python uno : the page number is blank on the first page

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

python uno : the page number is blank on the first page

Serge Noiraud
Hi,

I didn't found this subject in the faq, so I ask it.
I create a writer document and I'd like to have the page numbering.
It works except for the first page.
If I use PageNumberOffset to a value > 1, it works correctly.
If I set this to one or I don't set it, I have a blank number on the first page.
Do I forget something ?
Here is my sample :

# access the current writer document
model = desktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, ())
# access the document's text property
text = model.Text
# create a cursor
cursor = text.createTextCursor()
print "page syle : ", cursor.PageStyleName
cursor.setPropertyValue("PageNumberOffset", 1)
PageStyles = model.StyleFamilies.getByName("PageStyles")
StdPage = PageStyles.getByName("Standard")
StdPage.FooterIsOn = True
PageCount = model.createInstance("com.sun.star.text.textfield.PageCount")
PageCount.NumberingType = ARABIC
PageNumber = model.createInstance("com.sun.star.text.textfield.PageNumber")
PageNumber.NumberingType = ARABIC
FooterCursor = StdPage.FooterTextLeft.Text.createTextCursor()
StdPage.FooterTextLeft.Text.insertString(FooterCursor, "Page : ", False)
StdPage.FooterTextLeft.Text.insertTextContent(FooterCursor, PageNumber, False)
StdPage.FooterTextLeft.Text.insertString(FooterCursor, "/", False)
StdPage.FooterTextLeft.Text.insertTextContent(FooterCursor, PageCount, False)
FooterCursor.setPropertyValue("ParaAdjust", RIGHT);

I tried it on ubuntu karmic ( openoffice 3.1.1 ), ubuntu maverick ( 3.2.1 )
I always get the same problem.

--
Serge Noiraud
Linux, c'est mieux. Firefox, c'est mieux. LibreOffice, c'est mieux.

Développeur projet : http://www.gramps-project.org/

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

Reply | Threaded
Open this post in threaded view
|

Re: python uno : the page number is blank on the first page

Niklas Nebel-2
On 01/07/11 14:26, Serge Noiraud wrote:
> I didn't found this subject in the faq, so I ask it.
> I create a writer document and I'd like to have the page numbering.
> It works except for the first page.
> If I use PageNumberOffset to a value>  1, it works correctly.
> If I set this to one or I don't set it, I have a blank number on the first page.
> Do I forget something ?
> Here is my sample :

> PageNumber = model.createInstance("com.sun.star.text.textfield.PageNumber")
> PageNumber.NumberingType = ARABIC

You have to set the PageNumber field's SubType property to CURRENT.

For such general API questions, not specific to Python, the
[hidden email] list is a better place.

Niklas

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

Reply | Threaded
Open this post in threaded view
|

Re: python uno : the page number is blank on the first page

Serge Noiraud
Hi, Niklas,

Sorry for the delay, I was out of my office.

Le 07/01/2011 17:28, Niklas Nebel a écrit:

> On 01/07/11 14:26, Serge Noiraud wrote:
>> I didn't found this subject in the faq, so I ask it.
>> I create a writer document and I'd like to have the page numbering.
>> It works except for the first page.
>> If I use PageNumberOffset to a value>  1, it works correctly.
>> If I set this to one or I don't set it, I have a blank number on the
>> first page.
>> Do I forget something ?
>> Here is my sample :
>
>> PageNumber =
>> model.createInstance("com.sun.star.text.textfield.PageNumber")
>> PageNumber.NumberingType = ARABIC
>
> You have to set the PageNumber field's SubType property to CURRENT.
I already tried :
PageNumber.setPropertyValue("SubType", "com.sun.star.text.PageNumberType.CURRENT" )
it didn't work.
So I use now :
from com.sun.star.text.PageNumberType import CURRENT
PageNumber.SubType = CURRENT
and it works correctly.

>
> For such general API questions, not specific to Python, the
> [hidden email] list is a better place.
>
> Niklas
>


--
Serge Noiraud

Bull, Architect of an Open World (TM)
Visitez http://www.bull.com/fr/services/support-logiciel
Créez et suivez vos dossiers : http://support.bull.com 
Linux, c'est mieux. Firefox, c'est mieux. LibreOffice, c'est mieux.

Développeur projet : http://www.gramps-project.org/

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