Beispiel #1
0
        private void ProcessText()
        {
            if (!lineStarted)
            {
                StartParagraphOrLine();
            }

            foreach (var run in token.Runs)
            {
                if (run.IsTextRun)
                {
                    if (run.IsAnyWhitespace)
                    {
                        output.OutputSpace(1);
                    }
                    else if (run.TextType == RunTextType.Nbsp)
                    {
                        if (treatNbspAsBreakable)
                        {
                            output.OutputSpace(run.Length);
                        }
                        else
                        {
                            output.OutputNbsp(run.Length);
                        }
                    }
                    else
                    {
                        if (run.IsLiteral)
                        {
                            output.OutputNonspace(run.Literal, textMapping);
                        }
                        else
                        {
                            output.OutputNonspace(run.RawBuffer, run.RawOffset, run.RawLength, textMapping);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 private void ProcessText()
 {
     if (!lineStarted)
     {
         StartParagraphOrLine();
     }
     Token.RunEnumerator enumerator = token.Runs.GetEnumerator();
     while (enumerator.MoveNext())
     {
         TokenRun current = enumerator.Current;
         if (current.IsTextRun)
         {
             if (current.IsAnyWhitespace)
             {
                 output.OutputSpace(1);
             }
             else if (current.TextType == RunTextType.Nbsp)
             {
                 if (treatNbspAsBreakable)
                 {
                     output.OutputSpace(current.Length);
                 }
                 else
                 {
                     output.OutputNbsp(current.Length);
                 }
             }
             else if (current.IsLiteral)
             {
                 output.OutputNonspace(current.Literal, textMapping);
             }
             else
             {
                 output.OutputNonspace(current.RawBuffer, current.RawOffset, current.RawLength, textMapping);
             }
         }
     }
 }
Beispiel #3
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;
            }
        }