21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - 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.

The following example shows how the number of pages can be inserted into the footer of a document.<br />

Dim Doc As Object<br />

Dim DateTimeField As Object<br />

Dim PageStyles As Object<br />

Dim StdPage As Object<br />

Dim FooterCursor As Object<br />

Dim PageNumber As Object<br />

Doc = ThisComponent<br />

PageNumber = Doc.createInstance("com.sun.star.text.textfield.PageNumber")<br />

PageNumber.NumberingType = com.sun.star.style.NumberingType.ARABIC<br />

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

StdPage = PageStyles("Default")<br />

StdPage.FooterIsOn = True<br />

FooterCursor = StdPage.FooterTextLeft.Text.createTextCursor()<br />

StdPage.FooterTextLeft.Text.insertTextContent(FooterCursor, PageNumber, False)<br />

More Than Just Text<br />

The example first creates a text field which supports the com.sun.star.text.textfield.PageNumber service. Since the<br />

header and footer lines are defined as part of the page templates of <strong>OpenOffice</strong>.<strong>org</strong>, this is initially established<br />

using the list of all PageStyles.<br />

To ensure that the footer line is visible, the FooterIsOn property is set to True. The text field is then inserted in<br />

the document using the associated text object of the left-hand footer line.<br />

Annotations<br />

Annotation fields (com.sun.star.text.textfield.Annotation) can be seen by means of a small yellow symbol in the<br />

text. Clicking on this symbol opens a text field, in which a comment on the current point in the text can be<br />

recorded. An annotation field has the following properties.<br />

Author (String)<br />

name of author.<br />

Content (String)<br />

comment text.<br />

Date (Date)<br />

date on which annotation is written.<br />

Date / Time<br />

A date / time field (com.sun.star.text.textfield.DateTime) represents the current date or the current time. It<br />

supports the following properties:<br />

IsFixed (Boolean)<br />

if True, the time details of the insertion remain unchanged, if False, these are updated each time the<br />

document is opened.<br />

IsDate (Boolean)<br />

if True, the field displays the current date, otherwise the current time.<br />

DateTimeValue (struct)<br />

current content of field (com.sun.star.util.DateTime structure)<br />

NumberFormat (const)<br />

format in which the time or date is depicted.<br />

Chapter 6 · Text Documents 89

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

Saved successfully!

Ooh no, something went wrong!