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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

More Than Just Text 117<br />

Dim TextField As Object<br />

Dim I As Integer<br />

Doc = StarDesktop.CurrentComponent<br />

TextFieldEnum = Doc.getTextFields.createEnumeration<br />

While TextFieldEnum.hasMoreElements()<br />

TextField = TextFieldEnum.nextElement()<br />

If TextField.supportsService("com.sun.star.text.textfield.DateTime")<br />

Then<br />

MsgBox "Date/time"<br />

ElseIf<br />

TextField.supportsService("com.sun.star.text.textfield.Annotation")<br />

Then<br />

MsgBox "Annotation"<br />

Else<br />

MsgBox "unknown"<br />

End If<br />

Wend<br />

The starting point for establishing the text fields present is the TextFields list of the<br />

document object. The example creates an Enumeration object on the basis of this list, with<br />

which all text fields can be queried in turn in a loop. The text fields found are checked for<br />

the service supported using the supportsService method. If the field proves to be a<br />

date/time field or an annotation, then the corresponding field type is displayed in an<br />

information box. If on the other hand, the example encounters another field, then it displays<br />

the information “unknown”.<br />

Below, you will find a list of the most important text fields and their associated properties.<br />

A complete list of all text fields is provided in the API reference in the<br />

com.sun.star.text.textfield module. (When listing the service name of a text field, uppercase<br />

and lowercase characters should be used in <strong>OpenOffice</strong>.<strong>org</strong> Basic, as in the previous<br />

example.)

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

Saved successfully!

Ooh no, something went wrong!