Пример #1
0
 protected internal TagReference(PdfStructElem referencedTag, TagTreePointer tagPointer, int insertIndex)
 {
     this.role          = referencedTag.GetRole();
     this.referencedTag = referencedTag;
     this.tagPointer    = tagPointer;
     this.insertIndex   = insertIndex;
 }
Пример #2
0
 /// <summary>
 /// All tagging logic performed by iText automatically (along with addition of content, annotations etc)
 /// uses
 /// <see cref="TagTreePointer"/>
 /// returned by this method to manipulate the tag structure.
 /// </summary>
 /// <remarks>
 /// All tagging logic performed by iText automatically (along with addition of content, annotations etc)
 /// uses
 /// <see cref="TagTreePointer"/>
 /// returned by this method to manipulate the tag structure.
 /// Typically it points at the root tag. This pointer also could be used to tweak auto tagging process
 /// (e.g. move this pointer to the Section tag, which would result in placing all automatically tagged content
 /// under Section tag).
 /// </remarks>
 /// <returns>
 /// the
 /// <c>TagTreePointer</c>
 /// which is used for all automatic tagging of the document.
 /// </returns>
 public virtual TagTreePointer GetAutoTaggingPointer()
 {
     if (autoTaggingPointer == null)
     {
         autoTaggingPointer = new TagTreePointer(document);
     }
     return(autoTaggingPointer);
 }
Пример #3
0
 /// <summary>
 /// Assigns waiting state to the tag at which given
 /// <see cref="TagTreePointer"/>
 /// points, associating it with the given
 /// <see cref="System.Object"/>
 /// . If current tag of the given
 /// <see cref="TagTreePointer"/>
 /// is already waiting, then after this method call
 /// it's associated object will change to the one passed as the argument and the old one will not longer be
 /// an associated object.
 /// </summary>
 /// <param name="pointerToTag">
 /// a
 /// <see cref="TagTreePointer"/>
 /// pointing at a tag which is desired to be marked as waiting.
 /// </param>
 /// <param name="associatedObj">an object that is to be associated with the waiting tag. A null value is forbidden.
 ///     </param>
 /// <returns>
 /// the previous associated object with the tag if it has already had waiting state,
 /// or null if it was not waiting tag.
 /// </returns>
 public virtual Object AssignWaitingState(TagTreePointer pointerToTag, Object associatedObj)
 {
     if (associatedObj == null)
     {
         throw new ArgumentException("Passed associated object can not be null.");
     }
     return(SaveAssociatedObjectForWaitingTag(associatedObj, pointerToTag.GetCurrentStructElem()));
 }
Пример #4
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);
            }
        }
Пример #5
0
        /// <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);
        }
Пример #6
0
        private void WrapAllKidsInTag(PdfStructElem parent, PdfName wrapTagRole, PdfNamespace wrapTagNs)
        {
            int            kidsNum    = parent.GetKids().Count;
            TagTreePointer tagPointer = new TagTreePointer(parent, document);

            tagPointer.AddTag(0, wrapTagRole.GetValue());
            if (context.TargetTagStructureVersionIs2())
            {
                tagPointer.GetProperties().SetNamespace(wrapTagNs);
            }
            TagTreePointer newParentOfKids = new TagTreePointer(tagPointer);

            tagPointer.MoveToParent();
            for (int i = 0; i < kidsNum; ++i)
            {
                tagPointer.RelocateKid(1, newParentOfKids);
            }
        }
Пример #7
0
 /// <summary>
 /// Gets
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfStructElem"/>
 /// at which
 /// <see cref="TagTreePointer"/>
 /// points.
 /// </summary>
 /// <remarks>
 /// Gets
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfStructElem"/>
 /// at which
 /// <see cref="TagTreePointer"/>
 /// points.
 /// <para />
 /// NOTE: Be aware that
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfStructElem"/>
 /// is a low level class, use it carefully,
 /// especially in conjunction with high level
 /// <see cref="TagTreePointer"/>
 /// and
 /// <see cref="TagStructureContext"/>
 /// classes.
 /// </remarks>
 /// <param name="pointer">
 /// a
 /// <see cref="TagTreePointer"/>
 /// which points at desired
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfStructElem"/>.
 /// </param>
 /// <returns>
 /// a
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfStructElem"/>
 /// at which given
 /// <see cref="TagTreePointer"/>
 /// points.
 /// </returns>
 public virtual PdfStructElem GetPointerStructElem(TagTreePointer pointer)
 {
     return(pointer.GetCurrentStructElem());
 }
Пример #8
0
 internal BackedAccessibilityProperties(TagTreePointer pointerToBackingElem)
 {
     this.pointerToBackingElem = new TagTreePointer(pointerToBackingElem);
 }
Пример #9
0
 public override AccessibilityProperties AddRef(TagTreePointer treePointer)
 {
     GetBackingElem().AddRef(treePointer.GetCurrentStructElem());
     return(this);
 }
Пример #10
0
        private void RemoveOldRoot(PdfStructElem oldRoot)
        {
            TagTreePointer tagPointer = new TagTreePointer(document);

            tagPointer.SetCurrentStructElem(oldRoot).RemoveTag();
        }
Пример #11
0
 public virtual AccessibilityProperties AddRef(TagTreePointer treePointer)
 {
     return(this);
 }
 public override AccessibilityProperties AddRef(TagTreePointer treePointer)
 {
     refs.Add(new TagTreePointer(treePointer));
     return(this);
 }
Пример #13
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);
        }