Hi Jörg. This is probably not exactly your question but if you want to copy styles from one document to another one, the function "loadStylesFromURL" is very useful.
Sorry, this is Python code.

            url = ... # your template document URL
            try:
                ppp = createUnoStruct("com.sun.star.beans.PropertyValue")
ppp.Name = "OverwriteStyles" # we don't want to ovewrite the existing styles with similar names
                ppp.Value = False
res = xModel.getStyleFamilies().loadStylesFromURL(url, (ppp,))
            except:
                pass

Regards,

Marie

Le 04/01/2015 08:14, Jörg Schmidt a écrit :
From: Oliver Brinzing [mailto:oliver.brinz...@gmx.de]
Sent: Saturday, January 03, 2015 10:00 AM
To: api@openoffice.apache.org
Subject: Re: copy an existing style

Hi Jörg,

or try to set the parent style:

newStyle.ParentStyle = oldStyle.Name
oStyles.insertByName("myNewStyle", newStyle)

so newStyle inherits all properties from oldStyle
that's very interesting, the following works here:

oStyles = ThisComponent.StyleFamilies.getByName("ParagraphStyles")
        oldStyle = 
ThisComponent.getStyleFamilies.getByName("ParagraphStyles").getByName("jms1")
        newStyle = 
ThisComponent.CreateInstance("com.sun.star.style.ParagraphStyle")
        newStyle.ParentStyle = oldStyle.Name
        oStyles.insertByName("jms2", newStyle)


But it is not so very helpful, because copying a template within a document is 
only a test, my true goal is to copy a template between two documents.



Greetings,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
For additional commands, e-mail: api-h...@openoffice.apache.org

Reply via email to