Debian Codegraph @

scripting/examples/beanshell/Writer/ChangeFont.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.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
18 oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext());
19 if ( oDoc == null )
20 oDoc = XSCRIPTCONTEXT.getDocument();
21
22 xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);
23 xText = xTextDoc.getText();
24 XEnumerationAccess xEnumAcc = (XEnumerationAccess)(UnoRuntime.queryInterface(XEnumerationAccess.class, xText));
25 XEnumeration xEnum = xEnumAcc.createEnumeration();
26 while (xEnum.hasMoreElements()) {
27 Object xObj = xEnum.nextElement();
28 XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xObj);
29 if (xServiceInfo.supportsService("com.sun.star.text.Paragraph")) {
30 XPropertySet xSet = UnoRuntime.queryInterface(XPropertySet.class, xServiceInfo );
31 xSet.setPropertyValue( "CharHeight", 28 );
32 xSet.setPropertyValue( "CharFontName", "Liberation Sans" );
33 }
34 }
35
36 return 0;