private void RemoveTagUnavailableInPriorToOneDotFivePdf(TaggingHintKey taggingHintKey, LayoutTaggingHelper
                                                                taggingHelper)
        {
            taggingHelper.ReplaceKidHint(taggingHintKey, taggingHelper.GetAccessibleKidsHint(taggingHintKey));
            PdfDocument        pdfDocument        = taggingHelper.GetPdfDocument();
            WaitingTagsManager waitingTagsManager = pdfDocument.GetTagStructureContext().GetWaitingTagsManager();
            TagTreePointer     tagPointer         = new TagTreePointer(pdfDocument);

            if (waitingTagsManager.TryMovePointerToWaitingTag(tagPointer, taggingHintKey))
            {
                waitingTagsManager.RemoveWaitingState(taggingHintKey);
                tagPointer.RemoveTag();
            }
            if (finishForbidden.Remove(taggingHintKey))
            {
                taggingHintKey.SetFinished();
            }
        }
Exemple #2
0
        public virtual bool CreateTag(IRenderer renderer, TagTreePointer tagPointer)
        {
            TaggingHintKey hintKey = GetHintKey(renderer);
            bool           noHint  = hintKey == null;

            if (noHint)
            {
                hintKey = GetOrCreateHintKey(renderer, false);
            }
            bool created = CreateTag(hintKey, tagPointer);

            if (noHint)
            {
                hintKey.SetFinished();
                context.GetWaitingTagsManager().RemoveWaitingState(hintKey);
            }
            return(created);
        }
Exemple #3
0
        private static TaggingHintKey GetOrCreateHintKey(IPropertyContainer hintOwner, bool setProperty)
        {
            TaggingHintKey hintKey = hintOwner.GetProperty <TaggingHintKey>(Property.TAGGING_HINT_KEY);

            if (hintKey == null)
            {
                IAccessibleElement elem = null;
                if (hintOwner is IAccessibleElement)
                {
                    elem = (IAccessibleElement)hintOwner;
                }
                else
                {
                    if (hintOwner is IRenderer && ((IRenderer)hintOwner).GetModelElement() is IAccessibleElement)
                    {
                        elem = (IAccessibleElement)((IRenderer)hintOwner).GetModelElement();
                    }
                }
                hintKey = new TaggingHintKey(elem, hintOwner is IElement);
                if (elem != null && StandardRoles.ARTIFACT.Equals(elem.GetAccessibilityProperties().GetRole()))
                {
                    hintKey.SetArtifact();
                    hintKey.SetFinished();
                }
                if (setProperty)
                {
                    if (elem is ILargeElement && !((ILargeElement)elem).IsComplete())
                    {
                        ((ILargeElement)elem).SetProperty(Property.TAGGING_HINT_KEY, hintKey);
                    }
                    else
                    {
                        hintOwner.SetProperty(Property.TAGGING_HINT_KEY, hintKey);
                    }
                }
            }
            return(hintKey);
        }
Exemple #4
0
        public virtual void FinishTaggingHint(IPropertyContainer hintOwner)
        {
            TaggingHintKey rendererKey = GetHintKey(hintOwner);

            // artifact is always finished
            if (rendererKey == null || rendererKey.IsFinished())
            {
                return;
            }
            if (rendererKey.IsElementBasedFinishingOnly() && !(hintOwner is IElement))
            {
                // avoid auto finishing of hints created based on IElements
                return;
            }
            if (!IsNonAccessibleHint(rendererKey))
            {
                IAccessibleElement modelElement = rendererKey.GetAccessibleElement();
                String             role         = modelElement.GetAccessibilityProperties().GetRole();
                if (rendererKey.GetOverriddenRole() != null)
                {
                    role = rendererKey.GetOverriddenRole();
                }
                IList <ITaggingRule> rules = taggingRules.Get(role);
                bool ruleResult            = true;
                if (rules != null)
                {
                    foreach (ITaggingRule rule in rules)
                    {
                        ruleResult = ruleResult && rule.OnTagFinish(this, rendererKey);
                    }
                }
                if (!ruleResult)
                {
                    return;
                }
            }
            rendererKey.SetFinished();
        }
Exemple #5
0
        public virtual void MarkArtifactHint(TaggingHintKey hintKey)
        {
            hintKey.SetArtifact();
            hintKey.SetFinished();
            TagTreePointer existingArtifactTag = new TagTreePointer(document);

            if (context.GetWaitingTagsManager().TryMovePointerToWaitingTag(existingArtifactTag, hintKey))
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Tagging.LayoutTaggingHelper));
                logger.Error(iText.IO.LogMessageConstant.ALREADY_TAGGED_HINT_MARKED_ARTIFACT);
                context.GetWaitingTagsManager().RemoveWaitingState(hintKey);
                if (immediateFlush)
                {
                    existingArtifactTag.FlushParentsIfAllKidsFlushed();
                }
            }
            IList <TaggingHintKey> kidsHint = GetKidsHint(hintKey);

            foreach (TaggingHintKey kidKey in kidsHint)
            {
                MarkArtifactHint(kidKey);
            }
            RemoveParentHint(hintKey);
        }