| View previous topic :: View next topic |
| Author |
Message |
Cosmic P OOo Enthusiast

Joined: 23 Mar 2005 Posts: 186
|
Posted: Sat May 19, 2007 8:53 am Post subject: OOo's StyleFamilies: how to access them? |
|
|
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 |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8980 Location: Lexinton, Kentucky, USA
|
Posted: Sat May 19, 2007 9:16 am Post subject: |
|
|
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 |
|
 |
Cosmic P OOo Enthusiast

Joined: 23 Mar 2005 Posts: 186
|
Posted: Sat May 19, 2007 9:39 am Post subject: |
|
|
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 |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Sat May 19, 2007 8:16 pm Post subject: |
|
|
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 |
|
 |
|