Ejemplo n.º 1
0
        private static RtfControlWordInfo RtfControlWordLookup(string controlName)
        {
            // Initialize hashtable
            lock (_rtfControlTableMutex)
            {
                if (_rtfControlTable == null)
                {
                    RtfControlWordInfo[] controlWordInfoTable = RtfControls.ControlTable;
                    _rtfControlTable = new Hashtable(controlWordInfoTable.Length);

                    for (int i = 0; i < controlWordInfoTable.Length; i++)
                    {
                        _rtfControlTable.Add(controlWordInfoTable[i].ControlName, controlWordInfoTable[i]);
                    }
                }
            }

            RtfControlWordInfo cwi = (RtfControlWordInfo)_rtfControlTable[controlName];

            if (cwi == null)
            {
                // OK, then canonicalize it
                controlName = controlName.ToLower(CultureInfo.InvariantCulture);
                cwi         = (RtfControlWordInfo)_rtfControlTable[controlName];
            }
            return(cwi);
        }
        // Token: 0x060032BE RID: 12990 RVA: 0x000E44B4 File Offset: 0x000E26B4
        private static RtfControlWordInfo RtfControlWordLookup(string controlName)
        {
            object rtfControlTableMutex = RtfToXamlLexer._rtfControlTableMutex;

            lock (rtfControlTableMutex)
            {
                if (RtfToXamlLexer._rtfControlTable == null)
                {
                    RtfControlWordInfo[] controlTable = RtfControls.ControlTable;
                    RtfToXamlLexer._rtfControlTable = new Hashtable(controlTable.Length);
                    for (int i = 0; i < controlTable.Length; i++)
                    {
                        RtfToXamlLexer._rtfControlTable.Add(controlTable[i].ControlName, controlTable[i]);
                    }
                }
            }
            RtfControlWordInfo rtfControlWordInfo = (RtfControlWordInfo)RtfToXamlLexer._rtfControlTable[controlName];

            if (rtfControlWordInfo == null)
            {
                controlName        = controlName.ToLower(CultureInfo.InvariantCulture);
                rtfControlWordInfo = (RtfControlWordInfo)RtfToXamlLexer._rtfControlTable[controlName];
            }
            return(rtfControlWordInfo);
        }
        internal void HandleControl(RtfToken token, RtfControlWordInfo controlWordInfo)
        {
            FormatState formatState = _converterState.TopFormatState;

            if (formatState == null)
            {
                return;
            }

            switch (controlWordInfo.Control)
            {
                case RtfControlWord.Ctrl_V:
                    formatState.IsHidden = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_DELETED:
                    formatState.IsHidden = true;
                    break;
                case RtfControlWord.Ctrl_B:
                    formatState.Bold = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_I:
                    formatState.Italic = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_IMPR:
                    formatState.Engrave = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_OUTL:
                    formatState.Outline = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_SHAD:
                    formatState.Shadow = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_SCAPS:
                    formatState.SCaps = token.ToggleValue > 0;
                    break;
                case RtfControlWord.Ctrl_FS:
                    if (Validators.IsValidFontSize(token.Parameter))
                        formatState.FontSize = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_EXPND:
                case RtfControlWord.Ctrl_EXPNDTW:
                    formatState.Expand = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_F:
                    if (token.HasParameter)
                        if (formatState.RtfDestination == RtfDestination.DestFontTable)
                        {
                            _converterState.FontTable.DefineEntry((int)token.Parameter);
                        }
                        else
                        {
                            SelectFont(token.Parameter);

                            // Setting font also sets current language in effect
                            if (formatState.FontSlot == FontSlot.DBCH)
                            {
                                if (formatState.LangFE > 0)
                                {
                                    formatState.LangCur = formatState.LangFE;
                                }
                                else if (_converterState.DefaultLangFE > 0)
                                {
                                    formatState.LangCur = _converterState.DefaultLangFE;
                                }
                            }
                            else
                            {
                                if (formatState.Lang > 0)
                                {
                                    formatState.LangCur = formatState.Lang;
                                }
                                else if (_converterState.DefaultLang > 0)
                                {
                                    formatState.LangCur = _converterState.DefaultLang;
                                }
                            }
                        }

                    break;
                case RtfControlWord.Ctrl_DBCH:
                    formatState.FontSlot = FontSlot.DBCH;
                    break;
                case RtfControlWord.Ctrl_LOCH:
                    formatState.FontSlot = FontSlot.LOCH;
                    break;
                case RtfControlWord.Ctrl_HICH:
                    formatState.FontSlot = FontSlot.HICH;
                    break;
                case RtfControlWord.Ctrl_LANG:
                    formatState.Lang = token.Parameter;
                    formatState.LangCur = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_LANGFE:
                    formatState.LangFE = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_DEFLANG:
                    _converterState.DefaultLang = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_DEFLANGFE:
                    _converterState.DefaultLangFE = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_DEFF:
                    _converterState.DefaultFont = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_FNAME:
                    {
                        FormatState previousFormatState = _converterState.PreviousTopFormatState(1);
                        if (previousFormatState.RtfDestination == RtfDestination.DestFontTable)
                        {
                            formatState.RtfDestination = RtfDestination.DestFontName;
                            FontTableEntry entry = _converterState.FontTable.CurrentEntry;
                            if (entry != null)
                            {
                                entry.Name = null;
                            }
                        }
                    }
                    break;
                case RtfControlWord.Ctrl_FCHARSET:
                    if (formatState.RtfDestination == RtfDestination.DestFontTable)
                    {
                        HandleFontTableTokens(token);
                    }
                    break;
                case RtfControlWord.Ctrl_HIGHLIGHT:
                    formatState.CB = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_CB:
                    formatState.CB = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_CF:
                    formatState.CF = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_SUB:
                    formatState.Sub = token.FlagValue;
                    if (formatState.Sub)
                    {
                        formatState.Super = false;
                    }
                    break;
                case RtfControlWord.Ctrl_SUPER:
                    formatState.Super = token.FlagValue;
                    if (formatState.Super)
                    {
                        formatState.Sub = false;
                    }
                    break;
                case RtfControlWord.Ctrl_NOSUPERSUB:
                    formatState.Sub = false;
                    formatState.Super = false;

                    formatState.SuperOffset = 0;
                    break;
                case RtfControlWord.Ctrl_UP:
                    formatState.SuperOffset = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_ULC:
                    // NB: underline color not implemented
                    break;
                case RtfControlWord.Ctrl_UL:
                case RtfControlWord.Ctrl_ULD:
                case RtfControlWord.Ctrl_ULDASH:
                case RtfControlWord.Ctrl_ULDASHD:
                case RtfControlWord.Ctrl_ULDASHDD:
                case RtfControlWord.Ctrl_ULDB:
                case RtfControlWord.Ctrl_ULHAIR:
                case RtfControlWord.Ctrl_ULHWAVE:
                case RtfControlWord.Ctrl_ULLDASH:
                case RtfControlWord.Ctrl_ULTH:
                case RtfControlWord.Ctrl_ULTHD:
                case RtfControlWord.Ctrl_ULTHDASH:
                case RtfControlWord.Ctrl_ULTHDASHD:
                case RtfControlWord.Ctrl_ULTHDASHDD:
                case RtfControlWord.Ctrl_ULTHLDASH:
                case RtfControlWord.Ctrl_ULULDBWAVE:
                case RtfControlWord.Ctrl_ULWAVE:
                case RtfControlWord.Ctrl_ULW:
                    formatState.UL = (token.ToggleValue > 0 ? ULState.ULNormal : ULState.ULNone);
                    break;
                case RtfControlWord.Ctrl_ULNONE:
                    formatState.UL = ULState.ULNone;
                    break;
                case RtfControlWord.Ctrl_STRIKE:
                    formatState.Strike = token.ToggleValue > 0 ? StrikeState.StrikeNormal : StrikeState.StrikeNone;
                    break;
                case RtfControlWord.Ctrl_STRIKED:
                    formatState.Strike = token.ToggleValue > 0 ? StrikeState.StrikeDouble : StrikeState.StrikeNone;
                    break;
                case RtfControlWord.Ctrl_PLAIN:
                    formatState.SetCharDefaults();
                    if (_converterState.DefaultFont >= 0)
                    {
                        SelectFont(_converterState.DefaultFont);
                    }
                    break;

                // Paragraph settings
                case RtfControlWord.Ctrl_PARD:
                    formatState.SetParaDefaults();
                    break;
                case RtfControlWord.Ctrl_SB:
                    formatState.SB = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_SA:
                    formatState.SA = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_FI:
                    // Word first indent(\fiN) and Avalon TextIndent concept is the different.
                    // So we ignore the negative first indent safely which can make the content invisible.
                    // Word: \fi-200        -200    0   200
                    //                              abc
                    //                                  xyz
                    // Word: \fi200         -200    0   200
                    //                                  abc
                    //                              xyz
                    if (token.Parameter > 0)
                    {
                        formatState.FI = token.Parameter;
                    }
                    break;
                case RtfControlWord.Ctrl_LIN:
                    // We ignore \lin and do RTL fixup on margins outselves.
                    // formatState.LI = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_LI:
                    formatState.LI = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_RIN:
                    // We ignore \rin and do RTL fixup on margins outselves.
                    // formatState.RI = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_RI:
                    formatState.RI = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_QC:
                    formatState.HAlign = HAlign.AlignCenter;
                    break;
                case RtfControlWord.Ctrl_QJ:
                    formatState.HAlign = HAlign.AlignJustify;
                    break;
                case RtfControlWord.Ctrl_QL:
                    formatState.HAlign = HAlign.AlignLeft;
                    break;
                case RtfControlWord.Ctrl_QR:
                    formatState.HAlign = HAlign.AlignRight;
                    break;
                case RtfControlWord.Ctrl_CFPAT:
                    formatState.CFPara = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_SHADING:
                    // Shading of the CFPAT color, in 100's of a percent.
                    formatState.ParaShading = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_CBPAT:
                    formatState.CBPara = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_SL:
                    formatState.SL = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_SLMULT:
                    formatState.SLMult = token.ToggleValue > 0;
                    break;

                // Special text
                case RtfControlWord.Ctrl_LINE:
                    ProcessHardLine(token, formatState);
                    break;

                // LTR-RTL stuff
                case RtfControlWord.Ctrl_LTRCH:
                    formatState.DirChar = DirState.DirLTR;
                    break;
                case RtfControlWord.Ctrl_LTRPAR:
                case RtfControlWord.Ctrl_LTRDOC:
                case RtfControlWord.Ctrl_LTRSECT:
                    formatState.DirPara = DirState.DirLTR;
                    break;
                case RtfControlWord.Ctrl_RTLCH:
                    formatState.DirChar = DirState.DirRTL;
                    break;
                case RtfControlWord.Ctrl_RTLPAR:
                case RtfControlWord.Ctrl_RTLDOC:
                case RtfControlWord.Ctrl_RTLSECT:
                    formatState.DirPara = DirState.DirRTL;
                    // RTF defaults paragraph alignment to left for both RTL and LTR paragraphs, but
                    // Avalon switches the default.  Hard-code the alignment here when dealing with RTL
                    // paragraphs so that the distinction doesn't result in different defaults.
                    if (formatState.HAlign == HAlign.AlignDefault)
                    {
                        formatState.HAlign = HAlign.AlignLeft;
                    }
                    break;
                case RtfControlWord.Ctrl_LTRMARK:
                    ProcessText(new string('\x200e', 1));
                    break;
                case RtfControlWord.Ctrl_RTLMARK:
                    ProcessText(new string('\x200f', 1));
                    break;

                // Structure output
                case RtfControlWord.Ctrl_PAR:
                case RtfControlWord.Ctrl_SECT:
                    HandlePara(token, formatState);
                    break;

                case RtfControlWord.Ctrl_PAGE:
                    HandlePage(token, formatState);
                    break;

                // Table Tokens
                case RtfControlWord.Ctrl_CELL:
                case RtfControlWord.Ctrl_NESTCELL:
                case RtfControlWord.Ctrl_ROW:
                case RtfControlWord.Ctrl_TROWD:
                case RtfControlWord.Ctrl_NESTROW:
                case RtfControlWord.Ctrl_NESTTABLEPROPS:
                    HandleTableTokens(token, formatState);
                    break;

                // Table property tokens
                case RtfControlWord.Ctrl_TRGAPH:
                case RtfControlWord.Ctrl_TRLEFT:
                case RtfControlWord.Ctrl_TRQC:
                case RtfControlWord.Ctrl_TRQL:
                case RtfControlWord.Ctrl_TRQR:
                case RtfControlWord.Ctrl_TRPADDL:
                case RtfControlWord.Ctrl_TRPADDR:
                case RtfControlWord.Ctrl_TRPADDB:
                case RtfControlWord.Ctrl_TRPADDT:
                case RtfControlWord.Ctrl_TRPADDFL:
                case RtfControlWord.Ctrl_TRPADDFT:
                case RtfControlWord.Ctrl_TRPADDFB:
                case RtfControlWord.Ctrl_TRPADDFR:
                case RtfControlWord.Ctrl_TRFTSWIDTH:
                case RtfControlWord.Ctrl_TRFTSWIDTHB:
                case RtfControlWord.Ctrl_TRFTSWIDTHA:
                case RtfControlWord.Ctrl_TRWWIDTH:
                case RtfControlWord.Ctrl_TRWWIDTHB:
                case RtfControlWord.Ctrl_TRWWIDTHA:
                case RtfControlWord.Ctrl_TRAUTOFIT:
                case RtfControlWord.Ctrl_CLWWIDTH:
                case RtfControlWord.Ctrl_CLFTSWIDTH:
                case RtfControlWord.Ctrl_TRBRDRT:
                case RtfControlWord.Ctrl_TRBRDRB:
                case RtfControlWord.Ctrl_TRBRDRR:
                case RtfControlWord.Ctrl_TRBRDRL:
                case RtfControlWord.Ctrl_TRBRDRV:
                case RtfControlWord.Ctrl_TRBRDRH:
                case RtfControlWord.Ctrl_CLVERTALT:
                case RtfControlWord.Ctrl_CLVERTALB:
                case RtfControlWord.Ctrl_CLVERTALC:
                case RtfControlWord.Ctrl_CLSHDRAWNIL:
                case RtfControlWord.Ctrl_CLSHDNG:
                case RtfControlWord.Ctrl_CLBRDRB:
                case RtfControlWord.Ctrl_CLBRDRR:
                case RtfControlWord.Ctrl_CLBRDRT:
                case RtfControlWord.Ctrl_CLBRDRL:
                case RtfControlWord.Ctrl_CLCBPAT:
                case RtfControlWord.Ctrl_CLCFPAT:
                case RtfControlWord.Ctrl_CLPADL:
                case RtfControlWord.Ctrl_CLPADFL:
                case RtfControlWord.Ctrl_CLPADR:
                case RtfControlWord.Ctrl_CLPADFR:
                case RtfControlWord.Ctrl_CLPADT:
                case RtfControlWord.Ctrl_CLPADFT:
                case RtfControlWord.Ctrl_CLPADB:
                case RtfControlWord.Ctrl_CLPADFB:
                case RtfControlWord.Ctrl_CELLX:
                case RtfControlWord.Ctrl_BRDRART:
                case RtfControlWord.Ctrl_BRDRB:
                case RtfControlWord.Ctrl_BRDRNIL:
                case RtfControlWord.Ctrl_BRDRNONE:
                case RtfControlWord.Ctrl_BRDRTBL:
                case RtfControlWord.Ctrl_BRDRBAR:
                case RtfControlWord.Ctrl_BRDRBTW:
                case RtfControlWord.Ctrl_BRDRCF:
                case RtfControlWord.Ctrl_BRDRDASH:
                case RtfControlWord.Ctrl_BRDRDASHD:
                case RtfControlWord.Ctrl_BRDRDASHDD:
                case RtfControlWord.Ctrl_BRDRDASHDOTSTR:
                case RtfControlWord.Ctrl_BRDRDASHSM:
                case RtfControlWord.Ctrl_BRDRDB:
                case RtfControlWord.Ctrl_BRDRDOT:
                case RtfControlWord.Ctrl_BRDREMBOSS:
                case RtfControlWord.Ctrl_BRDRENGRAVE:
                case RtfControlWord.Ctrl_BRDRFRAME:
                case RtfControlWord.Ctrl_BRDRHAIR:
                case RtfControlWord.Ctrl_BRDRINSET:
                case RtfControlWord.Ctrl_BRDRL:
                case RtfControlWord.Ctrl_BRDROUTSET:
                case RtfControlWord.Ctrl_BRDRR:
                case RtfControlWord.Ctrl_BRDRS:
                case RtfControlWord.Ctrl_BRDRSH:
                case RtfControlWord.Ctrl_BRDRT:
                case RtfControlWord.Ctrl_BRDRTH:
                case RtfControlWord.Ctrl_BRDRTHTNLG:
                case RtfControlWord.Ctrl_BRDRTHTNMG:
                case RtfControlWord.Ctrl_BRDRTHTNSG:
                case RtfControlWord.Ctrl_BRDRTNTHLG:
                case RtfControlWord.Ctrl_BRDRTNTHMG:
                case RtfControlWord.Ctrl_BRDRTNTHSG:
                case RtfControlWord.Ctrl_BRDRTNTHTNLG:
                case RtfControlWord.Ctrl_BRDRTNTHTNMG:
                case RtfControlWord.Ctrl_BRDRTNTHTNSG:
                case RtfControlWord.Ctrl_BRDRTRIPLE:
                case RtfControlWord.Ctrl_BRDRW:
                case RtfControlWord.Ctrl_BRDRWAVY:
                case RtfControlWord.Ctrl_BRDRWAVYDB:
                case RtfControlWord.Ctrl_BRSP:
                case RtfControlWord.Ctrl_BOX:
                case RtfControlWord.Ctrl_RTLROW:
                case RtfControlWord.Ctrl_LTRROW:
                case RtfControlWord.Ctrl_TRSPDB:
                case RtfControlWord.Ctrl_TRSPDFB:
                case RtfControlWord.Ctrl_TRSPDFL:
                case RtfControlWord.Ctrl_TRSPDFR:
                case RtfControlWord.Ctrl_TRSPDFT:
                case RtfControlWord.Ctrl_TRSPDL:
                case RtfControlWord.Ctrl_TRSPDR:
                case RtfControlWord.Ctrl_TRSPDT:
                case RtfControlWord.Ctrl_CLMGF:
                case RtfControlWord.Ctrl_CLMRG:
                case RtfControlWord.Ctrl_CLVMGF:
                case RtfControlWord.Ctrl_CLVMRG:
                    HandleTableProperties(token, formatState);
                    break;

                // Symbols
                case RtfControlWord.Ctrl_TAB:
                    ProcessText("\t");
                    break;
                case RtfControlWord.Ctrl_EMDASH:
                    ProcessText("\x2014");
                    break;
                case RtfControlWord.Ctrl_ENDASH:
                    ProcessText("\x2013");
                    break;
                case RtfControlWord.Ctrl_EMSPACE:
                    ProcessText("\x2003");
                    break;
                case RtfControlWord.Ctrl_ENSPACE:
                    ProcessText("\x2002");
                    break;
                case RtfControlWord.Ctrl_QMSPACE:
                    ProcessText("\x2005");
                    break;
                case RtfControlWord.Ctrl_BULLET:
                    ProcessText("\x2022");  // Unicode bullet
                    break;
                case RtfControlWord.Ctrl_LQUOTE:
                    ProcessText("\x2018");
                    break;
                case RtfControlWord.Ctrl_RQUOTE:
                    ProcessText("\x2019");
                    break;
                case RtfControlWord.Ctrl_LDBLQUOTE:
                    ProcessText("\x201c");
                    break;
                case RtfControlWord.Ctrl_RDBLQUOTE:
                    ProcessText("\x201d");
                    break;
                case RtfControlWord.Ctrl_ZWJ:  // zero-width-joiner
                    ProcessText("\x200d");
                    break;
                case RtfControlWord.Ctrl_ZWNJ: // zero-width-non-joiner
                    ProcessText("\x200c");
                    break;

                case RtfControlWord.Ctrl_ANSICPG:
                    // This is just a hint for RTF output roundtripping - ignore.
                    break;

                // CodePage Tokens
                case RtfControlWord.Ctrl_ANSI:
                case RtfControlWord.Ctrl_MAC:
                case RtfControlWord.Ctrl_PC:
                case RtfControlWord.Ctrl_PCA:
                case RtfControlWord.Ctrl_UPR:
                case RtfControlWord.Ctrl_UD:
                case RtfControlWord.Ctrl_UC:
                    HandleCodePageTokens(token, formatState);
                    break;
                case RtfControlWord.Ctrl_U:
                    HandleCodePageTokens(token, formatState);
                    _lexer.AdvanceForUnicode(formatState.UnicodeSkip);
                    break;

                // Field (hyperlink) commands
                case RtfControlWord.Ctrl_FIELD:
                case RtfControlWord.Ctrl_FLDRSLT:
                case RtfControlWord.Ctrl_FLDINST:
                case RtfControlWord.Ctrl_FLDPRIV:
                    HandleFieldTokens(token, formatState);
                    break;

                // Structure commands
                case RtfControlWord.Ctrl_ILVL:
                    formatState.ILVL = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_INTBL:
                    formatState.IsInTable = token.FlagValue;
                    break;

                case RtfControlWord.Ctrl_LS:
                    if (formatState.RtfDestination == RtfDestination.DestListOverride)
                    {
                        HandleListTokens(token, formatState);
                    }
                    else
                    {
                        formatState.ILS = token.Parameter;
                    }
                    break;

                case RtfControlWord.Ctrl_ITAP:
                    formatState.ITAP = token.Parameter;
                    break;

                // Other special parsing commands
                case RtfControlWord.Ctrl_BIN:
                    HandleBinControl(token, formatState);
                    break;

                // List Table commands
                case RtfControlWord.Ctrl_LIST:
                case RtfControlWord.Ctrl_LISTTEMPLATEID:
                case RtfControlWord.Ctrl_LISTHYBRID:
                case RtfControlWord.Ctrl_LISTSIMPLE:
                case RtfControlWord.Ctrl_LISTLEVEL:
                case RtfControlWord.Ctrl_LISTTEXT:
                case RtfControlWord.Ctrl_LEVELNFC:
                case RtfControlWord.Ctrl_LEVELNFCN:
                case RtfControlWord.Ctrl_LEVELJC:
                case RtfControlWord.Ctrl_LEVELJCN:
                case RtfControlWord.Ctrl_LEVELFOLLOW:
                case RtfControlWord.Ctrl_LEVELSTARTAT:
                case RtfControlWord.Ctrl_LEVELSPACE:
                case RtfControlWord.Ctrl_LEVELINDENT:
                case RtfControlWord.Ctrl_LEVELTEXT:
                case RtfControlWord.Ctrl_LEVELTEMPLATEID:
                case RtfControlWord.Ctrl_LISTID:
                case RtfControlWord.Ctrl_LEVELNUMBERS:
                case RtfControlWord.Ctrl_LISTOVERRIDE:
                    HandleListTokens(token, formatState);
                    break;

                case RtfControlWord.Ctrl_LISTPICTURE:
                    formatState.RtfDestination = RtfDestination.DestListPicture;
                    break;

                // Old-style list info
                case RtfControlWord.Ctrl_PNLVL:
                case RtfControlWord.Ctrl_PNLVLBLT:
                case RtfControlWord.Ctrl_PNLVLBODY:
                case RtfControlWord.Ctrl_PNLVLCONT:
                case RtfControlWord.Ctrl_PNCARD:
                case RtfControlWord.Ctrl_PNDEC:
                case RtfControlWord.Ctrl_PNUCLTR:
                case RtfControlWord.Ctrl_PNUCRM:
                case RtfControlWord.Ctrl_PNLCLTR:
                case RtfControlWord.Ctrl_PNLCRM:
                case RtfControlWord.Ctrl_PNORD:
                case RtfControlWord.Ctrl_PNORDT:
                case RtfControlWord.Ctrl_PNBIDIA:
                case RtfControlWord.Ctrl_PNBIDIB:
                case RtfControlWord.Ctrl_PN:
                case RtfControlWord.Ctrl_PNTXTA:
                case RtfControlWord.Ctrl_PNTXTB:
                case RtfControlWord.Ctrl_PNTEXT:
                case RtfControlWord.Ctrl_PNSTART:
                    HandleOldListTokens(token, formatState);
                    break;

                // Shapes (we only read down-level info)
                case RtfControlWord.Ctrl_DO:
                case RtfControlWord.Ctrl_SHPRSLT:
                case RtfControlWord.Ctrl_DPTXBXTEXT:
                case RtfControlWord.Ctrl_SHPPICT:
                case RtfControlWord.Ctrl_NONSHPPICT:
                    HandleShapeTokens(token, formatState);
                    break;

                // Document tables
                case RtfControlWord.Ctrl_FONTTBL:
                    formatState.RtfDestination = RtfDestination.DestFontTable;
                    break;

                case RtfControlWord.Ctrl_COLORTBL:
                    formatState.RtfDestination = RtfDestination.DestColorTable;
                    break;

                case RtfControlWord.Ctrl_LISTTABLE:
                    formatState.RtfDestination = RtfDestination.DestListTable;
                    break;

                case RtfControlWord.Ctrl_LISTOVERRIDETABLE:
                    formatState.RtfDestination = RtfDestination.DestListOverrideTable;
                    break;

                case RtfControlWord.Ctrl_RED:
                    if (formatState.RtfDestination == RtfDestination.DestColorTable)
                    {
                        _converterState.ColorTable.NewRed = (byte)token.Parameter;
                    }
                    break;
                case RtfControlWord.Ctrl_GREEN:
                    if (formatState.RtfDestination == RtfDestination.DestColorTable)
                        _converterState.ColorTable.NewGreen = (byte)token.Parameter;
                    break;
                case RtfControlWord.Ctrl_BLUE:
                    if (formatState.RtfDestination == RtfDestination.DestColorTable)
                    {
                        _converterState.ColorTable.NewBlue = (byte)token.Parameter;
                    }
                    break;
                case RtfControlWord.Ctrl_SHPINST:
                    formatState.RtfDestination = RtfDestination.DestShapeInstruction;
                    break;
                case RtfControlWord.Ctrl_PICT:
                    {
                        FormatState previousFormatState = _converterState.PreviousTopFormatState(1);

                        // Filter the redundant picture or list picture
                        if ((previousFormatState.RtfDestination == RtfDestination.DestShapePicture ||
                             previousFormatState.RtfDestination == RtfDestination.DestShapeInstruction) ||
                            (previousFormatState.RtfDestination != RtfDestination.DestNoneShapePicture &&
                             previousFormatState.RtfDestination != RtfDestination.DestShape &&
                             previousFormatState.RtfDestination != RtfDestination.DestListPicture))
                        {
                            formatState.RtfDestination = RtfDestination.DestPicture;
                        }
                    }
                    break;
                case RtfControlWord.Ctrl_PNGBLIP:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageFormat = RtfImageFormat.Png;
                    }
                    break;
                case RtfControlWord.Ctrl_JPEGBLIP:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageFormat = RtfImageFormat.Jpeg;
                    }
                    break;
                case RtfControlWord.Ctrl_WMETAFILE:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageFormat = RtfImageFormat.Wmf;
                    }
                    break;
                case RtfControlWord.Ctrl_PICHGOAL:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageHeight = Converters.TwipToPositivePx(token.Parameter);
                    }
                    break;
                case RtfControlWord.Ctrl_PICWGOAL:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageWidth = Converters.TwipToPositivePx(token.Parameter);
                    }
                    break;
                case RtfControlWord.Ctrl_PICSCALEX:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageScaleWidth = token.Parameter;
                    }
                    break;
                case RtfControlWord.Ctrl_PICSCALEY:
                    if (formatState.RtfDestination == RtfDestination.DestPicture)
                    {
                        formatState.ImageScaleHeight = token.Parameter;
                    }
                    break;
            }
        }