Stephan Wunderlich ha scritto:
Hi Bart
Hi Stephan,

as far as I know it is not possible to insert a style that is "bound" to one document into another in the way you tried.

What you could do is create a new style with the same name if you like in the new document and then loop over all properties in your original style and set them accordingly in your new style.

Thanks, very usefull... loop over all properties is a good idea.

Moreover I found an old post (2003) signed by Oliver Brinzing that use the loop for write the pageStyle.

Cut and paste e voilĂ  the code for copy a page_style from a document, and write it to another document.

regards

Bart

--------------------------------------------
(NB The code must be in a shared library)

'**************************************************

SUB Copy_PageStyle '  execute fron source doc.sheet
oSheet = ThisComponent.Sheets.getByName(_
ThisComponent.currentcontroller.activesheet.name)
sStile_Pag = oSheet.PageStyle 'nome dello stile corrente
            ' sulla sheet sorgente
oDesktop = createUnoService( "com.sun.star.frame.Desktop")
oController = oDesktop.CurrentFrame.Controller
oDocument = oController.Model
oStyleFam = oDocument.StyleFamilies
oTablePageStyles = oStyleFam.getbyName("PageStyles")
oAktPage = oTablePageStyles.getByname(sStile_Pag)
aProperties = oAktPage.PropertySetInfo.Properties
END SUB


SUB Write_PageStyle ' execute from target doc.sheet
oSheet = ThisComponent.Sheets.getByName(_
ThisComponent.currentcontroller.activesheet.name)
oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
oController = oDesktop.CurrentFrame.Controller
oDocument = oController.Model
oStyleFam = oDocument.StyleFamilies
oTablePageStyles = oStyleFam.getbyName("PageStyles")
oCpyStyle = oDocument.createInstance("com.sun.star.style.PageStyle")
oTablePageStyles.insertByName(sStile_Pag, oCpyStyle)
aProperties =  oAktPage.PropertySetInfo.Properties
For i = LBound(aProperties) to UBound(aProperties)
    sX = aProperties(i).Name
    If  oAktPage.getPropertyState(sX) =
com.sun.star.beans.PropertyState.DIRECT_VALUE Then
        vTmp =  oAktPage.getPropertyValue(sX)
        oCpyStyle.setPropertyValue(sX, vTmp)
    EndIf
Next i
END SUB

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to