예제 #1
0
 public static RtfDestinationMgr GetInstance()
 {
     lock (destinations) {
         if (instance == null)
         {
             instance = new RtfDestinationMgr();
             // 2 required destinations for all documents
             RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_DOCUMENT, new Object[] { "RtfDestinationDocument", "" });
             RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_NULL, new Object[] { "RtfDestinationNull", "" });
         }
         return(instance);
     }
 }
 public static RtfDestinationMgr GetInstance(RtfParser parser)
 {
     lock (_destinations)
     {
         SetParser(parser);
         if (_instance == null)
         {
             _instance = new RtfDestinationMgr();
             // 2 required destinations for all documents
             AddDestination(DESTINATION_DOCUMENT, new object[] { "RtfDestinationDocument", "" });
             AddDestination(DESTINATION_NULL, new object[] { "RtfDestinationNull", "" });
         }
         return(_instance);
     }
 }
예제 #3
0
 public static RtfDestinationMgr GetInstance(RtfParser parser) {
     lock(destinations) {
         RtfDestinationMgr.SetParser(parser);
         if (instance == null) {
             instance = new RtfDestinationMgr();
             // 2 required destinations for all documents
             RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_DOCUMENT, new Object[] { "RtfDestinationDocument", "" } );
             RtfDestinationMgr.AddDestination(RtfDestinationMgr.DESTINATION_NULL, new Object[] { "RtfDestinationNull", "" } );
         }
         return instance;
     }
 }
예제 #4
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, 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");
        }