Exemple #1
0
        public static bool AddDestination(String destination, Object[] args)
        {
            if (destinations.ContainsKey(destination))
            {
                return(true);
            }

            String thisClass = "Legacy.Text.rtf.parser.destinations." + (String)args[0];

            if (thisClass.IndexOf("RtfDestinationNull") >= 0)
            {
                destinations[destination] = RtfDestinationNull.GetInstance();
                return(true);
            }

            Type value = null;

            try {
                value = Type.GetType(thisClass);
            } catch {
                return(false);
            }
            if (value == null)
            {
                return(false);
            }

            RtfDestination c = null;

            if (destinationObjects.ContainsKey(value.Name))
            {
                c = (RtfDestination)destinationObjects[value.Name];
            }
            else
            {
                try {
                    c = (RtfDestination)value.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[0], null).Invoke(null);
                } catch  {
                    return(false);
                }
            }

            c.SetParser(rtfParser);

            if (value.Equals(typeof(RtfDestinationInfo)))
            {
                ((RtfDestinationInfo)c).SetElementName(destination);
            }

            if (value.Equals(typeof(RtfDestinationStylesheetTable)))
            {
                ((RtfDestinationStylesheetTable)c).SetElementName(destination);
                ((RtfDestinationStylesheetTable)c).SetType((String)args[1]);
            }

            destinations[destination]      = c;
            destinationObjects[value.Name] = c;
            return(true);
        }
Exemple #2
0
        /**
         * Removes a <CODE>RtfDestinationListener</CODE> from the appropriate <CODE>RtfDestination</CODE>.
         *
         * @param destination the destination string for the listener
         * @param listener
         *            the RtfCtrlWordListener that has to be removed.
         */
        public static bool RemoveListener(String destination, IRtfDestinationListener listener)
        {
            RtfDestination dest = GetDestination(destination);

            if (dest != null)
            {
                return(dest.RemoveListener(listener));
            }
            return(false);
        }
Exemple #3
0
        public static RtfDestination GetDestination(String destination)
        {
            RtfDestination dest = null;

            if (destinations.ContainsKey(destination))
            {
                dest = (RtfDestination)destinations[destination];
            }
            else
            {
                if (ignoreUnknownDestinations)
                {
                    dest = (RtfDestination)destinations[DESTINATION_NULL];
                }
                else
                {
                    dest = (RtfDestination)destinations[DESTINATION_DOCUMENT];
                }
            }
            dest.SetParser(RtfDestinationMgr.rtfParser);
            return(dest);
        }
 /**
 * Copy constructor
 * @param orig The object to copy
 */
 public RtfParserState(RtfParserState orig)
 {
     this.properties = orig.properties;
     this.parserState = orig.parserState;
     this.tokeniserState = orig.tokeniserState;
     this.groupHandler = null;
     this.destination = orig.destination;
     this.text = new StringBuilder();
     this.ctrlWordHandlers = new Stack();
     this.destination = orig.destination;
     this.newGroup = false;
 }
 /**
 * Default constructor
 *
 */
 public RtfParserState()
 {
     this.text = new StringBuilder();
     this.ctrlWordHandlers = new Stack();
     this.properties = new RtfProperty();
     this.destination = RtfDestinationNull.GetInstance();
     this.newGroup = false;
 }