Package com.lowagie.text.rtf.parser
Class RtfImportMgr
- java.lang.Object
-
- com.lowagie.text.rtf.parser.RtfImportMgr
-
public class RtfImportMgr extends java.lang.Object
The RtfImportHeader stores the document header information from an RTF document that is being imported. Currently font and color settings are stored. The RtfImportHeader maintains a mapping from font and color numbers from the imported RTF document to the RTF document that is the target of the import. This guarantees that the merged document has the correct font and color settings. It also handles other list based items that need mapping, for example stylesheets and lists.- Since:
- 2.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private com.lowagie.text.Document
doc
The Document.private java.util.Map<java.lang.String,java.lang.String>
importColorMapping
The HashMap storing the color number mappings.private java.util.Map<java.lang.String,java.lang.String>
importFontMapping
The HashMap storing the font number mappings.private java.util.Map<java.lang.String,java.lang.String>
importListMapping
The HashMap storing the List number mappings.private java.util.Map<java.lang.String,java.lang.String>
importStylesheetListMapping
The HashMap storing the Stylesheet List number mappings.private RtfDocument
rtfDoc
The RtfDocument to get font and color numbers from.
-
Constructor Summary
Constructors Constructor Description RtfImportMgr(RtfDocument rtfDoc, com.lowagie.text.Document doc)
Constructs a new RtfImportHeader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
importColor(java.lang.String colorNr, java.awt.Color color)
Imports a color value.boolean
importFont(java.lang.String fontNr, java.lang.String fontName)
Imports a font.boolean
importFont(java.lang.String fontNr, java.lang.String fontName, int charset)
Imports a font.boolean
importFont(java.lang.String fontNr, java.lang.String fontName, java.lang.String fontFamily, int charset)
Imports a font.void
importList(java.lang.String origListNr, java.lang.String newListNr)
Imports a List value.boolean
importStylesheetList(java.lang.String listNr, com.lowagie.text.List listIn)
Imports a stylesheet list value.java.lang.String
mapColorNr(java.lang.String colorNr)
Performs the mapping from the original font number to the actual font number used in the RTF document.java.lang.String
mapFontNr(java.lang.String fontNr)
Performs the mapping from the original font number to the actual font number in the resulting RTF document.java.lang.String
mapListNr(java.lang.String listNr)
Performs the mapping from the original list number to the actual list number in the resulting RTF document.java.lang.String
mapStylesheetListNr(java.lang.String listNr)
Performs the mapping from the original stylesheet number to the actual stylesheet number in the resulting RTF document.
-
-
-
Field Detail
-
importFontMapping
private final java.util.Map<java.lang.String,java.lang.String> importFontMapping
The HashMap storing the font number mappings.
-
importColorMapping
private final java.util.Map<java.lang.String,java.lang.String> importColorMapping
The HashMap storing the color number mappings.
-
importStylesheetListMapping
private final java.util.Map<java.lang.String,java.lang.String> importStylesheetListMapping
The HashMap storing the Stylesheet List number mappings.
-
importListMapping
private final java.util.Map<java.lang.String,java.lang.String> importListMapping
The HashMap storing the List number mappings.
-
rtfDoc
private final RtfDocument rtfDoc
The RtfDocument to get font and color numbers from.
-
doc
private final com.lowagie.text.Document doc
The Document. Used for conversions, but not imports.
-
-
Constructor Detail
-
RtfImportMgr
public RtfImportMgr(RtfDocument rtfDoc, com.lowagie.text.Document doc)
Constructs a new RtfImportHeader.- Parameters:
rtfDoc
- The RtfDocument to get font and color numbers from.
-
-
Method Detail
-
importFont
public boolean importFont(java.lang.String fontNr, java.lang.String fontName)
Imports a font. The font name is looked up in the RtfDocumentHeader and then the mapping from original font number to actual font number is added.- Parameters:
fontNr
- The original font number.fontName
- The font name to look up.
-
importFont
public boolean importFont(java.lang.String fontNr, java.lang.String fontName, int charset)
Imports a font. The font name is looked up in the RtfDocumentHeader and then the mapping from original font number to actual font number is added.- Parameters:
fontNr
- The original font number.fontName
- The font name to look up.charset
- The character set to use for the font.
-
importFont
public boolean importFont(java.lang.String fontNr, java.lang.String fontName, java.lang.String fontFamily, int charset)
Imports a font. The font name is looked up in the RtfDocumentHeader and then the mapping from original font number to actual font number is added.- Parameters:
fontNr
- The original font number.fontName
- The font name to look up.charset
- The character set to use for the font.
-
mapFontNr
public java.lang.String mapFontNr(java.lang.String fontNr)
Performs the mapping from the original font number to the actual font number in the resulting RTF document. If the font number was not seen during import (thus no mapping) then 0 is returned, guaranteeing that the font number is always valid.- Parameters:
fontNr
- The font number to map.- Returns:
- The mapped font number.
-
importColor
public void importColor(java.lang.String colorNr, java.awt.Color color)
Imports a color value. The color number for the color defined by its red, green and blue values is determined and then the resulting mapping is added.- Parameters:
colorNr
- The original color number.color
- The color to import.
-
mapColorNr
public java.lang.String mapColorNr(java.lang.String colorNr)
Performs the mapping from the original font number to the actual font number used in the RTF document. If the color number was not seen during import (thus no mapping) then 0 is returned, guaranteeing that the color number is always valid.- Parameters:
colorNr
- The color number to map.- Returns:
- The mapped color number
-
importList
public void importList(java.lang.String origListNr, java.lang.String newListNr)
Imports a List value. The List number for the List defined is determined and then the resulting mapping is added.
-
mapListNr
public java.lang.String mapListNr(java.lang.String listNr)
Performs the mapping from the original list number to the actual list number in the resulting RTF document. If the list number was not seen during import (thus no mapping) then null is returned. There is no guarantee of a valid list number.
-
importStylesheetList
public boolean importStylesheetList(java.lang.String listNr, com.lowagie.text.List listIn)
Imports a stylesheet list value. The stylesheet number for the stylesheet defined is determined and then the resulting mapping is added.
-
mapStylesheetListNr
public java.lang.String mapStylesheetListNr(java.lang.String listNr)
Performs the mapping from the original stylesheet number to the actual stylesheet number in the resulting RTF document. If the stylesheet number was not seen during import (thus no mapping) then 0 is returned, guaranteeing that the stylesheet number is always valid.
-
-