[dev] How do I use the API to insert fields and change font size in a spreadsheet footer

2008-01-21 Thread Dave Cawley
I want my program to control spreadsheet footer contents.
In particular I want to be able to set the font size and use PageNumber and 
PageCount fields.
If I use the scalc GUI to set the footer contents and then interrogate the 
contents programatically, I see text values such as

 8This text is set to fontsize 8
and
 Page P of N

Clearly the  character introduces a code that controls font size or is a 
placeholder for a field such as the page number.

However, if I set the content of footer text to strings with this format 
there is no interpretation of the  codes and I see the exact text that I 
set into the footer, e.g. the footer displays as 'Page P of N' instead of 
'Page 1 of 3'.

On studying the Developers Guide I wondered if I needed to create a 
'com.sun.star.text.textfield.PageNumber' object and insert it into the 
footer text.
However, I can find no way to create the pagenumber object.
Code such as
  Dim field As Object = 
doc.createInstance(com.sun.star.text.textfield.PageNumber)
results in a  'com.sun.star.lang.ServiceNotRegisteredException:'

Please can someone give me a clue how to proceed? 




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



Re: [dev] How do I use the API to insert fields and change font size in a spreadsheet footer

2008-01-21 Thread Oliver Brinzing

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Dave,

Am 21.01.2008 11:45 schrieb Dave Cawley:
| I want my program to control spreadsheet footer contents.
| In particular I want to be able to set the font size and use PageNumber and
| PageCount fields.

please have a look ...

REM  *  BASIC  *

OPTION EXPLICIT

Sub CreateHeaderText()

Dim oDocument as Object
Dim oPStyle as Object
Dim oHContent as Object
Dim oText as Object
Dim oCursor as Object
Dim oField as Object

oDocument = ThisComponent
oPstyle = 
oDocument.StyleFamilies.getByName(PageStyles).getByName(Standard)

oPStyle.HeaderOn = True

oHContent = oPStyle.RightPageHeaderContent

oText = oHContent.LeftText
oCursor = oText.createTextCursor()

oText.insertString(oCursor, , True)

oCursor.CharHeight = 12
oCursor.CharFontName = Arial
oCursor.CharWeight = com.sun.star.awt.FontWeight.NORMAL
oCursor.CharPosture = com.sun.star.awt.FontSlant.NONE
oCursor.CharUnderline = com.sun.star.awt.FontUnderline.NONE

' insert text ...
oText.insertString(oCursor, Hello World , False)

~   ' PageNumber, PageCount, Date, Time
oField = 
oDocument.createInstance(com.sun.star.text.TextField.SheetName)
oText.insertTextContent(oCursor, oField, False)

'write content back
oPStyle.RightPageHeaderContent = oHContent

End Sub

HTH

Oliver
- --

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHlNfPTiyrQM/QSkURApIwAJ4rPeKrzXune4LCVRNa054nRrqMlgCeIxCQ
bZcW10p6vPmGKolMjLph2Rk=
=92km
-END PGP SIGNATURE-


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