// loops through all sub items of the container (IMarkupDataContainer)
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     foreach (var item in container)
     {
         item.AcceptVisitor(this);
     }
 }
Example #2
0
 // Iterates all sub items of segment container (IMarkupDataContainer)
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     foreach (var item in container)
     {
         item.AcceptVisitor(this);
     }
 }
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     foreach (var segment in container)
     {
         segment.AcceptVisitor(this);
     }
 }
        private IAbstractMarkupData GetElement(string tagId, IAbstractMarkupDataContainer originalTargetSegment,
                                               IAbstractMarkupDataContainer sourceSegment, Element element)
        {
            var extractor = new ElementExtractor();

            extractor.GetTag(tagId, originalTargetSegment, element);
            if (extractor.FoundElement != null)
            {
                return((IAbstractMarkupData)extractor.FoundElement.Clone());
            }

            extractor.GetTag(tagId, sourceSegment, element);
            if (extractor.FoundElement != null)
            {
                return((IAbstractMarkupData)extractor.FoundElement.Clone());
            }

            //switch (element)
            //{
            //	case ElementTagPair tagPair:
            //	case ElementPlaceholder placeholder:
            //		throw new Exception("Tags in segment ID " + originalTargetSegment.Properties.Id.Id + " are corrupted!");
            //	case ElementLocked locked:
            //		throw new Exception("Locked contents in segment ID " + originalTargetSegment.Properties.Id.Id + " are corrupted!");
            //}

            //throw new Exception("Problem when reading segment #" + originalTargetSegment.Properties.Id.Id);

            return(null);
        }
        private void DeleteNode(IAbstractMarkupData node)
        {
            //Remove node from tree
            int index = node.IndexInParent;
            IAbstractMarkupDataContainer parent = node.Parent;

            node.RemoveFromParent();

            //If this is a deleted revision marker then no more processing is required
            IRevisionMarker revisionMarker = node as IRevisionMarker;

            if (revisionMarker != null)
            {
                if (revisionMarker.Properties.RevisionType == revisionTypeToIgnore)
                {
                    return;
                }
            }

            //If a comment or inserted revision then copy children to parent at the index location of the original node we have removed
            IAbstractMarkupDataContainer container = node as IAbstractMarkupDataContainer;

            if (container.Count() > 0)
            {
                container.MoveItemsTo(parent, index, 0, container.Count());
            }
        }
        public GeneratorEmbeddedContentVisitor(IDocumentItemFactory itemFactory)
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);
            _parentParagraph = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
        }
        public GeneratorEmbeddedContentVisitor(IDocumentItemFactory itemFactory)
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);

            _parentParagraph  = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
        }
Example #8
0
 public IAbstractMarkupData GetTag(string elementID, IAbstractMarkupDataContainer objectToSearch, Token.TokenType tokenType)
 {
     ElementIdToSearch       = elementID;
     ElementTypeToSearch     = tokenType;
     FoundElement            = null;
     _currentLockedContentId = 0;
     VisitChildren(objectToSearch);
     return(FoundElement);
 }
        public ProcessorEmbeddedContentVisitor(IDocumentItemFactory itemFactory, IContentEvaluator evaluator, List<MatchRule> matchRules )
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);
            _parentParagraph = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
            _contentEvaluator = evaluator;
            _matchRules = matchRules;
        }
 public IEmbeddedContentVisitor CreateVisitor(IDocumentItemFactory itemFactory,
                                              IPropertiesFactory propertiesFactory, ITextProcessor textProcessor)
 {
     _itemFactory       = itemFactory;
     _propertiesFactory = propertiesFactory;
     _textProcessor     = textProcessor;
     GeneratedParagraph = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked).Source;
     _currentContainer  = GeneratedParagraph;
     return(this);
 }
        public void VisitCommentMarker(ICommentMarker commentMarker)
        {
            var newComment = _itemFactory.CreateCommentMarker(commentMarker.Comments);
            _parentParagraph.Add(newComment);
            _currentContainer = newComment;

            VisitChildElements(commentMarker);

            _currentContainer = newComment.Parent;
        }
Example #12
0
        public static void UnlockContent(ISegment targetSegment, IDocumentItemFactory itemFactory, IPropertiesFactory propFactory)
        {
            Location textLocation    = new Location(targetSegment, true);
            bool     isLContentFound = false;

            do
            {
                ILockedContent content = textLocation.ItemAtLocation as ILockedContent;
                if (content != null)
                {
                    isLContentFound = true;

                    int            indexInParent  = content.IndexInParent;
                    ILockedContent origLContent   = (ILockedContent)content.Clone();
                    Location       lockedLocation = new Location(origLContent.Content, true);
                    Location       origLocation   = new Location(CloneContainer(content.Parent), true);

                    // create new parent subitems
                    IAbstractMarkupDataContainer newParent = content.Parent;
                    newParent.Clear();

                    int index = 0;
                    do // loop by parent location
                    {
                        // take from locked selection
                        if (index == indexInParent)
                        {
                            do // loop by locked content
                            {
                                if (lockedLocation.ItemAtLocation != null)
                                {
                                    newParent.Add((IAbstractMarkupData)lockedLocation.ItemAtLocation.Clone());
                                }
                            }while (lockedLocation.MoveNextSibling());
                            index++;
                        }
                        // take original items
                        else
                        {
                            if (origLocation.ItemAtLocation != null)
                            {
                                newParent.Add((IAbstractMarkupData)origLocation.ItemAtLocation.Clone());
                            }
                            index++;
                        }
                    }while (origLocation.MoveNextSibling());
                }
            }while (textLocation.MoveNext());

            if (isLContentFound)
            {
                // merge IText objects
                MergeMarkupData(targetSegment, itemFactory, propFactory);
            }
        }
Example #13
0
        public void VisitTagPair(ITagPair tagPair)
        {
            var newTagPair = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);

            _currentContainer.Add(newTagPair);
            _currentContainer = newTagPair;

            VisitChildElements(tagPair);

            _currentContainer = newTagPair.Parent;
        }
        public void VisitRevisionMarker(IRevisionMarker revisionMarker)
        {
            var newRevisionMarker = CreateRevisionOrFeedback(revisionMarker.Properties);

            _currentContainer.Add(newRevisionMarker);
            _currentContainer = newRevisionMarker;

            VisitChildElements(revisionMarker);

            _currentContainer = newRevisionMarker.Parent;
        }
Example #15
0
        public void VisitSegment(ISegment segment)
        {
            var newSegment = _itemFactory.CreateSegment(segment.Properties);

            _currentContainer.Add(newSegment);
            _currentContainer = newSegment;

            VisitChildElements(segment);

            _currentContainer = newSegment.Parent;
        }
Example #16
0
        public void VisitRevisionMarker(IRevisionMarker revisionMarker)
        {
            var newRevisionMarker = CreateRevisionOrFeedback(revisionMarker.Properties);

            _currentContainer.Add(newRevisionMarker);
            _currentContainer = newRevisionMarker;

            VisitChildElements(revisionMarker);

            _currentContainer = newRevisionMarker.Parent;
        }
        public void VisitSegment(ISegment segment)
        {
            var newSegment = _itemFactory.CreateSegment(segment.Properties);

            _currentContainer.Add(newSegment);
            _currentContainer = newSegment;

            VisitChildElements(segment);

            _currentContainer = newSegment.Parent;
        }
Example #18
0
        public void VisitCommentMarker(ICommentMarker commentMarker)
        {
            var newComment = _itemFactory.CreateCommentMarker(commentMarker.Comments);

            _parentParagraph.Add(newComment);
            _currentContainer = newComment;

            VisitChildElements(commentMarker);

            _currentContainer = newComment.Parent;
        }
Example #19
0
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     if (container == null)
     {
         return;
     }
     foreach (var item in container)
     {
         item.AcceptVisitor(this);
     }
 }
Example #20
0
        public IAbstractMarkupData GetTag(string elementId, IAbstractMarkupDataContainer objectToSearch, Element element)
        {
            FoundElement = null;

            _elementIdToSearch      = elementId;
            _element                = element;
            _currentLockedContentId = 0;
            VisitChildren(objectToSearch);

            return(FoundElement);
        }
Example #21
0
        /// <summary>
        /// Insert item to the proper container
        /// </summary>
        /// <param name="vector"></param>
        /// <param name="segment"></param>
        /// <param name="abstractItem"></param>
        private void InsertItemOnLocation(IEnumerable <int> vector, ref ISegment segment, IAbstractMarkupData abstractItem)
        {
            IAbstractMarkupDataContainer currentContainer = segment;

            foreach (var index in vector)
            {
                currentContainer = (IAbstractMarkupDataContainer)currentContainer[index];
            }

            currentContainer.Add(abstractItem);
        }
Example #22
0
        private void Log(IAbstractMarkupData data, string tagContent)
        {
            IAbstractMarkupDataContainer parent = data.Parent;
            while (!(parent is ISegment))
            {
                parent = ((IAbstractMarkupData)parent).Parent;
            }

            var segment = (ISegment)parent;
            reportGenerator.AddTagItem(segment.Properties.Id.Id, tagContent);
        }
Example #23
0
        public ProcessorEmbeddedContentVisitor(IDocumentItemFactory itemFactory, IContentEvaluator evaluator, List <MatchRule> matchRules)
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);

            _parentParagraph  = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
            _contentEvaluator = evaluator;
            _matchRules       = matchRules;
        }
        public void VisitRevisionMarker(IRevisionMarker revisionMarker)
        {
            var revisionMarker2 = CreateRevisionOrFeedback(revisionMarker.Properties);

            _currentContainer.Add(revisionMarker2);
            _currentContainer = revisionMarker2;
            foreach (var current in revisionMarker)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = revisionMarker2.Parent;
        }
        public void VisitCommentMarker(ICommentMarker commentMarker)
        {
            var commentMarker2 = _itemFactory.CreateCommentMarker(commentMarker.Comments);

            _currentContainer.Add(commentMarker2);
            _currentContainer = commentMarker2;
            foreach (var current in commentMarker)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = commentMarker2.Parent;
        }
        public void VisitSegment(ISegment segment)
        {
            var segment2 = _itemFactory.CreateSegment(segment.Properties);

            _currentContainer.Add(segment2);
            _currentContainer = segment2;
            foreach (var current in segment)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = segment2.Parent;
        }
        public void VisitTagPair(ITagPair tagPair)
        {
            var tagPair2 = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);

            _currentContainer.Add(tagPair2);
            _currentContainer = tagPair2;
            foreach (var current in tagPair)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = tagPair2.Parent;
        }
        public void VisitOtherMarker(IOtherMarker marker)
        {
            var otherMarker = _itemFactory.CreateOtherMarker();
            otherMarker.Id = marker.Id;
            otherMarker.MarkerType = marker.MarkerType;

            _currentContainer.Add(otherMarker);
            _currentContainer = otherMarker;

            VisitChildElements(marker);

            _currentContainer = otherMarker.Parent;
        }
Example #29
0
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     try
     {
         foreach (var item in container)
         {
             item.AcceptVisitor(this);
         }
     }
     catch (Exception ex)
     {
         Log.Logger.Error($"{"VisitChildren method: "} {ex.Message}\n {ex.StackTrace}");
     }
 }
        public void VisitOtherMarker(IOtherMarker marker)
        {
            var otherMarker = _itemFactory.CreateOtherMarker();

            otherMarker.Id         = marker.Id;
            otherMarker.MarkerType = marker.MarkerType;
            _currentContainer.Add(otherMarker);
            _currentContainer = otherMarker;
            foreach (var current in marker)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = otherMarker.Parent;
        }
Example #31
0
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     try
     {
         foreach (var item in container)
         {
             item.AcceptVisitor(this);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Example #32
0
        public void VisitOtherMarker(IOtherMarker marker)
        {
            var otherMarker = _itemFactory.CreateOtherMarker();

            otherMarker.Id         = marker.Id;
            otherMarker.MarkerType = marker.MarkerType;

            _currentContainer.Add(otherMarker);
            _currentContainer = otherMarker;

            VisitChildElements(marker);

            _currentContainer = otherMarker.Parent;
        }
Example #33
0
        public static IAbstractMarkupDataContainer AddSegment(this IAbstractMarkupDataContainer paragraph, ISegment segment, SegmentBuilder builder)
        {
            if (segment != null)
            {
                var newSegment = builder.CreateSegment(segment.Properties.Clone() as ISegmentPairProperties);
                foreach (var item in segment)
                {
                    newSegment.Add(item?.Clone() as IAbstractMarkupData);
                }

                paragraph.Add(newSegment);
            }

            return(paragraph);
        }
Example #34
0
 private void AddOpenTagContainer(ContentMatch match)
 {
     if (match.MatchRule.IsContentTranslatable)
     {
         ITagPair tagPair = CreateTagPair(match);
         _currentContainer.Add(tagPair);
         _currentContainer = tagPair;
     }
     else
     {
         //treat non-translatable content as locked
         ILockedContent lockedContent = CreateLockedContent();
         _currentContainer.Add(lockedContent);
         _currentContainer = lockedContent.Content;
     }
 }
Example #35
0
        private void ReplaceTagPair(string updatedText, ITagPair tagPair, IAbstractMarkupDataContainer parent, ConversionItem conversionItem)
        {
            var entitizer  = new HtmlEntitizer();
            var markupData = CreateMarkupData(updatedText, new HtmlTagTable(entitizer.Entitize(updatedText, conversionItem.Search.Text)), entitizer, conversionItem);

            var index = tagPair.IndexInParent;

            if (markupData.Count > 0)
            {
                foreach (var item in markupData)
                {
                    parent.Insert(index++, item);
                }

                tagPair.RemoveFromParent();
            }
        }
Example #36
0
        private static IAbstractMarkupDataContainer CloneContainer(IAbstractMarkupDataContainer container)
        {
            var segContainer = container as ISegment;

            if (segContainer != null)
            {
                return((IAbstractMarkupDataContainer)segContainer.Clone());
            }

            var txtContainer = container as IText;

            if (txtContainer != null)
            {
                return((IAbstractMarkupDataContainer)txtContainer.Clone());
            }

            var tagContainer = container as ITagPair;

            if (tagContainer != null)
            {
                return((IAbstractMarkupDataContainer)tagContainer.Clone());
            }

            var commContainer = container as ICommentMarker;

            if (commContainer != null)
            {
                return((IAbstractMarkupDataContainer)commContainer.Clone());
            }

            var revContainer = container as IRevisionMarker;

            if (revContainer != null)
            {
                return((IAbstractMarkupDataContainer)revContainer.Clone());
            }

            var locContainer = container as ILocationMarker;

            if (locContainer != null)
            {
                return((IAbstractMarkupDataContainer)locContainer.Clone());
            }

            return(null);
        }
Example #37
0
 private void VisitChildren(IAbstractMarkupDataContainer container)
 {
     if (container == null)
     {
         return;
     }
     if (_detailLevel == DetailLevel.Raw)
     {
         _textBuilder.Append(container);
     }
     else
     {
         foreach (var item in container)
         {
             item.AcceptVisitor(this);
         }
     }
 }
 private void AddOpenTagContainer(ContentMatch match)
 {
     if (match.MatchRule.IsContentTranslatable)
     {
         ITagPair tagPair = CreateTagPair(match);
         _currentContainer.Add(tagPair);
         _currentContainer = tagPair;
     }
     else
     {
         //treat non-translatable content as locked
         ILockedContent lockedContent = CreateLockedContent();
         _currentContainer.Add(lockedContent);
         _currentContainer = lockedContent.Content;
     }
 }
        public void VisitTagPair(ITagPair tagPair)
        {
            var newTagPair = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);
            TagToOriginalText(tagPair.StartTagProperties);

            _currentContainer.Add(newTagPair);
            _currentContainer = newTagPair;
            VisitChildElements(tagPair);

            TagToOriginalText(tagPair.EndTagProperties);
            _currentContainer = newTagPair.Parent;
        }
        private void AddCloseTagContainer()
        {
            var currentTagPair = _currentContainer as ITagPair;

            if (currentTagPair != null)
            {
                _currentContainer = currentTagPair.Parent;
            }
            else
            {
                //exit locked content
                var lockedContainer = _currentContainer as ILockedContainer;

                if (lockedContainer != null)
                {
                    _currentContainer = lockedContainer.LockedContent.Parent;
                }
                else
                {
                    Debug.Assert(false, "Tags or locked content are out of line!");
                }
            }
        }