Exemple #1
0
 /**
  * Imports an RTF fragment.
  *
  * @param reader The Reader to read the RTF fragment from.
  * @param rtfDoc The RTF document to add the RTF fragment to.
  * @param importMappings The RtfImportMappings defining font and color mappings for the fragment.
  * @throws IOException On I/O errors.
  * @throws DocumentException On document writing errors.
  */
 public void ImportRtfFragment(TextReader reader, RtfDocument rtfDoc, RtfImportMappings importMappings)
 {
     this.rtfDoc           = rtfDoc;
     this.state            = PARSER_IN_DOCUMENT;
     this.importHeader     = new RtfImportHeader(this.rtfDoc);
     this.fontTableParser  = new RtfFontTableParser(this.importHeader);
     this.colorTableParser = new RtfColorTableParser(this.importHeader);
     HandleImportMappings(importMappings);
     this.tokeniser = new RtfTokeniser(this, 1);
     this.tokeniser.Tokenise(reader);
 }
Exemple #2
0
 /**
  * Imports the mappings defined in the RtfImportMappings into the
  * RtfImportHeader of this RtfParser.
  *
  * @param importMappings The RtfImportMappings to import.
  */
 private void HandleImportMappings(RtfImportMappings importMappings)
 {
     foreach (String fontNr in importMappings.GetFontMappings().Keys)
     {
         this.importHeader.ImportFont(fontNr, (String)importMappings.GetFontMappings()[fontNr]);
     }
     foreach (String colorNr in importMappings.GetColorMappings().Keys)
     {
         this.importHeader.ImportColor(colorNr, (Color)importMappings.GetColorMappings()[colorNr]);
     }
 }
Exemple #3
0
 /**
 * Imports the mappings defined in the RtfImportMappings into the
 * RtfImportHeader of this RtfParser.
 *
 * @param importMappings The RtfImportMappings to import.
 */
 private void HandleImportMappings(RtfImportMappings importMappings)
 {
     foreach (String fontNr in importMappings.GetFontMappings().Keys) {
         this.importHeader.ImportFont(fontNr, (String) importMappings.GetFontMappings()[fontNr]);
     }
     foreach (String colorNr in importMappings.GetColorMappings().Keys) {
         this.importHeader.ImportColor(colorNr, (Color) importMappings.GetColorMappings()[colorNr]);
     }
 }
Exemple #4
0
 /**
 * Imports an RTF fragment.
 *
 * @param reader The Reader to read the RTF fragment from.
 * @param rtfDoc The RTF document to add the RTF fragment to.
 * @param importMappings The RtfImportMappings defining font and color mappings for the fragment.
 * @throws IOException On I/O errors.
 * @throws DocumentException On document writing errors.
 */
 public void ImportRtfFragment(TextReader reader, RtfDocument rtfDoc, RtfImportMappings importMappings)
 {
     this.rtfDoc = rtfDoc;
     this.state = PARSER_IN_DOCUMENT;
     this.importHeader = new RtfImportHeader(this.rtfDoc);
     this.fontTableParser = new RtfFontTableParser(this.importHeader);
     this.colorTableParser = new RtfColorTableParser(this.importHeader);
     HandleImportMappings(importMappings);
     this.tokeniser = new RtfTokeniser(this, 1);
     this.tokeniser.Tokenise(reader);
 }
Exemple #5
0
 /**
 * Adds a fragment of an RTF document to the current RTF document being generated.
 * Since this fragment doesn't contain font or color tables, all fonts and colors
 * are mapped to the default font and color. If the font and color mappings are
 * known, they can be specified via the mappings parameter.
 *
 * @param documentSource The Reader to read the RTF fragment from.
 * @param mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.
 * @throws IOException On errors reading the RTF fragment.
 * @throws DocumentException On errors adding to this RTF fragment.
 */
 public void ImportRtfFragment(TextReader documentSource, RtfImportMappings mappings)
 {
     if(!this.open) {
         throw new DocumentException("The document must be open to import RTF fragments.");
     }
     RtfParser rtfImport = new RtfParser();
     rtfImport.ImportRtfFragment(documentSource, this.rtfDoc, mappings);
 }