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
Fields Modifier and Type Field Description static WidthRepresentation
DEFAULT_WIDTH_REPRESENTATION
The default width representation.protected java.util.List<CALSColSpanSpec>
spanspecInfos
The list with theCALSColSpanSpec
containing information about the columns span specification for this table.-
Fields inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
errorsListener
-
Fields 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
Constructors Constructor Description CALSTableCellInfoProvider()
Constructor.CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault)
Constructor.CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault, TableLayoutErrorsListener errorsListener)
Constructor.
-
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 columns width specifications in the source document by setting thecolwidth
attribute value of thecolspec
elements and by adding newcolspec
elements if needed.void
commitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, java.lang.String tableCellsTagName)
Sets thewidth
attribute value of thetable
element.java.util.List<WidthRepresentation>
getAllColspecWidthRepresentations()
Get all with representations defined in all colspecs.CALSColSpanSpec
getCellSpanSpec(AuthorAccess authorAccess, AuthorElement cellElement)
Find the column span specification for a table cell.java.util.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 theWidthRepresentation
for each column the cell spans across.boolean
getColSep(AuthorElement cellElem, int columnIndex)
Checks if a separator should be placed at the cell right.java.lang.Integer
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.CALSColSpec
getColSpec(int columnNumber)
Find the column specification for the given column number.CALSColSpec
getColSpec(java.lang.String colSpecName)
Find a column specification by name.AuthorElement
getColSpecElement(CALSColSpec colspec)
Find a column specification element.java.util.Set<CALSColSpec>
getColSpecs()
Returns the column specification set corresponding to the CALS table.java.lang.String
getDescription()
boolean
getRowSep(AuthorElement cellElem, int columnIndex)
Checks if a separator should be placed at the cell bottom.java.lang.Integer
getRowSpan(AuthorElement cellElement)
Compute the number of rows the cells span across by looking at themorerows
attribute.WidthRepresentation
getTableWidth(java.lang.String tableCellsTagName)
Returns theWidthRepresentation
obtained by analyzing thewidth
attribute value of thetable
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(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.protected boolean
isColspec(AuthorElement child)
Check if the child is a column specification.boolean
isTableAcceptingWidth(java.lang.String tableCellsTagName)
The DocBook CALS tables do not accept width specification.boolean
isTableAndColumnsResizable(java.lang.String tableCellsTagName)
It returnstrue
only if the given table cells tag name is equal to'entry'
.protected boolean
isTableCell(java.lang.String tableCellsTagName)
Check if the name of an element is a table cell.protected boolean
isTableElement(AuthorElement element)
Check if this element is atable
element.protected boolean
isTgroupElement(AuthorElement element)
Check if this element is atgroup
element.-
Methods inherited from class ro.sync.ecss.extensions.api.AuthorTableColumnWidthProviderBase
getErrorsListener, isPreferPercentageColumnWidths, setErrorsListener
-
-
-
-
Field Detail
-
DEFAULT_WIDTH_REPRESENTATION
public static final WidthRepresentation DEFAULT_WIDTH_REPRESENTATION
The default width representation. PUBLIC BECAUSE IT WAS USED IN OLDER VERSIONS AS API.
-
spanspecInfos
protected java.util.List<CALSColSpanSpec> spanspecInfos
The list with theCALSColSpanSpec
containing information about the columns span specification for this table.
-
-
Constructor Detail
-
CALSTableCellInfoProvider
public CALSTableCellInfoProvider(boolean colsepAndRowSepAreVisibleByDefault)
Constructor.- Parameters:
colsepAndRowSepAreVisibleByDefault
- The default visibility for the rowsep and colsep. (i.e. if nocolsep
orrowsep
attributes are present in the table).
-
CALSTableCellInfoProvider
public CALSTableCellInfoProvider()
Constructor. The default visibility for the rowsep and colsep. (i.e. if nocolsep
orrowsep
attributes 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 nocolsep
orrowsep
attributes are present in the table).errorsListener
- Table layout errors listener.
-
-
Method Detail
-
getColSpan
public java.lang.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 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
null
if not specified. - See Also:
AuthorTableCellSpanProvider.getColSpan(AuthorElement)
-
getColSpanInterval
public int[] getColSpanInterval(AuthorElement cellElem)
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
public java.lang.Integer getRowSpan(AuthorElement cellElement)
Compute the number of rows the cells span across 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 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 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 interfaceAuthorTableCellSepProvider
- Specified by:
init
in interfaceAuthorTableCellSpanProvider
- Specified by:
init
in interfaceAuthorTableColumnWidthProvider
- Parameters:
tableElement
- TheAuthorElement
representing a table (it has the CSS display property set on 'table').- See Also:
AuthorTableColumnWidthProvider.init(ro.sync.ecss.extensions.api.node.AuthorElement)
-
isColspec
protected boolean isColspec(AuthorElement child)
Check if the child is a column specification.- Parameters:
child
- The child- Returns:
true
if the child is a column specification.
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- 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(java.lang.String colSpecName)
Find a column specification by name.- Parameters:
colSpecName
- The name of column specification.- Returns:
- The column specification or
null
if no column specification is defined for the given colspec name.
-
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. 1 based.
-
getColSpecElement
public AuthorElement getColSpecElement(CALSColSpec colspec)
Find a column specification element.- Parameters:
colspec
- The column specification.- Returns:
- The column specification element or
null
if no column corresponds to the given specification.
-
getColSpecs
public java.util.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 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)
The list with the width representations for the given cell 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
Updates the columns width specifications in the source document by setting thecolwidth
attribute value of thecolspec
elements and by adding newcolspec
elements 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)
-
isTableCell
protected boolean isTableCell(java.lang.String tableCellsTagName)
Check if the name of an element is a table cell.- Parameters:
tableCellsTagName
- The name of an element.- Returns:
true
if the name of an element is a table cell.
-
commitTableWidthModification
public void commitTableWidthModification(AuthorDocumentController authorDocumentController, int newTableWidth, java.lang.String tableCellsTagName) throws AuthorOperationException
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)
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)
The DocBook CALS tables do not accept width specification.- 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)
It returnstrue
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()
-
getColSep
public boolean getColSep(AuthorElement cellElem, int columnIndex)
Description copied from interface:AuthorTableCellSepProvider
Checks 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:
getColSep
in 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:
true
if a separator should be placed at its right,false
otherwise.- See Also:
AuthorTableCellSepProvider.getColSep(ro.sync.ecss.extensions.api.node.AuthorElement, int)
-
getRowSep
public boolean getRowSep(AuthorElement cellElem, int columnIndex)
Description copied from interface:AuthorTableCellSepProvider
Checks 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:
getRowSep
in 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:
true
if a separator should be placed at its right,false
otherwise.- See Also:
AuthorTableCellSepProvider.getRowSep(ro.sync.ecss.extensions.api.node.AuthorElement, int)
-
isTableElement
protected boolean isTableElement(AuthorElement element)
Check if this element is atable
element.- Parameters:
element
- The analyzed element.- Returns:
true
if this element is a CALStable
element.
-
isTgroupElement
protected boolean isTgroupElement(AuthorElement element)
Check if this element is atgroup
element.- Parameters:
element
- The analyzed element.- Returns:
true
if this element is a CALStgroup
element.
-
-