Page m of n in footer reverts to default style
Posted: Tue Mar 05, 2019 7:14 pm
I've just had LibreOffice upgraded, and a macro no longer works quite right. As part of reformatting a document it puts "Page m of n" in small print in the footer. It still does this, but now only the word "Page" appears in the small print, while the " of " and the two variable numbers have reverted to the default font and size. The relevant code is:
The four text inserts are consecutive, as you see. Why has it changed format after the first one?
Edited: Didn't notice pageno and pagect were my own variable names, so I've added their definitions.
Code: Select all
FTR_FONT = "Calibri"
FTR_SIZE = 8
' Short names for stupidly named things
kARABIC = com.sun.star.style.NumberingType.ARABIC
kPAGENO = "com.sun.star.text.textfield.PageNumber"
kPAGECT = "com.sun.star.text.textfield.PageCount"
' . . .
cur4 = style.footertext.text.createtextcursor
cur4.charfontname = FTR_FONT
cur4.charheight = FTR_SIZE
' . . .
pageno = doc.createinstance(kPAGENO)
pageno.numberingtype = kARABIC ' default is A, B, C ...!
pageno.subtype = 1 ' subtype 1 = use current page no.
pagect = doc.createinstance(kPAGECT)
pagect.numberingtype = kARABIC
style.footertext.text.insertstring(cur4, chr(9) & "page ", 0) ' 9 = tab
style.footertext.text.inserttextcontent(cur4, pageno, 0)
style.footertext.text.insertstring(cur4, " of ", 0)
style.footertext.text.inserttextcontent(cur4, pagect, 0)
Edited: Didn't notice pageno and pagect were my own variable names, so I've added their definitions.