| 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.lang.XMultiServiceFactory; |
| 12 |
|
| 13 |
import com.sun.star.text.XTextDocument; |
| 14 |
import com.sun.star.text.XText; |
| 15 |
import com.sun.star.text.XTextContent; |
| 16 |
import com.sun.star.text.XTextTable; |
| 17 |
|
| 18 |
oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext()); |
| 19 |
if ( oDoc == null ) |
| 20 |
oDoc = XSCRIPTCONTEXT.getDocument(); |
| 21 |
|
| 22 |
XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); |
| 23 |
Object oTab = xDocMSF.createInstance("com.sun.star.text.TextTable"); |
| 24 |
XTextTable xTextTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, oTab); |
| 25 |
xTextTable.initialize(4,3); // four rows, three columns |
| 26 |
xTextContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, xTextTable); |
| 27 |
|
| 28 |
xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc); |
| 29 |
xText = (XText) UnoRuntime.queryInterface(XText.class, xTextDoc.getText()); |
| 30 |
xText.insertTextContent(xText.getEnd(), xTextContent, false); |
| 31 |
|
| 32 |
return 0; |