21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Formatting Spreadsheet Documents 145<br />

com.sun.star.sheet.HeaderFooterContent<br />

service)<br />

RightPageFooterContent (Object)<br />

content of footers for odd pages (<br />

com.sun.star.sheet.HeaderFooterContent<br />

service)<br />

If you do not need to distinguish between headers or footers for odd and even pages (the<br />

FooterIsShared property is False), then set the properties for headers and footers on odd<br />

pages.<br />

All the named objects return an object that supports the<br />

com.sun.star.sheet.HeaderFooterContent<br />

service. By means of the (non-genuine) properties LeftText, CenterText, and RightText, this<br />

service provides three text elements for the headers and footers of <strong>OpenOffice</strong>.<strong>org</strong> Calc.<br />

The following example writes the "Just a Test." value in the left-hand text field of the header<br />

from the "Default" template.<br />

Dim Doc As Object<br />

Dim Sheet As Object<br />

Dim StyleFamilies As Object<br />

Dim PageStyles As Object<br />

Dim DefPage As Object<br />

Dim HText As Object<br />

Dim HContent As Object<br />

Doc = StarDesktop.CurrentComponent<br />

StyleFamilies = Doc.StyleFamilies<br />

PageStyles = StyleFamilies.getByName("PageStyles")<br />

DefPage = PageStyles.getByName("Default")<br />

DefPage.HeaderIsOn = True<br />

HContent = DefPage.RightPageHeaderContent<br />

HText = HContent.LeftText<br />

HText.String = "Just a Test."<br />

DefPage.RightPageHeaderContent = HContent<br />

Note the last line in the example: Once the text is changed, the TextContent object must be<br />

assigned to the header again so that the change is effective.<br />

Another mechanism for changing the text of headers and footers is available for text<br />

documents (<strong>OpenOffice</strong>.<strong>org</strong> Writer) because these consist of a single block of text. The<br />

following properties are defined in the<br />

com.sun.star.style.PageProperties

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!