From db41ac7d21d2085242223aaafcd6062424020fbc Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Mon, 30 Jun 2003 17:45:33 +0000 Subject: [PATCH] style changes only. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196547 13f79535-47bb-0310-9956-ffa450edef68 --- .../IRtfPageNumberCitationContainer.java | 5 +- .../rtfdoc/IRtfPageNumberContainer.java | 5 +- .../rtflib/rtfdoc/IRtfParagraphContainer.java | 7 +- .../IRtfParagraphKeepTogetherContainer.java | 2 +- .../rtf/rtflib/rtfdoc/IRtfTableContainer.java | 10 +-- .../rtf/rtflib/rtfdoc/IRtfTextContainer.java | 11 ++- .../rtflib/rtfdoc/IrtfTemplateContainer.java | 2 +- .../rtfdoc/ParagraphKeeptogetherContext.java | 21 +++-- .../fop/rtf/rtflib/rtfdoc/RtfAfter.java | 8 +- .../rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java | 35 ++++---- .../fop/rtf/rtflib/testdocs/BasicLink.java | 15 ++-- .../rtflib/testdocs/CreateTestDocuments.java | 17 ++-- .../testdocs/DummyTableColumnsInfo.java | 3 +- .../rtf/rtflib/testdocs/ExternalGraphic.java | 21 ++--- .../fop/rtf/rtflib/testdocs/ListInTable.java | 40 +++++---- .../rtf/rtflib/testdocs/MergedTableCells.java | 21 +++-- .../fop/rtf/rtflib/testdocs/NestedTable.java | 86 ++++++++++++------ .../rtflib/testdocs/ParagraphAlignment.java | 7 +- .../rtf/rtflib/testdocs/SimpleDocument.java | 15 ++-- .../fop/rtf/rtflib/testdocs/SimpleLists.java | 39 ++++---- .../fop/rtf/rtflib/testdocs/SimpleTable.java | 26 +++--- .../fop/rtf/rtflib/testdocs/TestDocument.java | 32 +++---- .../rtf/rtflib/testdocs/TextAttributes.java | 27 +++--- .../fop/rtf/rtflib/testdocs/Whitespace.java | 19 ++-- .../fop/rtf/rtflib/tools/ImageConstants.java | 11 +-- .../fop/rtf/rtflib/tools/ImageUtil.java | 90 +++++++------------ 26 files changed, 303 insertions(+), 272 deletions(-) diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java index 116d29922..5814de4dc 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberCitationContainer.java @@ -60,7 +60,6 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.IOException; -public interface IRtfPageNumberCitationContainer -{ - public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException; +public interface IRtfPageNumberCitationContainer { + 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 index 9d3f17bca..dcbd9b4be 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageNumberContainer.java @@ -60,7 +60,6 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.IOException; -public interface IRtfPageNumberContainer -{ - public RtfPageNumber newPageNumber() throws IOException; +public interface IRtfPageNumberContainer { + 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 index 399dd431c..19dab0539 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphContainer.java @@ -64,12 +64,11 @@ import java.io.IOException; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfParagraphContainer -{ +public interface IRtfParagraphContainer { /** close current paragraph if any and start a new one with default attributes */ - public RtfParagraph newParagraph() throws IOException; + RtfParagraph newParagraph() throws IOException; /** close current paragraph if any and start a new one with specified attributes */ - public RtfParagraph newParagraph(RtfAttributes attr) throws IOException; + 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 index 2d2762b2d..0d6b0d197 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfParagraphKeepTogetherContainer.java @@ -63,5 +63,5 @@ import java.io.IOException; public interface IRtfParagraphKeepTogetherContainer { /** close current paragraph if any and start a new one */ - public RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException; + 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 index ae7a0033d..9a8d5711f 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTableContainer.java @@ -65,13 +65,13 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfTableContainer -{ +public interface IRtfTableContainer { /** close current table if any and start a new one */ - public RtfTable newTable(ITableColumnsInfo tc) throws IOException; + 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 + * @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; + 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 index 6bf2166e8..334ac275d 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfTextContainer.java @@ -64,23 +64,22 @@ import java.io.IOException; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfTextContainer -{ +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; + 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; + RtfText newText(String str) throws IOException; /** add a line break */ - public void newLineBreak() throws IOException; + 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(); + RtfAttributes getTextContainerAttributes(); } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java index cd5684afa..6ffacb1bd 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IrtfTemplateContainer.java @@ -68,7 +68,7 @@ public interface IrtfTemplateContainer { * * @exception IOException on error */ - public RtfTemplate newTemplate (String str, RtfAttributes attr) throws IOException; + 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 index 2abc9c664..28fdc68bd 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java @@ -67,8 +67,8 @@ package org.apache.fop.rtf.rtflib.rtfdoc; public class ParagraphKeeptogetherContext { - private static int m_paraKeepTogetherOpen=0; - private static boolean m_paraResetProperties=false; + private static int m_paraKeepTogetherOpen = 0; + private static boolean m_paraResetProperties = false; private static ParagraphKeeptogetherContext m_instance = null; ParagraphKeeptogetherContext() { @@ -81,11 +81,15 @@ public class ParagraphKeeptogetherContext { * @return The instance of ParagraphKeeptogetherContext */ public static ParagraphKeeptogetherContext getInstance() { - if (m_instance==null) m_instance = new ParagraphKeeptogetherContext(); + if (m_instance == null) { + m_instance = new ParagraphKeeptogetherContext(); + } return m_instance; } - /** Return the level of current "keep whith next" paragraph */ + /** + * @return the level of current "keep whith next" paragraph + */ public static int getKeepTogetherOpenValue() { return m_paraKeepTogetherOpen; } @@ -97,12 +101,13 @@ public class ParagraphKeeptogetherContext { /** Close a "keep whith next" paragraph */ public static void KeepTogetherClose() { - if(m_paraKeepTogetherOpen > 0) { + if (m_paraKeepTogetherOpen > 0) { m_paraKeepTogetherOpen--; - //If the \pard control word is not present, the current paragraph inherits all paragraph properties. + //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); + m_paraResetProperties = (m_paraKeepTogetherOpen == 0); } } @@ -113,7 +118,7 @@ public class ParagraphKeeptogetherContext { /** Reset the flag if the paragraph properties have been resested */ public static void setParagraphResetPropertiesUsed() { - m_paraResetProperties=false; + 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 index ace758a09..facfc8c1b 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfter.java @@ -64,16 +64,16 @@ 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[]{ + public static final String FOOTER = "footer"; + public static final String[] FOOTER_ATTR = new String[]{ FOOTER }; RtfAfter(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException { - super(parent,w,attrs); + super(parent, w, attrs); } protected void writeMyAttributes() throws IOException { - writeAttributes(m_attrib,FOOTER_ATTR); + 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 index a92a7149c..142507216 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAfterBeforeBase.java @@ -59,8 +59,6 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.Writer; -import java.io.*; -import java.util.*; import java.io.IOException; import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; @@ -72,45 +70,51 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; abstract class RtfAfterBeforeBase extends RtfContainer -implements IRtfParagraphContainer, IRtfExternalGraphicContainer,IRtfTableContainer { +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); + super((RtfContainer)parent, w, attrs); m_attrib = attrs; } public RtfParagraph newParagraph() throws IOException { closeAll(); - m_para = new RtfParagraph(this,m_writer); + 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); + m_para = new RtfParagraph(this, m_writer, attrs); return m_para; } public RtfExternalGraphic newImage() throws IOException { closeAll(); - m_externalGraphic = new RtfExternalGraphic(this,m_writer); + m_externalGraphic = new RtfExternalGraphic(this, m_writer); return m_externalGraphic; } private void closeCurrentParagraph() throws IOException { - if(m_para!=null) m_para.close(); + if (m_para != null) { + m_para.close(); + } } private void closeCurrentExternalGraphic() throws IOException { - if(m_externalGraphic!=null) m_externalGraphic.close(); + if (m_externalGraphic != null) { + m_externalGraphic.close(); + } } private void closeCurrentTable() throws IOException { - if(m_table != null) m_table.close(); + if (m_table != null) { + m_table.close(); + } } protected void writeRtfPrefix() throws IOException { @@ -119,13 +123,13 @@ implements IRtfParagraphContainer, IRtfExternalGraphicContainer,IRtfTableContain } /** must be implemented to write the header or footer attributes */ - abstract protected void writeMyAttributes() throws IOException; + protected abstract void writeMyAttributes() throws IOException; protected void writeRtfSuffix() throws IOException { writeGroupMark(false); } - public RtfAttributes getAttributes(){ + public RtfAttributes getAttributes() { return m_attrib; } @@ -136,18 +140,19 @@ implements IRtfParagraphContainer, IRtfExternalGraphicContainer,IRtfTableContain } /** 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 + * @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); + 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); + 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/testdocs/BasicLink.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java index 4841ebb02..407ebc24c 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java @@ -58,7 +58,11 @@ package org.apache.fop.rtf.rtflib.testdocs; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfHyperLink; + import java.io.IOException; /** @@ -67,8 +71,7 @@ import java.io.IOException; * @author Andreas Putz */ -public class BasicLink extends TestDocument -{ +public class BasicLink extends TestDocument { ////////////////////////////////////////////////// // @@ Construction ////////////////////////////////////////////////// @@ -76,13 +79,11 @@ public class BasicLink extends TestDocument /** * Default constructor. */ - public BasicLink() - { + public BasicLink() { } /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException - { + protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { RtfParagraph p = sect.newParagraph (); p.newLineBreak(); p.newLineBreak(); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java index 807d2ab31..7795cf8b7 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -71,7 +71,7 @@ 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 = { + private static final String [] classNames = { "SimpleDocument", "TextAttributes", "SimpleTable", @@ -87,24 +87,25 @@ public class CreateTestDocuments { CreateTestDocuments(File outDir) throws Exception { - if(!outDir.isDirectory() || !outDir.canWrite()) { + 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); + 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) + 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); + } catch (Exception e) { + throw new Exception("unable to instantiate '" + className + + " as a TestDocument object: " + e); } td.setOutputDir(outDir); td.generateOutput(); @@ -113,7 +114,7 @@ public class CreateTestDocuments { /** 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) { + if (args.length < 1) { System.err.println("usage: CreateTestDocuments "); System.exit(1); } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java index f1341f97c..9a62c34ac 100644 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/DummyTableColumnsInfo.java @@ -68,8 +68,7 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; * @author bdelacretaz@codeconsult.ch */ -class DummyTableColumnsInfo implements ITableColumnsInfo -{ +class DummyTableColumnsInfo implements ITableColumnsInfo { public float getColumnWidth() { return INVALID_COLUM_WIDTH; diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java index 5545658c9..6b95c156e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ExternalGraphic.java @@ -69,8 +69,7 @@ import java.io.IOException; * * @author Andreas Putz */ -class ExternalGraphic extends TestDocument -{ +class ExternalGraphic extends TestDocument { private String file = "file:///tmp/jfor-images/logo."; ////////////////////////////////////////////////// @@ -80,13 +79,11 @@ class ExternalGraphic extends TestDocument /** * Default constructor. */ - public ExternalGraphic () - { + public ExternalGraphic () { } /** generate the body of the test document */ - protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException - { + protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException { RtfParagraph p = sect.newParagraph (); p.newLineBreak(); p.newLineBreak(); @@ -99,7 +96,7 @@ class ExternalGraphic extends TestDocument p.newLineBreak(); p.close(); - p = sect.newParagraph( ); + p = sect.newParagraph(); p.newLineBreak(); p.newText ("PNG image with 150 % width"); p.newLineBreak(); @@ -109,7 +106,7 @@ class ExternalGraphic extends TestDocument p.newLineBreak(); p.close(); - p = sect.newParagraph( ); + p = sect.newParagraph(); p.newLineBreak(); p.newLineBreak(); p.newText ("JPG image with width = 200px and height = 20 px"); @@ -121,11 +118,11 @@ class ExternalGraphic extends TestDocument p.newLineBreak(); p.close(); - p = sect.newParagraph( ); + 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.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"); @@ -134,7 +131,7 @@ class ExternalGraphic extends TestDocument p.newLineBreak(); p.close(); - p = sect.newParagraph( ); + p = sect.newParagraph(); p.newLineBreak(); p.newLineBreak(); p.newText ("GIF image"); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java index a77dd9bd5..8c3aafeaa 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ListInTable.java @@ -58,43 +58,51 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfList; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfListItem; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; /** Generates a simple RTF test document for the jfor rtflib package. */ -class ListInTable extends TestDocument -{ +class ListInTable extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + 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"); + 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("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++) { + 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++) { + 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) { + 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); + para.newText(". " + "This list must have " + nItems + + " items. " + txt + " " + txt + " " + txt); } } } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java index 338cd522c..1e99c7740 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java @@ -58,18 +58,21 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; /** Generates an RTF test document containing merged table cells * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -class MergedTableCells extends TestDocument -{ +class MergedTableCells extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { sect.newParagraph().newText("This document contains a table with some merged cells."); @@ -81,7 +84,8 @@ class MergedTableCells extends TestDocument 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.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); @@ -137,7 +141,8 @@ class MergedTableCells extends TestDocument // 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"); + 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 index 1854e3a65..e67d8c494 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/NestedTable.java @@ -58,9 +58,15 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; + /** Generates an RTF document to test nested tables with the jfor rtflib package. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ @@ -69,9 +75,10 @@ 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) + protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { - sect.newParagraph().newText("This document demonstrates pseudo-nested tables created using merged table cells"); + sect.newParagraph().newText("This document demonstrates pseudo-nested " + + "tables created using merged table cells"); firstTestTable(sect); RtfParagraph p = sect.newParagraph(); @@ -102,21 +109,27 @@ class NestedTable extends TestDocument { // 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."); + 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("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."); + 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."); + 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."); } } @@ -129,65 +142,80 @@ class NestedTable extends TestDocument { { 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."); + 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."); + 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("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); + 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."); + 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."); + 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"); + 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.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); + 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."); + 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("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); + 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."); + 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."); + 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."); } } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java index 379ebeb60..3c48bc0e2 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java @@ -60,7 +60,6 @@ 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; @@ -68,11 +67,9 @@ 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 class ParagraphAlignment extends TestDocument { - public ParagraphAlignment() - { + public ParagraphAlignment() { } protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException { diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java index 34b1e9b8c..68d9a6a1e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java @@ -58,25 +58,26 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; /** Generates a simple RTF test document for the jfor rtflib package. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class SimpleDocument -extends TestDocument -{ +extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + 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++) { + for (int i = 0; i < 242; i++) { para.newText("This is string " + i); para.newLineBreak(); } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java index a33291204..859645eb3 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleLists.java @@ -58,45 +58,50 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfList; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfListItem; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; /** Generates a simple RTF test document for the jfor rtflib package. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -class SimpleLists extends TestDocument -{ +class SimpleLists extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + 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); + makeList(sect, 1, 5, null); sect.newParagraph().newText("Normal paragraph between lists 1 and 2."); - makeList(sect,2,3,null); + 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); + makeList(sect, 3, 4, nn); } - private void makeList(RtfSection sect,int listIndex,int nItems,RtfList.NumberingStyle ns) - throws IOException - { + 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++) { + 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++) { + 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) { + 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); + para.newText(". " + "This list should have " + nItems + + " items. " + txt + " " + txt + " " + txt); } } } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java index 59e69e44b..b9aa459f6 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java @@ -58,16 +58,20 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; /** Generates a simple RTF test document for the jfor rtflib package. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ class SimpleTable extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); final int MAX_ROW = 2; @@ -75,18 +79,20 @@ class SimpleTable extends TestDocument { 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 + "''"); + 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++) { + for (int row = 0; row < MAX_ROW; row++) { final RtfTableRow r = tbl.newTableRow(); - for(int col=0; col < MAX_COL; col++) { + 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("(" + 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"); } } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java index c8ed60fb4..e2a7f4866 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java @@ -59,8 +59,14 @@ package org.apache.fop.rtf.rtflib.testdocs; import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.File; +import java.io.IOException; +import java.io.FileWriter; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfFile; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; //import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo; /** Base class for generating RTF documents used to test the jfor rtflib package. @@ -71,13 +77,11 @@ abstract class TestDocument { private File m_output; final void setOutputDir(File outDir) - throws IOException - { - m_output = new File(outDir,getRtfFilename()); + throws IOException { + m_output = new File(outDir, getRtfFilename()); } - final String getRtfFilename() - { + final String getRtfFilename() { // use class name for output filename final String name = getClass().getName(); final int pos = name.lastIndexOf('.'); @@ -85,26 +89,24 @@ abstract class TestDocument { } final void generateOutput() - throws IOException - { + 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); + generateDocument(rda, sect); f.flush(); } - protected abstract void generateDocument(RtfDocumentArea rda,RtfSection sect) throws IOException; + protected abstract void generateDocument(RtfDocumentArea rda, RtfSection sect) + throws IOException; - void debugMsg(String msg) - { + void debugMsg(String msg) { System.err.println(msg); } - protected void addIntroComments(RtfSection sect) throws IOException - { + protected void addIntroComments(RtfSection sect) throws IOException { final RtfParagraph para = sect.newParagraph(); para.newText("jfor RTF library test document."); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java index 547f51252..eadc3e919 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TextAttributes.java @@ -58,27 +58,30 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +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 */ -class TextAttributes extends TestDocument -{ +class TextAttributes extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + 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)); + 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 size 48\n", new RtfAttributes().set(RtfText.ATTR_FONT_SIZE, 96)); para.newText( "This is bold and italic\n", @@ -88,8 +91,8 @@ class TextAttributes extends TestDocument 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); + 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"); } diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java index 663f49bb2..f4a28d3f7 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/Whitespace.java @@ -58,21 +58,23 @@ package org.apache.fop.rtf.rtflib.testdocs; -import java.util.Date; -import java.io.*; -import org.apache.fop.rtf.rtflib.rtfdoc.*; +import java.io.IOException; + +import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection; +import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; /** Generates an RTF document to test the WhitespaceCollapser * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -class Whitespace extends TestDocument -{ +class Whitespace extends TestDocument { /** generate the body of the test document */ - protected void generateDocument(RtfDocumentArea rda,RtfSection sect) + 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("\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(); @@ -83,7 +85,8 @@ class Whitespace extends TestDocument 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."); + 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: "); diff --git a/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java b/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java index 0e217d480..d563fb60e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java +++ b/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java @@ -65,8 +65,7 @@ import java.util.Hashtable; * @author a.putz@skynamics.com (Andreas Putz) */ -public class ImageConstants -{ +public class ImageConstants { ////////////////////////////////////////////////// // @@ Symbolic constants ////////////////////////////////////////////////// @@ -107,12 +106,11 @@ public class ImageConstants /** Defines the file extensions and the RTF property belongs to */ public static Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable (); - static - { + static { SUPPORTED_IMAGE_TYPES.put (EMF_EXT, new Integer (I_EMF)); SUPPORTED_IMAGE_TYPES.put (PNG_EXT, new Integer (I_PNG)); SUPPORTED_IMAGE_TYPES.put (JPG_EXT, new Integer (I_JPG_C)); - SUPPORTED_IMAGE_TYPES.put (JPEG_EXT,new Integer (I_JPG_C)); + SUPPORTED_IMAGE_TYPES.put (JPEG_EXT, new Integer (I_JPG_C)); SUPPORTED_IMAGE_TYPES.put (GIF_EXT, new Integer (I_GIF)); } @@ -123,7 +121,6 @@ public class ImageConstants /** * Private constructor. */ - private ImageConstants() - { + private ImageConstants() { } } diff --git a/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java index 25cc51f2a..d21166ec0 100755 --- a/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java +++ b/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java @@ -62,8 +62,7 @@ package org.apache.fop.rtf.rtflib.tools; * This class belongs to the tag processing. * @author Andreas Putz */ -public class ImageUtil -{ +public class ImageUtil { ////////////////////////////////////////////////// // @@ Construction @@ -72,8 +71,7 @@ public class ImageUtil /** * Private constructor. */ - private ImageUtil () - { + private ImageUtil () { } @@ -90,26 +88,20 @@ public class ImageUtil * -1 There is no digit\n * number The digits as integer */ - public static int getInt (String value) - { + public static int getInt (String value) { String retString = new String (); StringBuffer s = new StringBuffer (value); int len = s.length (); - for (int i = 0; i < len; i++) - { - if (Character.isDigit (s.charAt (i))) - { + for (int i = 0; i < len; i++) { + if (Character.isDigit (s.charAt (i))) { retString += s.charAt (i); } } - if (retString.length () == 0) - { + if (retString.length () == 0) { return -1; - } - else - { + } else { return Integer.parseInt (retString); } } @@ -123,10 +115,8 @@ public class ImageUtil * true The string contains a % value * false Other string */ - public static boolean isPercent (String value) - { - if (value.endsWith ("%")) - { + public static boolean isPercent (String value) { + if (value.endsWith ("%")) { return true; } @@ -147,46 +137,35 @@ public class ImageUtil * false If different */ public static boolean compareHexValues (byte[] pattern, byte[] data, int searchAt, - boolean searchForward) - { - if (searchAt >= data.length) - { + boolean searchForward) { + if (searchAt >= data.length) { return false; } int pLen = pattern.length; - if (searchForward) - { - if (pLen >= (data.length - searchAt)) - { + if (searchForward) { + if (pLen >= (data.length - searchAt)) { return false; } - for (int i = 0; i < pLen; i++) - { - if (pattern[i] != data[searchAt + i]) - { + for (int i = 0; i < pLen; i++) { + if (pattern[i] != data[searchAt + i]) { return false; } } return true; - } - else - { - if (pLen > (searchAt + 1)) - { + } else { + if (pLen > (searchAt + 1)) { return false; } - for (int i = 0; i < pLen; i++) - { - if (pattern[pLen - i - 1] != data[searchAt - i]) - { + for (int i = 0; i < pLen; i++) { + if (pattern[pLen - i - 1] != data[searchAt - i]) { return false; } } @@ -205,49 +184,42 @@ public class ImageUtil * @return A number */ public static int getIntFromByteArray (byte[] data, int startAt, int length, - boolean searchForward) - { + boolean searchForward) { int bit = 8; int bitMoving = length * bit; int retVal = 0; - if (startAt >= data.length) - { + if (startAt >= data.length) { return retVal; } - if (searchForward) - { - if (length >= (data.length - startAt)) - { + if (searchForward) { + if (length >= (data.length - startAt)) { return retVal; } - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { bitMoving -= bit; int iData = (int) data[startAt + i]; - if (iData < 0) + if (iData < 0) { iData += 256; + } retVal += iData << bitMoving; } - } - else - { - if (length > (startAt + 1)) - { + } else { + if (length > (startAt + 1)) { return retVal; } - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { bitMoving -= bit; int iData = (int) data[startAt - i]; - if (iData < 0) + if (iData < 0) { iData += 256; + } retVal += iData << bitMoving; } } -- 2.39.5