pyuno question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pyuno question

Martin Kaufmann-3
Hi,

I am a newbe in pyuno and like to modify the example

http://udk.openoffice.org/python/samples/swritercomp.py

in such a way, that the page format is landscape (and not portrait).

Can anybody help me with that? I really feel a bit lost with the documentation...

Thanks a lot and best wishes,

Martin

 
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: pyuno question

Fernand Vanrie
Martin ,
do not kwow pyuno but its similar to basic:

Note the landscape page MUST use a different page style then the
portrait pages. Each page style contains a* IsLandscape* property. You
want to insert a page break and change the page style name on the new page

the code must been like

Sub test()
    Dim oServiceManager As Object
    Dim oDesktop As Object
    Dim oDocument As Object
    Dim oText
    Dim oCursor
    Dim oNewStyle
    Dim Args()
    Dim s
    Dim oStyle
   

 
    Set oServiceManager = CreateObject("com.sun.star.ServiceManager")
    Set oDesktop =
oServiceManager.createInstance("com.sun.star.frame.Desktop")
    Set oDocument =
oDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, Args)
    Set oText = oDocument.GetText
    Set oCursor = oText.createTextCursor
   
    'Insert the page break
    oText.insertControlCharacter oCursor, 0, False
    oCursor.BreakType = 4
    oCursor.gotoEnd False
   
    'getting the old style
    s = oCursor.PageStyleName
    Set oStyle =
oDocument.StyleFamilies.getByName("*PageStyles*").getByName(s)
 
    'creating the new style
    Set oNewStyle =
oDocument.createInstance("com.sun.star.style.PageStyle")
    'Setting the lanscape property to true
    oNewStyle.setPropertyValue "IsLandscape", True
    oNewStyle.setPropertyValue "Width", oStyle.Height
    oNewStyle.setPropertyValue "Height", oStyle.Width

    'Adding the new style to pagestyle family
    oDocument.StyleFamilies.getByName("*PageStyles*").insertByName
"LandscapeStyle", oNewStyle
   
    'setting the PageStyleName to the *landscape* pagestyle
    oCursor.setPropertyValue "PageDescName", "LandscapeStyle"

end sub
hope it helps


Fernand
   






> Hi,
>
> I am a newbe in pyuno and like to modify the example
>
> http://udk.openoffice.org/python/samples/swritercomp.py
>
> in such a way, that the page format is landscape (and not portrait).
>
> Can anybody help me with that? I really feel a bit lost with the documentation...
>
> Thanks a lot and best wishes,
>
> Martin
>
>  
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]