How to copy all properties from a style

View: New views
5 Messages — Rating Filter:   Alert me  

How to copy all properties from a style

by Alan Yaniger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list-members,


I'm interested in duplicating a Writer paragraph style.

If I have the following code,

          ...

oFamilies = ThisComponent.StyleFamilies
oStyles = oFamilies.getByName("ParagraphStyles")
oldStyle = oStyles.getByIndex(1)

newStyle = ThisComponent.createInstance("com.sun.star.style.ParagraphStyle")


How do I assign to "newStyle" all the properties of "oldStyle"?


Thanks,

Alan


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: How to copy all properties from a style

by Bernard Marcelly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

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

Regards
   Bernard

Message de Alan Yaniger  date 2009-10-20 12:58 :

>
> oFamilies = ThisComponent.StyleFamilies
> oStyles = oFamilies.getByName("ParagraphStyles")
> oldStyle = oStyles.getByIndex(1)
>
> newStyle =
> ThisComponent.createInstance("com.sun.star.style.ParagraphStyle")
>
>
> How do I assign to "newStyle" all the properties of "oldStyle"?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: How to copy all properties from a style

by Alan Yaniger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Bernard,


Thank you very much for your help.


Alan


Bernard Marcelly wrote:

> Hi Alan,
>
> newStyle.ParentStyle = oldStyle.Name
> oStyles.insertByName("myNewStyle", newStyle)
>
> Regards
>   Bernard
>
> Message de Alan Yaniger  date 2009-10-20 12:58 :
>>
>> oFamilies = ThisComponent.StyleFamilies
>> oStyles = oFamilies.getByName("ParagraphStyles")
>> oldStyle = oStyles.getByIndex(1)
>>
>> newStyle =
>> ThisComponent.createInstance("com.sun.star.style.ParagraphStyle")
>>
>>
>> How do I assign to "newStyle" all the properties of "oldStyle"?
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: How to copy all properties from a style

by Laurent Godard-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi bernard

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

does it work with different spreadsheets ?
i'm not sure, i'll test when time but really not sure
actually, i loop on all properties. that is the quickest way i explored

Laurent




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: How to copy all properties from a style

by Michael Stahl-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Laurent Godard wrote:

> Hi bernard
>
>> newStyle.ParentStyle = oldStyle.Name
>> oStyles.insertByName("myNewStyle", newStyle)
>>
>
> does it work with different spreadsheets ?
> i'm not sure, i'll test when time but really not sure
> actually, i loop on all properties. that is the quickest way i explored
>
> Laurent

i would assume that setting a parent style only works if the parent style
actually exists in the same document as the newStyle.

furthermore, setting a parent style is different from simply copying all
the properties over: with a parent style, the new style is linked to the
parent, so a later change to the parent style will have an effect on the
child as well, which is not the case if you just copy properties.
this may or may not be what Alan wants.

michael

--
"Lisp for Dummies: An Introduction to Python"
 -- [Name withheld by request], proposed book title


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...