ChangeFont.bsh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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. import com.sun.star.beans.XPropertySet;
  9. import com.sun.star.lang.XServiceInfo;
  10. import com.sun.star.uno.UnoRuntime;
  11. import com.sun.star.frame.XModel;
  12. import com.sun.star.container.XEnumeration;
  13. import com.sun.star.container.XEnumerationAccess;
  14. import com.sun.star.text.XTextDocument;
  15. oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext());
  16. if ( oDoc == null )
  17. oDoc = XSCRIPTCONTEXT.getDocument();
  18. xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);
  19. xText = xTextDoc.getText();
  20. XEnumerationAccess xEnumAcc = (XEnumerationAccess)(UnoRuntime.queryInterface(XEnumerationAccess.class, xText));
  21. XEnumeration xEnum = xEnumAcc.createEnumeration();
  22. while (xEnum.hasMoreElements()) {
  23. Object xObj = xEnum.nextElement();
  24. XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xObj);
  25. if (xServiceInfo.supportsService("com.sun.star.text.Paragraph")) {
  26. XPropertySet xSet = UnoRuntime.queryInterface(XPropertySet.class, xServiceInfo );
  27. xSet.setPropertyValue( "CharHeight", 28 );
  28. xSet.setPropertyValue( "CharFontName", "Liberation Sans" );
  29. }
  30. }
  31. return 0;