ru.novosoft.dc.rtf.dom
Class RTFDocument

java.lang.Object
  |
  +--ru.novosoft.dc.rtf.dom.RTFDocument

public class RTFDocument
extends java.lang.Object

The root class of the RTF DOM. It consists of the document properties and an array of sections.


Constructor Summary
RTFDocument(SectionContext context)
          Create a new document with an empty first section.
 
Method Summary
 DocumentContext context()
          Return the document context.
 org.w3c.dom.Document DOM(org.w3c.dom.DOMImplementation handler, boolean usedFontsOnly)
          Compose a W3C DOM representation of the RTF DOM and return it.
 void expansionRequired()
          Set request for expanding character contexts while optimization.
 ColorTable getColorTable()
          Return the color table or null.
 CustomInformation getCustomInfo()
          Return the custom document information or null.
 FontTable getFontTable()
          Return the font table or null.
 DocumentInformation getInfo()
          Return the document information or null.
 StyleSheet getStyleSheet()
          Return the style sheet table or null.
 void mergeRequired()
          Set request for merge of near inline strings with the same context while optimization.
 RTFSection newSection(SectionContext context)
          Create a new section in the document content and return it.
 void optimize(boolean needMerge, boolean needExpand, int shapeMask)
          Optimization of the RTF Document.
 void removeSection(int index)
          Remove a section at the specified position in the range [0..sectionCount()-1].
 RTFSection section()
          Return the last section of the document.
 RTFSection section(int index)
          Return a section of the specified index in the range [0..sectionCount()-1].
 int sectionCount()
          Return the current number of sections.
 void setColorTable(ColorTable value)
          Set a color table.
 void setCustomInfo(CustomInformation value)
          Set a custom document information object.
 void setFontTable(FontTable value)
          Set a font table.
 void setInfo(DocumentInformation value)
          Set a document information object.
 void setStyleSheet(StyleSheet value)
          Set a style sheet table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RTFDocument

public RTFDocument(SectionContext context)
Create a new document with an empty first section.
Method Detail

context

public final DocumentContext context()
Return the document context.

newSection

public final RTFSection newSection(SectionContext context)
Create a new section in the document content and return it. Headers and footers are inhereted from the previous section.

sectionCount

public final int sectionCount()
Return the current number of sections.

section

public final RTFSection section()
Return the last section of the document.

section

public final RTFSection section(int index)
Return a section of the specified index in the range [0..sectionCount()-1].

removeSection

public final void removeSection(int index)
Remove a section at the specified position in the range [0..sectionCount()-1].

setFontTable

public final void setFontTable(FontTable value)
Set a font table.

getFontTable

public final FontTable getFontTable()
Return the font table or null.

setColorTable

public final void setColorTable(ColorTable value)
Set a color table.

getColorTable

public final ColorTable getColorTable()
Return the color table or null.

setStyleSheet

public final void setStyleSheet(StyleSheet value)
Set a style sheet table.

getStyleSheet

public final StyleSheet getStyleSheet()
Return the style sheet table or null.

setInfo

public final void setInfo(DocumentInformation value)
Set a document information object.

getInfo

public final DocumentInformation getInfo()
Return the document information or null.

setCustomInfo

public final void setCustomInfo(CustomInformation value)
Set a custom document information object.

getCustomInfo

public final CustomInformation getCustomInfo()
Return the custom document information or null.

DOM

public org.w3c.dom.Document DOM(org.w3c.dom.DOMImplementation handler,
                                boolean usedFontsOnly)
Compose a W3C DOM representation of the RTF DOM and return it.
Parameters:
handler - a DOM implementation constructing documents
usedFontsOnly - if true, only used fonts are exported to the DOM

mergeRequired

public final void mergeRequired()
Set request for merge of near inline strings with the same context while optimization.

expansionRequired

public final void expansionRequired()
Set request for expanding character contexts while optimization.

optimize

public void optimize(boolean needMerge,
                     boolean needExpand,
                     int shapeMask)
Optimization of the RTF Document. The following optimization actions can be applied to inline objects of the document:
  1. Clean some character shape flags;
  2. Merge neighbour inline strings having just the same character context;
  3. Expand character context to all subsequent inlines if they have no character context.
Parameters:
needMerge - if true, the merging optimization is applied if it was not applied before (to merge inlines once more, call the mergeRequired() method before the optimization)
needExpand - if true, the expanding optimization is applied if it was not applied before (to expand character contexts once more, call the expansionRequired() method before the optimization)
shapeMask - a mask of character shape flags to be removed in all character contexts. For example, CharacterShape.M_BOLD|CharacterShape.M_ITALIC removes BOLD and ITALIC shapes in all character contexts. See CharacterShape class.