View Panes

From Apache OpenOffice Wiki
Jump to: navigation, search



The com.sun.star.sheet.SpreadsheetViewPane service represents a pane in a view that shows a rectangular area of the document. The exposed area of a view pane always starts at a cell boundary. The com.sun.star.sheet.XViewPane interface's getFirstVisibleColumn(), getFirstVisibleRow(), setFirstVisibleColumn() and setFirstVisibleRow() methods query and set the start of the exposed area. The getVisibleRange() method returns a com.sun.star.table.CellRangeAddress struct describing which cells are shown in the pane. Columns or rows that are only partly visible at the right or lower edge of the view are not included.

The com.sun.star.sheet.XCellRangeReferrer interface gives direct access to the same cell range of exposed cells that are addressed by the getVisibleRange() return value.

The com.sun.star.view.XControlAccess interface's getControl() method gives access to a control model's control for the view pane. Refer to the chapter Models and Views for additional information.

The example below retrieves the cell range that is shown in the second pane. It is the lower left one after freezing both columns and rows, and assigns a cell background:

  // get the cell range shown in the second pane and assign a cell background to them
  com.sun.star.container.XIndexAccess xIndex = (com.sun.star.container.XIndexAccess)
      UnoRuntime.queryInterface(com.sun.star.container.XIndexAccess.class, xController);
  Object aPane = xIndex.getByIndex(1);
  com.sun.star.sheet.XCellRangeReferrer xRefer = (com.sun.star.sheet.XCellRangeReferrer)
      UnoRuntime.queryInterface(com.sun.star.sheet.XCellRangeReferrer.class, aPane);
  com.sun.star.table.XCellRange xRange = xRefer.getReferredCells();
  com.sun.star.beans.XPropertySet xRangeProp = (com.sun.star.beans.XPropertySet)
      UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xRange);
  xRangeProp.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));
  xRangeProp.setPropertyValue("CellBackColor", new Integer(0xFFFFCC));

The index container provides the available panes in a specific order, depending on how the view has been split.

Index No split Vertical split Horizontal split (*) Vertical and horizontal split (*)
0 Entire window Top pane Left pane Top left pane
1 -- Bottom pane Right pane Bottom left pane
2 -- -- -- Top right pane
3 -- -- -- Bottom right pane

(*) If the sheet is in right-to-left layout mode, the panes are swapped too (e.g., pane 0 would be the right pane or the top right pane).

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages