org.jfor.jfor.rtflib.rtfdoc
Class RtfText

java.lang.Object
  extended byorg.jfor.jfor.rtflib.rtfdoc.RtfElement
      extended byorg.jfor.jfor.rtflib.rtfdoc.RtfText

public class RtfText
extends RtfElement

Model of a text run (a piece of text with attributes) in an RTF document

Author:
Bertrand Delacretaz bdelacretaz@codeconsult.ch

Field Summary
static java.lang.String ALIGN_CENTER
          RtfText attributes: alignment attributes
static java.lang.String ALIGN_DISTRIBUTED
           
static java.lang.String ALIGN_JUSTIFIED
           
static java.lang.String ALIGN_LEFT
           
static java.lang.String ALIGN_RIGHT
           
static java.lang.String[] ALIGNMENT
          RtfText attributes: this must contain all allignment attributes names
static java.lang.String ATTR_BACKGROUND_COLOR
           
static java.lang.String ATTR_BOLD
          RtfText attributes: attribute names are RTF control word names to avoid additional mapping
static java.lang.String ATTR_FONT_COLOR
           
static java.lang.String ATTR_FONT_FAMILY
           
static java.lang.String ATTR_FONT_SIZE
           
static java.lang.String ATTR_ITALIC
           
static java.lang.String[] ATTR_NAMES
          RtfText attributes: this must contain all attribute names
static java.lang.String ATTR_UNDERLINE
           
static java.lang.String BDR_BOTTOM_DASH
           
static java.lang.String BDR_BOTTOM_DOTTED
           
static java.lang.String BDR_BOTTOM_DOUBLE
           
static java.lang.String BDR_BOTTOM_EMBOSS
           
static java.lang.String BDR_BOTTOM_SINGLE
          RtfText attributes: border attributes
static java.lang.String[] BORDER
          RtfText attributes:: this must contain all border attribute names
static java.lang.String[] INDENT
           
static java.lang.String LEFT_INDENT_BODY
          RtfText attributes: indentation attributes
static java.lang.String LEFT_INDENT_FIRST
           
static java.lang.String RTF_FIELD
          RtfText attributes: fields
static java.lang.String RTF_FIELD_PAGE
           
static java.lang.String RTF_FIELD_RESULT
           
static java.lang.String SPACE_AFTER
           
static java.lang.String SPACE_BEFORE
          Space before/after a paragraph
static java.lang.String TAB_CENTER
           
static java.lang.String TAB_LEADER_DOTS
           
static java.lang.String TAB_LEADER_EQUALS
           
static java.lang.String TAB_LEADER_HYPHEN
           
static java.lang.String TAB_LEADER_THICK
           
static java.lang.String TAB_LEADER_UNDER
           
static java.lang.String TAB_RIGHT
           
static java.lang.String[] TABS
           
 
Fields inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfElement
m_attrib, m_parent, m_writer
 
Constructor Summary
(package private) RtfText(IRtfTextContainer parent, java.io.Writer w, java.lang.String str, RtfAttributes attr)
          Create an RtfText in given IRtfTextContainer.
 
Method Summary
(package private)  java.lang.String getText()
          direct access to our text
 RtfAttributes getTextAttributes()
          get the attributes of our text
 RtfAttributes getTextContainerAttributes()
          IRtfTextContainer requirement: return a copy of our attributes
 boolean isBold(boolean isStart)
           
 boolean isEmpty()
          Checks whether the text is empty.
 boolean isNbsp()
          True if text contains a single non-breaking space (#160).
 boolean isNewLine()
           
 boolean isTab()
           
(package private)  void setText(java.lang.String str)
          direct access to our text
 void writeRtfContent()
          write our text to the RTF stream
 
Methods inherited from class org.jfor.jfor.rtflib.rtfdoc.RtfElement
close, dump, getParentOfClass, getRtfAttributes, getRtfFile, isClosed, okToWriteRtf, toString, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeRtfPrefix, writeRtfSuffix, writeStarControlWord, writeStarControlWordNS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTR_BOLD

public static final java.lang.String ATTR_BOLD
RtfText attributes: attribute names are RTF control word names to avoid additional mapping

See Also:
Constant Field Values

ATTR_ITALIC

public static final java.lang.String ATTR_ITALIC
See Also:
Constant Field Values

ATTR_UNDERLINE

public static final java.lang.String ATTR_UNDERLINE
See Also:
Constant Field Values

ATTR_FONT_SIZE

public static final java.lang.String ATTR_FONT_SIZE
See Also:
Constant Field Values

ATTR_FONT_FAMILY

public static final java.lang.String ATTR_FONT_FAMILY
See Also:
Constant Field Values

ATTR_FONT_COLOR

public static final java.lang.String ATTR_FONT_COLOR
See Also:
Constant Field Values

ATTR_BACKGROUND_COLOR

public static final java.lang.String ATTR_BACKGROUND_COLOR
See Also:
Constant Field Values

ALIGN_CENTER

public static java.lang.String ALIGN_CENTER
RtfText attributes: alignment attributes


ALIGN_LEFT

public static java.lang.String ALIGN_LEFT

ALIGN_RIGHT

public static java.lang.String ALIGN_RIGHT

ALIGN_JUSTIFIED

public static java.lang.String ALIGN_JUSTIFIED

ALIGN_DISTRIBUTED

public static java.lang.String ALIGN_DISTRIBUTED

BDR_BOTTOM_SINGLE

public static java.lang.String BDR_BOTTOM_SINGLE
RtfText attributes: border attributes


BDR_BOTTOM_DOUBLE

public static java.lang.String BDR_BOTTOM_DOUBLE

BDR_BOTTOM_EMBOSS

public static java.lang.String BDR_BOTTOM_EMBOSS

BDR_BOTTOM_DOTTED

public static java.lang.String BDR_BOTTOM_DOTTED

BDR_BOTTOM_DASH

public static java.lang.String BDR_BOTTOM_DASH

RTF_FIELD

public static java.lang.String RTF_FIELD
RtfText attributes: fields


RTF_FIELD_PAGE

public static java.lang.String RTF_FIELD_PAGE

RTF_FIELD_RESULT

public static java.lang.String RTF_FIELD_RESULT

LEFT_INDENT_BODY

public static java.lang.String LEFT_INDENT_BODY
RtfText attributes: indentation attributes


LEFT_INDENT_FIRST

public static java.lang.String LEFT_INDENT_FIRST

TAB_CENTER

public static java.lang.String TAB_CENTER

TAB_RIGHT

public static java.lang.String TAB_RIGHT

TAB_LEADER_DOTS

public static java.lang.String TAB_LEADER_DOTS

TAB_LEADER_HYPHEN

public static java.lang.String TAB_LEADER_HYPHEN

TAB_LEADER_UNDER

public static java.lang.String TAB_LEADER_UNDER

TAB_LEADER_THICK

public static java.lang.String TAB_LEADER_THICK

TAB_LEADER_EQUALS

public static java.lang.String TAB_LEADER_EQUALS

SPACE_BEFORE

public static final java.lang.String SPACE_BEFORE
Space before/after a paragraph

See Also:
Constant Field Values

SPACE_AFTER

public static final java.lang.String SPACE_AFTER
See Also:
Constant Field Values

ALIGNMENT

public static java.lang.String[] ALIGNMENT
RtfText attributes: this must contain all allignment attributes names


BORDER

public static java.lang.String[] BORDER
RtfText attributes:: this must contain all border attribute names


INDENT

public static java.lang.String[] INDENT

TABS

public static java.lang.String[] TABS

ATTR_NAMES

public static final java.lang.String[] ATTR_NAMES
RtfText attributes: this must contain all attribute names

Constructor Detail

RtfText

RtfText(IRtfTextContainer parent,
        java.io.Writer w,
        java.lang.String str,
        RtfAttributes attr)
  throws java.io.IOException
Create an RtfText in given IRtfTextContainer.

Parameters:
str - optional initial text content
Method Detail

writeRtfContent

public void writeRtfContent()
                     throws java.io.IOException
write our text to the RTF stream

Specified by:
writeRtfContent in class RtfElement
Throws:
java.io.IOException

getTextContainerAttributes

public RtfAttributes getTextContainerAttributes()
IRtfTextContainer requirement: return a copy of our attributes


getText

java.lang.String getText()
direct access to our text


setText

void setText(java.lang.String str)
direct access to our text


isEmpty

public boolean isEmpty()
Checks whether the text is empty.

Specified by:
isEmpty in class RtfElement
Returns:
true If m_text is null\n false m_text is set

isNbsp

public boolean isNbsp()
True if text contains a single non-breaking space (#160). TODO make this more general and/or merge with isEmpty? <-- what happen with empty paragraphs, if they will be removed, than NO, else ok

Returns:
true If m_text is character 160\n false m_text is not a nbsp

isTab

public boolean isTab()

isNewLine

public boolean isNewLine()

isBold

public boolean isBold(boolean isStart)

getTextAttributes

public RtfAttributes getTextAttributes()
get the attributes of our text