During the import process of a RTF file, the following keywords are not mapped
to the new color table entries. The result of them not being mapped causes the
background colors for tables to be incorrect.
Keyword:
\clcbpat
\clcbpatraw.
Below are my changes that map the colors. I added "else if" statements to
handle the 2 control words.
Class: RtfParser
Method: HandleCtrlWord
---------------------code start------------------------
public void HandleCtrlWord(String ctrlWord, int groupLevel) {
if (this.state == PARSER_IN_DOCUMENT) {
if (RtfColorTableParser.StringMatches(ctrlWord, "\\f")) {
ctrlWord = "\\f" +
this.importHeader.MapFontNr(ctrlWord.Substring(2));
} else if (RtfColorTableParser.StringMatches(ctrlWord, "\\cf"))
{
ctrlWord = "\\cf" +
this.importHeader.MapColorNr(ctrlWord.Substring(3));
} else if (RtfColorTableParser.StringMatches(ctrlWord, "\\cb"))
{
ctrlWord = "\\cb" +
this.importHeader.MapColorNr(ctrlWord.Substring(3));
}
else if (RtfColorTableParser.StringMatches(ctrlWord,
"\\clcbpat"))
{
ctrlWord = "\\clcbpat" +
this.importHeader.MapColorNr(ctrlWord.Substring(8));
}
else if (RtfColorTableParser.StringMatches(ctrlWord,
"\\clcbpatraw")) {
ctrlWord = "\\clcbpatraw" +
this.importHeader.MapColorNr(ctrlWord.Substring(11));
}
this.rtfDoc.Add(new RtfDirectContent(ctrlWord));
} else if (this.state == PARSER_IN_FONT_TABLE) {
this.fontTableParser.HandleCtrlWord(ctrlWord, groupLevel);
} else if (this.state == PARSER_IN_COLOR_TABLE) {
this.colorTableParser.HandleCtrlWord(ctrlWord, groupLevel);
} else if (this.state == PARSER_IN_HEADER) {
if (ctrlWord.Equals("\\info")) {
this.state = PARSER_IN_INFO_GROUP;
} else if (ctrlWord.Equals("\\fonttbl")) {
this.state = PARSER_IN_FONT_TABLE;
} else if (ctrlWord.Equals("\\colortbl")) {
this.state = PARSER_IN_COLOR_TABLE;
}
}
}
----------------------------code end-------------------------------------
Regards
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/