Author: ltheussl
Date: Thu May 21 17:15:51 2009
New Revision: 777184
URL: http://svn.apache.org/viewvc?rev=777184&view=rev
Log:
Implement table header cells, update default table properties
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/resources/fo-styles.xslt
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=777184&r1=777183&r2=777184&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
Thu May 21 17:15:51 2009
@@ -26,7 +26,6 @@
import java.util.Stack;
import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.html.HTML.Attribute;
import javax.swing.text.html.HTML.Tag;
@@ -478,10 +477,15 @@
public void listItem()
{
writeStartTag( LIST_ITEM_TAG, "list.item" );
- // TODO customize?
- writeln(
"<fo:list-item-label><fo:block>•</fo:block></fo:list-item-label>" );
+ writeStartTag( LIST_ITEM_LABEL_TAG );
+ writeStartTag( BLOCK_TAG );
+ write( "•" ); // TODO customize?
+ writeEndTag( BLOCK_TAG );
+ writeEndTag( LIST_ITEM_LABEL_TAG );
+ writeEOL();
writeStartTag( LIST_ITEM_BODY_TAG, "list.item" );
- writeStartTag( BLOCK_TAG, "" );
+ writeEOL();
+ writeStartTag( BLOCK_TAG );
}
/** {...@inheritdoc} */
@@ -713,7 +717,8 @@
public void horizontalRule()
{
writeEOL();
- writeStartTag( BLOCK_TAG, "" );
+ writeEOL();
+ writeStartTag( BLOCK_TAG );
writeEmptyTag( LEADER_TAG, "body.rule" );
writeEndTag( BLOCK_TAG );
writeEOL();
@@ -722,7 +727,6 @@
/** {...@inheritdoc} */
public void pageBreak()
{
- //writeln( "<fo:block break-before=\"page\"/>" );
writeEmptyTag( BLOCK_TAG, "break-before", "page" );
writeEOL();
}
@@ -733,8 +737,8 @@
writeEOL();
writeStartTag( BLOCK_TAG, "table.padding" );
- // <fo:table-and-caption> is XSL-FO 1.0 standard but not implemented
in FOP 0.93
- //writeStartTag( TABLE_AND_CAPTION_TAG, "" );
+ // <fo:table-and-caption> is XSL-FO 1.0 standard but still not
implemented in FOP 0.95
+ //writeStartTag( TABLE_AND_CAPTION_TAG );
writeStartTag( TABLE_TAG, "table.layout" );
}
@@ -780,7 +784,7 @@
writeEndTag( TABLE_TAG );
writeEOL();
- // <fo:table-and-caption> is XSL-FO 1.0 standard but not implemented
in FOP 0.93
+ // <fo:table-and-caption> is XSL-FO 1.0 standard but still not
implemented in FOP 0.95
//writeEndTag( TABLE_AND_CAPTION_TAG );
writeEndTag( BLOCK_TAG );
@@ -836,7 +840,6 @@
/** {...@inheritdoc} */
public void tableHeaderCell()
{
- // TODO: how to implement?
tableCell( true );
}
@@ -850,7 +853,7 @@
/**
* Writes a table cell.
*
- * @param headerRow Currently not used.
+ * @param headerRow true if this is a header cell.
*/
private void tableCell( boolean headerRow )
{
@@ -873,22 +876,31 @@
}
}
- if ( justif != null )
- {
- // the column-number is needed for the hack to center the table,
see tableRows.
- write( "<fo:table-cell column-number=\"" + String.valueOf(
cellCount + 2 ) + "\"" );
- if ( tableGrid )
- {
- // http://xmlgraphics.apache.org/fop/faq.html#keep-together
- write( " border-style=\"solid\" border-width=\"0.2mm\"
keep-together.within-column=\"always\"" );
- }
- writeln( config.getAttributeString( "table.body.cell" ) + ">" );
- }
- else
- {
- writeStartTag( TABLE_CELL_TAG, "table.body.cell" );
- }
- writeln( "<fo:block text-align=\"" + justif + "\">" );
+ 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.
+ cellAtts.addAttribute( "column-number", String.valueOf( cellCount + 2
) );
+
+ if ( tableGrid )
+ {
+ cellAtts.addAttributes( config.getAttributeSet(
"table.body.cell.grid" ) );
+ }
+
+ MutableAttributeSet blockAtts = headerRow
+ ? config.getAttributeSet( "table.heading.block" )
+ : config.getAttributeSet( "table.body.block" );
+
+ if ( justif != null )
+ {
+ blockAtts.addAttribute( "text-align", justif );
+ }
+
+ writeStartTag( TABLE_CELL_TAG, cellAtts );
+ writeEOL();
+ writeStartTag( BLOCK_TAG, blockAtts );
+ writeEOL();
}
/** {...@inheritdoc} */
@@ -914,8 +926,8 @@
/** {...@inheritdoc} */
public void tableCaption()
{
- // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in
FOP 0.93
- //writeStartTag( TABLE_CAPTION_TAG, "" );
+ // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in
FOP 0.95
+ //writeStartTag( TABLE_CAPTION_TAG );
// TODO: how to implement this otherwise?
// table-footer doesn't work because it has to be declared before
table-body.
@@ -924,7 +936,7 @@
/** {...@inheritdoc} */
public void tableCaption_()
{
- // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in
FOP 0.93
+ // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in
FOP 0.95
//writeEndTag( TABLE_CAPTION_TAG );
}
@@ -1042,7 +1054,8 @@
public void lineBreak()
{
writeEOL();
- writeEmptyTag( BLOCK_TAG, "" );
+ writeEOL();
+ writeSimpleTag( BLOCK_TAG );
}
/** {...@inheritdoc} */
@@ -1125,7 +1138,7 @@
writeStartTag( ROOT_TAG, atts );
- writeStartTag( LAYOUT_MASTER_SET_TAG, "" );
+ writeStartTag( LAYOUT_MASTER_SET_TAG );
writeStartTag( SIMPLE_PAGE_MASTER_TAG, "layout.master.set.cover-page"
);
writeEmptyTag( REGION_BODY_TAG,
"layout.master.set.cover-page.region-body" );
@@ -1200,8 +1213,7 @@
protected void writeStartTag( Tag tag, String id, String name )
{
writeEOL();
- MutableAttributeSet att = new SimpleAttributeSet();
- att.addAttribute( id, name );
+ MutableAttributeSet att = new SinkEventAttributeSet( new String[] {id,
name} );
writeStartTag( tag, att );
}
@@ -1239,8 +1251,7 @@
*/
protected void writeEmptyTag( Tag tag, String id, String name )
{
- MutableAttributeSet att = new SimpleAttributeSet();
- att.addAttribute( id, name );
+ MutableAttributeSet att = new SinkEventAttributeSet( new String[] {id,
name} );
writeEOL();
writeSimpleTag( tag, att );
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/resources/fo-styles.xslt
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/resources/fo-styles.xslt?rev=777184&r1=777183&r2=777184&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/resources/fo-styles.xslt
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/resources/fo-styles.xslt
Thu May 21 17:15:51 2009
@@ -114,6 +114,7 @@
</xsl:attribute-set>
<xsl:attribute-set name="body.source" use-attribute-sets="body.pre">
<xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
+ <xsl:attribute name="keep-together">always</xsl:attribute>
<xsl:attribute name="white-space-collapse">false</xsl:attribute>
<xsl:attribute name="color">black</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
@@ -355,6 +356,8 @@
<xsl:attribute-set name="base.cell">
<xsl:attribute name="padding-start">2.5pt</xsl:attribute>
<xsl:attribute name="padding-end">5pt</xsl:attribute>
+ <!-- http://xmlgraphics.apache.org/fop/faq.html#keep-together -->
+ <xsl:attribute
name="keep-together.within-column">always</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="base.block">
<xsl:attribute name="font-family">Helvetica,sans-serif</xsl:attribute>
@@ -374,22 +377,24 @@
<xsl:attribute name="border-after-color">black</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.title.block"
use-attribute-sets="base.block">
- <xsl:attribute name="font-size">9.5pt</xsl:attribute>
+ <xsl:attribute name="font-size">11pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.footer.cell" use-attribute-sets="base.cell">
<xsl:attribute name="padding-before">5pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.footer.block"
use-attribute-sets="base.block">
- <xsl:attribute name="font-size">7pt</xsl:attribute>
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
<xsl:attribute name="font-style">italic</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.heading.cell"
use-attribute-sets="base.cell">
<xsl:attribute name="padding-before">7pt</xsl:attribute>
<xsl:attribute name="display-align">after</xsl:attribute>
+ <xsl:attribute name="background-color">#bbbbbb</xsl:attribute>
+ <xsl:attribute name="color">white</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.heading.block"
use-attribute-sets="base.block">
- <xsl:attribute name="font-size">8pt</xsl:attribute>
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.heading.rule">
@@ -402,7 +407,7 @@
<xsl:attribute name="padding-before">6pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.number.block"
use-attribute-sets="base.block">
- <xsl:attribute name="font-size">7pt</xsl:attribute>
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
<xsl:attribute name="font-style">italic</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.subheading.row">
@@ -418,13 +423,13 @@
<xsl:attribute name="display-align">after</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.subheading.block"
use-attribute-sets="base.block">
- <xsl:attribute name="font-size">7pt</xsl:attribute>
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="vertical-align">bottom</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.body.row">
- <xsl:attribute name="keep-together">always</xsl:attribute>
- <xsl:attribute name="keep-with-next">always</xsl:attribute>
+ <xsl:attribute name="keep-together">auto</xsl:attribute>
+ <xsl:attribute name="keep-with-next">auto</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.body.norule">
<xsl:attribute name="leader-length.optimum">100%</xsl:attribute>
@@ -444,15 +449,20 @@
<xsl:attribute name="rule-thickness">0.5pt</xsl:attribute>
<xsl:attribute name="color">black</xsl:attribute>
</xsl:attribute-set>
+ <xsl:attribute-set name="table.body.cell.grid">
+ <xsl:attribute name="border-style">solid</xsl:attribute>
+ <xsl:attribute name="border-width">0.2mm</xsl:attribute>
+ </xsl:attribute-set>
<xsl:attribute-set name="table.body.cell" use-attribute-sets="base.cell">
<xsl:attribute name="padding-before">4pt</xsl:attribute>
<xsl:attribute name="padding-after">1.5pt</xsl:attribute>
+ <xsl:attribute name="background-color">#eeeeee</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.body.block" use-attribute-sets="base.block">
- <xsl:attribute name="font-size">7pt</xsl:attribute>
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table.pre" use-attribute-sets="base.pre.style">
- <xsl:attribute name="font-size">7pt</xsl:attribute>
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
</xsl:attribute-set>
<!-- Table of content styles -->
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java?rev=777184&r1=777183&r2=777184&view=diff
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
Thu May 21 17:15:51 2009
@@ -287,14 +287,17 @@
String dlAtts = getConfig().getAttributeString( "table.padding" );
String dtAtts = getConfig().getAttributeString( "table.layout" );
String ddAtts = getConfig().getAttributeString( "table.body.row" );
- String deAtts = getConfig().getAttributeString( "table.body.cell" );
+ //String deAtts = getConfig().getAttributeString( "table.body.cell" );
+
return EOL + EOL + "<fo:block" + dlAtts + ">" + EOL + "<fo:table" +
dtAtts + ">" + EOL
+ "<fo:table-column
column-width=\"proportional-column-width(1)\"/>"
+ EOL + "<fo:table-column column-width=\"100%\"/>"
+ EOL + "<fo:table-column
column-width=\"proportional-column-width(1)\"/>"
+ EOL + EOL + "<fo:table-body>" + EOL + "<fo:table-row" + ddAtts
- + "><fo:table-cell column-number=\"2\"" + deAtts
- + ">" + EOL + "<fo:block text-align=\"center\">" + EOL + cell
+ + "><fo:table-cell column-number=\"2\" padding-after=\"1.5pt\"
padding-end=\"5pt\" "
+ + "keep-together.within-column=\"always\" padding-start=\"2.5pt\" "
+ + "background-color=\"#eeeeee\" padding-before=\"4pt\">" + EOL +
"<fo:block line-height=\"1.2em\" "
+ + "text-align=\"center\" font-family=\"Helvetica,sans-serif\"
font-size=\"9pt\">" + EOL + cell
+ "</fo:block>" + EOL + "</fo:table-cell>" + EOL +
"</fo:table-row>" + EOL + "</fo:table-body>"
+ EOL + caption + "</fo:table>" + EOL + "</fo:block>" + EOL;
}