OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The Structure of Text Documents 96<br />
Default values for character and paragraph properties<br />
Direct formatting always takes priority over indirect formatting. In other words,<br />
formatting using templates is assigned a lower priority than direct formatting in a text.<br />
Establishing whether a section of a document has been directly or indirectly formatted is<br />
not easy. The symbol bars provided by <strong>OpenOffice</strong>.<strong>org</strong> show the common text properties<br />
such as font type, weight and size. However, whether the corresponding settings are based<br />
on template or direct formatting in the text is still unclear.<br />
<strong>OpenOffice</strong>.<strong>org</strong> Basic provides the getPropertyState method, with which programmers can<br />
check how a certain property was formatted. As a parameter, this takes the name of the<br />
property and returns a constant that provides information about the origin of the<br />
formatting. The following responses, which are defined in the<br />
com.sun.star.beans.PropertyState<br />
enumeration, are possible:<br />
the property is defined directly in the text (direct formatting)<br />
the property is defined by a template (indirect formatting)<br />
the property is unclear. This status arises, for example, when querying the bold type<br />
property of a paragraph, which includes both words depicted in bold and words<br />
depicted in normal font.<br />
The following example shows how format properties can be edited in <strong>OpenOffice</strong>.<strong>org</strong>. It<br />
searches through a text for paragraph portions which have been depicted as bold type<br />
using direct formatting. If it encounters a corresponding paragraph portion, it deletes the<br />
direct formatting using the setPropertyToDefault method and assigns a MyBold character<br />
template to the corresponding paragraph portion.<br />
Dim Doc As Object<br />
Dim Enum1 As Object<br />
Dim Enum2 As Object<br />
Dim TextElement As Object<br />
Dim TextPortion As Object<br />
Doc = StarDesktop.CurrentComponent<br />
Enum1 = Doc.Text.createEnumeration<br />
' loop over all paragraphs<br />
While Enum1.hasMoreElements<br />
TextElement = Enum1.nextElement<br />
Then<br />
If TextElement.supportsService("com.sun.star.text.Paragraph")<br />
Enum2 = TextElement.createEnumeration<br />
' loop over all paragraph portions<br />
While Enum2.hasMoreElements