Oxygen XML Editor 11.2 Author API

ro.sync.ecss.extensions.commons.table.support
Class CALSTableCellInfoProvider

java.lang.Object
  extended by ro.sync.ecss.extensions.commons.table.support.CALSTableCellInfoProvider
All Implemented Interfaces:
AuthorTableCellSpanProvider, AuthorTableColumnWidthProvider, Extension, CALSConstants
Direct Known Subclasses:
CALSTableCellSpanProvider

public class CALSTableCellInfoProvider
extends Object
implements AuthorTableColumnWidthProvider, AuthorTableCellSpanProvider, CALSConstants

Provides informations about the cell spanning and column width for Docbook CALS tables.


Field Summary
protected  List spanspecInfos
          The list with the CALSColSpanSpec containing information about the columns span specification for this table.
 
Fields inherited from interface ro.sync.ecss.extensions.commons.table.operations.cals.CALSConstants
ATTRIBUTE_NAME_COLNAME, ATTRIBUTE_NAME_COLNUM, ATTRIBUTE_NAME_COLS, ATTRIBUTE_NAME_COLWIDTH, ATTRIBUTE_NAME_ID, ATTRIBUTE_NAME_MOREROWS, ATTRIBUTE_NAME_NAMEEND, ATTRIBUTE_NAME_NAMEST, ATTRIBUTE_NAME_SPANNAME, ATTRIBUTE_NAME_TABLE_WIDTH, ELEMENT_NAME_COLSPEC, ELEMENT_NAME_ENTRY, ELEMENT_NAME_INFORMALTABLE, ELEMENT_NAME_ROW, ELEMENT_NAME_SPANSPEC, ELEMENT_NAME_TABLE, ELEMENT_NAME_TGROUP
 
Constructor Summary
CALSTableCellInfoProvider()
           
 
Method Summary
 void commitColumnWidthModifications(AuthorDocumentController authorDocumentController, WidthRepresentation[] colWidths, String tableCellsTagName)
          Updates the columns width specifications in the source document by setting the colwidth attribute value of the colspec elements and by adding new colspec elements if needed.
 void commitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, String tableCellsTagName)
          Sets the width attribute value of the table element.
 CALSColSpanSpec getCellSpanSpec(AuthorAccess authorAccess, AuthorElement cellElement)
          Find the column span specification for a table cell.
 List<WidthRepresentation> getCellWidth(AuthorElement cellElement, int colNumberStart, int colSpan)
          The list with the width representations for the given cell is obtained by computing the column span and then determining the WidthRepresentation for each column the cell spans across.
 Integer getColSpan(AuthorElement cellElem)
          Compute the number of columns the cell spans across by looking at the 'spanspec' attribute.
 CALSColSpec getColSpec(int columnNumber)
          Find the column specification for the given column number.
 Set<CALSColSpec> getColSpecs()
          Returns the column specification set corresponding to the CALS table.
 String getDescription()
           
 Integer getRowSpan(AuthorElement cellElement)
          Compute the number of rows the cells span across by looking at the morerows attribute.
 WidthRepresentation getTableWidth(String tableCellsTagName)
          Returns the WidthRepresentation obtained by analyzing the width attribute value of the table element.
 boolean hasColumnSpecifications(AuthorElement tableElement)
          This method tells if the table contains column specifications.
 void init(AuthorElement tableElement)
          This method is called when starting to compute the layout for a table.
 boolean isAcceptingFixedColumnWidths(String tableCellsTagName)
          Check if the table column widths can be represented as fixed values.
 boolean isAcceptingPercentageColumnWidths(String tableCellsTagName)
          Check if the table column widths can be represented as percentage values.
 boolean isAcceptingProportionalColumnWidths(String tableCellsTagName)
          Check if the table column widths can be represented as proportional values.
 boolean isTableAcceptingWidth(String tableCellsTagName)
          The DocBook CALS tables do not accept width specification.
 boolean isTableAndColumnsResizable(String tableCellsTagName)
          It returns true only if the given table cells tag name is equal to 'entry'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spanspecInfos

protected List spanspecInfos
The list with the CALSColSpanSpec containing information about the columns span specification for this table.

Constructor Detail

CALSTableCellInfoProvider

public CALSTableCellInfoProvider()
Method Detail

getColSpan

public Integer getColSpan(AuthorElement cellElem)
Compute the number of columns the cell spans across by looking at the 'spanspec' attribute. In case the 'spanspec' attribute is missing then the column span is defined by the 'namest' and 'nameend' attribute.

Specified by:
getColSpan in interface AuthorTableCellSpanProvider
Parameters:
cellElem - The node that represents a table cell in CSS.
Returns:
The number of columns this cell spans across (the minimum returned value must be 1) or null if not specified.
See Also:
AuthorTableCellSpanProvider.getColSpan(AuthorElement)

getRowSpan

public Integer getRowSpan(AuthorElement cellElement)
Compute the number of rows the cells span across by looking at the morerows attribute.

Specified by:
getRowSpan in interface AuthorTableCellSpanProvider
Parameters:
cellElement - The AuthorElement that represents a table cell in CSS.
Returns:
The number of rows this cell spans across (the minimum returned value must be 1) or null if not specified.
See Also:
AuthorTableCellSpanProvider.getRowSpan(AuthorElement)

init

public void init(AuthorElement tableElement)
Description copied from interface: AuthorTableCellSpanProvider
This method is called when starting to compute the layout for a table. Its intended to extract information from the element representing the table only once, not on every getColSpan() or getRowSpan() call. Example: for a DocBook table we identify and cache the colspec and spanspec elements from that table. A new instance of the table cell span provider is used for every table in a document so cached data cannot be used between different tables..

Specified by:
init in interface AuthorTableCellSpanProvider
Specified by:
init in interface AuthorTableColumnWidthProvider
Parameters:
tableElement - The AuthorElement representing a table (it has the CSS display property set on 'table').
See Also:
AuthorTableColumnWidthProvider.init(ro.sync.ecss.extensions.api.node.AuthorElement)

getDescription

public String getDescription()
Specified by:
getDescription in interface Extension
Returns:
The description of the extension.
See Also:
Extension.getDescription()

getCellSpanSpec

public CALSColSpanSpec getCellSpanSpec(AuthorAccess authorAccess,
                                       AuthorElement cellElement)
Find the column span specification for a table cell. If 'spanname' attribute is present the corresponding span specification will be returned. Otherwise a new span specification will be returned looking at the name of columns spanned by the cell.

Parameters:
authorAccess - The author access.
cellElement - The table cell element.
Returns:
The cell span specification. Null when column specifications are not defined.

getColSpec

public CALSColSpec getColSpec(int columnNumber)
Find the column specification for the given column number.

Parameters:
columnNumber - The column number, one based.
Returns:
The column specification or null if no column specification is defined for the given column number.

getColSpecs

public Set<CALSColSpec> getColSpecs()
Returns the column specification set corresponding to the CALS table. The list is ordered ascending by the column specification index ('colnum' attribute).

Returns:
The column specifications set.

hasColumnSpecifications

public boolean hasColumnSpecifications(AuthorElement tableElement)
Description copied from interface: AuthorTableCellSpanProvider
This method tells if the table contains column specifications. For example the CALS table model requires colspec elements to be present.

Specified by:
hasColumnSpecifications in interface AuthorTableCellSpanProvider
Parameters:
tableElement - The AuthorElement that is rendered as a table.
Returns:
true if some column specification info is present or if the table doesn't require any column specification info.
See Also:
AuthorTableCellSpanProvider.hasColumnSpecifications(ro.sync.ecss.extensions.api.node.AuthorElement)

getCellWidth

public List<WidthRepresentation> getCellWidth(AuthorElement cellElement,
                                              int colNumberStart,
                                              int colSpan)
The list with the width representations for the given cell is obtained by computing the column span and then determining the WidthRepresentation for each column the cell spans across.

Specified by:
getCellWidth in interface AuthorTableColumnWidthProvider
Parameters:
cellElement - The node that represents a table cell in CSS.
colNumberStart - The column number the cell starts at.
colSpan - The column span of the cell.
Returns:
The list with the WidthRepresentation of the specified cell element. If the cell spans over multiple columns then the returned list will contain one WidthRepresentation for each column the cell spans over.
See Also:
AuthorTableColumnWidthProvider.getCellWidth(ro.sync.ecss.extensions.api.node.AuthorElement, int, int)

commitColumnWidthModifications

public void commitColumnWidthModifications(AuthorDocumentController authorDocumentController,
                                           WidthRepresentation[] colWidths,
                                           String tableCellsTagName)
                                    throws AuthorOperationException
Updates the columns width specifications in the source document by setting the colwidth attribute value of the colspec elements and by adding new colspec elements if needed.

Specified by:
commitColumnWidthModifications in interface AuthorTableColumnWidthProvider
Parameters:
authorDocumentController - The AuthorDocumentController used to commit the table modifications in the document.
colWidths - The new column WidthRepresentation to set. The column widths must be ordered according to the corresponding column numbers.
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).
Throws:
AuthorOperationException - If the operation fails.
See Also:
AuthorTableColumnWidthProvider.commitColumnWidthModifications(AuthorDocumentController, ro.sync.ecss.extensions.api.WidthRepresentation[], java.lang.String)

commitTableWidthModification

public void commitTableWidthModification(AuthorDocumentController authorDocumentController,
                                         int newTableWidth,
                                         String tableCellsTagName)
                                  throws AuthorOperationException
Sets the width attribute value of the table element.

Specified by:
commitTableWidthModification in interface AuthorTableColumnWidthProvider
Parameters:
authorDocumentController - The AuthorDocumentController used to commit the table width modifications in the document.
newTableWidth - The new table WidthRepresentation to set. The value is given in pixels.
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).
Throws:
AuthorOperationException - If the operation fails.
See Also:
AuthorTableColumnWidthProvider.commitTableWidthModification(AuthorDocumentController, int, java.lang.String)

getTableWidth

public WidthRepresentation getTableWidth(String tableCellsTagName)
Returns the WidthRepresentation obtained by analyzing the width attribute value of the table element.

Specified by:
getTableWidth in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).
Returns:
A non null value if the table width is specified. Otherwise null.
See Also:
AuthorTableColumnWidthProvider.getTableWidth(java.lang.String)

isTableAcceptingWidth

public boolean isTableAcceptingWidth(String tableCellsTagName)
The DocBook CALS tables do not accept width specification.

Specified by:
isTableAcceptingWidth in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).
Returns:
true if the table type denoted by the tableCellsTagName accepts width specification of any kind.
See Also:
AuthorTableColumnWidthProvider.isTableAcceptingWidth(java.lang.String)

isTableAndColumnsResizable

public boolean isTableAndColumnsResizable(String tableCellsTagName)
It returns true only if the given table cells tag name is equal to 'entry'.

Specified by:
isTableAndColumnsResizable in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. CALS or HTML).
Returns:
true if the size of the table or the table cells can be adjusted.
See Also:
AuthorTableColumnWidthProvider.isTableAndColumnsResizable(java.lang.String)

isAcceptingFixedColumnWidths

public boolean isAcceptingFixedColumnWidths(String tableCellsTagName)
Description copied from interface: AuthorTableColumnWidthProvider
Check if the table column widths can be represented as fixed values.

Specified by:
isAcceptingFixedColumnWidths in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. CALS or HTML).
Returns:
true if the table column widths can be represented in fixed values.
See Also:
AuthorTableColumnWidthProvider.isAcceptingFixedColumnWidths(java.lang.String)

isAcceptingPercentageColumnWidths

public boolean isAcceptingPercentageColumnWidths(String tableCellsTagName)
Description copied from interface: AuthorTableColumnWidthProvider
Check if the table column widths can be represented as percentage values.

Specified by:
isAcceptingPercentageColumnWidths in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. CALS or HTML).
Returns:
true if the table column widths can be represented in percentage values.
See Also:
AuthorTableColumnWidthProvider.isAcceptingPercentageColumnWidths(java.lang.String)

isAcceptingProportionalColumnWidths

public boolean isAcceptingProportionalColumnWidths(String tableCellsTagName)
Description copied from interface: AuthorTableColumnWidthProvider
Check if the table column widths can be represented as proportional values.

Specified by:
isAcceptingProportionalColumnWidths in interface AuthorTableColumnWidthProvider
Parameters:
tableCellsTagName - The cells tag name. Used to identify the table type (e.g. CALS or HTML).
Returns:
true if the table column widths can be represented in proportional values.
See Also:
AuthorTableColumnWidthProvider.isAcceptingProportionalColumnWidths(java.lang.String)

Oxygen XML Editor 11.2 Author API

© Copyright SyncRO Soft SRL 2002 - 2010.