* @param headerRow true if this is a header cell.
* @param attributes the cell attributes, could be null.
*/
private void tableCell( boolean headerRow, SinkEventAttributes attributes )
{
MutableAttributeSet cellAtts = headerRow
? config.getAttributeSet( "table.heading.cell" )
: config.getAttributeSet( "table.body.cell" );
// the column-number is needed for the hack to center the table, see tableRows.
int cellCount = Integer.parseInt( this.cellCountStack.getLast().toString() );
cellAtts.addAttribute( "column-number", String.valueOf( cellCount + 1 ) );
if ( this.tableGridStack.getLast().equals( Boolean.TRUE ) )
{
cellAtts.addAttributes( config.getAttributeSet( "table.body.cell.grid" ) );
}
MutableAttributeSet blockAtts = headerRow
? config.getAttributeSet( "table.heading.block" )
: config.getAttributeSet( "table.body.block" );
String justif = null;
if ( attributes == null )
{
attributes = new SinkEventAttributeSet( 0 );
}
if ( attributes.isDefined( Attribute.ALIGN.toString() ) )
{
justif = attributes.getAttribute( Attribute.ALIGN.toString() ).toString();
}
int[] cellJustif = this.cellJustifStack.getLast();
if ( justif == null && cellJustif != null && cellJustif.length > 0
&& this.isCellJustifStack.getLast().equals( Boolean.TRUE ) )
{
switch ( cellJustif[Math.min( cellCount, cellJustif.length - 1 )] )
{
case JUSTIFY_LEFT:
justif = "left";
break;
case JUSTIFY_RIGHT:
justif = "right";
break;
case JUSTIFY_CENTER:
default:
justif = "center";
}
}
if ( justif != null )
{
blockAtts.addAttribute( "text-align", justif );
}
writeStartTag( TABLE_CELL_TAG, cellAtts );
writeEOL();
writeStartTag( BLOCK_TAG, blockAtts );