maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r406450 [1/2] - in /maven/doxia/trunk/doxia-modules/doxia-module-itext: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/doxia/ src/main/java/org/ap...
Date Sun, 14 May 2006 22:15:33 GMT
Author: jvanzyl
Date: Sun May 14 15:15:30 2006
New Revision: 406450

URL: http://svn.apache.org/viewcvs?rev=406450&view=rev
Log:
o adding vincent's itext stuff

Added:
    maven/doxia/trunk/doxia-modules/doxia-module-itext/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextUtil.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/resources/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/ITextSinkTestCase.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/apt/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/apt/guide-ide-netbeans.apt   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/apt/test.apt   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/apt/test.apt.bak
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Context_Menu.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Generate_Site.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Open_Project.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Project_Opened.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Refresh_Project.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Refreshed_Context_Menu.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Run_Build_Main_Project.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Run_Clean_Main_Project.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/images/Window_Files.png   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/xdoc/
    maven/doxia/trunk/doxia-modules/doxia-module-itext/src/test/resources/xdoc/test.xml   (with props)

Added: maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml?rev=406450&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml Sun May 14 15:15:30 2006
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <artifactId>doxia-modules</artifactId>
+    <groupId>org.apache.maven.doxia</groupId>
+    <version>1.0-alpha-8-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>doxia-module-itext</artifactId>
+  <name>Doxia iText Module</name>
+  <version>1.0-SNAPSHOT</version>
+  <developers>
+    <developer>
+      <id>vsiveton</id>
+      <name>Vincent Siveton</name>
+      <email>vsiveton@apache.org</email>
+      <organization>Apache Software Foundation</organization>
+      <roles>
+        <role>Java Developer</role>
+      </roles>
+      <timezone>-5</timezone>
+    </developer>
+  </developers>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.4</source>
+          <target>1.4</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>itext</groupId>
+      <artifactId>itext</artifactId>
+      <version>1.3.1</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java?rev=406450&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java Sun May 14 15:15:30 2006
@@ -0,0 +1,375 @@
+package org.apache.maven.doxia.module.itext;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.awt.Color;
+
+import com.lowagie.text.Font;
+import com.lowagie.text.FontFactory;
+import com.lowagie.text.markup.MarkupTags;
+import com.lowagie.text.pdf.DefaultFontMapper;
+import com.lowagie.text.pdf.FontMapper;
+
+/**
+ * <code>iText</code> wrapper object for font.
+ *
+ * @see com.lowagie.text.Font
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class ITextFont
+{
+    /** A normal font style */
+    public static final String NORMAL = MarkupTags.CSS_VALUE_NORMAL;
+
+    /** A bold font style */
+    public static final String BOLD = MarkupTags.CSS_VALUE_BOLD;
+
+    /** A italic font style */
+    public static final String ITALIC = MarkupTags.CSS_VALUE_ITALIC;
+
+    /** An underline font style */
+    public static final String UNDERLINE = MarkupTags.CSS_VALUE_UNDERLINE;
+
+    /** A default font name */
+    public static final String DEFAULT_FONT_NAME = FontFactory.HELVETICA;
+
+    /** A default font size */
+    public static final float DEFAULT_FONT_SIZE = 12;
+
+    /** A default font style */
+    public static final String DEFAULT_FONT_STYLE = NORMAL;
+
+    /** A default Black color definition */
+    public static final int DEFAULT_FONT_COLOR_RED = Color.BLACK.getRed();
+
+    /** A default Black color definition */
+    public static final int DEFAULT_FONT_COLOR_GREEN = Color.BLACK.getGreen();
+
+    /** A default Black color definition */
+    public static final int DEFAULT_FONT_COLOR_BLUE = Color.BLACK.getBlue();
+
+    /** To specify monoSpaced font */
+    private static final FontMapper FONT_MAPPER = new DefaultFontMapper();
+
+    private boolean monoSpaced = false;
+
+    private float currentSize = 12;
+
+    private int currentStyle = Font.NORMAL;
+
+    private Color currentColor = Color.BLACK;
+
+    /**
+     * Default constructor
+     */
+    public ITextFont()
+    {
+        // nop
+    }
+
+    /**
+     * Add bold style to the current style
+     */
+    public void addBold()
+    {
+        this.currentStyle += Font.BOLD;
+    }
+
+    /**
+     * Remove bold style to the current style
+     */
+    public void removeBold()
+    {
+        this.currentStyle -= Font.BOLD;
+        if ( this.currentStyle < 0 )
+        {
+            this.currentStyle = Font.NORMAL;
+        }
+    }
+
+    /**
+     * Add italic style to the current style
+     */
+    public void addItalic()
+    {
+        this.currentStyle += Font.ITALIC;
+    }
+
+    /**
+     * Remove italic style to the current style
+     */
+    public void removeItalic()
+    {
+        this.currentStyle -= Font.ITALIC;
+        if ( this.currentStyle < 0 )
+        {
+            this.currentStyle = Font.NORMAL;
+        }
+    }
+
+    /**
+     * Add italic style to the current style
+     */
+    public void addUnderlined()
+    {
+        this.currentStyle += Font.UNDERLINE;
+    }
+
+    /**
+     * Remove italic style to the current style
+     */
+    public void removeUnderlined()
+    {
+        this.currentStyle -= Font.UNDERLINE;
+        if ( this.currentStyle < 0 )
+        {
+            this.currentStyle = Font.NORMAL;
+        }
+    }
+
+    /**
+     * Add monospaced style to the current style
+     *
+     * @param monoSpaced true for monospaced style
+     */
+    public void setMonoSpaced( boolean monoSpaced )
+    {
+        this.monoSpaced = monoSpaced;
+    }
+
+    /**
+     * Set a new font color
+     *
+     * @param color a new color
+     */
+    public void setColor( Color color )
+    {
+        this.currentColor = color;
+    }
+
+    /**
+     * Set a new font color
+     *
+     * @param size a new size
+     */
+    public void setSize( float size )
+    {
+        this.currentSize = size;
+    }
+
+    /**
+     * Return the font name
+     *
+     * @return the font name
+     */
+    public String getFontName()
+    {
+        Font font = getCurrentFont();
+
+        return font.getFamilyname();
+    }
+
+    /**
+     * Return the font style
+     *
+     * @return the font style
+     */
+    public String getFontStyle()
+    {
+        Font font = getCurrentFont();
+        StringBuffer sb = new StringBuffer();
+
+        if ( font.isBold() )
+        {
+            sb.append( BOLD );
+        }
+
+        if ( font.isItalic() )
+        {
+            if ( sb.length() == 0 )
+            {
+                sb.append( ITALIC );
+            }
+            else
+            {
+                sb.append( "," );
+                sb.append( ITALIC );
+            }
+        }
+
+        if ( font.isUnderlined() )
+        {
+            if ( sb.length() == 0 )
+            {
+                sb.append( UNDERLINE );
+            }
+            else
+            {
+                sb.append( "," );
+                sb.append( UNDERLINE );
+            }
+        }
+
+        if ( sb.length() == 0 )
+        {
+            return NORMAL;
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Return the font name
+     *
+     * @return the font name
+     */
+    public String getFontSize()
+    {
+        Font font = getCurrentFont();
+
+        return String.valueOf( font.getCalculatedSize() );
+    }
+
+    /**
+     * Return the font color blue
+     *
+     * @return the font color blue
+     */
+    public String getFontColorBlue()
+    {
+        Font font = getCurrentFont();
+
+        return String.valueOf( font.color().getBlue() );
+    }
+
+    /**
+     * Return the font color green
+     *
+     * @return the font color green
+     */
+    public String getFontColorGreen()
+    {
+        Font font = getCurrentFont();
+
+        return String.valueOf( font.color().getGreen() );
+    }
+
+    /**
+     * Return the font color red
+     *
+     * @return the font color red
+     */
+    public String getFontColorRed()
+    {
+        Font font = getCurrentFont();
+
+        return String.valueOf( font.color().getRed() );
+    }
+
+    /**
+     * Get a section font depending the section number.
+     * <dl>
+     * <dt>0</dt>
+     * <dd>Chapter: font size = 24</dd>
+     * <dt>1</dt>
+     * <dd>Section 1: font size = 22</dd>
+     * <dt>2</dt>
+     * <dd>Section 2: font size = 20</dd>
+     * <dt>3</dt>
+     * <dd>Section 3: font size = 18</dd>
+     * <dt>4</dt>
+     * <dd>Section 4: font size = 16</dd>
+     * <dt>5 ot otherwise</dt>
+     * <dd>Section 5: font size = 14</dd>
+     * </dl>
+     *
+     * @param sectionNumber a section number
+     * @return a font
+     */
+    public static int getSectionFontSize( int sectionNumber )
+    {
+        switch ( sectionNumber )
+        {
+            case 0:
+                return 24;
+
+            case 1:
+                return 22;
+
+            case 2:
+                return 20;
+
+            case 3:
+                return 18;
+
+            case 4:
+                return 16;
+
+            case 5:
+            default:
+                return 14;
+        }
+    }
+
+    /**
+     * Convenience method to get a defined MonoSpaced font depending the wanted style and size.
+     *
+     * @param style
+     * @param size
+     * @param color
+     * @return a font
+     */
+    public static Font getMonoSpacedFont( int style, float size, Color color )
+    {
+        return new Font( FONT_MAPPER.awtToPdf( new java.awt.Font( "Monospaced", 0, 0 ) ), size, style, color );
+    }
+
+    /**
+     * Convenience method to get a defined font depending the wanted style and size.
+     *
+     * @param style
+     * @param size
+     * @param color
+     * @return a font
+     */
+    public static Font getFont( int style, float size, Color color )
+    {
+        Font font = new Font();
+        font.setFamily( DEFAULT_FONT_NAME );
+        font.setStyle( style );
+        font.setSize( size );
+        font.setColor( color );
+        return font;
+    }
+
+    /**
+     * Convenience method to return the current font
+     *
+     * @return the current font
+     */
+    private Font getCurrentFont()
+    {
+        if ( this.monoSpaced )
+        {
+            return getMonoSpacedFont( this.currentStyle, this.currentSize, this.currentColor );
+        }
+
+        return getFont(this.currentStyle, this.currentSize, this.currentColor );
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextFont.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java?rev=406450&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java Sun May 14 15:15:30 2006
@@ -0,0 +1,133 @@
+package org.apache.maven.doxia.module.itext;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Date;
+
+/**
+ * Header object containing meta-informations.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class ITextHeader
+{
+    private String title;
+
+    private StringBuffer authors;
+
+    private Date date;
+
+    /**
+     * Default constructor
+     */
+    public ITextHeader()
+    {
+        // nop
+    }
+
+    /**
+     * Add a title to the Document
+     *
+     * @param title1
+     */
+    public final void setTitle( String title1 )
+    {
+        this.title = title1;
+    }
+
+    /**
+     * Get the title
+     *
+     * @return title as String
+     */
+    public String getTitle()
+    {
+        if ( this.title == null )
+        {
+            return "";
+        }
+
+        return this.title;
+    }
+
+    /**
+     * Add a new author
+     *
+     * @param author
+     */
+    public void addAuthor( String author )
+    {
+        if ( this.authors == null )
+        {
+            this.authors = new StringBuffer();
+        }
+        else
+        {
+            this.authors.append( ", " );
+        }
+
+        this.authors.append( author );
+    }
+
+    /**
+     * Get the authors
+     *
+     * @return the authors as String
+     */
+    public String getAuthors()
+    {
+        if ( ( this.authors == null ) || ( this.authors.length() == 0 ) )
+        {
+            return System.getProperty( "user.name" );
+        }
+
+        return this.authors.toString();
+    }
+
+    /**
+     * Add a date to the document
+     *
+     * @param date1 a date as String
+     */
+    public void setDate( String date1 )
+    {
+        try
+        {
+            this.date = new Date( date1 );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            this.date = new Date();
+        }
+    }
+
+    /**
+     * Get the date of the document
+     *
+     * @return the date as String
+     */
+    public String getDate()
+    {
+        if ( this.date == null )
+        {
+            return new Date( System.currentTimeMillis() ).toString();
+        }
+
+        return this.date.toString();
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextHeader.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java?rev=406450&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java Sun May 14 15:15:30 2006
@@ -0,0 +1,1887 @@
+package org.apache.maven.doxia.module.itext;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.awt.Color;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.maven.doxia.module.HtmlTools;
+import org.apache.maven.doxia.module.SinkActionContext;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkAdapter;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+import com.lowagie.text.BadElementException;
+import com.lowagie.text.ElementTags;
+import com.lowagie.text.Image;
+
+/**
+ * <p>A doxia Sink which produces an XML Front End document for <code>iText</code> framework.</p>
+ * Known limitations:
+ * <ul>
+ * <li>Roman lists are not supported.</li>
+ * <li>Horizontal rule is not supported with 1.3.
+ * See <a href="http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg10323.html">http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg10323.html</a></li>
+ * <li>iText has some problems with <code>ElementTags.TABLE</code> and <code>ElementTags.TABLEFITSPAGE</code>.
+ * See http://sourceforge.net/tracker/index.php?func=detail&aid=786427&group_id=15255&atid=115255.</li>
+ * <li>Images could be on another page and next text on the last one.</li>
+ * </ul>
+ *
+ * @see <a href="http://www.lowagie.com/iText/tutorial/ch07.html">http://www.lowagie.com/iText/tutorial/ch07.html</a>
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.doxia.sink.Sink"
+ * role-hint="pdf"
+ */
+public final class ITextSink
+    extends SinkAdapter
+{
+    /** This is the place where the iText DTD is located. IMPORTANT: this DTD is not uptodate! */
+    public final static String DTD = "http://itext.sourceforge.net/itext.dtd";
+
+    /** This is the reference to the DTD. */
+    public static final String DOCTYPE = "ITEXT SYSTEM \"" + DTD + "\"";
+
+    /** This is the default leading for chapter title */
+    public static final String DEFAULT_CHAPTER_TITLE_LEADING = "36.0";
+
+    /** This is the default leading for section title */
+    public static final String DEFAULT_SECTION_TITLE_LEADING = "24.0";
+
+    /** The ClassLoader used */
+    private ClassLoader currentClassLoader;
+
+    /** The action context */
+    private SinkActionContext actionContext;
+
+    /** The Writer used */
+    private Writer writer;
+
+    /** The XML Writer used */
+    private XMLWriter xmlWriter;
+
+    /** The Header object */
+    private ITextHeader header;
+
+    /** The font object */
+    private ITextFont font;
+
+    private int numberDepth = 0;
+
+    private int depth = 0;
+
+    /**
+     * Default constructor
+     *
+     * @param w a writer
+     */
+    public ITextSink( Writer w )
+    {
+        this.writer = w;
+
+        this.actionContext = new SinkActionContext();
+        this.font = new ITextFont();
+        this.header = new ITextHeader();
+
+        this.xmlWriter = new PrettyPrintXMLWriter( this.writer, "UTF-8", null );//, DOCTYPE );
+    }
+
+    /**
+     * Get the current classLoader
+     *
+     * @return the current class loader
+     */
+    public ClassLoader getClassLoader()
+    {
+        return this.currentClassLoader;
+    }
+
+    /**
+     * Set a new class loader
+     *
+     * @param cl
+     */
+    public void setClassLoader( ClassLoader cl )
+    {
+        this.currentClassLoader = cl;
+    }
+
+    // ----------------------------------------------------------------------
+    // Document
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#close()
+     */
+    public void close()
+    {
+        IOUtil.close( this.writer );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#flush()
+     */
+    public void flush()
+    {
+        super.flush();
+    }
+
+    // ----------------------------------------------------------------------
+    // Header
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#head_()
+     */
+    public void head_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#head()
+     */
+    public void head()
+    {
+        this.actionContext.setAction( SinkActionContext.HEAD );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#author_()
+     */
+    public void author_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#author()
+     */
+    public void author()
+    {
+        this.actionContext.setAction( SinkActionContext.AUTHOR );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#date_()
+     */
+    public void date_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#date()
+     */
+    public void date()
+    {
+        this.actionContext.setAction( SinkActionContext.DATE );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#title_()
+     */
+    public void title_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#title()
+     */
+    public void title()
+    {
+        this.actionContext.setAction( SinkActionContext.TITLE );
+    }
+
+    // ----------------------------------------------------------------------
+    // Body
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#body_()
+     */
+    public void body_()
+    {
+        writeEndElement(); // ElementTags.CHAPTER
+
+        writeEndElement(); // ElementTags.ITEXT
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#body()
+     */
+    public void body()
+    {
+        writeStartElement( ElementTags.ITEXT );
+        writeAddAttribute( ElementTags.TITLE, this.header.getTitle() );
+        writeAddAttribute( ElementTags.AUTHOR, this.header.getAuthors() );
+        writeAddAttribute( ElementTags.CREATIONDATE, this.header.getDate() );
+        writeAddAttribute( ElementTags.SUBJECT, this.header.getTitle() );
+        writeAddAttribute( ElementTags.KEYWORDS, "" );
+        writeAddAttribute( ElementTags.PRODUCER, "Generated with Doxia by " + System.getProperty( "user.name" ) );
+        writeAddAttribute( ElementTags.PAGE_SIZE, ITextUtil.getPageSize( ITextUtil.getDefaultPageSize() ) );
+
+        writeStartElement( ElementTags.CHAPTER );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_CHAPTER_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME );
+        writeAddAttribute( ElementTags.SIZE, ITextFont.getSectionFontSize( 0 ) );
+        writeAddAttribute( ElementTags.STYLE, ITextFont.BOLD );
+        writeAddAttribute( ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE );
+        writeAddAttribute( ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN );
+        writeAddAttribute( ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME );
+        writeAddAttribute( ElementTags.SIZE, ITextFont.getSectionFontSize( 0 ) );
+        writeAddAttribute( ElementTags.STYLE, ITextFont.BOLD );
+        writeAddAttribute( ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE );
+        writeAddAttribute( ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN );
+        writeAddAttribute( ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED );
+        writeAddAttribute( ElementTags.LOCALDESTINATION, "top" );
+
+        write( this.header.getTitle() );
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        writeEndElement(); // ElementTags.TITLE
+
+        this.actionContext.setAction( SinkActionContext.BODY );
+    }
+
+    // ----------------------------------------------------------------------
+    // Sections
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#sectionTitle()
+     */
+    public void sectionTitle()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#sectionTitle_()
+     */
+    public void sectionTitle_()
+    {
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section1_()
+     */
+    public void section1_()
+    {
+        writeEndElement(); // ElementTags.SECTION
+
+        this.numberDepth--;
+        this.depth = 0;
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section1()
+     */
+    public void section1()
+    {
+        this.numberDepth++;
+        this.depth = 1;
+
+        writeStartElement( ElementTags.SECTION );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        lineBreak();
+
+        this.actionContext.setAction( SinkActionContext.SECTION_1 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#sectionTitle1_()
+     */
+    public void sectionTitle1_()
+    {
+        writeEndElement(); // ElementTags.TITLE
+
+        this.font.setSize( ITextFont.DEFAULT_FONT_SIZE );
+        bold_();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#sectionTitle()
+     */
+    public void sectionTitle1()
+    {
+        this.font.setSize( ITextFont.getSectionFontSize( 1 ) );
+        this.font.setColor( Color.BLACK );
+        bold();
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_SECTION_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE_1 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section2_()
+     */
+    public void section2_()
+    {
+        writeEndElement(); // ElementTags.SECTION
+
+        this.numberDepth--;
+        this.depth = 0;
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section2()
+     */
+    public void section2()
+    {
+        this.numberDepth++;
+        this.depth = 1;
+
+        writeStartElement( ElementTags.SECTION );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        lineBreak();
+
+        this.actionContext.setAction( SinkActionContext.SECTION_2 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle2_()
+     */
+    public void sectionTitle2_()
+    {
+        writeEndElement(); // ElementTags.TITLE
+
+        this.font.setSize( ITextFont.DEFAULT_FONT_SIZE );
+        bold_();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle2()
+     */
+    public void sectionTitle2()
+    {
+        this.font.setSize( ITextFont.getSectionFontSize( 2 ) );
+        this.font.setColor( Color.BLACK );
+        bold();
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_SECTION_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE_2 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section3_()
+     */
+    public void section3_()
+    {
+        writeEndElement(); // ElementTags.SECTION
+
+        this.numberDepth--;
+        this.depth = 1;
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section3()
+     */
+    public void section3()
+    {
+        this.numberDepth++;
+        this.depth = 1;
+
+        writeStartElement( ElementTags.SECTION );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        lineBreak();
+
+        this.actionContext.setAction( SinkActionContext.SECTION_3 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle3_()
+     */
+    public void sectionTitle3_()
+    {
+        writeEndElement(); // ElementTags.TITLE
+
+        this.font.setSize( ITextFont.DEFAULT_FONT_SIZE );
+        bold_();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle3()
+     */
+    public void sectionTitle3()
+    {
+        this.font.setSize( ITextFont.getSectionFontSize( 3 ) );
+        this.font.setColor( Color.BLACK );
+        bold();
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_SECTION_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE_3 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section4_()
+     */
+    public void section4_()
+    {
+        writeEndElement(); // ElementTags.SECTION
+
+        this.numberDepth--;
+        this.depth = 1;
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section4()
+     */
+    public void section4()
+    {
+        this.numberDepth++;
+        this.depth = 1;
+
+        writeStartElement( ElementTags.SECTION );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        lineBreak();
+
+        this.actionContext.setAction( SinkActionContext.SECTION_4 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle4_()
+     */
+    public void sectionTitle4_()
+    {
+        writeEndElement(); // ElementTags.TITLE
+
+        this.font.setSize( ITextFont.DEFAULT_FONT_SIZE );
+        bold_();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle4()
+     */
+    public void sectionTitle4()
+    {
+        this.font.setSize( ITextFont.getSectionFontSize( 4 ) );
+        this.font.setColor( Color.BLACK );
+        bold();
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_SECTION_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE_4 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section5_()
+     */
+    public void section5_()
+    {
+        writeEndElement(); // ElementTags.SECTION
+
+        this.numberDepth--;
+        this.depth = 1;
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#section5()
+     */
+    public void section5()
+    {
+        this.numberDepth++;
+        this.depth = 1;
+
+        writeStartElement( ElementTags.SECTION );
+        writeAddAttribute( ElementTags.NUMBERDEPTH, this.numberDepth );
+        writeAddAttribute( ElementTags.DEPTH, this.depth );
+        writeAddAttribute( ElementTags.INDENT, "0.0" );
+
+        lineBreak();
+
+        this.actionContext.setAction( SinkActionContext.SECTION_5 );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle5_()
+     */
+    public void sectionTitle5_()
+    {
+        writeEndElement(); // ElementTags.TITLE
+
+        this.font.setSize( ITextFont.DEFAULT_FONT_SIZE );
+        bold_();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#sectionTitle5()
+     */
+    public void sectionTitle5()
+    {
+        this.font.setSize( ITextFont.getSectionFontSize( 5 ) );
+        this.font.setColor( Color.BLACK );
+        bold();
+
+        writeStartElement( ElementTags.TITLE );
+        writeAddAttribute( ElementTags.LEADING, DEFAULT_SECTION_TITLE_LEADING );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.SECTION_TITLE_5 );
+    }
+
+    // ----------------------------------------------------------------------
+    // Paragraph
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#paragraph_()
+     */
+    public void paragraph_()
+    {
+        // Special case
+        if ( ( this.actionContext.getCurrentAction() == SinkActionContext.LIST_ITEM )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.NUMBERED_LIST_ITEM )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.DEFINITION ) )
+        {
+            return;
+        }
+
+        writeEndElement(); // ElementTags.PARAGRAPH
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#paragraph()
+     */
+    public void paragraph()
+    {
+        // Special case
+        if ( ( this.actionContext.getCurrentAction() == SinkActionContext.LIST_ITEM )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.NUMBERED_LIST_ITEM )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.DEFINITION ) )
+        {
+            return;
+        }
+
+        writeStartElement( ElementTags.PARAGRAPH );
+
+        writeStartElement( ElementTags.NEWLINE );
+        writeEndElement();
+
+        this.actionContext.setAction( SinkActionContext.PARAGRAPH );
+    }
+
+    // ----------------------------------------------------------------------
+    // Lists
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#list_()
+     */
+    public void list_()
+    {
+        writeEndElement(); // ElementTags.LIST
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#list()
+     */
+    public void list()
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.LIST );
+        writeAddAttribute( ElementTags.NUMBERED, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.SYMBOLINDENT, "15" );
+
+        this.actionContext.setAction( SinkActionContext.LIST );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#listItem_()
+     */
+    public void listItem_()
+    {
+        writeEndElement(); // ElementTags.LISTITEM
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#listItem()
+     */
+    public void listItem()
+    {
+        writeStartElement( ElementTags.LISTITEM );
+        writeAddAttribute( ElementTags.INDENTATIONLEFT, "20.0" );
+
+        this.actionContext.setAction( SinkActionContext.LIST_ITEM );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#numberedList_()
+     */
+    public void numberedList_()
+    {
+        writeEndElement(); // ElementTags.LIST
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#numberedList(int)
+     */
+    public void numberedList( int numbering )
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.LIST );
+        writeAddAttribute( ElementTags.NUMBERED, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.SYMBOLINDENT, "20" );
+
+        switch ( numbering )
+        {
+            case Sink.NUMBERING_UPPER_ALPHA:
+                writeAddAttribute( ElementTags.LETTERED, Boolean.TRUE.toString() );
+                writeAddAttribute( ElementTags.FIRST, 'A' );
+                break;
+
+            case Sink.NUMBERING_LOWER_ALPHA:
+                writeAddAttribute( ElementTags.LETTERED, Boolean.TRUE.toString() );
+                writeAddAttribute( ElementTags.FIRST, 'a' );
+                break;
+
+            // TODO Doesn't work
+            case Sink.NUMBERING_UPPER_ROMAN:
+                writeAddAttribute( ElementTags.LETTERED, Boolean.TRUE.toString() );
+                writeAddAttribute( ElementTags.FIRST, 'I' );
+                break;
+
+            case Sink.NUMBERING_LOWER_ROMAN:
+                writeAddAttribute( ElementTags.LETTERED, Boolean.TRUE.toString() );
+                writeAddAttribute( ElementTags.FIRST, 'i' );
+                break;
+
+            case Sink.NUMBERING_DECIMAL:
+            default:
+                writeAddAttribute( ElementTags.LETTERED, Boolean.FALSE.toString() );
+        }
+
+        this.actionContext.setAction( SinkActionContext.NUMBERED_LIST );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#numberedListItem_()
+     */
+    public void numberedListItem_()
+    {
+        writeEndElement(); // ElementTags.LISTITEM
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#numberedListItem()
+     */
+    public void numberedListItem()
+    {
+        writeStartElement( ElementTags.LISTITEM );
+        writeAddAttribute( ElementTags.INDENTATIONLEFT, "20" );
+
+        this.actionContext.setAction( SinkActionContext.NUMBERED_LIST_ITEM );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definitionList_()
+     */
+    public void definitionList_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definitionList()
+     */
+    public void definitionList()
+    {
+        this.actionContext.setAction( SinkActionContext.DEFINITION_LIST );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definedTerm_()
+     */
+    public void definedTerm_()
+    {
+        writeEndElement(); // ElementTags.CELL
+
+        writeEndElement(); // ElementTags.ROW
+
+        writeEndElement(); // ElementTags.TABLE
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definedTerm()
+     */
+    public void definedTerm()
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.TABLE );
+        writeAddAttribute( ElementTags.COLUMNS, "1" );
+        writeAddAttribute( ElementTags.LEFT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+        writeAddAttribute( ElementTags.WIDTH, "100%" );
+        //        writeAddAttribute( ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString() );
+        //        writeAddAttribute( ElementTags.CELLSFITPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLPADDING, "0" );
+
+        writeStartElement( ElementTags.ROW );
+
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.FALSE.toString() );
+
+        this.actionContext.setAction( SinkActionContext.DEFINED_TERM );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definition_()
+     */
+    public void definition_()
+    {
+        writeEndElement(); // ElementTags.CELL
+
+        writeEndElement(); // ElementTags.ROW
+
+        writeEndElement(); // ElementTags.TABLE
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definition()
+     */
+    public void definition()
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.TABLE );
+        writeAddAttribute( ElementTags.COLUMNS, "2" );
+        writeAddAttribute( ElementTags.LEFT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+        writeAddAttribute( ElementTags.WIDTH, "100%" );
+        writeAddAttribute( ElementTags.WIDTHS, "20.0;80.0" );
+        //        writeAddAttribute( ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLSFITPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLPADDING, "5" );
+
+        writeStartElement( ElementTags.ROW );
+
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.FALSE.toString() );
+
+        write( "" );
+
+        writeEndElement(); // ElementTags.CELL
+
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.FALSE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.FALSE.toString() );
+
+        this.actionContext.setAction( SinkActionContext.DEFINITION );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definitionListItem_()
+     */
+    public void definitionListItem_()
+    {
+        // nop
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#definitionListItem()
+     */
+    public void definitionListItem()
+    {
+        // nop
+
+        this.actionContext.setAction( SinkActionContext.DEFINITION_LIST_ITEM );
+    }
+
+    // ----------------------------------------------------------------------
+    // Tables
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#table_()
+     */
+    public void table_()
+    {
+        writeEndElement(); // ElementTags.TABLE
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#table()
+     */
+    public void table()
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.TABLE );
+        writeAddAttribute( ElementTags.LEFT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+        writeAddAttribute( ElementTags.WIDTH, "100.0%" );
+        writeAddAttribute( ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLSFITPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLPADDING, "10" );
+        //writeAddAttribute( ElementTags.COLUMNS, "2" );
+
+        this.actionContext.setAction( SinkActionContext.TABLE );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableCaption_()
+     */
+    public void tableCaption_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableCaption()
+     */
+    public void tableCaption()
+    {
+        this.actionContext.setAction( SinkActionContext.TABLE_CAPTION );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableCell_()
+     */
+    public void tableCell_()
+    {
+        writeEndElement(); // ElementTags.CELL
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableCell()
+     */
+    public void tableCell()
+    {
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.HORIZONTALALIGN, ElementTags.ALIGN_LEFT );
+
+        this.actionContext.setAction( SinkActionContext.TABLE_CELL );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableCell(java.lang.String)
+     */
+    public void tableCell( String width )
+    {
+        this.actionContext.setAction( SinkActionContext.TABLE_CELL );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableHeaderCell_()
+     */
+    public void tableHeaderCell_()
+    {
+        writeEndElement(); // ElementTags.CELL
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableHeaderCell()
+     */
+    public void tableHeaderCell()
+    {
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.HEADER, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BGRED, Color.GRAY.getRed() );
+        writeAddAttribute( ElementTags.BGBLUE, Color.GRAY.getBlue() );
+        writeAddAttribute( ElementTags.BGGREEN, Color.GRAY.getGreen() );
+        writeAddAttribute( ElementTags.HORIZONTALALIGN, ElementTags.ALIGN_CENTER );
+
+        this.actionContext.setAction( SinkActionContext.TABLE_HEADER_CELL );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableHeaderCell(java.lang.String)
+     */
+    public void tableHeaderCell( String width )
+    {
+        this.actionContext.setAction( SinkActionContext.TABLE_HEADER_CELL );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableRow_()
+     */
+    public void tableRow_()
+    {
+        writeEndElement(); // ElementTags.ROW
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableRow()
+     */
+    public void tableRow()
+    {
+        writeStartElement( ElementTags.ROW );
+
+        this.actionContext.setAction( SinkActionContext.TABLE_ROW );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableRows_()
+     */
+    public void tableRows_()
+    {
+        //writeEndElement(); // ElementTags.TABLE
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#tableRows(int[], boolean)
+     */
+    public void tableRows( int[] justification, boolean grid )
+    {
+        // ElementTags.TABLE
+        writeAddAttribute( ElementTags.COLUMNS, justification.length );
+
+        this.actionContext.setAction( SinkActionContext.TABLE_ROWS );
+    }
+
+    // ----------------------------------------------------------------------
+    // Verbatim
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#verbatim_()
+     */
+    public void verbatim_()
+    {
+        writeEndElement(); // ElementTags.CELL
+
+        writeEndElement(); // ElementTags.ROW
+
+        writeEndElement(); // ElementTags.TABLE
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#verbatim(boolean)
+     */
+    public void verbatim( boolean boxed )
+    {
+        // Always boxed
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.TABLE );
+        writeAddAttribute( ElementTags.COLUMNS, "1" );
+        writeAddAttribute( ElementTags.LEFT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+        writeAddAttribute( ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLSFITPAGE, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.CELLPADDING, "10" );
+        writeAddAttribute( ElementTags.WIDTH, "100.0%" );
+
+        writeStartElement( ElementTags.ROW );
+
+        writeStartElement( ElementTags.CELL );
+        writeAddAttribute( ElementTags.LEFT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.RIGHT, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.TOP, Boolean.TRUE.toString() );
+        writeAddAttribute( ElementTags.BOTTOM, Boolean.TRUE.toString() );
+
+        this.actionContext.setAction( SinkActionContext.VERBATIM );
+    }
+
+    // ----------------------------------------------------------------------
+    // Figures
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#figure_()
+     */
+    public void figure_()
+    {
+        writeEndElement(); // ElementTags.IMAGE
+
+        writeEndElement(); // ElementTags.CHUNK
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#figure()
+     */
+    public void figure()
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        writeStartElement( ElementTags.IMAGE );
+
+        this.actionContext.setAction( SinkActionContext.FIGURE );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#figureCaption_()
+     */
+    public void figureCaption_()
+    {
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#figureCaption()
+     */
+    public void figureCaption()
+    {
+        this.actionContext.setAction( SinkActionContext.FIGURE_CAPTION );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#figureGraphics(java.lang.String)
+     */
+    public void figureGraphics( String name )
+    {
+        String urlName = null;
+        if ( ( name.toLowerCase().startsWith( "http://" ) ) || ( name.toLowerCase().startsWith( "https://" ) ) )
+        {
+            urlName = name;
+        }
+        else
+        {
+            if ( getClassLoader() != null )
+            {
+                if ( getClassLoader().getResource( name ) != null )
+                {
+                    urlName = getClassLoader().getResource( name ).toString();
+                }
+            }
+            else
+            {
+                if ( ITextSink.class.getClassLoader().getResource( name ) != null )
+                {
+                    urlName = ITextSink.class.getClassLoader().getResource( name ).toString();
+                }
+            }
+        }
+
+        if ( urlName == null )
+        {
+            //TODO
+            System.err.println( "The image " + name + " not found in the class loader. Try to call setClassLoader(ClassLoader) before." );
+            return;
+        }
+
+        float width = 0;
+        float height = 0;
+        try
+        {
+            Image image = Image.getInstance( new URL( urlName ) );
+            image.scaleToFit( ITextUtil.getDefaultPageSize().width() / 2, ITextUtil.getDefaultPageSize().height() / 2 );
+            width = image.plainWidth();
+            height = image.plainHeight();
+        }
+        catch ( BadElementException e )
+        {
+            // nop
+        }
+        catch ( MalformedURLException e )
+        {
+            // nop
+        }
+        catch ( IOException e )
+        {
+            // nop
+        }
+
+        writeAddAttribute( ElementTags.URL, urlName );
+        writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_MIDDLE );
+        writeAddAttribute( ElementTags.PLAINWIDTH, String.valueOf( width ) );
+        writeAddAttribute( ElementTags.PLAINHEIGHT, String.valueOf( height ) );
+
+        this.actionContext.setAction( SinkActionContext.FIGURE_GRAPHICS );
+    }
+
+    // ----------------------------------------------------------------------
+    // Fonts
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#bold_()
+     */
+    public void bold_()
+    {
+        this.font.removeBold();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#bold()
+     */
+    public void bold()
+    {
+        this.font.addBold();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#italic_()
+     */
+    public void italic_()
+    {
+        this.font.removeItalic();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#italic()
+     */
+    public void italic()
+    {
+        this.font.addItalic();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#monospaced_()
+     */
+    public void monospaced_()
+    {
+        this.font.setMonoSpaced( false );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#monospaced()
+     */
+    public void monospaced()
+    {
+        this.font.setMonoSpaced( true );
+    }
+
+    // ----------------------------------------------------------------------
+    // Links
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#link_()
+     */
+    public void link_()
+    {
+        writeEndElement(); // ElementTags.ANCHOR
+
+        this.font.setColor( Color.BLACK );
+        this.font.removeUnderlined();
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#link(java.lang.String)
+     */
+    public void link( String name )
+    {
+        this.font.setColor( Color.BLUE );
+        this.font.addUnderlined();
+
+        writeStartElement( ElementTags.ANCHOR );
+        writeAddAttribute( ElementTags.REFERENCE, HtmlTools.escapeHTML( name ) );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        this.actionContext.setAction( SinkActionContext.LINK );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#anchor_()
+     */
+    public void anchor_()
+    {
+        writeEndElement(); // ElementTags.ANCHOR
+
+        this.actionContext.release();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#anchor(java.lang.String)
+     */
+    public void anchor( String name )
+    {
+        writeStartElement( ElementTags.ANCHOR );
+        writeAddAttribute( ElementTags.NAME, name );
+
+        this.actionContext.setAction( SinkActionContext.ANCHOR );
+    }
+
+    // ----------------------------------------------------------------------
+    // Misc
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#lineBreak()
+     */
+    public void lineBreak()
+    {
+        // Special case for the header
+        if ( ( this.actionContext.getCurrentAction() == SinkActionContext.AUTHOR )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.DATE )
+            || ( this.actionContext.getCurrentAction() == SinkActionContext.TITLE ) )
+        {
+            return;
+        }
+
+        writeStartElement( ElementTags.NEWLINE );
+        writeEndElement();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#nonBreakingSpace()
+     */
+    public void nonBreakingSpace()
+    {
+        write( " " );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.SinkAdapter#pageBreak()
+     */
+    public void pageBreak()
+    {
+        writeStartElement( ElementTags.NEWPAGE );
+        writeEndElement();
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#horizontalRule()
+     */
+    public void horizontalRule()
+    {
+        writeStartElement( ElementTags.HORIZONTALRULE );
+        writeEndElement();
+    }
+
+    // ----------------------------------------------------------------------
+    // Text
+    // ----------------------------------------------------------------------
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#rawText(java.lang.String)
+     */
+    public void rawText( String text )
+    {
+        writeStartElement( ElementTags.CHUNK );
+        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+        write( text, false );
+
+        writeEndElement(); // ElementTags.CHUNK
+    }
+
+    /**
+     * @see org.apache.maven.doxia.sink.Sink#text(java.lang.String)
+     */
+    public void text( String text )
+    {
+        switch ( this.actionContext.getCurrentAction() )
+        {
+            case SinkActionContext.UNDEFINED:
+                break;
+
+            case SinkActionContext.HEAD:
+                break;
+
+            case SinkActionContext.AUTHOR:
+                this.header.addAuthor( text );
+                break;
+
+            case SinkActionContext.DATE:
+                this.header.setDate( text );
+                break;
+
+            case SinkActionContext.TITLE:
+                this.header.setTitle( text );
+                break;
+
+            case SinkActionContext.SECTION_TITLE_1:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.SECTION_TITLE_2:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.SECTION_TITLE_3:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.SECTION_TITLE_4:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.SECTION_TITLE_5:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.LIST_ITEM:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.NUMBERED_LIST_ITEM:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.DEFINED_TERM:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.DEFINITION:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.TABLE:
+                break;
+
+            case SinkActionContext.TABLE_ROW:
+                break;
+
+            case SinkActionContext.TABLE_HEADER_CELL:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.TABLE_CELL:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.TABLE_CAPTION:
+                writeStartElement( ElementTags.PARAGRAPH );
+                writeAddAttribute( ElementTags.ALIGN, ElementTags.ALIGN_CENTER );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.PARAGRAPH
+                break;
+
+            case SinkActionContext.VERBATIM:
+                // Used to preserve indentation and formating
+                LineNumberReader lnr = new LineNumberReader( new StringReader( text ) );
+                String line;
+                try
+                {
+                    while ( ( line = lnr.readLine() ) != null )
+                    {
+                        writeStartElement( ElementTags.CHUNK );
+                        writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                        writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                        writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                        writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                        writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                        writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                        write( "<![CDATA[", true );
+                        // Special case
+                        line = StringUtils.replace( line, "<![CDATA[", "< ![CDATA[" );
+                        line = StringUtils.replace( line, "]]>", "]] >" );
+                        write( line, true, false );
+                        write( "]]>", true );
+
+                        writeEndElement();
+                        lineBreak();
+                    }
+                }
+                catch ( IOException e )
+                {
+                    throw new RuntimeException( "IOException: ", e );
+                }
+                break;
+
+            case SinkActionContext.FIGURE:
+            case SinkActionContext.FIGURE_GRAPHICS:
+                break;
+
+            case SinkActionContext.FIGURE_CAPTION:
+                writeAddAttribute( ElementTags.ALT, text );
+                break;
+
+            case SinkActionContext.LINK:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.ANCHOR:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+                break;
+
+            case SinkActionContext.SECTION_TITLE:
+            case SinkActionContext.SECTION_1:
+            case SinkActionContext.SECTION_2:
+            case SinkActionContext.SECTION_3:
+            case SinkActionContext.SECTION_4:
+            case SinkActionContext.SECTION_5:
+                break;
+
+            case SinkActionContext.PARAGRAPH:
+            default:
+                writeStartElement( ElementTags.CHUNK );
+                writeAddAttribute( ElementTags.FONT, this.font.getFontName() );
+                writeAddAttribute( ElementTags.SIZE, this.font.getFontSize() );
+                writeAddAttribute( ElementTags.STYLE, this.font.getFontStyle() );
+                writeAddAttribute( ElementTags.BLUE, this.font.getFontColorBlue() );
+                writeAddAttribute( ElementTags.GREEN, this.font.getFontColorGreen() );
+                writeAddAttribute( ElementTags.RED, this.font.getFontColorRed() );
+
+                write( text );
+
+                writeEndElement(); // ElementTags.CHUNK
+        }
+    }
+
+    /**
+     * Convenience method to write a starting element.
+     *
+     * @param tag the name of the tag
+     */
+    private void writeStartElement( String tag )
+    {
+        this.xmlWriter.startElement( tag );
+    }
+
+    /**
+     * Convenience method to write a key-value pair.
+     *
+     * @param key the name of an attribute
+     * @param value the value of an attribute
+     */
+    private void writeAddAttribute( String key, String value )
+    {
+        this.xmlWriter.addAttribute( key, value );
+    }
+
+    /**
+     * Convenience method to write a key-value pair.
+     *
+     * @param key the name of an attribute
+     * @param value the value of an attribute
+     */
+    private void writeAddAttribute( String key, int value )
+    {
+        this.xmlWriter.addAttribute( key, String.valueOf( value ) );
+    }
+
+    /**
+     * Convenience method to write an end element.
+     */
+    private void writeEndElement()
+    {
+        this.xmlWriter.endElement();
+    }
+
+    /**
+     * Convenience method to write a String
+     *
+     * @param aString
+     */
+    private void write( String aString )
+    {
+        write( aString, false );
+    }
+
+    /**
+     * Convenience method to write a String depending the escapeHtml flag
+     *
+     * @param aString
+     * @param escapeHtml
+     */
+    private void write( String aString, boolean escapeHtml )
+    {
+        write( aString, escapeHtml, true );
+    }
+
+    /**
+     * Convenience method to write a String depending the escapeHtml flag
+     *
+     * @param aString
+     * @param escapeHtml
+     * @param trim
+     */
+    private void write( String aString, boolean escapeHtml, boolean trim )
+    {
+        if ( aString == null )
+        {
+            return;
+        }
+
+        if ( trim )
+        {
+            aString = StringUtils.replace( aString, "\n", "" );
+
+            LineNumberReader lnr = new LineNumberReader( new StringReader( aString ) );
+            StringBuffer sb = new StringBuffer();
+            String line;
+            try
+            {
+                while ( ( line = lnr.readLine() ) != null )
+                {
+                    sb.append( beautifyPhrase( line.trim() ) );
+                    sb.append( " " );
+                }
+
+                aString = sb.toString();
+            }
+            catch ( IOException e )
+            {
+                // nop
+            }
+            if ( aString.trim().length() == 0 )
+            {
+                return;
+            }
+        }
+        if ( escapeHtml )
+        {
+            this.xmlWriter.writeMarkup( aString );
+        }
+        else
+        {
+            this.xmlWriter.writeText( aString );
+        }
+    }
+
+    /**
+     * Convenience method to return a beautify phrase, i.e. one space between words.
+     *
+     * @param aString
+     * @return a String with only one space between words
+     */
+    private static String beautifyPhrase( String aString )
+    {
+        String[] strings = StringUtils.split( aString, " " );
+        StringBuffer sb = new StringBuffer();
+        for ( int i = 0; i < strings.length; i++ )
+        {
+            if ( strings[i].trim().length() != 0 )
+            {
+                sb.append( strings[i].trim() );
+                sb.append( " " );
+            }
+        }
+
+        return sb.toString().trim();
+    }
+}
\ No newline at end of file

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message