Esempio n. 1
0
        /// <summary>
        /// Sets the tag, which is connected with the given accessible element, as a current tag for the given
        /// <see cref="TagTreePointer"/>
        /// . An exception will be thrown, if given accessible element is not connected to any tag.
        /// </summary>
        /// <param name="element">an element which has a connection with some tag.</param>
        /// <param name="tagPointer">
        ///
        /// <see cref="TagTreePointer"/>
        /// which will be moved to the tag connected to the given accessible element.
        /// </param>
        /// <returns>
        /// current
        /// <see cref="TagStructureContext"/>
        /// instance.
        /// </returns>
        public virtual iText.Kernel.Pdf.Tagutils.TagStructureContext MoveTagPointerToTag(IAccessibleElement element
                                                                                         , TagTreePointer tagPointer)
        {
            PdfStructElem connectedStructElem = connectedModelToStruct.Get(element);

            if (connectedStructElem == null)
            {
                throw new PdfException(PdfException.GivenAccessibleElementIsNotConnectedToAnyTag);
            }
            tagPointer.SetCurrentStructElem(connectedStructElem);
            return(this);
        }
Esempio n. 2
0
        private void WrapAllKidsInTag(PdfStructElem parent, PdfName wrapTagRole)
        {
            int            kidsNum    = parent.GetKids().Count;
            TagTreePointer tagPointer = new TagTreePointer(document);

            tagPointer.SetCurrentStructElem(parent).AddTag(0, wrapTagRole);
            TagTreePointer newParentOfKids = new TagTreePointer(tagPointer);

            tagPointer.MoveToParent();
            for (int i = 0; i < kidsNum; ++i)
            {
                tagPointer.RelocateKid(1, newParentOfKids);
            }
        }
        /// <summary>
        /// Moves given
        /// <see cref="TagTreePointer"/>
        /// to the waiting tag which is associated with the given object.
        /// If the passed object is not associated with any waiting tag,
        /// <see cref="TagTreePointer"/>
        /// position won't change.
        /// </summary>
        /// <param name="tagPointer">
        /// a
        /// <see cref="TagTreePointer"/>
        /// which position in the tree is to be changed to the
        /// waiting tag in case of the successful call.
        /// </param>
        /// <param name="associatedObject">
        /// an object which is associated with the waiting tag to which
        /// <see cref="TagTreePointer"/>
        /// is to be moved.
        /// </param>
        /// <returns>
        /// true if given object is actually associated with the waiting tag and
        /// <see cref="TagTreePointer"/>
        /// was moved
        /// in order to point at it.
        /// </returns>
        public virtual bool TryMovePointerToWaitingTag(TagTreePointer tagPointer, Object associatedObject)
        {
            if (associatedObject == null)
            {
                return(false);
            }
            PdfStructElem waitingStructElem = associatedObjToWaitingTag.Get(associatedObject);

            if (waitingStructElem != null)
            {
                tagPointer.SetCurrentStructElem(waitingStructElem);
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        private void RemoveOldRoot(PdfStructElem oldRoot)
        {
            TagTreePointer tagPointer = new TagTreePointer(document);

            tagPointer.SetCurrentStructElem(oldRoot).RemoveTag();
        }