You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2009/06/05 15:59:13 UTC
svn commit: r782017 -
/maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
Author: vsiveton
Date: Fri Jun 5 13:59:13 2009
New Revision: 782017
URL: http://svn.apache.org/viewvc?rev=782017&view=rev
Log:
DOXIA-332: Problem with Tables, Doxia, APT Maven site and PDF/RTF generation
o fixed tableCaption
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java?rev=782017&r1=782016&r2=782017&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java Fri Jun 5 13:59:13 2009
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.StringReader;
+import java.io.StringWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
@@ -107,7 +108,9 @@
private int depth = 0;
- private String tableCaption = null;
+ private StringWriter tableCaption = null;
+
+ private XMLWriter tableCaptionWriter = null;
/** Flag to know if an anchor is defined or not. Used as workaround for iText which needs a defined local
* destination. */
@@ -888,24 +891,30 @@
/** {@inheritDoc} */
public void table_()
{
- writeEndElement(); // ElementTags.TABLE
+ if ( tableCaptionWriter != null )
+ {
+ tableCaptionWriter = null;
- writeEndElement(); // ElementTags.CHUNK
+ writeEndElement(); // ElementTags.TABLE
- actionContext.release();
+ writeEndElement(); // ElementTags.CHUNK
- if ( tableCaption != null )
- {
- writeStartElement( ElementTags.PARAGRAPH );
- writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+ writeStartElement( ElementTags.PARAGRAPH );
+ writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
- write( tableCaption );
+ write( tableCaption.toString(), true );
- writeEndElement(); // ElementTags.PARAGRAPH
+ writeEndElement(); // ElementTags.PARAGRAPH
- tableCaption = null;
+ tableCaption = null;
}
+ else
+ {
+ writeEndElement(); // ElementTags.TABLE
+ writeEndElement(); // ElementTags.CHUNK
+ }
+ actionContext.release();
}
/** {@inheritDoc} */
@@ -943,6 +952,8 @@
/** {@inheritDoc} */
public void tableCaption()
{
+ tableCaption = new StringWriter();
+ tableCaptionWriter = new PrettyPrintXMLWriter( tableCaption );
actionContext.setAction( SinkActionContext.TABLE_CAPTION );
}
@@ -1457,7 +1468,7 @@
break;
case SinkActionContext.TABLE_CAPTION:
- this.tableCaption = text;
+ this.tableCaptionWriter.writeText( text );
break;
case SinkActionContext.VERBATIM:
@@ -1560,7 +1571,14 @@
*/
private void writeStartElement( String tag )
{
- xmlWriter.startElement( tag );
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.startElement( tag );
+ }
+ else
+ {
+ tableCaptionWriter.startElement( tag );
+ }
}
/**
@@ -1571,7 +1589,14 @@
*/
private void writeAddAttribute( String key, String value )
{
- xmlWriter.addAttribute( key, value );
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.addAttribute( key, value );
+ }
+ else
+ {
+ tableCaptionWriter.addAttribute( key, value );
+ }
}
/**
@@ -1582,7 +1607,14 @@
*/
private void writeAddAttribute( String key, int value )
{
- xmlWriter.addAttribute( key, String.valueOf( value ) );
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.addAttribute( key, String.valueOf( value ) );
+ }
+ else
+ {
+ tableCaptionWriter.addAttribute( key, String.valueOf( value ) );
+ }
}
/**
@@ -1590,7 +1622,14 @@
*/
private void writeEndElement()
{
- xmlWriter.endElement();
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.endElement();
+ }
+ else
+ {
+ tableCaptionWriter.endElement();
+ }
}
/**
@@ -1656,11 +1695,25 @@
}
if ( escapeHtml )
{
- xmlWriter.writeMarkup( aString );
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.writeMarkup( aString );
+ }
+ else
+ {
+ tableCaptionWriter.writeMarkup( aString );
+ }
}
else
{
- xmlWriter.writeText( aString );
+ if ( tableCaptionWriter == null )
+ {
+ xmlWriter.writeText( aString );
+ }
+ else
+ {
+ tableCaptionWriter.writeText( aString );
+ }
}
}