Example #1
0
 /**
  * Constructs a new RtfImportHeader.
  *
  * @param rtfDoc The RtfDocument to get font and color numbers from.
  */
 public RtfImportMgr(RtfDocument rtfDoc, Legacy.Text.Document doc)
 {
     this.rtfDoc                      = rtfDoc;
     this.doc                         = doc;
     this.importFontMapping           = new Hashtable();
     this.importColorMapping          = new Hashtable();
     this.importStylesheetListMapping = new Hashtable();
     this.importListMapping           = new Hashtable();
 }
Example #2
0
 /**
  * Constructs a new <code>RtfDestinationDocument</code> using
  * the parameters to initialize the object.
  * @param rtfDoc The <code>RtfDocument</code> this works with.
  * @param doc The iText <code>Document</code> this works with.
  * @param type The type of conversion being done.
  */
 public RtfDestinationDocument(RtfParser parser) : base(parser)
 {
     this.rtfDoc         = parser.GetRtfDocument();
     this.doc            = parser.GetDocument();
     this.conversionType = parser.GetConversionType();
     SetToDefaults();
     if (this.rtfParser.IsConvert())
     {
         this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
     }
 }
Example #3
0
 public override void SetParser(RtfParser parser)
 {
     this.rtfParser      = parser;
     this.rtfDoc         = parser.GetRtfDocument();
     this.doc            = parser.GetDocument();
     this.conversionType = parser.GetConversionType();
     SetToDefaults();
     if (this.rtfParser.IsConvert())
     {
         this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
     }
 }
Example #4
0
 /**
  * Constructs a new RtfWriter that listens to the specified Document and
  * writes its output to the Stream.
  *
  * @param doc The Document that this RtfWriter listens to
  * @param os The Stream to write to
  */
 protected RtfWriter2(Legacy.Text.Document doc, Stream os) : base(doc, os)
 {
     doc.AddDocListener(this);
     rtfDoc = new RtfDocument();
 }
Example #5
0
 /**
  * Static method to generate RtfWriters
  *
  * @param doc The Document that this RtfWriter listens to
  * @param os The Stream to write to
  * @return The new RtfWriter
  */
 public static RtfWriter2 GetInstance(Legacy.Text.Document doc, Stream os)
 {
     return(new RtfWriter2(doc, os));
 }
 public override void SetParser(RtfParser parser)
 {
     this.rtfParser = parser;
     this.rtfDoc = parser.GetRtfDocument();
     this.doc = parser.GetDocument();
     this.conversionType = parser.GetConversionType();
     SetToDefaults();
     if (this.rtfParser.IsConvert()) {
         this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
     }
 }
 /**
 * Constructs a new <code>RtfDestinationDocument</code> using
 * the parameters to initialize the object.
 * @param rtfDoc The <code>RtfDocument</code> this works with.
 * @param doc The iText <code>Document</code> this works with.
 * @param type The type of conversion being done.
 */
 public RtfDestinationDocument(RtfParser parser)
     : base(parser)
 {
     this.rtfDoc = parser.GetRtfDocument();
     this.doc = parser.GetDocument();
     this.conversionType = parser.GetConversionType();
     SetToDefaults();
     if (this.rtfParser.IsConvert()) {
         this.rtfParser.GetState().properties.AddRtfPropertyListener(this);
     }
 }
Example #8
0
 /**
 * Constructs a new RtfImportHeader.
 *
 * @param rtfDoc The RtfDocument to get font and color numbers from.
 */
 public RtfImportMgr(RtfDocument rtfDoc, Legacy.Text.Document doc)
 {
     this.rtfDoc = rtfDoc;
     this.doc = doc;
     this.importFontMapping = new Hashtable();
     this.importColorMapping = new Hashtable();
     this.importStylesheetListMapping = new Hashtable();
     this.importListMapping = new Hashtable();
 }
Example #9
0
 /**
 * Constructor
 * @param doc
 * @since 2.1.3
 */
 public RtfParser(Legacy.Text.Document doc)
 {
     this.document = doc;
 }
Example #10
0
        /**
        * Initialize the parser object values.
        *
        * @param type Type of conversion or import
        * @param rtfDoc The <code>RtfDocument</code>
        * @param readerIn The input stream
        * @param doc The iText <code>Document</code>
        */
        private void Init(int type, RtfDocument rtfDoc, Stream readerIn, Legacy.Text.Document doc, IElement elem)
        {
            Init_stats();
            // initialize reader to a PushbackReader
            this.pbReader = Init_Reader(readerIn);

            this.conversionType = type;
            this.rtfDoc = rtfDoc;
            this.document = doc;
            this.elem = elem;
            this.currentState = new RtfParserState();
            this.stackState = new Stack();
            this.SetParserState(PARSER_STARTSTOP);
            this.importMgr = new RtfImportMgr(this.rtfDoc, this.document);

            // get destination Mgr
            this.destinationMgr = RtfDestinationMgr.GetInstance(this);
            // set the parser
            RtfDestinationMgr.SetParser(this);

            // DEBUG INFO for timing and memory usage of RtfCtrlWordMgr object
            // create multiple new RtfCtrlWordMgr objects to check timing and memory usage
            //      System.Gc();
            //      long endTime = 0;
            //      Date endDate = null;
            //      long endFree = 0;
            //      DecimalFormat df = new DecimalFormat("#,##0");
            //      Date startDate = new Date();
            //      long startTime = System.CurrentTimeMillis();
            //      long startFree = Runtime.GetRuntime().FreeMemory();
            //      System.out.Println("1:");

            this.rtfKeywordMgr = new RtfCtrlWordMgr(this, this.pbReader);/////////DO NOT COMMENT OUT THIS LINE ///////////

            foreach (object listener in listeners) {
                if (listener is IRtfCtrlWordListener) {
                    this.rtfKeywordMgr.AddRtfCtrlWordListener((IRtfCtrlWordListener)listener);
                }
            }
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
            //
            //      System.Gc();
            //      System.out.Println("2:");
            //      startDate = new Date();
            //      startTime = System.CurrentTimeMillis();
            //      startFree = Runtime.GetRuntime().FreeMemory();
            //      RtfCtrlWordMgr rtfKeywordMgr2 = new RtfCtrlWordMgr(this, this.pbReader);
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
            //
            //      System.Gc();
            //      System.out.Println("3:");
            //      startDate = new Date();
            //      startTime = System.CurrentTimeMillis();
            //      startFree = Runtime.GetRuntime().FreeMemory();
            //      RtfCtrlWordMgr rtfKeywordMgr3 = new RtfCtrlWordMgr(this, this.pbReader);
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
            //
            //      System.Gc();
            //      System.out.Println("4:");
            //      startDate = new Date();
            //      startTime = System.CurrentTimeMillis();
            //      startFree = Runtime.GetRuntime().FreeMemory();
            //      RtfCtrlWordMgr rtfKeywordMgr4 = new RtfCtrlWordMgr(this, this.pbReader);
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
            //
            //      System.Gc();
            //      System.out.Println("5:");
            //      startDate = new Date();
            //      startTime = System.CurrentTimeMillis();
            //      startFree = Runtime.GetRuntime().FreeMemory();
            //      RtfCtrlWordMgr rtfKeywordMgr5 = new RtfCtrlWordMgr(this, this.pbReader);
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
            //      System.Gc();
            //      System.out.Println("At ed:");
            //      startDate = new Date();
            //      startTime = System.CurrentTimeMillis();
            //      startFree = Runtime.GetRuntime().FreeMemory();
            //      //RtfCtrlWordMgr rtfKeywordMgr6 = new RtfCtrlWordMgr(this, this.pbReader);
            //      endFree = Runtime.GetRuntime().FreeMemory();
            //      endTime = System.CurrentTimeMillis();
            //      endDate = new Date();
            //      System.out.Println("RtfCtrlWordMgr start date: " + startDate.ToLocaleString());
            //      System.out.Println("RtfCtrlWordMgr end date  : " + endDate.ToLocaleString());
            //      System.out.Println("  Elapsed time    : " + Long.ToString(endTime - startTime) + " milliseconds.");
            //      System.out.Println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.Format(startFree / 1024) + "k");
            //      System.out.Println("End Constructor RtfCtrlWordMgr , free mem is " + df.Format(endFree / 1024) + "k");
            //      System.out.Println("RtfCtrlWordMgr used approximately " + df.Format((startFree - endFree) / 1024) + "k");
        }