Modifying textfield font attributes via Basic macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
PairOdachs
Posts: 31
Joined: Mon Aug 11, 2008 1:10 pm

Modifying textfield font attributes via Basic macro

Post by PairOdachs »

Is it possible to programatically (via Basic macro) change the font attributes (e.g., bold, italics) of a textbox created in the Dialog editor? If so, (a) please point me to an example, (b) please point me to the API documentation, and (c) pretty, pretty please tell me the logic that you used to figure out how to do it (I feel like I'm in a Macro/Dialog noob information maze).
OOo 3.4.1 on Mac OS X 10.6.8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Modifying textfield font attributes via Basic macro

Post by hanya »

a:

Code: Select all

Sub DialogTest
  d = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
  oFieldModel = d.getControl("TextField1").getModel()
  oFieldModel.FontWeight = com.sun.star.awt.FontWeight.BOLD
  oFieldModel.FontSlant = com.sun.star.awt.FontSlant.ITALIC
  d.execute()
  d.dispose()
End Sub
b: http://www.openoffice.org/api/docs/comm ... Model.html
Property values starting with "Font" are not listed in the document, they are generated from member of css.awt.FontDescriptor.
c: http://wiki.openoffice.org/wiki/Documen ... /UNO_Tools
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Post Reply