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)
* 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;
}
/** 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
if (e instanceof RtfTableRow) {
addRow((RtfTableRow)e, rowIndex, xOffset);
rowIndex++;
- m_maxRowIndex = Math.max(rowIndex, m_maxRowIndex);
+ maxRowIndex = Math.max(rowIndex, maxRowIndex);
}
}
return rowIndex;
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();
}
}
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
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;
return this.parentITableColumnsInfo;
}
+ /**
+ *
+ * @param parentITableColumnsInfo table context to set
+ */
public void setParentITableColumnsInfo (ITableColumnsInfo parentITableColumnsInfo) {
this.parentITableColumnsInfo = parentITableColumnsInfo;
}
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);
}
// 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;
*/
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 {
/** 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();
/** 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");
/**
* Default constructor.
*
- * @param container a <code>RtfContainer</code> value
+ * @param parent a <code>RtfContainer</code> value
* @param writer a <code>Writer</code> value
- * @param attributes a <code>RtfAttributes</code> value
+ * @param str text of the link
+ * @param attr a <code>RtfAttributes</code> value
+ * @throws IOException for I/O problems
*/
public RtfHyperLink (IRtfTextContainer parent, Writer writer, String str, RtfAttributes attr)
throws IOException {
// @@ 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 ();
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;
}
- /** add a line break */
+ /**
+ * add a line break
+ * @throws IOException for I/O problems
+ */
public void newLineBreak () throws IOException {
new RtfLineBreak (this, writer);
}
this.url = this.url.replace (' ', RtfBookmark.REPLACE_CHARACTER);
}
+ /**
+ *
+ * @return false (always)
+ */
public boolean isEmpty () {
return false;
}