Templates are named lists containing formatting attributes. They move through all applications of Apache OpenOffice and help to significantly simplify formatting. If the user changes one of the attributes of a template, then Apache OpenOffice automatically adjusts all document sections depending on the attribute. The user can therefore, for example, change the font type of all level one headers by means of a central modification in the document. Depending on the relevant document types, Apache OpenOffice recognizes a whole range of different types of template.
Apache OpenOffice Writer supports the following templates:
- Character templates
- Paragraph templates
- Frame templates
- Page templates
- Numbering templates
Apache OpenOffice Calc supports the following templates:
- Cell template
- Page templates
Apache OpenOffice Impress supports the following templates:
- Character element templates
- Presentation templates
In Apache OpenOffice terminology, the different types of templates are called StyleFamilies in accordance with the com.sun.star.style.StyleFamily service on which they are based. The StyleFamilies are accessed by means of the document object:
Dim Doc As Object Dim Sheet As Object Dim StyleFamilies As Object Dim CellStyles As Object Doc = StarDesktop.CurrentComponent StyleFamilies = Doc.StyleFamilies CellStyles = StyleFamilies.getByName("CellStyles")
The example uses the StyleFamilies property of a spreadsheet document to establish a list containing all available cell templates.
The individual templates can be accessed directly by means of an index:
Dim Doc As Object Dim Sheet As Object Dim StyleFamilies As Object Dim CellStyles As Object Dim CellStyle As Object Dim I As Integer Doc = StarDesktop.CurrentComponent StyleFamilies = Doc.StyleFamilies CellStyles = StyleFamilies.getByName("CellStyles") For I = 0 To CellStyles.Count - 1 CellStyle = CellStyles(I) MsgBox CellStyle.Name Next I
The loop added since the previous example displays the names of all cell templates one after another in a message box.
Details about various formatting options
Each type of template provides a whole range of individual formatting properties. Here is an overview of the most important formatting properties and the points at which they are explained:
- Character properties, com.sun.star.style.CharacterProperties service
- Paragraph properties, com.sun.star.text.Paragraph service
- Cell properties, com.sun.star.table.CellProperties service
- Page properties, com.sun.star.style.PageProperties service
- Character element properties, Various services
The format properties are by no means restricted to the applications in which these are explained, but instead can be used universally. For example, most of the page properties described in Spreadsheets can therefore be used not only in Apache OpenOffice Calc, but also in Apache OpenOffice Writer.
More information about working with templates can be found in the Default values for character and paragraph properties section in Text Documents.
|Content on this page is licensed under the Public Documentation License (PDL).|