Class RtfElement
java.lang.Object
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
- Direct Known Subclasses:
RtfBookmark
,RtfContainer
,RtfExternalGraphic
,RtfFontTable
,RtfGenerator
,RtfLineBreak
,RtfPageBreak
,RtfParagraphBreak
,RtfString
,RtfText
,RtfTextrun.RtfCloseGroupMark
,RtfTextrun.RtfOpenGroupMark
Base class for all elements of an RTF file.
This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch) and Andreas Putz (a.putz@skynamics.com).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RtfAttributes
attributes of the elementprivate boolean
private final int
private static int
protected final RtfContainer
parent elementprotected final Writer
Writer to be usedprivate boolean
-
Constructor Summary
ConstructorsConstructorDescriptionRtfElement
(RtfContainer parent, Writer w) Create an RTF element as a child of given containerRtfElement
(RtfContainer parent, Writer w, RtfAttributes attr) Create an RTF element as a child of given container with given attributes -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
Does nothing, meant to allow elements to write themselves without waiting for write(), but not implemented yet(package private) void
debugging to given PrintWriterfind the first parent where c.isAssignableFrom(parent.getClass()) is trueAdded by Normand Masse Used for attribute inheritance(package private) RtfFile
access our RtfFile, which is always the topmost parent(package private) boolean
isClosed()
true if close() has been calledabstract boolean
isEmpty()
void
newLine()
Starts a new line in the RTF file being written.protected boolean
can be overridden to suppress all RTF outputtoString()
minimal debugging displayprotected void
writeAttributes
(RtfAttributes attr, String[] nameList) Write given attribute values to our Writerprotected final void
writeControlWord
(String word) Write an RTF control word to our Writerprotected final void
writeControlWordNS
(String word) Write rtf control word without the space behind itprotected void
Make a visible entry in the RTF for an exceptionprotected final void
writeGroupMark
(boolean isStart) Write a start or end group markprotected void
writeOneAttribute
(String name, Object value) Write one attribute to our Writerprotected void
writeOneAttributeNS
(String name, Object value) Write one attribute to our Writer without a spacefinal void
writeRtf()
Write the RTF code of this element to our Writerprotected abstract void
Must be implemented to write RTF content to m_writerprotected void
Called before writeRtfContent()protected void
Called after writeRtfContent()protected final void
writeStarControlWord
(String word) Write an RTF control word to our Writer, preceeded by a star '*' meaning "ignore this if you don't know what it means"protected final void
writeStarControlWordNS
(String word) Same as writeStarControlWord(String word), except with no space behind it
-
Field Details
-
writer
Writer to be used -
parent
parent element -
attrib
attributes of the element -
written
private boolean written -
closed
private boolean closed -
id
private final int id -
idCounter
private static int idCounter
-
-
Constructor Details
-
RtfElement
RtfElement(RtfContainer parent, Writer w) throws IOException Create an RTF element as a child of given container- Throws:
IOException
-
RtfElement
RtfElement(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException Create an RTF element as a child of given container with given attributes- Throws:
IOException
-
-
Method Details
-
close
Does nothing, meant to allow elements to write themselves without waiting for write(), but not implemented yet- Throws:
IOException
- for I/O problems
-
writeRtf
Write the RTF code of this element to our Writer- Throws:
IOException
- for I/O problems
-
newLine
Starts a new line in the RTF file being written. This is only to format the RTF file itself (for easier debugging), not its content.- Throws:
IOException
- in case of an I/O problem
-
writeControlWord
Write an RTF control word to our Writer- Parameters:
word
- RTF control word to write- Throws:
IOException
- for I/O problems
-
writeStarControlWord
Write an RTF control word to our Writer, preceeded by a star '*' meaning "ignore this if you don't know what it means"- Parameters:
word
- RTF control word to write- Throws:
IOException
- for I/O problems
-
writeStarControlWordNS
Same as writeStarControlWord(String word), except with no space behind it- Parameters:
word
- RTF control word to write- Throws:
IOException
- for I/O problems
-
writeControlWordNS
Write rtf control word without the space behind it- Parameters:
word
- RTF control word to write- Throws:
IOException
- for I/O problems
-
writeRtfPrefix
Called before writeRtfContent()- Throws:
IOException
- for I/O problems
-
writeRtfContent
Must be implemented to write RTF content to m_writer- Throws:
IOException
- for I/O problems
-
writeRtfSuffix
Called after writeRtfContent()- Throws:
IOException
- for I/O problems
-
writeGroupMark
Write a start or end group mark- Parameters:
isStart
- set to true if this is a start mark- Throws:
IOException
- for I/O problems
-
writeAttributes
Write given attribute values to our Writer- Parameters:
attr
- RtfAttributes to be writtennameList
- if given, only attribute names from this list are considered- Throws:
IOException
- for I/O problems
-
writeOneAttribute
Write one attribute to our Writer- Parameters:
name
- name of attribute to writevalue
- value of attribute to be written- Throws:
IOException
- for I/O problems
-
writeOneAttributeNS
Write one attribute to our Writer without a space- Parameters:
name
- name of attribute to writevalue
- value of attribute to be written- Throws:
IOException
- for I/O problems
-
okToWriteRtf
protected boolean okToWriteRtf()can be overridden to suppress all RTF output- Returns:
- true if this object can be written into the RTF
-
dump
debugging to given PrintWriter- Throws:
IOException
-
toString
minimal debugging display -
isClosed
boolean isClosed()true if close() has been called -
getRtfFile
RtfFile getRtfFile()access our RtfFile, which is always the topmost parent -
getParentOfClass
find the first parent where c.isAssignableFrom(parent.getClass()) is true- Returns:
- null if not found
-
isEmpty
public abstract boolean isEmpty()- Returns:
- true if this element would generate no "useful" RTF content
-
writeExceptionInRtf
Make a visible entry in the RTF for an exception- Parameters:
ie
- Exception to flag- Throws:
IOException
- for I/O problems
-
getRtfAttributes
Added by Normand Masse Used for attribute inheritance- Returns:
- RtfAttributes
-