示例#1
0
        private void OutputTextElements(TextOutput output, bool treatNbspAsBreakable)
        {
            int  num = 0;
            char c   = '\0';

            for (;;)
            {
                if (this.charBufferCount == 0)
                {
                    if (!this.DecodeMore())
                    {
                        break;
                    }
                    num = this.charBufferOffet;
                    c   = this.charBuffer[num];
                }
                int num2 = num;
                if (c > ' ' && c != '\u00a0')
                {
                    do
                    {
                        c = this.charBuffer[++num];
                    }while (c > ' ' && c != '\u00a0');
                    output.OutputNonspace(this.charBuffer, num2, num - num2, this.textMapping);
                }
                else if (c == ' ')
                {
                    do
                    {
                        c = this.charBuffer[++num];
                    }while (c == ' ');
                    output.OutputSpace(num - num2);
                }
                else
                {
                    char c2 = c;
                    if (c2 != '\0')
                    {
                        switch (c2)
                        {
                        case '\t':
                        case '\n':
                        case '\v':
                        case '\f':
                        case '\r':
                            do
                            {
                                c = this.charBuffer[++num];
                            }while (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(c)) && c != ' ');
                            output.OutputSpace(1);
                            break;

                        default:
                            if (c2 != '\u00a0')
                            {
                                do
                                {
                                    c = this.charBuffer[++num];
                                }while (ParseSupport.ControlCharacter(ParseSupport.GetCharClass(c)));
                                output.OutputNonspace(this.charBuffer, num2, num - num2, this.textMapping);
                            }
                            else if (this.textMapping == TextMapping.Unicode)
                            {
                                do
                                {
                                    c = this.charBuffer[++num];
                                }while (c == '\u00a0');
                                if (treatNbspAsBreakable)
                                {
                                    output.OutputSpace(num - num2);
                                }
                                else
                                {
                                    output.OutputNbsp(num - num2);
                                }
                            }
                            else
                            {
                                do
                                {
                                    c = this.charBuffer[++num];
                                }while (c > ' ');
                                output.OutputNonspace(this.charBuffer, num2, num - num2, this.textMapping);
                            }
                            break;
                        }
                    }
                }
                this.charBufferOffet  = num;
                this.charBufferCount -= num - num2;
            }
        }
示例#2
0
        private bool MoveToNextTextElement()
        {
            if (this.charBufferCount == 0 && !this.DecodeMore())
            {
                return(false);
            }
            int num = this.charBufferOffet;

            this.elementOffset = num;
            char c = this.charBuffer[num];

            if (c > ' ' && c != '\u00a0')
            {
                this.elementTextType = RunTextType.NonSpace;
                do
                {
                    c = this.charBuffer[++num];
                    if (c <= ' ')
                    {
                        break;
                    }
                }while (c != '\u00a0');
            }
            else if (c == ' ')
            {
                this.elementTextType = RunTextType.Space;
                while (this.charBuffer[++num] == ' ')
                {
                }
            }
            else
            {
                char c2 = c;
                switch (c2)
                {
                case '\t':
                case '\n':
                case '\v':
                case '\f':
                case '\r':
                    this.elementTextType = RunTextType.UnusualWhitespace;
                    while (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(c = this.charBuffer[++num])))
                    {
                        if (c == ' ')
                        {
                            break;
                        }
                    }
                    break;

                default:
                    if (c2 != '\u00a0')
                    {
                        this.elementTextType = RunTextType.NonSpace;
                        while (ParseSupport.ControlCharacter(ParseSupport.GetCharClass(this.charBuffer[++num])))
                        {
                        }
                    }
                    else if (this.textMapping == TextMapping.Unicode)
                    {
                        this.elementTextType = RunTextType.Nbsp;
                        while (this.charBuffer[++num] == '\u00a0')
                        {
                        }
                    }
                    else
                    {
                        this.elementTextType = RunTextType.NonSpace;
                        do
                        {
                            c = this.charBuffer[++num];
                            if (c <= ' ')
                            {
                                break;
                            }
                        }while (c != '\u00a0');
                    }
                    break;
                }
            }
            this.elementLength    = num - this.elementOffset;
            this.charBufferOffet  = num;
            this.charBufferCount -= this.elementLength;
            return(true);
        }