From: William Victor Mote Date: Mon, 30 Jun 2003 01:31:16 +0000 (+0000) Subject: style changes only X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1380 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e1d2bb1574e7da875e58b5aff851ab80013cd538;p=xmlgraphics-fop.git style changes only git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196542 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java index 5063ba74e..adb4dac7d 100755 --- a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java +++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java @@ -62,10 +62,8 @@ package org.apache.fop.rtf.rtflib.exceptions; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public class RtfException extends java.io.IOException -{ - public RtfException(String reason) - { +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 index ea4fd2e47..09c59d711 100755 --- a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java +++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java @@ -63,10 +63,8 @@ package org.apache.fop.rtf.rtflib.exceptions; */ public class RtfStructureException -extends RtfException -{ - public RtfStructureException(String reason) - { +extends RtfException { + public RtfStructureException(String reason) { super(reason); } } \ No newline at end of file diff --git a/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java b/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java index 9f4ec08bd..e91ec8a98 100644 --- a/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java +++ b/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java @@ -62,8 +62,7 @@ package org.apache.fop.rtf.rtflib.interfaces; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface ITableColumnsInfo -{ +public interface ITableColumnsInfo { float INVALID_COLUM_WIDTH = 200f; /** reset the column iteration index, meant to be called when creating a new row */ @@ -77,9 +76,9 @@ public interface ITableColumnsInfo */ float getColumnWidth(); - /** return current column iteration index */ + /** @return current column iteration index */ int getColumnIndex(); - /** return number of columns */ + /** @return number of columns */ int getNumberOfColumns(); } \ 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 index dd8c43099..12f50a6b4 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IBorderAttributes.java @@ -64,12 +64,12 @@ 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_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"; diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java index 8d98aab15..54c48ae55 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfAfterContainer.java @@ -61,7 +61,6 @@ 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; +public interface IRtfAfterContainer { + 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 index 32a7e4327..cd568d062 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBeforeContainer.java @@ -60,7 +60,6 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.IOException; -public interface IRtfBeforeContainer -{ - public RtfBefore newBefore(RtfAttributes attrs) throws IOException; +public interface IRtfBeforeContainer { + 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 index e5c69afc0..3deb4318a 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfBookmarkContainer.java @@ -64,8 +64,7 @@ import java.io.IOException; * RTF Bookmark container interface. * @author Andreas Putz */ -public interface IRtfBookmarkContainer -{ +public interface IRtfBookmarkContainer { /** * Create a new RTF bookmark. diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java index 6f6eb0c9d..e393c8b3e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfExternalGraphicContainer.java @@ -60,8 +60,7 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.IOException; -public interface IRtfExternalGraphicContainer -{ +public interface IRtfExternalGraphicContainer { /** * Creates a new image on external graphic base. diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java index 835cd3620..1a5b0869b 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfHyperLinkContainer.java @@ -63,12 +63,11 @@ import java.io.IOException; /** interface for RtfElements that can contain RtfHyperLinks * @author Andreas Putz a.putz@skynamics.com */ -public interface IRtfHyperLinkContainer extends IRtfTextContainer -{ +public interface IRtfHyperLinkContainer extends IRtfTextContainer { /** * Creates a new hyperlink. * * @exception IOException on error */ - public RtfHyperLink newHyperLink (String str, RtfAttributes attr) throws IOException; + 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 index 9d7e4d1f3..47930a1a1 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfJforCmdContainer.java @@ -62,5 +62,5 @@ package org.apache.fop.rtf.rtflib.rtfdoc; import java.io.IOException; public interface IRtfJforCmdContainer { - public RtfJforCmd newJforCmd(RtfAttributes attr) throws IOException; + 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 index 1d72a5674..8566db05a 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfListContainer.java @@ -64,8 +64,7 @@ import java.io.IOException; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfListContainer -{ +public interface IRtfListContainer { /** close current list if any and start a new one */ - public RtfList newList(RtfAttributes attrs) throws IOException; + 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 index d97c5766a..3d2e631c5 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfOptions.java @@ -61,17 +61,16 @@ package org.apache.fop.rtf.rtflib.rtfdoc; /** * Options for configuring the rtf elements. */ -public interface IRtfOptions -{ +public interface IRtfOptions { /** * Sets the compression rate for the external graphic in percent. * @param percent Compression rate */ - public void setRtfExternalGraphicCompressionRate (int percent); + void setRtfExternalGraphicCompressionRate (int percent); /** * Gets the compression rate for the external graphic in percent. * @return Compression rate */ - public int getRtfExternalGraphicCompressionRate (); + 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 index b210bfc28..2fb4db308 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageBreakContainer.java @@ -64,8 +64,7 @@ import java.io.IOException; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfPageBreakContainer -{ +public interface IRtfPageBreakContainer { /** add a page break */ - public void newPageBreak() throws IOException; + 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 index 62161495a..37fef86fa 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/IRtfPageContainer.java @@ -64,10 +64,9 @@ import java.io.IOException; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public interface IRtfPageContainer -{ +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; + RtfPage newPage(RtfAttributes attrs) throws IOException; } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java index 2b9273b73..3d5b011f0 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTable.java @@ -58,26 +58,26 @@ package org.apache.fop.rtf.rtflib.rtfdoc; -import java.io.*; -import java.util.Iterator; +import java.io.Writer; +import java.io.IOException; import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; /** Container for RtfRow elements * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public class RtfTable extends RtfContainer -{ +public class RtfTable extends RtfContainer { private RtfTableRow m_row; - private int highestRow=0; + private int highestRow = 0; - /** Added by Boris Poudérous on 07/22/2002 in order to process number-columns-spanned attribute */ + /** 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); + 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; } @@ -85,62 +85,59 @@ public class RtfTable extends RtfContainer /** 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); + 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(); + public RtfTableRow newTableRow() throws IOException { + if (m_row != null) { + m_row.close(); + } highestRow++; - m_row = new RtfTableRow(this,m_writer,m_attrib,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 - { + public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException { RtfAttributes attr = null; - if (m_attrib != null) - { + if (m_attrib != null) { attr = (RtfAttributes) m_attrib.clone (); attr.set (attrs); - } - else + } else { attr = attrs; - if(m_row != null) m_row.close(); + } + if (m_row != null) { + m_row.close(); + } highestRow++; - m_row = new RtfTableRow(this,m_writer,attr,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 - { + protected void writeRtfPrefix() throws IOException { writeGroupMark(true); } /** overridden to write RTF suffix code, what comes after our children */ - protected void writeRtfSuffix() throws IOException - { + protected void writeRtfSuffix() throws IOException { writeGroupMark(false); } - public boolean isHighestRow(int id) - { + public boolean isHighestRow(int id) { return (highestRow == id) ? true : false; } /** Added by Boris Poudérous on 07/22/2002 */ - public ITableColumnsInfo getITableColumnsInfo() - { + public ITableColumnsInfo getITableColumnsInfo() { return this.m_table_context; } @@ -148,7 +145,7 @@ public class RtfTable extends RtfContainer // Added by Normand Masse // Support for table-header attributes (used instead of table attributes - public void setHeaderAttribs( RtfAttributes attrs ) { + public void setHeaderAttribs(RtfAttributes attrs) { m_header_attribs = attrs; } @@ -156,7 +153,7 @@ public class RtfTable extends RtfContainer // 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 ) { + if (m_header_attribs != null) { return m_header_attribs; } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java index 6a507ba9f..972e6a7ed 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableCell.java @@ -58,8 +58,9 @@ package org.apache.fop.rtf.rtflib.rtfdoc; -import java.io.*; -import java.util.*; +import java.io.Writer; +import java.io.IOException; +import java.util.Iterator; import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; /** A cell in an RTF table, container for paragraphs, lists, etc. @@ -68,7 +69,8 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; public class RtfTableCell extends RtfContainer -implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExternalGraphicContainer { +implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer, + IRtfExternalGraphicContainer { private RtfParagraph m_paragraph; private RtfList m_list; private RtfTable m_table; @@ -89,17 +91,17 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter private int m_hMerge = NO_MERGE; /** cell merging: this cell is not merged */ - public final static int NO_MERGE = 0; + public static final int NO_MERGE = 0; /** cell merging: this cell is the start of a range of merged cells */ - public final static int MERGE_START = 1; + public static final 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; + public static final 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); + RtfTableCell(RtfTableRow parent, Writer w, int cellWidth, int idNum) throws IOException { + super(parent, w); id = idNum; m_parentRow = parent; m_cellWidth = cellWidth; @@ -108,44 +110,47 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter } /** 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); + 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 */ + /** 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) - { + 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) - { + 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 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()) + while ((this.id - 1) != ITableColumnsInfo.getColumnIndex()) { ITableColumnsInfo.selectNextColumn(); + } - // We widthdraw one cell because the first cell is already created (it's the current cell) ! + // We widthdraw one cell because the first cell is already created + // (it's the current cell) ! int i = nbMergedCells - 1; - while (i > 0) - { + 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); + parent.newTableCellMergedHorizontally((int)ITableColumnsInfo.getColumnWidth(), + attrs); i--; } @@ -159,23 +164,20 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter closeAll(); // in tables, RtfParagraph must have the intbl attribute - if(attrs==null) attrs = new RtfAttributes(); + if (attrs == null) { + attrs = new RtfAttributes(); + } attrs.set("intbl"); - m_paragraph = new RtfParagraph(this,m_writer,attrs); + m_paragraph = new RtfParagraph(this, m_writer, attrs); - if(m_paragraph.m_attrib.isSet("qc")) - { - set_center=true; + if (m_paragraph.m_attrib.isSet("qc")) { + set_center = true; attrs.set("qc"); - } - else if(m_paragraph.m_attrib.isSet("qr")) - { - set_right=true; + } else if (m_paragraph.m_attrib.isSet("qr")) { + set_right = true; attrs.set("qr"); - } - else - { + } else { attrs.set("ql"); } attrs.set("intbl"); @@ -188,7 +190,7 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter /** 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); + m_externalGraphic = new RtfExternalGraphic(this, m_writer); return m_externalGraphic; } @@ -200,18 +202,19 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter /** 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); + 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); + 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 + /** 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(); @@ -227,16 +230,16 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter m_widthOffset = widthOffset; // vertical cell merge codes - if(m_vMerge == MERGE_START) { + if (m_vMerge == MERGE_START) { writeControlWord("clvmgf"); - } else if(m_vMerge == MERGE_WITH_PREVIOUS) { + } else if (m_vMerge == MERGE_WITH_PREVIOUS) { writeControlWord("clvmrg"); } // horizontal cell merge codes - if(m_hMerge == MERGE_START) { + if (m_hMerge == MERGE_START) { writeControlWord("clmgf"); - } else if(m_hMerge == MERGE_WITH_PREVIOUS) { + } else if (m_hMerge == MERGE_WITH_PREVIOUS) { writeControlWord("clmrg"); } @@ -256,22 +259,17 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter //these lines added by Chris Scott, Westinghouse //some attributes need to be writting before opening block - if(set_center) - { + if (set_center) { writeControlWord("qc"); - } - else if (set_right) - { + } else if (set_right) { writeControlWord("qr"); - } - else - { + } else { writeControlWord("ql"); } writeControlWord("cellx" + xPos); - writeControlWord( "ql" ); + writeControlWord("ql"); return xPos; @@ -280,25 +278,21 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter /** 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, + // 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) - { + if (set_center) { writeControlWord("qc"); - } - else if (set_right) - { + } else if (set_right) { writeControlWord("qr"); - } - else - { + } else { writeControlWord("ql"); } - if(!containsText()) { + if (!containsText()) { writeControlWord("intbl"); //R.Marra this create useless paragraph @@ -312,22 +306,27 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter //modified by Chris Scott, Westinghouse private void closeCurrentParagraph() throws IOException { - if(m_paragraph!=null) - { + if (m_paragraph != null) { m_paragraph.close(); } } private void closeCurrentList() throws IOException { - if(m_list!=null) m_list.close(); + if (m_list != null) { + m_list.close(); + } } private void closeCurrentTable() throws IOException { - if(m_table!=null) m_table.close(); + if (m_table != null) { + m_table.close(); + } } private void closeCurrentExternalGraphic() throws IOException { - if(m_externalGraphic!=null) m_externalGraphic.close(); + if (m_externalGraphic != null) { + m_externalGraphic.close(); + } } private void closeAll() @@ -358,19 +357,23 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter int extraRowIndex = 0; RtfTableCell extraCell = null; - for(Iterator it = getChildren().iterator(); it.hasNext(); ) { + for (Iterator it = getChildren().iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); - if(e instanceof RtfTable) { + 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 = 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) { + } else if (extraCell != null) { // we are after a nested table, add elements to the extra cell created for them extraCell.addChild(e); @@ -386,34 +389,31 @@ implements IRtfParagraphContainer,IRtfListContainer,IRtfTableContainer,IRtfExter * 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() - { + 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) - { + 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(); ) { + for (Iterator it = getChildren().iterator(); it.hasNext();) { final Object o = it.next(); - if(!pFound) { + 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()) { + if (!p2.isEmpty()) { // found a non-empty paragraph after p result = true; break; } - } - else if (o instanceof RtfTable) { + } else if (o instanceof RtfTable) { break; } } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java index bd5f277c0..4d47c4be2 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -58,8 +58,9 @@ package org.apache.fop.rtf.rtflib.rtfdoc; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; /** Container for RtfTableCell elements * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch @@ -71,32 +72,32 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { private RtfTableCell m_cell; private RtfExtraRowSet m_extraRowSet; private int id; - private int highestCell=0; + 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); + 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; + 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); + 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); + m_cell = new RtfTableCell(this, m_writer, cellWidth, attrs, highestCell); return m_cell; } @@ -105,7 +106,8 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { * 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 { + 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); @@ -116,14 +118,15 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { * 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 { + 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" ); + wAttributes.unset("number-columns-spanned"); - m_cell = new RtfTableCell(this,m_writer,cellWidth,wAttributes,highestCell); + m_cell = new RtfTableCell(this, m_writer, cellWidth, wAttributes, highestCell); m_cell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS); return m_cell; } @@ -143,7 +146,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { writeControlWord("trowd"); //check for keep-together - if(m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) { + if (m_attrib != null && m_attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) { writeControlWord(ROW_KEEP_TOGETHER); } @@ -151,27 +154,27 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { // if we have attributes, manipulate border properties final RtfTable parentTable = (RtfTable) m_parent; - if(m_attrib != null && parentTable != null) { + if (m_attrib != null && parentTable != null) { //if table is only one row long - if(isFirstRow() && parentTable.isHighestRow(id)){ + if (isFirstRow() && parentTable.isHighestRow(id)) { m_attrib.unset(ITableAttributes.ROW_BORDER_HORIZONTAL); //or if row is the first row - }else if(isFirstRow()){ + } else if (isFirstRow()) { m_attrib.unset(ITableAttributes.ROW_BORDER_BOTTOM); //or if row is the last row - }else if(parentTable.isHighestRow(id)){ + } else if (parentTable.isHighestRow(id)) { m_attrib.unset(ITableAttributes.ROW_BORDER_TOP); //else the row is an inside row - }else{ + } 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); + 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 @@ -183,30 +186,24 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { int numberOfCellsBeforeNestedTable = 0; java.util.Vector indexesFound = new java.util.Vector(); - for (Iterator it = getChildren().iterator(); it.hasNext(); ) - { + 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(); ) - { + 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) - { + 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(); ) + } else if (subElement instanceof RtfParagraph) { + for (Iterator it3 = + ((RtfParagraph)subElement).getChildren().iterator(); it3.hasNext();) { final RtfElement subSubElement = (RtfElement)it3.next(); - if (subSubElement instanceof RtfTable) - { + if (subSubElement instanceof RtfTable) { nestedTableFound = true; indexesFound.addElement(new Integer(index)); } @@ -222,34 +219,29 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { // 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(); ) { + for (Iterator it = getChildren().iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); - if(e instanceof RtfTableCell) { + 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 (!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 (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()) - { + } 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()) - { + } else if (index > ((Integer)indexesFound.get(i)).intValue()) { ((RtfTableCell)e).setVMerge(RtfTableCell.MERGE_START); break; } @@ -261,31 +253,31 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { // 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 == 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 (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 (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 )); + 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)); } } @@ -314,22 +306,27 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { 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 + // 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)) { + 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(); + 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) { + 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); + if (gaph >= 0) { + m_attrib.set(ATTR_RTF_15_TRGAPH, gaph); } } @@ -337,11 +334,12 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { writeAttributes(m_attrib, ATTRIB_ROW_PADDING); } - public boolean isFirstRow(){ - if(id == 1) + public boolean isFirstRow() { + if (id == 1) { return true; - else + } else { return false; + } } public boolean isHighestCell(int id) { diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java index 1d5492a47..7e4276a99 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfTemplate.java @@ -58,10 +58,7 @@ 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 @@ -78,8 +75,7 @@ public class RtfTemplate { /** * Constructor. */ - private RtfTemplate () - { + private RtfTemplate () { } @@ -89,8 +85,7 @@ public class RtfTemplate { * * @return The instance of RtfTemplate */ - public static RtfTemplate getInstance () - { + public static RtfTemplate getInstance () { if (instance == null) { instance = new RtfTemplate(); } @@ -106,7 +101,7 @@ public class RtfTemplate { **/ public void setTemplateFilePath(String templateFilePath) throws IOException { // no validity checks here - leave this to the RTF client - if(templateFilePath == null) { + if (templateFilePath == null) { this.templateFilePath = null; } else { this.templateFilePath = templateFilePath.trim(); @@ -118,9 +113,10 @@ public class RtfTemplate { * @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; + public void writeTemplate (RtfHeader header) throws IOException { + if (templateFilePath == null || templateFilePath.length() == 0) { + return; + } header.writeGroupMark (true); header.writeControlWord ("template"); diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java index b4d0433c7..e2b7c4dbb 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfText.java @@ -65,8 +65,7 @@ import java.io.Writer; * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ -public class RtfText extends RtfElement -{ +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; @@ -85,7 +84,8 @@ public class RtfText extends RtfElement private final RtfAttributes m_attr; - /** RtfText attributes: attribute names are RTF control word names to avoid additional mapping */ + /** 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"; @@ -145,7 +145,8 @@ public class RtfText extends RtfElement //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 + BDR_BOTTOM_SINGLE, BDR_BOTTOM_DOUBLE, BDR_BOTTOM_EMBOSS, BDR_BOTTOM_DOTTED, + BDR_BOTTOM_DASH }; public static String[] INDENT = new String [] @@ -155,8 +156,8 @@ public class RtfText extends RtfElement 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 + TAB_CENTER, TAB_RIGHT, TAB_LEADER_DOTS, TAB_LEADER_HYPHEN, TAB_LEADER_UNDER, + TAB_LEADER_THICK, TAB_LEADER_EQUALS }; @@ -174,40 +175,39 @@ public class RtfText extends RtfElement /** 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); + 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 - { + 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}); + writeAttributes(m_attr, new String[] {RtfText.SPACE_BEFORE}); + writeAttributes(m_attr, new String[] {RtfText.SPACE_AFTER}); } - if(isTab()){ + if (isTab()) { writeControlWord("tab"); - }else if(isNewLine()){ + } else if (isNewLine()) { break writeChars; - }else if(isBold(true)){ + } else if (isBold(true)) { writeControlWord("b"); - }else if(isBold(false)){ + } else if (isBold(false)) { writeControlWord("b0"); - } - // TODO not optimal, consecutive RtfText with same attributes could be written without group marks - else{ + // 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); + if (m_attr != null && mustWriteAttributes()) { + writeAttributes(m_attr, RtfText.ATTR_NAMES); } - RtfStringConverter.getInstance().writeRtfString(m_writer,m_text); + RtfStringConverter.getInstance().writeRtfString(m_writer, m_text); writeGroupMark(false); } @@ -215,89 +215,89 @@ public class RtfText extends RtfElement } /** true if our text attributes must be written */ - private boolean mustWriteAttributes() - { + private boolean mustWriteAttributes() { return !isEmpty() && !isNbsp(); } - /** IRtfTextContainer requirement: return a copy of our attributes */ + /** IRtfTextContainer requirement: + * @return a copy of our attributes */ public RtfAttributes getTextContainerAttributes() { - if(m_attrib == null) return null; + if (m_attrib == null) { + return null; + } return (RtfAttributes)this.m_attrib.clone(); } /** direct access to our text */ - String getText() - { + String getText() { return m_text; } /** direct access to our text */ - void setText(String str) - { + 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 + * @return true If m_text is null\n + * false m_text is set */ - public boolean isEmpty () - { + 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 + * 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 + * @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) + 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) + public boolean isTab() { + if (m_text.trim().length() == 1 && m_text.charAt(0) == CHAR_TAB) { return true; - else + } else { return false; + } } - public boolean isNewLine() - { - if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_NEW_LINE) + public boolean isNewLine() { + if (m_text.trim().length() == 1 && m_text.charAt(0) == CHAR_NEW_LINE) { return true; - else + } else { return false; + } } - public boolean isBold(boolean isStart) - { - if(isStart){ - if(m_text.trim().length()==1 && m_text.charAt(0)== CHAR_BOLD_START) + 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) + } + } else { + if (m_text.trim().length() == 1 && m_text.charAt(0) == CHAR_BOLD_END) { return true; - else + } else { return false; + } } return false; } - /** get the attributes of our text */ - public RtfAttributes getTextAttributes(){ + /** @return 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 index 034c6df53..e795106fa 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/WhitespaceCollapser.java @@ -66,21 +66,21 @@ import java.util.StringTokenizer; */ class WhitespaceCollapser { - private final static String SPACE = " "; - private boolean m_lastEndSpace = true; + private static final String SPACE = " "; + private boolean 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(); ) { + for (Iterator it = c.getChildren().iterator(); it.hasNext();) { RtfText current = null; final Object kid = it.next(); - if(kid instanceof RtfText) { + 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; + lastEndSpace = true; } } } @@ -91,35 +91,38 @@ class WhitespaceCollapser { // tokenize the text based on whitespace and regenerate it so as // to collapse multiple spaces into one - if(orig != null && orig.length() > 0) { + 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 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); + if (allSpaces) { + if (!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) { + final StringTokenizer stk = new StringTokenizer(txt.getText(), " \t\n\r"); + while (stk.hasMoreTokens()) { + if (first && beginSpace && !lastEndSpace) { sb.append(SPACE); } first = false; sb.append(stk.nextToken()); - if(stk.hasMoreTokens() || endSpace) { + if (stk.hasMoreTokens() || endSpace) { sb.append(SPACE); } } } txt.setText(sb.toString()); - m_lastEndSpace = endSpace; + lastEndSpace = endSpace; } } } \ No newline at end of file