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

OOo's StyleFamilies: how to access them?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Sat May 19, 2007 8:53 am    Post subject: OOo's StyleFamilies: how to access them? Reply with quote

How can I access the StyleFamilies defined within OpenOffice.org? By that I mean those that are not restricted to a certain document.

A document's StyleFamilies can be accessed with

Code:
ThisComponent.StyleFamilies


The following didn't work

Code:
StarDesktop.StyleFamilies
StarDesktop.getStyleFamilies()


GlobalScope didn't work either (which is what I expected).
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


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

PostPosted: Sat May 19, 2007 9:16 am    Post subject: Reply with quote

I don't know what you want to do but perhaps this will get you started.
Code:
Sub StyleFamilies
Dim oSF,oPS,aray,c
oSF = ThisComponent.getStyleFamilies
oPS = oSF.getByName("ParagraphStyles")
aray = oPS.getElementNames
For c = 0 to uBound(aray)
 Print aray(c)
Next
End Sub
Back to top
View user's profile Send private message
Cosmic P
OOo Enthusiast
OOo Enthusiast


Joined: 23 Mar 2005
Posts: 186

PostPosted: Sat May 19, 2007 9:39 am    Post subject: Reply with quote

That gives me access to the document's StyleFamilies, which is not what I wanted.

I want to create a macro that can load styles (or style definitions) from a document on the server and install those on the computer's hard disc, so that they can always be used.

I can load the styles from one document and insert them into another with the following code:

Code:

   Dim oDocStyles as Object, sURL as String
   
   Dim arg(0) as new com.sun.star.beans.PropertyValue
   arg(0).Name = "OverwriteStyles"
   arg(0).Value = True
   
   oDocStyles = ThisComponent.StyleFamilies
   sURL = "file:///$path/styles.odt"
   oDocStyles.loadStylesFromURL(sURL, arg())


But as I said, with this I can only install them into the present document.
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Sat May 19, 2007 8:16 pm    Post subject: Reply with quote

Available styles are related to each document. If I change a style in one document, it is not seen in another. You can not easily make the styles available for existing documents, but you can modify the "default" document to contain these styles. A better solution, however, is to create a custom template as you desire. If you crfeate a document from a template, then you can later change teh template and have the styles applied to existing documents created from that template.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
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