de.vc.jfo.rtf

## Class DocumentContext

- java.lang.Object
- - de.vc.jfo.rtf.DocumentContext

- Direct Known Subclasses:
    FieldContext

      public class DocumentContext
      extends java.lang.Object

  The document context provides information about the current context when importing a RTF file and has methods for inserting objects into document tree.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `AUTO_VALUE_DATA_ROW_INDEX`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addNamespace(java.lang.String prefix, java.lang.String namespace)` Adds a namespace to the document.
    `protected boolean` | `doWrap(java.lang.Class nodeClass, Node wrapper)`
    `protected void` | `doWrap(Node documentNode, Node wrapper)`
    `java.io.File` | `findFile(java.lang.String path)` Finds a file that is either relative to the RTF file that is currently imported or that is absolute.
    `ListItem` | `getCurrentListItem()` Gets the current list item or null if context is not in list.
    `TableRow` | `getCurrentTableRow()` Returns the current table-row or null if context is not in a table.
    `Document` | `getDocument()` Returns the document (XSL-FO object tree) that is imported.
    `AreaEstimator` | `getEstimator()`
    `java.lang.String` | `getMappedFont(java.lang.String fontname)` Maps a font name using the font-mapper as defined JFO-Configuration or Import-Parameters.
    `RTF2FOConfig` | `getRTF2FOConfig()`
    `void` | `insert(java.lang.Object obj)` Inserts an object at the current position.
    `void` | `insert(java.lang.Object obj, boolean mergeFormat)` This method is equivalent to `insert(Object obj)` but with a parameter that overrides mergeFormat property.
    `void` | `insert(java.lang.Object obj, java.util.Map paragraphProperties)` This method is equivalent to `insert(Object obj)` but with a parameter for additional paragraph properties.
    `void` | `insert(java.lang.Object obj, java.util.Map paragraphProperties, boolean mergeFormat)` This method is equivalent to `insert(Object obj)` but with a parameter for additional paragraph properties.
    `void` | `insertAutoValue(int autoValue)` Inserts an automatically generated value.
    `void` | `insertDocument(Document doc)` Appends a full document at the current position.
    `void` | `insertDocument(Document doc, boolean restartNumbering)` Appends a full document at the current position.
    `void` | `insertDocumentContent(Document doc)` Inserts only the content of a document, no new page sequence is started.
    `void` | `insertListItems(java.lang.Object[] items)` Inserts values for a list.
    `void` | `insertTableColumn(java.lang.Object[] cells)` Inserts values for a table column.
    `boolean` | `isInTable()` Tests if current position is in a table.
    `boolean` | `isMergeFormat()` Checks whether text formatting properties are applied.
    `void` | `setMergeFormat(boolean mergeFormat)` Sets whether text formatting properties of RTF should be applied to inserted objects.
    `java.lang.String` | `transcodeString(java.lang.String fontname, java.lang.String str)`
    `void` | `wrapBlock(Node wrapper)` Wraps the current block (paragraph) into another node.
    `void` | `wrapListItem(Node wrapper)` Wraps this list item into another node.
    `void` | `wrapPageSequence(Node wrapper)` Wraps the current page sequence (section) into another node.
    `void` | `wrapParentNode(Node wrapper, java.lang.Class wrappedNodeType)`
    `void` | `wrapTableRow(Node wrapper)` Wraps the current table row into another node.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### AUTO_VALUE_DATA_ROW_INDEX

          public static final int AUTO_VALUE_DATA_ROW_INDEX

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getDocument

          public Document getDocument()

      Returns the document (XSL-FO object tree) that is imported.
      Returns:
        Document

    - #### getEstimator

          public AreaEstimator getEstimator()

    - #### insert

          public void insert(java.lang.Object obj)

      Inserts an object at the current position. The `obj` can be a formatting object, a node element or any other objects (Strings). To insert more than one object `obj` can be an object-array or a collection (any subclass of java.util.Collection). If this context is inside a table (`isInTable()==true`), `obj` can be a TableCell-Array for filling the actual table vertically. If this context is inside a list, `obj` can be a ListItem-Array or ListItemBody-Array. Examples: `insert("Hello world");`
      Inserts Hello world at the current position. `insert(new Inline("Hello world",Color.green));`
      Inserts Hello world in green at the current position. `insert(new TableCell[]{new TableCell("row1"),new TableCell("row2")});`
      Fills a table column. `insert(new ListItem[]{new ListItem("item 1"),new ListItem("item 2")});`
      Fills a list (bullets and numberings). `insert(new DefaultNode("my-xml-node"));`
      Inserts a custom xml-node.
      Parameters:
        `obj` - Object.

    - #### insert

          public void insert(java.lang.Object obj,
                    java.util.Map paragraphProperties,
                    boolean mergeFormat)

      This method is equivalent to `insert(Object obj)` but with a parameter for additional paragraph properties.
      Parameters:
        `obj` - Object.
        `paragraphProperties` - Properties that are applied to the actual paragraph.
        `mergeFormat` - Merge format. This overrides property set by setMergeFormat().
      See Also:
        `insert(java.lang.Object)`

    - #### insert

          public void insert(java.lang.Object obj,
                    java.util.Map paragraphProperties)

      This method is equivalent to `insert(Object obj)` but with a parameter for additional paragraph properties.
      Parameters:
        `obj` - Object.
        `paragraphProperties` - Properties that are applied to the actual paragraph.
      See Also:
        `insert(java.lang.Object)`

    - #### insert

          public void insert(java.lang.Object obj,
                    boolean mergeFormat)

      This method is equivalent to `insert(Object obj)` but with a parameter that overrides mergeFormat property.
      Parameters:
        `obj` - Object.
        `mergeFormat` - Merge format. This overrides property set by setMergeFormat().
      See Also:
        `insert(java.lang.Object)`

    - #### insertDocument

          public void insertDocument(Document doc)

      Appends a full document at the current position. A new page sequence (section) is started and page numbering is not restarted.
      Parameters:
        `doc` - Document.

    - #### insertDocument

          public void insertDocument(Document doc,
                            boolean restartNumbering)

      Appends a full document at the current position. A new page sequence (section) is started and optionally page numbering can be restarted.
      Parameters:
        `doc` - Document.
        `restartNumbering` - `true` to restart page numbering.

    - #### insertDocumentContent

          public void insertDocumentContent(Document doc)

      Inserts only the content of a document, no new page sequence is started.
      Parameters:
        `doc` - Document.

    - #### insertTableColumn

          public void insertTableColumn(java.lang.Object[] cells)

      Inserts values for a table column. Common object arrays are:
    - TableCell[]
    - String[]
    - Block[]
    - Inline[]

Parameters:
  `cells` - Cells of column.

- #### insertAutoValue

      public void insertAutoValue(int autoValue)

  Inserts an automatically generated value. Possible values are:
  - AUTO_VALUE_DATA_ROW_INDEX
  Parameters:
    `autoValue` - String
  See Also:
    `AUTO_VALUE_DATA_ROW_INDEX`

- #### insertListItems

      public void insertListItems(java.lang.Object[] items)

  Inserts values for a list. Common object arrays are:
- String[] - With auto generated labels.
- ListItemBody[] - With auto generated labels.
- Block[] - With auto generated labels.
- ListItem[] - No auto generated labels.

Parameters:
  `items` - Object[]

- #### setMergeFormat

      public void setMergeFormat(boolean mergeFormat)

  Sets whether text formatting properties of RTF should be applied to inserted objects. The default value is `true/code>`
  Parameters:
    `mergeFormat` - Merge text format.

- #### isMergeFormat

      public boolean isMergeFormat()

  Checks whether text formatting properties are applied.
  Returns:
    `true` if properties are applied.

- #### isInTable

      public boolean isInTable()

  Tests if current position is in a table.
  Returns:
    boolean `true` if in table.

- #### getMappedFont

      public java.lang.String getMappedFont(java.lang.String fontname)

  Maps a font name using the font-mapper as defined JFO-Configuration or Import-Parameters.
  Parameters:
    `fontname` - Original font name.
  Returns:
    Mapped font name.

- #### transcodeString

      public java.lang.String transcodeString(java.lang.String fontname,
                                     java.lang.String str)

- #### wrapTableRow

      public void wrapTableRow(Node wrapper)

  Wraps the current table row into another node.
  NOTE: You should only use this method if context is in a table cell.
  Parameters:
    `wrapper` - Node

- #### wrapBlock

      public void wrapBlock(Node wrapper)

  Wraps the current block (paragraph) into another node.
  Parameters:
    `wrapper` - Node

- #### wrapPageSequence

      public void wrapPageSequence(Node wrapper)

  Wraps the current page sequence (section) into another node.
  Parameters:
    `wrapper` - Node

- #### wrapListItem

      public void wrapListItem(Node wrapper)

  Wraps this list item into another node.
  NOTE: You should only use this method when the context is in a list.
  Parameters:
    `wrapper` - Node

- #### wrapParentNode

      public void wrapParentNode(Node wrapper,
                        java.lang.Class wrappedNodeType)

- #### getCurrentTableRow

      public TableRow getCurrentTableRow()

  Returns the current table-row or null if context is not in a table.
  Returns:
    Table row.

- #### getCurrentListItem

      public ListItem getCurrentListItem()

  Gets the current list item or null if context is not in list.
  Returns:
    List item.

- #### addNamespace

      public void addNamespace(java.lang.String prefix,
                      java.lang.String namespace)

  Adds a namespace to the document.
  Parameters:
    `prefix` - Prefix of namespace.
    `namespace` - Namespace.

- #### findFile

      public final java.io.File findFile(java.lang.String path)

  Finds a file that is either relative to the RTF file that is currently imported or that is absolute.
  Parameters:
    `path` - String
  Returns:
    File

- #### getRTF2FOConfig

      public RTF2FOConfig getRTF2FOConfig()

- #### doWrap

      protected boolean doWrap(java.lang.Class nodeClass,
                   Node wrapper)

- #### doWrap

      protected void doWrap(Node documentNode,
                Node wrapper)

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.