예제 #1
0
 /**
  * Handles the font number control word. Only relevant if the
  * group nesting level is 3.
  *
  * @param ctrlWord The control word to handle.
  * @param groupLevel The current group nesting level.
  */
 public void HandleCtrlWord(String ctrlWord, int groupLevel)
 {
     if (RtfColorTableParser.StringMatches(ctrlWord, "\\f") && groupLevel == 3)
     {
         this.fontNr = ctrlWord.Substring(2);
     }
 }
예제 #2
0
 /**
  * Handles control word tokens. Depending on the current
  * state a control word can lead to a state change. When
  * parsing the actual document contents, The font number,
  * color number and background color number are remapped.
  *
  * @param ctrlWord The control word to handle.
  * @param groupLevel The current group nesting level.
  * @throws DocumentException On document writing errors.
  */
 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));
         }
         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;
         }
     }
 }