/// <summary>
        /// Returns the previous iterator to a leaf in the document object tree pointing.
        /// </summary>
        /// <returns>The previous leaf, null if none exists.</returns>
        internal ParagraphIterator GetPreviousLeaf()
        {
            //Move up to appropriate parent element
            ParagraphIterator parIterator = GetParentIterator();

            if (parIterator == null)
            {
                return(null);
            }

            int elementIndex         = LastIndex;
            ParagraphElements parEls = (ParagraphElements)parIterator._current;

            while (elementIndex == 0)
            {
                elementIndex = parIterator.LastIndex;
                parIterator  = parIterator.GetParentIterator();
                if (parIterator == null)
                {
                    break;
                }

                parEls = (ParagraphElements)parIterator._current;
            }
            if (parIterator == null)
            {
                return(null);
            }

            int newIndex = elementIndex - 1;

            if (newIndex < 0)
            {
                return(null);
            }

            List <int> indices = new List <int>(parIterator._positionIndices);//(Array_List)parIterator.positionIndices.Clone();

            indices.Add(newIndex);

            DocumentObject    obj      = GetNodeObject(parEls[newIndex]);
            ParagraphIterator iterator = new ParagraphIterator(_rootNode, obj, indices);

            return(iterator.SeekLastLeaf());
        }
예제 #2
0
        /// <summary>
        /// Returns the next iterator in the tree pointing to a leaf.
        /// </summary>
        /// <remarks>This function is intended to receive the renderable objects of a paragraph.
        /// Thus, empty ParagraphElement objects (which are collections) don't count as leafs.</remarks>
        internal ParagraphIterator GetNextLeaf()
        {
            //Move up to appropriate parent element
            ParagraphIterator parIterator = GetParentIterator();

            if (parIterator == null)
            {
                return(null);
            }

            int elementIndex         = this.LastIndex;
            ParagraphElements parEls = (ParagraphElements)parIterator.current;

            while (elementIndex == parEls.Count - 1)
            {
                elementIndex = parIterator.LastIndex;
                parIterator  = parIterator.GetParentIterator();
                if (parIterator == null)
                {
                    break;
                }

                parEls = (ParagraphElements)parIterator.current;
            }
            if (parIterator == null)
            {
                return(null);
            }
            int newIndex = elementIndex + 1;

            if (newIndex >= parEls.Count)
            {
                return(null);
            }

            ArrayList indices = (ArrayList)parIterator.positionIndices.Clone();

            indices.Add(newIndex);
            DocumentObject    obj      = GetNodeObject(parEls[newIndex]);
            ParagraphIterator iterator = new ParagraphIterator(this.rootNode, obj, indices);

            return(iterator.SeekFirstLeaf());
        }