org.jfor.jfor.rtflib.rtfdoc
Class RtfTableCell

java.lang.Object
  extended by org.jfor.jfor.rtflib.rtfdoc.RtfElement
      extended by org.jfor.jfor.rtflib.rtfdoc.RtfContainer
          extended by org.jfor.jfor.rtflib.rtfdoc.RtfTableCell
All Implemented Interfaces:
IRtfExternalGraphicContainer, IRtfListContainer, IRtfParagraphContainer, IRtfTableContainer

public class RtfTableCell
extends RtfContainer
implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer, IRtfExternalGraphicContainer

A cell in an RTF table, container for paragraphs, lists, etc.

Author:
Bertrand Delacretaz bdelacretaz@codeconsult.ch

Field Summary
static int DEFAULT_CELL_WIDTH
           
static int MERGE_START
          cell merging: this cell is the start of a range of merged cells
static int MERGE_WITH_PREVIOUS
          cell merging: this cell is part of (but not the start of) a range of merged cells
static int NO_MERGE
          cell merging: this cell is not merged
 
Fields inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfElement
m_attrib, m_parent, m_writer
 
Constructor Summary
RtfTableCell(RtfTableRow parent, java.io.Writer w, int cellWidth, int idNum)
          Create an RTF element as a child of given container
RtfTableCell(RtfTableRow parent, java.io.Writer w, int cellWidth, RtfAttributes attrs, int idNum)
          Create an RTF element as a child of given container
 
Method Summary
(package private)  int getCellWidth()
          get cell width
 int getHMerge()
          get horizontal cell merging status
 int getVMerge()
          get vertical cell merging status
 boolean isEmpty()
          A table cell always contains "useful" content, as it is here to take some space in a row.
 RtfExternalGraphic newImage()
          start a new external graphic after closing current paragraph, list and table
 RtfList newList(RtfAttributes attrib)
          start a new list after closing current paragraph, list and table
 RtfParagraph newParagraph()
          start a new paragraph with default attributes after closing current paragraph, list and table
 RtfParagraph newParagraph(RtfAttributes attrs)
          start a new paragraph after closing current current paragraph, list and table
 RtfTable newTable(ITableColumnsInfo tc)
          start a new nested table after closing current paragraph, list and table
 RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc)
          start a new nested table after closing current paragraph, list and table
(package private)  boolean paragraphNeedsPar(RtfParagraph p)
          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)
 void setHMerge(int mergeStatus)
          set horizontal cell merging status
 void setVMerge(int mergeStatus)
          set vertical cell merging status
(package private)  int writeCellDef(int widthOffset)
          used by RtfTableRow to write the cell definition control words
protected  void writeRtfContent()
          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
protected  void writeRtfSuffix()
          the "cell" control word marks the end of a cell
 
Methods inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfContainer
addChild, containsText, dump, getChildCount, getChildren, getOptions, okToWriteRtf, setChildren, setOptions, toString
 
Methods inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfElement
close, getParentOfClass, getRtfAttributes, getRtfFile, isClosed, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeRtfPrefix, writeStarControlWord, writeStarControlWordNS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CELL_WIDTH

public static final int DEFAULT_CELL_WIDTH
See Also:
Constant Field Values

NO_MERGE

public static final int NO_MERGE
cell merging: this cell is not merged

See Also:
Constant Field Values

MERGE_START

public static final int MERGE_START
cell merging: this cell is the start of a range of merged cells

See Also:
Constant Field Values

MERGE_WITH_PREVIOUS

public static final int MERGE_WITH_PREVIOUS
cell merging: this cell is part of (but not the start of) a range of merged cells

See Also:
Constant Field Values
Constructor Detail

RtfTableCell

RtfTableCell(RtfTableRow parent,
             java.io.Writer w,
             int cellWidth,
             int idNum)
       throws java.io.IOException
Create an RTF element as a child of given container

Throws:
java.io.IOException

RtfTableCell

RtfTableCell(RtfTableRow parent,
             java.io.Writer w,
             int cellWidth,
             RtfAttributes attrs,
             int idNum)
       throws java.io.IOException
Create an RTF element as a child of given container

Throws:
java.io.IOException
Method Detail

newParagraph

public RtfParagraph newParagraph(RtfAttributes attrs)
                          throws java.io.IOException
start a new paragraph after closing current current paragraph, list and table

Specified by:
newParagraph in interface IRtfParagraphContainer
Throws:
java.io.IOException

newImage

public RtfExternalGraphic newImage()
                            throws java.io.IOException
start a new external graphic after closing current paragraph, list and table

Specified by:
newImage in interface IRtfExternalGraphicContainer
Throws:
java.io.IOException - On error

newParagraph

public RtfParagraph newParagraph()
                          throws java.io.IOException
start a new paragraph with default attributes after closing current paragraph, list and table

Specified by:
newParagraph in interface IRtfParagraphContainer
Throws:
java.io.IOException

newList

public RtfList newList(RtfAttributes attrib)
                throws java.io.IOException
start a new list after closing current paragraph, list and table

Specified by:
newList in interface IRtfListContainer
Throws:
java.io.IOException

newTable

public RtfTable newTable(ITableColumnsInfo tc)
                  throws java.io.IOException
start a new nested table after closing current paragraph, list and table

Specified by:
newTable in interface IRtfTableContainer
Throws:
java.io.IOException

newTable

public RtfTable newTable(RtfAttributes attrs,
                         ITableColumnsInfo tc)
                  throws java.io.IOException
start a new nested table after closing current paragraph, list and table

Specified by:
newTable in interface IRtfTableContainer
tc - added by Boris Poud?rous on july 2002 in order to process number-columns-spanned attribute
Throws:
java.io.IOException

writeCellDef

int writeCellDef(int widthOffset)
           throws java.io.IOException
used by RtfTableRow to write the cell definition control words

Parameters:
widthOffset - sum of the widths of preceeding cells in same row
Returns:
widthOffset + width of this cell
Throws:
java.io.IOException

writeRtfSuffix

protected void writeRtfSuffix()
                       throws java.io.IOException
the "cell" control word marks the end of a cell

Overrides:
writeRtfSuffix in class RtfElement
Throws:
java.io.IOException

setVMerge

public void setVMerge(int mergeStatus)
set vertical cell merging status


getVMerge

public int getVMerge()
get vertical cell merging status


setHMerge

public void setHMerge(int mergeStatus)
set horizontal cell merging status


getHMerge

public int getHMerge()
get horizontal cell merging status


getCellWidth

int getCellWidth()
get cell width


writeRtfContent

protected void writeRtfContent()
                        throws java.io.IOException
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

Overrides:
writeRtfContent in class RtfContainer
Throws:
java.io.IOException

isEmpty

public boolean isEmpty()
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?

Overrides:
isEmpty in class RtfContainer

paragraphNeedsPar

boolean paragraphNeedsPar(RtfParagraph p)
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)