com.lowagie.text.rtf.document

Class RtfDocument

public class RtfDocument extends RtfElement

The RtfDocument stores all document related data and also the main data stream. INTERNAL CLASS - NOT TO BE USED DIRECTLY

Version: $Id: RtfDocument.java 2808 2007-05-30 10:58:16Z psoares33 $

Author: Mark Hall (mhall@edu.uni-klu.ac.at) Todd Bush [Tab support] Thomas Bickel (tmb99@inode.at)

Field Summary
booleanautogenerateTOCEntries
Whether to automatically generate TOC entries for Chapters and Sections.
RtfDataCachedata
Stores the actual document data
RtfDocumentHeaderdocumentHeader
The RtfDocumentHeader that handles all document header methods
RtfDocumentSettingsdocumentSettings
The RtfDocumentSettings for this RtfDocument.
static byte[]FSC_BACKSLASH
static byte[]FSC_HEX_PREFIX
static byte[]FSC_LINE
static byte[]FSC_NEWPAGE
static byte[]FSC_PAGE_PAR
static byte[]FSC_PAR
static byte[]FSC_TAB
static byte[]FSC_UNI_PREFIX
RtfBasicElementlastElementWritten
The last RtfBasicElement that was added directly to the RtfDocument.
RtfMappermapper
The RtfMapper to use in this RtfDocument
ArrayListpreviousRandomInts
Stores integers that have been generated as unique random numbers
static byte[]RTF_DOCUMENT
Constant for the Rtf document start
Constructor Summary
RtfDocument()
The default constructor for a RtfDocument
Method Summary
voidadd(RtfBasicElement element)
Adds an element to the rtf document
StringfilterSpecialChar(String str, boolean useHex, boolean softLineBreaks)
Replaces special characters with their unicode values
voidfilterSpecialChar(OutputStream out, String str, boolean useHex, boolean softLineBreaks)
Writes the given string to the given OutputStream encoding the string characters.
booleangetAutogenerateTOCEntries()
Get whether to autmatically generate table of contents entries
RtfDocumentHeadergetDocumentHeader()
Gets the RtfDocumentHeader of this RtfDocument
RtfDocumentSettingsgetDocumentSettings()
Gets the RtfDocumentSettings that specify how the rtf document is generated.
RtfBasicElementgetLastElementWritten()
Gets the last RtfBasicElement that was directly added to the RtfDocument.
RtfMappergetMapper()
Gets the RtfMapper object of this RtfDocument
intgetRandomInt()
Generates a random integer that is unique with respect to the document.
voidopen()
Opens the RtfDocument and initialises the data cache.
voidsetAutogenerateTOCEntries(boolean autogenerate)
Whether to automagically generate table of contents entries when adding Chapters or Sections.
static booleansubMatch(String str, int soff, byte[] m)
Returns true if m.length characters in str, starting at offset soff match the bytes in the given array m.
byte[]write()
unused
voidwriteContent(OutputStream out)
unused
voidwriteDocument(OutputStream out)
Writes the document

Field Detail

autogenerateTOCEntries

private boolean autogenerateTOCEntries
Whether to automatically generate TOC entries for Chapters and Sections. Defaults to false

data

private RtfDataCache data
Stores the actual document data

documentHeader

private RtfDocumentHeader documentHeader
The RtfDocumentHeader that handles all document header methods

documentSettings

private RtfDocumentSettings documentSettings
The RtfDocumentSettings for this RtfDocument.

FSC_BACKSLASH

private static final byte[] FSC_BACKSLASH

FSC_HEX_PREFIX

private static final byte[] FSC_HEX_PREFIX

FSC_LINE

private static final byte[] FSC_LINE

FSC_NEWPAGE

private static final byte[] FSC_NEWPAGE

FSC_PAGE_PAR

private static final byte[] FSC_PAGE_PAR

FSC_PAR

private static final byte[] FSC_PAR

FSC_TAB

private static final byte[] FSC_TAB

FSC_UNI_PREFIX

private static final byte[] FSC_UNI_PREFIX

lastElementWritten

private RtfBasicElement lastElementWritten
The last RtfBasicElement that was added directly to the RtfDocument.

mapper

private RtfMapper mapper
The RtfMapper to use in this RtfDocument

previousRandomInts

private ArrayList previousRandomInts
Stores integers that have been generated as unique random numbers

RTF_DOCUMENT

private static final byte[] RTF_DOCUMENT
Constant for the Rtf document start

Constructor Detail

RtfDocument

public RtfDocument()
The default constructor for a RtfDocument

Method Detail

add

public void add(RtfBasicElement element)
Adds an element to the rtf document

Parameters: element The element to add

filterSpecialChar

public String filterSpecialChar(String str, boolean useHex, boolean softLineBreaks)

Deprecated: replaced by RtfDocument

Replaces special characters with their unicode values

Parameters: str The original String useHex indicated if the hexadecimal value has to be used softLineBreaks whether to use soft line breaks instead of default hard ones.

Returns: The converted String

filterSpecialChar

public void filterSpecialChar(OutputStream out, String str, boolean useHex, boolean softLineBreaks)
Writes the given string to the given OutputStream encoding the string characters.

Parameters: out destination OutputStream str string to write useHex if true hex encoding characters is preferred to unicode encoding if possible softLineBreaks if true return characters are written as soft line breaks

Throws: IOException

getAutogenerateTOCEntries

public boolean getAutogenerateTOCEntries()
Get whether to autmatically generate table of contents entries

Returns: Wheter to automatically generate TOC entries

getDocumentHeader

public RtfDocumentHeader getDocumentHeader()
Gets the RtfDocumentHeader of this RtfDocument

Returns: The RtfDocumentHeader of this RtfDocument

getDocumentSettings

public RtfDocumentSettings getDocumentSettings()
Gets the RtfDocumentSettings that specify how the rtf document is generated.

Returns: The current RtfDocumentSettings.

getLastElementWritten

public RtfBasicElement getLastElementWritten()
Gets the last RtfBasicElement that was directly added to the RtfDocument.

Returns: The last RtfBasicElement that was directly added to the RtfDocument.

getMapper

public RtfMapper getMapper()
Gets the RtfMapper object of this RtfDocument

Returns: The RtfMapper

getRandomInt

public int getRandomInt()
Generates a random integer that is unique with respect to the document.

Returns: A random int

open

public void open()
Opens the RtfDocument and initialises the data cache. If the data cache is set to CACHE_DISK, but the cache cannot be initialised then the memory cache is used.

setAutogenerateTOCEntries

public void setAutogenerateTOCEntries(boolean autogenerate)
Whether to automagically generate table of contents entries when adding Chapters or Sections.

Parameters: autogenerate Whether to automatically generate TOC entries

subMatch

private static boolean subMatch(String str, int soff, byte[] m)
Returns true if m.length characters in str, starting at offset soff match the bytes in the given array m.

Parameters: str the string to search for a match soff the starting offset in str m the array to match

Returns: true if there is match

write

public byte[] write()

Deprecated: replaced by writeContent

unused

writeContent

public void writeContent(OutputStream out)
unused

writeDocument

public void writeDocument(OutputStream out)
Writes the document

Parameters: out The OutputStream to write the RTF document to.