On 4/14/05, Niklas Nebel <[EMAIL PROTECTED]> wrote:
> Kohei Yoshida wrote:
> > When I try to create a service object
> > "com.sun.star.text.textfield.PageNumber" from the SpreadsheetDocument,
> > I get an "NoSuchServiceRegistered" (or something similar) exception.
> > So, I'm at a loss on getting a page number object to insert into an
> > XHeaderFooterContent object.
> 
> It's "com.sun.star.text.TextField.PageNumber" (note the capital
> letters). Documentation and reality differ here. There has been issue
> 13121, which is marked as "fixed", but I'm not really sure what the
> resolution is.

Yup.  The capitalized name worked.  Thanks for your help. :-)

For everyone's benefit, let me just post the following Basic code as
an example of inserting a page number and a page count into a
header/footer of a Calc document.

sub setPageNumber

        oDoc = ThisComponent
        oStyles = oDoc.getStyleFamilies().getByName( "PageStyles" )
        oPStyle = oStyles.getByName( "Default" )
        oPageNumber = oDoc.createInstance( 
"com.sun.star.text.TextField.PageNumber" )
        oPageCount  = oDoc.createInstance( 
"com.sun.star.text.TextField.PageCount" )
        oFooter = oPStyle.RightPageFooterContent
        oFooter.getLeftText().setString( "Test" )
        oFooter.getRightText().setString( "Page " )
        oCursor = oFooter.getRightText().createTextCursor()
        oCursor.gotoEnd( False )
        oFooter.getRightText().insertTextContent( oCursor, oPageNumber, True )
        oCursor.gotoEnd( False )
        oCursor.setString( " of " )
        oCursor.gotoEnd( False )
        oFooter.getRightText().insertTextContent( oCursor, oPageCount, True )
        oPStyle.RightPageFooterContent = oFooter
        
end sub


Kohei

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to