/// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
        /// </summary>
        public override bool HandleCloseGroup()
        {
            OnCloseGroup();    // event handler

            if (RtfParser.IsImport())
            {
                if (_buffer.Length > 0)
                {
                    writeBuffer();
                }
                writeText("}");
            }
            if (RtfParser.IsConvert())
            {
                if (_buffer.Length > 0 && _iTextParagraph == null)
                {
                    _iTextParagraph = new Paragraph();
                }
                if (_buffer.Length > 0)
                {
                    Chunk chunk = new Chunk();
                    chunk.Append(_buffer.ToString());
                    _iTextParagraph.Add(chunk);
                }
                if (_iTextParagraph != null)
                {
                    addParagraphToDocument();
                }
            }
            return true;
        }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
        /// </summary>
        public override bool HandleCloseGroup()
        {
            OnCloseGroup();    // event handler

            if (RtfParser.IsImport())
            {
                if (_buffer.Length > 0)
                {
                    writeBuffer();
                }
                if (_dataOs != null)
                {
                    addImage();
                    _dataOs = null;
                }
                writeText("}");
                return(true);
            }
            if (RtfParser.IsConvert())
            {
                if (_dataOs != null)
                {
                    addImage();
                    _dataOs = null;
                }
            }
            return(true);
        }
 /// <summary>
 /// (non-Javadoc)
 /// @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()
 /// </summary>
 public override bool HandleOpeningSubGroup()
 {
     if (RtfParser.IsImport())
     {
         if (_buffer.Length > 0)
         {
             writeBuffer();
         }
     }
     return true;
 }
 /// <summary>
 /// emfblip - EMF (nhanced metafile) - NOT HANDLED
 /// </summary>
 /// <summary>
 /// pngblip int ORIGINAL_PNG = 2;
 /// </summary>
 /// <summary>
 /// jpegblip Image.ORIGINAL_JPEG = 1; ORIGINAL_JPEG2000 = 8;
 /// </summary>
 /// <summary>
 /// (non-Javadoc)
 /// @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
 /// </summary>
 public override bool CloseDestination()
 {
     if (RtfParser.IsImport())
     {
         if (_buffer.Length > 0)
         {
             writeBuffer();
         }
     }
     return(true);
 }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
        /// </summary>
        public override bool HandleCharacter(int ch)
        {
            if (RtfParser.IsImport())
            {
                if (_buffer.Length > 254)
                {
                    writeBuffer();
                }
            }
            if (_data == null)
            {
                _data = new ByteBuffer();
            }

            switch (_dataFormat)
            {
            case FORMAT_HEXADECIMAL:
                _hexChars.Append(ch);
                if (_hexChars.Length == 2)
                {
                    try
                    {
                        _data.Append((char)int.Parse(_hexChars.ToString(), NumberStyles.HexNumber));
                    }
                    catch
                    {
                    }
                    _hexChars = new StringBuilder();
                }
                break;

            case FORMAT_BINARY:
                if (_dataOs == null)
                {
                    _dataOs = new MemoryStream();
                }
                // HGS - FIX ME IF PROBLEM!
                _dataOs.WriteByte((byte)ch);
                // PNG signature should be.
                //             (decimal)              137  80  78  71  13  10  26  10
                //             (hexadecimal)           89  50  4e  47  0d  0a  1a  0a
                //             (ASCII C notation)    \211   P   N   G  \r  \n \032 \n

                _binaryLength--;
                if (_binaryLength == 0)
                {
                    _dataFormat = FORMAT_HEXADECIMAL;
                }
                break;
            }

            return(true);
        }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
        /// </summary>
        public override bool HandleOpenGroup()
        {
            OnOpenGroup(); // event handler

            if (RtfParser.IsImport())
            {
            }
            if (RtfParser.IsConvert())
            {
            }
            return(true);
        }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()
        /// </summary>
        public override bool HandleOpenGroup()
        {
            OnOpenGroup(); // event handler

            if (RtfParser.IsImport())
            {
            }
            if (RtfParser.IsConvert())
            {
                if (_iTextParagraph == null) _iTextParagraph = new Paragraph();
            }
            return true;
        }
        private bool addImage()
        {
            Image img = null;

            try
            {
                img = Image.GetInstance(_dataOs.ToArray());
            }
            catch
            {
            }
            //                if (img != null) {
            //                    FileOutputStream out =null;
            //                    try {
            //                        out = new FileOutputStream("c:\\test.png");
            //                        out.Write(img.GetOriginalData());
            //                        out.Close();
            //                    } catch (FileNotFoundException e1) {
            //                        // TODO Auto-generated catch block
            //                        e1.PrintStackTrace();
            //                    } catch (IOException e1) {
            //                        // TODO Auto-generated catch block
            //                        e1.PrintStackTrace();
            //                    }

            if (img != null)
            {
                img.ScaleAbsolute((float)_desiredWidth / PixelTwipsFactor, (float)_desiredHeight / PixelTwipsFactor);
                img.ScaleAbsolute((float)_width / PixelTwipsFactor, (float)_height / PixelTwipsFactor);
                img.ScalePercent(_scaleX, _scaleY);

                try
                {
                    if (RtfParser.IsImport())
                    {
                        var doc = RtfParser.GetDocument();
                        doc.Add(img);
                    }
                    if (RtfParser.IsConvert())
                    {
                        RtfParser.GetDocument().Add(img);
                    }
                }
                catch
                {
                }
            }
            _dataFormat = FORMAT_HEXADECIMAL;
            return(true);
        }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()
        /// </summary>
        public override bool CloseDestination()
        {
            if (RtfParser.IsImport())
            {
                if (_buffer.Length > 0)
                {
                    writeBuffer();
                }
            }

            RtfParser.GetState().Properties.RemoveRtfPropertyListener(this);

            return true;
        }
        /// <summary>
        /// Processes the color triplet parsed from the document.
        /// Add it to the import mapping so colors can be mapped when encountered
        /// in the RTF import or conversion.
        /// </summary>
        private void processColor()
        {
            if (_red != -1 && _green != -1 && _blue != -1)
            {
                if (RtfParser.IsImport())
                {
                    _importHeader.ImportColor(_colorNr.ToString(), new BaseColor(_red, _green, _blue));
                }

                if (RtfParser.IsConvert())
                {
                    _colorMap[_colorNr.ToString()] = new BaseColor(_red, _green, _blue);
                }
            }
            SetToDefaults();
            _colorNr++;
        }
        /// <summary>
        /// (non-Javadoc)
        /// @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(int)
        /// </summary>
        public override bool HandleCharacter(int ch)
        {
            bool result = true;
            OnCharacter(ch);   // event handler

            if (RtfParser.IsImport())
            {
                if (_buffer.Length > 254)
                {
                    writeBuffer();
                }
                _buffer.Append((char)ch);
            }
            if (RtfParser.IsConvert())
            {
                _buffer.Append((char)ch);
            }
            return result;
        }
Beispiel #12
0
        /// <summary>
        /// Process the font information that was parsed from the input.
        /// @since 2.0.8
        /// </summary>
        private void processFont()
        {
            _fontName = _fontName.Trim();
            if (_fontName.Length == 0)
            {
                return;
            }
            if (_fontNr.Length == 0)
            {
                return;
            }

            if (_fontName.Length > 0 && _fontName.IndexOf(";", StringComparison.Ordinal) >= 0)
            {
                _fontName = _fontName.Substring(0, _fontName.IndexOf(";", StringComparison.Ordinal));
            }

            if (RtfParser.IsImport())
            {
                //TODO: If primary font fails, use the alternate
                //TODO: Problem: RtfFont defaults family to \froman and doesn't allow any other family.
                // if you set the family, it changes the font name and not the family in the Font.java class.

                //          if (this.fontFamily.Length() > 0) {
                //              if (this.importHeader.ImportFont(this.fontNr, this.fontName, this.fontFamily, Integer.ParseInt(this.charset)) == false) {
                //                  if (this.falt.Length() > 0) {
                //                      this.importHeader.ImportFont(this.fontNr, this.falt, this.fontFamily, Integer.ParseInt(this.charset));
                //                  }
                //              }
                //          } else {
                if (!_importHeader.ImportFont(_fontNr, _fontName, int.Parse(_charset == "" ? CharsetDefault : _charset)))
                {
                    if (_falt.Length > 0)
                    {
                        _importHeader.ImportFont(_fontNr, _falt, int.Parse(_charset == "" ? CharsetDefault : _charset));
                    }
                }
                //          }
            }
            if (RtfParser.IsConvert())
            {
                // This could probably be written as a better font matching function

                string fName = _fontName;   // work variable for trimming name if needed.
                Font   f1    = createfont(fName);
                if (f1.BaseFont == null && _falt.Length > 0)
                {
                    f1 = createfont(_falt);
                }

                if (f1.BaseFont == null)
                {
                    // Did not find a font, let's try a substring of the first name.
                    if (FontFactory.COURIER.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        f1 = FontFactory.GetFont(FontFactory.COURIER);
                    }
                    else if (FontFactory.HELVETICA.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        f1 = FontFactory.GetFont(FontFactory.HELVETICA);
                    }
                    else if (FontFactory.TIMES.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        f1 = FontFactory.GetFont(FontFactory.TIMES);
                    }
                    else if (FontFactory.SYMBOL.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        f1 = FontFactory.GetFont(FontFactory.SYMBOL);
                    }
                    else if (FontFactory.ZAPFDINGBATS.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        f1 = FontFactory.GetFont(FontFactory.ZAPFDINGBATS);
                    }
                    else
                    {
                        // we did not find a matching font in any form.
                        // default to HELVETICA for now.
                        f1 = FontFactory.GetFont(FontFactory.HELVETICA);
                    }
                }
                _fontMap[_fontNr] = f1;
                //System.out.Println(f1.GetFamilyname());
            }
            SetToDefaults();
        }
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            var result       = false;
            var skipCtrlWord = false;

            if (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; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("blipuid"))
                {
                    skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picprop"))
                {
                    skipCtrlWord = true; 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"))
                {
                    _width = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("pich"))
                {
                    _height = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picwgoal"))
                {
                    _desiredWidth = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("pichgoal"))
                {
                    _desiredHeight = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscalex"))
                {
                    _scaleX = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscaley"))
                {
                    _scaleY = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscaled"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picprop"))
                {
                    skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("defshp"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropt"))
                {
                    _cropTop = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropb"))
                {
                    _cropBottom = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropl"))
                {
                    _cropLeft = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropr"))
                {
                    _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;
                    // set length to param
                    _binaryLength = ctrlWordData.LongValue();
                    RtfParser.SetTokeniserStateBinary(_binaryLength);
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("blipupi"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("blipuid"))
                {
                    skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("bliptag"))
                {
                    result = true;
                }
            }
            if (RtfParser.IsConvert())
            {
                if (ctrlWordData.CtrlWord.Equals("shppict"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("nonshppict"))
                {
                    skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("blipuid"))
                {
                    result = true; 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; 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"))
                {
                    _width = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("pich"))
                {
                    _height = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picwgoal"))
                {
                    _desiredWidth = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("pichgoal"))
                {
                    _desiredHeight = ctrlWordData.LongValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscalex"))
                {
                    _scaleX = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscaley"))
                {
                    _scaleY = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picscaled"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("picprop"))
                {
                    skipCtrlWord = true; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("defshp"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropt"))
                {
                    _cropTop = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropb"))
                {
                    _cropBottom = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropl"))
                {
                    _cropLeft = ctrlWordData.IntValue(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("piccropr"))
                {
                    _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; RtfParser.SetTokeniserStateSkipGroup(); result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("bliptag"))
                {
                    result = true;
                }
            }
            if (!skipCtrlWord)
            {
                switch (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);
        }
Beispiel #14
0
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            var result       = true;
            var skipCtrlWord = false;

            if (RtfParser.IsImport())
            {
                skipCtrlWord = true;
                if (ctrlWordData.CtrlWord.Equals("listtable"))
                {
                    result = true;
                    _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;
                    _newList     = new RtfList(RtfParser.GetRtfDocument());
                    _newList.SetListType(RtfList.LIST_TYPE_NORMAL); // set default
                    _currentLevel = -1;
                    _currentListMappingNumber++;
                    _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")
                    {
                        _newList.SetListType(RtfList.LIST_TYPE_SIMPLE);
                    }
                    else
                    {
                        _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*/
                {
                    _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*/
                {
                    _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 */
                {
                    _currentLevel++;
                    _currentListLevel = _newList.GetListLevel(_currentLevel);
                    _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 (_currentListLevel.GetAlignment() == RtfListLevel.LIST_TYPE_UNKNOWN)
                    {
                        switch (ctrlWordData.IntValue())
                        {
                        case 0:
                            _currentListLevel.SetAlignment(Element.ALIGN_LEFT);
                            break;

                        case 1:
                            _currentListLevel.SetAlignment(Element.ALIGN_CENTER);
                            break;

                        case 2:
                            _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:
                        _currentListLevel.SetAlignment(Element.ALIGN_LEFT);
                        break;

                    case 1:
                        _currentListLevel.SetAlignment(Element.ALIGN_CENTER);
                        break;

                    case 2:
                        _currentListLevel.SetAlignment(Element.ALIGN_RIGHT);
                        break;
                    }
                    skipCtrlWord = true;
                    result       = true;
                }
                else if (ctrlWordData.CtrlWord.Equals("levelstartat"))
                {
                    _currentListLevel.SetListStartAt(ctrlWordData.IntValue());
                    skipCtrlWord = true;
                    result       = true;
                }
                else if (ctrlWordData.CtrlWord.Equals("lvltentative"))
                {
                    _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"))
                {
                    _currentListLevel.SetLevelFollowValue(ctrlWordData.IntValue());
                    skipCtrlWord = true;
                    result       = true;
                }
                else if (ctrlWordData.CtrlWord.Equals("levellegal"))
                {
                    _currentListLevel.SetLegal(ctrlWordData.Param == "1");
                    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 (_currentListLevel.GetListType() == RtfListLevel.LIST_TYPE_UNKNOWN)
                    {
                        _currentListLevel.SetListType(ctrlWordData.IntValue() + RtfListLevel.LIST_TYPE_BASE);
                    }
                    skipCtrlWord = true;
                    result       = true;
                }
                else if (ctrlWordData.CtrlWord.Equals("levelnfcn")) /* new style takes priority over levelnfc.*/
                {
                    _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 (RtfParser.IsConvert())
            {
                if (ctrlWordData.CtrlWord.Equals("shppict"))
                {
                    result = true;
                }
                if (ctrlWordData.CtrlWord.Equals("nonshppict"))
                {
                    skipCtrlWord = true;
                    RtfParser.SetTokeniserStateSkipGroup();
                    result = true;
                }
            }
            if (!skipCtrlWord)
            {
                switch (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);
        }
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            bool result = false;
            OnCtrlWord(ctrlWordData);  // event handler

            if (RtfParser.IsImport())
            {
                // map font information
                if (ctrlWordData.CtrlWord.Equals("f")) { ctrlWordData.Param = RtfParser.GetImportManager().MapFontNr(ctrlWordData.Param); }

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



            if (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)
            {
                RtfParser.GetState().Properties.ToggleProperty(ctrlWordData);//ctrlWordData.specialHandler);
            }

            if (ctrlWordData.CtrlWordType == RtfCtrlWordType.FLAG ||
                    ctrlWordData.CtrlWordType == RtfCtrlWordType.VALUE)
            {
                RtfParser.GetState().Properties.SetProperty(ctrlWordData);//ctrlWordData.specialHandler, ctrlWordData.param);
            }

            switch (_conversionType)
            {
                case RtfParser.TYPE_IMPORT_FULL:
                    if (!_importIgnoredCtrlwords.Contains(ctrlWordData.CtrlWord))
                    {
                        writeBuffer();
                        writeText(ctrlWordData.ToString());
                    }
                    result = true;
                    break;
                case RtfParser.TYPE_IMPORT_FRAGMENT:
                    if (!_importIgnoredCtrlwords.Contains(ctrlWordData.CtrlWord))
                    {
                        writeBuffer();
                        writeText(ctrlWordData.ToString());
                    }
                    result = true;
                    break;
                case RtfParser.TYPE_CONVERT:
                    if (_importIgnoredCtrlwords.Contains(ctrlWordData.CtrlWord) == false)
                    {
                    }
                    result = true;
                    break;
                default:    // error because is should be an import or convert
                    result = false;
                    break;
            }




            return result;
        }
        /// <summary>
        /// The primary control word handler method.
        /// Called by the parser once it has a control word and parameter if applicable.
        /// The control word and associated parameter if applicable.
        ///  true  or  false  if the control word was handled.
        /// @since 2.0.8
        /// </summary>
        /// <param name="ctrlWordDataIn"></param>
        /// <returns></returns>
        public bool HandleControlword(RtfCtrlWordData ctrlWordDataIn)
        {
            bool result = false;

            CtrlWordData = ctrlWordDataIn;
            RtfDestination dest    = null;
            bool           handled = false;

            CtrlWordData.Prefix         = CtrlWordPrefix;
            CtrlWordData.Suffix         = CtrlWordSuffix;
            CtrlWordData.NewGroup       = RtfParser.GetState().NewGroup;
            CtrlWordData.CtrlWordType   = CtrlWordType;
            CtrlWordData.SpecialHandler = SpecialHandler;

            if (!CtrlWordData.HasParam && PassDefaultParameterValue)
            {
                CtrlWordData.HasParam = true;
                CtrlWordData.Param    = DefaultParameterValue.ToString();
            }

            if (_debug)
            {
                printDebug("handleKeyword: [" + CtrlWordData.CtrlWord + "] param=" + ctrlWordDataIn.Param);
                RtfParser.OutputDebug(RtfParser.GetRtfDocument(), RtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug Start: " + CtrlWordData.CtrlWord + " ");
            }
            if (CtrlWordData.CtrlWord.Equals("*"))
            {
                return(true);
            }

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

            switch (CtrlWordType)
            {
            case RtfCtrlWordType.FLAG:
            case RtfCtrlWordType.TOGGLE:
            case RtfCtrlWordType.VALUE:
                dest = RtfParser.GetCurrentDestination();
                if (dest != null)
                {
                    handled = dest.HandleControlWord(CtrlWordData);
                }
                break;

            case RtfCtrlWordType.SYMBOL:
                dest = 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 (RtfParser.IsImport())
                    {
                        data = CtrlWordPrefix + CtrlWordData.CtrlWord + CtrlWordSuffix;
                    }
                    if (RtfParser.IsConvert())
                    {
                        data = 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)
                        {
                            handled = dest.HandleCharacter(cc);
                        }
                    }
                    else
                    {
                        handled = dest.HandleControlWord(CtrlWordData);
                    }
                }
                break;

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

            AfterControlWord();

            if (_debug)
            {
                RtfParser.OutputDebug(RtfParser.GetRtfDocument(), RtfParser.GetLevel() + 1, "RtfCtrlWordHandler debug End: " + CtrlWordData.CtrlWord + " ");
            }

            return(result);
        }
Beispiel #17
0
        public override bool HandleControlWord(RtfCtrlWordData ctrlWordData)
        {
            var result = true;

            OnCtrlWord(ctrlWordData);  // event handler

            if (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)
            {
                RtfParser.GetState().Properties.SetProperty(ctrlWordData);
            }

            switch (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);
        }