[Solved] pyUNO PageStyle Left and Right

The Application Programming Interface and the OASIS Open Document Format

[Solved] pyUNO PageStyle Left and Right

Postby beranger » Tue Nov 05, 2013 6:32 pm

Hello ,

I'm using pyUNo in order to edit a document automaticately. I'm doing a lot of things but i have a problem. I create header and footer but I need to change footer on each page ( Right Page and Left Page)
This is why i create footer/header left and right like this :
Code: Select all   Expand viewCollapse view
        pageStyle = doc.getStyleFamilies().getByName("PageStyles")
        propertySetLeft = pageStyle.getByName("Left Page")
   propertySetRight= pageStyle.getByName("Right Page")
   propertySetLeft.setPropertyValue("HeaderIsOn", True)
   propertySetRight.setPropertyValue("HeaderIsOn", True)
   propertySetLeft.setPropertyValue("FooterIsOn", True)
   propertySetRight.setPropertyValue("FooterIsOn", True)

   headerCursorRight = headerTextRight.createTextCursor()
   headerCursorLeft = headerTextLeft.createTextCursor()

   FooterTextRight = propertySetRight.getPropertyValue("FooterTextRight")
   FooterTextLeft = propertySetLeft.getPropertyValue("FooterTextLeft")
   FooterCursorRight = FooterTextRight.createTextCursor()
   FooterCursorLeft = FooterTextLeft.createTextCursor()

   PN = doc.createInstance("com.sun.star.text.textfield.PageNumber")
   PC = doc.createInstance("com.sun.star.text.textfield.PageCount")
   Logo_OO=doc.createInstance( "com.sun.star.text.TextGraphicObject" )
   Logo_OO.AnchorType = "AT_PARAGRAPH"
   Logo_OO.GraphicURL = "file:///home/beranger/Documents/FE_Rapport/logo_OO.png"
   Logo_OO.SurroundAnchorOnly = False

   headerTextRight.insertString(headerCursorRight,"Un truc à inclure dans le header Right", False)
   headerTextLeft.insertString(headerCursorLeft,"Un truc à inclure dans le header left", False)

   FooterTextRight.insertTextContent(FooterCursorRight, Logo_OO, False )

   FooterTextLeft.insertTextContent(FooterCursorLeft,PN, False)
   FooterTextLeft.insertString(FooterCursorLeft,"/", False)
   FooterTextLeft.insertTextContent(FooterCursorLeft,PC, False)

It's works when on openoffice I define each page as LeftPage or Right Page, but i cant do that for all pages... just after compilation each Page have Standard style.
Do you have a solution in order to associate each Right page ( number 0 ,2 ,4 ,6 ...) to RightPage style and Left Page ( 1, 3,5,7...) to left page style ?
Last edited by beranger on Tue Dec 03, 2013 4:16 pm, edited 2 times in total.
Beranger Openoffice 2.4
Posts: 10
Joined: Tue Nov 05, 2013 6:20 pm

Re: pyUNO PageStyle Left and Right

Postby F3K Total » Sat Nov 16, 2013 11:02 am

you need to set the FollowStyle Left Page -> Right Page -> Left Page ...

Code: Select all   Expand viewCollapse view
       propertySetLeft = pageStyle.getByName("Left Page")
       propertySetLeft.FollowStyle = ("Right Page")
       propertySetRight= pageStyle.getByName("Right Page")
       propertySetRight.FollowStyle = ("Left Page")

    MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
    my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
F3K Total
Posts: 989
Joined: Fri Dec 16, 2011 8:20 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests