| 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.beans.XPropertySet; |
| 10 |
import com.sun.star.lang.XServiceInfo; |
| 11 |
import com.sun.star.uno.UnoRuntime; |
| 12 |
import com.sun.star.frame.XModel; |
| 13 |
import com.sun.star.container.XEnumeration; |
| 14 |
import com.sun.star.container.XEnumerationAccess; |
| 15 |
|
| 16 |
import com.sun.star.text.XTextDocument; |
| 17 |
import com.sun.star.text.XText; |
| 18 |
|
| 19 |
oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext()); |
| 20 |
if ( oDoc == null ) |
| 21 |
oDoc = XSCRIPTCONTEXT.getDocument(); |
| 22 |
|
| 23 |
xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc); |
| 24 |
xText = xTextDoc.getText(); |
| 25 |
XEnumerationAccess xEnumAcc = (XEnumerationAccess)(UnoRuntime.queryInterface(XEnumerationAccess.class, xText)); |
| 26 |
XEnumeration xEnum = xEnumAcc.createEnumeration(); |
| 27 |
while (xEnum.hasMoreElements()) { |
| 28 |
Object xObj = xEnum.nextElement(); |
| 29 |
XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xObj); |
| 30 |
if (xServiceInfo.supportsService("com.sun.star.text.Paragraph")) { |
| 31 |
XPropertySet xSet = UnoRuntime.queryInterface(XPropertySet.class, xServiceInfo ); |
| 32 |
// Set the justification to be center justified |
| 33 |
xSet.setPropertyValue( "ParaAdjust", com.sun.star.style.ParagraphAdjust.CENTER ); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
return 0; |