Ejemplo n.º 1
0
        /**
         * Dispatch the token to the correct control word handling object.
         *
         * @param ctrlWordData The <code>RtfCtrlWordData</code> object with control word and param
         * @param groupLevel The current document group parsing level
         * @return errOK if ok, otherwise an error code.
         */
        private int DispatchKeyword(RtfCtrlWordData ctrlWordData, int groupLevel)
        {
            int result = RtfParser.errOK;

            if (ctrlWordData != null)
            {
                RtfCtrlWordHandler ctrlWord = ctrlWordMap.GetCtrlWordHandler(ctrlWordData.ctrlWord);
                if (ctrlWord != null)
                {
                    ctrlWord.HandleControlword(ctrlWordData);
                    if (debug && debugFound)
                    {
                        Console.Out.WriteLine("Keyword found:" +
                                              " New:" + ctrlWordData.ctrlWord +
                                              " Param:" + ctrlWordData.param +
                                              " bParam=" + ctrlWordData.hasParam.ToString());
                    }
                }
                else
                {
                    result = RtfParser.errCtrlWordNotFound;
                    //result = RtfParser2.errAssertion;
                    if (debug && debugNotFound)
                    {
                        Console.Out.WriteLine("Keyword unknown:" +
                                              " New:" + ctrlWordData.ctrlWord +
                                              " Param:" + ctrlWordData.param +
                                              " bParam=" + ctrlWordData.hasParam.ToString());
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
 private bool AfterCtrlWord(RtfCtrlWordData ctrlWordData)
 {
     foreach (IRtfCtrlWordListener listener in listeners)
     {
         listener.AfterCtrlWord(ctrlWordData);
     }
     return(true);
 }
Ejemplo n.º 3
0
        /**
         * Internal to control word manager class.
         *
         * @param ctrlWordData The <code>RtfCtrlWordData</code> object with control word and param
         * @param groupLevel The current document group parsing level
         * @return errOK if ok, otherwise an error code.
         */
        public int HandleKeyword(RtfCtrlWordData ctrlWordData, int groupLevel)
        {
            //TODO: May be used for event handling.
            int result = RtfParser.errOK;

            // Call before handler event here
            BeforeCtrlWord(ctrlWordData);

            result = DispatchKeyword(ctrlWordData, groupLevel);

            // call after handler event here
            AfterCtrlWord(ctrlWordData);

            return(result);
        }
 public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
 {
     if (ctrlWordData.ctrlWord.Equals("blue")) this.SetBlue(ctrlWordData.IntValue());
     if (ctrlWordData.ctrlWord.Equals("red")) this.SetRed(ctrlWordData.IntValue());
     if (ctrlWordData.ctrlWord.Equals("green")) this.SetGreen(ctrlWordData.IntValue());
     if (ctrlWordData.ctrlWord.Equals("cshade")) this.SetShade(ctrlWordData.IntValue());
     if (ctrlWordData.ctrlWord.Equals("ctint")) this.SetTint(ctrlWordData.IntValue());
     //if(ctrlWordData.ctrlWord.Equals("cmaindarkone")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cmainlightone")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cmaindarktwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cmainlighttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccentone")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccenttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccentthree")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccentfour")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccentfive")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("caccentsix")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("chyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cfollowedhyperlink")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cbackgroundone")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("ctextone")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("cbacgroundtwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
     //if(ctrlWordData.ctrlWord.Equals("ctexttwo")) this.SetThemeColor(ctrlWordData.ctrlWord);
     return true;
 }
Ejemplo n.º 5
0
 /* (non-Javadoc)
 * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
 */
 public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
 {
     return true;
 }
Ejemplo n.º 6
0
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = false;
            this.OnCtrlWord(ctrlWordData);  // event handler

            if (this.rtfParser.IsImport()) {
                // map font information
                if (ctrlWordData.ctrlWord.Equals("f")) { ctrlWordData.param =  this.rtfParser.GetImportManager().MapFontNr(ctrlWordData.param);}

                // map color information
                //colors
                if (ctrlWordData.ctrlWord.Equals("cb")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                if (ctrlWordData.ctrlWord.Equals("cf")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                //cells
                if (ctrlWordData.ctrlWord.Equals("clcbpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                if (ctrlWordData.ctrlWord.Equals("clcbpatraw")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                if (ctrlWordData.ctrlWord.Equals("clcfpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                if (ctrlWordData.ctrlWord.Equals("clcfpatraw")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                //table rows
                if (ctrlWordData.ctrlWord.Equals("trcfpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                if (ctrlWordData.ctrlWord.Equals("trcbpat")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                //paragraph border
                if (ctrlWordData.ctrlWord.Equals("brdrcf")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapColorNr(ctrlWordData.param);}
                // map lists
                if(ctrlWordData.ctrlWord.Equals("ls")) { ctrlWordData.param = this.rtfParser.GetImportManager().MapListNr(ctrlWordData.param);}
            }

            if (this.rtfParser.IsConvert()) {
                if (ctrlWordData.ctrlWord.Equals("par")) { AddParagraphToDocument(); }
                // Set Font
                if (ctrlWordData.ctrlWord.Equals("f")) {}

                // color information
                //colors
                if (ctrlWordData.ctrlWord.Equals("cb")) {}
                if (ctrlWordData.ctrlWord.Equals("cf")) {}
                //cells
                if (ctrlWordData.ctrlWord.Equals("clcbpat")) {}
                if (ctrlWordData.ctrlWord.Equals("clcbpatraw")) {}
                if (ctrlWordData.ctrlWord.Equals("clcfpat")) {}
                if (ctrlWordData.ctrlWord.Equals("clcfpatraw")) {}
                //table rows
                if (ctrlWordData.ctrlWord.Equals("trcfpat")) {}
                if (ctrlWordData.ctrlWord.Equals("trcbpat")) {}
                //paragraph border
                if (ctrlWordData.ctrlWord.Equals("brdrcf")) {}

                /* TABLES */
                if (ctrlWordData.ctrlWord.Equals("trowd")) /*Beginning of row*/ { tableLevel++;}
                if (ctrlWordData.ctrlWord.Equals("cell")) /*End of Cell Denotes the end of a table cell*/ {
            //              String ctl = ctrlWordData.ctrlWord;
            //              System.out.Print("cell found");
                }
                if (ctrlWordData.ctrlWord.Equals("row")) /*End of row*/ { tableLevel++;}
                if (ctrlWordData.ctrlWord.Equals("lastrow")) /*Last row of the table*/ {}
                if (ctrlWordData.ctrlWord.Equals("row")) /*End of row*/ { tableLevel++;}
                if (ctrlWordData.ctrlWord.Equals("irow")) /*param  is the row index of this row.*/ {}
                if (ctrlWordData.ctrlWord.Equals("irowband")) /*param is the row index of the row, adjusted to account for header rows. A header row has a value of -1.*/ {}
                if (ctrlWordData.ctrlWord.Equals("tcelld")) /*Sets table cell defaults*/ {}
                if (ctrlWordData.ctrlWord.Equals("nestcell")) /*Denotes the end of a nested cell.*/ {}
                if (ctrlWordData.ctrlWord.Equals("nestrow")) /*Denotes the end of a nested row*/ {}
                if (ctrlWordData.ctrlWord.Equals("nesttableprops")) /*Defines the properties of a nested table. This is a destination control word*/ {}
                if (ctrlWordData.ctrlWord.Equals("nonesttables")) /*Contains text for readers that do not understand nested tables. This destination should be ignored by readers that support nested tables.*/ {}
                if (ctrlWordData.ctrlWord.Equals("trgaph")) /*Half the space between the cells of a table row in twips.*/ {}
                if (ctrlWordData.ctrlWord.Equals("cellx")) /*param Defines the right boundary of a table cell, including its half of the space between cells.*/ {}
                if (ctrlWordData.ctrlWord.Equals("clmgf")) /*The first cell in a range of table cells to be merged.*/ {}
                if (ctrlWordData.ctrlWord.Equals("clmrg")) /*Contents of the table cell are merged with those of the preceding cell*/ {}
                if (ctrlWordData.ctrlWord.Equals("clvmgf")) /*The first cell in a range of table cells to be vertically merged.*/ {}
                if (ctrlWordData.ctrlWord.Equals("clvmrg")) /*Contents of the table cell are vertically merged with those of the preceding cell*/ {}
                /* TABLE: table row revision tracking */
                if (ctrlWordData.ctrlWord.Equals("trauth")) /*With revision tracking enabled, this control word identifies the author of changes to a table row's properties. N refers to a value in the revision table*/ {}
                if (ctrlWordData.ctrlWord.Equals("trdate")) /*With revision tracking enabled, this control word identifies the date of a revision*/ {}
                /* TABLE: Autoformatting flags */
                if (ctrlWordData.ctrlWord.Equals("tbllkborder")) /*Flag sets table autoformat to format borders*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkshading")) /*Flag sets table autoformat to affect shading.*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkfont")) /*Flag sets table autoformat to affect font*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkcolor")) /*Flag sets table autoformat to affect color*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkbestfit")) /*Flag sets table autoformat to apply best fit*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkhdrrows")) /*Flag sets table autoformat to format the first (header) row*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllklastrow")) /*Flag sets table autoformat to format the last row.*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllkhdrcols")) /*Flag sets table autoformat to format the first (header) column*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllklastcol")) /*Flag sets table autoformat to format the last column*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllknorowband")) /*Specifies row banding conditional formatting shall not be applied*/ {}
                if (ctrlWordData.ctrlWord.Equals("tbllknocolband")) /*Specifies column banding conditional formatting shall not be applied.*/ {}
                /* TABLE: Row Formatting */
                if (ctrlWordData.ctrlWord.Equals("taprtl")) /*Table direction is right to left*/ {}
                if (ctrlWordData.ctrlWord.Equals("trautofit")) /*param = AutoFit:
            0   No AutoFit (default).
            1   AutoFit is on for the row. Overridden by \clwWidthN and \trwWidthN in any table row.
            */ {}
                if (ctrlWordData.ctrlWord.Equals("trhdr")) /*Table row header. This row should appear at the top of every page on which the current table appears*/ {}
                if (ctrlWordData.ctrlWord.Equals("trkeep")) /*Keep table row together. This row cannot be split by a page break. This property is assumed to be off unless the control word is present*/ {}
                if (ctrlWordData.ctrlWord.Equals("trkeepfollow")) /*Keep row in the same page as the following row.*/ {}
                if (ctrlWordData.ctrlWord.Equals("trleft")) /*Position in twips of the leftmost edge of the table with respect to the left edge of its column.*/ {}
                if (ctrlWordData.ctrlWord.Equals("trqc")) /*Centers a table row with respect to its containing column.*/ {}
                if (ctrlWordData.ctrlWord.Equals("trql")) /*Left-justifies a table row with respect to its containing column.*/ {}
                if (ctrlWordData.ctrlWord.Equals("trqr")) /*Right-justifies a table row with respect to its containing column*/ {}
                if (ctrlWordData.ctrlWord.Equals("trrh")) /*Height of a table row in twips. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line*/ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddfb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddfl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddfr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpaddft")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdfl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdft")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdfb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trspdfr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trwWidth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trftsWidth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trwWidthB")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trftsWidthB")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trftsWidthB")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trwWidthA")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trftsWidthA")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tblind")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tblindtype")) /* */ {}
                /*TABLE: Row shading and Background Colors*/
                if (ctrlWordData.ctrlWord.Equals("trcbpat")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trcfpat")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trpat")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trshdng")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgbdiag")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgcross")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdcross")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkbdiag")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkcross")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkdcross")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkfdiag")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkhor")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgdkvert")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgfdiag")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbghoriz")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbgvert")) /* */ {}
                /* TABLE: Cell Formatting*/
                if (ctrlWordData.ctrlWord.Equals("clFitText")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clNoWrap")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadfl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadft")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadfb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clpadfr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clwWidth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clftsWidth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clhidemark")) /* */ {}
                /* TABLE: Compared Table Cells */
                if (ctrlWordData.ctrlWord.Equals("clins")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("cldel")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clmrgd")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clmrgdr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clsplit")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clsplitr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clinsauth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clinsdttm")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("cldelauth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("cldeldttm")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clmrgdauth")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clmrgddttm")) /* */ {}
                /*TABLE: Position Wrapped Tables (The following properties must be the same for all rows in the table.)*/
                if (ctrlWordData.ctrlWord.Equals("tdfrmtxtLeft")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tdfrmtxtRight")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tdfrmtxtTop")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tdfrmtxtBottom")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tabsnoovrlp")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tphcol")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tphmrg")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tphpg")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposnegx")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposnegy")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposx")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposxc")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposxi")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposxl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposxo")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposxr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposy")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyc")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyil")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyin")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyout")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tposyt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tpvmrg")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tpvpara")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("tpvpg")) /* */ {}
                /* TABLE: Bidirectional Controls */
                if (ctrlWordData.ctrlWord.Equals("rtlrow")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("ltrrow")) /* */ {}
                /* TABLE: Row Borders */
                if (ctrlWordData.ctrlWord.Equals("trbrdrt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbrdrl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbrdrb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbrdrr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbrdrh")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("trbrdrv")) /* */ {}
                /* TABLE: Cell Borders */
                if (ctrlWordData.ctrlWord.Equals("brdrnil")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clbrdrb")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clbrdrt")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clbrdrl")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("clbrdrr")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("cldglu")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("cldgll")) /* */ {}
                if (ctrlWordData.ctrlWord.Equals("")) /* */ {}
            }
            if (ctrlWordData.ctrlWordType == RtfCtrlWordType.TOGGLE) {
                this.rtfParser.GetState().properties.ToggleProperty(ctrlWordData);//ctrlWordData.specialHandler);
            }

            if (ctrlWordData.ctrlWordType == RtfCtrlWordType.FLAG ||
                    ctrlWordData.ctrlWordType == RtfCtrlWordType.VALUE) {
                this.rtfParser.GetState().properties.SetProperty(ctrlWordData);//ctrlWordData.specialHandler, ctrlWordData.param);
            }

            switch (conversionType) {
            case RtfParser.TYPE_IMPORT_FULL:
                if (!IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord)) {
                    WriteBuffer();
                    WriteText(ctrlWordData.ToString());
                }
                result = true;
                break;
            case RtfParser.TYPE_IMPORT_FRAGMENT:
                if (!IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord)) {
                    WriteBuffer();
                    WriteText(ctrlWordData.ToString());
                }
                result = true;
                break;
            case RtfParser.TYPE_CONVERT:
                if (IMPORT_IGNORED_CTRLWORDS.Contains(ctrlWordData.ctrlWord) == false) {
                }
                result = true;
                break;
            default:    // error because is should be an import or convert
                result = false;
                break;
            }

            return result;
        }
Ejemplo n.º 7
0
        /**
        * Parses a keyword and it's parameter if one exists
        * @param reader
        *       This is a pushback reader for file input.
        * @return
        *       Returns an error code or errOK if no error.
        * @throws IOException
        *       Catch any file read problem.
        */
        private int ParseCtrlWord(PushbackStream reader)
        {
            int nextChar = 0;
            int result = errOK;

            if((nextChar = reader.ReadByte()) == -1) {
                    return errEndOfFile;
            }
            this.byteCount++;

            StringBuilder parsedCtrlWord = new StringBuilder();
            StringBuilder parsedParam= new StringBuilder();
            RtfCtrlWordData ctrlWordParam = new RtfCtrlWordData();

            if (!Char.IsLetterOrDigit((char)nextChar)) {
                parsedCtrlWord.Append((char)nextChar);
                ctrlWordParam.ctrlWord = parsedCtrlWord.ToString();
                result =  this.HandleCtrlWord(ctrlWordParam);
                lastCtrlWordParam = ctrlWordParam;
                return result;
            }

            //      for ( ; Character.IsLetter(nextChar[0]); reader.Read(nextChar) ) {
            //          parsedCtrlWord.Append(nextChar[0]);
            //      }
            do {
                parsedCtrlWord.Append((char)nextChar);
                //TODO: catch EOF
                nextChar = reader.ReadByte();
                this.byteCount++;
            } while  (Char.IsLetter((char)nextChar));

            ctrlWordParam.ctrlWord = parsedCtrlWord.ToString();

            if ((char)nextChar == '-') {
                ctrlWordParam.isNeg = true;
                if((nextChar = reader.ReadByte()) == -1) {
                        return errEndOfFile;
                }
                this.byteCount++;
            }

            if (Char.IsDigit((char)nextChar)) {
                ctrlWordParam.hasParam = true;
            //          for ( ; Character.IsDigit(nextChar[0]); reader.Read(nextChar) ) {
            //              parsedParam.Append(nextChar[0]);
            //          }
                do {
                    parsedParam.Append((char)nextChar);
                    //TODO: catch EOF
                    nextChar = reader.ReadByte();
                    this.byteCount++;
                } while  (Char.IsDigit((char)nextChar));

                ctrlWordParam.param = parsedParam.ToString();
            }

            // push this character back into the stream
            if ((char)nextChar != ' ') { // || this.IsImport() ) {
                reader.Unread(nextChar);
            }

            if (debugParser) {
            //      // debug: insrsid6254399
            //      if (ctrlWordParam.ctrlWord.Equals("proptype") && ctrlWordParam.param.Equals("30")) {
            //          System.out.Print("Debug value found\n");
            //      }
            //      if (ctrlWordParam.ctrlWord.Equals("panose") ) {
            //          System.out.Print("Debug value found\n");
            //      }
            }

            result = this.HandleCtrlWord(ctrlWordParam);
            lastCtrlWordParam = ctrlWordParam;
            return result;
        }
Ejemplo n.º 8
0
        /**
        * Toggle the value of the property identified by the <code>RtfCtrlWordData.specialHandler</code> parameter.
        * Toggle values are assumed to be integer values per the RTF spec with a value of 0=off or 1=on.
        *
        * @param ctrlWordData The property name to set
        * @return <code>true</code> for handled or <code>false</code> if <code>propertyName</code> is <code>null</code> or <i>blank</i>
        */
        public bool ToggleProperty(RtfCtrlWordData ctrlWordData)
        {
            //String propertyName) {

            String propertyName = ctrlWordData.specialHandler;

            if (propertyName == null || propertyName.Length == 0) return false;

            Object propertyValue = GetProperty(propertyName);
            if (propertyValue == null) {
                propertyValue = RtfProperty.ON;
            } else {
                if (propertyValue is int) {
                    int value = (int)propertyValue;
                    if (value != 0) {
                        RemoveProperty(propertyName);
                    }
                    return true;
                } else {
                    if (propertyValue is long) {
                        long value = (long)propertyValue;
                        if (value != 0) {
                            RemoveProperty(propertyName);
                        }
                        return true;
                    }
                }
            }
            SetProperty(propertyName, propertyValue);
            return true;
        }
Ejemplo n.º 9
0
 /* (non-Javadoc)
 * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
 */
 public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
 {
     elementName = ctrlWordData.ctrlWord;
     return true;
 }
Ejemplo n.º 10
0
 /**
 *
 */
 protected RtfCtrlWordData OnCtrlWord(RtfCtrlWordData ctrlWordData)
 {
     foreach (IRtfDestinationListener listener in listeners) {
         listener.OnCtrlWord(ctrlWordData);
     }
     return null;
 }
Ejemplo n.º 11
0
 /**
 * Handle control word for this destination
 * @param ctrlWordData The control word and parameter information object
 * @return true if handled, false if not handled
 */
 public abstract bool HandleControlWord(RtfCtrlWordData ctrlWordData);
Ejemplo n.º 12
0
        /**
        * The primary control word handler method.
        * Called by the parser once it has a control word and parameter if applicable.
        *
        * @param ctrlWordDataIn
        *      The control word and associated parameter if applicable.
        * @return
        *      <code>true</code> or <code>false</code> if the control word was handled.
        * @since 2.0.8
        */
        public bool HandleControlword(RtfCtrlWordData ctrlWordDataIn)
        {
            bool result = false;
            this.ctrlWordData = ctrlWordDataIn;
            RtfDestination dest = null;
            bool handled = false;

            this.ctrlWordData.prefix  = this.ctrlWordPrefix;
            this.ctrlWordData.suffix  = this.ctrlWordSuffix;
            this.ctrlWordData.newGroup = this.rtfParser.GetState().newGroup;
            this.ctrlWordData.ctrlWordType = this.ctrlWordType;
            this.ctrlWordData.specialHandler = this.specialHandler;

            if (!this.ctrlWordData.hasParam && this.passDefaultParameterValue) {
                this.ctrlWordData.hasParam = true;
                this.ctrlWordData.param = this.defaultParameterValue.ToString();
            }

            if (debug) {
                PrintDebug("handleKeyword: [" + this.ctrlWordData.ctrlWord + "] param=" + ctrlWordDataIn.param);
                RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel()+1, "RtfCtrlWordHandler debug Start: " + this.ctrlWordData.ctrlWord + " ");
            }
            if (this.ctrlWordData.ctrlWord.Equals("*")) {
                return true;
            }

            if (!BeforeControlWord()) {
                return true;
            }

            switch (this.ctrlWordType) {
            case RtfCtrlWordType.FLAG:
            case RtfCtrlWordType.TOGGLE:
            case RtfCtrlWordType.VALUE:
                dest = this.rtfParser.GetCurrentDestination();
                if (dest != null) {
                    handled = dest.HandleControlWord(this.ctrlWordData);
                }
                break;

            case RtfCtrlWordType.SYMBOL:
                dest = this.rtfParser.GetCurrentDestination();
                if (dest != null) {
                    String data = null;
                    // if doing an import, then put the control word in the output stream through the character handler
                    if (this.rtfParser.IsImport()) {
                        data = this.ctrlWordPrefix + this.ctrlWordData.ctrlWord + this.ctrlWordSuffix;
                    }
                    if (this.rtfParser.IsConvert()) {
                        data = this.specialHandler;
                    }

                    // If there is a substitute character, process the character.
                    // If no substitute character, then provide special handling in the destination for the ctrl word.
                    if (data != null) {
                        foreach (char cc in data.ToCharArray()) {
                            handled = dest.HandleCharacter((int)cc);
                        }
                    } else {
                        handled = dest.HandleControlWord(this.ctrlWordData);
                    }
                }
                break;

            case RtfCtrlWordType.DESTINATION_EX:
            case RtfCtrlWordType.DESTINATION:
                // set the destination
                int x=0;
                if(this.ctrlWord == "shppict" || this.ctrlWord == "nonshppict") {
                    x++;
                }
                handled = this.rtfParser.SetCurrentDestination(this.ctrlWord);
                // let destination handle the ctrl word now.
                dest = this.rtfParser.GetCurrentDestination();
                if(dest != null) {
                    if(dest.GetNewTokeniserState() == RtfParser.TOKENISER_IGNORE_RESULT) {
                        handled = dest.HandleControlWord(this.ctrlWordData);
                    }
                    else {
                        this.rtfParser.SetTokeniserState(dest.GetNewTokeniserState());
                    }
                }
                break;
            }

            AfterControlWord();

            if (debug) {
                RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel()+1, "RtfCtrlWordHandler debug End: " + this.ctrlWordData.ctrlWord + " ");
            }

            return result;
        }
Ejemplo n.º 13
0
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = false;
            bool skipCtrlWord = false;
            if (this.rtfParser.IsImport()) {
                skipCtrlWord = true;
                if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("nonshppict")) {    // never gets here because this is a destination set to null
                    skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pict")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true; pictureType = Image.ORIGINAL_NONE;}
                if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true; pictureType = Image.ORIGINAL_PNG;}
                if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true; pictureType = Image.ORIGINAL_JPEG;}
                if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true; pictureType = Image.ORIGINAL_NONE;}
                if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true; pictureType = Image.ORIGINAL_NONE;}
                if (ctrlWordData.ctrlWord.Equals("wmetafile")) { result = true; pictureType = Image.ORIGINAL_WMF;}
                if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true; pictureType = Image.ORIGINAL_NONE;}
                if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true; pictureType = Image.ORIGINAL_BMP;}
                /* bitmap information */
                if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true;}
                /* picture size, scaling and cropping */
                if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue();result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true;}
                /* metafile information */
                if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true;}
                /* picture data */
                if (ctrlWordData.ctrlWord.Equals("bin")) {
                    this.dataFormat = FORMAT_BINARY;
                    // set length to param
                    this.binaryLength = ctrlWordData.LongValue();
                    this.rtfParser.SetTokeniserStateBinary(binaryLength);
                    result = true;
                }
                if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true;}
            }
            if (this.rtfParser.IsConvert()) {
                if (ctrlWordData.ctrlWord.Equals("shppict")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("nonshppict")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("blipuid")) { result = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pict")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("emfblip")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("pngblip")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("jepgblip")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("macpict")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("pmmetafile")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wmetafile")) {  skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("dibitmap")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wbitmap")) { result = true;}
                /* bitmap information */
                if (ctrlWordData.ctrlWord.Equals("wbmbitspixel")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wbmplanes")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("wbmwidthbytes")) { result = true;}
                /* picture size, scaling and cropping */
                if (ctrlWordData.ctrlWord.Equals("picw")) { this.width = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pich")) { this.height = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picwgoal")) { this.desiredWidth = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("pichgoal")) { this.desiredHeight = ctrlWordData.LongValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscalex")) { this.scaleX = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscaley")) { this.scaleY = ctrlWordData.IntValue();result = true;}
                if (ctrlWordData.ctrlWord.Equals("picscaled")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("picprop")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("defshp")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropt")) { this.cropTop = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropb")) { this.cropBottom = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropl")) { this.cropLeft = ctrlWordData.IntValue(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("piccropr")) { this.cropRight = ctrlWordData.IntValue(); result = true;}
                /* metafile information */
                if (ctrlWordData.ctrlWord.Equals("picbmp")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("picbpp")) { result = true;}
                /* picture data */
                if(ctrlWordData.ctrlWord.Equals("bin")) {
                    dataFormat = FORMAT_BINARY; result = true;
                }
                if (ctrlWordData.ctrlWord.Equals("blipupi")) { result = true;}
                if (ctrlWordData.ctrlWord.Equals("blipuid")) { skipCtrlWord = true; this.rtfParser.SetTokeniserStateSkipGroup(); result = true;}
                if (ctrlWordData.ctrlWord.Equals("bliptag")) { result = true;}

            }
            if (!skipCtrlWord) {
            switch (this.rtfParser.GetConversionType()) {
            case RtfParser.TYPE_IMPORT_FULL:
                    WriteBuffer();
                    WriteText(ctrlWordData.ToString());
                result = true;
                break;
            case RtfParser.TYPE_IMPORT_FRAGMENT:
                    WriteBuffer();
                    WriteText(ctrlWordData.ToString());
                result = true;
                break;
            case RtfParser.TYPE_CONVERT:
                result = true;
                break;
            default:    // error because is should be an import or convert
                result = false;
                break;
            }
            }
            return result;
        }
Ejemplo n.º 14
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, certain tabled
        * values are remapped. i.e. colors, fonts, styles, etc.
        *
        * @param ctrlWordData The control word to handle.
        * @return errOK if ok, other if an error occurred.
        */
        public int HandleCtrlWord(RtfCtrlWordData ctrlWordData)
        {
            int result = errOK;
            this.ctrlWordCount++; // stats

            if (debugParser) {
                RtfParser.OutputDebug(this.rtfDoc, groupLevel, "DEBUG: handleCtrlWord=" + ctrlWordData.ctrlWord);
            }

            if (this.GetTokeniserState() == TOKENISER_SKIP_GROUP) {
                this.ctrlWordSkippedCount++;
                if (debugParser) {
                    RtfParser.OutputDebug(this.rtfDoc, groupLevel, "DEBUG: SKIPPED");
                }
                return result;
            }

            //      RtfDestination dest = (RtfDestination)this.GetCurrentDestination();
            //      bool handled = false;
            //      if (dest != null) {
            //          handled = dest.HandleControlWord(ctrlWordData);
            //      }

            result = this.rtfKeywordMgr.HandleKeyword(ctrlWordData, this.groupLevel);

            if ( result == errOK){
                this.ctrlWordHandledCount++;
            } else {
                this.ctrlWordNotHandledCount++;
                result = errOK; // hack for now.
            }

            return result;
        }
Ejemplo n.º 15
0
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = true;
            bool skipCtrlWord = false;

            if (this.rtfParser.IsImport()) {
                skipCtrlWord = true;
                if (ctrlWordData.ctrlWord.Equals("listtable")) {
                    result = true;
                    this.currentListMappingNumber = 0;

                } else
                    /* Picture info for icons/images for lists */
                    if (ctrlWordData.ctrlWord.Equals("listpicture"))/* DESTINATION */{
                    skipCtrlWord = true;
                    // this.rtfParser.SetTokeniserStateSkipGroup();
                    result = true;
                } else
                    /* list */
                    if (ctrlWordData.ctrlWord.Equals("list")) /* DESTINATION */{
                    skipCtrlWord = true;
                    this.newList = new RtfList(this.rtfParser.GetRtfDocument());
                    this.newList.SetListType(RtfList.LIST_TYPE_NORMAL); // set default
                    this.currentLevel = -1;
                    this.currentListMappingNumber++;
                    this.currentSubGroupCount = 0;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("listtemplateid")) /* // List item*/ {
                    // ignore this because it gets regenerated in every document
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("listsimple")) /* // List item*/ {
                    // is value 0 or 1
                    if (ctrlWordData.hasParam && ctrlWordData.param == "1") {
                        this.newList.SetListType(RtfList.LIST_TYPE_SIMPLE);
                    } else {
                        this.newList.SetListType(RtfList.LIST_TYPE_NORMAL);
                    }
                    skipCtrlWord = true;
                    result = true;
                    // this gets set internally. Don't think it should be imported
                } else if (ctrlWordData.ctrlWord.Equals("listhybrid")) /* // List item*/ {
                    this.newList.SetListType(RtfList.LIST_TYPE_HYBRID);
                    skipCtrlWord = true;
                    result = true;
                    // this gets set internally. Don't think it should be imported
                } else if (ctrlWordData.ctrlWord.Equals("listrestarthdn")) /* // List item*/ {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("listid")) {    // List item cannot be between -1 and -5
                    // needs to be mapped for imports and is recreated
                    // we have the new id and the old id. Just add it to the mapping table here.
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("listname"))/* // List item*/ {
                    this.newList.SetName(ctrlWordData.param);
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("liststyleid"))/* // List item*/ {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("liststylename"))/* // List item*/ {
                    skipCtrlWord = true;
                    result = true;
                } else
                    /* listlevel */
                    if (ctrlWordData.ctrlWord.Equals("listlevel")) /* DESTINATION There are 1 or 9 listlevels per list */{
                    this.currentLevel++;
                    this.currentListLevel = this.newList.GetListLevel(this.currentLevel);
                    this.currentListLevel.SetTentative(false);
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("leveljc")) { // listlevel item justify
                    // this is the old number. Only use it if the current type is not set
                    if ( this.currentListLevel.GetAlignment()== RtfListLevel.LIST_TYPE_UNKNOWN) {
                        switch (ctrlWordData.IntValue()) {
                            case 0:
                                this.currentListLevel.SetAlignment(Element.ALIGN_LEFT);
                                break;
                            case 1:
                                this.currentListLevel.SetAlignment(Element.ALIGN_CENTER);
                                break;
                            case 2:
                                this.currentListLevel.SetAlignment(Element.ALIGN_RIGHT);
                                break;
                        }
                    }
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("leveljcn")) { // listlevel item
                    //justify
                    // if this exists, use it and it overrides the old setting
                    switch (ctrlWordData.IntValue()) {
                        case 0:
                            this.currentListLevel.SetAlignment(Element.ALIGN_LEFT);
                            break;
                        case 1:
                            this.currentListLevel.SetAlignment(Element.ALIGN_CENTER);
                            break;
                        case 2:
                            this.currentListLevel.SetAlignment(Element.ALIGN_RIGHT);
                            break;
                    }
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelstartat")) {
                    this.currentListLevel.SetListStartAt(ctrlWordData.IntValue());
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("lvltentative")) {
                    this.currentListLevel.SetTentative(true);
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelold")) {
                    // old style. ignore
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelprev")) {
                    // old style. ignore
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelprevspace")) {
                    // old style. ignore
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelspace")) {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelindent")) {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("leveltext")) {/* FIX */
                    skipCtrlWord = true;
                    result = true;
                }  else if (ctrlWordData.ctrlWord.Equals("levelfollow")) {
                    this.currentListLevel.SetLevelFollowValue(ctrlWordData.IntValue());
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levellegal")) {
                    this.currentListLevel.SetLegal(ctrlWordData.param=="1"?true:false);
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelnorestart")) {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("chrfmt")) {/* FIX */
                    // set an attribute pair
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelpicture")) {
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("li")) {
                    // set an attribute pair
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("fi")) {
                    // set an attribute pair
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("jclisttab")) {
                    // set an attribute pair
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("tx")) {
                    // set an attribute pair
                    skipCtrlWord = true;
                    result = true;
                } else
                    /* number */
                    if (ctrlWordData.ctrlWord.Equals("levelnfc")) /* old style */ {
                    if ( this.currentListLevel.GetListType()== RtfListLevel.LIST_TYPE_UNKNOWN) {
                        this.currentListLevel.SetListType(ctrlWordData.IntValue()+RtfListLevel.LIST_TYPE_BASE);
                    }
                    skipCtrlWord = true;
                    result = true;
                } else if (ctrlWordData.ctrlWord.Equals("levelnfcn")) /* new style takes priority over levelnfc.*/ {
                    this.currentListLevel.SetListType(ctrlWordData.IntValue()+RtfListLevel.LIST_TYPE_BASE);
                    skipCtrlWord = true;
                    result = true;
                } else
                    /* level text */
                    if (ctrlWordData.ctrlWord.Equals("leveltemplateid")) {
                    // ignore. this value is regenerated in each document.
                    skipCtrlWord = true;
                    result = true;
                } else
                    /* levelnumber */
                    if (ctrlWordData.ctrlWord.Equals("levelnumbers")) {
                    skipCtrlWord = true;
                    result = true;
                }
            }

            if (this.rtfParser.IsConvert()) {
                if (ctrlWordData.ctrlWord.Equals("shppict")) {
                    result = true;
                }
                if (ctrlWordData.ctrlWord.Equals("nonshppict")) {
                    skipCtrlWord = true;
                    this.rtfParser.SetTokeniserStateSkipGroup();
                    result = true;
                }
            }
            if (!skipCtrlWord) {
                switch (this.rtfParser.GetConversionType()) {
                    case RtfParser.TYPE_IMPORT_FULL:
                        // WriteBuffer();
                        // WriteText(ctrlWordData.ToString());
                        result = true;
                        break;
                    case RtfParser.TYPE_IMPORT_FRAGMENT:
                        // WriteBuffer();
                        // WriteText(ctrlWordData.ToString());
                        result = true;
                        break;
                    case RtfParser.TYPE_CONVERT:
                        result = true;
                        break;
                    default: // error because is should be an import or convert
                        result = false;
                        break;
                }
            }

            return result;
        }
Ejemplo n.º 16
0
 /**
 * Set the value of the property identified by the parameter.
 *
 * @param ctrlWordData The controlword with the name to set
 * @return <code>true</code> for handled or <code>false</code> if <code>propertyName</code> or <code>propertyValue</code> is <code>null</code>
 */
 public bool SetProperty(RtfCtrlWordData ctrlWordData)
 {
     //String propertyName, Object propertyValueNew) {
     String propertyName = ctrlWordData.specialHandler;
     Object propertyValueNew = ctrlWordData.param;
     // depending on the control word, set mulitiple or reset settings, etc.
     //if pard then reset settings
     //
     SetProperty(propertyName, propertyValueNew);
     return true;
 }
Ejemplo n.º 17
0
        /* (non-Javadoc)
        * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)
        *
        * @since 2.0.8
        */
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = true;
            // just let fonttbl fall through and set last ctrl word object.

            if (ctrlWordData.ctrlWord.Equals("f")) { this.SetFontNumber(ctrlWordData.param); result=true;}
            if (ctrlWordData.ctrlWord.Equals("fcharset")) { this.SetCharset(ctrlWordData.param); result=true; }

            // font families
            if (ctrlWordData.ctrlWord.Equals("fnil")) { this.SetFontFamily("roman"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("froman")) { this.SetFontFamily("roman"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("fswiss")) { this.SetFontFamily("swiss"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("fmodern")) { this.SetFontFamily("modern"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("fscript")) { this.SetFontFamily("script"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("fdecor")) { this.SetFontFamily("decor"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("ftech")) { this.SetFontFamily("tech"); result=true; }
            if (ctrlWordData.ctrlWord.Equals("fbidi")) { this.SetFontFamily("bidi"); result=true; }
            // pitch
            if (ctrlWordData.ctrlWord.Equals("fprq")) { this.SetPitch(ctrlWordData.param); result=true; }
            // bias
            if (ctrlWordData.ctrlWord.Equals("fbias")) { this.SetBias(ctrlWordData.param); result=true; }
            // theme font information
            if (ctrlWordData.ctrlWord.Equals("flomajor")) { this.SetThemeFont("flomajor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fhimajor")) { this.SetThemeFont("fhimajor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fdbmajor")) { this.SetThemeFont("fdbmajor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fbimajor")) { this.SetThemeFont("fbimajor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("flominor")) { this.SetThemeFont("flominor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fhiminor")) { this.SetThemeFont("fhiminor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fdbminor")) { this.SetThemeFont("fdbminor"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fbiminor")) { this.SetThemeFont("fbiminor"); result= true; }

            // panose
            if (ctrlWordData.ctrlWord.Equals("panose")) {state = SETTING_PANOSE; result = true; }

            // \*\fname
            // <font name> #PCDATA
            if (ctrlWordData.ctrlWord.Equals("fname")) {state = SETTING_FONTNAME; result = true; }

            // \*\falt
            if (ctrlWordData.ctrlWord.Equals("falt")) { state = SETTING_ALTERNATE; result = true; }

            // \*\fontemb
            if (ctrlWordData.ctrlWord.Equals("fontemb")) { state = SETTING_FONT_EMBED; result = true; }

            // font type
            if (ctrlWordData.ctrlWord.Equals("ftnil")) { this.SetTrueType("ftnil"); result= true; }
            if (ctrlWordData.ctrlWord.Equals("fttruetype")) { this.SetTrueType("fttruetype"); result= true; }

            // \*\fontfile
            if (ctrlWordData.ctrlWord.Equals("fontemb")) { state = SETTING_FONT_FILE; result = true; }

            // codepage
            if (ctrlWordData.ctrlWord.Equals("cpg")) { this.SetCodePage(ctrlWordData.param); result= true; }

            this.lastCtrlWord = ctrlWordData;
            return result;
        }
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = true;
            this.OnCtrlWord(ctrlWordData);  // event handler

            if (this.rtfParser.IsImport()) {
                // information
                if (ctrlWordData.ctrlWord.Equals("s")) { }
                if (ctrlWordData.ctrlWord.Equals("cs")) {}
                if (ctrlWordData.ctrlWord.Equals("ds")) {}
                if (ctrlWordData.ctrlWord.Equals("ts")) {}
                if (ctrlWordData.ctrlWord.Equals("tsrowd")) {}

                if (ctrlWordData.ctrlWord.Equals("keycode")) {}
                if (ctrlWordData.ctrlWord.Equals("shift")) { }
                if (ctrlWordData.ctrlWord.Equals("ctrl")) { }
                if (ctrlWordData.ctrlWord.Equals("alt")) { }
                //cells
                if (ctrlWordData.ctrlWord.Equals("fn")) { }
                if (ctrlWordData.ctrlWord.Equals("additive")) { }
                if (ctrlWordData.ctrlWord.Equals("sbasedon")) { }
                if (ctrlWordData.ctrlWord.Equals("snext")) { }
                if (ctrlWordData.ctrlWord.Equals("sautoupd")) { }
                if (ctrlWordData.ctrlWord.Equals("shidden")) { }
                if (ctrlWordData.ctrlWord.Equals("slink")) { }
                if (ctrlWordData.ctrlWord.Equals("slocked")) { }
                if (ctrlWordData.ctrlWord.Equals("spersonal")) { }
                if (ctrlWordData.ctrlWord.Equals("scompose")) { }
                if (ctrlWordData.ctrlWord.Equals("sreply")) { }
                /* FORMATTING */
                // brdrdef/parfmt/apoctl/tabdef/shading/chrfmt

                if (ctrlWordData.ctrlWord.Equals("styrsid")) { }
                if (ctrlWordData.ctrlWord.Equals("ssemihidden")) { }
                if (ctrlWordData.ctrlWord.Equals("sqformat")) { }
                if (ctrlWordData.ctrlWord.Equals("spriority")) { }
                if (ctrlWordData.ctrlWord.Equals("sunhideused")) { }

                /* TABLE STYLES */
                if (ctrlWordData.ctrlWord.Equals("tscellwidth")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellwidthfts")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddt")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddl")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddr")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddb")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddft"))/*0-auto, 3-twips*/ { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddfl"))/*0-auto, 3-twips*/ { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddfr"))/*0-auto, 3-twips*/ { }
                if (ctrlWordData.ctrlWord.Equals("tscellpaddfb"))/*0-auto, 3-twips*/ { }
                if (ctrlWordData.ctrlWord.Equals("tsvertalt")) { }
                if (ctrlWordData.ctrlWord.Equals("tsvertalc")) { }
                if (ctrlWordData.ctrlWord.Equals("tsvertalb")) { }
                if (ctrlWordData.ctrlWord.Equals("tsnowrap")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellcfpat")) { }
                if (ctrlWordData.ctrlWord.Equals("tscellcbpat")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgbdiag")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgfdiag")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgcross")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgdcross")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgdkcross ")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgdkdcross")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbghoriz")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgvert")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgdkhor")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbgdkvert")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrt")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrb")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrl")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrr")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrh")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrv")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrdgl")) { }
                if (ctrlWordData.ctrlWord.Equals("tsbrdrdgr")) { }
                if (ctrlWordData.ctrlWord.Equals("tscbandsh")) { }
                if (ctrlWordData.ctrlWord.Equals("tscbandsv")) { }
            }
            if (ctrlWordData.ctrlWordType == RtfCtrlWordType.FLAG ||
                    ctrlWordData.ctrlWordType == RtfCtrlWordType.TOGGLE ||
                    ctrlWordData.ctrlWordType == RtfCtrlWordType.VALUE) {
                this.rtfParser.GetState().properties.SetProperty(ctrlWordData);
            }

            switch (this.rtfParser.GetConversionType()) {
            case RtfParser.TYPE_IMPORT_FULL:
                result = true;
                break;
            case RtfParser.TYPE_IMPORT_FRAGMENT:
                result = true;
                break;
            case RtfParser.TYPE_CONVERT:
                result = true;
                break;
            default:    // error because is should be an import or convert
                result = false;
                break;
            }
            return result;
        }
Ejemplo n.º 19
0
        /**
         * The primary control word handler method.
         * Called by the parser once it has a control word and parameter if applicable.
         *
         * @param ctrlWordDataIn
         *      The control word and associated parameter if applicable.
         * @return
         *      <code>true</code> or <code>false</code> if the control word was handled.
         * @since 2.0.8
         */
        public bool HandleControlword(RtfCtrlWordData ctrlWordDataIn)
        {
            bool result = false;

            this.ctrlWordData = ctrlWordDataIn;
            RtfDestination dest    = null;
            bool           handled = false;

            this.ctrlWordData.prefix         = this.ctrlWordPrefix;
            this.ctrlWordData.suffix         = this.ctrlWordSuffix;
            this.ctrlWordData.newGroup       = this.rtfParser.GetState().newGroup;
            this.ctrlWordData.ctrlWordType   = this.ctrlWordType;
            this.ctrlWordData.specialHandler = this.specialHandler;

            if (!this.ctrlWordData.hasParam && this.passDefaultParameterValue)
            {
                this.ctrlWordData.hasParam = true;
                this.ctrlWordData.param    = this.defaultParameterValue.ToString();
            }

            if (debug)
            {
                PrintDebug("handleKeyword: [" + this.ctrlWordData.ctrlWord + "] param=" + ctrlWordDataIn.param);
                RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug Start: " + this.ctrlWordData.ctrlWord + " ");
            }
            if (this.ctrlWordData.ctrlWord.Equals("*"))
            {
                return(true);
            }

            if (!BeforeControlWord())
            {
                return(true);
            }

            switch (this.ctrlWordType)
            {
            case RtfCtrlWordType.FLAG:
            case RtfCtrlWordType.TOGGLE:
            case RtfCtrlWordType.VALUE:
                dest = this.rtfParser.GetCurrentDestination();
                if (dest != null)
                {
                    handled = dest.HandleControlWord(this.ctrlWordData);
                }
                break;

            case RtfCtrlWordType.SYMBOL:
                dest = this.rtfParser.GetCurrentDestination();
                if (dest != null)
                {
                    String data = null;
                    // if doing an import, then put the control word in the output stream through the character handler
                    if (this.rtfParser.IsImport())
                    {
                        data = this.ctrlWordPrefix + this.ctrlWordData.ctrlWord + this.ctrlWordSuffix;
                    }
                    if (this.rtfParser.IsConvert())
                    {
                        data = this.specialHandler;
                    }

                    // If there is a substitute character, process the character.
                    // If no substitute character, then provide special handling in the destination for the ctrl word.
                    if (data != null)
                    {
                        foreach (char cc in data.ToCharArray())
                        {
                            handled = dest.HandleCharacter((int)cc);
                        }
                    }
                    else
                    {
                        handled = dest.HandleControlWord(this.ctrlWordData);
                    }
                }
                break;

            case RtfCtrlWordType.DESTINATION_EX:
            case RtfCtrlWordType.DESTINATION:
                // set the destination
                int x = 0;
                if (this.ctrlWord == "shppict" || this.ctrlWord == "nonshppict")
                {
                    x++;
                }
                handled = this.rtfParser.SetCurrentDestination(this.ctrlWord);
                // let destination handle the ctrl word now.
                dest = this.rtfParser.GetCurrentDestination();
                if (dest != null)
                {
                    if (dest.GetNewTokeniserState() == RtfParser.TOKENISER_IGNORE_RESULT)
                    {
                        handled = dest.HandleControlWord(this.ctrlWordData);
                    }
                    else
                    {
                        this.rtfParser.SetTokeniserState(dest.GetNewTokeniserState());
                    }
                }
                break;
            }

            AfterControlWord();

            if (debug)
            {
                RtfParser.OutputDebug(this.rtfParser.GetRtfDocument(), this.rtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug End: " + this.ctrlWordData.ctrlWord + " ");
            }

            return(result);
        }