You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2004/09/23 16:09:24 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/rtf/rtflib/testdocs TextAttributes.java CreateTestDocuments.java NestedTable.java SimpleLists.java MergedTableCells.java SimpleTable.java TestDocument.java Whitespace.java SimpleDocument.java ExternalGraphic.java package.html ListInTable.java DummyTableColumnsInfo.java BasicLink.java ParagraphAlignment.java

jeremias    2004/09/23 07:09:24

  Added:       test/java/org/apache/fop/render/rtf/rtflib/testdocs
                        TextAttributes.java CreateTestDocuments.java
                        TestDocument.java BasicLink.java NestedTable.java
                        DummyTableColumnsInfo.java SimpleDocument.java
                        package.html ParagraphAlignment.java
                        MergedTableCells.java Whitespace.java
                        ExternalGraphic.java SimpleLists.java
                        SimpleTable.java ListInTable.java
  Removed:     src/java/org/apache/fop/render/rtf/rtflib/testdocs
                        TextAttributes.java CreateTestDocuments.java
                        NestedTable.java SimpleLists.java
                        MergedTableCells.java SimpleTable.java
                        TestDocument.java Whitespace.java
                        SimpleDocument.java ExternalGraphic.java
                        package.html ListInTable.java
                        DummyTableColumnsInfo.java BasicLink.java
                        ParagraphAlignment.java
  Log:
  Moved test classes to their proper location.
  
  Revision  Changes    Path
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TextAttributes.java
  
  Index: TextAttributes.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: TextAttributes.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class TextAttributes extends TestDocument {
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          final RtfParagraph para = sect.newParagraph();
          para.newText("This is normal\n");
          para.newText("This is bold\n", new RtfAttributes().set(RtfText.ATTR_BOLD));
          para.newText("This is italic\n", new RtfAttributes().set(RtfText.ATTR_ITALIC));
          para.newText("This is underline\n", new RtfAttributes().set(RtfText.ATTR_UNDERLINE));
  
          // RTF font sizes are in half-points
          para.newText("This is size 48\n", new RtfAttributes().set(RtfText.ATTR_FONT_SIZE, 96));
  
          para.newText(
              "This is bold and italic\n",
              new RtfAttributes().set(RtfText.ATTR_BOLD).set(RtfText.ATTR_ITALIC)
            );
  
          final RtfAttributes attr = new RtfAttributes();
          attr.set(RtfText.ATTR_BOLD).set(RtfText.ATTR_ITALIC);
          attr.set(RtfText.ATTR_UNDERLINE);
          attr.set(RtfText.ATTR_FONT_SIZE, 72);
          para.newText("This is bold, italic, underline and size 36\n", attr);
  
          para.newText("This is back to normal\n");
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java
  
  Index: CreateTestDocuments.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: CreateTestDocuments.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.File;
  import java.io.IOException;
  //import org.apache.fop.render.rtf.rtflib.jfor.main.JForVersionInfo;
  
  /**  Create test RTF documents from classes found in this package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   *  @author Andreas Putz a.putz@skynamics.com
   */
  
  public class CreateTestDocuments {
  
      /**
       * package name for the testdocs
       */
      public static final String TESTDOCS_PACKAGE = "org.apache.fop.render.rtf.rtflib.testdocs";
  
      /** List of all TestDocument subclasses from this package */
      private static final String [] CLASS_NAMES = {
          "SimpleDocument",
          "TextAttributes",
          "SimpleTable",
          "SimpleLists",
          "ListInTable",
          "Whitespace",
          "MergedTableCells",
          "NestedTable",
          "ExternalGraphic",
          "BasicLink",
          "ParagraphAlignment"
      };
  
      CreateTestDocuments(File outDir)
      throws Exception {
          if (!outDir.isDirectory() || !outDir.canWrite()) {
              throw new IOException("output directory (" + outDir + ") must exist and be writable");
          }
  
          for (int i = 0; i < CLASS_NAMES.length; i++) {
              createOneTestDocument(CLASS_NAMES[i], outDir);
          }
      }
  
      /** instantiate one TestDocument and let it generate its document */
      void createOneTestDocument(String className, File outDir)
              throws Exception {
          className = TESTDOCS_PACKAGE + "." + className;
          TestDocument td = null;
          try {
              td = (TestDocument)Class.forName(className).newInstance();
          } catch (Exception e) {
              throw new Exception("unable to instantiate '" + className
                      + " as a TestDocument object: " + e);
          }
          td.setOutputDir(outDir);
          try {
              td.generateOutput();
          } catch (Exception e) {
              System.err.println("Error while generating test RTF document:");
              e.printStackTrace();
          }
      }
  
      /** execute this to create test documents from all classes listed in classNames array
       * @param args String array of arguments
       * @throws Exception for errors
       */
      public static void main(String[] args)
      throws Exception {
          if (args.length < 1) {
              System.err.println("usage: CreateTestDocuments <output directory>");
              System.exit(1);
          }
  
  //        System.err.println("CreateTestDocuments - using " + JForVersionInfo.getLongVersionInfo());
          System.err.println("Generates documents to test the RTF library.");
          final File outDir = new File(args[0]);
          new CreateTestDocuments(outDir);
          System.err.println("CreateTestDocuments - all done.");
          System.exit(0);
      }
  }
  
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/TestDocument.java
  
  Index: TestDocument.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: TestDocument.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.util.Date;
  import java.io.File;
  import java.io.IOException;
  import java.io.FileWriter;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  //import org.apache.fop.render.rtf.rtflib.jfor.main.JForVersionInfo;
  
  /**  Base class for generating RTF documents used to test the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  abstract class TestDocument {
      private File output;
  
      final void setOutputDir(File outDir)
      throws IOException {
          output = new File(outDir, getRtfFilename());
      }
  
      final String getRtfFilename() {
          // use class name for output filename
          final String name = getClass().getName();
          final int pos = name.lastIndexOf('.');
          return name.substring(pos + 1) + ".rtf";
      }
  
      final void generateOutput()
      throws IOException {
          debugMsg("Generating document " + output + "...");
          final RtfFile f = new RtfFile(new FileWriter(output));
          final RtfDocumentArea rda = f.startDocumentArea();
          final RtfSection sect = rda.newSection();
          addIntroComments(sect);
          generateDocument(rda, sect);
          f.flush();
      }
  
      protected abstract void generateDocument(RtfDocumentArea rda, RtfSection sect)
              throws IOException;
  
      void debugMsg(String msg) {
          System.err.println(msg);
      }
  
      protected void addIntroComments(RtfSection sect) throws IOException {
          final RtfParagraph para = sect.newParagraph();
  
          para.newText("jfor RTF library test document.");
          para.newLineBreak();
  //        para.newText(JForVersionInfo.getLongVersionInfo());
          para.newLineBreak();
          para.newText("generated by class " + getClass().getName());
          para.newLineBreak();
          para.newText("generated on " + new Date());
          para.close();
     }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/BasicLink.java
  
  Index: BasicLink.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: BasicLink.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink;
  
  import java.io.IOException;
  
  /**
   * Class <code>BasicLink</code> here.
   *
   * @author <a href="mailto:mks@ANDREAS">Andreas Putz</a>
   */
  
  public class BasicLink extends TestDocument {
      //////////////////////////////////////////////////
      // @@ Construction
      //////////////////////////////////////////////////
  
      /**
       * Default constructor.
       */
      public BasicLink() {
      }
  
      /** generate the body of the test document
       * @param rda RtfDocumentArea
       * @param sect RtfSection
       * @throws IOException for I/O Errors
       */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException {
          RtfParagraph p = sect.newParagraph ();
          p.newLineBreak();
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("external link: ");
          RtfHyperLink link = p.newHyperLink ("click here to go to the hompage", null);
          link.setExternalURL ("http://www.skynamics.com");
          p.close();
  
          p = sect.newParagraph ();
          p.newLineBreak();
          p.newText ("here we will demonstrate internal link to a bookmark");
          p.newLineBreak();
          p.newText ("internal link: ");
          link = p.newHyperLink ("click here to go to the bookmark", null);
          link.setInternalURL ("testBookmark");
          p.close();
  
          p = sect.newParagraph();
          p.newLineBreak();
          p.newLineBreak();
          p.newLineBreak();
          p.newPageBreak();
          p.newBookmark("testBookmark");
          p.newText("testBookmark");
      }
  }
  
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/NestedTable.java
  
  Index: NestedTable.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: NestedTable.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell;
  
  /**  Generates an RTF document to test nested tables with the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class NestedTable extends TestDocument {
      private static final int MM_TO_TWIPS = (int)(1440f / 25.4f);
  
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("This document demonstrates pseudo-nested "
                  + "tables created using merged table cells");
  
          firstTestTable(sect);
          RtfParagraph p = sect.newParagraph();
          p.newText("Test continues on next page.");
          p.newPageBreak();
          secondTestTable(sect);
  
          p = sect.newParagraph();
          p.newText("Test continues on next page.");
          p.newPageBreak();
          thirdTestTable(sect);
  
          sect.newParagraph().newText("End of nested tables test document");
      }
  
      private void firstTestTable(RtfSection sect)
      throws IOException {
  
          sect.newParagraph().newText("First test: table with one nested table in cell 1,1");
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
          // first row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(160 * MM_TO_TWIPS);
              c.newParagraph().newText("cell 0,0, width 160mm, only cell in this row.");
          }
  
          // second row contains nested table
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,0, width 40mm, to the left of nested table.");
  
              final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
              c.newParagraph().newText("cell 1,1, width 80mm, this text is "
                      + "followed by a nested table in the same cell, followed "
                      + "by text that says 'AFTER NESTED TABLE'.");
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 1);
              c.newParagraph().newText("AFTER NESTED TABLE");
  
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,2, width 40mm, to the right of nested table.");
          }
  
          // third row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,0, width 80mm, this row has two cells.");
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,1, width 80mm, last cell.");
          }
  
      }
  
      private void secondTestTable(RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("Second test: table with two nested tables in cell 1,1");
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
          // first row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(160 * MM_TO_TWIPS);
              c.newParagraph().newText("second test table: cell 0,0, width 160mm, "
                      + "only cell in this row.");
          }
  
          // second row contains nested table
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,0, width 40mm, to the left of nested tables.");
  
              final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
              c.newParagraph().newText("cell 1,1, width 80mm, this text is "
                      + "followed by a nested table in the same cell, followed "
                      + "by text that says 'BETWEEN', then another table, then 'AFTER'.");
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 2);
              c.newParagraph().newText("BETWEEN");
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 3);
              c.newParagraph().newText("AFTER");
  
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,2, width 40mm, to the right of nested table.");
          }
  
          // third row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,0, width 80mm, this row has two cells.");
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,1, width 80mm, last cell.");
          }
      }
  
      private void thirdTestTable(RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("Third test: table with two nested tables "
                  + "in cell 1,1 and one nested table in cell 0,1");
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
          // first row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
              c.newParagraph().newText("third test table: cell 0,0, width 40mm, "
                      + "the cell to its right contains a nested table with no other text.");
              c = r.newTableCell(80 * MM_TO_TWIPS);
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 4);
          }
  
          // second row contains nested table
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,0, width 40mm, to the left of nested tables.");
  
              final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
              c.newParagraph().newText("cell 1,1, width 80mm, this text is "
                      + "followed by a nested table in the same cell, followed "
                      + "by text that says 'BETWEEN', then another table, then 'AFTER'.");
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 5);
              c.newParagraph().newText("BETWEEN");
              fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 6);
              c.newParagraph().newText("AFTER");
  
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 1,2, width 40mm, to the right of nested table.");
          }
  
          // third row, normal
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,0, width 80mm, this row has two cells.");
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 2,1, width 80mm, last cell.");
          }
      }
  
      /** fill the nested table */
      private void fillNestedTable(RtfTable tbl, int index)
      throws IOException {
          final String id = "TABLE " + index;
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText(
              id + ":nested cell 0,0. Nested table contains 3 rows with 1,2 and 3 cells respectively"
              );
          }
  
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 1,0, 40mm.");
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 1,1, 40mm.");
          }
  
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,0, 30mm.");
              r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,1, 30mm.");
              r.newTableCell(20 * MM_TO_TWIPS).newParagraph().newText(id + ":nested cell 2,2, 20mm.");
          }
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java
  
  Index: DummyTableColumnsInfo.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: DummyTableColumnsInfo.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import org.apache.fop.render.rtf.rtflib.interfaces.ITableColumnsInfo;
  
  /** ITableColumnsInfo that does nothing, used in testodcs package
   *  to create documents without worrying about nested tables handling.
   *  Might need to be replaced by more complete version in some sample
   *  documents created by this package.
   *
   *  @author bdelacretaz@codeconsult.ch
   */
  
  class DummyTableColumnsInfo implements ITableColumnsInfo {
  
      public float getColumnWidth() {
          return INVALID_COLUM_WIDTH;
      }
  
      public void selectFirstColumn() {
      }
  
      public int getNumberOfColumns() {
          return 0;
      }
  
      public int getColumnIndex() {
          return 0;
      }
  
      public void selectNextColumn() {
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleDocument.java
  
  Index: SimpleDocument.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: SimpleDocument.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class SimpleDocument
  extends TestDocument {
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("First paragraph of the simple RTF test document.");
  
          final RtfParagraph para = sect.newParagraph();
          para.newText("Second paragraph of simple RTF test document.\n");
          for (int i = 0; i < 242; i++) {
              para.newText("This is string " + i);
              para.newLineBreak();
          }
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/package.html
  
  Index: package.html
  ===================================================================
  <HTML>
  <TITLE>org.apache.fop.render.rtf.rtflib.testdocs</TITLE>
  <BODY>
  <P>Classes used to test/demonstrate RTFLib capabilities by generating sample
  RTF documents.</P>
  </BODY>
  </HTML>
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ParagraphAlignment.java
  
  Index: ParagraphAlignment.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: ParagraphAlignment.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  public class ParagraphAlignment extends TestDocument {
  
      /**
       * Constructor
       */
      public ParagraphAlignment() {
      }
  
      /**
       * Generate the document.
       * @param rda RtfDocumentArea
       * @param sect RtfSection
       * @throws java.io.IOException for I/O errors
       */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException
      {
          RtfAttributes attr = new RtfAttributes ();
          attr.set(RtfText.ALIGN_CENTER);
          RtfParagraph p = sect.newParagraph (attr);
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("Centered title");
          p.newLineBreak();
          p.close();
  
          attr = new RtfAttributes ();
          attr.set(RtfText.ALIGN_LEFT);
          p = sect.newParagraph (attr);
          p.newLineBreak();
          p.newText ("This is the left aligned text.");
          p.newLineBreak();
          p.close();
  
          attr = new RtfAttributes ();
          attr.set(RtfText.ALIGN_RIGHT);
          p = sect.newParagraph (attr);
          p.newLineBreak();
          p.newText ("This is the right aligned text.");
          p.newLineBreak();
          p.close();
      }
  }
  
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/MergedTableCells.java
  
  Index: MergedTableCells.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: MergedTableCells.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell;
  
  /**  Generates an RTF test document containing merged table cells
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class MergedTableCells extends TestDocument {
      static final int MM_TO_TWIPS = (int)(1440f / 25.4f);
  
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("This document contains a table with some merged cells.");
  
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
  
          // first row, test horizontal merging
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
              c.setHMerge(RtfTableCell.MERGE_START);
              c.newParagraph().newText("cell 0,0, width 80mm, merge start, "
                      + "followed by two merged cells totalling 80mm width.");
  
              c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
              c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT");
  
              c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
              c.newParagraph().newText("THIS IS IN AN HMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT");
          }
  
          // second row, start vertical merging in column 1
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setVMerge(RtfTableCell.MERGE_START);
              c.newParagraph().newText("cell 1,0, vertical merge start, 40mm, spans three rows.");
  
              r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 1,1, no merge, 80mm");
  
              c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setVMerge(RtfTableCell.MERGE_START);
              c.newParagraph().newText("cell 1,2, vertical merge start, 40mm, spans two rows.");
          }
  
          // third row, column 1 merged with previous row
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
              c.newParagraph().newText("cell 2,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT");
  
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, no merge, 40mm");
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 2,2, no merge, 40mm");
  
              c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
              c.newParagraph().newText("cell 2,3, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT");
          }
  
          // fourth row, column 1 merged with previous row
          {
              RtfTableRow r = tbl.newTableRow();
              RtfTableCell c = r.newTableCell(40 * MM_TO_TWIPS);
              c.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
              c.newParagraph().newText("cell 3,0, VMERGED CELL, MUST NOT APPEAR IN RTF DOCUMENT");
  
              r.newTableCell(10 * MM_TO_TWIPS).newParagraph().newText("cell 3,1, no merge, 10mm");
              r.newTableCell(30 * MM_TO_TWIPS).newParagraph().newText("cell 3,2, no merge, 30mm");
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,3, no merge, 40mm");
              r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 3,4, no merge, 40mm");
          }
  
          // fifth row, just one cell
          {
              RtfTableRow r = tbl.newTableRow();
              r.newTableCell(160 * MM_TO_TWIPS).newParagraph().newText
                      ("cell 4,0, width 160mm, only cell in this row");
          }
      }
  }
  
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/Whitespace.java
  
  Index: Whitespace.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: Whitespace.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  
  /**  Generates an RTF document to test the WhitespaceCollapser
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class Whitespace extends TestDocument {
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          final RtfParagraph p1 = sect.newParagraph();
          p1.newText("\t  Each word  of this paragraph must   be "
                     + "separated\tfrom\t\n\tthe next word with exactly\t \tone");
          p1.newText("   space.");
  
          final RtfParagraph p2 = sect.newParagraph();
          p2.newText("");
          p2.newText("In this");
          p2.newText(" paragraph ");
          p2.newText("as well,");
          p2.newText("   there must\tbe    \t");
          p2.newText("exactly");
          p2.newText(" one space   ");
          p2.newText("between  each\tword and the  next, and no spaces at the "
                     + "beginning or end of the paragraph.");
  
          final RtfParagraph p3 = sect.newParagraph();
          p3.newText("The word 'boomerang' must be written after this with no funny spacing: ");
          p3.newText("boo");
          p3.newText("me");
          p3.newText("r");
          p3.newText("a");
          p3.newText("ng.");
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ExternalGraphic.java
  
  Index: ExternalGraphic.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: ExternalGraphic.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  
  import java.io.IOException;
  /**
   * Generate a test document containing external graphics.
   *
   * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
   */
  class ExternalGraphic extends TestDocument {
      private String file = "file:///tmp/jfor-images/logo.";
  
      //////////////////////////////////////////////////
      // @@ Construction
      //////////////////////////////////////////////////
  
      /**
       * Default constructor.
       */
      public ExternalGraphic () {
  
      }
      /** generate the body of the test document */
      protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException {
          RtfParagraph p = sect.newParagraph ();
          p.newLineBreak();
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("EMF image with 150 % height");
          p.newLineBreak();
          RtfExternalGraphic imageA = p.newImage ();
          imageA.setURL (file + "emf");
          imageA.setHeight ("150%");
          p.newLineBreak();
          p.close();
  
          p = sect.newParagraph();
          p.newLineBreak();
          p.newText ("PNG image with 150 % width");
          p.newLineBreak();
          RtfExternalGraphic imageB = sect.newImage ();
          imageB.setURL (file + "png");
          imageB.setWidth ("150%");
          p.newLineBreak();
          p.close();
  
          p = sect.newParagraph();
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("JPG image with width = 200px and height = 20 px");
          p.newLineBreak();
          RtfExternalGraphic imageC = sect.newImage ();
          imageC.setURL (file + "jpg");
          imageC.setWidth ("200");
          imageC.setHeight ("20");
          p.newLineBreak();
          p.close();
  
          p = sect.newParagraph();
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image "
                  + "size will adjusted automatically");
          p.newLineBreak();
          RtfExternalGraphic imageD = sect.newImage ();
          imageD.setURL (file + "gif");
          imageD.setWidth ("200");
          imageD.setScaling ("uniform");
          p.newLineBreak();
          p.close();
  
          p = sect.newParagraph();
          p.newLineBreak();
          p.newLineBreak();
          p.newText ("GIF image");
          p.newLineBreak();
          RtfExternalGraphic imageE = sect.newImage ();
          imageE.setURL (file + "gif");
          p.newLineBreak();
          p.close();
  
      }
  
  
  
  }
  
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleLists.java
  
  Index: SimpleLists.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: SimpleLists.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyle;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListStyleNumber;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  
  class SimpleLists extends TestDocument {
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("First paragraph of the 'SimpleLists' RTF test document.");
          sect.newParagraph().newText("First bulleted list with 5 items.");
          makeList(sect, 1, 5, null);
          sect.newParagraph().newText("Normal paragraph between lists 1 and 2.");
          makeList(sect, 2, 3, null);
          sect.newParagraph().newText("Normal paragraph after list 2.");
  
          sect.newParagraph().newText("Now a numbered list (4 items):");
          makeList(sect, 3, 4, new RtfListStyleNumber());
      }
  
      private void makeList(RtfSection sect, int listIndex, int nItems, RtfListStyle ls)
      throws IOException {
          final RtfList list = sect.newList(null);
          if (ls != null) {
              list.setRtfListStyle(ls);
          }
          for (int i = 0; i < nItems; i++) {
              final RtfListItem item = list.newListItem();
              for (int j = 0; j <= i; j++) {
                  final RtfParagraph para = item.newParagraph();
                  para.newText("List " + listIndex + ", item " + i + ", paragraph " + j);
                  if (i == 0 && j == 0) {
                      final String txt = "This item takes more than one line to check word-wrapping.";
                      para.newText(". " + "This list should have " + nItems
                              + " items. " + txt + " " + txt + " " + txt);
                  }
              }
          }
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/SimpleTable.java
  
  Index: SimpleTable.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: SimpleTable.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
   */
  class SimpleTable extends TestDocument {
      /** generate the body of the test document */
      static final int MAX_ROW = 2;
      static final int MAX_COL = 3;
      static final int INCH_TO_TWIPS = 1440;
      static final int C1W = 4;
  
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
          tbl.newTableRow().newTableCell(C1W * INCH_TO_TWIPS).newParagraph().newText
                  ("Here's a table row with just one cell, width " + C1W + "''");
  
          for (int row = 0; row < MAX_ROW; row++) {
              final RtfTableRow r = tbl.newTableRow();
  
              for (int col = 0; col < MAX_COL; col++) {
                  final float widthInInches = col / 2f + 1f;
                  final int widthInTwips = (int)(widthInInches * INCH_TO_TWIPS);
                  final RtfTableCell c = r.newTableCell(widthInTwips);
                  c.newParagraph().newText("(" + row + "," + col + "), width "
                          + widthInInches  + "''");
                  if (row == 0 && col == 1) {
                      for (int i = 0; i < 4; i++) {
                          c.newParagraph().newText("additional paragraph " + i + " of cell 0,1");
                      }
                  }
              }
          }
  
          sect.newParagraph().newText("This paragraph follows the table.");
      }
  }
  
  
  1.1                  xml-fop/test/java/org/apache/fop/render/rtf/rtflib/testdocs/ListInTable.java
  
  Index: ListInTable.java
  ===================================================================
  /*
   * Copyright 1999-2004 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.
   */
  
  /* $Id: ListInTable.java,v 1.1 2004/09/23 14:09:23 jeremias Exp $ */
  
  
  /*
   * This file is part of the RTF library of the FOP project, which was originally
   * created by Bertrand Delacretaz <bd...@codeconsult.ch> and by other
   * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
   * the FOP project.
   */
  
  package org.apache.fop.render.rtf.rtflib.testdocs;
  
  import java.io.IOException;
  
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
  import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
  
  /**  Generates a simple RTF test document for the jfor rtflib package.
   */
  
  class ListInTable extends TestDocument {
      /** generate the body of the test document */
      protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
      throws IOException {
          sect.newParagraph().newText("There must be a table below where the "
                  + "second cell contains a bulleted list mixed with normal paragraphs");
  
          final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
          final RtfTableRow row = tbl.newTableRow();
          row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell A, simple");
  
          final RtfTableCell c = row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH);
          c.newParagraph().newText("cell B, contains this paragraph followed by "
                  + "a list and another paragraph");
          fillList(c.newList(null), 1, 3);
          c.newParagraph().newText("Normal paragraph, follows the list.");
  
          row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell C, simple");
      }
  
      private void fillList(RtfList list, int listIndex, int nItems)
      throws IOException {
          for (int i = 0; i < nItems; i++) {
              final RtfListItem item = list.newListItem();
              for (int j = 0; j <= i; j++) {
                  final RtfParagraph para = item.newParagraph();
                  para.newText("List " + listIndex + ", item " + i + ", paragraph " + j);
                  if (i == 0 && j == 0) {
                      final String txt = "This item takes more than one line to check word-wrapping.";
                      para.newText(". " + "This list must have " + nItems
                              + " items. " + txt + " " + txt + " " + txt);
                  }
              }
          }
      }
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org