maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r548106 - in /maven/sandbox/trunk/doxia/doxia-module-fo: ./ 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/apache/maven/doxi...
Date Sun, 17 Jun 2007 20:40:49 GMT
Author: ltheussl
Date: Sun Jun 17 13:40:47 2007
New Revision: 548106

URL: http://svn.apache.org/viewvc?view=rev&rev=548106
Log:
Adding a first version of a FO sink. It's basically functional with a few known limitations.

Added:
    maven/sandbox/trunk/doxia/doxia-module-fo/
    maven/sandbox/trunk/doxia/doxia-module-fo/pom.xml   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/figure.png   (with props)
    maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt   (with props)

Added: maven/sandbox/trunk/doxia/doxia-module-fo/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/pom.xml?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/pom.xml (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/pom.xml Sun Jun 17 13:40:47 2007
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<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-sandbox</artifactId>
+    <groupId>org.apache.maven.doxia</groupId>
+    <version>1.0-alpha-9-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>doxia-module-fo</artifactId>
+  <name>Doxia :: FO Module</name>
+  <developers>
+    <developer>
+      <id>ltheussl</id>
+      <name>Lukas Theussl</name>
+      <email>ltheussl@apache.org</email>
+      <organization>Apache Software Foundation</organization>
+      <roles>
+        <role>Java Developer</role>
+      </roles>
+      <timezone>+1</timezone>
+    </developer>
+  </developers>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-core</artifactId>
+      <version>${projectVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-sink-api</artifactId>
+      <version>${projectVersion}</version>
+    </dependency>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>fop</groupId>
+      <artifactId>fop</artifactId>
+      <version>0.93</version>
+      <classifier>jdk14</classifier>
+      <scope>test</scope>
+    </dependency>
+    <!-- This should'n be needed, see DOXIA-101 -->
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-module-apt</artifactId>
+      <version>${projectVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- These are transitive deps of fop, but there is no pom in the repo -->
+    <dependency>
+      <groupId>avalon-framework</groupId>
+      <artifactId>avalon-framework</artifactId>
+      <version>4.1.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.xmlgraphics</groupId>
+      <artifactId>xmlgraphics-commons</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>batik</groupId>
+      <artifactId>batik-util</artifactId>
+      <version>1.6</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- To be sure that JVM will implement AWT in software -->
+          <systemProperties>
+            <property>
+              <name>java.awt.headless</name>
+              <value>true</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

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

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

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java Sun Jun 17 13:40:47 2007
@@ -0,0 +1,916 @@
+package org.apache.maven.doxia.module.fo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.Writer;
+import java.util.Stack;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.util.LineBreaker;
+import org.apache.maven.doxia.parser.Parser;
+
+/**
+ * A Doxia Sink that produces a FO model.
+ */
+public class FoSink implements Sink
+{
+
+    /** System-dependent end-of-line string. */
+    private static final String EOL = System.getProperty( "line.separator" );
+
+    /** Linebreaker for writing the result. */
+    private final LineBreaker out;
+
+    /** Used to get the current position in numbered lists. */
+    private final Stack listStack = new Stack();
+
+    /** Counts the current section level. */
+    private int section = 0;
+
+    /** Counts the current subsection level. */
+    private int subsection = 0;
+
+    /** Counts the current subsubsection level. */
+    private int subsubsection = 0;
+
+    /** Drawing borders on table cells. */
+    private boolean tableGrid;
+
+    /** Alignment of table cells. */
+    private int[] cellJustif;
+
+    /** Current table cell. */
+    private int cellCount;
+
+    /** Verbatim flag. */
+    private boolean verbatim;
+
+    /** Constructor.
+     * @param writer The writer for writing the result.
+     */
+    public FoSink( Writer writer )
+    {
+        this.out = new LineBreaker( writer );
+    }
+
+    // TODO factor out all attributes and re-use them, configuration file?
+    // TODO page headers, page numbering
+    // TODO add aggregate mode?
+    // TODO add FOP compliance mode?
+
+    /** {@inheritDoc} */
+    public void head()
+    {
+        writeln( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
+
+        writeln( "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">" );
+
+        writeln( "<fo:layout-master-set>" );
+        writeln( "  <fo:simple-page-master margin-right=\"1in\" margin-left=\"1in\" margin-bottom=\"0.6in\" margin-top=\"0.625in\" page-height=\"11.70in\" page-width=\"8.25in\" master-name=\"body\">" );
+        writeln( "    <fo:region-body margin-bottom=\"0.8in\" margin-top=\"0.7in\"/><fo:region-before extent=\"0.35in\"/><fo:region-after extent=\"0.125in\"/>" );
+        writeln( "  </fo:simple-page-master>" );
+        writeln( "</fo:layout-master-set>" );
+        writeln( "" );
+
+        writeln( "<fo:page-sequence initial-page-number=\"1\" master-reference=\"body\">" );
+        writeln( "  <fo:flow flow-name=\"xsl-region-body\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void head_()
+    {
+        // nothing?
+    }
+
+    /** {@inheritDoc} */
+    public void title()
+    {
+        lnwrite( "<fo:block text-align=\"center\" font-family=\"Garamond,serif\" font-size=\"16pt\" space-before.optimum=\"30pt\" space-after.optimum=\"14pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void title_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void author()
+    {
+        lnwrite( "<fo:block text-align=\"center\" font-family=\"Garamond,serif\" font-size=\"12pt\" space-before.optimum=\"20pt\" space-after.optimum=\"14pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void author_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void date()
+    {
+        lnwrite( "<fo:block text-align=\"center\" font-family=\"Garamond,serif\" font-size=\"12pt\" space-before.optimum=\"20pt\" space-after.optimum=\"30pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void date_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void body()
+    {
+        // nothing?
+    }
+
+    /** {@inheritDoc} */
+    public void body_()
+    {
+         newline();
+         writeln( "  </fo:flow>" );
+         writeln( "</fo:page-sequence>" );
+         writeln( "</fo:root>" );
+         flush();
+         close();
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // -----------------------------------------------------------------------
+
+    /** {@inheritDoc} */
+    public void sectionTitle()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void section1()
+    {
+        section++;
+        subsection = 0;
+        subsubsection = 0;
+        onSection();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1()
+    {
+        onSectionTitle( 1 );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1_()
+    {
+        onSectionTitle_();
+    }
+
+    /** {@inheritDoc} */
+    public void section1_()
+    {
+        onSection_();
+    }
+
+    /** {@inheritDoc} */
+    public void section2()
+    {
+        subsection++;
+        subsubsection = 0;
+        onSection();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2()
+    {
+        onSectionTitle( 2 );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2_()
+    {
+        onSectionTitle_();
+    }
+
+    /** {@inheritDoc} */
+    public void section2_()
+    {
+        onSection_();
+    }
+
+    /** {@inheritDoc} */
+    public void section3()
+    {
+        subsubsection++;
+        onSection();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3()
+    {
+        onSectionTitle( 3 );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3_()
+    {
+        onSectionTitle_();
+    }
+
+    /** {@inheritDoc} */
+    public void section3_()
+    {
+        onSection_();
+    }
+
+    /** {@inheritDoc} */
+    public void section4()
+    {
+        onSection();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4()
+    {
+        onSectionTitle( 4 );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4_()
+    {
+        onSectionTitle_();
+    }
+
+    /** {@inheritDoc} */
+    public void section4_()
+    {
+        onSection_();
+    }
+
+    /** {@inheritDoc} */
+    public void section5()
+    {
+        onSection();
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5()
+    {
+        onSectionTitle( 5 );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5_()
+    {
+        onSectionTitle_();
+    }
+
+    /** {@inheritDoc} */
+    public void section5_()
+    {
+        onSection_();
+    }
+
+    /** Starts a section/subsection. */
+    private void onSection()
+    {
+        newline();
+        writeln( "<fo:block font-family=\"Garamond,serif\" font-size=\"11pt\" line-height=\"12pt\" white-space-collapse=\"true\">" );
+    }
+
+    /** Starts a section title. */
+    private void onSectionTitle( int depth )
+    {
+        String baseAttribs = "font-family=\"Helvetica,sans-serif\" color=\"#000000\" keep-with-next=\"always\" ";
+        String levelAttribs = "";
+
+        StringBuffer title = new StringBuffer( 10 );
+
+        if ( depth == 1 )
+        {
+            levelAttribs = "font-size=\"12pt\" font-weight=\"bold\" space-before=\"18pt\" space-after=\"6pt\"";
+            title.append( section );
+            title.append( "   " );
+        }
+        else if ( depth == 2 )
+        {
+            levelAttribs = "font-size=\"9.5pt\" font-weight=\"bold\" space-before=\"18pt\" space-after=\"5pt\"";
+            title.append( section );
+            title.append( "." );
+            title.append( subsection );
+            title.append( "   " );
+        }
+        else if ( depth == 3 )
+        {
+            levelAttribs = "font-size=\"9.5pt\" font-weight=\"bold\" space-before=\"15pt\" space-after=\"3pt\"";
+            title.append( section );
+            title.append( "." );
+            title.append( subsection );
+            title.append( "." );
+            title.append( subsubsection );
+            title.append( "   " );
+        }
+        else if ( depth == 4 )
+        {
+            levelAttribs = "font-size=\"9.5pt\" font-weight=\"bold\" space-before=\"9pt\" space-after=\"3pt\"";
+        }
+        else
+        {
+            levelAttribs = "font-size=\"9.5pt\" font-weight=\"bold\" font-style=\"italic\" space-after=\"3pt\"";
+        }
+
+        lnwrite( "<fo:block " + baseAttribs + levelAttribs + ">" );
+        write( title.toString() );
+    }
+
+    /** Ends a section title. */
+    private void onSectionTitle_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    /** Ends a section/subsection. */
+    private void onSection_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // -----------------------------------------------------------------------
+
+    /** {@inheritDoc} */
+    public void list()
+    {
+        newline();
+        writeln( "<fo:list-block provisional-distance-between-starts=\"1em\" provisional-label-separation=\"1em\" start-indent=\"inherited-property-value(start-indent)\" space-before.optimum=\"10pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void list_()
+    {
+        writeln( "</fo:list-block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void listItem()
+    {
+        writeln( "  <fo:list-item space-before=\"0.15em\" space-after=\"0.25em\" start-indent=\"inherited-property-value(start-indent) + .5em\">" );
+        writeln( "    <fo:list-item-label><fo:block>&#8226;</fo:block></fo:list-item-label>" );
+        writeln( "    <fo:list-item-body start-indent=\"body-start()\">" );
+        write( "      <fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void listItem_()
+    {
+        writeln( "      </fo:block>" );
+        writeln( "    </fo:list-item-body>" );
+        writeln( "  </fo:list-item>" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList( int numbering )
+    {
+        listStack.push( new NumberedListItem( numbering ) );
+        newline();
+        writeln( "<fo:list-block provisional-distance-between-starts=\"1em\" provisional-label-separation=\"1em\" start-indent=\"inherited-property-value(start-indent)\" space-before.optimum=\"10pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList_()
+    {
+        listStack.pop();
+        writeln( "</fo:list-block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem()
+    {
+        NumberedListItem current = (NumberedListItem) listStack.peek();
+        current.next();
+
+        lnwrite( "<fo:list-item space-before=\"0.15em\" space-after=\"0.25em\" start-indent=\"inherited-property-value(start-indent) + .5em\">" );
+        lnwrite( "<fo:list-item-label><fo:block>" );
+        write( current.getListItemSymbol() );
+        write( "</fo:block></fo:list-item-label>" );
+        lnwrite( "<fo:list-item-body start-indent=\"body-start()\"><fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem_()
+    {
+        writeln( "</fo:block></fo:list-item-body></fo:list-item>" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionList()
+    {
+        newline();
+        writeln( "<fo:block start-indent=\"1em\" end-indent=\"1em\" space-before.optimum=\"10pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionList_()
+    {
+        writeln( "</fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm()
+    {
+        writeln( "  <fo:block start-indent=\"1em\" end-indent=\"1em\" font-weight=\"bold\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm_()
+    {
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void definition()
+    {
+        newline();
+        writeln( "  <fo:block space-before=\"0.6em\" space-after=\"0.6em\" start-indent=\"inherited-property-value(start-indent) + 1em\" end-indent=\"inherited-property-value(start-indent) + 1em\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void definition_()
+    {
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void figure()
+    {
+        newline();
+        writeln( "  <fo:block display-align=\"center\" text-align=\"center\">" );
+        write( "    <fo:external-graphic height=\"auto\" width=\"auto\" content-height=\"auto\" content-width=\"auto\" display-align=\"center\" text-align=\"center\"" );
+    }
+
+    /** {@inheritDoc} */
+    public void figure_()
+    {
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void figureGraphics( String s )
+    {
+        // TODO: figure out file extension.
+        writeln( " src=\"" + s + ".png\"/>" );
+    }
+
+    /** {@inheritDoc} */
+    public void figureCaption()
+    {
+        lnwrite( "  <fo:block keep-with-previous=\"always\" text-align=\"center\" font-family=\"Garamond,serif\" font-size=\"10pt\" font-style=\"italic\" space-before.optimum=\"20pt\" space-after.optimum=\"30pt\"> " );
+    }
+
+    /** {@inheritDoc} */
+    public void figureCaption_()
+    {
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph()
+    {
+        lnwrite( "  <fo:block font-family=\"Garamond,serif\" font-size=\"11pt\" line-height=\"12pt\" white-space-collapse=\"true\" space-before.optimum=\"10pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph_()
+    {
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim( boolean boxed )
+    {
+        this.verbatim = true;
+        StringBuffer buffer = new StringBuffer( 512 );
+        buffer.append( "  <fo:block font-family=\"monospace\" font-size=\"10pt\"" );
+
+        if ( boxed )
+        {
+            buffer.append( " wrap-option=\"wrap\"" );
+            buffer.append( " white-space-collapse=\"false\"" );
+            buffer.append( " color=\"black\"" );
+            buffer.append( " border-style=\"solid\"" );
+            buffer.append( " border-width=\"0.5pt\"" );
+            buffer.append( " border-color=\"#454545\"" );
+            buffer.append( " padding-before=\"0.25em\"" );
+            buffer.append( " padding-after=\"0.25em\"" );
+            buffer.append( " padding-start=\"0.25em\"" );
+            buffer.append( " padding-end=\"0.25em\"" );
+            buffer.append( " start-indent=\"inherited-property-value(start-indent) + 2.5em\"" );
+            buffer.append( " end-indent=\"inherited-property-value(end-indent) + 3em\"" );
+            buffer.append( " space-before=\"0.75em\"" );
+            buffer.append( " space-after=\"1em\"" );
+        }
+        buffer.append( ">" );
+
+        writeln( buffer.toString() );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim_()
+    {
+        this.verbatim = false;
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    /** {@inheritDoc} */
+    public void horizontalRule()
+    {
+        newline();
+        writeln( "  <fo:block line-height=\"1pt\"><fo:leader leader-length.optimum=\"100%\" leader-pattern=\"rule\" rule-thickness=\"0.5pt\" color=\"black\"/></fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void pageBreak()
+    {
+        writeln( "  <fo:block break-before=\"page\"/>" );
+    }
+
+    /** {@inheritDoc} */
+    public void table()
+    {
+        newline();
+        writeln( "  <fo:block padding-before=\"9pt\" padding-after=\"12pt\">" );
+        // <fo:table-and-caption> is XSL-FO 1.0 standard but not implemented in FOP 0.93
+        //writeln( "  <fo:table-and-caption>" );
+        // table-layout="auto" is not supported by FOP 0.93
+        writeln( "    <fo:table table-omit-footer-at-break=\"false\" table-layout=\"fixed\" width=\"100%\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void table_()
+    {
+        writeln( "    </fo:table>" );
+        // <fo:table-and-caption> is XSL-FO 1.0 standard but not implemented in FOP 0.93
+        //writeln( "  </fo:table-and-caption>" );
+        writeln( "  </fo:block>" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRows( int[] justification, boolean grid )
+    {
+        this.tableGrid = grid;
+        this.cellJustif = justification;
+        // FOP hack to center the table, see http://xmlgraphics.apache.org/fop/fo.html#fo-center-table-horizon
+        writeln( "      <fo:table-column column-width=\"proportional-column-width(1)\"/>" );
+        // TODO: calculate width[i]
+        for ( int i = 0;  i < cellJustif.length; i++ )
+        {
+            writeln( "      <fo:table-column column-width=\"1in\"/>" );
+        }
+        writeln( "      <fo:table-column column-width=\"proportional-column-width(1)\"/>" );
+        writeln( "<fo:table-body>" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRows_()
+    {
+        this.cellJustif = null;
+        writeln( "</fo:table-body>" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow()
+    {
+        // TODO spacer rows
+        writeln( "<fo:table-row keep-together=\"always\" keep-with-next=\"always\">" );
+        this.cellCount = 0;
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow_()
+    {
+        writeln( "</fo:table-row>" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell()
+    {
+        tableCell( false );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell( String width )
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell()
+    {
+        // TODO: how to implement?
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell( String width )
+    {
+        // nop
+    }
+
+    /** Writes a table cell.
+     * @param headerRow Currently not used.
+     */
+    private void tableCell( boolean headerRow )
+    {
+         String justif = null;
+ 
+         if ( cellJustif != null )
+         {
+             switch ( cellJustif[cellCount] )
+             {
+                 case Parser.JUSTIFY_LEFT:
+                     justif = "left";
+                     break;
+                 case Parser.JUSTIFY_RIGHT:
+                     justif = "right";
+                     break;
+                 case Parser.JUSTIFY_CENTER:
+                 default:
+                     justif = "center";
+                     break;
+             }
+         }
+ 
+         if ( justif != null )
+         {
+            // the column-number is needed for the hack to center the table, see tableRows.
+            write( "<fo:table-cell column-number=\"" + String.valueOf( cellCount + 2 ) + "\"" );
+            if ( tableGrid )
+            {
+                write( " border-style=\"solid\" border-width=\"0.2mm\"" );
+            }
+            writeln( " padding-start=\"2.5pt\" padding-end=\"5pt\" padding-before=\"4pt\" padding-after=\"1.5pt\">" );
+         }
+         else
+         {
+             writeln( "<fo:table-cell padding-start=\"2.5pt\" padding-end=\"5pt\" padding-before=\"4pt\" padding-after=\"1.5pt\">" );
+         }
+        writeln( "<fo:block text-align=\"" + justif + "\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell_()
+    {
+        writeln( "</fo:block>" );
+        writeln( "</fo:table-cell>" );
+        ++cellCount;
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell_()
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void tableCaption()
+    {
+        // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in FOP 0.93
+        //lnwrite( "<fo:table-caption>" );
+        // TODO: how to implement this otherwise?
+        // table-footer doesn't work because it has to be declared before table-body.
+    }
+
+    /** {@inheritDoc} */
+    public void tableCaption_()
+    {
+        // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in FOP 0.93
+        //writeln( "  </fo:table-caption>" );
+    }
+
+    /** {@inheritDoc} */
+    public void anchor( String name )
+    {
+        lnwrite( "  <fo:inline id=\"" + name + "\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void anchor_()
+    {
+        write( "  </fo:inline>" );
+    }
+
+    /** {@inheritDoc} */
+    public void link( String name )
+    {
+        if ( name.startsWith( "http", 0 ) || name.startsWith( "mailto", 0 ) || name.startsWith( "ftp", 0 ) )
+        {
+            lnwrite( "  <fo:basic-link external-destination=\"" + name + "\">" );
+        }
+        else if ( name.startsWith( "#", 0 ) )
+        {
+            lnwrite( "  <fo:basic-link internal-destination=\"" + name + "\">" );
+        }
+        else
+        {
+            // TODO: aggregate mode: link to another document, construct relative path
+            lnwrite( "<fo:basic-link internal-destination=\"" + name + "\">" );
+        }
+        write( "    <fo:inline color=\"green\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void link_()
+    {
+        write( "   </fo:inline></fo:basic-link>" );
+    }
+
+    /** {@inheritDoc} */
+    public void italic()
+    {
+        lnwrite( "  <fo:inline font-style=\"italic\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void italic_()
+    {
+        writeln( "  </fo:inline>" );
+    }
+
+    /** {@inheritDoc} */
+    public void bold()
+    {
+        lnwrite( "  <fo:inline font-weight=\"bold\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void bold_()
+    {
+        writeln( "  </fo:inline>" );
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced()
+    {
+        lnwrite( "  <fo:inline font-family=\"monospace\" font-size=\"10pt\">" );
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced_()
+    {
+        writeln( "  </fo:inline>" );
+    }
+
+    /** {@inheritDoc} */
+    public void lineBreak()
+    {
+        newline();
+        writeln( "<fo:block/>" );
+    }
+
+    /** {@inheritDoc} */
+    public void nonBreakingSpace()
+    {
+        write( "&#160;" );
+    }
+
+    /** {@inheritDoc} */
+    public void text( String text )
+    {
+        content( text );
+    }
+
+    /** {@inheritDoc} */
+    public void rawText( String text )
+    {
+        // nop
+    }
+
+    /** {@inheritDoc} */
+    public void flush()
+    {
+        out.flush();
+    }
+
+    /** {@inheritDoc} */
+    public void close()
+    {
+        out.close();
+    }
+
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void write( String text )
+    {
+        out.write( text, true );
+    }
+
+    private void writeln( String text )
+    {
+        out.write( text, true );
+        newline();
+    }
+
+    private void lnwrite( String text )
+    {
+        newline();
+        out.write( text, true );
+    }
+
+    private void content( String text )
+    {
+        out.write( escaped( text ), true );
+    }
+
+    private void newline()
+    {
+        out.write( EOL, false );
+    }
+
+    private String escaped( String text )
+    {
+        int length = text.length();
+        StringBuffer buffer = new StringBuffer( length );
+
+        for ( int i = 0; i < length; ++i )
+        {
+            char c = text.charAt( i );
+            switch ( c )
+            {
+                case ' ':
+                    if ( verbatim )
+                    {
+                        buffer.append( "&#160;" );
+                    }
+                    else
+                    {
+                        buffer.append( c );
+                    }
+                    break;
+                case '<':
+                    buffer.append( "&lt;" );
+                    break;
+                case '>':
+                    buffer.append( "&gt;" );
+                    break;
+                case '&':
+                    buffer.append( "&amp;" );
+                    break;
+                case '\u00a9': // copyright
+                    buffer.append( "&#169;" );
+                    break;
+                case '\n':
+                    buffer.append( EOL );
+                    if ( verbatim )
+                    {
+                        buffer.append( "<fo:block/>" + EOL );
+                    }
+                    break;
+                default:
+                    buffer.append( c );
+            }
+        }
+
+        return buffer.toString();
+    }
+
+
+}

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java Sun Jun 17 13:40:47 2007
@@ -0,0 +1,149 @@
+package org.apache.maven.doxia.module.fo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.maven.doxia.sink.Sink;
+
+/**
+ * Used to count the position in a numbered list.
+ */
+public class NumberedListItem
+{
+
+    /** Arabic decimals from 1 - 26. */
+    private static final String[] DECIMALS =
+    {
+        "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
+        "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
+        "21", "22", "23", "24", "25", "26"
+    };
+
+    /** Lower-case alphanumerics from a - z. */
+    private static final String[] LOWER_ALPHAS =
+    {
+        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+        "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+        "u", "v", "w", "x", "y", "z"
+    };
+
+    /** Upper-case alphanumerics from A - Z. */
+    private static final String[] UPPER_ALPHAS =
+    {
+        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
+        "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
+        "U", "V", "W", "X", "Y", "Z"
+    };
+
+    /** Lower-case roman numbers from i - xxvi. */
+    private static final String[] LOWER_ROMANS =
+    {
+        "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x",
+        "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx",
+        "xxi", "xxii", "xxiii", "xxiv", "xxv", "xxvi"
+    };
+
+    /** Upper-case roman numbers from I - XXVI. */
+    private static final String[] UPPER_ROMANS =
+    {
+        "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X",
+        "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX",
+        "XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI"
+    };
+
+    /** The position in the list. */
+    private int count;
+
+    /** The numbering format. */
+    private final int format;
+
+    /** Constructor. Initializes count and format.
+     * @param itemFormat The numbering format of this List.
+     * Should be one of the formats defined in {@link Sink}.
+     */
+    public NumberedListItem ( int itemFormat )
+    {
+        this.format = itemFormat;
+        this.count = 0;
+    }
+
+    /**
+     * Returns the current count, ie the position in the list.
+     * @return The current count.
+     */
+    public int count()
+    {
+        return count;
+    }
+
+    /**
+     * Returns the numbering format.
+     * @return The numbering format.
+     */
+    public int format()
+    {
+        return format;
+    }
+
+    /** Increase the current count by 1. */
+    public void next()
+    {
+        count++;
+    }
+
+     /**
+     * Returns the symbol for the current list item.
+     * @return The symbol for the current list item.
+     */
+    public String getListItemSymbol()
+    {
+        int j = count() - 1;
+        if ( j < 0 )
+        {
+            j = 0;
+        }
+        else if ( j > DECIMALS.length - 1 )
+        {
+            j = DECIMALS.length - 1;
+        }
+
+        String symbol;
+        switch ( format() )
+        {
+            case Sink.NUMBERING_UPPER_ALPHA:
+                symbol = UPPER_ALPHAS[j];
+                break;
+            case Sink.NUMBERING_LOWER_ALPHA:
+                symbol = LOWER_ALPHAS[j];
+                break;
+            case Sink.NUMBERING_UPPER_ROMAN:
+                symbol = UPPER_ROMANS[j];
+                break;
+            case Sink.NUMBERING_LOWER_ROMAN:
+                symbol = LOWER_ROMANS[j];
+                break;
+            case Sink.NUMBERING_DECIMAL:
+            default:
+                symbol = DECIMALS[j];
+        }
+        return symbol;
+    }
+
+
+}

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/NumberedListItem.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml Sun Jun 17 13:40:47 2007
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+ -->
+
+<project name="Doxia :: FO Module">
+  <bannerLeft>
+    <name>Doxia :: FO Module</name>
+    <src>http://maven.apache.org/images/apache-maven-project-2.png</src>
+    <href>http://maven.apache.org/doxia/</href>
+  </bannerLeft>
+  <bannerRight>
+    <src>http://maven.apache.org/images/maven-logo-2.gif</src>
+  </bannerRight>
+  <publishDate format="dd MMM yyyy" />
+  <skin>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-stylus-skin</artifactId>
+  </skin>
+  <body>
+    <links>
+      <item name="Apache" href="http://www.apache.org/"/>
+      <item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
+      <item name="Maven 2.x" href="http://maven.apache.org/"/>
+      <item name="Continuum" href="http://maven.apache.org/continuum"/>
+      <item name="SCM" href="http://maven.apache.org/scm"/>
+      <item name="Wagon" href="http://maven.apache.org/wagon"/>
+      <item name="JXR" href="http://maven.apache.org/jxr"/>
+      <item name="Doxia" href="http://maven.apache.org/doxia"/>
+    </links>
+
+    <menu name="Doxia :: FO Module">
+      <item name="Overview" href="index.html"/>
+      <item name="Usage" href="usage.html"/>
+      <item name="Links" href="links.html"/>
+    </menu>
+
+    ${reports}
+
+  </body>
+</project>

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml Sun Jun 17 13:40:47 2007
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<document>
+  <properties>
+    <title>Doxia FO Module - Index</title>
+    <author email="ltheussl@apache.org">Lukas Theussl</author>
+  </properties>
+
+  <body>
+    <section name="Doxia FO Module">
+
+      <p>
+        This is a <a href="http://maven.apache.org/doxia/">Doxia</a> module
+        for <a href="http://www.w3.org/TR/xsl/">XSL Formatting Objects</a>.
+      </p>
+      <p>
+        Currently only a sink is available, ie you can generate FO files
+        from other formats supported by Doxia, but you cannot parse them.
+      </p>
+      <p>
+        The generated FO files can then be converted into other formats,
+        eg pdf, using <a href="http://xmlgraphics.apache.org/fop/">Apache Fop</a>.
+      </p>
+
+      <subsection name="Current limitations">
+        <ul>
+          <li>Not configurable</li>
+          <li>No page headers, page numbering</li>
+          <li>Table captions not implemented</li>
+          <li>Table header cells not implemented</li>
+          <li>Table width is fixed</li>
+          <li>Only supported graphics format is png.</li>
+        </ul>
+      </subsection>
+
+    </section>
+
+  </body>
+</document>
\ No newline at end of file

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/index.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml Sun Jun 17 13:40:47 2007
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<document>
+  <properties>
+    <title>Doxia FO Module - Links</title>
+    <author email="ltheussl@apache.org">Lukas Theussl</author>
+  </properties>
+
+  <body>
+    <section name="Useful links">
+
+      <ul>
+        <li><a href="http://xmlgraphics.apache.org/fop/">Apache FOP</a></li>
+        <li><a href="http://www.w3.org/TR/xsl/">W3C XSL Recommendation</a></li>
+        <li><a href="http://www.w3.org/TR/xslt">W3C XSLT Recommendation</a></li>
+        <li><a href="http://www.adobe.com/devnet/pdf/pdf_reference.html">PDF Reference</a></li>
+        <li><a href="http://www.w3schools.com/xslfo/default.asp">XSL-FO Tutorial</a></li>
+        <li><a href="http://www.xmlmind.com/foconverter/">XMLmind FO Converter</a></li>
+      </ul>
+
+    </section>
+
+  </body>
+</document>
\ No newline at end of file

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/links.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml Sun Jun 17 13:40:47 2007
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<document>
+  <properties>
+    <title>Doxia FO Module - Usage</title>
+    <author email="ltheussl@apache.org">Lukas Theussl</author>
+  </properties>
+
+  <body>
+    <section name="Usage">
+
+      <p>
+        Here's an example that converts an apt input file into a fo document.
+        To produce a pdf from the result using Apache FOP, see eg
+        <a href="http://xmlgraphics.apache.org/fop/0.93/embedding.html#ExampleFO2PDF">ExampleFO2PDF</a>.
+      </p>
+
+      <source>
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.maven.doxia.module.apt.AptParser;
+import org.apache.maven.doxia.module.fo.FoSink;
+import org.apache.maven.doxia.parser.ParseException;
+
+
+public class Apt2FO
+{
+    public static void main(String[] args)
+    {
+        try
+        {
+            // Open input apt document:
+            FileReader source = new FileReader( new File( "resources", "test.apt" ) );
+
+            // Create FO sink:
+            FoSink fosink = new FoSink( new FileWriter( new File( "output", "test.fo" ) ) );
+
+            AptParser parser = new AptParser();
+            parser.parse( source, fosink );
+
+            // close streams
+            fosink.close();
+            source.close();
+        }
+        catch ( ParseException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( FileNotFoundException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+    }
+}
+      </source>
+
+    </section>
+
+  </body>
+</document>
\ No newline at end of file

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/site/xdoc/usage.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java Sun Jun 17 13:40:47 2007
@@ -0,0 +1,68 @@
+package org.apache.maven.doxia.module.fo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.File;
+import java.io.StringWriter;
+
+import org.apache.maven.doxia.module.apt.AptParser;
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+
+/**
+ * <code>FO Sink</code> Test case.
+ */
+public class FoSinkTest extends AbstractSinkTestCase
+{
+
+    public void testConvertFO2PDF() throws Exception
+    {
+        // first create fo file from apt
+        new AptParser().parse( getTestReader(), createSink() );
+
+        // then generate PDF
+        File outputDirectory = new File( getBasedirFile(), "target/output" );
+        File resourceDirectory = new File( getBasedirFile(), "target/test-classes" );
+        File foFile = new File( outputDirectory, "test." + outputExtension() );
+        File pdfFile = new File( outputDirectory, "test.pdf" );
+        FoTestUtils.convertFO2PDF( foFile, pdfFile, resourceDirectory.getCanonicalPath() );
+    }
+
+    /** {@inheritDoc} */
+    protected String outputExtension()
+    {
+        return "fo";
+    }
+
+    /** {@inheritDoc} */
+    protected Parser createParser()
+    {
+        // fo parser?
+        return new AptParser();
+    }
+
+    /** {@inheritDoc} */
+    protected Sink createSink() throws Exception
+    {
+        return new FoSink( getTestWriter() );
+    }
+
+}

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java Sun Jun 17 13:40:47 2007
@@ -0,0 +1,104 @@
+package org.apache.maven.doxia.module.fo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+
+/**
+ * <code>FO Sink</code> Test utilities.
+ */
+public class FoTestUtils
+{
+
+    /**
+     * Converts an FO file to a PDF file using FOP.
+     * @param fo the FO file.
+     * @param pdf the target PDF file.
+     * @param resourceDir The base directory for relative path resolution.
+     * If null, defaults to the parent directory of fo.
+     * @throws IOException In case of an I/O problem.
+     * @throws FOPException In case of a FOP problem.
+     * @throws TransformerException In case of a transformer problem.
+     * @throws TransformerConfigurationException As above.
+     */
+    public static void convertFO2PDF( File fo, File pdf, String resourceDir )
+        throws IOException, FOPException, TransformerConfigurationException, TransformerException
+    {
+
+        FopFactory fopFactory = FopFactory.newInstance();
+        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
+        foUserAgent.setBaseURL( getBaseURL( fo, resourceDir ) );
+        OutputStream out = null;
+
+        try
+        {
+            out = new BufferedOutputStream( new FileOutputStream( pdf ) );
+            Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, foUserAgent, out );
+
+            Source src = new StreamSource( fo);
+            Result res = new SAXResult( fop.getDefaultHandler() );
+
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer transformer = factory.newTransformer(); // identity transformer
+            transformer.transform(src, res);
+        }
+        finally
+        {
+            out.close();
+        }
+    }
+
+    private static String getBaseURL( File fo, String resourceDir )
+    {
+        String url = null;
+        if ( resourceDir == null )
+        {
+            url = "file:///" + fo.getParent() + "/";
+        }
+        else
+        {
+            url = "file:///" + resourceDir + "/";
+        }
+        return url;
+    }
+
+}

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoTestUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/figure.png
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/figure.png?view=auto&rev=548106
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/figure.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt?view=auto&rev=548106
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt (added)
+++ maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt Sun Jun 17 13:40:47 2007
@@ -0,0 +1,104 @@
+                                    ------
+                                    Title
+                                    ------
+                                    Author
+                                    ------
+                                     Date
+
+  Paragraph 1, line 1.
+  Paragraph 1, line 2.
+
+  Paragraph 2, line 1.
+  Paragraph 2, line 2.
+
+Section title
+
+* Sub-section title
+
+** Sub-sub-section title
+
+*** Sub-sub-sub-section title
+
+**** Sub-sub-sub-sub-section title
+
+      * List item 1.
+
+      * List item 2.
+
+        Paragraph contained in list item 2.
+
+            * Sub-list item 1.
+
+            * Sub-list item 2.
+
+      * List item 3.
+        Force end of list:
+
+      []
+
++------------------------------------------+
+Verbatim text not contained in list item 3
++------------------------------------------+
+
+      [[1]] Numbered item 1.
+
+                [[A]] Numbered item A.
+
+                [[B]] Numbered item B.
+
+      [[2]] Numbered item 2.
+
+  List numbering schemes: [[1]], [[a]], [[A]], [[i]], [[I]].
+
+      [Defined term 1] of definition list.
+
+      [Defined term 2] of definition list.
+
++-------------------------------+
+Verbatim text
+                        in a box        
++-------------------------------+
+
+  --- instead of +-- suppresses the box around verbatim text.
+
+[figure] Figure caption
+
+*----------*--------------+----------------:
+| Centered | Left-aligned | Right-aligned  |
+| cell 1,1 | cell 1,2     | cell 1,3       |
+*----------*--------------+----------------:
+| cell 2,1 | cell 2,2     | cell 2,3       |
+*----------*--------------+----------------:
+Table caption
+
+  No grid, no caption:
+
+*-----*------*
+ cell | cell
+*-----*------*
+ cell | cell
+*-----*------*
+
+  Horizontal line:
+
+=======================================================================
+
+~~^L
+  New page.
+
+  <Italic> font. <<Bold>> font. <<<Monospaced>>> font.
+
+  {Anchor}. Link to {{Anchor}}. Link to {{http://www.pixware.fr}}. 
+  Link to {{{Anchor}showing alternate text}}.
+  Link to {{{http://www.pixware.fr}Pixware home page}}.
+
+  Force line\
+  break.
+
+  Non\ breaking\ space.
+
+  Escaped special characters: \~, \=, \-, \+, \*, \[, \], \<, \>, \{, \}, \\.
+
+  Copyright symbol: \251, \xA9, \u00a9.
+
+~~Commented out.

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/doxia/doxia-module-fo/src/test/resources/test.apt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message