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.

Doc = ThisComponent<br />

StyleFamilies = Doc.StyleFamilies<br />

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

For I = 0 To CellStyles.Count - 1<br />

CellStyle = CellStyles(I)<br />

MsgBox CellStyle.Name<br />

Next I<br />

Styles and Templates<br />

The loop added since the previous example displays the names of all cell styles one after another in a message<br />

box.<br />

Note – The reference CellStyles(I) corresponds to the method getByIndex(), which is optional for these<br />

style container objects. It may not be available in all types of documents. The method getByName() is<br />

mandatory, and should always be available.<br />

Details about various formatting options<br />

Each type of style provides a whole range of individual formatting properties. Here is an overview of the most<br />

important formatting properties and the points at which they are explained:<br />

Character properties,<br />

com.sun.star.style.CharacterProperties service<br />

Paragraph properties,<br />

com.sun.star.text.Paragraph service<br />

Cell properties,<br />

com.sun.star.table.CellProperties service<br />

Page properties,<br />

com.sun.star.style.PageProperties service<br />

Character element properties,<br />

Various services<br />

The format properties are by no means restricted to the applications in which these are explained, but instead can<br />

be used universally. For example, most of the page properties described in Spreadsheets can therefore be used not<br />

only in <strong>OpenOffice</strong>.<strong>org</strong> Calc, but also in <strong>OpenOffice</strong>.<strong>org</strong> Writer.<br />

More information about working with styles can be found in the Default values for character and paragraph<br />

properties section in Text Documents.<br />

Templates<br />

Templates are auxiliary documents. They provide a very convenient way to store, maintain, and distribute styles,<br />

macros, boiler-plate text, and other useful things.<br />

Document and Template Types<br />

Each major type of <strong>OpenOffice</strong>.<strong>org</strong> document has its own associated template type. In general, and for styles in<br />

particular, you can access information within a template in the same way you would access the same information<br />

in the associated document type. In other words, code (like the above examples) that works in a particular<br />

document type should also work for the associated template type.<br />

Automatic Update<br />

Most template types – Draw templates are the exception – have an automatic-update feature. If a style in the<br />

template has been changed, and you open a document created with that template, you will see a message asking<br />

whether to update the styles in the document. If you click on Yes, the new or changed styles will be copied into<br />

the document. Styles deleted from the template are not removed from documents.<br />

A problem may arise if you click on No: the styles will not be updated, and the automatic-update feature will be<br />

turned off. As of <strong>OpenOffice</strong>.<strong>org</strong> Version 3.1, this status does not show in the GUI, nor is there any GUI way to<br />

re-enable the feature. (For Writer documents only, you can use the Template Changer extension to set this feature<br />

again.)<br />

Chapter 5 · Working with Documents 67

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

Saved successfully!

Ooh no, something went wrong!