*/
public class RtfTable extends RtfContainer {
- private RtfTableRow m_row;
+ private RtfTableRow row;
private int highestRow = 0;
/** Added by Boris Poudérous on 07/22/2002 in order to process
* number-columns-spanned attribute */
- private ITableColumnsInfo m_table_context;
+ private ITableColumnsInfo tableContext;
/** Create an RTF element as a child of given container */
RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc)
throws IOException {
super((RtfContainer)parent, w);
// Line added by Boris Poudérous on 07/22/2002
- m_table_context = tc;
+ tableContext = tc;
}
/** Create an RTF element as a child of given container
ITableColumnsInfo tc) throws IOException {
super((RtfContainer)parent, w, attrs);
// Line added by Boris Poudérous on 07/22/2002
- m_table_context = tc;
+ tableContext = tc;
}
- /** close current row if any and start a new one */
+ /**
+ * Close current row if any and start a new one
+ * @return new RtfTableRow
+ * @throws IOException for I/O problems
+ */
public RtfTableRow newTableRow() throws IOException {
- if (m_row != null) {
- m_row.close();
+ if (row != null) {
+ row.close();
}
highestRow++;
- m_row = new RtfTableRow(this, writer, attrib, highestRow);
- return m_row;
+ row = new RtfTableRow(this, writer, attrib, highestRow);
+ return row;
}
- /** close current row if any and start a new one */
+
+ /**
+ * Close current row if any and start a new one
+ * @param attrs attributs of new RtfTableRow
+ * @return new RtfTableRow
+ * @throws IOException for I/O problems
+ */
public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException {
RtfAttributes attr = null;
if (attrib != null) {
} else {
attr = attrs;
}
- if (m_row != null) {
- m_row.close();
+ if (row != null) {
+ row.close();
}
highestRow++;
- m_row = new RtfTableRow(this, writer, attr, highestRow);
- return m_row;
+ row = new RtfTableRow(this, writer, attr, highestRow);
+ return row;
}
- /** 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);
}
- /** 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);
}
+ /**
+ *
+ * @param id row to check (??)
+ * @return true if id is the highestRow
+ */
public boolean isHighestRow(int id) {
return (highestRow == id) ? true : false;
}
- /** Added by Boris Poudérous on 07/22/2002 */
+ /**
+ * Added by Boris Poudérous on 07/22/2002
+ * @return ITableColumnsInfo for this table
+ */
public ITableColumnsInfo getITableColumnsInfo() {
- return this.m_table_context;
+ return this.tableContext;
}
- private RtfAttributes m_header_attribs = null;
+ private RtfAttributes headerAttribs = null;
- // Added by Normand Masse
- // Support for table-header attributes (used instead of table attributes
+ /**
+ * Added by Normand Masse
+ * Support for table-header attributes (used instead of table attributes)
+ * @param attrs attributes to be set
+ */
public void setHeaderAttribs(RtfAttributes attrs) {
- m_header_attribs = attrs;
+ headerAttribs = attrs;
}
- // Added by Normand Masse
- // Returns the table-header attributes if they are present, otherwise the
- // parent's attributes are returned normally.
+ /**
+ * Added by Normand Masse
+ * @return the table-header attributes if they are present, otherwise the
+ * parent's attributes are returned normally.
+ */
public RtfAttributes getRtfAttributes() {
- if (m_header_attribs != null) {
- return m_header_attribs;
+ if (headerAttribs != null) {
+ return headerAttribs;
}
return super.getRtfAttributes();
extends RtfContainer
implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer,
IRtfExternalGraphicContainer {
- private RtfParagraph m_paragraph;
- private RtfList m_list;
- private RtfTable m_table;
- private RtfExternalGraphic m_externalGraphic;
- private final RtfTableRow m_parentRow;
- private boolean set_center;
- private boolean set_right;
+ private RtfParagraph paragraph;
+ private RtfList list;
+ private RtfTable table;
+ private RtfExternalGraphic externalGraphic;
+ private final RtfTableRow parentRow;
+ private boolean setCenter;
+ private boolean setRight;
private int id;
+ /** default cell width (in twips ??) */
public static final int DEFAULT_CELL_WIDTH = 2000;
/** cell width in twips */
- private int m_cellWidth;
- private int m_widthOffset;
+ private int cellWidth;
+ private int widthOffset;
/** cell merging has three states */
- private int m_vMerge = NO_MERGE;
- private int m_hMerge = NO_MERGE;
+ private int vMerge = NO_MERGE;
+ private int hMerge = NO_MERGE;
/** cell merging: this cell is not merged */
public static final int NO_MERGE = 0;
RtfTableCell(RtfTableRow parent, Writer w, int cellWidth, int idNum) throws IOException {
super(parent, w);
id = idNum;
- m_parentRow = parent;
- m_cellWidth = cellWidth;
- set_center = set_right = false;
+ parentRow = parent;
+ this.cellWidth = cellWidth;
+ setCenter = setRight = false;
}
int idNum) throws IOException {
super(parent, w, attrs);
id = idNum;
- m_parentRow = parent;
- m_cellWidth = cellWidth;
+ parentRow = parent;
+ this.cellWidth = cellWidth;
/** Added by Boris Poudérous on 07/22/2002 in order to process
* number-columns-spanned attribute */
if (parent.parent instanceof RtfTable) {
// Get the context of the current table in order to get the width of each column
- ITableColumnsInfo ITableColumnsInfo =
+ ITableColumnsInfo tableColumnsInfo =
((RtfTable)parent.parent).getITableColumnsInfo();
- ITableColumnsInfo.selectFirstColumn();
+ tableColumnsInfo.selectFirstColumn();
// Reach the column index in table context corresponding to the current column cell
// id is the index of the current cell (it begins at 1)
// getColumnIndex() is the index of the current column in table context (it begins at 0)
// => so we must widthdraw 1 when comparing these two variables.
- while ((this.id - 1) != ITableColumnsInfo.getColumnIndex()) {
- ITableColumnsInfo.selectNextColumn();
+ while ((this.id - 1) != tableColumnsInfo.getColumnIndex()) {
+ tableColumnsInfo.selectNextColumn();
}
// We widthdraw one cell because the first cell is already created
// (it's the current cell) !
int i = nbMergedCells - 1;
while (i > 0) {
- ITableColumnsInfo.selectNextColumn();
+ tableColumnsInfo.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(),
+ parent.newTableCellMergedHorizontally((int)tableColumnsInfo.getColumnWidth(),
attrs);
i--;
/** - end - */
}
- /** start a new paragraph after closing current current paragraph, list and table */
+ /**
+ * Start a new paragraph after closing current current paragraph, list and table
+ * @param attrs attributes of new RtfParagraph
+ * @return new RtfParagraph object
+ * @throws IOException for I/O problems
+ */
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
closeAll();
}
attrs.set("intbl");
- m_paragraph = new RtfParagraph(this, writer, attrs);
+ paragraph = new RtfParagraph(this, writer, attrs);
- if (m_paragraph.attrib.isSet("qc")) {
- set_center = true;
+ if (paragraph.attrib.isSet("qc")) {
+ setCenter = true;
attrs.set("qc");
- } else if (m_paragraph.attrib.isSet("qr")) {
- set_right = true;
+ } else if (paragraph.attrib.isSet("qr")) {
+ setRight = true;
attrs.set("qr");
} else {
attrs.set("ql");
//lines modified by Chris Scott, Westinghouse
- return m_paragraph;
+ return paragraph;
}
- /** start a new external graphic after closing current paragraph, list and table */
+ /**
+ * Start a new external graphic after closing current paragraph, list and table
+ * @throws IOException for I/O problems
+ * @return new RtfExternalGraphic object
+ */
public RtfExternalGraphic newImage() throws IOException {
closeAll();
- m_externalGraphic = new RtfExternalGraphic(this, writer);
- return m_externalGraphic;
+ externalGraphic = new RtfExternalGraphic(this, writer);
+ return externalGraphic;
}
- /** start a new paragraph with default attributes after closing current paragraph, list and table */
+ /**
+ * Start a new paragraph with default attributes after closing current
+ * paragraph, list and table
+ * @return new RtfParagraph object
+ * @throws IOException for I/O problems
+ */
public RtfParagraph newParagraph() throws IOException {
return newParagraph(null);
}
- /** start a new list after closing current paragraph, list and table */
+ /**
+ * Start a new list after closing current paragraph, list and table
+ * @param attrib attributes for new RtfList
+ * @return new RtfList object
+ * @throws IOException for I/O problems
+ */
public RtfList newList(RtfAttributes attrib) throws IOException {
closeAll();
- m_list = new RtfList(this, writer, attrib);
- return m_list;
+ list = new RtfList(this, writer, attrib);
+ return list;
}
- /** start a new nested table after closing current paragraph, list and table */
+ /**
+ * Start a new nested table after closing current paragraph, list and table
+ * @param tc table column info for new RtfTable
+ * @return new RtfTable object
+ * @throws IOException for I/O problems
+ */
public RtfTable newTable(ITableColumnsInfo tc) throws IOException {
closeAll();
- m_table = new RtfTable(this, writer, tc);
- return m_table;
+ table = new RtfTable(this, writer, tc);
+ return table;
}
- /** start a new nested table after closing current paragraph, list and table */
+ /**
+ * Start a new nested table after closing current paragraph, list and table
+ * @param attrs attributes of new RtfTable
+ * @param tc table column info for new RtfTable
+ * @return new RtfTable object
+ * @throws IOException for I/O problems
+ */
// Modified by Boris Poudérous on 07/22/2002
- public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException
- {
+ public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException {
closeAll();
- m_table = new RtfTable(this,writer, attrs, tc); // Added tc Boris Poudérous 07/22/2002
- return m_table;
+ table = new RtfTable(this, writer, attrs, tc); // Added tc Boris Poudérous 07/22/2002
+ return table;
}
/** used by RtfTableRow to write the <celldef> cell definition control words
* @return widthOffset + width of this cell
*/
int writeCellDef(int widthOffset) throws IOException {
- m_widthOffset = widthOffset;
+ this.widthOffset = widthOffset;
// vertical cell merge codes
- if (m_vMerge == MERGE_START) {
+ if (vMerge == MERGE_START) {
writeControlWord("clvmgf");
- } else if (m_vMerge == MERGE_WITH_PREVIOUS) {
+ } else if (vMerge == MERGE_WITH_PREVIOUS) {
writeControlWord("clvmrg");
}
// horizontal cell merge codes
- if (m_hMerge == MERGE_START) {
+ if (hMerge == MERGE_START) {
writeControlWord("clmgf");
- } else if (m_hMerge == MERGE_WITH_PREVIOUS) {
+ } else if (hMerge == MERGE_WITH_PREVIOUS) {
writeControlWord("clmrg");
}
writeAttributes (attrib, BorderAttributesConverter.BORDERS);
// cell width
- final int xPos = widthOffset + this.m_cellWidth;
+ final int xPos = widthOffset + this.cellWidth;
//these lines added by Chris Scott, Westinghouse
//some attributes need to be writting before opening block
- if (set_center) {
+ if (setCenter) {
writeControlWord("qc");
- } else if (set_right) {
+ } else if (setRight) {
writeControlWord("qr");
} else {
writeControlWord("ql");
}
- /** the "cell" control word marks the end of a cell */
+ /**
+ * The "cell" control word marks the end of a cell
+ * @throws IOException for I/O problems
+ */
protected void writeRtfSuffix() throws IOException {
// word97 hangs if cell does not contain at least one "par" control word
// TODO this is what causes the extra spaces in nested table of test
// 004-spacing-in-tables.fo,
// but if is not here we generate invalid RTF for word97
- if (set_center) {
+ if (setCenter) {
writeControlWord("qc");
- } else if (set_right) {
+ } else if (setRight) {
writeControlWord("qr");
} else {
writeControlWord("ql");
//modified by Chris Scott, Westinghouse
private void closeCurrentParagraph() throws IOException {
- if (m_paragraph != null) {
- m_paragraph.close();
+ if (paragraph != null) {
+ paragraph.close();
}
}
private void closeCurrentList() throws IOException {
- if (m_list != null) {
- m_list.close();
+ if (list != null) {
+ list.close();
}
}
private void closeCurrentTable() throws IOException {
- if (m_table != null) {
- m_table.close();
+ if (table != null) {
+ table.close();
}
}
private void closeCurrentExternalGraphic() throws IOException {
- if (m_externalGraphic != null) {
- m_externalGraphic.close();
+ if (externalGraphic != null) {
+ externalGraphic.close();
}
}
closeCurrentExternalGraphic();
}
- /** set vertical cell merging status */
- public void setVMerge(int mergeStatus) { this.m_vMerge = mergeStatus; }
- /** get vertical cell merging status */
- public int getVMerge() { return this.m_vMerge; }
- /** set horizontal cell merging status */
- public void setHMerge(int mergeStatus) { this.m_hMerge = mergeStatus; }
- /** get horizontal cell merging status */
- public int getHMerge() { return this.m_hMerge; }
+ /**
+ * @param mergeStatus vertical cell merging status to set
+ */
+ public void setVMerge(int mergeStatus) { this.vMerge = mergeStatus; }
+
+ /**
+ * @return vertical cell merging status
+ */
+ public int getVMerge() { return this.vMerge; }
+
+ /**
+ * Set horizontal cell merging status
+ * @param mergeStatus mergeStatus to set
+ */
+ public void setHMerge(int mergeStatus) {
+ this.hMerge = mergeStatus;
+ }
+
+ /**
+ * @return horizontal cell merging status
+ */
+ public int getHMerge() {
+ return this.hMerge;
+ }
+
/** get cell width */
- int getCellWidth() { return this.m_cellWidth; }
+ int getCellWidth() { return this.cellWidth; }
- /** overridden so that nested tables cause extra rows to be added after the row
- * that contains this cell
- * disabled for V0.3 - nested table support is not done yet
+ /**
+ * Overridden so that nested tables cause extra rows to be added after the row
+ * that contains this cell
+ * disabled for V0.3 - nested table support is not done yet
+ * @throws IOException for I/O problems
*/
protected void writeRtfContent()
throws IOException {
// 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);
+ parentRow.getExtraRowSet().setParentITableColumnsInfo(
+ ((RtfTable)this.getParentOfClass(e.getClass())).getITableColumnsInfo());
+ extraRowIndex = parentRow.getExtraRowSet().addTable((RtfTable)e,
+ extraRowIndex, 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(), attrib);
+ extraCell = parentRow.getExtraRowSet().createExtraCell(extraRowIndex,
+ widthOffset, this.getCellWidth(), attrib);
extraRowIndex++;
} else if (extraCell != null) {
}
}
- /** A table cell always contains "useful" content, as it is here to take some
- * space in a row.
- * Use containsText() to find out if there is really some useful content in the cell.
- * TODO: containsText could use the original isEmpty implementation?
+ /**
+ * A table cell always contains "useful" content, as it is here to take some
+ * space in a row.
+ * Use containsText() to find out if there is really some useful content in the cell.
+ * TODO: containsText could use the original isEmpty implementation?
+ * @return false (always)
*/
public boolean isEmpty() {
return false;
*/
public class RtfTableRow extends RtfContainer implements ITableAttributes {
- private RtfTableCell m_cell;
- private RtfExtraRowSet m_extraRowSet;
+ private RtfTableCell cell;
+ private RtfExtraRowSet extraRowSet;
private int id;
private int highestCell = 0;
id = idNum;
}
- /** close current cell if any and start a new one */
+ /**
+ * Close current cell if any and start a new one
+ * @param cellWidth width of new cell
+ * @return new RtfTableCell
+ * @throws IOException for I/O problems
+ */
public RtfTableCell newTableCell(int cellWidth) throws IOException {
highestCell++;
- m_cell = new RtfTableCell(this, writer, cellWidth, highestCell);
- return m_cell;
+ cell = new RtfTableCell(this, writer, cellWidth, highestCell);
+ return cell;
}
- /** close current cell if any and start a new one */
+ /**
+ * Close current cell if any and start a new one
+ * @param attrs attributes of new cell
+ * @param cellWidth width of new cell
+ * @return new RtfTableCell
+ * @throws IOException for I/O problems
+ */
public RtfTableCell newTableCell(int cellWidth, RtfAttributes attrs) throws IOException {
highestCell++;
- m_cell = new RtfTableCell(this, writer, cellWidth, attrs, highestCell);
- return m_cell;
+ cell = new RtfTableCell(this, writer, cellWidth, attrs, highestCell);
+ return cell;
}
/**
* Added by Boris POUDEROUS on 07/02/2002
* in order to add an empty cell that is merged with the cell above.
* This cell is placed before or after the nested table.
+ * @param attrs attributes of new cell
+ * @param cellWidth width of new cell
+ * @return new RtfTableCell
+ * @throws IOException for I/O problems
*/
public RtfTableCell newTableCellMergedVertically(int cellWidth,
RtfAttributes attrs) throws IOException {
highestCell++;
- m_cell = new RtfTableCell (this, writer, cellWidth, attrs, highestCell);
- m_cell.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
- return m_cell;
+ cell = new RtfTableCell (this, writer, cellWidth, attrs, highestCell);
+ cell.setVMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ return cell;
}
/**
* Added by Boris POUDEROUS on 07/02/2002
* in order to add an empty cell that is merged with the previous cell.
+ * @param attrs attributes of new cell
+ * @param cellWidth width of new cell
+ * @return new RtfTableCell
+ * @throws IOException for I/O problems
*/
public RtfTableCell newTableCellMergedHorizontally (int cellWidth,
RtfAttributes attrs) throws IOException {
RtfAttributes wAttributes = (RtfAttributes)attrs.clone();
wAttributes.unset("number-columns-spanned");
- m_cell = new RtfTableCell(this, writer, cellWidth, wAttributes, highestCell);
- m_cell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
- return m_cell;
+ cell = new RtfTableCell(this, writer, cellWidth, wAttributes, highestCell);
+ cell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ return cell;
}
+ /**
+ * @throws IOException for I/O problems
+ */
protected void writeRtfPrefix() throws IOException {
writeGroupMark(true);
}
- /** overridden to write trowd and cell definitions before writing our cells */
+ /**
+ * Overridden to write trowd and cell definitions before writing our cells
+ * @throws IOException for I/O problems
+ */
protected void writeRtfContent() throws IOException {
// create new extra row set to allow our cells to put nested tables
// in rows that will be rendered after this one
- m_extraRowSet = new RtfExtraRowSet(writer);
+ extraRowSet = new RtfExtraRowSet(writer);
// render the row and cells definitions
writeControlWord("trowd");
super.writeRtfContent();
}
- /** 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 {
writeControlWord("row");
// write extra rows if any
- m_extraRowSet.writeRtf();
+ extraRowSet.writeRtf();
writeGroupMark(false);
}
RtfExtraRowSet getExtraRowSet() {
- return m_extraRowSet;
+ return extraRowSet;
}
private void writePaddingAttributes()
writeAttributes(attrib, ATTRIB_ROW_PADDING);
}
+ /**
+ * @return true if the row is the first in the table
+ */
public boolean isFirstRow() {
if (id == 1) {
return true;
}
}
+ /**
+ * @param id cell id to check
+ * @return true if the cell is the highest cell
+ */
public boolean isHighestCell(int id) {
return (highestCell == id) ? true : false;
}