aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBertrand Delacretaz <bdelacretaz@apache.org>2003-06-20 16:08:27 +0000
committerBertrand Delacretaz <bdelacretaz@apache.org>2003-06-20 16:08:27 +0000
commit6b224cde3d8732b3af689edd314204931418ff70 (patch)
tree1986f8eb9c5937089b8c27c9e2ec22f7f63efec3 /src
parent9a5987593fed944979a8926f620191d432d48b42 (diff)
downloadxmlgraphics-fop-6b224cde3d8732b3af689edd314204931418ff70.tar.gz
xmlgraphics-fop-6b224cde3d8732b3af689edd314204931418ff70.zip
jfor RTF library donated to the FOP project
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196519 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java66
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java67
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/BorderAttributesConverter.java143
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java87
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java62
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java61
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java76
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java67
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java69
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java61
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java66
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java72
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java66
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java68
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java61
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java61
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java70
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java62
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java71
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java81
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/ITableAttributes.java154
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java69
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java113
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java73
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java147
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java210
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java74
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java194
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java132
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java285
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java210
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfDocumentArea.java80
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java289
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java633
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java308
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java207
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontManager.java215
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontTable.java82
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java120
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java228
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java111
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfLineBreak.java81
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfList.java166
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListItem.java121
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java195
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfNull.java68
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfOptions.java70
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPage.java120
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageArea.java89
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageBreak.java81
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumber.java111
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java136
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraph.java300
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java107
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfSection.java200
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStringConverter.java135
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java283
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java161
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java417
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java345
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java130
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java297
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java119
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java106
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java122
-rw-r--r--src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java85
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java145
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java96
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java137
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java212
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java98
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java78
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java98
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java92
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java113
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java90
-rwxr-xr-xsrc/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java90
77 files changed, 10665 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java
new file mode 100755
index 000000000..fd85af925
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.exceptions;
+
+/** Base class for rtflib exceptions.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfException extends java.io.IOException
+{
+ public RtfException(String reason)
+ {
+ super(reason);
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java
new file mode 100755
index 000000000..7dba69b4b
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.exceptions;
+
+/** Thrown when a method call would lead to an invalid RTF document structure.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfStructureException
+extends RtfException
+{
+ public RtfStructureException(String reason)
+ {
+ super(reason);
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/BorderAttributesConverter.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/BorderAttributesConverter.java
new file mode 100644
index 000000000..ea20f7b3b
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/BorderAttributesConverter.java
@@ -0,0 +1,143 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+/** Constants for RTF border attribute names, and a static method for converting fo attribute strings. */
+
+public class BorderAttributesConverter {
+
+ public static final String BORDER_SINGLE_THICKNESS = "brdrs";
+ public static final String BORDER_DOUBLE_THICKNESS = "brdrth";
+ public static final String BORDER_SHADOWED ="brdrsh";
+ public static final String BORDER_DOUBLE ="brdrdb";
+ public static final String BORDER_DOTTED ="brdrdot";
+ public static final String BORDER_DASH ="brdrdash";
+ public static final String BORDER_HAIRLINE ="brdrhair";
+ public static final String BORDER_DASH_SMALL ="brdrdashsm";
+ public static final String BORDER_DOT_DASH = "brdrdashd";
+ public static final String BORDER_DOT_DOT_DASH = "brdrdashdd";
+ public static final String BORDER_TRIPLE = "brdrtriple";
+ public static final String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
+ public static final String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
+ public static final String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
+ public static final String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
+ public static final String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
+ public static final String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
+ public static final String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
+ public static final String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
+ public static final String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
+ public static final String BORDER_WAVY = "brdrwavy";
+ public static final String BORDER_WAVY_DOUBLE = "brdrwavydb";
+ public static final String BORDER_STRIPED = "brdrdashdotstr";
+ public static final String BORDER_EMBOSS = "brdremboss";
+ public static final String BORDER_ENGRAVE = "brdrengrave";
+ public static final String BORDER_COLOR = "brdrcf";
+ public static final String BORDER_SPACE = "brsp";
+ public static final String BORDER_WIDTH = "brdrw";
+
+ public static final String [] BORDERS = new String[] {
+ BORDER_SINGLE_THICKNESS, BORDER_DOUBLE_THICKNESS, BORDER_SHADOWED,
+ BORDER_DOUBLE, BORDER_DOTTED, BORDER_DASH,
+ BORDER_HAIRLINE, BORDER_DASH_SMALL, BORDER_DOT_DASH,
+ BORDER_DOT_DOT_DASH, BORDER_TRIPLE, BORDER_THINK_THIN_SMALL,
+ BORDER_THIN_THICK_SMALL, BORDER_THIN_THICK_THIN_SMALL, BORDER_THINK_THIN_MEDIUM,
+ BORDER_THIN_THICK_MEDIUM, BORDER_THIN_THICK_THIN_MEDIUM, BORDER_THINK_THIN_LARGE,
+ BORDER_THIN_THICK_LARGE, BORDER_THIN_THICK_THIN_LARGE, BORDER_WAVY,
+ BORDER_WAVY_DOUBLE, BORDER_STRIPED, BORDER_EMBOSS,
+ BORDER_ENGRAVE, BORDER_COLOR, BORDER_SPACE,
+ BORDER_WIDTH
+ };
+
+ /**BorderAttributesConverter: Static Method for converting FO strings
+ * to RTF control words*/
+ public static String convertAttributetoRtf(String value) {
+ // Added by Normand Masse
+ // "solid" is interpreted like "thin"
+ if(value.equals("thin") || value.equals("solid")){
+ return BORDER_SINGLE_THICKNESS;
+ }else if (value.equals("thick")) {
+ return BORDER_DOUBLE_THICKNESS;
+ }else if(value.equals("shadowed")){
+ return BORDER_SHADOWED;
+ }else if(value.equals("double")){
+ return BORDER_DOUBLE;
+ }else if(value.equals("dotted")){
+ return BORDER_DOTTED;
+ }else if(value.equals("dash")){
+ return BORDER_DASH;
+ }else if(value.equals("hairline")){
+ return BORDER_HAIRLINE;
+ }else if(value.equals("dot-dash")){
+ return BORDER_DOT_DASH;
+ }else if(value.equals("dot-dot-dash")){
+ return BORDER_DOT_DOT_DASH;
+ }else if(value.equals("triple")){
+ return BORDER_TRIPLE;
+ }else if(value.equals("wavy")){
+ return BORDER_WAVY;
+ }else if(value.equals("wavy-double")){
+ return BORDER_WAVY_DOUBLE;
+ }else if(value.equals("striped")){
+ return BORDER_STRIPED;
+ }else if(value.equals("emboss")){
+ return BORDER_EMBOSS;
+ }else if(value.equals("engrave")){
+ return BORDER_ENGRAVE;
+ }else{
+ return null;
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java
new file mode 100644
index 000000000..938233579
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java
@@ -0,0 +1,87 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+/** Constants for RTF table attribute names */
+
+public interface IBorderAttributes {
+
+ String BORDER_SINGLE_THICKNESS = "brdrs";
+ String BORDER_DOUBLE_THICKNESS = "brdrth";
+ String BORDER_SHADOWED ="brdrsh";
+ String BORDER_DOUBLE ="brdrdb";
+ String BORDER_DOTTED ="brdrdot";
+ String BORDER_DASH ="brdrdash";
+ String BORDER_HAIRLINE ="brdrhair";
+ String BORDER_DASH_SMALL ="brdrdashsm";
+ String BORDER_DOT_DASH = "brdrdashd";
+ String BORDER_DOT_DOT_DASH = "brdrdashdd";
+ String BORDER_TRIPLE = "brdrtriple";
+ String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
+ String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
+ String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
+ String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
+ String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
+ String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
+ String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
+ String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
+ String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
+ String BORDER_WAVY = "brdrwavy";
+ String BORDER_WAVY_DOUBLE = "brdrwavydb";
+ String BORDER_STRIPED = "brdrdashdotstr";
+ String BORDER_EMBOSS = "brdremboss";
+ String BORDER_ENGRAVE = "brdrengrave";
+ String BORDER_COLOR = "brdrcf";
+ String BORDER_SPACE = "brsp";
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java
new file mode 100644
index 000000000..a236256f6
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** interface for RTF objects that can contain footers */
+public interface IRtfAfterContainer
+{
+ public RtfAfter newAfter(RtfAttributes attrs) throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java
new file mode 100644
index 000000000..3597a46c7
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+public interface IRtfBeforeContainer
+{
+ public RtfBefore newBefore(RtfAttributes attrs) throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java
new file mode 100755
index 000000000..bb8ea2118
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java
@@ -0,0 +1,76 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/**
+ * RTF Bookmark container interface.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+public interface IRtfBookmarkContainer
+{
+
+ /**
+ * Create a new RTF bookmark.
+ *
+ * @param bookmark Name of the bookmark
+ *
+ * @return RTF bookmark
+ *
+ * @throws IOException On eror
+ */
+ RtfBookmark newBookmark (String bookmark) throws IOException;
+}
+
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java
new file mode 100755
index 000000000..9d122cef1
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+public interface IRtfExternalGraphicContainer
+{
+
+ /**
+ * Creates a new image on external graphic base.
+ *
+ * @exception IOException On error
+ */
+ RtfExternalGraphic newImage () throws IOException;
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java
new file mode 100755
index 000000000..a3ce7f2c3
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** interface for RtfElements that can contain RtfHyperLinks
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+public interface IRtfHyperLinkContainer extends IRtfTextContainer
+{
+ /**
+ * Creates a new hyperlink.
+ *
+ * @exception IOException on error
+ */
+ public RtfHyperLink newHyperLink (String str, RtfAttributes attr) throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java
new file mode 100644
index 000000000..475932df2
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+
+import java.io.IOException;
+
+public interface IRtfJforCmdContainer {
+ public RtfJforCmd newJforCmd(RtfAttributes attr) throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java
new file mode 100755
index 000000000..25de23978
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** Interface for RtfElements that can contain RtfLists
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfListContainer
+{
+ /** close current list if any and start a new one */
+ public RtfList newList(RtfAttributes attrs) throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java
new file mode 100644
index 000000000..95bb80213
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+/**
+ * Options for configuring the rtf elements.
+ */
+public interface IRtfOptions
+{
+ /**
+ * Sets the compression rate for the external graphic in percent.
+ * @param percent Compression rate
+ */
+ public void setRtfExternalGraphicCompressionRate (int percent);
+
+ /**
+ * Gets the compression rate for the external graphic in percent.
+ * @return Compression rate
+ */
+ public int getRtfExternalGraphicCompressionRate ();
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java
new file mode 100755
index 000000000..2e2687ead
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** Interface for RtfElements that can contain RtfPageBreaks
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfPageBreakContainer
+{
+ /** add a page break */
+ public void newPageBreak() throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java
new file mode 100644
index 000000000..9d8a39f4b
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** Interface for RtfElements that can contain RtfText elements
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfPageContainer
+{
+ /** close current text run if any and start a new one with specified attributes
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfPage newPage(RtfAttributes attrs) throws IOException;
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java
new file mode 100644
index 000000000..de2f96f75
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+public interface IRtfPageNumberCitationContainer
+{
+ public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException;
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java
new file mode 100644
index 000000000..486acf84d
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+public interface IRtfPageNumberContainer
+{
+ public RtfPageNumber newPageNumber() throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java
new file mode 100755
index 000000000..03ed97704
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** Interface for RtfElements that can contain RtfParagraphs
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfParagraphContainer
+{
+ /** close current paragraph if any and start a new one with default attributes */
+ public RtfParagraph newParagraph() throws IOException;
+
+ /** close current paragraph if any and start a new one with specified attributes */
+ public RtfParagraph newParagraph(RtfAttributes attr) throws IOException;
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java
new file mode 100644
index 000000000..abd460bf6
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+public interface IRtfParagraphKeepTogetherContainer {
+
+ /** close current paragraph if any and start a new one */
+ public RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException;
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java
new file mode 100755
index 000000000..d39047498
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java
@@ -0,0 +1,71 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+/** Interface for RtfElements that can contain RtfTables
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfTableContainer
+{
+ /** close current table if any and start a new one */
+ public RtfTable newTable(ITableColumnsInfo tc) throws IOException;
+
+ /** close current table if any and start a new one
+ * @param tc added by Boris Poudérous on july 2002 in order to process number-columns-spanned attribute
+ **/
+ public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException;
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java
new file mode 100755
index 000000000..83030e430
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java
@@ -0,0 +1,81 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+/** Interface for RtfElements that can contain RtfText elements
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public interface IRtfTextContainer
+{
+ /** close current text run if any and start a new one with specified attributes
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText(String str,RtfAttributes attr) throws IOException;
+
+ /** close current text run if any and start a new one with default attributes
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText(String str) throws IOException;
+
+ /** add a line break */
+ public void newLineBreak() throws IOException;
+
+ /** text containers usually provide default attributes for all texts that they contain.
+ * This returns a copy of the container's attributes
+ */
+ public RtfAttributes getTextContainerAttributes();
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ITableAttributes.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ITableAttributes.java
new file mode 100644
index 000000000..87d37f7e9
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ITableAttributes.java
@@ -0,0 +1,154 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+/** Constants for RTF table attribute names */
+public interface ITableAttributes {
+ /**
+ * Added by Boris POUDEROUS on 2002/06/27 in order to
+ * process column/row spanning :
+ */
+ public static final String COLUMN_SPAN = "number-columns-spanned";
+ public static final String ROW_SPAN = "number-rows-spanned";
+
+ // RTF 1.5 attributes (word 97)
+ // half the space between the cells of a table row in twips
+ String ATTR_RTF_15_TRGAPH = "trgaph";
+
+ // RTF 1.6 Row and table attributes
+ String ATTR_ROW_PADDING_TOP = "trpaddt";
+ String ATTR_ROW_PADDING_BOTTOM = "trpaddb";
+ String ATTR_ROW_PADDING_LEFT = "trpaddl";
+ String ATTR_ROW_PADDING_RIGHT = "trpaddr";
+
+ String ATTR_ROW_U_PADDING_TOP = "trpaddft";
+ String ATTR_ROW_U_PADDING_BOTTOM = "trpaddfb";
+ String ATTR_ROW_U_PADDING_LEFT = "trpaddfl";
+ String ATTR_ROW_U_PADDING_RIGHT = "trpaddfr";
+
+ // list of ALL ROW PADDING attributes, used to select them
+ // when writing attributes
+ String[] ATTRIB_ROW_PADDING = {
+ ATTR_ROW_PADDING_TOP, ATTR_ROW_U_PADDING_TOP,
+ ATTR_ROW_PADDING_BOTTOM, ATTR_ROW_U_PADDING_BOTTOM,
+ ATTR_ROW_PADDING_LEFT, ATTR_ROW_U_PADDING_LEFT,
+ ATTR_ROW_PADDING_RIGHT, ATTR_ROW_U_PADDING_RIGHT,
+ ATTR_RTF_15_TRGAPH
+ };
+
+ // Cell attributes
+ String ATTR_CELL_PADDING_TOP = "clpadt";
+ String ATTR_CELL_PADDING_BOTTOM = "clpadb";
+ String ATTR_CELL_PADDING_LEFT = "clpadl";
+ String ATTR_CELL_PADDING_RIGHT = "clpadr";
+
+ String ATTR_CELL_U_PADDING_TOP = "clpadft";
+ String ATTR_CELL_U_PADDING_BOTTOM = "clpadfb";
+ String ATTR_CELL_U_PADDING_LEFT = "clpadfl";
+ String ATTR_CELL_U_PADDING_RIGHT = "clpadfr";
+
+ // These lines added by Chris Scott, Westinghouse
+ // need to make a border style file
+
+ String CELL_BORDER_TOP = "clbrdrt";
+ String CELL_BORDER_BOTTOM = "clbrdrb";
+ String CELL_BORDER_LEFT = "clbrdrl";
+ String CELL_BORDER_RIGHT = "clbrdrr";
+ //Table row border attributes
+ String ROW_BORDER_TOP = "trbrdrt";
+ String ROW_BORDER_BOTTOM = "trbrdrb";
+ String ROW_BORDER_LEFT = "trbrdrl";
+ String ROW_BORDER_RIGHT = "trbrdrr";
+ String ROW_BORDER_HORIZONTAL = "trbrdrh";
+ String ROW_BORDER_VERTICAL = "trbrdrv";
+
+ //Table row attributes
+ String ROW_KEEP_TOGETHER = "trkeep";
+
+ //This control word is nonexistent in RTF, used
+ //to simulate the FO:keep-with-next attribute.
+ String ROW_KEEP_WITH_NEXT = "knext";
+
+ //This control word is nonexistent in RTF, used
+ //to simulate the FO:keep-with-previous attribute.
+ String ROW_KEEP_WITH_PREVIOUS = "kprevious";
+
+ //shading and color, all are unit based attributes
+ String CELL_SHADE = "clshdng";
+ String CELL_COLOR_BACKGROUND = "clcbpat";
+ String CELL_COLOR_FOREGROUND = "clcfpat";
+
+ // list of ALL CELL PADDING attributes, used to select them
+ // when writing attributes
+ String[] ATTRIB_CELL_PADDING = {
+ ATTR_CELL_PADDING_TOP, ATTR_CELL_U_PADDING_TOP,
+ ATTR_CELL_PADDING_BOTTOM, ATTR_CELL_U_PADDING_BOTTOM,
+ ATTR_CELL_PADDING_LEFT, ATTR_CELL_U_PADDING_LEFT,
+ ATTR_CELL_PADDING_RIGHT, ATTR_CELL_U_PADDING_RIGHT,
+ };
+
+ String[] CELL_BORDER = {
+ CELL_BORDER_TOP, CELL_BORDER_BOTTOM,
+ CELL_BORDER_LEFT, CELL_BORDER_RIGHT
+ };
+
+ String[] ROW_BORDER = {
+ ROW_BORDER_TOP, ROW_BORDER_BOTTOM, ROW_BORDER_LEFT,
+ ROW_BORDER_RIGHT, ROW_BORDER_HORIZONTAL, ROW_BORDER_VERTICAL
+ };
+
+ String[] CELL_COLOR = {
+ CELL_SHADE, CELL_COLOR_BACKGROUND, CELL_COLOR_FOREGROUND
+ };
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java
new file mode 100644
index 000000000..a1879f142
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+
+
+public interface IrtfTemplateContainer {
+
+ /**
+ * Creates a new Template.
+ *
+ * @exception IOException on error
+ */
+ public RtfTemplate newTemplate (String str, RtfAttributes attr) throws IOException;
+
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
new file mode 100644
index 000000000..748c2eb56
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
@@ -0,0 +1,113 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+/**
+ *
+ * This context is used to manage the "keepn" RTF attribute
+ * Used by ParagraphBuilder and JforCmd
+ *
+ */
+
+public class ParagraphKeeptogetherContext {
+
+ private static int m_paraKeepTogetherOpen=0;
+ private static boolean m_paraResetProperties=false;
+ private static ParagraphKeeptogetherContext m_instance = null;
+
+ ParagraphKeeptogetherContext() {
+ }
+
+
+ /**
+ * Singelton.
+ *
+ * @return The instance of ParagraphKeeptogetherContext
+ */
+ public static ParagraphKeeptogetherContext getInstance() {
+ if (m_instance==null) m_instance = new ParagraphKeeptogetherContext();
+ return m_instance;
+ }
+
+ /** Return the level of current "keep whith next" paragraph */
+ public static int getKeepTogetherOpenValue() {
+ return m_paraKeepTogetherOpen;
+ }
+
+ /** Open a new "keep whith next" paragraph */
+ public static void KeepTogetherOpen() {
+ m_paraKeepTogetherOpen++;
+ }
+
+ /** Close a "keep whith next" paragraph */
+ public static void KeepTogetherClose() {
+ if(m_paraKeepTogetherOpen > 0) {
+ m_paraKeepTogetherOpen--;
+
+ //If the \pard control word is not present, the current paragraph inherits all paragraph properties.
+ //Also the next paragraph must reset the properties otherwise the \keepn don't stop.
+ m_paraResetProperties= (m_paraKeepTogetherOpen==0);
+ }
+ }
+
+ /** Determine if the next paragraph must reset the properites */
+ public static boolean paragraphResetProperties() {
+ return m_paraResetProperties;
+ }
+
+ /** Reset the flag if the paragraph properties have been resested */
+ public static void setParagraphResetPropertiesUsed() {
+ m_paraResetProperties=false;
+ }
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java
new file mode 100644
index 000000000..dd93dfeae
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java
@@ -0,0 +1,73 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** RtfContainer that encloses footers */
+public class RtfAfter extends RtfAfterBeforeBase {
+ /**RtfBefore attributes*/
+ public final static String FOOTER = "footer";
+ public final static String[] FOOTER_ATTR = new String[]{
+ FOOTER
+ };
+
+ RtfAfter(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
+ super(parent,w,attrs);
+ }
+
+ protected void writeMyAttributes() throws IOException {
+ writeAttributes(m_attrib,FOOTER_ATTR);
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
new file mode 100644
index 000000000..64cd01033
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java
@@ -0,0 +1,147 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+/** Common code for RtfAfter and RtfBefore
+* @author Andreas Lambert <andreas.lambert@cronidesoft.com>
+* @author Christopher Scott, scottc@westinghouse.com
+* @author Christoph Zahm <zahm@jnet.ch> (support for tables in headers/footers)
+*/
+
+abstract class RtfAfterBeforeBase
+extends RtfContainer
+implements IRtfParagraphContainer, IRtfExternalGraphicContainer,IRtfTableContainer {
+ protected RtfAttributes m_attrib;
+ private RtfParagraph m_para;
+ private RtfExternalGraphic m_externalGraphic;
+ private RtfTable m_table;
+
+ RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
+ super((RtfContainer)parent,w,attrs);
+ m_attrib = attrs;
+ }
+
+ public RtfParagraph newParagraph() throws IOException {
+ closeAll();
+ m_para = new RtfParagraph(this,m_writer);
+ return m_para;
+ }
+
+ public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
+ closeAll();
+ m_para = new RtfParagraph(this,m_writer,attrs);
+ return m_para;
+ }
+
+ public RtfExternalGraphic newImage() throws IOException {
+ closeAll();
+ m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ return m_externalGraphic;
+ }
+
+ private void closeCurrentParagraph() throws IOException {
+ if(m_para!=null) m_para.close();
+ }
+
+ private void closeCurrentExternalGraphic() throws IOException {
+ if(m_externalGraphic!=null) m_externalGraphic.close();
+ }
+
+ private void closeCurrentTable() throws IOException {
+ if(m_table != null) m_table.close();
+ }
+
+ protected void writeRtfPrefix() throws IOException {
+ writeGroupMark(true);
+ writeMyAttributes();
+ }
+
+ /** must be implemented to write the header or footer attributes */
+ abstract protected void writeMyAttributes() throws IOException;
+
+ protected void writeRtfSuffix() throws IOException {
+ writeGroupMark(false);
+ }
+
+ public RtfAttributes getAttributes(){
+ return m_attrib;
+ }
+
+ public void closeAll() throws IOException {
+ closeCurrentParagraph();
+ closeCurrentExternalGraphic();
+ closeCurrentTable();
+ }
+
+ /** close current table if any and start a new one
+ * @param tc added by Boris Poudérous on july 2002 in order to process number-columns-spanned attribute
+ */
+ public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException {
+ closeAll();
+ m_table = new RtfTable(this,m_writer,attrs,tc);
+ return m_table;
+ }
+
+ /** close current table if any and start a new one */
+ public RtfTable newTable(ITableColumnsInfo tc) throws IOException {
+ closeAll();
+ m_table = new RtfTable(this,m_writer,tc);
+ return m_table;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java
new file mode 100755
index 000000000..0858aa1f0
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java
@@ -0,0 +1,210 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.AttributesImpl;
+
+
+/** Attributes for RtfText
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfAttributes
+implements java.lang.Cloneable
+{
+ private HashMap m_values = new HashMap();
+
+ /** set attributes from a other attributes object.
+ * @return this object, for chaining calls
+ */
+ public RtfAttributes set (RtfAttributes attrs)
+ {
+ if (attrs != null)
+ {
+ Iterator it = attrs.nameIterator ();
+ while (it.hasNext ())
+ {
+ String name = (String) it.next ();
+ if (attrs.getValue(name) instanceof Integer){
+ Integer value = (Integer)attrs.getValue (name);
+ if (value == null)
+ set (name);
+ else
+ set (name, value.intValue ());
+ }
+ else if(attrs.getValue(name) instanceof String){
+ String value = (String)attrs.getValue (name);
+ if (value == null)
+ set (name);
+ else
+ set (name, value);
+ }else{
+ set (name);
+ }
+
+
+ }
+ // indicate the XSL attributes used to build the Rtf attributes
+ setXslAttributes( attrs.getXslAttributes() );
+ }
+ return this;
+ }
+
+ /** set an attribute that has no value.
+ * @return this object, for chaining calls
+ */
+ public RtfAttributes set(String name)
+ {
+ m_values.put(name,null);
+ return this;
+ }
+
+ /** unset an attribute that has no value
+ * @return this object, for chaining calls
+ */
+ public RtfAttributes unset(String name)
+ {
+ m_values.remove(name);
+ return this;
+ }
+
+ /** debugging log */
+ public String toString()
+ {
+ return m_values.toString() + "(" + super.toString() + ")";
+ }
+
+ /** implement cloning */
+ public Object clone()
+ {
+ final RtfAttributes result = new RtfAttributes();
+ result.m_values = (HashMap)m_values.clone();
+
+ // Added by Normand Masse
+ // indicate the XSL attributes used to build the Rtf attributes
+ if ( m_xsl_attributes != null ) {
+ result.m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl( m_xsl_attributes );
+ }
+
+ return result;
+ }
+
+ /** set an attribute that has an integer value
+ * @return this object, for chaining calls
+ */
+ public RtfAttributes set(String name,int value)
+ {
+ m_values.put(name,new Integer(value));
+ return this;
+ }
+
+ public RtfAttributes set(String name, String type)
+ {
+ m_values.put(name,type);
+ return this;
+ }
+
+ /** get the value of an attribute, null if not found */
+ public Object getValue(String name)
+ {
+ return m_values.get(name);
+ }
+
+ /** true if given attribute is set */
+ public boolean isSet(String name)
+ {
+ return m_values.containsKey(name);
+ }
+
+ /** return an Iterator on all names that are set */
+ public Iterator nameIterator()
+ {
+ return m_values.keySet().iterator();
+ }
+
+ private Attributes m_xsl_attributes = null;
+
+ // Added by Normand Masse
+ // Used for attribute inheritance
+ public Attributes getXslAttributes() {
+ return m_xsl_attributes;
+ }
+
+ // Added by Normand Masse
+ // Used for attribute inheritance
+ public void setXslAttributes( Attributes pAttribs ) {
+ if ( pAttribs == null ) {
+ return;
+ }
+ // copy/replace the xsl attributes into the current attributes
+ if ( m_xsl_attributes != null ) {
+ for ( int i = 0; i < pAttribs.getLength(); i++ ) {
+ String wKey = pAttribs.getQName( i );
+ int wPos = m_xsl_attributes.getIndex( wKey );
+ if ( wPos == -1 ) {
+ ((AttributesImpl)m_xsl_attributes).addAttribute( pAttribs.getURI( i ),
+ pAttribs.getLocalName(i), pAttribs.getQName(i),
+ pAttribs.getType(i), pAttribs.getValue(i));
+ } else {
+ ((AttributesImpl)m_xsl_attributes).setAttribute( wPos, pAttribs.getURI( i ),
+ pAttribs.getLocalName(i), pAttribs.getQName(i),
+ pAttribs.getType(i), pAttribs.getValue(i));
+ }
+ }
+ } else {
+ m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl( pAttribs );
+ }
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java
new file mode 100644
index 000000000..1d310e071
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** The opposite of RtfAfter */
+public class RtfBefore extends RtfAfterBeforeBase {
+ /**RtfBefore attributes*/
+ public final static String HEADER = "header";
+
+ public final static String[] HEADER_ATTR = new String[]{
+ HEADER
+ };
+
+ RtfBefore(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
+ super(parent,w,attrs);
+ }
+
+ protected void writeMyAttributes() throws IOException {
+ writeAttributes(m_attrib,HEADER_ATTR);
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java
new file mode 100755
index 000000000..9750fec5f
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java
@@ -0,0 +1,194 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * RTF Bookmark.
+ * Create an RTF bookmark as a child of given container with default attributes.
+ * This class belongs to the "id" attribute processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+public class RtfBookmark extends RtfElement
+{
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+ /** Name of the bokkmark */
+ private String bookmark = null;
+ /** Word 2000 supports a length of 40 characters only */
+ public static int maxBookmarkLength = 40;
+ /** Word 2000 converts '.' in bookmarks to "_", thats why we control this replacement. */
+ public static char replaceCharacter = '_';
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Constructor.
+ *
+ * @param parent a <code>RtfBookmarkContainer</code> value
+ * @param writer a <code>Writer</code> value
+ * @param bookmark Name of the bookmark
+ */
+ RtfBookmark (IRtfBookmarkContainer parent, Writer w, String bookmark) throws IOException
+ {
+ super ((RtfContainer) parent, w);
+
+ int now = bookmark.length ();
+
+ this.bookmark = bookmark.substring (0, now < maxBookmarkLength ? now : maxBookmarkLength);
+ this.bookmark = this.bookmark.replace ('.',replaceCharacter);
+ this.bookmark = this.bookmark.replace (' ',replaceCharacter);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ RtfElement implementation
+ //////////////////////////////////////////////////
+
+ /**
+ * Is called before writing the Rtf content.
+ *
+ * @throws IOException On Error
+ */
+ public void writeRtfPrefix () throws IOException
+ {
+ startBookmark ();
+ }
+
+ /**
+ * Writes the RTF content to m_writer.
+ *
+ * @exception IOException On error
+ */
+ public void writeRtfContent () throws IOException
+ {
+ this.getRtfFile ().getLog ().logInfo ("Write bookmark '" + bookmark + "'.");
+ // No content to write
+ }
+
+ /**
+ * Is called after writing the Rtf content.
+ *
+ * @throws IOException On Error
+ */
+ public void writeRtfSuffix () throws IOException
+ {
+ endBookmark ();
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Private methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Writes RTF content to begin the bookmark.
+ *
+ * @throws IOException On error
+ */
+ private void startBookmark () throws IOException
+ {
+
+ // {\*\bkmkstart test}
+ writeRtfBookmark ("bkmkstart");
+ }
+
+ /**
+ * Writes RTF content to close the bookmark.
+ *
+ * @throws IOException On error
+ */
+ private void endBookmark () throws IOException
+ {
+
+ // {\*\bkmkend test}
+ writeRtfBookmark ("bkmkend");
+ }
+
+ /**
+ * Writes the rtf bookmark.
+ *
+ * @param tag Begin or close tag
+ *
+ * @throws IOException On error
+ */
+ private void writeRtfBookmark (String tag) throws IOException
+ {
+ if (bookmark == null)
+ {
+ return;
+
+ }
+
+ this.writeGroupMark (true);
+
+ //changed. Now using writeStarControlWord
+ this.writeStarControlWord (tag);
+
+ m_writer.write (bookmark);
+ this.writeGroupMark (false);
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return bookmark==null || bookmark.trim().length() == 0;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java
new file mode 100755
index 000000000..e14a81bac
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java
@@ -0,0 +1,132 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * RTF Bookmark container implementation.
+ * Nearly all containers or elements can have a bookmark, that is why the bookmark container is
+ * implemented as stand alone.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+public class RtfBookmarkContainerImpl extends RtfContainer implements IRtfBookmarkContainer
+{
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+ /** Rtf bookmark */
+ RtfBookmark mBookmark = null;
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Constructor.
+ * Create an RTF container as a child of given container.
+ *
+ * @param parent The parent container
+ * @param w Writer
+ *
+ * @exception IOException On error
+ */
+ RtfBookmarkContainerImpl (RtfContainer parent, Writer w) throws IOException
+ {
+ super (parent, w, null);
+ }
+
+ /**
+ * Constructor.
+ * Create an RTF container as a child of given container.
+ *
+ * @param parent The parent container
+ * @param w Writer
+ * @param attr Rtf attributes
+ *
+ * @exception IOException On error
+ */
+ RtfBookmarkContainerImpl (RtfContainer parent, Writer w, RtfAttributes attr) throws IOException
+ {
+ super (parent, w, attr);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Public methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Create a new RTF bookmark.
+ *
+ * @param bookmark Name of the bookmark
+ *
+ * @return RTF bookmark
+ *
+ * @throws IOException On eror
+ */
+ public RtfBookmark newBookmark (String bookmark) throws IOException
+ {
+ if (mBookmark != null)
+ {
+ mBookmark.close ();
+ }
+
+ mBookmark = new RtfBookmark (this, m_writer, bookmark);
+
+ return mBookmark;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java
new file mode 100755
index 000000000..cbfc61187
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java
@@ -0,0 +1,285 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.awt.Color;
+import java.io.IOException;
+
+/**
+ * Singelton of the RTF color table.
+ * This class was created for <fo:basic-link> tag processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+
+public class RtfColorTable
+{
+ //////////////////////////////////////////////////
+ // @@ Symbolic constants
+ //////////////////////////////////////////////////
+
+ // Defines the bit moving for the colors
+ private static int RED = 16;
+ private static int GREEN = 8;
+ private static int BLUE = 0;
+
+
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+ /** Singelton instance */
+ private static RtfColorTable instance = null;
+
+ /** Index table for the colors */
+ private Hashtable colorIndex = null;
+ /** Used colors to this vector */
+ private Vector colorTable = null;
+ /** Map of color names to color numbers */
+ private Hashtable namedColors = null;
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Constructor.
+ */
+ private RtfColorTable ()
+ {
+ colorTable = new Vector ();
+ colorIndex = new Hashtable ();
+ namedColors = new Hashtable ();
+
+ init ();
+ }
+
+ /**
+ * Singelton.
+ *
+ * @return The instance of RTFColorTable
+ */
+ public static RtfColorTable getInstance ()
+ {
+ if (instance == null)
+ {
+ instance = new RtfColorTable ();
+ }
+
+ return instance;
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Initializing
+ //////////////////////////////////////////////////
+
+ /**
+ * Initialize the color table.
+ */
+ private void init ()
+ {
+ addNamedColor("black",getColorNumber (0, 0, 0));
+ addNamedColor("white",getColorNumber (255, 255, 255));
+ addNamedColor("red",getColorNumber (255, 0, 0));
+ addNamedColor("green",getColorNumber (0, 255, 0));
+ addNamedColor("blue",getColorNumber (0, 0, 255));
+ addNamedColor("cyan",getColorNumber (0, 255, 255));
+ addNamedColor("magenta",getColorNumber (255, 0, 255));
+ addNamedColor("yellow",getColorNumber (255, 255, 0));
+
+ getColorNumber (0, 0, 128);
+ getColorNumber (0, 128, 128);
+ getColorNumber (0, 128, 0);
+ getColorNumber (128, 0, 128);
+ getColorNumber (128, 0, 0);
+ getColorNumber (128, 128, 0);
+ getColorNumber (128, 128, 128);
+
+ // Added by Normand Masse
+ // Gray color added
+ addNamedColor( "gray", getColorNumber( 128, 128, 128 ) );
+
+ getColorNumber (192, 192, 192);
+ }
+
+ /** define a named color for getColorNumber(String) */
+ private void addNamedColor(String name,int colorNumber)
+ {
+ namedColors.put(name.toLowerCase(),new Integer(colorNumber));
+ }
+
+ //////////////////////////////////////////////////
+ // @@ Public methods
+ //////////////////////////////////////////////////
+
+ /** get the RTF number of a named color
+ * @return null if name not found
+ */
+ public Integer getColorNumber (String name)
+ {
+ return (Integer)namedColors.get(name.toLowerCase());
+ }
+
+ /**
+ * Gets the number of color in the color table
+ *
+ * @param red Color level red
+ * @param green Color level green
+ * @param blue Color level blue
+ *
+ * @return The number of the color in the table
+ */
+ public int getColorNumber (int red, int green, int blue)
+ {
+ Integer identifier = new Integer (determineIdentifier (red, green, blue));
+ Object o = colorIndex.get (identifier);
+ int retVal;
+
+ if (o == null)
+ {
+ addColor (identifier);
+
+ retVal = colorTable.size ();
+ }
+ else
+ {
+ retVal = ((Integer) o).intValue ();
+ }
+
+ return retVal + 1;
+ }
+
+ /**
+ * Writes the color table in the header.
+ *
+ * @param header The header container to write in
+ *
+ * @throws IOException On error
+ */
+ public void writeColors (RtfHeader header) throws IOException
+ {
+ if (colorTable == null || colorTable.size () == 0)
+ {
+ return;
+ }
+
+ header.writeGroupMark (true);
+ header.writeControlWord ("colortbl;");
+
+ int len = colorTable.size ();
+
+ for (int i = 0; i < len; i++)
+ {
+ int identifier = ((Integer) colorTable.get (i)).intValue ();
+
+ header.write ("\\red" + determineColorLevel (identifier, RED));
+ header.write ("\\green" + determineColorLevel (identifier, GREEN));
+ header.write ("\\blue" + determineColorLevel (identifier, BLUE) + ";");
+ }
+
+ header.writeGroupMark (false);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Private methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Adds a color to the table.
+ *
+ * @param i Identifier of color
+ */
+ private void addColor (Integer i)
+ {
+ colorIndex.put (i, new Integer (colorTable.size () + 1));
+ colorTable.addElement (i);
+ }
+
+ /**
+ * Determines a identifier for the color.
+ *
+ * @param red Color level red
+ * @param green Color level green
+ * @param blue Color level blue
+ *
+ * @return Unique identifier of color
+ */
+ private int determineIdentifier (int red, int green, int blue)
+ {
+ int c = red << RED;
+
+ c += green << GREEN;
+ c += blue << BLUE;
+
+ return c;
+ }
+
+ /**
+ * Determines the color level from the identifier.
+ *
+ * @param identifier Unique color identifier
+ * @param color One of the bit moving constants
+ *
+ * @return Color level in byte size
+ */
+ private int determineColorLevel (int identifier, int color)
+ {
+ int retVal = (byte) (identifier >> color);
+
+ return retVal < 0 ? retVal + 256 : retVal;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java
new file mode 100755
index 000000000..2b4db5870
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java
@@ -0,0 +1,210 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.util.*;
+import java.io.IOException;
+import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException;
+
+/** An RtfElement that can contain other elements.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfContainer extends RtfElement {
+ private LinkedList m_children; // 'final' removed by Boris Poudérous on 07/22/2002
+ private RtfOptions m_options = new RtfOptions();
+ private RtfElement m_lastChild;
+
+ /** Create an RTF container as a child of given container */
+ RtfContainer(RtfContainer parent, Writer w) throws IOException {
+ this(parent,w,null);
+ }
+
+ /** Create an RTF container as a child of given container with given attributes */
+ RtfContainer(RtfContainer parent, Writer w,RtfAttributes attr) throws IOException {
+ super(parent,w,attr);
+ m_children = new LinkedList();
+ }
+
+ /** set options */
+ public void setOptions(RtfOptions opt) {
+ m_options = opt;
+ }
+
+ /** add a child element to this */
+ protected void addChild(RtfElement e)
+ throws RtfStructureException {
+ if(isClosed()) {
+ // No childs should be added to a container that has been closed
+ final StringBuffer sb = new StringBuffer();
+ sb.append("addChild: container already closed (parent=");
+ sb.append(this.getClass().getName());
+ sb.append(" child=");
+ sb.append(e.getClass().getName());
+ sb.append(")");
+ final String msg = sb.toString();
+
+ // warn of this problem
+ final RtfFile rf = getRtfFile();
+ if(rf.getLog() != null) {
+ rf.getLog().logWarning(msg);
+ }
+
+ // TODO this should be activated to help detect XSL-FO constructs
+ // that we do not handle properly.
+ /*
+ throw new RtfStructureException(msg);
+ */
+ }
+
+ m_children.add(e);
+ m_lastChild = e;
+ }
+
+ /** return a copy of our children's list */
+ public List getChildren() {
+ return (List)m_children.clone();
+ }
+
+ /** return the number of children */
+ public int getChildCount() {
+ return m_children.size();
+ }
+
+ /**
+ * Add by Boris Poudérous on 07/22/2002
+ * Set the children list
+ */
+ public boolean setChildren (List children)
+ {
+ if (children instanceof LinkedList)
+ {
+ this.m_children = (LinkedList)children;
+ return true;
+ }
+
+ return false;
+ }
+
+ /** write RTF code of all our children */
+ protected void writeRtfContent()
+ throws IOException {
+ for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ e.writeRtf();
+ }
+ }
+
+ /** return our options */
+ RtfOptions getOptions() {
+ return m_options;
+ }
+
+ /** true if this (recursively) contains at least one RtfText object */
+ boolean containsText() {
+ boolean result = false;
+ for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(e instanceof RtfText) {
+ result = !e.isEmpty();
+ } else if(e instanceof RtfContainer) {
+ if(((RtfContainer)e).containsText()) {
+ result = true;
+ }
+ }
+ if(result) break;
+ }
+ return result;
+ }
+
+ /** debugging to given Writer */
+ void dump(Writer w,int indent)
+ throws IOException {
+ super.dump(w,indent);
+ for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ e.dump(w,indent + 1);
+ }
+ }
+
+ /** minimal debugging display */
+ public String toString() {
+ return super.toString() + " (" + getChildCount() + " children)";
+ }
+
+ /** don't write any RTF if empty of if our options block it */
+ protected boolean okToWriteRtf() {
+ boolean result = super.okToWriteRtf() && !isEmpty();
+ if(result && !m_options.renderContainer(this)) {
+ result = false;
+ }
+ return result;
+ }
+
+ /** true if this element would generate no "useful" RTF content.
+ * For an RtfContainer, true if it has no children where isEmpty() is false
+ */
+ public boolean isEmpty()
+ {
+ boolean result = true;
+ for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(!e.isEmpty()) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfDocumentArea.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfDocumentArea.java
new file mode 100755
index 000000000..76d72ad3b
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfDocumentArea.java
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** The RTF document area, container for RtfSection objects.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfDocumentArea
+extends RtfContainer
+{
+ private RtfSection m_currentSection;
+
+ /** Create an RTF element as a child of given container */
+ RtfDocumentArea(RtfFile f,Writer w) throws IOException
+ {
+ super(f,w);
+ }
+
+ /** close current RtfSection if any and create a new one */
+ public RtfSection newSection() throws IOException
+ {
+ if(m_currentSection != null) m_currentSection.close();
+ m_currentSection = new RtfSection(this,m_writer);
+ return m_currentSection;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java
new file mode 100755
index 000000000..2ad0378b8
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfElement.java
@@ -0,0 +1,289 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.*;
+import java.util.*;
+import org.jfor.jfor.main.JForVersionInfo;
+import org.xml.sax.Attributes;
+
+/** Base class for all elements of an RTF file.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+public abstract class RtfElement {
+ protected final Writer m_writer;
+ protected final RtfContainer m_parent;
+ protected final RtfAttributes m_attrib;
+ private boolean m_written;
+ private boolean m_closed;
+ private final int m_id;
+ private static int m_idCounter;
+
+ /** Create an RTF element as a child of given container */
+ RtfElement(RtfContainer parent,Writer w) throws IOException {
+ this(parent,w,null);
+ }
+
+
+ /** Create an RTF element as a child of given container with given attributes */
+ RtfElement(RtfContainer parent,Writer w,RtfAttributes attr) throws IOException {
+
+ m_id = m_idCounter++;
+ m_parent = parent;
+ m_attrib = (attr != null ? attr : new RtfAttributes());
+ if(m_parent != null) m_parent.addChild(this);
+ m_writer = w;
+ m_written = false;
+ }
+
+ /** Does nothing, meant to allow elements to write themselves without waiting
+ * for write(), but not implemented yet */
+ public final void close() throws IOException {
+ m_closed = true;
+ }
+
+ /** write the RTF code of this element to our Writer */
+ public final void writeRtf() throws IOException {
+ if(!m_written) {
+ m_written = true;
+ if(okToWriteRtf()) {
+ writeRtfPrefix();
+ writeRtfContent();
+ writeRtfSuffix();
+ }
+ }
+ }
+
+ /** write an RTF control word to our Writer */
+ protected final void writeControlWord(String word)
+ throws IOException {
+ m_writer.write('\\');
+ m_writer.write(word);
+ m_writer.write(' ');
+ }
+
+ /** write an RTF control word to our Writer, preceeded by a star '*'
+ * meaning "ignore this if you don't know what it means"
+ */
+ protected final void writeStarControlWord(String word)
+ throws IOException {
+ m_writer.write("\\*\\");
+ m_writer.write(word);
+ m_writer.write(' ');
+ }
+
+ protected final void writeStarControlWordNS(String word)
+ throws IOException {
+ m_writer.write("\\*\\");
+ m_writer.write(word);
+ }
+
+ /** write rtf control word without the space behind it */
+ protected final void writeControlWordNS(String word)
+ throws IOException {
+ m_writer.write('\\');
+ m_writer.write(word);
+ }
+
+ /** called before writeRtfContent() */
+ protected void writeRtfPrefix() throws IOException {
+ }
+
+ /** must be implemented to write RTF content to m_writer */
+ protected abstract void writeRtfContent() throws IOException;
+
+ /** called after writeRtfContent() */
+ protected void writeRtfSuffix() throws IOException {
+ }
+
+ /** Write a start or end group mark */
+ protected final void writeGroupMark(boolean isStart)
+ throws IOException {
+ m_writer.write(isStart ? "{" : "}");
+ }
+
+ /** write given attribute values to our Writer
+ * @param nameList if given, only attribute names from this list are considered
+ */
+ protected void writeAttributes(RtfAttributes attr,String [] nameList)
+ throws IOException {
+ if(attr==null) return;
+
+ if(nameList != null) {
+ // process only given attribute names
+ for(int i=0; i < nameList.length; i++) {
+ final String name = nameList[i];
+ if(attr.isSet(name)) {
+ writeOneAttribute(name,attr.getValue(name));
+ }
+ }
+ } else {
+ // process all defined attributes
+ for(Iterator it = attr.nameIterator(); it.hasNext(); ) {
+ final String name = (String)it.next();
+ if(attr.isSet(name)) {
+ writeOneAttribute(name,attr.getValue(name));
+ }
+ }
+ }
+ }
+
+ /** write one attribute to our Writer */
+ protected void writeOneAttribute(String name,Object value)
+ throws IOException {
+ String cw = name;
+ if(value instanceof Integer) {
+ // attribute has integer value, must write control word + value
+ cw += value;
+ }else if(value instanceof String){
+ cw += value;
+ }
+ writeControlWord(cw);
+ }
+ /** write one attribute to our Writer without a space*/
+ protected void writeOneAttributeNS(String name,Object value)
+ throws IOException {
+ String cw = name;
+ if(value instanceof Integer) {
+ // attribute has integer value, must write control word + value
+ cw += value;
+ }else if(value instanceof String){
+ cw += value;
+ }
+ writeControlWordNS(cw);
+ }
+
+ /** can be overridden to suppress all RTF output */
+ protected boolean okToWriteRtf() {
+ return true;
+ }
+
+ /** debugging to given PrintWriter */
+ void dump(Writer w,int indent)
+ throws IOException {
+ for(int i=0; i < indent; i++) {
+ w.write(' ');
+ }
+ w.write(this.toString());
+ w.write('\n');
+ w.flush();
+ }
+
+ /** minimal debugging display */
+ public String toString() {
+ return (this == null) ? "null" : (this.getClass().getName() + " #" + m_id);
+ }
+
+ /** true if close() has been called */
+ boolean isClosed() {
+ return m_closed;
+ }
+
+ /** access our RtfFile, which is always the topmost parent */
+ RtfFile getRtfFile() {
+ // go up the chain of parents until we find the topmost one
+ RtfElement result = this;
+ while(result.m_parent != null) {
+ result = result.m_parent;
+ }
+
+ // topmost parent must be an RtfFile
+ // a ClassCastException here would mean that the parent-child structure is not as expected
+ return (RtfFile)result;
+ }
+
+ /** find the first parent where c.isAssignableFrom(parent.getClass()) is true
+ * @return null if not found
+ */
+ RtfElement getParentOfClass(Class c)
+ {
+ RtfElement result = null;
+ RtfElement current = this;
+ while(current.m_parent != null) {
+ current = current.m_parent;
+ if(c.isAssignableFrom(current.getClass())) {
+ result = current;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public abstract boolean isEmpty();
+
+
+ protected void writeExceptionInRtf(Exception ie)
+ throws IOException {
+ writeGroupMark(true);
+ writeControlWord("par");
+
+ // make the exception message stand out so that the problem is visible
+ writeControlWord("fs48");
+ RtfStringConverter.getInstance().writeRtfString(m_writer,JForVersionInfo.getShortVersionInfo() + ": ");
+ RtfStringConverter.getInstance().writeRtfString(m_writer,ie.getClass().getName());
+
+ writeControlWord("fs20");
+ RtfStringConverter.getInstance().writeRtfString(m_writer," " + ie.toString());
+
+ writeControlWord("par");
+ writeGroupMark(false);
+ }
+
+ // Added by Normand Masse
+ // Used for attribute inheritance
+ public RtfAttributes getRtfAttributes() {
+ return m_attrib;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
new file mode 100755
index 000000000..ba11ba0aa
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
@@ -0,0 +1,633 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfElement;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfContainer;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
+
+import org.jfor.jfor.tools.ImageConstants;
+import org.jfor.jfor.tools.ImageUtil;
+import org.jfor.jfor.tools.jpeg.Encoder;
+import org.jfor.jfor.tools.jpeg.JPEGException;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.InputStreamReader;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Writer;
+
+import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.Hashtable;
+
+/**
+ * Creates an RTF image from an external graphic file.
+ * This class belongs to the <fo:external-graphic> tag processing. <br>
+ *
+ * Supports relative path like "../test.gif", too (01-08-24) <br>
+ *
+ * Limitations:
+ * <li> Only the image types PNG, JPEG and EMF are supported
+ * <li> The GIF is supported, too, but will be converted to JPG
+ * <li> Only the attributes SRC (required), WIDTH, HEIGHT, SCALING are supported
+ * <li> The SCALING attribute supports (uniform | non-uniform)
+ *
+ * Known Bugs:
+ * <li> If the emf image has a desired size, the image will be clipped
+ * <li> The emf, jpg & png image will not be displayed in correct size
+ *
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ * @author Gianugo Rabellino gianugo@rabellino.it
+ */
+
+public class RtfExternalGraphic extends RtfElement
+{
+ /** Exception thrown when an image file/URL cannot be read */
+ public static class ExternalGraphicException extends IOException
+ {
+ ExternalGraphicException(String reason)
+ {
+ super(reason);
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+
+ /**
+ * The url of the image
+ */
+ protected URL url = null;
+
+ /**
+ * The height of the image
+ */
+ protected int height = -1;
+
+ /**
+ * The desired percent value of the height
+ */
+ protected int heightPercent = -1;
+
+ /**
+ * The desired height
+ */
+ protected int heightDesired = -1;
+
+ /**
+ * Flag whether the desired height is a percentage
+ */
+ protected boolean perCentH = false;
+
+ /**
+ * The width of the image
+ */
+ protected int width = -1;
+
+ /**
+ * The desired percent value of the width
+ */
+ protected int widthPercent = -1;
+
+ /**
+ * The desired width
+ */
+ protected int widthDesired = -1;
+
+ /**
+ * Flag whether the desired width is a percentage
+ */
+ protected boolean perCentW = false;
+
+ /**
+ * Flag whether the image size shall be adjusted
+ */
+ protected boolean scaleUniform = false;
+
+ /**
+ * Graphic compression rate
+ */
+ protected int graphicCompressionRate = 80;
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+
+ /**
+ * Default constructor.
+ * Create an RTF element as a child of given container.
+ *
+ * @param container a <code>RtfContainer</code> value
+ * @param writer a <code>Writer</code> value
+ */
+ public RtfExternalGraphic(RtfContainer container, Writer writer) throws IOException {
+ super (container, writer);
+ }
+
+ /**
+ * Default constructor.
+ *
+ * @param container a <code>RtfContainer</code> value
+ * @param writer a <code>Writer</code> value
+ * @param attributes a <code>RtfAttributes</code> value
+ */
+ public RtfExternalGraphic(RtfContainer container, Writer writer,
+ RtfAttributes attributes) throws IOException {
+ super (container, writer, attributes);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ RtfElement implementation
+ //////////////////////////////////////////////////
+
+ /** RtfElement override - catches ExternalGraphicException and writes a warning
+ * message to the document if image cannot be read
+ */
+ protected void writeRtfContent() throws IOException {
+ try {
+ writeRtfContentWithException();
+ } catch(ExternalGraphicException ie) {
+ writeExceptionInRtf(ie);
+ }
+ }
+
+ /**
+ * Writes the RTF content to m_writer - this one throws ExternalGraphicExceptions
+ *
+ * @exception IOException On error
+ */
+ protected void writeRtfContentWithException() throws IOException {
+
+ if (m_writer == null) {
+ return;
+ }
+
+
+ if (url == null) {
+ throw new ExternalGraphicException("The attribute 'url' of <fo:external-graphic> is null.");
+ }
+
+ String linkToRoot = System.getProperty( "jfor_link_to_root" );
+ if (linkToRoot != null)
+ {
+ m_writer.write( "{\\field {\\* \\fldinst { INCLUDEPICTURE \"" );
+ m_writer.write( linkToRoot );
+ File urlFile = new File( url.getFile() );
+ m_writer.write( urlFile.getName() );
+ m_writer.write( "\" \\\\* MERGEFORMAT \\\\d }}}" );
+ return;
+ }
+
+ getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");
+
+
+ byte[] data = null;
+ try
+ {
+ // image reading patch provided by Michael Krause <michakurt@web.de>
+ final BufferedInputStream bin = new BufferedInputStream(url.openStream());
+ final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ while (true) {
+ final int datum = bin.read();
+ if (datum == -1) break;
+ bout.write(datum);
+ }
+ bout.flush();
+ data = bout.toByteArray();
+ }
+ catch (Exception e) {
+ throw new ExternalGraphicException("The attribute 'src' of <fo:external-graphic> has a invalid value: '" + url + "' (" + e + ")");
+ }
+
+ if (data == null) {
+ return;
+ }
+
+ // Determine image file format
+ String file = url.getFile ();
+ int type = determineImageType(data, file.substring(file.lastIndexOf(".") + 1));
+
+ if (type >= ImageConstants.I_TO_CONVERT_BASIS) {
+ // convert
+ int to = ImageConstants.CONVERT_TO [type - ImageConstants.I_TO_CONVERT_BASIS];
+
+ if (to == ImageConstants.I_JPG) {
+ ByteArrayOutputStream out = null;
+ try {
+ //convert to jpeg
+ out = new ByteArrayOutputStream();
+ Encoder jpgEncoder = new Encoder(graphicCompressionRate, out);
+ jpgEncoder.encodeJPEG(data);
+ data = out.toByteArray();
+ type = to;
+ }
+ catch (JPEGException e) {
+ e.setMessage("Image from tag <fo:external-graphic> could not be created (src = '" + url + "'");
+ }
+ finally {
+ out.close();
+ }
+ }
+ else {
+ type = ImageConstants.I_NOT_SUPPORTED;
+ }
+ }
+
+
+ if (type == ImageConstants.I_NOT_SUPPORTED) {
+ throw new ExternalGraphicException("The tag <fo:external-graphic> does not support " + file.substring(file.lastIndexOf(".") + 1) + " - image type.");
+ }
+
+ String rtfImageCode = ImageConstants.RTF_TAGS [type];
+
+ // Writes the beginning of the rtf image
+
+ writeGroupMark(true);
+ writeStarControlWord("shppict");
+ writeGroupMark(true);
+ writeControlWord("pict");
+
+ StringBuffer buf = new StringBuffer(data.length * 3);
+
+ writeControlWord(rtfImageCode);
+
+ if (type == ImageConstants.I_PNG) {
+ width = ImageUtil.getIntFromByteArray(data, 16, 4, true);
+ height = ImageUtil.getIntFromByteArray(data, 20, 4, true);
+ }
+ else if (type == ImageConstants.I_JPG) {
+ int basis = -1;
+ byte ff = (byte) 0xff;
+ byte c0 = (byte) 0xc0;
+ for (int i = 0; i < data.length; i++) {
+ byte b = data[i];
+ if (b != ff)
+ continue;
+ if (i == data.length - 1)
+ continue;
+ b = data[i + 1];
+ if (b != c0)
+ continue;
+ basis = i + 5;
+ break;
+ }
+
+ if (basis != -1) {
+ width = ImageUtil.getIntFromByteArray(data, basis + 2, 2, true);
+ height = ImageUtil.getIntFromByteArray(data, basis, 2, true);
+ }
+ }
+ else if (type == ImageConstants.I_EMF) {
+ width = ImageUtil.getIntFromByteArray(data, 151, 4, false);
+ height = ImageUtil.getIntFromByteArray(data, 155, 4, false);
+ }
+
+ // Set image size
+ if (width != -1) {
+ writeControlWord("picw" + width);
+ }
+ if (height != -1) {
+ writeControlWord("pich" + height);
+ }
+
+ if (widthDesired != -1) {
+ if (perCentW) {
+ writeControlWord("picscalex" + widthDesired);
+ }
+ else {
+ writeControlWord("picscalex" + widthDesired * 100 / width);
+ }
+
+ writeControlWord("picwgoal" + widthDesired);
+ }
+ else if (scaleUniform && heightDesired != -1) {
+ if (perCentH) {
+ writeControlWord("picscalex" + heightDesired);
+ }
+ else {
+ writeControlWord("picscalex" + heightDesired * 100 / height);
+ }
+ }
+
+ if (heightDesired != -1) {
+ if (perCentH) {
+ writeControlWord("picscaley" + heightDesired);
+ }
+ else {
+ writeControlWord("picscaley" + heightDesired * 100 / height);
+ }
+
+ writeControlWord("pichgoal" + heightDesired);
+ }
+ else if (scaleUniform && widthDesired != -1) {
+ if (perCentW) {
+ writeControlWord("picscaley" + widthDesired);
+ }
+ else {
+ writeControlWord("picscaley" + widthDesired * 100 / width);
+ }
+ }
+
+ for (int i = 0; i < data.length; i++) {
+ int iData = data [i];
+
+ // Make positive byte
+ if (iData < 0)
+ iData += 256;
+
+ if (iData < 16) {
+ // Set leading zero and append
+ buf.append('0');
+ }
+
+ buf.append(Integer.toHexString(iData));
+ }
+
+ int len = buf.length();
+ char[] chars = new char[len];
+
+ buf.getChars(0, len, chars, 0);
+ m_writer.write(chars);
+
+ // Writes the end of RTF image
+
+ writeGroupMark(false);
+ writeGroupMark(false);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Member access
+ //////////////////////////////////////////////////
+
+ /**
+ * Sets the desired height of the image.
+ *
+ * @param theHeight The desired image height
+ */
+ public void setHeight(String theHeight) {
+ this.heightDesired = ImageUtil.getInt(theHeight);
+ this.perCentH = ImageUtil.isPercent(theHeight);
+ }
+
+ /**
+ * Sets the desired width of the image.
+ *
+ * @param theWidth The desired image width
+ */
+ public void setWidth(String theWidth) {
+ this.widthDesired = ImageUtil.getInt(theWidth);
+ this.perCentW = ImageUtil.isPercent(theWidth);
+ }
+
+ /**
+ * Sets the flag whether the image size shall be adjusted.
+ *
+ * @param value
+ * true image width or height shall be adjusted automatically\n
+ * false no adjustment
+ */
+ public void setScaling(String value) {
+ if (value.equalsIgnoreCase("uniform")) {
+ this.scaleUniform = true;
+ }
+ }
+
+ /**
+ * Sets the url of the image.
+ *
+ * @param urlString Image url like "file://..."
+ * @throws IOException On error
+ */
+ public void setURL(String urlString) throws IOException
+ {
+ URL tmpUrl = null;
+ try
+ {
+ tmpUrl = new URL (urlString);
+ }
+ catch (MalformedURLException e)
+ {
+ try
+ {
+ tmpUrl = new File (urlString).toURL ();
+ }
+ catch (MalformedURLException ee)
+ {
+ throw new ExternalGraphicException("The attribute 'src' of <fo:external-graphic> has a invalid value: '" + urlString + "' (" + ee + ")");
+ }
+ }
+ this.url = tmpUrl;
+ }
+
+ /**
+ * Gets the compression rate for the image in percent.
+ * @return Compression rate
+ */
+ public int getCompressionRate ()
+ {
+ return graphicCompressionRate;
+ }
+
+ /**
+ * Sets the compression rate for the image in percent.
+ *
+ * @param percent Compression rate
+ * @return
+ * true: The compression rate is valid (0..100)\n
+ * false: The compression rate is invalid
+ */
+ public boolean setCompressionRate (int percent)
+ {
+ if (percent < 1 || percent > 100)
+ return false;
+
+ graphicCompressionRate = percent;
+ return true;
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Helpers
+ //////////////////////////////////////////////////
+
+
+ /**
+ * Determines wheter the image is a jpeg.
+ *
+ * @param data Image
+ *
+ * @return
+ * true If JPEG type\n
+ * false Other type
+ */
+ private boolean isJPEG(byte[] data) {
+ // Indentifier "0xFFD8" on position 0
+ byte [] pattern = new byte [] {(byte) 0xFF, (byte) 0xD8};
+
+ return ImageUtil.compareHexValues(pattern, data, 0, true);
+ }
+
+ /**
+ * Determines wheter the image is a png.
+ *
+ * @param data Image
+ *
+ * @return
+ * true If PNG type\n
+ * false Other type
+ */
+ private boolean isPNG(byte[] data) {
+ // Indentifier "PNG" on position 1
+ byte [] pattern = new byte [] {(byte) 0x50, (byte) 0x4E, (byte) 0x47};
+
+ return ImageUtil.compareHexValues(pattern, data, 1, true);
+ }
+
+ /**
+ * Determines wheter the image is a emf.
+ *
+ * @param data Image
+ *
+ * @return
+ * true If EMF type\n
+ * false Other type
+ */
+ private boolean isEMF(byte[] data) {
+ // No offical Indentifier known
+ byte [] pattern = new byte [] {(byte) 0x01, (byte) 0x00, (byte) 0x00};
+
+ return ImageUtil.compareHexValues(pattern, data, 0, true);
+ }
+
+ /**
+ * Determines wheter the image is a gif.
+ *
+ * @param data Image
+ *
+ * @return
+ * true If GIF type\n
+ * false Other type
+ */
+ private boolean isGIF(byte[] data) {
+ // Indentifier "GIF8" on position 0
+ byte [] pattern = new byte [] {(byte) 0x47, (byte) 0x49, (byte) 0x46, (byte) 0x38};
+
+ return ImageUtil.compareHexValues(pattern, data, 0, true);
+ }
+
+ /**
+ * Determines wheter the image is a gif.
+ *
+ * @param data Image
+ *
+ * @return
+ * true If BMP type\n
+ * false Other type
+ */
+ private boolean isBMP(byte[] data) {
+ // Indentifier "BM" on position 0
+ byte [] pattern = new byte [] {(byte) 0x42, (byte) 0x4D};
+
+ return ImageUtil.compareHexValues(pattern, data, 0, true);
+ }
+
+ /**
+ * Determine image file format.
+ *
+ * @param data Image
+ * @param ext Image extension
+ *
+ * @return Image type by ImageConstants.java
+ */
+ private int determineImageType(byte [] data, String ext) {
+ int type = ImageConstants.I_NOT_SUPPORTED;
+
+ if (isPNG(data)) {
+ type = ImageConstants.I_PNG;
+ }
+ else if (isJPEG(data)) {
+ type = ImageConstants.I_JPG_C;
+ }
+ else if (isEMF(data)) {
+ type = ImageConstants.I_EMF;
+ }
+ else if (isGIF(data)) {
+ type = ImageConstants.I_GIF;
+ }
+ else {
+ Object tmp = ImageConstants.SUPPORTED_IMAGE_TYPES.get(ext.toLowerCase());
+ if (tmp != null) {
+ type = ((Integer) tmp).intValue();
+ }
+ }
+
+ return type;
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return url==null;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
new file mode 100755
index 000000000..a7bdbdb05
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
@@ -0,0 +1,308 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.*;
+import java.util.*;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+
+/** Used to add extra table rows after a row that contains a nested table:
+ * <li> created by RtfTableRow before generating RTF code
+ * <li> an RtfTableCell that contains a nested table can ask this to put
+ * some of its children in extra rows that after the current row
+ * <li> once RtfTableRow is done rendering its children, it renders this,
+ * causing extra rows to be generated, with content that can come
+ * from several RtfTableCells
+ *
+ * @see org.apache.fop.rtf.rtflib.testdoc.NestedTable
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfExtraRowSet extends RtfContainer {
+ // TODO what is idnum?
+ final int DEFAULT_IDNUM = 0;
+
+ /** Parent table context
+ * (added by Boris Poudérous on july 2002 in order to process nested tables)
+ */
+ private ITableColumnsInfo parentITableColumnsInfo = null;
+
+ /** While a top-level RtfTableRow is being rendered, we build a list of
+ * RtfTableCells that must be rendered in extra rows.
+ * This holds a cell with positioning information
+ */
+ private final List m_cells = new LinkedList();
+ private static class PositionedCell
+ implements Comparable {
+ final RtfTableCell cell;
+ final int xOffset;
+ final int rowIndex;
+
+ PositionedCell(RtfTableCell c,int index,int offset) {
+ cell = c;
+ xOffset = offset;
+ rowIndex = index;
+ }
+
+ /** debugging dump */
+ public String toString() {
+ return "PositionedCell: row " + rowIndex + ", offset " + xOffset;
+ }
+
+ /** cells need to be sorted by row index and then by x offset */
+ public int compareTo(Object o) {
+ int result = 0;
+ if(o==null) {
+ result = 1;
+ } else if( !(o instanceof PositionedCell)) {
+ result = 1;
+ } else {
+ final PositionedCell pc = (PositionedCell)o;
+ if(this.rowIndex < pc.rowIndex) {
+ result = -1;
+ } else if(this.rowIndex > pc.rowIndex) {
+ result = 1;
+ } else if(this.xOffset < pc.xOffset) {
+ result = -1;
+ } else if(this.xOffset > pc.xOffset) {
+ result = 1;
+ }
+ }
+
+ return result;
+ }
+
+ public boolean equals(Object o) {
+ return o!=null && this.compareTo(o) == 0;
+ }
+ }
+
+ /** our maximum row index */
+ private int m_maxRowIndex;
+
+ /** an RtfExtraRowSet has no parent, it is only used temporary during
+ * generation of RTF for an RtfTableRow
+ */
+ RtfExtraRowSet(Writer w)
+ throws IOException {
+ super(null,w);
+ }
+
+ /** Add all cells of given Table to this set for later rendering in extra rows
+ * @return index of extra row to use for elements that follow this table in the same cell
+ * @param rowIndex index of first extra row to create to hold cells of tbl
+ * @param xOffset horizontal position of left edge of first column of tbl
+ */
+ int addTable(RtfTable tbl,int rowIndex,int xOffset) {
+ // process all rows of the table
+ for(Iterator it = tbl.getChildren().iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(e instanceof RtfTableRow) {
+ addRow((RtfTableRow)e,rowIndex,xOffset);
+ rowIndex++;
+ m_maxRowIndex = Math.max(rowIndex,m_maxRowIndex);
+ }
+ }
+ return rowIndex;
+ }
+
+ /** add all cells of given row to this set */
+ private void addRow(RtfTableRow row,int rowIndex,int xOffset) {
+ for(Iterator it = row.getChildren().iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(e instanceof RtfTableCell) {
+ final RtfTableCell c = (RtfTableCell)e;
+ m_cells.add(new PositionedCell(c,rowIndex,xOffset));
+ xOffset += c.getCellWidth();
+ }
+ }
+ }
+
+ /** create an extra cell to hold content that comes after a nested table in a cell
+ * Modified by Boris Poudérous in order to permit the extra cell to have the attributes of its parent cell
+ */
+ RtfTableCell createExtraCell(int rowIndex,int xOffset,int cellWidth,RtfAttributes parentCellAttributes)
+ throws IOException {
+ final RtfTableCell c = new RtfTableCell(null,m_writer,cellWidth,parentCellAttributes,DEFAULT_IDNUM);
+ m_cells.add(new PositionedCell(c,rowIndex,xOffset));
+ return c;
+ }
+
+ /** render extra RtfTableRows containing all the extra RtfTableCells that we contain */
+ protected void writeRtfContent() throws IOException {
+ // sort cells by rowIndex and xOffset
+ Collections.sort(m_cells);
+
+ // process all extra cells by rendering them into extra rows
+ List rowCells = null;
+ int rowIndex = -1;
+ for(Iterator it = m_cells.iterator(); it.hasNext(); ) {
+ final PositionedCell pc = (PositionedCell)it.next();
+ if(pc.rowIndex != rowIndex) {
+ // starting a new row, render previous one
+ if(rowCells!=null) writeRow(rowCells);
+ rowIndex = pc.rowIndex;
+ rowCells = new LinkedList();
+ }
+ rowCells.add(pc);
+ }
+
+ // render last row
+ if(rowCells!=null) writeRow(rowCells);
+ }
+
+ /** write one RtfTableRow containing given PositionedCells */
+ private void writeRow(List cells)
+ throws IOException {
+ if(allCellsEmpty(cells)) return;
+
+ final RtfTableRow row = new RtfTableRow(null,m_writer,DEFAULT_IDNUM);
+ int cellIndex = 0;
+
+ // Get the context of the table that holds the nested table
+ ITableColumnsInfo parentITableColumnsInfo = getParentITableColumnsInfo();
+ parentITableColumnsInfo.selectFirstColumn();
+
+ // X offset of the current empty cell to add
+ float xOffset = 0;
+ float xOffsetOfLastPositionedCell = 0;
+
+ for(Iterator it = cells.iterator(); it.hasNext(); ) {
+ final PositionedCell pc = (PositionedCell)it.next();
+
+ // if first cell is not at offset 0, add placeholder cell
+ // TODO should be merged with the cell that is above it
+ if(cellIndex==0 && pc.xOffset > 0) {
+ /**
+ * Added by Boris Poudérous
+ */
+ // Add empty cells merged vertically with the cells above and with the same widths
+ // (BEFORE the cell that contains the nested table)
+ for (int i = 0; (xOffset < pc.xOffset) && (i < parentITableColumnsInfo.getNumberOfColumns()); i++) {
+ // Get the width of the cell above
+ xOffset += parentITableColumnsInfo.getColumnWidth();
+ // Create the empty cell merged vertically
+ row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(), pc.cell.m_attrib);
+ // Select next column in order to have its width
+ parentITableColumnsInfo.selectNextColumn();
+ }
+ }
+
+ row.addChild(pc.cell);
+ // Line added by Boris Poudérous
+ xOffsetOfLastPositionedCell = pc.xOffset + pc.cell.getCellWidth();
+ cellIndex++;
+ }
+
+ /**
+ * Added by Boris Poudérous
+ */
+ // Add empty cells merged vertically with the cells above AFTER the cell that contains the nested table
+ // The cells added have the same widths than the cells above.
+ if (parentITableColumnsInfo.getColumnIndex() < (parentITableColumnsInfo.getNumberOfColumns() - 1))
+ {
+ parentITableColumnsInfo.selectNextColumn();
+
+ while (parentITableColumnsInfo.getColumnIndex() < parentITableColumnsInfo.getNumberOfColumns())
+ {
+ // Create the empty cell merged vertically
+ // TODO : the new cells after the extra cell don't have its attributes as we did for the previous cells.
+ // => in fact the m_attrib below (last argument) is empty => should be the attributes of the above cells.
+ row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(), m_attrib);
+ // Select next column in order to have its width
+ parentITableColumnsInfo.selectNextColumn();
+ }
+ }
+
+ row.writeRtf();
+ }
+
+ /** true if all cells of given list are empty
+ * @param cells List of PositionedCell objects
+ */
+ private static boolean allCellsEmpty(List cells) {
+ boolean empty = true;
+ for(Iterator it = cells.iterator(); it.hasNext(); ) {
+ final PositionedCell pc = (PositionedCell)it.next();
+ if(pc.cell.containsText()) {
+ empty = false;
+ break;
+ }
+ }
+ return empty;
+ }
+
+ /** As this contains cells from several rows, we say that it's empty
+ * only if we have no cells.
+ * writeRow makes the decision about rendering specific rows
+ */
+ public boolean isEmpty() {
+ return false;
+ }
+
+ /**
+ * @return The table context of the parent table
+ * Added by Boris Poudérous on july 2002 in order to process nested tables
+ */
+ public ITableColumnsInfo getParentITableColumnsInfo()
+ {
+ return this.parentITableColumnsInfo;
+ }
+
+ public void setParentITableColumnsInfo (ITableColumnsInfo parentITableColumnsInfo)
+ {
+ this.parentITableColumnsInfo = parentITableColumnsInfo;
+ }
+ /** - end - */
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java
new file mode 100755
index 000000000..397db08b3
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java
@@ -0,0 +1,207 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException;
+import org.jfor.jfor.converter.ConverterLogChannel;
+import java.io.*;
+
+/** Models the top-level structure of an RTF file.
+ * @see RtfFileExample
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ * @author Christopher Scott scottc@westinghouse.com
+ */
+
+public class RtfFile
+extends RtfContainer {
+ private RtfHeader m_header;
+ private RtfPageArea m_pageArea;
+ private RtfListTable m_listTable;
+ private RtfDocumentArea m_docArea;
+ private ConverterLogChannel m_log;
+ private RtfContainer m_listTableContainer;
+ private int listNum=0;
+
+ /** Create an RTF file that outputs to the given Writer */
+ public RtfFile(Writer w) throws IOException {
+ super(null,w);
+ }
+
+ /** optional log channel */
+ public void setLogChannel(ConverterLogChannel log)
+ {
+ m_log = log;
+ }
+
+ /**
+ * Gets the log channel.
+ * If logchannel not set, it will return a empty log channel.
+ * @return our log channel, it is never null */
+ ConverterLogChannel getLog()
+ {
+ if (m_log == null)
+ m_log = new ConverterLogChannel (null);
+ return m_log;
+ }
+
+ /** If called, must be called before startDocumentArea */
+ public RtfHeader startHeader()
+ throws IOException {
+ if(m_header!=null) throw new RtfStructureException("startHeader called more than once");
+ m_header = new RtfHeader(this,m_writer);
+ m_listTableContainer = new RtfContainer(this,m_writer);
+ return m_header;
+ }
+
+ /** Creates the list table.*/
+ public RtfListTable startListTable(RtfAttributes attr)
+ throws IOException{
+ listNum++;
+ m_listTable = new RtfListTable(this,m_writer,new Integer(listNum),attr);
+ m_listTableContainer.addChild(m_listTable);
+ return m_listTable;
+ }
+
+ /** Closes the RtfHeader if not done yet, and starts the docment area.
+ Like startDocumentArea, is only called once. This is not optimal,
+ must be able to have multiple page definition, and corresponding
+ Document areas */
+ public RtfPageArea startPageArea()
+ throws IOException,RtfStructureException {
+ if(m_pageArea!=null) throw new RtfStructureException("startPageArea called more than once");
+ // create an empty header if there was none
+ if(m_header==null) startHeader();
+ m_header.close();
+ m_pageArea = new RtfPageArea(this,m_writer);
+ addChild(m_pageArea);
+ return m_pageArea;
+ }
+
+ /** Call startPageArea if needed and return the page area object. */
+ public RtfPageArea getPageArea()
+ throws IOException,RtfStructureException {
+ if(m_pageArea== null) return startPageArea();
+ return m_pageArea;
+ }
+
+ /** Closes the RtfHeader if not done yet, and starts the document area.
+ * Must be called once only.
+ */
+ public RtfDocumentArea startDocumentArea()
+ throws IOException,RtfStructureException {
+ if(m_docArea!=null) throw new RtfStructureException("startDocumentArea called more than once");
+ // create an empty header if there was none
+ if(m_header==null) startHeader();
+ m_header.close();
+ m_docArea = new RtfDocumentArea(this,m_writer);
+ addChild(m_docArea);
+ return m_docArea;
+ }
+
+
+
+ /** Call startDocumentArea if needed and return the document area object. */
+ public RtfDocumentArea getDocumentArea()
+ throws IOException,RtfStructureException {
+ if(m_docArea == null) return startDocumentArea();
+ return m_docArea;
+ }
+
+ /** overridden to write RTF prefix code, what comes before our children */
+ protected void writeRtfPrefix() throws IOException
+ {
+ writeGroupMark(true);
+ writeControlWord("rtf1");
+ }
+
+ /** overridden to write RTF suffix code, what comes after our children */
+ protected void writeRtfSuffix() throws IOException
+ {
+ writeGroupMark(false);
+ }
+
+ /** must be called when done creating the document */
+ public synchronized void flush() throws IOException {
+ writeRtf();
+ m_writer.flush();
+ }
+
+ /** minimal test and usage example */
+ public static void main(String args[])
+ throws Exception {
+ Writer w = null;
+ if(args.length != 0) {
+ final String outFile = args[0];
+ System.err.println("Outputting RTF to file '" + outFile + "'");
+ w = new BufferedWriter(new FileWriter(outFile));
+ } else {
+ System.err.println("Outputting RTF code to standard output");
+ w = new BufferedWriter(new OutputStreamWriter(System.out));
+ }
+
+ final RtfFile f = new RtfFile(w);
+ final RtfSection sect = f.startDocumentArea().newSection();
+
+ final RtfParagraph p = sect.newParagraph();
+ p.newText("Hello, RTF world.\n",null);
+ final RtfAttributes attr = new RtfAttributes();
+ attr.set(RtfText.ATTR_BOLD);
+ attr.set(RtfText.ATTR_ITALIC);
+ attr.set(RtfText.ATTR_FONT_SIZE,36);
+ p.newText("This is bold, italic, 36 points",attr);
+
+ f.flush();
+ System.err.println("RtfFile test: all done.");
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontManager.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontManager.java
new file mode 100644
index 000000000..d04735196
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontManager.java
@@ -0,0 +1,215 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * RTF font table
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+public class RtfFontManager
+{
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+ /** Singelton instance */
+ private static RtfFontManager instance = null;
+
+ /** Index table for the fonts */
+ private Hashtable fontIndex = null;
+ /** Used fonts to this vector */
+ private Vector fontTable = null;
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Constructor.
+ */
+ private RtfFontManager ()
+ {
+ fontTable = new Vector ();
+ fontIndex = new Hashtable ();
+
+ init ();
+ }
+
+ /**
+ * Singelton.
+ *
+ * @return The instance of RtfFontManager
+ */
+ public static RtfFontManager getInstance ()
+ {
+ if (instance == null)
+ {
+ instance = new RtfFontManager ();
+ }
+
+ return instance;
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Initializing
+ //////////////////////////////////////////////////
+
+ /**
+ * Initialize the font table.
+ */
+ private void init ()
+ {
+
+// getFontNumber ("Helvetica");
+ //Chanded by R.Marra default font Arial
+ getFontNumber ("Arial");
+ getFontNumber ("Symbol"); // used by RtfListItem.java
+ getFontNumber ("Times New Roman");
+
+/*
+ {\\f0\\fswiss Helv;}
+
+ // f1 is used by RtfList and RtfListItem for bullets
+
+ {\\f1\\froman\\fcharset2 Symbol;}
+ {\\f2\\froman\\fprq2 Times New Roman;}
+ {\\f3\\froman Times New Roman;}
+*/
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Public methods
+ //////////////////////////////////////////////////
+
+
+ /**
+ * Gets the number of font in the font table
+ *
+ * @param family Font family name ('Helvetica')
+ *
+ * @return The number of the font in the table
+ */
+ public int getFontNumber (String family)
+ {
+
+ family = family.toLowerCase ();
+ Object o = fontIndex.get (family);
+ int retVal;
+
+ if (o == null)
+ {
+ addFont (family);
+
+ retVal = fontTable.size () - 1;
+ }
+ else
+ {
+ retVal = ((Integer) o).intValue ();
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Writes the font table in the header.
+ *
+ * @param header The header container to write in
+ *
+ * @throws IOException On error
+ */
+ public void writeFonts (RtfHeader header) throws IOException
+ {
+ if (fontTable == null || fontTable.size () == 0)
+ {
+ return;
+ }
+
+ header.writeGroupMark (true);
+ header.writeControlWord ("fonttbl;");
+
+ int len = fontTable.size ();
+
+ for (int i = 0; i < len; i++)
+ {
+ header.writeGroupMark (true);
+ header.write ("\\f" + i);
+ header.write (" " + (String) fontTable.elementAt (i));
+ header.writeGroupMark (false);
+ }
+
+ header.writeGroupMark (false);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Private methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Adds a font to the table.
+ *
+ * @param i Identifier of font
+ */
+ private void addFont (String family)
+ {
+ fontIndex.put (family, new Integer (fontTable.size ()));
+ fontTable.addElement (family);
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontTable.java
new file mode 100755
index 000000000..e8979af1f
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFontTable.java
@@ -0,0 +1,82 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** RTF font table
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+
+class RtfFontTable extends RtfElement
+{
+ /** Create an RTF header */
+ RtfFontTable(RtfHeader h, Writer w) throws IOException
+ {
+ super(h,w);
+ }
+
+ /** write our contents to m_writer. */
+ protected void writeRtfContent() throws IOException
+ {
+ RtfFontManager.getInstance ().writeFonts ((RtfHeader)m_parent);
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java
new file mode 100755
index 000000000..5c99fe670
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java
@@ -0,0 +1,120 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import org.jfor.jfor.main.JForVersionInfo;
+
+/** RTF file header, contains style, font and other document-level information.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+
+class RtfHeader extends RtfContainer {
+ private final String m_charset = "ansi";
+ private final Map m_userProperties = new HashMap();
+
+ /** Create an RTF header */
+ RtfHeader(RtfFile f,Writer w) throws IOException {
+ super(f,w);
+ new RtfFontTable(this,w);
+ m_userProperties.put("jforVersion",JForVersionInfo.getLongVersionInfo());
+ }
+
+ /** Overridden to write our own data before our children's data */
+ protected void writeRtfContent() throws IOException {
+ writeControlWord(m_charset);
+ writeUserProperties();
+ RtfColorTable.getInstance().writeColors(this);
+ super.writeRtfContent();
+ RtfTemplate.getInstance().writeTemplate(this);
+ RtfStyleSheetTable.getInstance().writeStyleSheet(this);
+
+ }
+
+ /** write user properties if any */
+ private void writeUserProperties() throws IOException {
+ if(m_userProperties.size() > 0) {
+ writeGroupMark(true);
+ writeStarControlWord("userprops");
+ for(Iterator it = m_userProperties.entrySet().iterator(); it.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry)it.next();
+ writeGroupMark(true);
+ writeControlWord("propname");
+ RtfStringConverter.getInstance().writeRtfString(m_writer,entry.getKey().toString());
+ writeGroupMark(false);
+ writeControlWord("proptype30");
+ writeGroupMark(true);
+ writeControlWord("staticval");
+ RtfStringConverter.getInstance().writeRtfString(m_writer,entry.getValue().toString());
+ writeGroupMark(false);
+ }
+ writeGroupMark(false);
+ }
+ }
+
+ /** write directly to our Writer
+ * TODO should check that this done at the right point, or even better, store
+ * what is written here to render it in writeRtfContent. <-- it is for the color table
+ */
+ void write(String toWrite) throws IOException {
+ m_writer.write(toWrite);
+ }
+
+ /** write to our Writer using an RtfStringConverter */
+ void writeRtfString(String toWrite) throws IOException {
+ RtfStringConverter.getInstance().writeRtfString(m_writer,toWrite);
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java
new file mode 100755
index 000000000..4ddf7e8e6
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java
@@ -0,0 +1,228 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * Creates an hyperlink.
+ * This class belongs to the <fo:basic-link> tag processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ *
+ * {\field {\*\fldinst HYPERLINK "http://www.test.de" }{\fldrslt Joe Smith}}
+ */
+public class RtfHyperLink extends RtfContainer implements IRtfTextContainer
+{
+
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+ /** The url of the image */
+ protected String url = null;
+
+ /** RtfText */
+ protected RtfText mText = null;
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+
+ /**
+ * Default constructor.
+ *
+ * @param container a <code>RtfContainer</code> value
+ * @param writer a <code>Writer</code> value
+ * @param attributes a <code>RtfAttributes</code> value
+ */
+ public RtfHyperLink (IRtfTextContainer parent, Writer writer, String str, RtfAttributes attr)
+ throws IOException
+ {
+ super ((RtfContainer) parent, writer, attr);
+ new RtfText (this, writer, str, attr);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ RtfElement implementation
+ //////////////////////////////////////////////////
+
+ /**
+ * Writes the RTF content to m_writer.
+ *
+ * @exception IOException On error
+ */
+ public void writeRtfPrefix () throws IOException
+ {
+ super.writeGroupMark (true);
+ super.writeControlWord ("field");
+
+ super.writeGroupMark (true);
+ super.writeStarControlWord ("fldinst");
+
+ m_writer.write ("HYPERLINK \"" + url + "\" ");
+ super.writeGroupMark (false);
+
+ super.writeGroupMark (true);
+ super.writeControlWord ("fldrslt");
+
+ // start a group for this paragraph and write our own attributes if needed
+ if (m_attrib != null && m_attrib.isSet ("cs"))
+ {
+ writeGroupMark (true);
+ writeAttributes(m_attrib, new String [] {"cs"});
+ }
+ }
+
+ /**
+ * Writes the RTF content to m_writer.
+ *
+ * @exception IOException On error
+ */
+ public void writeRtfSuffix () throws IOException
+ {
+ if (m_attrib != null && m_attrib.isSet ("cs"))
+ {
+ writeGroupMark (false);
+ }
+ super.writeGroupMark (false);
+ super.writeGroupMark (false);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ IRtfContainer implementation
+ //////////////////////////////////////////////////
+
+ /** close current text run if any and start a new one with default attributes
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText (String str) throws IOException {
+ return newText (str,null);
+ }
+
+ /** close current text run if any and start a new one
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText (String str,RtfAttributes attr) throws IOException
+ {
+ closeAll ();
+ mText = new RtfText (this, m_writer, str, attr);
+ return mText;
+ }
+
+ /** IRtfTextContainer requirement: return a copy of our attributes */
+ public RtfAttributes getTextContainerAttributes()
+ {
+ if (m_attrib == null) return null;
+ return (RtfAttributes) this.m_attrib.clone ();
+ }
+
+
+ /** add a line break */
+ public void newLineBreak () throws IOException
+ {
+ new RtfLineBreak (this, m_writer);
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Common container methods
+ //////////////////////////////////////////////////
+
+ private void closeCurrentText () throws IOException
+ {
+ if (mText != null) mText.close ();
+ }
+
+ private void closeAll () throws IOException
+ {
+ closeCurrentText();
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Member access
+ //////////////////////////////////////////////////
+
+ /**
+ * Sets the url of the external link.
+ *
+ * @param url Link url like "http://..."
+ */
+ public void setExternalURL (String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ * Sets the url of the external link.
+ *
+ * @param jumpTo Name of the text mark
+ */
+ public void setInternalURL (String jumpTo)
+ {
+ int now = jumpTo.length ();
+ int max = RtfBookmark.maxBookmarkLength;
+ this.url = "#" + jumpTo.substring (0, now > max ? max : now);
+ this.url = this.url.replace ('.', RtfBookmark.replaceCharacter);
+ this.url = this.url.replace (' ', RtfBookmark.replaceCharacter);
+ }
+
+ public boolean isEmpty ()
+ {
+ return false;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java
new file mode 100644
index 000000000..86541b73c
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfJforCmd.java
@@ -0,0 +1,111 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+
+/*
+ * RtfJforCmd process "jfor-cmd"
+ *
+ */
+public class RtfJforCmd extends RtfContainer {
+
+ private final String PARA_KEEP_ON ="para-keep:on";
+ private final String PARA_KEEP_OFF ="para-keep:off";
+
+ private final RtfAttributes m_attrib;
+ private ParagraphKeeptogetherContext m_paragraphKeeptogetherContext;
+
+
+
+ RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
+ super((RtfContainer)parent,w);
+ m_attrib = attrs;
+ m_paragraphKeeptogetherContext=ParagraphKeeptogetherContext.getInstance();
+ }
+
+
+
+ public boolean isEmpty() {
+ return true;
+ }
+
+
+ public void process() {
+
+ //Execute all jfor-cmd commands
+ //TODO create one class for each jfor command ?
+
+ for(Iterator it = m_attrib.nameIterator(); it.hasNext(); ) {
+ final String cmd = (String)it.next();
+
+ if (cmd.equals(PARA_KEEP_ON)) {
+ m_paragraphKeeptogetherContext.KeepTogetherOpen();
+ }else if (cmd.equals(PARA_KEEP_OFF)) {
+ m_paragraphKeeptogetherContext.KeepTogetherClose();
+ }else {
+ this.getRtfFile ().getLog ().logInfo ("JFOR-CMD ignored, command not recognised:"+cmd);
+ }
+
+ }
+
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfLineBreak.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfLineBreak.java
new file mode 100755
index 000000000..9c97f3129
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfLineBreak.java
@@ -0,0 +1,81 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** "Model" of an RTF line break
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfLineBreak extends RtfElement
+{
+ /** Create an RTF paragraph as a child of given container with default attributes */
+ RtfLineBreak(IRtfTextContainer parent, Writer w) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ }
+
+ /** overridden to write our attributes before our content */
+ protected void writeRtfContent() throws IOException
+ {
+ writeControlWord("line");
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfList.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfList.java
new file mode 100755
index 000000000..63ace729d
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfList.java
@@ -0,0 +1,166 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** Model of an RTF list, which can contain RTF list items
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Christopher Scott, scottc@westinghouse.com
+ */
+
+public class RtfList extends RtfContainer {
+ private RtfListItem m_item;
+ private RtfListTable m_listTable;
+ private final boolean m_hasTableParent;
+
+ /** list numbering style.
+ * Could add more variables, for now we simply differentiate between bullets and numbering
+ */
+ private NumberingStyle m_numberingStyle;
+ public static class NumberingStyle {
+ public boolean isBulletedList = true;
+ }
+
+ /** Create an RTF list as a child of given container with given attributes */
+ RtfList(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
+ super((RtfContainer)parent,w,attr);
+ m_numberingStyle = new NumberingStyle();
+ //create a new list table entry for the list
+ m_listTable = (getRtfFile()).startListTable(attr);
+ m_listTable.setParentList(this);
+
+ // find out if we are nested in a table
+ m_hasTableParent = this.getParentOfClass(RtfTable.class) != null;
+ }
+
+ /** change numbering style */
+ public void setNumberingStyle(NumberingStyle ns) {
+ m_numberingStyle = ns;
+ }
+
+ /** overridden to setup the list: start a group with appropriate attributes */
+ protected void writeRtfPrefix() throws IOException {
+ // pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
+ if(!m_hasTableParent) writeControlWord("pard");
+
+ writeOneAttribute(RtfText.LEFT_INDENT_FIRST,m_attrib.getValue(RtfListTable.LIST_INDENT));
+ writeOneAttribute(RtfText.LEFT_INDENT_BODY,m_attrib.getValue(RtfText.LEFT_INDENT_BODY));
+
+ // put the whole list in a group
+ writeGroupMark(true);
+
+ // group for list setup info
+ writeGroupMark(true);
+
+ writeStarControlWord("pn");
+ //Modified by Chris Scott
+ //fixes second line indentation
+
+ if(m_numberingStyle.isBulletedList) {
+ // bulleted list
+ writeControlWord("pnlvlblt");
+ writeControlWord("ilvl0");
+ writeOneAttribute(RtfListTable.LIST_NUMBER,
+ (m_listTable.getListNumber()).toString());
+ writeOneAttribute("pnindent",
+ m_attrib.getValue(RtfListTable.LIST_INDENT));
+ writeControlWord("pnf1");
+ writeGroupMark(true);
+ writeControlWord("pndec");
+ writeOneAttribute(RtfListTable.LIST_FONT_TYPE,"2");
+ writeControlWord("pntxtb");
+ writeControlWord("'b7");
+ writeGroupMark(false);
+ } else {
+ // numbered list
+ writeControlWord("pnlvlbody");
+ writeControlWord("ilvl0");
+ writeOneAttribute(RtfListTable.LIST_NUMBER,
+ (m_numberingStyle.isBulletedList) ? "2" : "0");
+ writeControlWord("pndec");
+ writeOneAttribute("pnstart",
+ m_attrib.getValue(RtfListTable.LIST_START_AT));
+ writeOneAttribute("pnindent",
+ m_attrib.getValue(RtfListTable.LIST_INDENT));
+ writeControlWord("pntxta.");
+ }
+
+ writeGroupMark(false);
+ writeOneAttribute(RtfListTable.LIST_NUMBER,
+ (m_listTable.getListNumber()).toString());
+ }
+
+ /** end the list group */
+ protected void writeRtfSuffix() throws IOException {
+ // close group that encloses the whole list
+ writeGroupMark(false);
+
+ // reset paragraph defaults to make sure list ends
+ // but pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
+ if(!m_hasTableParent) writeControlWord("pard");
+ }
+
+ /** close current list item and start a new one */
+ public RtfListItem newListItem() throws IOException {
+ if(m_item != null) m_item.close();
+ m_item = new RtfListItem(this,m_writer);
+ return m_item;
+ }
+
+ /** true if this is a bulleted list (as opposed to numbered list) */
+ public boolean isBulletedList() {
+ return m_numberingStyle.isBulletedList;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListItem.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListItem.java
new file mode 100755
index 000000000..24e5ac398
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListItem.java
@@ -0,0 +1,121 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.*;
+
+/** Model of an RTF list item, which can contain RTF paragraphs
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ */
+public class RtfListItem
+extends RtfContainer
+implements IRtfParagraphContainer {
+ private RtfList m_parentList;
+ private RtfParagraph m_paragraph;
+
+ /** special RtfParagraph that writes list item setup code before its content */
+ private class RtfListItemParagraph extends RtfParagraph {
+
+ RtfListItemParagraph(RtfListItem rli,RtfAttributes attrs)
+ throws IOException {
+ super(rli,rli.m_writer,attrs);
+ }
+
+ protected void writeRtfPrefix() throws IOException {
+ super.writeRtfPrefix();
+ // for bulleted list, add list item setup group before paragraph contents
+ if(m_parentList.isBulletedList()) {
+ writeGroupMark(true);
+ writeControlWord("pntext");
+ writeControlWord("f" + RtfFontManager.getInstance().getFontNumber("Symbol"));
+ writeControlWord("'b7");
+ writeControlWord("tab");
+ writeGroupMark(false);
+ }else{
+ writeGroupMark(true);
+ writeControlWord("pntext");
+ writeGroupMark(false);
+ }
+ }
+
+ }
+
+ /** Create an RTF list item as a child of given container with default attributes */
+ RtfListItem(RtfList parent, Writer w) throws IOException {
+ super((RtfContainer)parent,w);
+ m_parentList = parent;
+ }
+
+ /** Create an RTF list item as a child of given container with given attributes */
+ RtfListItem(RtfList parent, Writer w, RtfAttributes attr) throws IOException {
+ super((RtfContainer)parent,w,attr);
+ m_parentList = parent;
+ }
+
+ /** close current paragraph and start a new one */
+ /** close current paragraph if any and start a new one */
+ public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
+ if(m_paragraph != null) m_paragraph.close();
+ m_paragraph = new RtfListItemParagraph(this,attrs);
+ return m_paragraph;
+ }
+
+ /** close current paragraph if any and start a new one with default attributes */
+ public RtfParagraph newParagraph() throws IOException {
+ return newParagraph(null);
+ }
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java
new file mode 100644
index 000000000..23a392288
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfListTable.java
@@ -0,0 +1,195 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import org.jfor.jfor.main.JForVersionInfo;
+
+/**RtfListTable: used to make the list table in the header section of the RtfFile.
+ * This is the method that Word uses to make lists in RTF and the way most RTF readers,
+ * esp. Adobe FrameMaker read lists from RTF.
+ * @author Christopher Scott, scottc@westinghouse.com
+ */
+public class RtfListTable extends RtfContainer{
+
+ //number of list in document
+ private Integer listNum;
+ //id of list
+ private Integer listId;
+ private Integer listTemplateId;
+ private RtfList parentList;
+ //static data members
+ public static final String LIST_TABLE = "listtable";
+ public static final String LIST = "list";
+ public static final String LIST_TEMPLATE_ID = "listtemplateid";
+ public static final String LIST_LEVEL = "listlevel";
+ public static final String LIST_NUMBER_TYPE = "levelnfc";
+ public static final String LIST_JUSTIFICATION = "leveljc";
+ public static final String LIST_FOLLOWING_CHAR = "levelfollow";
+ public static final String LIST_START_AT = "levelstartat";
+ public static final String LIST_SPACE = "levelspace";
+ public static final String LIST_INDENT = "levelindent";
+ public static final String LIST_TEXT_FORM = "leveltext";
+ public static final String LIST_NUM_POSITION = "levelnumbers";
+ public static final String LIST_NAME = "listname ;";
+ public static final String LIST_ID = "listid";
+ public static final String LIST_FONT_TYPE ="f";
+
+ public static final String LIST_OVR_TABLE = "listoverridetable";
+ public static final String LIST_OVR = "listoverride";
+ public static final String LIST_OVR_COUNT = "listoverridecount";
+ public static final String LIST_NUMBER = "ls";
+
+ public static final String [] LIST_TABLE_ATTR = {
+ LIST_TABLE, LIST, LIST_TEMPLATE_ID,
+ LIST_NUMBER_TYPE, LIST_JUSTIFICATION, LIST_FOLLOWING_CHAR,
+ LIST_START_AT, LIST_SPACE, LIST_INDENT,
+ LIST_TEXT_FORM, LIST_NUM_POSITION, LIST_ID,
+ LIST_OVR_TABLE, LIST_OVR, LIST_OVR_COUNT,
+ LIST_NUMBER, LIST_LEVEL
+ };
+
+ /**RtfListTable Constructor: sets the number of the list, and allocates
+ * for the RtfAttributes */
+ public RtfListTable(RtfContainer parent, Writer w, Integer num, RtfAttributes attrs)
+ throws IOException{
+ super(parent, w, attrs);
+ listNum = new Integer(num.intValue());
+ //random number generator for ids
+ Date runTime = new Date();
+ Random listIdGenerator = new Random(runTime.getTime());
+ listId = new Integer(listIdGenerator.nextInt());
+ m_attrib.set(LIST_ID,listId.toString());
+ listTemplateId = new Integer(listIdGenerator.nextInt());
+ m_attrib.set(LIST_NUMBER_TYPE,0);
+ }
+
+ public void setParentList(RtfList parent) {
+ parentList = parent;
+ }
+
+ public Integer getListNumber() {
+ return listNum;
+ }
+
+ /** Set whether the list is a bulleted list not, and set attributes
+ * accordingly */
+ private void setListType() {
+ if(parentList.isBulletedList()){
+ // bullet definition for bulleted lists
+ // Chris Scott's version was "\\\'01\\u-3913 ?;"
+ // 'b7 is what was used in jfor V0.5.2
+ m_attrib.set(LIST_TEXT_FORM,"\\\'01\\'b7 ?;");
+ m_attrib.set(LIST_NUM_POSITION);
+ m_attrib.set(LIST_NUMBER_TYPE,23);
+ m_attrib.set(LIST_FONT_TYPE,2);
+ }else{
+ m_attrib.set(LIST_TEXT_FORM, "\\\'03\\\'00. ;");
+ m_attrib.set(LIST_NUM_POSITION, "\\\'01;");
+ m_attrib.set(LIST_NUMBER_TYPE,0);
+ m_attrib.set(LIST_FONT_TYPE,0);
+ }
+ }
+
+ public void writeRtfContent() throws IOException {
+ setListType();
+ writeGroupMark(true);
+ writeStarControlWordNS(LIST_TABLE);
+ writeGroupMark(true);
+
+ writeControlWordNS(LIST);
+ writeOneAttributeNS(LIST_TEMPLATE_ID,listTemplateId.toString());
+ writeOneAttributeNS(LIST,m_attrib.getValue(LIST));
+ writeGroupMark(true);
+ writeControlWordNS(LIST_LEVEL);
+ writeOneAttributeNS(LIST_NUMBER_TYPE,m_attrib.getValue(LIST_NUMBER_TYPE));
+ writeOneAttributeNS(LIST_JUSTIFICATION,m_attrib.getValue(LIST_JUSTIFICATION));
+ writeOneAttributeNS(LIST_FOLLOWING_CHAR,m_attrib.getValue(LIST_FOLLOWING_CHAR));
+ writeOneAttributeNS(LIST_START_AT,m_attrib.getValue(LIST_START_AT));
+ writeOneAttributeNS(LIST_SPACE,new Integer(0));
+ writeOneAttributeNS(LIST_INDENT,m_attrib.getValue(LIST_INDENT));
+ writeGroupMark(true);
+ writeOneAttributeNS(LIST_TEXT_FORM,m_attrib.getValue(LIST_TEXT_FORM));
+ writeGroupMark(false);
+ writeGroupMark(true);
+ writeOneAttributeNS(LIST_NUM_POSITION,m_attrib.getValue(LIST_NUM_POSITION));
+ writeGroupMark(false);
+ writeOneAttributeNS(LIST_FONT_TYPE,m_attrib.getValue(LIST_FONT_TYPE));
+ writeGroupMark(false);
+ writeGroupMark(true);
+ writeControlWordNS(LIST_NAME);
+ writeGroupMark(false);
+ writeOneAttributeNS(LIST_ID,listId.toString());
+ writeGroupMark(false);
+ writeGroupMark(false);
+ writeGroupMark(true);
+ writeStarControlWordNS(LIST_OVR_TABLE);
+ writeGroupMark(true);
+ writeControlWordNS(LIST_OVR);
+ writeOneAttributeNS(LIST_ID,listId.toString());
+ writeOneAttributeNS(LIST_OVR_COUNT,new Integer(0));
+ writeOneAttributeNS(LIST_NUMBER,listNum.toString());
+ writeGroupMark(false);
+ writeGroupMark(false);
+ }
+
+ //since this has no text content we have to overwrite isEmpty to print
+ //the table
+ public boolean isEmpty() {
+ return false;
+ }
+
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfNull.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfNull.java
new file mode 100644
index 000000000..4301c8712
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfNull.java
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+
+/* @author Christopher Scott, scottc@westinghouse.com */
+
+public class RtfNull
+extends RtfContainer{
+
+ RtfNull(RtfPage parent, Writer w) throws IOException {
+ super((RtfContainer)parent,w);
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfOptions.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfOptions.java
new file mode 100755
index 000000000..67d51b670
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfOptions.java
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.util.*;
+import java.io.IOException;
+
+/** Simplistic options definitions for RTF generation
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfOptions
+{
+ /** if true, RtfParagraphs that have no children do not generate any RTF code */
+ public boolean ignoreEmptyParagraphs() { return true; }
+
+ /** RtfContainer does not generate any RTF is this returns false */
+ public boolean renderContainer(RtfContainer c) { return true; }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPage.java
new file mode 100644
index 000000000..e5abe6d12
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPage.java
@@ -0,0 +1,120 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+/** Specifies rtf control words. Is the container for page attributes.
+ * Overrides okToWriteRtf.
+ * @author Christopher Scott, scottc@westinghouse.com
+ */
+
+public class RtfPage
+extends RtfContainer{
+ private final RtfAttributes m_attrib;
+
+ /**RtfPage attributes*/
+ public final static String PAGE_WIDTH = "paperw";
+ public final static String PAGE_HEIGHT = "paperh";
+
+ public final static String MARGIN_TOP = "margt";
+ public final static String MARGIN_BOTTOM = "margb";
+ public final static String MARGIN_LEFT = "margl";
+ public final static String MARGIN_RIGHT = "margr";
+
+ public final static String[] PAGE_ATTR = new String[]{
+ PAGE_WIDTH, PAGE_HEIGHT, MARGIN_TOP, MARGIN_BOTTOM,
+ MARGIN_LEFT, MARGIN_RIGHT
+ };
+
+ /** RtfPage creates new page attributes with the parent container, the writer
+ and the attributes*/
+ RtfPage(RtfPageArea parent, Writer w, RtfAttributes attrs) throws IOException {
+ super((RtfContainer)parent,w);
+ m_attrib = attrs;
+ }
+
+ /** RtfPage writes the attributes the attributes contained in the string
+ PAGE_ATTR, if not null */
+ protected void writeRtfContent() throws IOException {
+ writeAttributes(m_attrib, PAGE_ATTR);
+
+ if (m_attrib != null)
+ {
+ Object widthRaw = m_attrib.getValue( PAGE_WIDTH );
+ Object heightRaw = m_attrib.getValue( PAGE_HEIGHT );
+
+ if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer) &&
+ ((Integer) widthRaw).intValue() > ((Integer) heightRaw).intValue())
+ {
+ writeControlWord( "landscape" );
+ }
+ }
+ }
+
+ /** RtfPage - attributes accessor */
+ public RtfAttributes getAttributes(){
+ return m_attrib;
+ }
+
+ /** RtfPage - is overwritten here because page attributes have no content
+ only attributes. RtfContainer is defined not to write when empty.
+ Therefore must make this true to print.*/
+ protected boolean okToWriteRtf()
+ {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageArea.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageArea.java
new file mode 100644
index 000000000..53070bf5e
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageArea.java
@@ -0,0 +1,89 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.*;
+
+/* @author Christopher Scott, scottc@westinghouse.com */
+
+public class RtfPageArea
+extends RtfContainer
+{
+ private RtfPage m_currentPage;
+ private RtfNull nullChild;
+ private RtfAttributes childAttributes;
+
+ /** Create an RTF element as a child of given container */
+ RtfPageArea(RtfFile f,Writer w) throws IOException
+ {
+ super(f,w);
+ }
+
+ /** close current Rtfpage if any and create a new one */
+ public RtfPage newPage(RtfAttributes attr) throws IOException
+ {
+ if(m_currentPage != null){
+ m_currentPage.close();
+ }
+ m_currentPage = new RtfPage(this,m_writer,attr);
+
+ return m_currentPage;
+ }
+
+ protected boolean okToWriteRtf()
+ {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageBreak.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageBreak.java
new file mode 100755
index 000000000..38bc9b956
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageBreak.java
@@ -0,0 +1,81 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/** "Model" of an RTF page break
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfPageBreak extends RtfElement
+{
+ /** Create an RTF paragraph as a child of given container with default attributes */
+ RtfPageBreak(IRtfPageBreakContainer parent, Writer w) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ }
+
+ /** overridden to write our attributes before our content */
+ protected void writeRtfContent() throws IOException
+ {
+ writeControlWord("page");
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumber.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumber.java
new file mode 100644
index 000000000..ca70b1869
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumber.java
@@ -0,0 +1,111 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/* @author Christopher Scott, scottc@westinghouse.com */
+public class RtfPageNumber extends RtfContainer
+{
+ /** RtfText attributes: fields */
+ //must be carefull of group markings and star control
+ //ie page field:
+ // "{\field {\*\fldinst {PAGE}} {\fldrslt}}"
+ public static String RTF_FIELD = "field";
+ public static String RTF_FIELD_PAGE = "fldinst { PAGE }";
+ public static String RTF_FIELD_RESULT = "fldrslt";
+
+ /** Create an RTF paragraph as a child of given container with default attributes */
+ RtfPageNumber(IRtfPageNumberContainer parent, Writer w) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ }
+
+ /** Create an RTF page number as a child of given paragraph,
+ * copying the paragraph attributes
+ */
+ RtfPageNumber(RtfParagraph parent, Writer w) throws IOException
+ {
+ // Adds the attributes of the parent paragraph
+ super((RtfContainer)parent,w, parent.m_attrib);
+
+ // copy parent's text attributes
+ if (parent.getTextAttributes() != null) {
+ m_attrib.set(parent.getTextAttributes());
+ }
+ }
+
+ /** write our attributes and content */
+ protected void writeRtfContent() throws IOException
+ {
+ writeGroupMark(true);
+ writeControlWord(RTF_FIELD);
+ writeGroupMark(true);
+ writeAttributes(m_attrib,RtfText.ATTR_NAMES); // Added by Boris Poudérous
+ writeStarControlWord(RTF_FIELD_PAGE);
+ writeGroupMark(false);
+ writeGroupMark(true);
+ writeControlWord(RTF_FIELD_RESULT);
+ writeGroupMark(false);
+ writeGroupMark(false);
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+}
+
+ \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
new file mode 100644
index 000000000..b1550e03d
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
@@ -0,0 +1,136 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/*
+ * @author Christopher Scott, scottc@westinghouse.com
+ * @author Boris Pouderous, boris.pouderous@free.fr
+ */
+
+public class RtfPageNumberCitation extends RtfContainer
+{
+ // Page field :
+ // "{\field {\*\fldinst {PAGEREF xx}} {\fldrslt}}" where xx represents the
+ // 'id' of the referenced page
+ public static final String RTF_FIELD = "field";
+ public static final String RTF_FIELD_PAGEREF_MODEL = "fldinst { PAGEREF }";
+ public static final String RTF_FIELD_RESULT = "fldrslt";
+
+ // The 'id' of the referenced page
+ private String id = null;
+
+ /** Create an RTF page number citation as a child of given container with default attributes */
+ RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ this.id = id;
+ }
+
+ /** Create an RTF page number citation as a child of given
+ * paragraph, copying its attributes */
+ RtfPageNumberCitation (RtfParagraph parent, Writer w, String id)
+ throws IOException
+ {
+ // add the attributes ant text attributes of the parent paragraph
+ super((RtfContainer)parent,w, parent.m_attrib);
+ if (parent.getTextAttributes() != null) {
+ m_attrib.set(parent.getTextAttributes());
+ }
+ this.id = id;
+ }
+
+ protected void writeRtfContent() throws IOException
+ {
+ // If we have a valid ID
+ if (isValid()) {
+ // Build page reference field
+ String pageRef = RTF_FIELD_PAGEREF_MODEL;
+ final int insertionIndex = pageRef.indexOf("}");
+ pageRef =
+ pageRef.substring(0,insertionIndex) + "\"" + id + "\"" + " "
+ + pageRef.substring(insertionIndex, pageRef.length())
+ ;
+ id = null;
+
+ // Write RTF content
+ writeGroupMark(true);
+ writeControlWord(RTF_FIELD);
+ writeGroupMark(true);
+ writeAttributes(m_attrib,RtfText.ATTR_NAMES); // Added by Boris Poudérous
+ writeStarControlWord(pageRef);
+ writeGroupMark(false);
+ writeGroupMark(true);
+ writeControlWord(RTF_FIELD_RESULT);
+ writeGroupMark(false);
+ writeGroupMark(false);
+ }
+ }
+
+ /** checks that the 'ref-id' attribute exists */
+ private boolean isValid()
+ {
+ if (id != null)
+ return true;
+ else
+ return false;
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraph.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraph.java
new file mode 100755
index 000000000..e38ea3e4c
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraph.java
@@ -0,0 +1,300 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.util.List;
+
+/** Model of an RTF paragraph, which can contain RTF text elements.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ * @author Boris Poudérous, boris.pouderous@free.fr
+ */
+
+public class RtfParagraph extends RtfBookmarkContainerImpl
+implements IRtfTextContainer,IRtfPageBreakContainer,IRtfHyperLinkContainer,IRtfExternalGraphicContainer,
+IRtfPageNumberContainer,IRtfPageNumberCitationContainer {
+ private RtfText m_text;
+ private RtfHyperLink m_hyperlink;
+ private RtfExternalGraphic m_externalGraphic;
+ private RtfPageNumber m_pageNumber;
+ private RtfPageNumberCitation m_pageNumberCitation; // Line added by Boris POUDEROUS on 2002/07/09
+ private boolean m_keepn=false;
+ private boolean m_resetProperties=false;
+
+ /* needed for importing Rtf into FrameMaker
+ FrameMaker is not as forgiving as word in rtf
+ thus /pard/par must be written in a page break directly
+ after a table. /pard is probably needed in other places
+ also, this is just a hack to make FrameMaker import Jfor rtf
+ correctly */
+ private boolean writeForBreak = false;
+
+ /** Set of attributes that must be copied at the start of a paragraph */
+ private static final String [] PARA_ATTRIBUTES = { "intbl" };
+
+ /** Create an RTF paragraph as a child of given container with default attributes */
+ RtfParagraph(IRtfParagraphContainer parent, Writer w) throws IOException {
+ super((RtfContainer)parent,w);
+ }
+
+ /** Create an RTF paragraph as a child of given container with given attributes */
+ RtfParagraph(IRtfParagraphContainer parent, Writer w,RtfAttributes attr) throws IOException {
+ super((RtfContainer)parent,w,attr);
+ }
+
+ public String getText(){
+ return(m_text.getText());
+ }
+
+ /** Set the keepn attribute for this paragraph */
+ public void setKeepn() {
+ this.m_keepn=true;
+ }
+
+ /** Force reset properties */
+ public void setResetProperties() {
+ this.m_resetProperties=true;
+ }
+
+ /** IRtfTextContainer requirement: return a copy of our attributes */
+ public RtfAttributes getTextContainerAttributes() {
+ if(m_attrib == null) return null;
+ return (RtfAttributes)this.m_attrib.clone();
+ }
+
+ /** overridden to write our attributes before our content */
+ protected void writeRtfPrefix() throws IOException {
+ // collapse whitespace before writing out
+ // TODO could be made configurable
+ if(m_attrib != null && m_attrib.isSet("WhiteSpaceFalse")){
+ m_attrib.unset("WhiteSpaceFalse");
+ } else {
+ new WhitespaceCollapser(this);
+ }
+
+ //Reset paragraph properties if needed
+ if(m_resetProperties) {
+ writeControlWord("pard");
+ }
+
+ // do not write text attributes here, they are handled
+ // by RtfText
+ writeAttributes(m_attrib,PARA_ATTRIBUTES);
+ // Added by Normand Masse
+ // Write alignment attributes after \intbl for cells
+ if ( m_attrib.isSet( "intbl" ) && mustWriteAttributes() ) {
+ writeAttributes(m_attrib, RtfText.ALIGNMENT);
+ }
+
+ //Set keepn if needed (Keep paragraph with the next paragraph)
+ if(m_keepn) writeControlWord("keepn");
+
+ // start a group for this paragraph and write our own attributes if needed
+ if(mustWriteGroupMark()) writeGroupMark(true);
+
+
+ if(mustWriteAttributes()) {
+ // writeAttributes(m_attrib, new String [] {"cs"});
+ // Added by Normand Masse
+ // If \intbl then attributes have already been written (see higher in method)
+ if ( !m_attrib.isSet( "intbl" ) ) {
+ writeAttributes(m_attrib, RtfText.ALIGNMENT);
+ }
+ //this line added by Chris Scott, Westinghouse
+ writeAttributes(m_attrib, RtfText.BORDER);
+ writeAttributes(m_attrib, RtfText.INDENT);
+ writeAttributes(m_attrib, RtfText.TABS);
+ if(writeForBreak){
+ writeControlWord("pard\\par");
+ }
+ }
+
+ }
+
+ /** overridden to close paragraph */
+ protected void writeRtfSuffix() throws IOException {
+ // sometimes the end of paragraph mark must be suppressed in table cells
+ boolean writeMark = true;
+ if(m_parent instanceof RtfTableCell) {
+ writeMark = ((RtfTableCell)m_parent).paragraphNeedsPar(this);
+ }
+ if(writeMark) {
+ writeControlWord("par");
+ }
+
+ if(mustWriteGroupMark()) writeGroupMark(false);
+
+
+ }
+
+ /** close current text run if any and start a new one with default attributes
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText(String str) throws IOException {
+ return newText(str,null);
+ }
+
+ /** close current text run if any and start a new one
+ * @param str if not null, added to the RtfText created
+ */
+ public RtfText newText(String str,RtfAttributes attr) throws IOException {
+ closeAll();
+ m_text = new RtfText(this,m_writer,str,attr);
+ return m_text;
+ }
+
+ /** add a page break */
+ public void newPageBreak() throws IOException {
+ writeForBreak = true;
+ new RtfPageBreak(this,m_writer);
+ }
+
+ /** add a line break */
+ public void newLineBreak() throws IOException {
+ new RtfLineBreak(this,m_writer);
+ }
+
+ public RtfPageNumber newPageNumber()throws IOException {
+ m_pageNumber = new RtfPageNumber(this,m_writer);
+ return m_pageNumber;
+ }
+
+ /**
+ * Added by Boris POUDEROUS on 2002/07/09
+ */
+ public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException
+ {
+ m_pageNumberCitation = new RtfPageNumberCitation(this,m_writer, id);
+ return m_pageNumberCitation;
+ }
+
+ /** Creates a new hyperlink. */
+ public RtfHyperLink newHyperLink(String str, RtfAttributes attr) throws IOException {
+ m_hyperlink = new RtfHyperLink(this, m_writer, str, attr);
+ return m_hyperlink;
+ }
+
+ /** start a new external graphic after closing all other elements */
+ public RtfExternalGraphic newImage() throws IOException {
+ closeAll();
+ m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ return m_externalGraphic;
+ }
+
+ private void closeCurrentText() throws IOException {
+ if(m_text != null) m_text.close();
+ }
+
+ private void closeCurrentHyperLink() throws IOException {
+ if(m_hyperlink != null) m_hyperlink.close();
+ }
+
+ private void closeAll() throws IOException {
+ closeCurrentText();
+ closeCurrentHyperLink();
+ }
+
+ /** depending on RtfOptions, do not emit any RTF for empty paragraphs */
+ protected boolean okToWriteRtf() {
+ boolean result = super.okToWriteRtf();
+
+ if(m_parent.getOptions().ignoreEmptyParagraphs() && getChildCount() == 0) {
+ // TODO should test that this is the last RtfParagraph in the cell instead
+ // of simply testing for last child??
+ result = false;
+ }
+
+ return result;
+ }
+
+ /** true if we must write our own (non-text) attributes in the RTF */
+ private boolean mustWriteAttributes() {
+ boolean writeAttributes = false;
+ final int children = getChildCount();
+ if (children > 0) {
+ final List childList = getChildren();
+ for (int i = 0; i < children; i++) {
+ final RtfElement el = (RtfElement) childList.get(i);
+ if (! el.isEmpty()) {
+ if (el.getClass() == RtfText.class ) {
+ boolean tmp = ((RtfText) el).isNbsp();
+ if (! tmp) {
+ writeAttributes = true;
+ break;
+ }
+ }
+ else {
+ writeAttributes = true;
+ break;
+ }
+ }
+ }
+ }
+ return writeAttributes;
+ }
+
+ /** true if we must write a group mark around this paragraph
+ * TODO is this correct, study interaction with mustWriteAttributes() <-- On implementation i have noticed if the groupmark set, the format attributes are only for this content, i think this implementation is ok
+ */
+ private boolean mustWriteGroupMark() {
+ return getChildCount() > 0;
+ }
+
+ /** get the attributes of our text */
+ public RtfAttributes getTextAttributes(){
+ if(m_text == null) return null;
+ return m_text.getTextAttributes();
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java
new file mode 100644
index 000000000..9f92b84e7
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfParagraphKeepTogether.java
@@ -0,0 +1,107 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+
+public class RtfParagraphKeepTogether extends RtfContainer{
+
+ public static final int STATUS_NULL=0;
+ public static final int STATUS_OPEN_PARAGRAPH=1;
+ public static final int STATUS_CLOSE_PARAGRAPH=2;
+ private int m_status =STATUS_NULL;
+
+
+ /** RtfParagraphKeepTogether*/
+ RtfParagraphKeepTogether(IRtfParagraphContainer parent, Writer w) throws IOException {
+ super((RtfContainer)parent,w);
+ }
+
+
+ protected void writeRtfContent() throws IOException {
+
+ //First reet paragraph properties
+ // create a new one with keepn
+ if (m_status==STATUS_OPEN_PARAGRAPH) {
+ writeControlWord("pard");
+ writeControlWord("par");
+ writeControlWord("keepn");
+ writeGroupMark(true);
+ m_status = STATUS_NULL;
+ }
+
+
+ if (m_status == STATUS_CLOSE_PARAGRAPH) {
+ writeGroupMark(false);
+ m_status = STATUS_NULL;
+ }
+
+ }
+
+
+
+ public void setStatus(int status) {
+ m_status = status;
+ }
+
+ /** true if this element would generate no "useful" RTF content */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfSection.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfSection.java
new file mode 100755
index 000000000..d013cb7fb
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfSection.java
@@ -0,0 +1,200 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.Writer;
+import java.io.*;
+import java.util.*;
+import java.io.IOException;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+/** Models a section in an RTF document
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfSection
+extends RtfContainer
+implements
+ IRtfParagraphContainer,
+ IRtfTableContainer,
+ IRtfListContainer,
+ IRtfExternalGraphicContainer,
+ IRtfBeforeContainer,
+ IRtfParagraphKeepTogetherContainer,
+ IRtfAfterContainer,
+ IRtfJforCmdContainer
+{
+ private RtfParagraph m_paragraph;
+ private RtfTable m_table;
+ private RtfList m_list;
+ private RtfExternalGraphic m_externalGraphic;
+ private RtfBefore m_before;
+ private RtfAfter m_after;
+ private RtfJforCmd m_jforCmd;
+
+ /** Create an RTF container as a child of given container */
+ RtfSection(RtfDocumentArea parent, Writer w) throws IOException {
+ super(parent,w);
+ }
+
+ /** start a new external graphic after closing current paragraph, list and table */
+ public RtfExternalGraphic newImage() throws IOException {
+ closeAll();
+ m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ return m_externalGraphic;
+ }
+
+ /** start a new paragraph after closing current paragraph, list and table */
+ public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
+ closeAll();
+ m_paragraph = new RtfParagraph(this,m_writer,attrs);
+ return m_paragraph;
+ }
+
+ /** close current paragraph if any and start a new one with default attributes */
+ public RtfParagraph newParagraph() throws IOException {
+ return newParagraph(null);
+ }
+
+ /** close current paragraph if any and start a new one */
+ public RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException {
+ return new RtfParagraphKeepTogether(this,m_writer);
+ }
+
+ /** start a new table after closing current paragraph, list and table
+ * @param tc Table context used for number-columns-spanned attribute (added by Boris Poudérous on july 2002)
+ */
+ public RtfTable newTable(ITableColumnsInfo tc) throws IOException {
+ closeAll();
+ m_table = new RtfTable(this,m_writer,tc);
+ return m_table;
+ }
+
+ /** start a new table after closing current paragraph, list and table
+ * @param tc Table context used for number-columns-spanned attribute (added by Boris Poudérous on july 2002)
+ */
+ public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException
+ {
+ closeAll();
+ m_table = new RtfTable(this,m_writer, attrs, tc);
+ return m_table;
+ }
+
+ /** start a new list after closing current paragraph, list and table */
+ public RtfList newList(RtfAttributes attrs) throws IOException {
+ closeAll();
+ m_list = new RtfList(this,m_writer, attrs);
+ return m_list;
+ }
+
+ /** IRtfBeforeContainer */
+ public RtfBefore newBefore(RtfAttributes attrs) throws IOException {
+ closeAll();
+ m_before = new RtfBefore(this,m_writer,attrs);
+ return m_before;
+ }
+
+ /** IRtfAfterContainer */
+ public RtfAfter newAfter(RtfAttributes attrs) throws IOException {
+ closeAll();
+ m_after = new RtfAfter(this,m_writer,attrs);
+ return m_after;
+ }
+
+
+ public RtfJforCmd newJforCmd(RtfAttributes attrs) throws IOException {
+ m_jforCmd = new RtfJforCmd(this,m_writer,attrs);
+ return m_jforCmd;
+ }
+
+
+
+ /** can be overridden to write RTF prefix code, what comes before our children */
+ protected void writeRtfPrefix() throws IOException {
+ writeControlWord("sectd");
+ }
+
+ /** can be overridden to write RTF suffix code, what comes after our children */
+ protected void writeRtfSuffix() throws IOException {
+ writeControlWord("sect");
+ }
+
+ private void closeCurrentTable() throws IOException {
+ if(m_table != null) m_table.close();
+ }
+
+ private void closeCurrentParagraph() throws IOException {
+ if(m_paragraph!=null) m_paragraph.close();
+ }
+
+ private void closeCurrentList() throws IOException {
+ if(m_list!=null) m_list.close();
+ }
+
+ private void closeCurrentExternalGraphic() throws IOException {
+ if(m_externalGraphic!=null) m_externalGraphic.close();
+ }
+
+ private void closeCurrentBefore() throws IOException {
+ if(m_before!=null) m_before.close();
+ }
+
+ private void closeAll()
+ throws IOException {
+ closeCurrentTable();
+ closeCurrentParagraph();
+ closeCurrentList();
+ closeCurrentExternalGraphic();
+ closeCurrentBefore();
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStringConverter.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStringConverter.java
new file mode 100755
index 000000000..ec82ab6bd
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStringConverter.java
@@ -0,0 +1,135 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.*;
+import java.io.IOException;
+import java.io.Writer;
+
+/** Converts java Strings according to RTF conventions
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfStringConverter {
+ private static final RtfStringConverter m_instance = new RtfStringConverter();
+
+ private static final Map m_specialChars;
+ private static final Character DBLQUOTE = new Character('\"');
+ private static final Character QUOTE = new Character('\'');
+ private static final Character SPACE = new Character(' ');
+
+ /** List of characters to escape with corresponding replacement strings */
+ static {
+ m_specialChars = new HashMap();
+ m_specialChars.put(new Character('\t'),"tab");
+ m_specialChars.put(new Character('\n'),"line");
+ m_specialChars.put(new Character('\''),"rquote");
+ m_specialChars.put(new Character('\"'),"rdblquote");
+ m_specialChars.put(new Character('\\'),"\\");
+ m_specialChars.put(new Character('{'),"{");
+ m_specialChars.put(new Character('}'),"}");
+ }
+
+ /** singleton pattern */
+ private RtfStringConverter() {
+ }
+
+ /** use this to get an object of this class */
+ public static RtfStringConverter getInstance() {
+ return m_instance;
+ }
+
+ /** write given String to given Writer, converting characters as required by RTF spec */
+ public void writeRtfString(Writer w,String str) throws IOException {
+ if(str == null) return;
+
+ // TODO: could be made more efficient (binary lookup, etc.)
+ for(int i=0; i < str.length(); i++) {
+ final Character c = new Character(str.charAt(i));
+ Character d;
+ String replacement;
+ if(i!= 0) {
+ d=new Character(str.charAt(i-1));
+ } else {
+ d=new Character(str.charAt(i));
+ }
+
+ //This section modified by Chris Scott
+ //add "smart" quote recognition
+ if(c.equals((Object)DBLQUOTE) && d.equals((Object)SPACE)) {
+ replacement = "ldblquote";
+ } else if(c.equals((Object)QUOTE) && d.equals((Object)SPACE)) {
+ replacement = "lquote";
+ } else {
+ replacement = (String)m_specialChars.get(c);
+ }
+
+ if(replacement != null) {
+ // RTF-escaped char
+ w.write('\\');
+ w.write(replacement);
+ w.write(' ');
+ } else if (c.charValue() > 255) {
+ // write unicode representation - contributed by Michel Jacobson <jacobson@idf.ext.jussieu.fr>
+ w.write("\\u");
+ w.write(Integer.toString((int)c.charValue()));
+ w.write("\\\'3f");
+ } else {
+ // plain char that is understood by RTF natively
+ w.write(c.charValue());
+ }
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
new file mode 100644
index 000000000..d0b0dc768
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
@@ -0,0 +1,283 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.Vector;
+import java.util.Hashtable;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * Singelton of the RTF style sheet table.
+ * This class belongs to the <jfor:stylesheet> tag processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+public class RtfStyleSheetTable
+{
+ //////////////////////////////////////////////////
+ // @@ Symbolic constants
+ //////////////////////////////////////////////////
+
+ /** Start index number for the stylesheet reference table */
+ private static int startIndex = 15;
+
+ /** OK status value for attribute handling */
+ public static int STATUS_OK = 0;
+ /** Status value for attribute handling, if the stylesheet not found and
+ * the stylesheet set to the default stylesheet */
+ public static int STATUS_DEFAULT = 1;
+
+ /** Standard style name */
+ private static String STANDARD_STYLE = "Standard";
+
+
+ //////////////////////////////////////////////////
+ // @@ Singleton
+ //////////////////////////////////////////////////
+
+ /** Singelton instance */
+ private static RtfStyleSheetTable instance = null;
+
+
+ //////////////////////////////////////////////////
+ // @@ Members
+ //////////////////////////////////////////////////
+
+
+ /** Table of styles */
+ private Hashtable styles = null;
+
+ /** Used, style attributes to this vector */
+ private Hashtable attrTable = null;
+
+ /** Used, style names to this vector */
+ private Vector nameTable = null;
+
+ /** Default style */
+ private String defaultStyleName = STANDARD_STYLE;
+
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Constructor.
+ */
+ private RtfStyleSheetTable ()
+ {
+ styles = new Hashtable ();
+ attrTable = new Hashtable ();
+ nameTable = new Vector ();
+ }
+
+ /**
+ * Singelton.
+ *
+ * @return The instance of RtfStyleSheetTable
+ */
+ public static RtfStyleSheetTable getInstance ()
+ {
+ if (instance == null)
+ {
+ instance = new RtfStyleSheetTable ();
+ }
+
+ return instance;
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Member access
+ //////////////////////////////////////////////////
+
+ /**
+ * Sets the default style.
+ * @param styleName Name of the default style, defined in the stylesheet
+ */
+ public void setDefaultStyle (String styleName)
+ {
+ this.defaultStyleName = styleName;
+ }
+
+ /**
+ * Gets the name of the default style.
+ * @return Default style name.
+ */
+ public String getDefaultStyleName ()
+ {
+ if (attrTable.get (defaultStyleName) != null)
+ return defaultStyleName;
+
+ if (attrTable.get (STANDARD_STYLE) != null)
+ {
+ defaultStyleName = STANDARD_STYLE;
+ return defaultStyleName;
+ }
+
+ return null;
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Public methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Adds a style to the table.
+ * @param name Name of style to add
+ * @param attrs Rtf attributes which defines the style
+ */
+ public void addStyle (String name, RtfAttributes attrs)
+ {
+ nameTable.addElement (name);
+ if (attrs != null)
+ attrTable.put (name, attrs);
+ styles.put (name, new Integer (nameTable.size () - 1 + startIndex));
+ }
+
+ /**
+ * Adds the style attributes to the given attributes.
+ * @param name Name of style, of which the attributes will copied to attr
+ * @param attrs Default rtf attributes
+ * @return Status value
+ */
+ public int addStyleToAttributes (String name, RtfAttributes attr)
+ {
+ // Sets status to ok
+ int status = STATUS_OK;
+
+ // Gets the style number from table
+ Integer style = (Integer) styles.get (name);
+
+ if (style == null && !name.equals (defaultStyleName))
+ {
+ // If style not found, and style was not the default style, try the default style
+ name = defaultStyleName;
+ style = (Integer) styles.get (name);
+ // set status for default style setting
+ status = STATUS_DEFAULT;
+ }
+
+ // Returns the status for invalid styles
+ if (style == null)
+ return status;
+
+ // Adds the attributes to default attributes, if not available in default attributes
+ attr.set ("cs", style.intValue ());
+
+ Object o = attrTable.get (name);
+ if (o != null)
+ {
+ RtfAttributes rtfAttr = (RtfAttributes) o;
+
+ for (Iterator names = rtfAttr.nameIterator (); names.hasNext ();)
+ {
+ String attrName = (String) names.next ();
+ if (! attr.isSet (attrName))
+ {
+ Integer i = (Integer) rtfAttr.getValue (attrName);
+ if (i == null)
+ attr.set (attrName);
+ else
+ attr.set (attrName, i.intValue ());
+ }
+ }
+ }
+ return status;
+ }
+
+ /**
+ * Writes the rtf style sheet table.
+ * @param header Rtf header is the parent
+ * @throws IOException On write error
+ */
+ public void writeStyleSheet (RtfHeader header) throws IOException
+ {
+ if (styles == null || styles.size () == 0)
+ {
+ return;
+ }
+ header.writeGroupMark (true);
+ header.writeControlWord ("stylesheet");
+
+ int number = nameTable.size ();
+ for (int i = 0; i < number; i++)
+ {
+ String name = (String) nameTable.elementAt (i);
+ header.writeGroupMark (true);
+ header.writeControlWord ("*\\" + this.getRtfStyleReference (name));
+
+ Object o = attrTable.get (name);
+ if (o != null)
+ {
+ header.writeAttributes ((RtfAttributes) o, RtfText.ATTR_NAMES);
+ header.writeAttributes ((RtfAttributes) o, RtfText.ALIGNMENT);
+ }
+
+ header.write (name + ";");
+ header.writeGroupMark (false);
+ }
+ header.writeGroupMark (false);
+ }
+
+ /**
+ * Gets the rtf style reference from the table.
+ * @param name Name of Style
+ * @return Rtf attribute of the style reference
+ */
+ private String getRtfStyleReference (String name)
+ {
+ return "cs" + styles.get (name).toString ();
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java
new file mode 100755
index 000000000..24eb35c4a
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java
@@ -0,0 +1,161 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.*;
+import java.util.Iterator;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+/** Container for RtfRow elements
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfTable extends RtfContainer
+{
+ private RtfTableRow m_row;
+ private int highestRow=0;
+
+ /** Added by Boris Poudérous on 07/22/2002 in order to process number-columns-spanned attribute */
+ private ITableColumnsInfo m_table_context;
+
+ /** Create an RTF element as a child of given container */
+ RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ // Line added by Boris Poudérous on 07/22/2002
+ m_table_context = tc;
+ }
+
+ /** Create an RTF element as a child of given container
+ * Modified by Boris Poudérous in order to process 'number-columns-spanned' attribute
+ */
+ RtfTable(IRtfTableContainer parent, Writer w, RtfAttributes attrs, ITableColumnsInfo tc) throws IOException
+ {
+ super((RtfContainer)parent,w,attrs);
+ // Line added by Boris Poudérous on 07/22/2002
+ m_table_context = tc;
+ }
+
+ /** close current row if any and start a new one */
+ public RtfTableRow newTableRow() throws IOException
+ {
+ if(m_row != null) m_row.close();
+
+ highestRow++;
+ m_row = new RtfTableRow(this,m_writer,m_attrib,highestRow);
+ return m_row;
+ }
+ /** close current row if any and start a new one */
+ public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException
+ {
+ RtfAttributes attr = null;
+ if (m_attrib != null)
+ {
+ attr = (RtfAttributes) m_attrib.clone ();
+ attr.set (attrs);
+ }
+ else
+ attr = attrs;
+ if(m_row != null) m_row.close();
+ highestRow++;
+
+ m_row = new RtfTableRow(this,m_writer,attr,highestRow);
+ return m_row;
+ }
+
+
+
+ /** overridden to write RTF prefix code, what comes before our children */
+ protected void writeRtfPrefix() throws IOException
+ {
+ writeGroupMark(true);
+ }
+
+ /** overridden to write RTF suffix code, what comes after our children */
+ protected void writeRtfSuffix() throws IOException
+ {
+ writeGroupMark(false);
+ }
+
+ public boolean isHighestRow(int id)
+ {
+ return (highestRow == id) ? true : false;
+ }
+
+ /** Added by Boris Poudérous on 07/22/2002 */
+ public ITableColumnsInfo getITableColumnsInfo()
+ {
+ return this.m_table_context;
+ }
+
+ private RtfAttributes m_header_attribs = null;
+
+ // Added by Normand Masse
+ // Support for table-header attributes (used instead of table attributes
+ public void setHeaderAttribs( RtfAttributes attrs ) {
+ m_header_attribs = attrs;
+ }
+
+ // Added by Normand Masse
+ // Returns the table-header attributes if they are present, otherwise the
+ // parent's attributes are returned normally.
+ public RtfAttributes getRtfAttributes() {
+ if ( m_header_attribs != null ) {
+ return m_header_attribs;
+ }
+
+ return super.getRtfAttributes();
+ }
+ /** - end - */
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java
new file mode 100755
index 000000000..62a24981d
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java
@@ -0,0 +1,417 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.*;
+import java.util.*;
+import org.jfor.jfor.interfaces.ITableColumnsInfo;
+
+/** A cell in an RTF table, container for paragraphs, lists, etc.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfTableCell
+extends RtfContainer
+implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExternalGraphicContainer {
+ private RtfParagraph m_paragraph;
+ private RtfList m_list;
+ private RtfTable m_table;
+ private RtfExternalGraphic m_externalGraphic;
+ private final RtfTableRow m_parentRow;
+ private boolean set_center;
+ private boolean set_right;
+ private int id;
+
+ public static final int DEFAULT_CELL_WIDTH = 2000;
+
+ /** cell width in twips */
+ private int m_cellWidth;
+ private int m_widthOffset;
+
+ /** cell merging has three states */
+ private int m_vMerge = NO_MERGE;
+ private int m_hMerge = NO_MERGE;
+
+ /** cell merging: this cell is not merged */
+ public final static int NO_MERGE = 0;
+
+ /** cell merging: this cell is the start of a range of merged cells */
+ public final static int MERGE_START = 1;
+
+ /** cell merging: this cell is part of (but not the start of) a range of merged cells */
+ public final static int MERGE_WITH_PREVIOUS = 2;
+
+ /** Create an RTF element as a child of given container */
+ RtfTableCell(RtfTableRow parent, Writer w,int cellWidth, int idNum) throws IOException {
+ super(parent,w);
+ id = idNum;
+ m_parentRow = parent;
+ m_cellWidth = cellWidth;
+ set_center = set_right = false;
+
+ }
+
+ /** Create an RTF element as a child of given container */
+ RtfTableCell(RtfTableRow parent, Writer w,int cellWidth, RtfAttributes attrs, int idNum) throws IOException {
+ super(parent,w,attrs);
+ id = idNum;
+ m_parentRow = parent;
+ m_cellWidth = cellWidth;
+
+ /** Added by Boris Poudérous on 07/22/2002 in order to process number-columns-spanned attribute */
+ // If the cell is spanned horizontally
+ if (attrs.getValue("number-columns-spanned") != null)
+ {
+ // Start horizontal merge
+ this.setHMerge(MERGE_START);
+
+ // Get the number of columns spanned
+ int nbMergedCells = ((Integer)attrs.getValue("number-columns-spanned")).intValue();
+
+ if (parent.m_parent instanceof RtfTable)
+ {
+ // Get the context of the current table in order to get the width of each column
+ ITableColumnsInfo ITableColumnsInfo = ((RtfTable)parent.m_parent).getITableColumnsInfo();
+ ITableColumnsInfo.selectFirstColumn();
+
+ // Reach the column index in table context corresponding to the current column cell
+ // id is the index of the current cell (it begins at 1)
+ // getColumnIndex() is the index of the current column in table context (it begins at 0)
+ // => so we must widthdraw 1 when comparing these two variables.
+ while ((this.id-1) != ITableColumnsInfo.getColumnIndex())
+ ITableColumnsInfo.selectNextColumn();
+
+ // We widthdraw one cell because the first cell is already created (it's the current cell) !
+ int i = nbMergedCells - 1;
+ while (i > 0)
+ {
+ ITableColumnsInfo.selectNextColumn();
+ // Added by Normand Masse
+ // Pass in the current cell's attributes so the 'merged' cell has the
+ // same display attributes.
+ parent.newTableCellMergedHorizontally((int)ITableColumnsInfo.getColumnWidth(), attrs);
+
+ i--;
+ }
+ }
+ }
+ /** - end - */
+ }
+
+ /** start a new paragraph after closing current current paragraph, list and table */
+ public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
+ closeAll();
+
+ // in tables, RtfParagraph must have the intbl attribute
+ if(attrs==null) attrs = new RtfAttributes();
+ attrs.set("intbl");
+
+ m_paragraph = new RtfParagraph(this,m_writer,attrs);
+
+ if(m_paragraph.m_attrib.isSet("qc"))
+ {
+ set_center=true;
+ attrs.set("qc");
+ }
+ else if(m_paragraph.m_attrib.isSet("qr"))
+ {
+ set_right=true;
+ attrs.set("qr");
+ }
+ else
+ {
+ attrs.set("ql");
+ }
+ attrs.set("intbl");
+
+
+ //lines modified by Chris Scott, Westinghouse
+ return m_paragraph;
+ }
+
+ /** start a new external graphic after closing current paragraph, list and table */
+ public RtfExternalGraphic newImage() throws IOException {
+ closeAll();
+ m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ return m_externalGraphic;
+ }
+
+ /** start a new paragraph with default attributes after closing current paragraph, list and table */
+ public RtfParagraph newParagraph() throws IOException {
+ return newParagraph(null);
+ }
+
+ /** start a new list after closing current paragraph, list and table */
+ public RtfList newList(RtfAttributes attrib) throws IOException {
+ closeAll();
+ m_list = new RtfList(this,m_writer,attrib);
+ return m_list;
+ }
+
+ /** start a new nested table after closing current paragraph, list and table */
+ public RtfTable newTable(ITableColumnsInfo tc) throws IOException {
+ closeAll();
+ m_table = new RtfTable(this,m_writer,tc);
+ return m_table;
+ }
+
+ /** start a new nested table after closing current paragraph, list and table */ // Modified by Boris Poudérous on 07/22/2002
+ public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException
+ {
+ closeAll();
+ m_table = new RtfTable(this,m_writer, attrs, tc); // Added tc Boris Poudérous 07/22/2002
+ return m_table;
+ }
+
+ /** used by RtfTableRow to write the <celldef> cell definition control words
+ * @param widthOffset sum of the widths of preceeding cells in same row
+ * @return widthOffset + width of this cell
+ */
+ int writeCellDef(int widthOffset) throws IOException {
+ m_widthOffset = widthOffset;
+
+ // vertical cell merge codes
+ if(m_vMerge == MERGE_START) {
+ writeControlWord("clvmgf");
+ } else if(m_vMerge == MERGE_WITH_PREVIOUS) {
+ writeControlWord("clvmrg");
+ }
+
+ // horizontal cell merge codes
+ if(m_hMerge == MERGE_START) {
+ writeControlWord("clmgf");
+ } else if(m_hMerge == MERGE_WITH_PREVIOUS) {
+ writeControlWord("clmrg");
+ }
+
+ /**
+ * Added by Boris POUDEROUS on 2002/06/26
+ */
+ // Cell background color processing :
+ writeAttributes (m_attrib, ITableAttributes.CELL_COLOR);
+ /** - end - */
+
+ writeAttributes (m_attrib, ITableAttributes.ATTRIB_CELL_PADDING);
+ writeAttributes (m_attrib, ITableAttributes.CELL_BORDER);
+ writeAttributes (m_attrib, BorderAttributesConverter.BORDERS);
+
+ // cell width
+ final int xPos = widthOffset + this.m_cellWidth;
+
+ //these lines added by Chris Scott, Westinghouse
+ //some attributes need to be writting before opening block
+ if(set_center)
+ {
+ writeControlWord("qc");
+ }
+ else if (set_right)
+ {
+ writeControlWord("qr");
+ }
+ else
+ {
+ writeControlWord("ql");
+ }
+
+ writeControlWord("cellx" + xPos);
+
+ writeControlWord( "ql" );
+
+ return xPos;
+
+ }
+
+ /** the "cell" control word marks the end of a cell */
+ protected void writeRtfSuffix() throws IOException {
+ // word97 hangs if cell does not contain at least one "par" control word
+ // TODO this is what causes the extra spaces in nested table of test 004-spacing-in-tables.fo,
+ // but if is not here we generate invalid RTF for word97
+
+ if(set_center)
+ {
+ writeControlWord("qc");
+ }
+ else if (set_right)
+ {
+ writeControlWord("qr");
+ }
+ else
+ {
+ writeControlWord("ql");
+ }
+
+
+
+ if(!containsText()) {
+ writeControlWord("intbl");
+
+ //R.Marra this create useless paragraph
+ //Seem working into Word97 with the "intbl" only
+// writeControlWord("par");
+ }
+
+ writeControlWord("cell");
+ }
+
+
+ //modified by Chris Scott, Westinghouse
+ private void closeCurrentParagraph() throws IOException {
+ if(m_paragraph!=null)
+ {
+ m_paragraph.close();
+ }
+ }
+
+ private void closeCurrentList() throws IOException {
+ if(m_list!=null) m_list.close();
+ }
+
+ private void closeCurrentTable() throws IOException {
+ if(m_table!=null) m_table.close();
+ }
+
+ private void closeCurrentExternalGraphic() throws IOException {
+ if(m_externalGraphic!=null) m_externalGraphic.close();
+ }
+
+ private void closeAll()
+ throws IOException {
+ closeCurrentTable();
+ closeCurrentParagraph();
+ closeCurrentList();
+ closeCurrentExternalGraphic();
+ }
+
+ /** set vertical cell merging status */
+ public void setVMerge(int mergeStatus) { this.m_vMerge = mergeStatus; }
+ /** get vertical cell merging status */
+ public int getVMerge() { return this.m_vMerge; }
+ /** set horizontal cell merging status */
+ public void setHMerge(int mergeStatus) { this.m_hMerge = mergeStatus; }
+ /** get horizontal cell merging status */
+ public int getHMerge() { return this.m_hMerge; }
+ /** get cell width */
+ int getCellWidth() { return this.m_cellWidth; }
+
+ /** overridden so that nested tables cause extra rows to be added after the row
+ * that contains this cell
+ * disabled for V0.3 - nested table support is not done yet
+ */
+ protected void writeRtfContent()
+ throws IOException {
+ int extraRowIndex = 0;
+ RtfTableCell extraCell = null;
+
+ for(Iterator it = getChildren().iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(e instanceof RtfTable) {
+ // nested table - render its cells in supplementary rows after current row,
+ // and put the remaining content of this cell in a new cell after nested table
+ // Line added by Boris Poudérous
+ m_parentRow.getExtraRowSet().setParentITableColumnsInfo(((RtfTable)this.getParentOfClass(e.getClass())).getITableColumnsInfo());
+ extraRowIndex = m_parentRow.getExtraRowSet().addTable((RtfTable)e,extraRowIndex,m_widthOffset);
+ // Boris Poudérous added the passing of the current cell attributes to the new cells (in order not to have cell without border for example)
+ extraCell = m_parentRow.getExtraRowSet().createExtraCell(extraRowIndex,m_widthOffset,this.getCellWidth(), m_attrib);
+ extraRowIndex++;
+
+ } else if(extraCell!=null) {
+ // we are after a nested table, add elements to the extra cell created for them
+ extraCell.addChild(e);
+
+ } else {
+ // before a nested table, normal rendering
+ e.writeRtf();
+ }
+ }
+ }
+
+ /** A table cell always contains "useful" content, as it is here to take some
+ * space in a row.
+ * Use containsText() to find out if there is really some useful content in the cell.
+ * TODO: containsText could use the original isEmpty implementation?
+ */
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ /** true if the "par" control word must be written for given RtfParagraph
+ * (which is not the case for the last non-empty paragraph of the cell)
+ */
+ boolean paragraphNeedsPar(RtfParagraph p)
+ {
+ // true if there is at least one non-empty paragraph after p in our children
+ boolean pFound = false;
+ boolean result = false;
+ for(Iterator it = getChildren().iterator(); it.hasNext(); ) {
+ final Object o = it.next();
+ if(!pFound) {
+ // set pFound when p is found in the list
+ pFound = (o == p);
+ } else {
+ if (o instanceof RtfParagraph) {
+ final RtfParagraph p2 = (RtfParagraph)o;
+ if(!p2.isEmpty()) {
+ // found a non-empty paragraph after p
+ result = true;
+ break;
+ }
+ }
+ else if (o instanceof RtfTable) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java
new file mode 100755
index 000000000..934f1b9fc
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java
@@ -0,0 +1,345 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.*;
+import java.util.*;
+
+/** Container for RtfTableCell elements
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ * @author Andreas Putz a.putz@skynamics.com
+ * @author Roberto Marra roberto@link-u.com
+ */
+
+public class RtfTableRow extends RtfContainer implements ITableAttributes {
+ private RtfTableCell m_cell;
+ private RtfExtraRowSet m_extraRowSet;
+ private int id;
+ private int highestCell=0;
+
+
+ /** Create an RTF element as a child of given container */
+ RtfTableRow(RtfTable parent, Writer w, int idNum) throws IOException {
+ super(parent,w);
+ id = idNum;
+ }
+
+ /** Create an RTF element as a child of given container */
+ RtfTableRow(RtfTable parent, Writer w, RtfAttributes attrs, int idNum) throws IOException {
+ super(parent,w,attrs);
+ id=idNum;
+ }
+
+ /** close current cell if any and start a new one */
+ public RtfTableCell newTableCell(int cellWidth) throws IOException {
+ highestCell++;
+ m_cell = new RtfTableCell(this,m_writer,cellWidth,highestCell);
+ return m_cell;
+ }
+
+ /** close current cell if any and start a new one */
+ public RtfTableCell newTableCell(int cellWidth, RtfAttributes attrs) throws IOException {
+ highestCell++;
+ m_cell = new RtfTableCell(this,m_writer,cellWidth, attrs,highestCell);
+ return m_cell;
+ }
+
+ /**
+ * Added by Boris POUDEROUS on 07/02/2002
+ * in order to add an empty cell that is merged with the cell above.
+ * This cell is placed before or after the nested table.
+ */
+ public RtfTableCell newTableCellMergedVertically(int cellWidth, RtfAttributes attrs) throws IOException {
+ highestCell++;
+ m_cell = new RtfTableCell (this, m_writer, cellWidth, attrs, highestCell);
+ m_cell.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ return m_cell;
+ }
+
+ /**
+ * Added by Boris POUDEROUS on 07/02/2002
+ * in order to add an empty cell that is merged with the previous cell.
+ */
+ public RtfTableCell newTableCellMergedHorizontally (int cellWidth, RtfAttributes attrs) throws IOException {
+ highestCell++;
+ // Added by Normand Masse
+ // Inherit attributes from base cell for merge
+ RtfAttributes wAttributes = (RtfAttributes)attrs.clone();
+ wAttributes.unset( "number-columns-spanned" );
+
+ m_cell = new RtfTableCell(this,m_writer,cellWidth,wAttributes,highestCell);
+ m_cell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ return m_cell;
+ }
+
+ protected void writeRtfPrefix() throws IOException {
+ writeGroupMark(true);
+ }
+
+ /** overridden to write trowd and cell definitions before writing our cells */
+ protected void writeRtfContent() throws IOException {
+
+ // create new extra row set to allow our cells to put nested tables
+ // in rows that will be rendered after this one
+ m_extraRowSet = new RtfExtraRowSet(m_writer);
+
+ // render the row and cells definitions
+ writeControlWord("trowd");
+
+ //check for keep-together
+ if(m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
+ writeControlWord(ROW_KEEP_TOGETHER);
+ }
+
+ writePaddingAttributes();
+
+ // if we have attributes, manipulate border properties
+ final RtfTable parentTable = (RtfTable) m_parent;
+ if(m_attrib != null && parentTable != null) {
+
+ //if table is only one row long
+ if(isFirstRow() && parentTable.isHighestRow(id)){
+ m_attrib.unset(ITableAttributes.ROW_BORDER_HORIZONTAL);
+ //or if row is the first row
+ }else if(isFirstRow()){
+ m_attrib.unset(ITableAttributes.ROW_BORDER_BOTTOM);
+ //or if row is the last row
+ }else if(parentTable.isHighestRow(id)){
+ m_attrib.unset(ITableAttributes.ROW_BORDER_TOP);
+ //else the row is an inside row
+ }else{
+ m_attrib.unset(ITableAttributes.ROW_BORDER_BOTTOM);
+ m_attrib.unset(ITableAttributes.ROW_BORDER_TOP);
+ }
+ }
+
+ writeAttributes(m_attrib,ITableAttributes.ROW_BORDER);
+ writeAttributes(m_attrib,ITableAttributes.CELL_BORDER);
+ writeAttributes(m_attrib,BorderAttributesConverter.BORDERS);
+
+ /**
+ * Added by Boris POUDEROUS on 07/02/2002
+ * in order to get the indexes of the cells preceding a cell that contains a nested table.
+ * Thus, the cells of the extra row will be merged with the cells above.
+ */
+ boolean nestedTableFound = false;
+ int index = 0; // Used to store the index of the cell that contains a nested table
+ int numberOfCellsBeforeNestedTable = 0;
+
+ java.util.Vector indexesFound = new java.util.Vector();
+ for (Iterator it = getChildren().iterator(); it.hasNext(); )
+ {
+ final RtfElement e = (RtfElement)it.next();
+
+ if (e instanceof RtfTableCell)
+ {
+ if (!nestedTableFound)
+ ++numberOfCellsBeforeNestedTable;
+
+ for (Iterator it2 = ((RtfTableCell)e).getChildren().iterator(); it2.hasNext(); )
+ {
+ final RtfElement subElement = (RtfElement)it2.next();
+ if (subElement instanceof RtfTable)
+ {
+ nestedTableFound = true;
+ indexesFound.addElement(new Integer(index));
+ }
+ else if (subElement instanceof RtfParagraph)
+ {
+ for (Iterator it3 = ((RtfParagraph)subElement).getChildren().iterator(); it3.hasNext(); )
+ {
+ final RtfElement subSubElement = (RtfElement)it3.next();
+ if (subSubElement instanceof RtfTable)
+ {
+ nestedTableFound = true;
+ indexesFound.addElement(new Integer(index));
+ }
+ }
+ }
+ }
+ }
+
+ index++;
+ }
+ /** - end - */
+
+ // write X positions of our cells
+ int xPos = 0;
+ index = 0; // Line added by Boris POUDEROUS on 07/02/2002
+ for(Iterator it = getChildren().iterator(); it.hasNext(); ) {
+ final RtfElement e = (RtfElement)it.next();
+ if(e instanceof RtfTableCell) {
+ /**
+ * Added by Boris POUDEROUS on 2002/07/02
+ */
+ // If one of the row's child cells contains a nested table :
+ if (!indexesFound.isEmpty())
+ {
+ for (int i = 0; i < indexesFound.size(); i++)
+ {
+ // If the current cell index is equals to the index of the cell that
+ // contains a nested table => NO MERGE
+ if (index == ((Integer)indexesFound.get(i)).intValue())
+ break;
+
+ // If the current cell index is lower than the index of the cell that
+ // contains a nested table => START VERTICAL MERGE
+ else if (index < ((Integer)indexesFound.get(i)).intValue())
+ {
+ ((RtfTableCell)e).setVMerge(RtfTableCell.MERGE_START);
+ break;
+ }
+
+ // If the current cell index is greater than the index of the cell that
+ // contains a nested table => START VERTICAL MERGE
+ else if (index > ((Integer)indexesFound.get(i)).intValue())
+ {
+ ((RtfTableCell)e).setVMerge(RtfTableCell.MERGE_START);
+ break;
+ }
+ }
+ }
+ /** - end - */
+
+ // Added by Normand Masse
+ // Adjust the cell's display attributes so the table's/row's borders
+ // are drawn properly.
+ RtfTableCell cell = (RtfTableCell)e;
+ if ( index == 0 ) {
+ if ( !cell.getRtfAttributes().isSet( ITableAttributes.CELL_BORDER_LEFT ) ) {
+ cell.getRtfAttributes().set( ITableAttributes.CELL_BORDER_LEFT,
+ (String)m_attrib.getValue( ITableAttributes.ROW_BORDER_LEFT ));
+ }
+ }
+
+ if ( index == this.getChildCount() -1 ) {
+ if ( !cell.getRtfAttributes().isSet( ITableAttributes.CELL_BORDER_RIGHT ) ) {
+ cell.getRtfAttributes().set( ITableAttributes.CELL_BORDER_RIGHT,
+ (String)m_attrib.getValue( ITableAttributes.ROW_BORDER_RIGHT ));
+ }
+ }
+
+ if ( isFirstRow() ) {
+ if ( !cell.getRtfAttributes().isSet( ITableAttributes.CELL_BORDER_TOP ) ) {
+ cell.getRtfAttributes().set( ITableAttributes.CELL_BORDER_TOP,
+ (String)m_attrib.getValue( ITableAttributes.ROW_BORDER_TOP ));
+ }
+ }
+
+ if ( parentTable.isHighestRow(id) ) {
+ if ( !cell.getRtfAttributes().isSet( ITableAttributes.CELL_BORDER_BOTTOM ) ) {
+ cell.getRtfAttributes().set( ITableAttributes.CELL_BORDER_BOTTOM,
+ (String)m_attrib.getValue( ITableAttributes.ROW_BORDER_BOTTOM ));
+ }
+ }
+
+ xPos = cell.writeCellDef(xPos);
+ }
+ index++; // Added by Boris POUDEROUS on 2002/07/02
+ }
+
+ // now children can write themselves, we have the correct RTF prefix code
+ super.writeRtfContent();
+ }
+
+ /** overridden to write RTF suffix code, what comes after our children */
+ protected void writeRtfSuffix() throws IOException {
+ writeControlWord("row");
+
+ // write extra rows if any
+ m_extraRowSet.writeRtf();
+ writeGroupMark(false);
+ }
+
+ RtfExtraRowSet getExtraRowSet() {
+ return m_extraRowSet;
+ }
+
+ private void writePaddingAttributes()
+ throws IOException {
+ // Row padding attributes generated in the converter package
+ // use RTF 1.6 definitions - try to compute a reasonable RTF 1.5 value out of them if present
+ // how to do vertical padding with RTF 1.5?
+ if(m_attrib != null && !m_attrib.isSet(ATTR_RTF_15_TRGAPH)) {
+ int gaph = -1;
+ try {
+ // set (RTF 1.5) gaph to the average of the (RTF 1.6) left and right padding values
+ final Integer leftPadStr = (Integer)m_attrib.getValue(ATTR_ROW_PADDING_LEFT);
+ if(leftPadStr != null) gaph = leftPadStr.intValue();
+ final Integer rightPadStr = (Integer)m_attrib.getValue(ATTR_ROW_PADDING_RIGHT);
+ if(rightPadStr != null) gaph = (gaph + rightPadStr.intValue()) / 2;
+ } catch(Exception e) {
+ final String msg = "RtfTableRow.writePaddingAttributes: " + e.toString();
+ getRtfFile().getLog().logWarning(msg);
+ }
+ if(gaph >= 0) {
+ m_attrib.set(ATTR_RTF_15_TRGAPH,gaph);
+ }
+ }
+
+ // write all padding attributes
+ writeAttributes(m_attrib, ATTRIB_ROW_PADDING);
+ }
+
+ public boolean isFirstRow(){
+ if(id == 1)
+ return true;
+ else
+ return false;
+ }
+
+ public boolean isHighestCell(int id) {
+ return (highestCell == id) ? true : false;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java
new file mode 100644
index 000000000..40c8d62c9
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java
@@ -0,0 +1,130 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import java.io.File;
+
+/**
+ * Singelton of the RTF style template
+ * This class belongs to the <jfor:style-template> tag processing.
+ */
+
+public class RtfTemplate {
+
+ /** Singelton instance */
+ private static RtfTemplate instance = null;
+
+ private String templateFilePath = null;
+
+ /**
+ * Constructor.
+ */
+ private RtfTemplate ()
+ {
+
+ }
+
+
+ /**
+ * Singelton.
+ *
+ * @return The instance of RtfTemplate
+ */
+ public static RtfTemplate getInstance ()
+ {
+ if (instance == null) {
+ instance = new RtfTemplate();
+ }
+
+ return instance;
+ }
+
+
+ /**
+ *Set the template file and adjust tha path separator
+ *
+ *@param templateFilePath The full path of the template
+ **/
+ public void setTemplateFilePath(String templateFilePath) throws IOException {
+ // no validity checks here - leave this to the RTF client
+ if(templateFilePath == null) {
+ this.templateFilePath = null;
+ } else {
+ this.templateFilePath = templateFilePath.trim();
+ }
+ }
+
+ /**
+ * Write the rtf template
+ * @param header Rtf header is the parent
+ * @throws IOException On write error
+ */
+ public void writeTemplate (RtfHeader header) throws IOException
+ {
+ if (templateFilePath == null || templateFilePath.length() == 0) return;
+
+ header.writeGroupMark (true);
+ header.writeControlWord ("template");
+ header.writeRtfString(this.templateFilePath);
+ header.writeGroupMark (false);
+
+ header.writeGroupMark (true);
+ header.writeControlWord ("linkstyles");
+ header.writeGroupMark (false);
+ }
+}
+
+
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java
new file mode 100755
index 000000000..fba214ed7
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java
@@ -0,0 +1,297 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/** Model of a text run (a piece of text with attributes) in an RTF document
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+public class RtfText extends RtfElement
+{
+ // char code for non-breakable space
+ private static final int CHAR_NBSP = 160;
+ private static final int CHAR_TAB = 137;
+ private static final int CHAR_NEW_LINE = 141;
+ /* these next two variables are used to encode bold formating in the
+ * raw xml text. Usefull when specific words or phrases are to be bolded
+ * but their placement and length change. Thus the bold formatting becomes
+ * part of the data. The same method can be used for implementing other types
+ * of raw text formatting.
+ */
+ private static final int CHAR_BOLD_START = 130;
+ private static final int CHAR_BOLD_END = 131;
+
+ /** members */
+ private String m_text;
+ private final RtfAttributes m_attr;
+
+
+ /** RtfText attributes: attribute names are RTF control word names to avoid additional mapping */
+ public static final String ATTR_BOLD = "b";
+ public static final String ATTR_ITALIC = "i";
+ public static final String ATTR_UNDERLINE = "ul";
+ public static final String ATTR_FONT_SIZE = "fs";
+ public static final String ATTR_FONT_FAMILY = "f";
+ public static final String ATTR_FONT_COLOR = "cf";
+ public static final String ATTR_BACKGROUND_COLOR = "chcbpat"; // Added by Boris on 06/25//02
+
+ /** RtfText attributes: alignment attributes */
+ public static String ALIGN_CENTER = "qc";
+ public static String ALIGN_LEFT = "ql";
+ public static String ALIGN_RIGHT = "qr";
+ public static String ALIGN_JUSTIFIED = "qj";
+ public static String ALIGN_DISTRIBUTED = "qd";
+
+ /** RtfText attributes: border attributes */
+ //added by Chris Scott
+ public static String BDR_BOTTOM_SINGLE = "brdrb\\brsp40\\brdrs";
+ public static String BDR_BOTTOM_DOUBLE = "brdrb\\brsp40\\brdrdb";
+ public static String BDR_BOTTOM_EMBOSS = "brdrb\\brsp40\\brdremboss";
+ public static String BDR_BOTTOM_DOTTED = "brdrb\\brsp40\\brdrdot";
+ public static String BDR_BOTTOM_DASH = "brdrb\\brsp40\\brdrdash";
+
+ /** RtfText attributes: fields */
+ //must be carefull of group markings and star control
+ //ie page field:
+ // "{\field {\*\fldinst {PAGE}} {\fldrslt}}"
+ public static String RTF_FIELD = "field";
+ public static String RTF_FIELD_PAGE = "fldinst { PAGE }";
+ public static String RTF_FIELD_RESULT = "fldrslt";
+
+ /**RtfText attributes: indentation attributes */
+ //added by Chris Scott
+ public static String LEFT_INDENT_BODY = "li";
+ public static String LEFT_INDENT_FIRST = "fi-";
+
+ public static String TAB_CENTER = "tqc\\tx";
+ public static String TAB_RIGHT = "tqr\\tx";
+ public static String TAB_LEADER_DOTS = "tldot";
+ public static String TAB_LEADER_HYPHEN = "tlhyph";
+ public static String TAB_LEADER_UNDER = "tlul";
+ public static String TAB_LEADER_THICK = "tlth";
+ public static String TAB_LEADER_EQUALS = "tleq";
+
+ /** Space before/after a paragraph */
+ //these lines were added by Boris Pouderous
+ public static final String SPACE_BEFORE = "sb";
+ public static final String SPACE_AFTER = "sa";
+
+ /** RtfText attributes: this must contain all allignment attributes names */
+ public static String[] ALIGNMENT = new String []
+ {
+ ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_JUSTIFIED, ALIGN_DISTRIBUTED
+ };
+
+ /** RtfText attributes:: this must contain all border attribute names*/
+ //this line added by Chris Scott, Westinghouse
+ public static String[] BORDER = new String []
+ {
+ BDR_BOTTOM_SINGLE,BDR_BOTTOM_DOUBLE,BDR_BOTTOM_EMBOSS,BDR_BOTTOM_DOTTED,BDR_BOTTOM_DASH
+ };
+
+ public static String[] INDENT = new String []
+ {
+ LEFT_INDENT_BODY, LEFT_INDENT_FIRST
+ };
+
+ public static String[] TABS = new String []
+ {
+ TAB_CENTER ,TAB_RIGHT,TAB_LEADER_DOTS,TAB_LEADER_HYPHEN,TAB_LEADER_UNDER,
+ TAB_LEADER_THICK,TAB_LEADER_EQUALS
+ };
+
+
+ /** RtfText attributes: this must contain all attribute names */
+ public static final String [] ATTR_NAMES = {
+ ATTR_BOLD,
+ ATTR_ITALIC,
+ ATTR_UNDERLINE,
+ ATTR_FONT_SIZE,
+ ATTR_FONT_FAMILY,
+ ATTR_FONT_COLOR,
+ ATTR_BACKGROUND_COLOR
+ };
+
+ /** Create an RtfText in given IRtfTextContainer.
+ * @param str optional initial text content
+ */
+ RtfText(IRtfTextContainer parent,Writer w,String str,RtfAttributes attr) throws IOException
+ {
+ super((RtfContainer)parent,w);
+ m_text = str;
+ m_attr = attr;
+ }
+
+ /** write our text to the RTF stream */
+ public void writeRtfContent() throws IOException
+ {
+ writeChars: {
+
+ //these lines were added by Boris Pouderous
+ if (m_attr != null) {
+ writeAttributes(m_attr,new String[] {RtfText.SPACE_BEFORE});
+ writeAttributes(m_attr,new String[] {RtfText.SPACE_AFTER});
+ }
+
+ if(isTab()){
+ writeControlWord("tab");
+ }else if(isNewLine()){
+ break writeChars;
+ }else if(isBold(true)){
+ writeControlWord("b");
+ }else if(isBold(false)){
+ writeControlWord("b0");
+ }
+ // TODO not optimal, consecutive RtfText with same attributes could be written without group marks
+ else{
+ writeGroupMark(true);
+ if(m_attr != null && mustWriteAttributes()) {
+ writeAttributes(m_attr,RtfText.ATTR_NAMES);
+ }
+ RtfStringConverter.getInstance().writeRtfString(m_writer,m_text);
+ writeGroupMark(false);
+ }
+
+ }
+ }
+
+ /** true if our text attributes must be written */
+ private boolean mustWriteAttributes()
+ {
+ return !isEmpty() && !isNbsp();
+ }
+
+ /** IRtfTextContainer requirement: return a copy of our attributes */
+ public RtfAttributes getTextContainerAttributes() {
+ if(m_attrib == null) return null;
+ return (RtfAttributes)this.m_attrib.clone();
+ }
+
+ /** direct access to our text */
+ String getText()
+ {
+ return m_text;
+ }
+
+ /** direct access to our text */
+ void setText(String str)
+ {
+ m_text = str;
+ }
+
+ /**
+ * Checks whether the text is empty.
+ *
+ * @return
+ * true If m_text is null\n
+ * false m_text is set
+ */
+ public boolean isEmpty ()
+ {
+ return m_text == null || m_text.trim().length() == 0;
+ }
+
+ /**
+ * True if text contains a single non-breaking space (#160).
+ * TODO make this more general and/or merge with isEmpty? <-- what happen with empty paragraphs, if they will be removed, than NO, else ok
+ *
+ * @return
+ * true If m_text is character 160\n
+ * false m_text is not a nbsp
+ */
+ public boolean isNbsp ()
+ {
+ if (! isEmpty ())
+ if (m_text.trim ().length () == 1 && m_text.charAt (0) == CHAR_NBSP)
+ return true;
+ return false;
+ }
+
+ public boolean isTab()
+ {
+ if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_TAB)
+ return true;
+ else
+ return false;
+ }
+
+ public boolean isNewLine()
+ {
+ if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_NEW_LINE)
+ return true;
+ else
+ return false;
+ }
+
+ public boolean isBold(boolean isStart)
+ {
+ if(isStart){
+ if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_BOLD_START)
+ return true;
+ }else{
+ if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_BOLD_END)
+ return true;
+ else
+ return false;
+ }
+ return false;
+ }
+
+ /** get the attributes of our text */
+ public RtfAttributes getTextAttributes(){
+ return m_attr;
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
new file mode 100755
index 000000000..56a8bacf2
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
@@ -0,0 +1,119 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.rtfdoc;
+
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+/** Collapses whitespace of an RtfContainer that contains RtfText elements
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+class WhitespaceCollapser {
+ private final static String SPACE = " ";
+ private boolean m_lastEndSpace = true;
+
+ /** remove extra whitespace in RtfText elements that are inside c */
+ WhitespaceCollapser(RtfContainer c) {
+ // process all texts
+ for(Iterator it = c.getChildren().iterator(); it.hasNext(); ) {
+ RtfText current = null;
+ final Object kid = it.next();
+ if(kid instanceof RtfText) {
+ current = (RtfText)kid;
+ processText(current);
+ } else {
+ // if there is something between two texts, it counts for a space
+ m_lastEndSpace = true;
+ }
+ }
+ }
+
+ /** process one RtfText from our container */
+ private void processText(RtfText txt) {
+ final String orig = txt.getText();
+
+ // tokenize the text based on whitespace and regenerate it so as
+ // to collapse multiple spaces into one
+ if(orig != null && orig.length() > 0) {
+ final boolean allSpaces = orig.trim().length() == 0;
+ final boolean endSpace = allSpaces || Character.isWhitespace(orig.charAt(orig.length() - 1));
+ final boolean beginSpace = Character.isWhitespace(orig.charAt(0));
+ final StringBuffer sb = new StringBuffer(orig.length());
+
+ // if text contains spaces only, keep at most one
+ if(allSpaces) {
+ if(!m_lastEndSpace) sb.append(SPACE);
+ } else {
+ // TODO to be compatible with different Locales, should use Character.isWhitespace
+ // instead of this limited list
+ boolean first = true;
+ final StringTokenizer stk = new StringTokenizer(txt.getText()," \t\n\r");
+ while(stk.hasMoreTokens()) {
+ if(first && beginSpace && !m_lastEndSpace) {
+ sb.append(SPACE);
+ }
+ first = false;
+
+ sb.append(stk.nextToken());
+ if(stk.hasMoreTokens() || endSpace) {
+ sb.append(SPACE);
+ }
+ }
+ }
+
+ txt.setText(sb.toString());
+ m_lastEndSpace = endSpace;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java
new file mode 100755
index 000000000..222063d76
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java
@@ -0,0 +1,106 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+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 */
+ 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");
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java
new file mode 100755
index 000000000..1fa3cdbfb
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java
@@ -0,0 +1,122 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.io.File;
+import java.io.IOException;
+import org.jfor.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 {
+ public static final String TESTDOCS_PACKAGE = "org.apache.fop.rtf.rtflib.testdocs";
+
+ /** List of all TestDocument subclasses from this package */
+ private final static String [] classNames = {
+ "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 < classNames.length; i++) {
+ createOneTestDocument(classNames[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);
+ td.generateOutput();
+ }
+
+ /** execute this to create test documents from all classes listed in classNames array */
+ 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 jfor RTF library.");
+ final File outDir = new File(args[0]);
+ new CreateTestDocuments(outDir);
+ System.err.println("CreateTestDocuments - all done.");
+ System.exit(0);
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java
new file mode 100644
index 000000000..03a984d7f
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java
@@ -0,0 +1,85 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import org.jfor.jfor.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() {
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java
new file mode 100755
index 000000000..ccaa52459
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java
@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfExternalGraphic;
+import org.apache.fop.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();
+
+ }
+
+
+
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java
new file mode 100755
index 000000000..32bc9266c
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java
@@ -0,0 +1,96 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java
new file mode 100755
index 000000000..dfa4f8d53
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java
@@ -0,0 +1,137 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** Generates an RTF test document containing merged table cells
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+class MergedTableCells extends TestDocument
+{
+ /** 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());
+ final int MM_TO_TWIPS = (int)(1440f / 25.4f);
+
+ // first row, test horizontal merging
+ {
+ RtfTableRow r = tbl.newTableRow();
+ RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
+ c.setHMerge(c.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(c.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(c.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(c.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(c.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(c.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(c.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(c.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");
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java
new file mode 100755
index 000000000..9be4e0f52
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java
@@ -0,0 +1,212 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+/** 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.");
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java
new file mode 100755
index 000000000..3d31fcbd4
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java
@@ -0,0 +1,98 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfExternalGraphic;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfText;
+import org.apache.fop.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
+{
+
+ public ParagraphAlignment()
+ {
+ }
+ 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();
+ }
+}
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java
new file mode 100755
index 000000000..fa20fe372
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java
@@ -0,0 +1,78 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java
new file mode 100755
index 000000000..129fba3e4
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java
@@ -0,0 +1,98 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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):");
+ final RtfList.NumberingStyle nn = new RtfList.NumberingStyle();
+ nn.isBulletedList = false;
+ makeList(sect,3,4,nn);
+ }
+
+ private void makeList(RtfSection sect,int listIndex,int nItems,RtfList.NumberingStyle ns)
+ throws IOException
+ {
+ final RtfList list = sect.newList(null);
+ if(ns != null) list.setNumberingStyle(ns);
+ 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);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java
new file mode 100755
index 000000000..06f43d9e2
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java
@@ -0,0 +1,92 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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 */
+ protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ throws IOException {
+ final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
+ final int MAX_ROW = 2;
+ final int MAX_COL = 3;
+
+ final int INCH_TO_TWIPS = 1440;
+ final int c1w = 4;
+ 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.");
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java
new file mode 100755
index 000000000..118e4f426
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java
@@ -0,0 +1,113 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import org.jfor.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 m_output;
+
+ final void setOutputDir(File outDir)
+ throws IOException
+ {
+ m_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 " + m_output + "...");
+ final RtfFile f = new RtfFile(new FileWriter(m_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();
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java
new file mode 100755
index 000000000..c5b87e4a5
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java
@@ -0,0 +1,90 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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");
+ }
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java
new file mode 100755
index 000000000..cffac2c92
--- /dev/null
+++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java
@@ -0,0 +1,90 @@
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * The RTF library of the FOP project consists of voluntary contributions made by
+ * many individuals on behalf of the Apache Software Foundation and was originally
+ * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and contributors of
+ * the jfor project (www.jfor.org), who agreed to donate jfor to the FOP project.
+ * For more information on the Apache Software Foundation, please
+ * see <http://www.apache.org/>.
+ */
+package org.apache.fop.rtf.rtflib.testdocs;
+
+import java.util.Date;
+import java.io.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.*;
+
+/** 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.");
+ }
+} \ No newline at end of file