Holger's
Java API

com.antelmann.ooffice
Class OOTableWriter

java.lang.Object
  extended by com.antelmann.ooffice.OOTableWriter
All Implemented Interfaces:
Wrapped<OOWriter>

@ThirdParty(value="uses OpenOffice.org libraries")
public class OOTableWriter
extends Object
implements Wrapped<OOWriter>

provides easy to use table-related functionality for TextFrames This class implements ThirdParty for its use of OpenOffice libraries; see www.openoffice.org

Author:
Holger Antelmann
See Also:
Cell

Constructor Summary
OOTableWriter(OOWriter doc)
           
 
Method Summary
 int appendRows(String tableName, int count)
          returns the number of rows in the given table including the appended rows
 TableModel asTableModel(String table, boolean firstRowIsHeader)
           
 void copyCellText(com.sun.star.table.XCell origin, com.sun.star.table.XCell target)
           
 int deleteRows(String tableName, int atRow, int count)
          returns the number of rows in the given table including the inserted rows
 void deleteTable(String tableName)
           
 Cell getCell(String tableName, int row, int column)
           
 Cell getCell(String tableName, String cellName)
           
 Cell getCellForBookmark(String bookmark)
           
 Cell getCellForCursor(com.sun.star.text.XTextCursor cursor)
           
 String getCellNameFor(String bookmark)
           
 String getCellNameFor(com.sun.star.table.XCell cell)
           
 String[] getCellNamesFor(String tableName)
           
 String getCellText(com.sun.star.table.XCell cell)
           
static int getColumnForCellName(String cellName)
           
 com.sun.star.text.XTextCursor getCursorForCell(com.sun.star.table.XCell cell)
           
 int getNumberOfColumns(String tableName)
           
 int getNumberOfRows(String tableName)
           
 OOWriter getOOWriter()
           
static int getRowForCellName(String cell)
          only works properly for simple cell names (without merged/splitted cells)
 com.sun.star.text.XTextTable getTable(String tableName)
           
 com.sun.star.text.XTextTable getTableFor(com.sun.star.table.XCell cell)
           
 String getTableNameFor(String bookmark)
           
 String getTableNameFor(com.sun.star.table.XCell cell)
           
 String[] getTableNames()
           
 void gotoCell(com.sun.star.table.XCell cell)
          moves the visible cursor to the given cell
 int insertRows(String tableName, int atRow, int count)
          returns the number of rows in the given table including the inserted rows
 int insertRowsAtBookmark(String bookmark, int count)
           
 String insertTable(int rows, int columns)
          uses the view cursor
 String insertTable(int rows, int columns, com.sun.star.text.XTextRange position)
          the table is inserted at the start of the given position and the name of the table is returned.
 String insertTableModel(TableModel model)
          uses the view cursor
 String insertTableModel(TableModel model, com.sun.star.text.XTextRange position)
          inserts the model at the given location and returns the name of the table
 Cell mergeWithRightCell(com.sun.star.table.XCell cell)
          merges the given cell with the one to its right.
 void placeTableModel(TableModel model, String table, int startingRow, int startingColumn, boolean withHeader)
          places the model into the given table starting at the given position; additional rows are inserted as needed
 Cell relativeMove(com.sun.star.table.XCell cell, Direction direction, int amount)
          supported directions are Direction.get2Dimensionals()
 void setCellBackground(com.sun.star.table.XCell cell, Color color)
           
 void setCellBackground(com.sun.star.table.XCell cell, String imageURL)
           
 void setCellBorder(com.sun.star.table.XCell cell, CellBorder border)
           
 com.sun.star.text.XText setCellText(String tableName, int row, int column, String text)
          returns the text component of the target cell for further handling
 com.sun.star.text.XText setCellText(String tableName, String cellName, String text)
          returns the text component of the target cell for further handling
 com.sun.star.text.XText setCellText(com.sun.star.table.XCell cell, String text)
          returns the text component of the target cell for further handling
 void setKeepTogether(String tableName, boolean flag)
           
 void setRepeatHeaderline(String tableName, boolean flag)
           
 void setTableProperty(String tableName, String key, Object value)
           
 OOWriter unwrap()
          returns the embedded instance that this wrapper encloses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OOTableWriter

public OOTableWriter(OOWriter doc)
Method Detail

getOOWriter

public OOWriter getOOWriter()

unwrap

public OOWriter unwrap()
Description copied from interface: Wrapped
returns the embedded instance that this wrapper encloses

Specified by:
unwrap in interface Wrapped<OOWriter>

insertTable

public String insertTable(int rows,
                          int columns)
                   throws OfficeException
uses the view cursor

Throws:
OfficeException

insertTable

public String insertTable(int rows,
                          int columns,
                          com.sun.star.text.XTextRange position)
                   throws OfficeException
the table is inserted at the start of the given position and the name of the table is returned.

Returns:
the name of the inserted table for reference
Throws:
OfficeException

deleteTable

public void deleteTable(String tableName)
                 throws OfficeException,
                        IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

deleteRows

public int deleteRows(String tableName,
                      int atRow,
                      int count)
               throws OfficeException,
                      IllegalArgumentException
returns the number of rows in the given table including the inserted rows

Throws:
OfficeException
IllegalArgumentException

insertRows

public int insertRows(String tableName,
                      int atRow,
                      int count)
               throws OfficeException,
                      IllegalArgumentException
returns the number of rows in the given table including the inserted rows

Throws:
OfficeException
IllegalArgumentException

appendRows

public int appendRows(String tableName,
                      int count)
               throws OfficeException,
                      IllegalArgumentException
returns the number of rows in the given table including the appended rows

Throws:
OfficeException
IllegalArgumentException

getNumberOfRows

public int getNumberOfRows(String tableName)
                    throws OfficeException,
                           IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getNumberOfColumns

public int getNumberOfColumns(String tableName)
                       throws OfficeException,
                              IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCellText

public String getCellText(com.sun.star.table.XCell cell)
                   throws OfficeException
Throws:
OfficeException

getCellNamesFor

public String[] getCellNamesFor(String tableName)
                         throws OfficeException,
                                IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCellNameFor

public String getCellNameFor(com.sun.star.table.XCell cell)
                      throws OfficeException
Throws:
OfficeException

getTableFor

public com.sun.star.text.XTextTable getTableFor(com.sun.star.table.XCell cell)
                                         throws OfficeException
Throws:
OfficeException

getTableNameFor

public String getTableNameFor(com.sun.star.table.XCell cell)
                       throws OfficeException
Throws:
OfficeException

getTableNames

public String[] getTableNames()

getRowForCellName

public static int getRowForCellName(String cell)
only works properly for simple cell names (without merged/splitted cells)


getColumnForCellName

public static int getColumnForCellName(String cellName)

insertRowsAtBookmark

public int insertRowsAtBookmark(String bookmark,
                                int count)
                         throws OfficeException
Throws:
OfficeException

getTableNameFor

public String getTableNameFor(String bookmark)
                       throws OfficeException,
                              IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCellNameFor

public String getCellNameFor(String bookmark)
                      throws OfficeException,
                             IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCellForBookmark

public Cell getCellForBookmark(String bookmark)
                        throws OfficeException,
                               IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCellForCursor

public Cell getCellForCursor(com.sun.star.text.XTextCursor cursor)
                      throws OfficeException
Throws:
OfficeException

getCursorForCell

public com.sun.star.text.XTextCursor getCursorForCell(com.sun.star.table.XCell cell)
                                               throws OfficeException
Throws:
OfficeException

gotoCell

public void gotoCell(com.sun.star.table.XCell cell)
moves the visible cursor to the given cell


setCellText

public com.sun.star.text.XText setCellText(String tableName,
                                           String cellName,
                                           String text)
                                    throws OfficeException,
                                           IllegalArgumentException
returns the text component of the target cell for further handling

Throws:
OfficeException
IllegalArgumentException

setCellText

public com.sun.star.text.XText setCellText(String tableName,
                                           int row,
                                           int column,
                                           String text)
                                    throws OfficeException,
                                           IllegalArgumentException
returns the text component of the target cell for further handling

Throws:
OfficeException
IllegalArgumentException

setCellText

public com.sun.star.text.XText setCellText(com.sun.star.table.XCell cell,
                                           String text)
returns the text component of the target cell for further handling


getCell

public Cell getCell(String tableName,
                    int row,
                    int column)
             throws OfficeException,
                    IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getCell

public Cell getCell(String tableName,
                    String cellName)
             throws OfficeException,
                    IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

relativeMove

public Cell relativeMove(com.sun.star.table.XCell cell,
                         Direction direction,
                         int amount)
                  throws OfficeException,
                         IllegalArgumentException
supported directions are Direction.get2Dimensionals()

Throws:
OfficeException
IllegalArgumentException

copyCellText

public void copyCellText(com.sun.star.table.XCell origin,
                         com.sun.star.table.XCell target)
                  throws OfficeException
Throws:
OfficeException

mergeWithRightCell

public Cell mergeWithRightCell(com.sun.star.table.XCell cell)
                        throws OfficeException
merges the given cell with the one to its right. This only works properly on tables that do not contain split cells.

Returns:
the cell representing the newly merged cell
Throws:
OfficeException

setCellBackground

public void setCellBackground(com.sun.star.table.XCell cell,
                              Color color)
                       throws OfficeException
Throws:
OfficeException

setCellBackground

public void setCellBackground(com.sun.star.table.XCell cell,
                              String imageURL)
                       throws OfficeException
Throws:
OfficeException

setCellBorder

public void setCellBorder(com.sun.star.table.XCell cell,
                          CellBorder border)
                   throws OfficeException
Throws:
OfficeException

getTable

public com.sun.star.text.XTextTable getTable(String tableName)
                                      throws OfficeException
Throws:
OfficeException

setRepeatHeaderline

public void setRepeatHeaderline(String tableName,
                                boolean flag)
                         throws OfficeException,
                                IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setKeepTogether

public void setKeepTogether(String tableName,
                            boolean flag)
                     throws OfficeException,
                            IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setTableProperty

public void setTableProperty(String tableName,
                             String key,
                             Object value)
                      throws OfficeException,
                             IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

asTableModel

public TableModel asTableModel(String table,
                               boolean firstRowIsHeader)
                        throws IllegalArgumentException,
                               OfficeException
Throws:
IllegalArgumentException
OfficeException

insertTableModel

public String insertTableModel(TableModel model)
                        throws OfficeException
uses the view cursor

Throws:
OfficeException

insertTableModel

public String insertTableModel(TableModel model,
                               com.sun.star.text.XTextRange position)
                        throws OfficeException
inserts the model at the given location and returns the name of the table

Throws:
OfficeException

placeTableModel

public void placeTableModel(TableModel model,
                            String table,
                            int startingRow,
                            int startingColumn,
                            boolean withHeader)
                     throws OfficeException
places the model into the given table starting at the given position; additional rows are inserted as needed

Throws:
OfficeException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads