Class RtfTableCell
- java.lang.Object
-
- org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
-
- org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer
-
- org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell
-
- All Implemented Interfaces:
IRtfExternalGraphicContainer
,IRtfListContainer
,IRtfParagraphContainer
,IRtfTableContainer
,IRtfTextrunContainer
public class RtfTableCell extends RtfContainer implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer, IRtfExternalGraphicContainer, IRtfTextrunContainer
A cell in an RTF table, container for paragraphs, lists, etc.
This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch).
-
-
Field Summary
Fields Modifier and Type Field Description private int
cellWidth
cell width in twipsstatic int
DEFAULT_CELL_WIDTH
default cell width (in twips ??)private RtfExternalGraphic
externalGraphic
private int
hMerge
private int
id
private RtfParagraphBreak
lastBreak
private RtfList
list
static int
MERGE_START
cell merging: this cell is the start of a range of merged cellsstatic int
MERGE_WITH_PREVIOUS
cell merging: this cell is part of (but not the start of) a range of merged cellsstatic int
NO_MERGE
cell merging: this cell is not mergedprivate RtfParagraph
paragraph
private RtfTableRow
parentRow
private boolean
setCenter
private boolean
setRight
private RtfTable
table
private static java.lang.String
TABLE_CELL_NESTED_PARAGRAPH
private static java.lang.String
TABLE_CELL_PARAGRAPH
private int
vMerge
cell merging has three statesprivate int
widthOffset
-
Fields inherited from class org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
attrib, parent, writer
-
-
Constructor Summary
Constructors Constructor Description RtfTableCell(RtfTableRow parent, java.io.Writer w, int cellWidth, int idNum)
Create an RTF element as a child of given containerRtfTableCell(RtfTableRow parent, java.io.Writer w, int cellWidth, RtfAttributes attrs, int idNum)
Create an RTF element as a child of given container
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
closeAll()
private void
closeCurrentExternalGraphic()
private void
closeCurrentList()
private void
closeCurrentParagraph()
private void
closeCurrentTable()
void
finish()
The last paragraph break was just stored before, now the control word is really switched(package private) int
getCellWidth()
get cell widthint
getHMerge()
RtfTableRow
getRow()
Get the parent row.RtfTextrun
getTextrun()
Returns the current RtfTextrun object.int
getVMerge()
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 tableRtfList
newList(RtfAttributes attrib)
Start a new list after closing current paragraph, list and tableRtfParagraph
newParagraph()
Start a new paragraph with default attributes after closing current paragraph, list and tableRtfParagraph
newParagraph(RtfAttributes attrs)
Start a new paragraph after closing current current paragraph, list and tableRtfTable
newTable(ITableColumnsInfo tc)
Start a new nested table after closing current paragraph, list and tableRtfTable
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 statusvoid
setLastParagraph(RtfParagraphBreak parBreak)
The table cell decides whether or not a newly added paragraph break will be used to write the cell-end control word.void
setVMerge(int mergeStatus)
(package private) int
writeCellDef(int offset)
used by RtfTableRow to write thecell definition control words protected void
writeRtfContent()
Overriden to avoid writing any it's a merged cell.protected void
writeRtfPrefix()
Called before writeRtfContent; overriden to avoid writing any it's a merged cell.protected void
writeRtfSuffix()
The "cell" control word marks the end of a cell-
Methods inherited from class org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer
addChild, containsText, dump, findChildren, getChildCount, getChildren, getOptions, okToWriteRtf, setChildren, setOptions, toString
-
Methods inherited from class org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
close, getParentOfClass, getRtfAttributes, getRtfFile, isClosed, newLine, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeStarControlWord, writeStarControlWordNS
-
-
-
-
Field Detail
-
paragraph
private RtfParagraph paragraph
-
list
private RtfList list
-
table
private RtfTable table
-
externalGraphic
private RtfExternalGraphic externalGraphic
-
parentRow
private final RtfTableRow parentRow
-
setCenter
private boolean setCenter
-
setRight
private boolean setRight
-
id
private int id
-
lastBreak
private RtfParagraphBreak lastBreak
-
TABLE_CELL_PARAGRAPH
private static final java.lang.String TABLE_CELL_PARAGRAPH
- See Also:
- Constant Field Values
-
TABLE_CELL_NESTED_PARAGRAPH
private static final java.lang.String TABLE_CELL_NESTED_PARAGRAPH
- See Also:
- Constant Field Values
-
DEFAULT_CELL_WIDTH
public static final int DEFAULT_CELL_WIDTH
default cell width (in twips ??)- See Also:
- Constant Field Values
-
cellWidth
private int cellWidth
cell width in twips
-
widthOffset
private int widthOffset
-
vMerge
private int vMerge
cell merging has three states
-
hMerge
private int hMerge
-
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 interfaceIRtfParagraphContainer
- Parameters:
attrs
- attributes of new RtfParagraph- Returns:
- new RtfParagraph object
- Throws:
java.io.IOException
- for I/O problems
-
newImage
public RtfExternalGraphic newImage() throws java.io.IOException
Start a new external graphic after closing current paragraph, list and table- Specified by:
newImage
in interfaceIRtfExternalGraphicContainer
- Returns:
- new RtfExternalGraphic object
- Throws:
java.io.IOException
- for I/O problems
-
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 interfaceIRtfParagraphContainer
- Returns:
- new RtfParagraph object
- Throws:
java.io.IOException
- for I/O problems
-
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 interfaceIRtfListContainer
- Parameters:
attrib
- attributes for new RtfList- Returns:
- new RtfList object
- Throws:
java.io.IOException
- for I/O problems
-
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 interfaceIRtfTableContainer
- Parameters:
tc
- table column info for new RtfTable- Returns:
- new RtfTable object
- Throws:
java.io.IOException
- for I/O problems
-
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 interfaceIRtfTableContainer
- Parameters:
attrs
- attributes of new RtfTabletc
- table column info for new RtfTable- Returns:
- new RtfTable object
- Throws:
java.io.IOException
- for I/O problems
-
writeCellDef
int writeCellDef(int offset) throws java.io.IOException
used by RtfTableRow to write thecell definition control words - Parameters:
offset
- sum of the widths of preceeding cells in same row- Returns:
- offset + width of this cell
- Throws:
java.io.IOException
-
writeRtfContent
protected void writeRtfContent() throws java.io.IOException
Overriden to avoid writing any it's a merged cell.- Overrides:
writeRtfContent
in classRtfContainer
- Throws:
java.io.IOException
- for I/O problems
-
writeRtfPrefix
protected void writeRtfPrefix() throws java.io.IOException
Called before writeRtfContent; overriden to avoid writing any it's a merged cell.- Overrides:
writeRtfPrefix
in classRtfElement
- Throws:
java.io.IOException
- for I/O problems
-
writeRtfSuffix
protected void writeRtfSuffix() throws java.io.IOException
The "cell" control word marks the end of a cell- Overrides:
writeRtfSuffix
in classRtfElement
- Throws:
java.io.IOException
- for I/O problems
-
closeCurrentParagraph
private void closeCurrentParagraph() throws java.io.IOException
- Throws:
java.io.IOException
-
closeCurrentList
private void closeCurrentList() throws java.io.IOException
- Throws:
java.io.IOException
-
closeCurrentTable
private void closeCurrentTable() throws java.io.IOException
- Throws:
java.io.IOException
-
closeCurrentExternalGraphic
private void closeCurrentExternalGraphic() throws java.io.IOException
- Throws:
java.io.IOException
-
closeAll
private void closeAll() throws java.io.IOException
- Throws:
java.io.IOException
-
setVMerge
public void setVMerge(int mergeStatus)
- Parameters:
mergeStatus
- vertical cell merging status to set
-
getVMerge
public int getVMerge()
- Returns:
- vertical cell merging status
-
setHMerge
public void setHMerge(int mergeStatus)
Set horizontal cell merging status- Parameters:
mergeStatus
- mergeStatus to set
-
getHMerge
public int getHMerge()
- Returns:
- horizontal cell merging status
-
getCellWidth
int getCellWidth()
get cell width
-
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 classRtfContainer
- Returns:
- false (always)
-
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)
-
getTextrun
public RtfTextrun getTextrun() throws java.io.IOException
Returns the current RtfTextrun object. Opens a new one if necessary.- Specified by:
getTextrun
in interfaceIRtfTextrunContainer
- Returns:
- The RtfTextrun object
- Throws:
java.io.IOException
- Thrown when an IO-problem occurs
-
getRow
public RtfTableRow getRow()
Get the parent row.- Returns:
- The parent row.
-
setLastParagraph
public void setLastParagraph(RtfParagraphBreak parBreak)
The table cell decides whether or not a newly added paragraph break will be used to write the cell-end control word. For nested tables it is not necessary.- Parameters:
parBreak
- the paragraph break element
-
finish
public void finish()
The last paragraph break was just stored before, now the control word is really switched
-
-