another problem with not evident solution: insert page numbers into a new document's footer. After reading lots of manuals and (fortunately) some forum code sheets, I came to the following:
Code: Select all
from com.sun.star.text.PageNumberType import PREV as PAGING_PREV, CURRENT as PAGING_CURRENT, NEXT as PAGING_NEXT
from com.sun.star.style.NumberingType import ARABIC
from com.sun.star.style.ParagraphAdjust import RIGHT as PARA_ADJUST_RIGHT, LEFT as PARA_ADJUST_LEFT
...
addpages_doc = self.desktop.loadComponentFromURL(not_paged_doc_url, "_default", 0, ())
addpages_doc.StyleFamilies.PageStyles.Standard.FooterIsOn = True # after setting it to True "FooterText" appears magically in addpages_doc.StyleFamilies.PagesStyles.Standard
addpages_doc.StyleFamilies.PageStyles.Standard.FooterHeight = 1000
addpages_doc.StyleFamilies.PageStyles.Standard.FirstIsShared = False # to remove numbering from the title page
# the very page number we'll use
page_numbering = addpages_doc.createInstance("com.sun.star.text.textfield.PageNumber")
page_numbering.NumberingType = ARABIC
page_numbering.Offset = 0
page_numbering.SubType = PAGING_CURRENT
# was not easy to find
footer = addpages_doc.StyleFamilies.PageStyles.Standard.FooterText
footer_cursor = footer.createTextCursor()
footer_cursor.gotoEnd(False)
footer_cursor.ParaAdjust = PARA_ADJUST_RIGHT
# footer_cursor.CharHeight = 10 # commented properties do not work somewhy
# footer_cursor.CharFontName = 'verdana'
# footer_cursor.CharColor = 0x7f0000 # dark red
# footer_cursor.CharPosture = ITALIC
# footer_cursor.CharWeight = FW_BOLD
footer.insertTextContent(footer_cursor, page_numbering, False)
save_arg = PropertyValue(Name="Overwrite", Value=True)
addpages_doc.storeToURL(paged_doc_url, (save_arg,))
The posts I read before creating my code are: viewtopic.php?f=44&t=71155 and viewtopic.php?f=44&t=89998 .