예제 #1
0
파일: Bidi.cs 프로젝트: borkaborka/gmit
      // 3.3.1.P1 - Split the text into separate paragraphs.
      // A paragraph separator is kept with the previous paragraph.
      // Within each paragraph, apply all the other rules of this algorithm.
      private static Paragraph[] SplitStringToParagraphs(string logicalString) {
         List<Paragraph> ret = new List<Paragraph>();
         int start = 0;
         int i;
         byte embedingLevel = 255;

         for (i = 0; i < logicalString.Length; ++i) {
            char c = logicalString[i];
            BidiCharacterType cType = UnicodeCharacterDataResolver.GetBidiCharacterType(c);
            if (cType == BidiCharacterType.B) {
               Paragraph p = new Paragraph(logicalString.Substring(start, i - start));
               p.ParagraphSeparator = c;
               if (embedingLevel == 255)
                  embedingLevel = p.EmbeddingLevel;
               else {
                  p.EmbeddingLevel = embedingLevel;
                  p.RecalculateCharactersEmbeddingLevels();
               }
               ret.Add(p);
               start = i + 1;
            }
         }
         if (i - start + 1 > 0) // string ended without a paragraph separator
			{
            ret.Add(new Paragraph(logicalString.Substring(start)));
         }
         return ret.ToArray();
      }