|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.lowagie.text.rtf.parser.RtfParser
public class RtfParser
The RtfParser allows the importing of RTF documents or RTF document fragments. The RTF document or fragment is tokenised, font and color definitions corrected and then added to the document being written.
Field Summary | |
---|---|
static int |
DESTINATION_NORMAL
Destination is normal. |
static int |
DESTINATION_SKIP
Destination is skipping. |
static int |
errAssertion
|
static int |
errBadTable
|
static int |
errCtrlWordNotFound
|
static int |
errEndOfFile
|
static int |
errInvalidHex
|
static int |
errOK
|
static int |
errStackOverflow
|
static int |
errStackUnderflow
|
static int |
errUnmatchedBrace
|
static int |
PARSER_ERROR
Currently the parser is in an error state. |
static int |
PARSER_ERROR_EOF
The parser reached the end of the file. |
static int |
PARSER_IN_BLIPUID
Currently a blipuid control word is being parsed. |
static int |
PARSER_IN_CHARSET
Currently the RTF charset is being parsed. |
static int |
PARSER_IN_COLOR_TABLE
Currently the RTF color table is being parsed. |
static int |
PARSER_IN_DEFFONT
Currently the RTF deffont is being parsed. |
static int |
PARSER_IN_DOCUMENT
Currently the RTF document content is being parsed. |
static int |
PARSER_IN_FILE_TABLE
Currently the RTF filetbl is being parsed. |
static int |
PARSER_IN_FONT_TABLE
Currently the RTF font table is being parsed. |
static int |
PARSER_IN_FONT_TABLE_INFO
Currently a RTF font table info element is being parsed. |
static int |
PARSER_IN_GENERATOR
Currently the RTF generator is being parsed. |
static int |
PARSER_IN_HEADER
Currently the RTF document header is being parsed. |
static int |
PARSER_IN_INFO_GROUP
Currently the RTF info group is being parsed. |
static int |
PARSER_IN_LATENTSTYLES
Currently the Latent Style and Formatting usage restrictions |
static int |
PARSER_IN_LIST_TABLE
Currently the RTF listtables is being parsed. |
static int |
PARSER_IN_LISTOVERRIDE_TABLE
Currently the RTF listtable override is being parsed. |
static int |
PARSER_IN_OLDCPROPS
Currently the RTF Old Properties. |
static int |
PARSER_IN_OLDPPROPS
Currently the RTF Old Properties. |
static int |
PARSER_IN_OLDSPROPS
Currently the RTF Old Properties. |
static int |
PARSER_IN_OLDTPROPS
Currently the RTF Old Properties. |
static int |
PARSER_IN_PARAGRAPH_GROUP_PROPERTIES
|
static int |
PARSER_IN_PARAGRAPH_TABLE
Currently the RTF Paragraph group properties Table (word 2002) |
static int |
PARSER_IN_PICPROP
Currently a picprop control word is being parsed. |
static int |
PARSER_IN_PICT
Currently a pict control word is being parsed. |
static int |
PARSER_IN_PROT_USER_TABLE
Currently the RTF User Protection Information. |
static int |
PARSER_IN_REV_TABLE
Currently the RTF revtbl is being parsed. |
static int |
PARSER_IN_RSID_TABLE
Currently the RTF rsidtable is being parsed. |
static int |
PARSER_IN_SHPPICT
Currently a shppict control word is being parsed. |
static int |
PARSER_IN_STYLESHEET
Currently the RTF stylesheet is being parsed. |
static int |
PARSER_IN_UNKNOWN
Currently the parser is in an unknown state. |
static int |
PARSER_IN_UPR
|
static int |
PARSER_STARTSTOP
The parser is at the beginning or the end of the file. |
static int |
TOKENISER_BINARY
The RtfTokeniser is currently reading binary stream. |
static int |
TOKENISER_HEX
The RtfTokeniser is currently reading hex data. |
static int |
TOKENISER_IGNORE_RESULT
The RtfTokeniser ignore result |
static int |
TOKENISER_NORMAL
The RtfTokeniser is in its ground state. |
static int |
TOKENISER_SKIP_BYTES
The last token parsed was a slash. |
static int |
TOKENISER_SKIP_GROUP
The RtfTokeniser is currently tokenising a control word. |
static int |
TOKENISER_STATE_IN_ERROR
The RtfTokeniser is currently in error state |
static int |
TOKENISER_STATE_IN_UNKOWN
The RtfTokeniser is currently in an unkown state |
static int |
TYPE_CONVERT
Conversion type is a conversion. |
static int |
TYPE_IMPORT_FRAGMENT
Conversion type is an import of a partial file/fragment. |
static int |
TYPE_IMPORT_FULL
Conversion type is an import. |
static int |
TYPE_IMPORT_INTO_ELEMENT
Conversion type to import a document into an element. |
static int |
TYPE_UNIDENTIFIED
Conversion type is unknown |
Constructor Summary | |
---|---|
RtfParser(Document doc)
Constructor |
Method Summary | |
---|---|
void |
addListener(java.util.EventListener listener)
Adds a EventListener to the RtfCtrlWordMgr . |
void |
convertRtfDocument(java.io.InputStream readerIn,
Document doc)
Converts an RTF document to an iText document. |
int |
getConversionType()
Get the conversion type. |
RtfDestination |
getCurrentDestination()
Get the current destination object. |
RtfDestination |
getDestination(java.lang.String destination)
Get a destination from the map |
Document |
getDocument()
Get the Document object. |
boolean |
getExtendedDestination()
Helper method to indicate if this control word was a \* control word. |
RtfImportMgr |
getImportManager()
Get the RtfImportHeader object. |
int |
getLevel()
Gets the current group level |
java.lang.String |
getLogFile()
Get the logfile name. |
int |
getParserState()
Get the current state of the parser. |
RtfDocument |
getRtfDocument()
Get the RTF Document object. |
RtfParserState |
getState()
Get the state of the parser. |
int |
getTokeniserState()
Get the current state of the tokeniser. |
int |
handleCharacter(int nextChar)
Handles text tokens. |
int |
handleCloseGroup()
Handles close group tokens. |
int |
handleCtrlWord(RtfCtrlWordData ctrlWordData)
Handles control word tokens. |
int |
handleOpenGroup()
Handles open group tokens. |
void |
importRtfDocument(java.io.InputStream readerIn,
RtfDocument rtfDoc)
Imports a complete RTF document. |
void |
importRtfDocumentIntoElement(Element elem,
java.io.InputStream readerIn,
RtfDocument rtfDoc)
Imports a complete RTF document into an Element, i.e. |
void |
importRtfFragment(java.io.InputStream readerIn,
RtfDocument rtfDoc,
RtfImportMappings importMappings)
Imports an RTF fragment. |
protected void |
init_stats()
Initialize the statistics values. |
boolean |
isConvert()
Helper method to determin if conversion is TYPE_CONVERT |
boolean |
isImport()
Helper method to determin if conversion is TYPE_IMPORT_FULL or TYPE_IMPORT_FRAGMENT |
boolean |
isImportFragment()
Helper method to determin if conversion is TYPE_IMPORT_FRAGMENT |
boolean |
isImportFull()
Helper method to determin if conversion is TYPE_IMPORT_FULL |
boolean |
isLogAppend()
|
boolean |
isLogging()
Get flag indicating if logging is on or off. |
boolean |
isNewGroup()
Helper method to determine if this is a new group. |
static void |
outputDebug(java.lang.Object doc,
int groupLevel,
java.lang.String str)
|
void |
removeListener(java.util.EventListener listener)
Removes a EventListener from the RtfCtrlWordMgr . |
boolean |
setCurrentDestination(java.lang.String destination)
Set the current destination object for the current state. |
boolean |
setExtendedDestination(boolean value)
Helper method to set the extended control word flag. |
void |
setLogAppend(boolean logAppend)
|
void |
setLogFile(java.lang.String logFile)
Set the logFile name |
void |
setLogFile(java.lang.String logFile,
boolean logAppend)
Set the logFile name |
void |
setLogging(boolean logging)
Set flag indicating if logging is on or off |
boolean |
setNewGroup(boolean value)
Helper method to set the new group flag |
int |
setParserState(int newState)
Set the state value of the parser. |
void |
setTokeniserSkipBytes(long numberOfBytesToSkip)
Sets the number of bytes to skip and the state of the tokeniser. |
int |
setTokeniserState(int value)
Set the current state of the tokeniser. |
void |
setTokeniserStateBinary(int binaryCount)
Sets the number of binary bytes. |
void |
setTokeniserStateBinary(long binaryCount)
Sets the number of binary bytes. |
void |
setTokeniserStateNormal()
Set the tokeniser state to skip to the end of the group. |
void |
setTokeniserStateSkipGroup()
Set the tokeniser state to skip to the end of the group. |
void |
tokenise()
Read through the input file and parse the data stream into tokens. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PARSER_IN_HEADER
public static final int PARSER_IN_CHARSET
public static final int PARSER_IN_DEFFONT
public static final int PARSER_IN_FONT_TABLE
public static final int PARSER_IN_FONT_TABLE_INFO
public static final int PARSER_IN_FILE_TABLE
public static final int PARSER_IN_COLOR_TABLE
public static final int PARSER_IN_STYLESHEET
public static final int PARSER_IN_LIST_TABLE
public static final int PARSER_IN_LISTOVERRIDE_TABLE
public static final int PARSER_IN_REV_TABLE
public static final int PARSER_IN_RSID_TABLE
public static final int PARSER_IN_GENERATOR
public static final int PARSER_IN_PARAGRAPH_TABLE
public static final int PARSER_IN_OLDCPROPS
public static final int PARSER_IN_OLDPPROPS
public static final int PARSER_IN_OLDTPROPS
public static final int PARSER_IN_OLDSPROPS
public static final int PARSER_IN_PROT_USER_TABLE
public static final int PARSER_IN_LATENTSTYLES
public static final int PARSER_IN_PARAGRAPH_GROUP_PROPERTIES
public static final int PARSER_IN_DOCUMENT
public static final int PARSER_IN_INFO_GROUP
public static final int PARSER_IN_UPR
public static final int PARSER_IN_SHPPICT
public static final int PARSER_IN_PICT
public static final int PARSER_IN_PICPROP
public static final int PARSER_IN_BLIPUID
public static final int PARSER_STARTSTOP
public static final int PARSER_ERROR
public static final int PARSER_ERROR_EOF
public static final int PARSER_IN_UNKNOWN
public static final int TYPE_UNIDENTIFIED
public static final int TYPE_IMPORT_FULL
public static final int TYPE_IMPORT_FRAGMENT
public static final int TYPE_CONVERT
public static final int TYPE_IMPORT_INTO_ELEMENT
public static final int DESTINATION_NORMAL
public static final int DESTINATION_SKIP
public static final int TOKENISER_NORMAL
public static final int TOKENISER_SKIP_BYTES
public static final int TOKENISER_SKIP_GROUP
public static final int TOKENISER_BINARY
public static final int TOKENISER_HEX
public static final int TOKENISER_IGNORE_RESULT
public static final int TOKENISER_STATE_IN_ERROR
public static final int TOKENISER_STATE_IN_UNKOWN
public static final int errOK
public static final int errStackUnderflow
public static final int errStackOverflow
public static final int errUnmatchedBrace
public static final int errInvalidHex
public static final int errBadTable
public static final int errAssertion
public static final int errEndOfFile
public static final int errCtrlWordNotFound
Constructor Detail |
---|
public RtfParser(Document doc)
doc
- Method Detail |
---|
public void importRtfDocument(java.io.InputStream readerIn, RtfDocument rtfDoc) throws java.io.IOException
readerIn
- The Reader to read the RTF document from.rtfDoc
- The RtfDocument to add the imported document to.
java.io.IOException
- On I/O errors.public void importRtfDocumentIntoElement(Element elem, java.io.InputStream readerIn, RtfDocument rtfDoc) throws java.io.IOException
elem
- The Element the document is to be imported into.readerIn
- The Reader to read the RTF document from.rtfDoc
- The RtfDocument to add the imported document to.
java.io.IOException
- On I/O errors.public void convertRtfDocument(java.io.InputStream readerIn, Document doc) throws java.io.IOException
readerIn
- The Reader to read the RTF file from.doc
- The iText document that the RTF file is to be added to.
java.io.IOException
- On I/O errors.public void importRtfFragment(java.io.InputStream readerIn, RtfDocument rtfDoc, RtfImportMappings importMappings) throws java.io.IOException
readerIn
- The Reader to read the RTF fragment from.rtfDoc
- The RTF document to add the RTF fragment to.importMappings
- The RtfImportMappings defining font and color mappings for the fragment.
java.io.IOException
- On I/O errors.public void addListener(java.util.EventListener listener)
EventListener
to the RtfCtrlWordMgr
.
listener
- the new EventListener.public void removeListener(java.util.EventListener listener)
EventListener
from the RtfCtrlWordMgr
.
listener
- the EventListener that has to be removed.protected void init_stats()
public int handleOpenGroup()
public static void outputDebug(java.lang.Object doc, int groupLevel, java.lang.String str)
public int handleCloseGroup()
public int handleCtrlWord(RtfCtrlWordData ctrlWordData)
ctrlWordData
- The control word to handle.
public int handleCharacter(int nextChar)
nextChar
- The text token to handle.
public RtfParserState getState()
public int getParserState()
public int setParserState(int newState)
newState
- The new state for the parser
public int getConversionType()
public RtfDocument getRtfDocument()
public Document getDocument()
public RtfImportMgr getImportManager()
public boolean setCurrentDestination(java.lang.String destination)
destination
- The destination value to set.public RtfDestination getCurrentDestination()
public RtfDestination getDestination(java.lang.String destination)
destination
- The string destination.
public boolean isNewGroup()
public boolean setNewGroup(boolean value)
value
- The boolean value to set the flag
public void tokenise() throws java.io.IOException
java.io.IOException
- on IO error.public int setTokeniserState(int value)
value
- The new state of the tokeniser.
public int getTokeniserState()
public int getLevel()
public void setTokeniserStateNormal()
public void setTokeniserStateSkipGroup()
public void setTokeniserSkipBytes(long numberOfBytesToSkip)
numberOfBytesToSkip
- The numbere of bytes to skip in the file.public void setTokeniserStateBinary(int binaryCount)
binaryCount
- The number of binary bytes.public void setTokeniserStateBinary(long binaryCount)
binaryCount
- The number of binary bytes.public boolean isConvert()
TYPE_CONVERT
public boolean isImport()
TYPE_IMPORT_FULL
,
TYPE_IMPORT_FRAGMENT
public boolean isImportFull()
TYPE_IMPORT_FULL
public boolean isImportFragment()
TYPE_IMPORT_FRAGMENT
public boolean getExtendedDestination()
public boolean setExtendedDestination(boolean value)
value
- Boolean to set the value to.
public java.lang.String getLogFile()
public void setLogFile(java.lang.String logFile)
logFile
- the logFile to setpublic void setLogFile(java.lang.String logFile, boolean logAppend)
logFile
- the logFile to setpublic boolean isLogging()
public void setLogging(boolean logging)
logging
- true
to turn on logging, false
to turn off logging.public boolean isLogAppend()
public void setLogAppend(boolean logAppend)
logAppend
- the logAppend to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |