Top Description Fields Constructors Methods
org.eclipse.swt.custom

pack-priv Class RTFWriter

extends StyledTextWriterBase
Class Inheritance
Imports
java.util.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*

The RTFWriter class is used to write styled content as rich text. The implementation complies with the RTF specification version 1.5.

toString() is guaranteed to return a valid formatted string only after close() has been called.

Whole and partial lines and line breaks can be written. Lines will be formatted using the styles queried from the LineStyleListener, if set, or those set directly in the widget. All styles are applied to the stream like they are rendered by the widget. In addition, the widget font name and size is used for the whole text.

Field Summary

Modifier and TypeField and Description
pack-priv List<Color>
pack-priv static final int
pack-priv static final int
pack-priv List<Font>
Inherited from org.eclipse.swt.custom.StyledTextWriterBase:
styledText

Constructor Summary

AccessConstructor and Description
public
RTFWriter(StyledText styledText, int start, int length)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides org.eclipse.swt.custom.TextWriter.close.

Closes the writer.
pack-priv String
escapeText(String
the text to escape
string
)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.escapeText.

Takes plain text and returns the same text escaped using the rules of the output format.
private int

Returns:

the index of the specified color in the RTF color table or "defaultIndex" if "color" is null.
getColorIndex
(Color
the color
color
,
int
return value if color is null
defaultIndex
)

Returns the index of the specified color in the RTF color table.

private int

Returns:

the index of the specified color in the RTF color table or "defaultIndex" if "color" is null.
getFontIndex
(Font
the color
font
)

Returns the index of the specified color in the RTF color table.

pack-priv void
writeEmptyLine()

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeEmptyLine.

Invoked at the end of each line, writeLineEnd, if there was no text output.
pack-priv void
writeHeader()

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeHeader.

Writes the RTF header including font table and color table.
public void
writeLineDelimiter(String
line delimiter to write
lineDelimiter
)

Overrides org.eclipse.swt.custom.TextWriter.writeLineDelimiter.

Appends the specified line delimiter to the data.
pack-priv String
writeLineStart(Color lineBackground, int indent, int verticalIndent, int alignment, boolean justify)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeLineStart.

Invoked at the beginning of each line in the original widget.
pack-priv String
writeSpanStart(StyleRange style)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeSpanStart.

Invoked at the beginning of each styled span fragment in the original widget.
Inherited from org.eclipse.swt.custom.StyledTextWriterBase:
writeEscapedwriteLinewriteLineEndwriteSpanEndwriteStyledLine

Field Detail

colorTableback to summary
pack-priv List<Color> colorTable
DEFAULT_BACKGROUNDback to summary
pack-priv static final int DEFAULT_BACKGROUND
DEFAULT_FOREGROUNDback to summary
pack-priv static final int DEFAULT_FOREGROUND
fontTableback to summary
pack-priv List<Font> fontTable

Constructor Detail

RTFWriterback to summary
public RTFWriter(StyledText styledText, int start, int length)

Method Detail

closeback to summary
public void close()

Overrides org.eclipse.swt.custom.TextWriter.close.

Doc from org.eclipse.swt.custom.TextWriter.close.

Closes the writer. Once closed no more content can be written

Note

toString() is not guaranteed to return a valid string unless the writer is closed.

Annotations
@Override
escapeTextback to summary
pack-priv String escapeText(String string)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.escapeText.

Doc from org.eclipse.swt.custom.StyledTextWriterBase.escapeText.

Takes plain text and returns the same text escaped using the rules of the output format.

Parameters
string:String

the text to escape

Returns:String

the escaped text

Annotations
@Override
getColorIndexback to summary
private int getColorIndex(Color color, int defaultIndex)

Returns the index of the specified color in the RTF color table.

Parameters
color:Color

the color

defaultIndex:int

return value if color is null

Returns:int

the index of the specified color in the RTF color table or "defaultIndex" if "color" is null.

getFontIndexback to summary
private int getFontIndex(Font font)

Returns the index of the specified color in the RTF color table.

Parameters
font:Font

the color

Returns:int

the index of the specified color in the RTF color table or "defaultIndex" if "color" is null.

writeEmptyLineback to summary
pack-priv void writeEmptyLine()

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeEmptyLine.

Doc from org.eclipse.swt.custom.StyledTextWriterBase.writeEmptyLine.

Invoked at the end of each line, writeLineEnd, if there was no text output.

This is needed for HTML, which does not render empty paragraphs.

Annotations
@Override
writeHeaderback to summary
pack-priv void writeHeader()

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeHeader.

Writes the RTF header including font table and color table.

Annotations
@Override
writeLineDelimiterback to summary
public void writeLineDelimiter(String lineDelimiter)

Overrides org.eclipse.swt.custom.TextWriter.writeLineDelimiter.

Doc from org.eclipse.swt.custom.TextWriter.writeLineDelimiter.

Appends the specified line delimiter to the data.

Parameters
lineDelimiter:String

line delimiter to write

Annotations
@Override
writeLineStartback to summary
pack-priv String writeLineStart(Color lineBackground, int indent, int verticalIndent, int alignment, boolean justify)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeLineStart.

Doc from org.eclipse.swt.custom.StyledTextWriterBase.writeLineStart.

Invoked at the beginning of each line in the original widget.

It should output whatever tags are appropriate to start a new line in the output format.
It will return the text that has to be output at the end of the line.

Returns:String

the text to append at the end of the line

Annotations
@Override
writeSpanStartback to summary
pack-priv String writeSpanStart(StyleRange style)

Implements abstract org.eclipse.swt.custom.StyledTextWriterBase.writeSpanStart.

Doc from org.eclipse.swt.custom.StyledTextWriterBase.writeSpanStart.

Invoked at the beginning of each styled span fragment in the original widget.

It should output whatever tags are appropriate to start a formatted span in the output format.
It will return the text that has to be output at the end of the span (to close it).

Returns:String

the text to append at the end of the styled span

Annotations
@Override