Difference between revisions of "Documentation/DevGuide/Spreadsheets/Overall Document Features"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
Line 16: Line 16:
 
The collection of style families is available from the spreadsheet document with the <idl>com.sun.star.style.XStyleFamiliesSupplier</idl>'s method <code>getStyleFamilies()</code>. The general handling of styles is described in this section, therefore this chapter focuses on the spreadsheet specific style properties.
 
The collection of style families is available from the spreadsheet document with the <idl>com.sun.star.style.XStyleFamiliesSupplier</idl>'s method <code>getStyleFamilies()</code>. The general handling of styles is described in this section, therefore this chapter focuses on the spreadsheet specific style properties.
  
{{Documentation/Note|A new style is inserted into the family container,then it is possible to set any properties.}}
+
{{Note|A new style is inserted into the family container,then it is possible to set any properties.}}
  
 
==== Cell Styles ====
 
==== Cell Styles ====
Line 60: Line 60:
 
The properties <code>LeftPageFooterContent</code>, <code>LeftPageHeaderContent</code>, <code>RightPageFooterContent</code> and <code>RightPageHeaderContent</code> return the interface <idl>com.sun.star.sheet.XHeaderFooterContent</idl> for the headers and footers for the left and right pages. Headers and footers are represented by the service <idl>com.sun.star.sheet.HeaderFooterContent</idl>. Each header or footer object contains three text objects for the left, middle and right portion of a header or footer. The methods <code>getLeftText()</code>, <code>getCenterText()</code> and <code>getRightText()</code> return the interface <idl>com.sun.star.text.XText</idl> of these text portions.
 
The properties <code>LeftPageFooterContent</code>, <code>LeftPageHeaderContent</code>, <code>RightPageFooterContent</code> and <code>RightPageHeaderContent</code> return the interface <idl>com.sun.star.sheet.XHeaderFooterContent</idl> for the headers and footers for the left and right pages. Headers and footers are represented by the service <idl>com.sun.star.sheet.HeaderFooterContent</idl>. Each header or footer object contains three text objects for the left, middle and right portion of a header or footer. The methods <code>getLeftText()</code>, <code>getCenterText()</code> and <code>getRightText()</code> return the interface <idl>com.sun.star.text.XText</idl> of these text portions.
  
{{Documentation/Note|After the text of a header or footer is changed, it is reinserted into the property set of the page style.}}
+
{{Note|After the text of a header or footer is changed, it is reinserted into the property set of the page style.}}
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Spreadsheet Documents]]
 
[[Category:Documentation/Developer's Guide/Spreadsheet Documents]]

Revision as of 20:52, 3 July 2018

  • Overall Document Features



Styles

A style contains all formatting properties for a specific object. All styles of the same type are contained in a collection named a style family. Each style family has a specific name to identify it in the collection. In OpenOffice.org API Calc, there are two style families named CellStyles and PageStyles. A cell style can be applied to a cell, a cell range, or all cells of the spreadsheet. A page style can be applied to a spreadsheet itself.

StyleFamilies

The collection of style families is available from the spreadsheet document with the com.sun.star.style.XStyleFamiliesSupplier's method getStyleFamilies(). The general handling of styles is described in this section, therefore this chapter focuses on the spreadsheet specific style properties.

Documentation note.png A new style is inserted into the family container,then it is possible to set any properties.

Cell Styles

Cell styles are predefined packages of format settings that are applied in a single step.

CellStyle

A cell style is represented by the service com.sun.star.sheet.TableCellStyle. If a formatting property is applied directly to a cell, it covers the property of the applied cell style. This service does not support the property CellStyle. The name of the style is set with the interface com.sun.star.container.XNamed.

The following example creates a new cell style with gray background. The xDocument is the com.sun.star.sheet.XSpreadsheetDocument interface of a spreadsheet document.

 // get the cell style container
 com.sun.star.style.XStyleFamiliesSupplier xFamiliesSupplier =
     (com.sun.star.style.XStyleFamiliesSupplier) UnoRuntime.queryInterface(
         com.sun.star.style.XStyleFamiliesSupplier.class, xDocument);
 com.sun.star.container.XNameAccess xFamiliesNA = xFamiliesSupplier.getStyleFamilies();
 Object aCellStylesObj = xFamiliesNA.getByName("CellStyles");
 com.sun.star.container.XNameContainer xCellStylesNA = (com.sun.star.container.XNameContainer)
     UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, aCellStylesObj);
 
 // create a new cell style
 com.sun.star.lang.XMultiServiceFactory xServiceManager = (com.sun.star.lang.XMultiServiceFactory)
     UnoRuntime.queryInterface(com.sun.star.lang.XMultiServiceFactory.class, xDocument);
 Object aCellStyle = xServiceManager.createInstance("com.sun.star.style.CellStyle");
 xCellStylesNA.insertByName("MyNewCellStyle", aCellStyle);
 
 // modify properties of the new style
 com.sun.star.beans.XPropertySet xPropSet = (com.sun.star.beans.XPropertySet)
     UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, aCellStyle);
 xPropSet.setPropertyValue("CellBackColor", new Integer(0x888888));
 xPropSet.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));

Page Styles

A page style is represented by the service com.sun.star.sheet.TablePageStyle. It contains the service com.sun.star.style.PageStyle and additional spreadsheet specific page properties.

TablePageStyle

The properties LeftPageFooterContent, LeftPageHeaderContent, RightPageFooterContent and RightPageHeaderContent return the interface com.sun.star.sheet.XHeaderFooterContent for the headers and footers for the left and right pages. Headers and footers are represented by the service com.sun.star.sheet.HeaderFooterContent. Each header or footer object contains three text objects for the left, middle and right portion of a header or footer. The methods getLeftText(), getCenterText() and getRightText() return the interface com.sun.star.text.XText of these text portions.

Documentation note.png After the text of a header or footer is changed, it is reinserted into the property set of the page style.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages