Re: copy an existing style

2015-01-07 Thread Oliver Brinzing

Hi Jörg,

 Using the following code will _not_ transfer the setting
position-at (in a german AOO Position-bei) of an numbering style.

i think you have to iterate over the NumberingRules Objects and Copy it's 
properties

For j = 0 To oPStyle.NumberingRules.getCount()-1
mArray() =oPStyle.NumberingRules.getByIndex(j)
...
Next j

Regards
Oliver





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



Re: copy an existing style

2015-01-06 Thread Jörg Schmidt
Hello, 

 From: Jörg Schmidt [mailto:joe...@j-m-schmidt.de] 

 Thank You. The following works for me:
 
 Sub Vorlage_kopieren()
 ...

I use the same for numberingstyles it does not work properly.

Using the following code will _not_ transfer the setting position-at (in a 
german AOO Position-bei) of an numbering style. 

Sub Vorlage_kopieren()

On Local Error Goto ErrorHandler

Dim oDocument as Object
Dim oSheet as Object
Dim oPStyle as Object
Dim oStyles as Object
Dim oCpyStyle as Object
Dim aProperties as Object
Dim vTmp as Variant
Dim sCopy as String
Dim sX as String
Dim i as Integer

oDocument = ThisComponent

oStyles = oDocument.StyleFamilies.getByName(NumberingStyles)
oPStyle = oStyles.getByName(jms1)

sCopy = jms2

oCpyStyle = 
oDocument.createInstance(com.sun.star.style.NumberingStyle)

If oStyles.hasByName(sCopy) Then
oStyles.removeByName(sCopy)
EndIf

oStyles.insertByName(sCopy, oCpyStyle)  

aProperties = oPStyle.PropertySetInfo.Properties

'XrayTool.XRAY(oPStyle)

For i = LBound(aProperties) to UBound(aProperties)
sX = aProperties(i).Name
'kk = kk  aProperties(i).Name  |
If Not IsNull(sX) Then
If sX   Then
If oPStyle.getPropertyState(sX) = 
com.sun.star.beans.PropertyState.DIRECT_VALUE Then
vTmp = oPStyle.getPropertyValue(sX)
oCpyStyle.setPropertyValue(sX, vTmp)
EndIf
EndIf
EndIf
Next i
'Msgbox kk
Exit Sub
ErrorHandler:
msgbox Erl  |  Error  |  Err
Resume Next
End Sub


Greetings,
Jörg


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



Re: copy an existing style

2015-01-04 Thread Oliver Brinzing

Hi,

   res = xModel.getStyleFamilies().loadStylesFromURL(url, (ppp,))

yes,  XStyleLoader should work in general but there are some limitations,
for example:

https://issues.apache.org/ooo/show_bug.cgi?id=75048
XStyleLoader - user defined number formats are not imported

Regards
Oliver



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



Re: copy an existing style

2015-01-03 Thread Oliver Brinzing

Hi Jörg,


the_style = 
ThisComponent.getStyleFamilies.getByName(ParagraphStyles).getByName(jms1)
ThisComponent.getStyleFamilies.getByName(ParagraphStyles).insertByName(jms3, 
the_style)


i think you have to copy all Properties from old to new style.
this should work for Pagestyles:


REM  *  BASIC  *
OPTION EXPLICIT

Sub PageStyle

On Local Error Goto ErrorHandler

Dim oDocument as Object
Dim oSheet as Object
Dim oPStyle as Object
Dim oStyles as Object
Dim oCpyStyle as Object
Dim aProperties as Object
Dim vTmp as Variant
Dim sCopy as String
Dim sX as String
Dim i as Integer

oDocument = ThisComponent
oSheet = oDocument.getSheets.getByIndex(0)

oStyles = oDocument.StyleFamilies.getByName(PageStyles)
oPStyle = oStyles.getByName(Default)

sCopy = NewStyle

oCpyStyle = oDocument.createInstance(com.sun.star.style.PageStyle)

If oStyles.hasByName(sCopy) Then
oStyles.removeByName(sCopy)
EndIf

oStyles.insertByName(sCopy, oCpyStyle)  
oSheet.PageStyle = oCpyStyle.Name   

aProperties = oPStyle.PropertySetInfo.Properties

For i = LBound(aProperties) to UBound(aProperties)
sX = aProperties(i).Name
If Not IsNull(sX) Then
If sX   Then
If oPStyle.getPropertyState(sX) = 
com.sun.star.beans.PropertyState.DIRECT_VALUE Then
vTmp = oPStyle.getPropertyValue(sX)
oCpyStyle.setPropertyValue(sX, vTmp)
EndIf
EndIf
EndIf
Next i
Exit Sub
ErrorHandler:
msgbox Erl  Error  Err
Resume Next
End Sub


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



Re: copy an existing style

2015-01-03 Thread Oliver Brinzing

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

Regards
Oliver

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



Re: copy an existing style

2015-01-03 Thread Jörg Schmidt
 From: Oliver Brinzing [mailto:oliver.brinz...@gmx.de] 

 i think you have to copy all Properties from old to new style.
 this should work for Pagestyles:
 
 
 REM  *  BASIC  *
 OPTION EXPLICIT
 
 Sub PageStyle
 [...]

Thank You. The following works for me:

Sub Vorlage_kopieren()

On Local Error Goto ErrorHandler

Dim oDocument as Object
Dim oSheet as Object
Dim oPStyle as Object
Dim oStyles as Object
Dim oCpyStyle as Object
Dim aProperties as Object
Dim vTmp as Variant
Dim sCopy as String
Dim sX as String
Dim i as Integer

oDocument = ThisComponent

oStyles = oDocument.StyleFamilies.getByName(ParagraphStyles)
oPStyle = oStyles.getByName(jms1)

sCopy = jms2

oCpyStyle = 
oDocument.createInstance(com.sun.star.style.ParagraphStyle)

If oStyles.hasByName(sCopy) Then
oStyles.removeByName(sCopy)
EndIf

oStyles.insertByName(sCopy, oCpyStyle)  

aProperties = oPStyle.PropertySetInfo.Properties

For i = LBound(aProperties) to UBound(aProperties)
sX = aProperties(i).Name
If Not IsNull(sX) Then
If sX   Then
If oPStyle.getPropertyState(sX) = 
com.sun.star.beans.PropertyState.DIRECT_VALUE Then
vTmp = oPStyle.getPropertyValue(sX)
oCpyStyle.setPropertyValue(sX, vTmp)
EndIf
EndIf
EndIf
Next i
Exit Sub
ErrorHandler:
msgbox Erl  |  Error  |  Err
Resume Next
End Sub


Greetings,
Jörg


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



Re: copy an existing style

2015-01-03 Thread Jörg Schmidt
 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