Class CALSandHTMLTableCellInfoProvider
- java.lang.Object
-
- ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
-
- ro.sync.ecss.extensions.commons.table.support.CALSandHTMLTableCellInfoProvider
-
- All Implemented Interfaces:
AuthorTableCellSpanProvider
,AuthorTableColumnWidthProvider
,Extension
- Direct Known Subclasses:
CALSandHTMLTableCellSpanProvider
@API(type=INTERNAL, src=PUBLIC) public class CALSandHTMLTableCellInfoProvider extends AuthorTableColumnWidthProviderBase implements AuthorTableCellSpanProvider
A table cell span and column width info provider used for frameworks that have both CALS and HTML tables.
-
-
Field Summary
-
Fields inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
errorsListener
-
-
Constructor Summary
Constructors Constructor Description CALSandHTMLTableCellInfoProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commitColumnWidthModifications(AuthorDocumentController authorDocumentController, WidthRepresentation[] colWidths, java.lang.String tableCellsTagName)
Updates the column widths in the document and in the column layout model.void
commitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, java.lang.String tableCellsTagName)
Commit the table width modification.java.util.List<WidthRepresentation>
getAllColspecWidthRepresentations()
Get all with representations defined in all colspecs.AuthorTableCellSpanProvider
getCALSTableCellSpanProvider()
Get the table span provider for the CALS table model.java.util.List<WidthRepresentation>
getCellWidth(AuthorElement cellElement, int colNumberStart, int colSpan)
Get the width representation for the cell represented by thecellElement
.java.lang.Integer
getColSpan(AuthorElement cellElement)
Get the number of columns the given cell spans across.java.lang.String
getDescription()
java.lang.Integer
getRowSpan(AuthorElement cellElement)
Get the number of rows that the given cell spans across.WidthRepresentation
getTableWidth(java.lang.String tableCellsTagName)
Returns a non nullWidthRepresentation
if the table width is currently known.AuthorTableCellSpanProvider
getXHTMLTableCellSpanProvider()
Get the table span provider for the HTML table model.boolean
hasColumnSpecifications(AuthorElement tableElement)
This method tells if the table contains column specifications.void
init(AuthorElement tableNode)
This method is called when starting to compute the layout for a table.boolean
isAcceptingFixedColumnWidths(java.lang.String tableCellsTagName)
Check if the table column widths can be represented as fixed values.boolean
isAcceptingPercentageColumnWidths(java.lang.String tableCellsTagName)
Check if the table column widths can be represented as percentage values.boolean
isAcceptingProportionalColumnWidths(java.lang.String tableCellsTagName)
Check if the table column widths can be represented as proportional values.boolean
isPreferPercentageColumnWidths(java.lang.String tableCellsTagName)
Check if percentage column widths are preferred.boolean
isTableAcceptingWidth(java.lang.String tableCellsTagName)
Used to determine if the table accepts width specification.boolean
isTableAndColumnsResizable(java.lang.String tableCellsTagName)
This method is used to check if the table and/or table columns can be resized.-
Methods inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
getErrorsListener, setErrorsListener
-
-
-
-
Method Detail
-
getColSpan
public java.lang.Integer getColSpan(AuthorElement cellElement)
Description copied from interface:AuthorTableCellSpanProvider
Get the number of columns the given cell spans across. For example, for the DocBook CALS tables the number of columns the cell spans across is computed by looking at thespanspec
attribute. In case thespanspec
attribute is missing then the column span is defined by thenamest
andnameend
attribute.- Specified by:
getColSpan
in interfaceAuthorTableCellSpanProvider
- Parameters:
cellElement
- 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 java.lang.Integer getRowSpan(AuthorElement cellElement)
Description copied from interface:AuthorTableCellSpanProvider
Get the number of rows that the given cell spans across. For example, for the DocBook CALS tables this value is computed by looking at themorerows
attribute.- Specified by:
getRowSpan
in interfaceAuthorTableCellSpanProvider
- Parameters:
cellElement
- TheAuthorElement
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 tableNode)
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 thecolspec
andspanspec
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 interfaceAuthorTableCellSpanProvider
- Specified by:
init
in interfaceAuthorTableColumnWidthProvider
- Parameters:
tableNode
- TheAuthorElement
representing a table (it has the CSS display property set on 'table').- See Also:
AuthorTableCellSpanProvider.init(AuthorElement)
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
Extension.getDescription()
-
getCALSTableCellSpanProvider
public AuthorTableCellSpanProvider getCALSTableCellSpanProvider()
Get the table span provider for the CALS table model.- Returns:
- The table span provider for the CALS table model.
-
getXHTMLTableCellSpanProvider
public AuthorTableCellSpanProvider getXHTMLTableCellSpanProvider()
Get the table span provider for the HTML table model.- Returns:
- The table span provider for the HTML table model.
-
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 requirescolspec
elements to be present.- Specified by:
hasColumnSpecifications
in interfaceAuthorTableCellSpanProvider
- Parameters:
tableElement
- TheAuthorElement
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 java.util.List<WidthRepresentation> getCellWidth(AuthorElement cellElement, int colNumberStart, int colSpan)
Description copied from interface:AuthorTableColumnWidthProvider
Get the width representation for the cell represented by thecellElement
.
For example for a CALS table cell the list with the width representations is obtained by computing the column span and then determining theWidthRepresentation
for each column the cell spans across.- Specified by:
getCellWidth
in 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
WidthRepresentation
of the specified cell element ornull
if the cell width cannot be computed. If the cell spans over multiple columns then the returned list will contain oneWidthRepresentation
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, java.lang.String tableCellsTagName) throws AuthorOperationException
Description copied from interface:AuthorTableColumnWidthProvider
Updates the column widths in the document and in the column layout model.
For example, for the DocBook CALS tables the method updates the columns width specifications in the source document by setting thecolwidth
attribute value of thecolspec
elements. Newcolspec
elements will be added if needed.- Specified by:
commitColumnWidthModifications
in interfaceAuthorTableColumnWidthProvider
- Parameters:
authorDocumentController
- TheAuthorDocumentController
used to commit the table modifications in the document.colWidths
- The new columnWidthRepresentation
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, java.lang.String tableCellsTagName) throws AuthorOperationException
Description copied from interface:AuthorTableColumnWidthProvider
Commit the table width modification.
For example in the case of DocBook HTML tables sets thewidth
attribute value of thetable
element.- Specified by:
commitTableWidthModification
in interfaceAuthorTableColumnWidthProvider
- Parameters:
authorDocumentController
- TheAuthorDocumentController
used to commit the table width modifications in the document.newTableWidth
- The new tableWidthRepresentation
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(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
Returns a non nullWidthRepresentation
if the table width is currently known.
For the DocBook HTML tables it returns theWidthRepresentation
obtained by analyzing thewidth
attribute value of thetable
element.- Specified by:
getTableWidth
in 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
null
value if the table width is specified. Otherwisenull
. - See Also:
AuthorTableColumnWidthProvider.getTableWidth(java.lang.String)
-
isTableAcceptingWidth
public boolean isTableAcceptingWidth(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
Used to determine if the table accepts width specification.
For example, for the DocBook CALS tables which do not accept anwidth
attribute the method will returnfalse
.- Specified by:
isTableAcceptingWidth
in interfaceAuthorTableColumnWidthProvider
- 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 thetableCellsTagName
accepts width specification of any kind.- See Also:
AuthorTableColumnWidthProvider.isTableAcceptingWidth(java.lang.String)
-
isTableAndColumnsResizable
public boolean isTableAndColumnsResizable(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
This method is used to check if the table and/or table columns can be resized.
For example in the case of the DocBook CALS tables will returntrue
only if the given table cells tag name is equal to'entry'
.- Specified by:
isTableAndColumnsResizable
in interfaceAuthorTableColumnWidthProvider
- 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(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
Check if the table column widths can be represented as fixed values.- Specified by:
isAcceptingFixedColumnWidths
in interfaceAuthorTableColumnWidthProvider
- 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(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
Check if the table column widths can be represented as percentage values.- Specified by:
isAcceptingPercentageColumnWidths
in interfaceAuthorTableColumnWidthProvider
- 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(java.lang.String tableCellsTagName)
Description copied from interface:AuthorTableColumnWidthProvider
Check if the table column widths can be represented as proportional values.- Specified by:
isAcceptingProportionalColumnWidths
in interfaceAuthorTableColumnWidthProvider
- 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)
-
getAllColspecWidthRepresentations
public java.util.List<WidthRepresentation> getAllColspecWidthRepresentations()
Description copied from class:AuthorTableColumnWidthProviderBase
Get 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:
getAllColspecWidthRepresentations
in classAuthorTableColumnWidthProviderBase
- Returns:
- All width representations from the defined colspecs.
- See Also:
AuthorTableColumnWidthProviderBase.getAllColspecWidthRepresentations()
-
isPreferPercentageColumnWidths
public boolean isPreferPercentageColumnWidths(java.lang.String tableCellsTagName)
Description copied from class:AuthorTableColumnWidthProviderBase
Check if percentage column widths are preferred.- Overrides:
isPreferPercentageColumnWidths
in classAuthorTableColumnWidthProviderBase
- Parameters:
tableCellsTagName
- The cell tag name- Returns:
false
by default.- See Also:
AuthorTableColumnWidthProviderBase.isPreferPercentageColumnWidths(java.lang.String)
-
-