Debian Codegraph @

scripting/examples/beanshell/Calc/InsertSheet.bsh

raw
1 /*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9 import com.sun.star.uno.UnoRuntime;
10 import com.sun.star.frame.XModel;
11 import com.sun.star.sheet.XSpreadsheetDocument;
12 import com.sun.star.sheet.XSpreadsheets;
13 import com.sun.star.lang.XMultiServiceFactory;
14
15 oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext());
16 if ( oDoc == null )
17 oDoc = XSCRIPTCONTEXT.getDocument();
18
19 XSpreadsheetDocument xDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class,oDoc);
20 XSpreadsheets xSheets = xDoc.getSheets();
21
22 xSheets.insertNewByName("First new sheet", (short)0);
23 xSheets.insertNewByName("Second new sheet", (short)1);
24
25 return 0;