Class CALSTableCellInfoProvider
java.lang.Object
ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
ro.sync.ecss.extensions.commons.table.support.CALSTableCellInfoProvider
- All Implemented Interfaces:
AuthorTableCellSepProvider,AuthorTableCellSpanProvider,AuthorTableColumnWidthProvider,Extension,CALSConstants
- Direct Known Subclasses:
CALSTableCellSpanProvider,DITACALSTableCellInfoProvider,DITATableCellSepInfoProvider,DocbookTableCellSepInfoProvider
@API(type=INTERNAL,
src=PUBLIC)
public class CALSTableCellInfoProvider
extends AuthorTableColumnWidthProviderBase
implements AuthorTableCellSpanProvider, CALSConstants, AuthorTableCellSepProvider
Provides informations about the cell spanning and column width for Docbook CALS tables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final WidthRepresentationThe default width representation.protected List<CALSColSpanSpec>The list with theCALSColSpanSpeccontaining information about the columns span specification for this table.Fields inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
errorsListenerFields inherited from interface ro.sync.ecss.extensions.commons.table.operations.cals.CALSConstants
ATTRIBUTE_NAME_ALIGN, ATTRIBUTE_NAME_COLNAME, ATTRIBUTE_NAME_COLNUM, ATTRIBUTE_NAME_COLS, ATTRIBUTE_NAME_COLSEP, ATTRIBUTE_NAME_COLWIDTH, ATTRIBUTE_NAME_ID, ATTRIBUTE_NAME_MOREROWS, ATTRIBUTE_NAME_NAMEEND, ATTRIBUTE_NAME_NAMEST, ATTRIBUTE_NAME_ROWSEP, ATTRIBUTE_NAME_SPANNAME, ATTRIBUTE_NAME_TABLE_WIDTH, ATTRIBUTE_NAME_XML_ID, ELEMENT_NAME_COLSPEC, ELEMENT_NAME_ENTRY, ELEMENT_NAME_INFORMALTABLE, ELEMENT_NAME_ROW, ELEMENT_NAME_SPANSPEC, ELEMENT_NAME_TABLE, ELEMENT_NAME_TGROUP -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault) Constructor.CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault, TableLayoutErrorsListener errorsListener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommitColumnWidthModifications(AuthorDocumentController authorDocumentController, WidthRepresentation[] colWidths, String tableCellsTagName) Updates the columns width specifications in the source document by setting thecolwidthattribute value of thecolspecelements and by adding newcolspecelements if needed.voidcommitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, String tableCellsTagName) Sets thewidthattribute value of thetableelement.Get all with representations defined in all colspecs.getCellSpanSpec(AuthorAccess authorAccess, AuthorElement cellElement) Find the column span specification for a table cell.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 theWidthRepresentationfor each column the cell spans across.booleangetColSep(AuthorElement cellElem, int columnIndex) Checks if a separator should be placed at the cell right.getColSpan(AuthorElement cellElem) Compute the number of columns the cell spans across by looking at the 'spanspec' attribute.int[]getColSpanInterval(AuthorElement cellElem) Compute the interval a cell spans across by looking at the 'spanspec' attribute.getColSpec(int columnNumber) Find the column specification for the given column number.getColSpec(String colSpecName) Find a column specification by name.getColSpecElement(CALSColSpec colspec) Find a column specification element.Returns the column specification set corresponding to the CALS table.booleangetRowSep(AuthorElement cellElem, int columnIndex) Checks if a separator should be placed at the cell bottom.getRowSpan(AuthorElement cellElement) Compute the number of rows the cells span across by looking at themorerowsattribute.getTableWidth(String tableCellsTagName) Returns theWidthRepresentationobtained by analyzing thewidthattribute value of thetableelement.booleanhasColumnSpecifications(AuthorElement tableElement) This method tells if the table contains column specifications.voidinit(AuthorElement tableElement) This method is called when starting to compute the layout for a table.booleanisAcceptingFixedColumnWidths(String tableCellsTagName) Check if the table column widths can be represented as fixed values.booleanisAcceptingPercentageColumnWidths(String tableCellsTagName) Check if the table column widths can be represented as percentage values.booleanisAcceptingProportionalColumnWidths(String tableCellsTagName) Check if the table column widths can be represented as proportional values.protected booleanisColspec(AuthorElement child) Check if the child is a column specification.booleanisTableAcceptingWidth(String tableCellsTagName) The DocBook CALS tables do not accept width specification.booleanisTableAndColumnsResizable(String tableCellsTagName) It returnstrueonly if the given table cells tag name is equal to'entry'.protected booleanisTableCell(String tableCellsTagName) Check if the name of an element is a table cell.protected booleanisTableElement(AuthorElement element) Check if this element is atableelement.protected booleanisTgroupElement(AuthorElement element) Check if this element is atgroupelement.Methods inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
getErrorsListener, isPreferPercentageColumnWidths, setErrorsListener
-
Field Details
-
DEFAULT_WIDTH_REPRESENTATION
The default width representation. PUBLIC BECAUSE IT WAS USED IN OLDER VERSIONS AS API. -
spanspecInfos
The list with theCALSColSpanSpeccontaining information about the columns span specification for this table.
-
-
Constructor Details
-
CALSTableCellInfoProvider
public CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault) Constructor.- Parameters:
colsepAndRowSepAreVisibleByDefault- The default visibility for the rowsep and colsep. (i.e. if nocolseporrowsepattributes are present in the table).
-
CALSTableCellInfoProvider
public CALSTableCellInfoProvider()Constructor. The default visibility for the rowsep and colsep. (i.e. if nocolseporrowsepattributes are present in the table) is hidden. -
CALSTableCellInfoProvider
public CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault, TableLayoutErrorsListener errorsListener) Constructor.- Parameters:
colsepAndRowSepAreVisibleByDefault- The default visibility for the rowsep and colsep. (i.e. if nocolseporrowsepattributes are present in the table).errorsListener- Table layout errors listener.
-
-
Method Details
-
getColSpan
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:
getColSpanin interfaceAuthorTableCellSpanProvider- 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
nullif not specified. - See Also:
-
getColSpanInterval
Compute the interval a 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.- Parameters:
cellElem- Cell we want to check for spans.- Returns:
- The interval a cell spans. Can be
null
-
getRowSpan
Compute the number of rows the cells span across by looking at themorerowsattribute.- Specified by:
getRowSpanin interfaceAuthorTableCellSpanProvider- Parameters:
cellElement- TheAuthorElementthat represents a table cell in CSS.- Returns:
- The number of rows this cell spans across (the minimum returned value must be 1)
or
nullif not specified. - See Also:
-
init
Description copied from interface:AuthorTableCellSpanProviderThis 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 thecolspecandspanspecelements 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:
initin interfaceAuthorTableCellSepProvider- Specified by:
initin interfaceAuthorTableCellSpanProvider- Specified by:
initin interfaceAuthorTableColumnWidthProvider- Parameters:
tableElement- TheAuthorElementrepresenting a table (it has the CSS display property set on 'table').- See Also:
-
isColspec
Check if the child is a column specification.- Parameters:
child- The child- Returns:
trueif the child is a column specification.
-
getDescription
- Specified by:
getDescriptionin interfaceExtension- Returns:
- The description of the extension.
- See Also:
-
getCellSpanSpec
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.
Nullwhen column specifications are not defined.
-
getColSpec
Find a column specification by name.- Parameters:
colSpecName- The name of column specification.- Returns:
- The column specification or
nullif no column specification is defined for the given colspec name.
-
getColSpec
Find the column specification for the given column number.- Parameters:
columnNumber- The column number, one based.- Returns:
- The column specification or
nullif no column specification is defined for the given column number. 1 based.
-
getColSpecElement
Find a column specification element.- Parameters:
colspec- The column specification.- Returns:
- The column specification element or
nullif no column corresponds to the given specification.
-
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
Description copied from interface:AuthorTableCellSpanProviderThis method tells if the table contains column specifications. For example the CALS table model requirescolspecelements to be present.- Specified by:
hasColumnSpecificationsin interfaceAuthorTableCellSpanProvider- Parameters:
tableElement- TheAuthorElementthat is rendered as a table.- Returns:
trueif some column specification info is present or if the table doesn't require any column specification info.- See Also:
-
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 theWidthRepresentationfor each column the cell spans across.- Specified by:
getCellWidthin interfaceAuthorTableColumnWidthProvider- 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
WidthRepresentationof the specified cell element ornullif the cell width cannot be computed. If the cell spans over multiple columns then the returned list will contain oneWidthRepresentationfor each column the cell spans over. - See Also:
-
commitColumnWidthModifications
public void commitColumnWidthModifications(AuthorDocumentController authorDocumentController, WidthRepresentation[] colWidths, String tableCellsTagName) throws AuthorOperationException Updates the columns width specifications in the source document by setting thecolwidthattribute value of thecolspecelements and by adding newcolspecelements if needed.- Specified by:
commitColumnWidthModificationsin interfaceAuthorTableColumnWidthProvider- Parameters:
authorDocumentController- TheAuthorDocumentControllerused to commit the table modifications in the document.colWidths- The new columnWidthRepresentationto 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:
-
isTableCell
Check if the name of an element is a table cell.- Parameters:
tableCellsTagName- The name of an element.- Returns:
trueif the name of an element is a table cell.
-
commitTableWidthModification
public void commitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, String tableCellsTagName) throws AuthorOperationException Sets thewidthattribute value of thetableelement.- Specified by:
commitTableWidthModificationin interfaceAuthorTableColumnWidthProvider- Parameters:
authorDocumentController- TheAuthorDocumentControllerused to commit the table width modifications in the document.newTableWidth- The new tableWidthRepresentationto 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:
-
getTableWidth
Returns theWidthRepresentationobtained by analyzing thewidthattribute value of thetableelement.- Specified by:
getTableWidthin interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).- Returns:
- A non
nullvalue if the table width is specified. Otherwisenull. - See Also:
-
isTableAcceptingWidth
The DocBook CALS tables do not accept width specification.- Specified by:
isTableAcceptingWidthin interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. 'entry' for CALS or 'td' for HTML).- Returns:
trueif the table type denoted by thetableCellsTagNameaccepts width specification of any kind.- See Also:
-
isTableAndColumnsResizable
It returnstrueonly if the given table cells tag name is equal to'entry'.- Specified by:
isTableAndColumnsResizablein interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. CALS or HTML).- Returns:
trueif the size of the table or the table cells can be adjusted.- See Also:
-
isAcceptingFixedColumnWidths
Description copied from interface:AuthorTableColumnWidthProviderCheck if the table column widths can be represented as fixed values.- Specified by:
isAcceptingFixedColumnWidthsin interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. CALS or HTML).- Returns:
trueif the table column widths can be represented in fixed values.- See Also:
-
isAcceptingPercentageColumnWidths
Description copied from interface:AuthorTableColumnWidthProviderCheck if the table column widths can be represented as percentage values.- Specified by:
isAcceptingPercentageColumnWidthsin interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. CALS or HTML).- Returns:
trueif the table column widths can be represented in percentage values.- See Also:
-
isAcceptingProportionalColumnWidths
Description copied from interface:AuthorTableColumnWidthProviderCheck if the table column widths can be represented as proportional values.- Specified by:
isAcceptingProportionalColumnWidthsin interfaceAuthorTableColumnWidthProvider- Parameters:
tableCellsTagName- The cells tag name. Used to identify the table type (e.g. CALS or HTML).- Returns:
trueif the table column widths can be represented in proportional values.- See Also:
-
getAllColspecWidthRepresentations
Description copied from class:AuthorTableColumnWidthProviderBaseGet all with representations defined in all colspecs. If a colspec does not specify a width, it is supposed to be 1*. If the table group specifies more columns than colspecs, those widths are supposed to be 1*.- Specified by:
getAllColspecWidthRepresentationsin classAuthorTableColumnWidthProviderBase- Returns:
- All width representations from the defined colspecs.
- See Also:
-
getColSep
Description copied from interface:AuthorTableCellSepProviderChecks if a separator should be placed at the cell right. Note that if the cell is the last from its row, the separator is not painted even if this method returnstrue.- Specified by:
getColSepin interfaceAuthorTableCellSepProvider- Parameters:
cellElem- The node that represents a table cell in CSS.columnIndex- The index of the column, used to identify the colspec associated to the cell. The colspec can give information about the colsep. 1 based.- Returns:
trueif a separator should be placed at its right,falseotherwise.- See Also:
-
getRowSep
Description copied from interface:AuthorTableCellSepProviderChecks if a separator should be placed at the cell bottom. Note that if the cell is on the last row, the separator is not painted even if this method returnstrue.- Specified by:
getRowSepin interfaceAuthorTableCellSepProvider- Parameters:
cellElem- The node that represents a table cell in CSS.columnIndex- The index of the column, used to identify the rowspec associated to the cell. The rowspec can give information about the colsep. 1 based.- Returns:
trueif a separator should be placed at its right,falseotherwise.- See Also:
-
isTableElement
Check if this element is atableelement.- Parameters:
element- The analyzed element.- Returns:
trueif this element is a CALStableelement.
-
isTgroupElement
Check if this element is atgroupelement.- Parameters:
element- The analyzed element.- Returns:
trueif this element is a CALStgroupelement.
-