Ejemplo n.º 1
0
        // Token: 0x0600190D RID: 6413 RVA: 0x000C7DFC File Offset: 0x000C5FFC
        public static bool IsIncludePictureField(ref ScratchBuffer scratch, out BufferString linkUrl)
        {
            int num    = 0;
            int length = scratch.Length;

            while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num])))
            {
                num++;
            }
            if (scratch.Length - num > 15 && scratch[num] == 'I' && scratch[num + 1] == 'N' && scratch[num + 2] == 'C' && scratch[num + 3] == 'L' && scratch[num + 4] == 'U' && scratch[num + 5] == 'D' && scratch[num + 6] == 'E' && scratch[num + 7] == 'P' && scratch[num + 8] == 'I' && scratch[num + 9] == 'C' && scratch[num + 10] == 'T' && scratch[num + 11] == 'U' && scratch[num + 12] == 'R' && scratch[num + 13] == 'E' && scratch[num + 14] == ' ')
            {
                num += 15;
                int offset;
                int num2;
                int offset2;
                int num3;
                int fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out offset, out num2, out offset2, out num3);
                while (num2 == 2 && scratch[offset] == '\\')
                {
                    num          += fieldArgument;
                    fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out offset, out num2, out offset2, out num3);
                }
                if (num3 > 2)
                {
                    linkUrl = scratch.SubString(offset2, num3);
                    return(true);
                }
            }
            linkUrl = BufferString.Null;
            return(false);
        }
Ejemplo n.º 2
0
        // Token: 0x060018FE RID: 6398 RVA: 0x000C7A24 File Offset: 0x000C5C24
        public static RtfSupport.CharRep CharRepFromLanguage(int langid)
        {
            short num = (short)(langid & 1023);

            if (num >= 26)
            {
                if (langid == 3098 || langid == 2092 || langid == 2115 || langid == 1104)
                {
                    return(RtfSupport.CharRep.RUSSIAN_INDEX);
                }
                if ((int)num >= RtfSupport.CharRepFromLID.Length)
                {
                    return(RtfSupport.CharRep.ANSI_INDEX);
                }
            }
            RtfSupport.CharRep charRep = RtfSupport.CharRepFromLID[(int)num];
            if (!RtfSupport.IsFECharRep(charRep))
            {
                return(charRep);
            }
            if (charRep == RtfSupport.CharRep.GB2312_INDEX && langid != 2052 && langid != 4100)
            {
                charRep = RtfSupport.CharRep.BIG5_INDEX;
            }
            return(charRep);
        }
Ejemplo n.º 3
0
        // Token: 0x0600190C RID: 6412 RVA: 0x000C7C8C File Offset: 0x000C5E8C
        public static bool IsHyperlinkField(ref ScratchBuffer scratch, out bool local, out BufferString linkUrl)
        {
            int num    = 0;
            int length = scratch.Length;

            while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num])))
            {
                num++;
            }
            if (scratch.Length - num > 10 && scratch[num] == 'H' && scratch[num + 1] == 'Y' && scratch[num + 2] == 'P' && scratch[num + 3] == 'E' && scratch[num + 4] == 'R' && scratch[num + 5] == 'L' && scratch[num + 6] == 'I' && scratch[num + 7] == 'N' && scratch[num + 8] == 'K' && scratch[num + 9] == ' ')
            {
                num += 10;
                int num2;
                int num3;
                int num4;
                int num5;
                int fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
                if (num3 == 2 && scratch[num2] == '\\' && scratch[num2 + 1] == 'l')
                {
                    local         = true;
                    num          += fieldArgument;
                    fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
                }
                else
                {
                    local = false;
                }
                if (num5 != 0)
                {
                    if (local)
                    {
                        num4--;
                        num5++;
                        scratch[num4] = '#';
                    }
                    linkUrl = scratch.SubString(num4, num5);
                    return(true);
                }
            }
            local   = false;
            linkUrl = BufferString.Null;
            return(false);
        }
Ejemplo n.º 4
0
        private int EncodeText(char[] buffer, int offset, int count, bool flushEncoder)
        {
            int num  = offset;
            int num2 = offset + count;

            while (num != num2)
            {
                if (this.outputCurrent == this.outputEnd)
                {
                    this.CommitOutput();
                    this.GetOutputBuffer(16);
                }
                int  num3 = num;
                char c    = buffer[num3];
                if ((int)c < RtfSupport.UnsafeAsciiMap.Length)
                {
                    if (RtfSupport.UnsafeAsciiMap[(int)c] != 0)
                    {
                        if (this.outputEnd - this.outputCurrent < 6)
                        {
                            this.CommitOutput();
                            this.GetOutputBuffer(16);
                        }
                        if (c == '\\')
                        {
                            if (this.textType == RtfOutput.TextType.DoubleEscapedText)
                            {
                                this.outputBuffer[this.outputCurrent++] = 92;
                                this.outputBuffer[this.outputCurrent++] = 92;
                            }
                            this.outputBuffer[this.outputCurrent++] = 92;
                            this.outputBuffer[this.outputCurrent++] = 92;
                        }
                        else if (c == '{' || c == '}')
                        {
                            if (this.textType == RtfOutput.TextType.DoubleEscapedText)
                            {
                                this.outputBuffer[this.outputCurrent++] = 92;
                            }
                            this.outputBuffer[this.outputCurrent++] = 92;
                            this.outputBuffer[this.outputCurrent++] = (byte)c;
                        }
                        else if (c == '"')
                        {
                            if (this.textType == RtfOutput.TextType.DoubleEscapedText)
                            {
                                this.outputBuffer[this.outputCurrent++] = 92;
                                this.outputBuffer[this.outputCurrent++] = 92;
                                this.outputBuffer[this.outputCurrent++] = 34;
                            }
                            else
                            {
                                this.outputBuffer[this.outputCurrent++] = 34;
                            }
                        }
                        else if (c == '\u00a0')
                        {
                            this.outputBuffer[this.outputCurrent++] = 32;
                        }
                        else if (this.textType == RtfOutput.TextType.MarkupText && (c == '\r' || c == '\n'))
                        {
                            this.outputBuffer[this.outputCurrent++] = 92;
                            this.outputBuffer[this.outputCurrent++] = 112;
                            this.outputBuffer[this.outputCurrent++] = 97;
                            this.outputBuffer[this.outputCurrent++] = 114;
                            this.outputBuffer[this.outputCurrent++] = 13;
                            this.outputBuffer[this.outputCurrent++] = 10;
                            if (c == '\r' && num3 < num2 - 1 && buffer[num3 + 1] == '\n')
                            {
                                num3++;
                            }
                        }
                        else
                        {
                            this.outputBuffer[this.outputCurrent++] = 92;
                            this.outputBuffer[this.outputCurrent++] = 39;
                            RtfSupport.Escape(c, this.outputBuffer, this.outputCurrent);
                            this.outputCurrent += 2;
                        }
                        num3++;
                    }
                    else
                    {
                        this.outputBuffer[this.outputCurrent++] = (byte)c;
                        num3++;
                        while (num3 != num2 && this.outputCurrent != this.outputEnd && (int)(c = buffer[num3]) < RtfSupport.UnsafeAsciiMap.Length)
                        {
                            if (RtfSupport.UnsafeAsciiMap[(int)c] != 0)
                            {
                                break;
                            }
                            this.outputBuffer[this.outputCurrent++] = (byte)c;
                            num3++;
                        }
                    }
                }
                else if (!this.codePageMap.IsUnsafeExtendedCharacter(c))
                {
                    if (this.outputEnd - this.outputCurrent < 16)
                    {
                        this.CommitOutput();
                        this.GetOutputBuffer(16);
                    }
                    do
                    {
                        num3++;
                    }while (num3 != num2 && (int)(c = buffer[num3]) >= RtfSupport.UnsafeAsciiMap.Length && !this.codePageMap.IsUnsafeExtendedCharacter(c));
                    if (this.encodeBuffer == null)
                    {
                        this.encodeBuffer = new byte[512];
                    }
                    bool flag = num3 != num2 || flushEncoder;
                    for (;;)
                    {
                        int  num4;
                        int  num5;
                        bool flag2;
                        this.encoder.Convert(buffer, num, num3 - num, this.encodeBuffer, 0, this.encodeBuffer.Length, flag, out num4, out num5, out flag2);
                        this.encoderFlushed = (flag && flag2);
                        for (int i = 0; i < num5; i++)
                        {
                            if (this.outputEnd - this.outputCurrent < 4)
                            {
                                this.CommitOutput();
                                this.GetOutputBuffer(16);
                            }
                            this.outputBuffer[this.outputCurrent++] = 92;
                            this.outputBuffer[this.outputCurrent++] = 39;
                            RtfSupport.Escape((char)this.encodeBuffer[i], this.outputBuffer, this.outputCurrent);
                            this.outputCurrent += 2;
                        }
                        num += num4;
                        if (num == num3)
                        {
                            if (!flag)
                            {
                                break;
                            }
                            if (flag2)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (this.outputEnd - this.outputCurrent < 8)
                    {
                        this.CommitOutput();
                        this.GetOutputBuffer(16);
                    }
                    int num6 = (int)c;
                    int num7 = (num6 < 10) ? 1 : ((num6 < 100) ? 2 : ((num6 < 1000) ? 3 : ((num6 < 10000) ? 4 : 5)));
                    this.outputBuffer[this.outputCurrent++] = 92;
                    this.outputBuffer[this.outputCurrent++] = 117;
                    int num8 = this.outputCurrent + num7;
                    while (num6 != 0)
                    {
                        int num9 = num6 % 10;
                        this.outputBuffer[--num8] = (byte)(num9 + 48);
                        num6 /= 10;
                    }
                    this.outputCurrent += num7;
                    this.outputBuffer[this.outputCurrent++] = 63;
                    num3++;
                }
                num = num3;
            }
            return(count);
        }
Ejemplo n.º 5
0
        // Token: 0x0600190E RID: 6414 RVA: 0x000C7F8C File Offset: 0x000C618C
        public static bool IsSymbolField(ref ScratchBuffer scratch, out TextMapping textMapping, out char symbol, out short points)
        {
            textMapping = TextMapping.Unicode;
            symbol      = '\0';
            points      = 0;
            int num    = 0;
            int length = scratch.Length;

            while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num])))
            {
                num++;
            }
            if (scratch.Length - num <= 7 || scratch[num] != 'S' || scratch[num + 1] != 'Y' || scratch[num + 2] != 'M' || scratch[num + 3] != 'B' || scratch[num + 4] != 'O' || scratch[num + 5] != 'L' || scratch[num + 6] != ' ')
            {
                return(false);
            }
            num += 7;
            int  num2;
            int  num3;
            int  num4;
            int  num5;
            int  fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
            int  num6;
            char c;

            if (num3 > 2 && scratch.Buffer[num2] == '0' && (ushort)(scratch.Buffer[num2 + 1] | ' ') == 120)
            {
                num6 = 2;
                while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= 'f')
                {
                    if (('0' > c || c > '9') && ('a' > c || c > 'f'))
                    {
                        if ('A' > c)
                        {
                            break;
                        }
                        if (c > 'F')
                        {
                            break;
                        }
                    }
                    symbol = (symbol << 4) + ((c <= '9') ? (c - '0') : ((c & 'O') - 'A' + '\n'));
                    num6++;
                }
            }
            else
            {
                num6 = 0;
                while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= '9' && '0' <= c)
                {
                    symbol = '\n' * symbol + (c - '0');
                    num6++;
                }
            }
            num          += fieldArgument;
            fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
            if (num3 != 2 || scratch[num2] != '\\' || scratch[num2 + 1] != 'f')
            {
                return(false);
            }
            num          += fieldArgument;
            fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
            if (num5 == 0)
            {
                return(false);
            }
            RecognizeInterestingFontName recognizeInterestingFontName = default(RecognizeInterestingFontName);

            num6 = 0;
            while (num6 < num5 && !recognizeInterestingFontName.IsRejected)
            {
                recognizeInterestingFontName.AddCharacter(scratch.Buffer[num4 + num6]);
                num6++;
            }
            textMapping = recognizeInterestingFontName.TextMapping;
            if (textMapping == TextMapping.Unicode)
            {
                textMapping = TextMapping.OtherSymbol;
            }
            num          += fieldArgument;
            fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
            if (num3 != 2 || scratch[num2] != '\\' || scratch[num2 + 1] != 's')
            {
                return(true);
            }
            num          += fieldArgument;
            fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
            num6          = 0;
            while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= '9' && '0' <= c)
            {
                points = 10 * points + (short)(c - '0');
                num6++;
            }
            return(true);
        }
Ejemplo n.º 6
0
        // Token: 0x06001893 RID: 6291 RVA: 0x000C4ABC File Offset: 0x000C2CBC
        private bool ParseKeywordRun()
        {
            if (1 != this.parseEnd - this.parseOffset)
            {
                byte b = this.parseBuffer[this.parseOffset + 1];
                char c = (char)b;
                int  num;
                if (c > '-')
                {
                    if (c <= '\\')
                    {
                        if (c == ':')
                        {
                            this.lastLeadByte = false;
                            this.run.InitializeKeyword(3, 0, 2, this.SkipIfNecessary(1), this.firstKeyword);
                            this.parseOffset += 2;
                            return(true);
                        }
                        if (c != '\\')
                        {
                            goto IL_CE;
                        }
                    }
                    else
                    {
                        if (c != '_')
                        {
                            switch (c)
                            {
                            case '{':
                            case '}':
                                goto IL_EA;

                            case '|':
                                this.lastLeadByte = false;
                                this.run.InitializeKeyword(2, 0, 2, this.SkipIfNecessary(1), this.firstKeyword);
                                this.parseOffset += 2;
                                return(true);

                            case '~':
                                num = 160;
                                goto IL_155;
                            }
                            goto IL_CE;
                        }
                        num = 8209;
                        goto IL_155;
                    }
IL_EA:
                    num = (int)b;
                    goto IL_EC;
                }
                if (c <= '\'')
                {
                    switch (c)
                    {
                    case '\t':
                        this.lastLeadByte = false;
                        this.run.InitializeKeyword(126, 0, 2, this.SkipIfNecessary(1), this.firstKeyword);
                        this.parseOffset += 2;
                        return(true);

                    case '\n':
                    case '\r':
                        this.lastLeadByte = false;
                        this.run.InitializeKeyword(68, 0, 2, this.SkipIfNecessary(1), this.firstKeyword);
                        this.parseOffset += 2;
                        return(true);

                    case '\v':
                    case '\f':
                        break;

                    default:
                        if (c == '\'')
                        {
                            this.EnsureCodePage();
                            if (this.parseEnd - this.parseOffset >= 4)
                            {
                                num = RtfSupport.Unescape(this.parseBuffer[this.parseOffset + 2], this.parseBuffer[this.parseOffset + 3]);
                                if (num > 255)
                                {
                                    if (this.lastLeadByte)
                                    {
                                        this.lastLeadByte = false;
                                        this.run.Initialize(RtfRunKind.Text, 1, 0, this.SkipIfNecessary(1), false);
                                        this.parseOffset++;
                                        return(true);
                                    }
                                    num = 63;
                                }
                                else
                                {
                                    if ((num == 13 || num == 10) && !this.lastLeadByte)
                                    {
                                        this.run.InitializeKeyword(68, 0, 4, this.SkipIfNecessary(1), this.firstKeyword);
                                        this.parseOffset += 4;
                                        return(true);
                                    }
                                    if (num == 0)
                                    {
                                        num = 32;
                                    }
                                    this.lastLeadByte = (!this.lastLeadByte && ParseSupport.IsLeadByte((byte)num, this.leadMask));
                                }
                                this.run.Initialize(RtfRunKind.Escape, 4, num, this.SkipIfNecessary(1), this.lastLeadByte);
                                this.parseOffset += 4;
                                return(true);
                            }
                            if (this.endOfFileVisible)
                            {
                                this.run.Initialize(RtfRunKind.Text, 1, 0, this.SkipIfNecessary(1), false);
                                this.parseOffset++;
                                this.lastLeadByte = false;
                                return(true);
                            }
                            return(false);
                        }
                        break;
                    }
                }
                else
                {
                    if (c == '*')
                    {
                        this.lastLeadByte = false;
                        this.run.InitializeKeyword(1, 0, 2, this.SkipIfNecessary(1), this.firstKeyword);
                        this.parseOffset += 2;
                        return(true);
                    }
                    if (c == '-')
                    {
                        num = 173;
                        goto IL_155;
                    }
                }
IL_CE:
                CharClass charClass = ParseSupport.GetCharClass(b);
                if (ParseSupport.AlphaCharacter(charClass))
                {
                    this.lastLeadByte = false;
                    return(this.ParseKeyword(b));
                }
                num = (int)b;
                if (num == 0)
                {
                    num = 32;
                }
IL_EC:
                this.EnsureCodePage();
                this.lastLeadByte = (!this.lastLeadByte && ParseSupport.IsLeadByte((byte)num, this.leadMask));
                this.run.Initialize(RtfRunKind.Escape, 2, num, this.SkipIfNecessary(1), this.lastLeadByte);
                this.parseOffset += 2;
                return(true);

IL_155:
                this.EnsureCodePage();
                this.lastLeadByte = false;
                this.run.Initialize(RtfRunKind.Unicode, 2, num, this.SkipIfNecessary(1), false);
                this.parseOffset += 2;
                return(true);
            }
            if (this.endOfFileVisible)
            {
                this.run.Initialize(RtfRunKind.Text, 1, 0, this.SkipIfNecessary(1), false);
                this.parseOffset++;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        // Token: 0x0600173D RID: 5949 RVA: 0x000B4F28 File Offset: 0x000B3128
        private void EndGroup()
        {
            RtfDestination destination = this.state.Destination;

            switch (destination)
            {
            case RtfDestination.Field:
                if (this.state.ParentDestination != RtfDestination.Field)
                {
                    this.skipFieldResult = false;
                    if (this.includePictureField)
                    {
                        PropertyValue propertyValue  = new PropertyValue(LengthUnits.Twips, this.pictureHeight);
                        PropertyValue propertyValue2 = new PropertyValue(LengthUnits.Twips, this.pictureWidth);
                        this.output.OutputImage(this.imageUrl, this.imageAltText, propertyValue2.PixelsInteger, propertyValue.PixelsInteger);
                        this.includePictureField = false;
                        this.imageUrl            = null;
                        this.imageAltText        = null;
                        return;
                    }
                    if (this.hyperLinkActive)
                    {
                        if (!this.urlCompareSink.IsMatch)
                        {
                            this.output.CloseAnchor();
                        }
                        else
                        {
                            this.output.CancelAnchor();
                        }
                        this.hyperLinkActive = false;
                    }
                }
                break;

            case RtfDestination.FieldResult:
                break;

            case RtfDestination.FieldInstruction:
                if (this.state.ParentDestination == RtfDestination.Field)
                {
                    bool         flag;
                    BufferString bufferString;
                    TextMapping  textMapping;
                    char         ucs32Literal;
                    short        num;
                    if (RtfSupport.IsHyperlinkField(ref this.scratch, out flag, out bufferString))
                    {
                        if (!flag)
                        {
                            if (this.hyperLinkActive)
                            {
                                if (!this.urlCompareSink.IsMatch)
                                {
                                    this.output.CloseAnchor();
                                }
                                else
                                {
                                    this.output.CancelAnchor();
                                }
                                this.hyperLinkActive = false;
                                this.urlCompareSink.Reset();
                            }
                            bufferString.TrimWhitespace();
                            if (bufferString.Length != 0)
                            {
                                string text = bufferString.ToString();
                                this.output.OpenAnchor(text);
                                this.hyperLinkActive = true;
                                if (this.urlCompareSink == null)
                                {
                                    this.urlCompareSink = new UrlCompareSink();
                                }
                                this.urlCompareSink.Initialize(text);
                            }
                        }
                    }
                    else if (RtfSupport.IsIncludePictureField(ref this.scratch, out bufferString))
                    {
                        bufferString.TrimWhitespace();
                        if (bufferString.Length != 0)
                        {
                            this.includePictureField = true;
                            bufferString.TrimWhitespace();
                            if (bufferString.Length != 0)
                            {
                                this.imageUrl = bufferString.ToString();
                            }
                            this.pictureWidth  = 0;
                            this.pictureHeight = 0;
                        }
                    }
                    else if (RtfSupport.IsSymbolField(ref this.scratch, out textMapping, out ucs32Literal, out num))
                    {
                        if (this.output.LineEmpty && this.lineIndent >= 120 && this.lineIndent < 7200)
                        {
                            this.output.OutputSpace(this.lineIndent / 120);
                        }
                        this.output.OutputNonspace((int)ucs32Literal, textMapping);
                        this.skipFieldResult = true;
                    }
                    this.scratch.Reset();
                    return;
                }
                break;

            default:
                switch (destination)
                {
                case RtfDestination.Picture:
                    if (this.state.ParentDestination != RtfDestination.Picture && !this.includePictureField)
                    {
                        PropertyValue propertyValue3 = new PropertyValue(LengthUnits.Twips, this.pictureHeight);
                        PropertyValue propertyValue4 = new PropertyValue(LengthUnits.Twips, this.pictureWidth);
                        this.output.OutputImage(null, null, propertyValue4.PixelsInteger, propertyValue3.PixelsInteger);
                        return;
                    }
                    break;

                case RtfDestination.PictureProperties:
                    break;

                case RtfDestination.ShapeName:
                    if (this.state.ParentDestination != RtfDestination.ShapeName)
                    {
                        BufferString bufferString2 = this.scratch.BufferString;
                        bufferString2.TrimWhitespace();
                        this.descriptionProperty = bufferString2.EqualsToLowerCaseStringIgnoreCase("wzdescription");
                        this.scratch.Reset();
                        return;
                    }
                    break;

                case RtfDestination.ShapeValue:
                    if (this.state.ParentDestination != RtfDestination.ShapeValue && this.descriptionProperty)
                    {
                        BufferString bufferString3 = this.scratch.BufferString;
                        bufferString3.TrimWhitespace();
                        if (bufferString3.Length != 0)
                        {
                            this.imageAltText = bufferString3.ToString();
                        }
                        this.scratch.Reset();
                        return;
                    }
                    break;

                default:
                    return;
                }
                break;
            }
        }