OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

set default font family en size of entire document

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
christopher23
General User
General User


Joined: 25 Feb 2010
Posts: 19

PostPosted: Tue Mar 23, 2010 6:00 am    Post subject: set default font family en size of entire document Reply with quote

Is it possible to set the entire document to one font family and size without having to redeclare it everytime you create a textcursor?
At the moment I need to do something like this everytime I need new text.

Code:
cursor = text.createTextCursor()
cursor.setPropertyValue("CharFontName", "Arial")   
cursor.setPropertyValue("CharHeight", 9)


Java and Basic examples are also welcome. hopefully this is possible
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 8995
Location: Lexinton, Kentucky, USA

PostPosted: Tue Mar 23, 2010 7:16 am    Post subject: Reply with quote

Code:
Sub Main
CtrlA_CtrlM() 'remove direct formatting with recorded macro
oDoc = ThisComponent
PS = oDoc.getStyleFamilies.getByName("ParagraphStyles")
For i = 0 to PS.Count-1
 thisPS = PS.getByIndex(i)
 If thisPS.isInUse then
  thisPS.CharFontName = "Tahoma"
  thisPS.CharHeight = 16
 EndIf
Next
End Sub

Sub CtrlA_CtrlM
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group