iTextSharp.text.pdf.BidiOrder.RunAlgorithm C# (CSharp) Метод

RunAlgorithm() приватный Метод

private RunAlgorithm ( ) : void
Результат void
        private void RunAlgorithm()
        {
            textLength = initialTypes.Length;

            // Initialize output types.
            // Result types initialized to input types.
            resultTypes = (sbyte[])initialTypes.Clone();

            // 1) determining the paragraph level
            // Rule P1 is the requirement for entering this algorithm.
            // Rules P2, P3.
            // If no externally supplied paragraph embedding level, use default.
            if (paragraphEmbeddingLevel == -1) {
                DetermineParagraphEmbeddingLevel();
            }

            // Initialize result levels to paragraph embedding level.
            resultLevels = new sbyte[textLength];
            SetLevels(0, textLength, paragraphEmbeddingLevel);

            // 2) Explicit levels and directions
            // Rules X1-X8.
            DetermineExplicitEmbeddingLevels();

            // Rule X9.
            textLength = RemoveExplicitCodes();

            // Rule X10.
            // Run remainder of algorithm one level run at a time
            sbyte prevLevel = paragraphEmbeddingLevel;
            int start = 0;
            while (start < textLength) {
                sbyte level = resultLevels[start];
                sbyte prevType = TypeForLevel(Math.Max(prevLevel, level));

                int limit = start + 1;
                while (limit < textLength && resultLevels[limit] == level) {
                    ++limit;
                }

                sbyte succLevel = limit < textLength ? resultLevels[limit] : paragraphEmbeddingLevel;
                sbyte succType = TypeForLevel(Math.Max(succLevel, level));

                // 3) resolving weak types
                // Rules W1-W7.
                ResolveWeakTypes(start, limit, level, prevType, succType);

                // 4) resolving neutral types
                // Rules N1-N3.
                ResolveNeutralTypes(start, limit, level, prevType, succType);

                // 5) resolving implicit embedding levels
                // Rules I1, I2.
                ResolveImplicitLevels(start, limit, level, prevType, succType);

                prevLevel = level;
                start = limit;
            }

            // Reinsert explicit codes and assign appropriate levels to 'hide' them.
            // This is for convenience, so the resulting level array maps 1-1
            // with the initial array.
            // See the implementation suggestions section of TR#9 for guidelines on
            // how to implement the algorithm without removing and reinserting the codes.
            textLength = ReinsertExplicitCodes(textLength);
        }