From 595277df067df36c532c09a88cb6620f5179be0c Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Thu, 3 Jul 2003 07:29:41 +0000 Subject: [PATCH] style changes only, mostly javadoc comments and refactoring of names git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196562 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java | 40 ++++-- .../apache/fop/rtf/rtflib/rtfdoc/RtfFile.java | 131 ++++++++++++------ .../fop/rtf/rtflib/rtfdoc/RtfHeader.java | 10 +- .../fop/rtf/rtflib/rtfdoc/RtfHyperLink.java | 35 +++-- 4 files changed, 145 insertions(+), 71 deletions(-) diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java index 1bf60446f..4e272b5aa 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfExtraRowSet.java @@ -82,7 +82,7 @@ import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo; public class RtfExtraRowSet extends RtfContainer { // TODO what is idnum? - final int DEFAULT_IDNUM = 0; + static final int DEFAULT_IDNUM = 0; /** Parent table context * (added by Boris Poudérous on july 2002 in order to process nested tables) @@ -93,12 +93,12 @@ public class RtfExtraRowSet extends RtfContainer { * RtfTableCells that must be rendered in extra rows. * This holds a cell with positioning information */ - private final List m_cells = new LinkedList(); + private final List cells = new LinkedList(); private static class PositionedCell implements Comparable { - final RtfTableCell cell; - final int xOffset; - final int rowIndex; + private final RtfTableCell cell; + private final int xOffset; + private final int rowIndex; PositionedCell(RtfTableCell c, int index, int offset) { cell = c; @@ -140,7 +140,7 @@ public class RtfExtraRowSet extends RtfContainer { } /** our maximum row index */ - private int m_maxRowIndex; + private int maxRowIndex; /** an RtfExtraRowSet has no parent, it is only used temporary during * generation of RTF for an RtfTableRow @@ -162,7 +162,7 @@ public class RtfExtraRowSet extends RtfContainer { if (e instanceof RtfTableRow) { addRow((RtfTableRow)e, rowIndex, xOffset); rowIndex++; - m_maxRowIndex = Math.max(rowIndex, m_maxRowIndex); + maxRowIndex = Math.max(rowIndex, maxRowIndex); } } return rowIndex; @@ -174,7 +174,7 @@ public class RtfExtraRowSet extends RtfContainer { final RtfElement e = (RtfElement)it.next(); if (e instanceof RtfTableCell) { final RtfTableCell c = (RtfTableCell)e; - m_cells.add(new PositionedCell(c, rowIndex, xOffset)); + cells.add(new PositionedCell(c, rowIndex, xOffset)); xOffset += c.getCellWidth(); } } @@ -189,19 +189,23 @@ public class RtfExtraRowSet extends RtfContainer { throws IOException { final RtfTableCell c = new RtfTableCell(null, writer, cellWidth, parentCellAttributes, DEFAULT_IDNUM); - m_cells.add(new PositionedCell(c, rowIndex, xOffset)); + cells.add(new PositionedCell(c, rowIndex, xOffset)); return c; } - /** render extra RtfTableRows containing all the extra RtfTableCells that we contain */ + /** + * render extra RtfTableRows containing all the extra RtfTableCells that we + * contain + * @throws IOException for I/O problems + */ protected void writeRtfContent() throws IOException { // sort cells by rowIndex and xOffset - Collections.sort(m_cells); + Collections.sort(cells); // process all extra cells by rendering them into extra rows List rowCells = null; int rowIndex = -1; - for (Iterator it = m_cells.iterator(); it.hasNext();) { + for (Iterator it = cells.iterator(); it.hasNext();) { final PositionedCell pc = (PositionedCell)it.next(); if (pc.rowIndex != rowIndex) { // starting a new row, render previous one @@ -309,9 +313,11 @@ public class RtfExtraRowSet extends RtfContainer { return empty; } - /** As this contains cells from several rows, we say that it's empty - * only if we have no cells. - * writeRow makes the decision about rendering specific rows + /** + * As this contains cells from several rows, we say that it's empty + * only if we have no cells. + * writeRow makes the decision about rendering specific rows + * @return false (always) */ public boolean isEmpty() { return false; @@ -325,6 +331,10 @@ public class RtfExtraRowSet extends RtfContainer { return this.parentITableColumnsInfo; } + /** + * + * @param parentITableColumnsInfo table context to set + */ public void setParentITableColumnsInfo (ITableColumnsInfo parentITableColumnsInfo) { this.parentITableColumnsInfo = parentITableColumnsInfo; } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java index e5a973e63..a9a09b19e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfFile.java @@ -76,15 +76,19 @@ import java.io.OutputStreamWriter; public class RtfFile extends RtfContainer { - private RtfHeader m_header; - private RtfPageArea m_pageArea; - private RtfListTable m_listTable; - private RtfDocumentArea m_docArea; + private RtfHeader header; + private RtfPageArea pageArea; + private RtfListTable listTable; + private RtfDocumentArea docArea; // private ConverterLogChannel m_log; - private RtfContainer m_listTableContainer; + private RtfContainer listTableContainer; private int listNum = 0; - /** Create an RTF file that outputs to the given Writer */ + /** + * Create an RTF file that outputs to the given Writer + * @param w the Writer to write to + * @throws IOException for I/O problems + */ public RtfFile(Writer w) throws IOException { super(null, w); } @@ -106,101 +110,142 @@ extends RtfContainer { // return m_log; // } - /** If called, must be called before startDocumentArea */ + /** + * If called, must be called before startDocumentArea + * @return the new RtfHeader + * @throws IOException for I/O problems + */ public RtfHeader startHeader() throws IOException { - if (m_header != null) { + if (header != null) { throw new RtfStructureException("startHeader called more than once"); } - m_header = new RtfHeader(this, writer); - m_listTableContainer = new RtfContainer(this, writer); - return m_header; + header = new RtfHeader(this, writer); + listTableContainer = new RtfContainer(this, writer); + return header; } - /** Creates the list table.*/ + /** + * Creates the list table. + * @param attr attributes for the RtfListTable + * @return the new RtfListTable + * @throws IOException for I/O problems + */ public RtfListTable startListTable(RtfAttributes attr) throws IOException { listNum++; - m_listTable = new RtfListTable(this, writer, new Integer(listNum), attr); - m_listTableContainer.addChild(m_listTable); - return m_listTable; + listTable = new RtfListTable(this, writer, new Integer(listNum), attr); + listTableContainer.addChild(listTable); + return listTable; } - /** Closes the RtfHeader if not done yet, and starts the docment area. - Like startDocumentArea, is only called once. This is not optimal, - must be able to have multiple page definition, and corresponding - Document areas */ + /** + * Closes the RtfHeader if not done yet, and starts the docment area. + * Like startDocumentArea, is only called once. This is not optimal, + * must be able to have multiple page definition, and corresponding + * Document areas + * @return the RtfPageArea + * @throws IOException for I/O problems + * @throws RtfStructureException for illegal RTF structure + */ public RtfPageArea startPageArea() throws IOException, RtfStructureException { - if (m_pageArea != null) { + if (pageArea != null) { throw new RtfStructureException("startPageArea called more than once"); } // create an empty header if there was none - if (m_header == null) { + if (header == null) { startHeader(); } - m_header.close(); - m_pageArea = new RtfPageArea(this, writer); - addChild(m_pageArea); - return m_pageArea; + header.close(); + pageArea = new RtfPageArea(this, writer); + addChild(pageArea); + return pageArea; } - /** Call startPageArea if needed and return the page area object. */ + /** + * Call startPageArea if needed and return the page area object. + * @return the RtfPageArea + * @throws IOException for I/O problems + * @throws RtfStructureException for illegal RTF structure + */ public RtfPageArea getPageArea() throws IOException, RtfStructureException { - if (m_pageArea == null) { + if (pageArea == null) { return startPageArea(); } - return m_pageArea; + return pageArea; } - /** Closes the RtfHeader if not done yet, and starts the document area. - * Must be called once only. + /** + * Closes the RtfHeader if not done yet, and starts the document area. + * Must be called once only. + * @return the RtfDocumentArea + * @throws IOException for I/O problems + * @throws RtfStructureException for illegal RTF structure */ public RtfDocumentArea startDocumentArea() throws IOException, RtfStructureException { - if (m_docArea != null) { + if (docArea != null) { throw new RtfStructureException("startDocumentArea called more than once"); } // create an empty header if there was none - if (m_header == null) { + if (header == null) { startHeader(); } - m_header.close(); - m_docArea = new RtfDocumentArea(this, writer); - addChild(m_docArea); - return m_docArea; + header.close(); + docArea = new RtfDocumentArea(this, writer); + addChild(docArea); + return docArea; } - /** Call startDocumentArea if needed and return the document area object. */ + /** + * Call startDocumentArea if needed and return the document area object. + * @return the RtfDocumentArea + * @throws IOException for I/O problems + * @throws RtfStructureException for illegal RTF structure + */ public RtfDocumentArea getDocumentArea() throws IOException, RtfStructureException { - if (m_docArea == null) { + if (docArea == null) { return startDocumentArea(); } - return m_docArea; + return docArea; } - /** overridden to write RTF prefix code, what comes before our children */ + /** + * overridden to write RTF prefix code, what comes before our children + * @throws IOException for I/O problems + */ protected void writeRtfPrefix() throws IOException { writeGroupMark(true); writeControlWord("rtf1"); } - /** overridden to write RTF suffix code, what comes after our children */ + /** + * overridden to write RTF suffix code, what comes after our children + * @throws IOException for I/O problems + */ protected void writeRtfSuffix() throws IOException { writeGroupMark(false); } - /** must be called when done creating the document */ + /** + * must be called when done creating the document + * @throws IOException for I/O problems + */ public synchronized void flush() throws IOException { writeRtf(); writer.flush(); } - /** minimal test and usage example */ + /** + * minimal test and usage example + * @param args command-line arguments + * @throws Exception for problems + */ public static void main(String args[]) throws Exception { Writer w = null; diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java index dceb26680..f437890fb 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHeader.java @@ -72,8 +72,8 @@ import java.io.IOException; */ class RtfHeader extends RtfContainer { - private final String m_charset = "ansi"; - private final Map m_userProperties = new HashMap(); + private final String charset = "ansi"; + private final Map userProperties = new HashMap(); /** Create an RTF header */ RtfHeader(RtfFile f, Writer w) throws IOException { @@ -84,7 +84,7 @@ class RtfHeader extends RtfContainer { /** Overridden to write our own data before our children's data */ protected void writeRtfContent() throws IOException { - writeControlWord(m_charset); + writeControlWord(charset); writeUserProperties(); RtfColorTable.getInstance().writeColors(this); super.writeRtfContent(); @@ -95,10 +95,10 @@ class RtfHeader extends RtfContainer { /** write user properties if any */ private void writeUserProperties() throws IOException { - if (m_userProperties.size() > 0) { + if (userProperties.size() > 0) { writeGroupMark(true); writeStarControlWord("userprops"); - for (Iterator it = m_userProperties.entrySet().iterator(); it.hasNext();) { + for (Iterator it = userProperties.entrySet().iterator(); it.hasNext();) { final Map.Entry entry = (Map.Entry)it.next(); writeGroupMark(true); writeControlWord("propname"); diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java index a9269e420..028c5983e 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfHyperLink.java @@ -88,9 +88,11 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer { /** * Default constructor. * - * @param container a RtfContainer value + * @param parent a RtfContainer value * @param writer a Writer value - * @param attributes a RtfAttributes value + * @param str text of the link + * @param attr a RtfAttributes value + * @throws IOException for I/O problems */ public RtfHyperLink (IRtfTextContainer parent, Writer writer, String str, RtfAttributes attr) throws IOException { @@ -146,15 +148,22 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer { // @@ IRtfContainer implementation ////////////////////////////////////////////////// - /** close current text run if any and start a new one with default attributes - * @param str if not null, added to the RtfText created + /** + * close current text run if any and start a new one with default attributes + * @param str if not null, added to the RtfText created + * @throws IOException for I/O problems + * @return new RtfText object */ public RtfText newText (String str) throws IOException { return newText (str, null); } - /** close current text run if any and start a new one - * @param str if not null, added to the RtfText created + /** + * close current text run if any and start a new one + * @param str if not null, added to the RtfText created + * @param attr attributes of text to add + * @throws IOException for I/O problems + * @return the new RtfText object */ public RtfText newText (String str, RtfAttributes attr) throws IOException { closeAll (); @@ -162,7 +171,10 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer { return mText; } - /** IRtfTextContainer requirement: return a copy of our attributes */ + /** + * IRtfTextContainer requirement: + * @return a copy of our attributes + */ public RtfAttributes getTextContainerAttributes() { if (attrib == null) { return null; @@ -171,7 +183,10 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer { } - /** add a line break */ + /** + * add a line break + * @throws IOException for I/O problems + */ public void newLineBreak () throws IOException { new RtfLineBreak (this, writer); } @@ -218,6 +233,10 @@ public class RtfHyperLink extends RtfContainer implements IRtfTextContainer { this.url = this.url.replace (' ', RtfBookmark.REPLACE_CHARACTER); } + /** + * + * @return false (always) + */ public boolean isEmpty () { return false; } -- 2.39.5