public PlaceholderCreatorVisitor(MyCustomBatchTaskSettings settings) { this.settings = settings; // The itemfactory is how we create all the IAbstractMarkupData this.itemFactory = DefaultDocumentItemFactory.CreateInstance(); }
public void PlaceholderTagIsRemovedElement() { // Arrange var segment = utility.CreateSegment(); var phTag = Substitute.For <IPlaceholderTag>(); phTag.Parent = segment; phTag.TagProperties.Returns(Substitute.For <IAbstractTagProperties>()); phTag.TagProperties.TagContent = "<html>"; var settings = utility.CreateSettings(); settings.Placeholders = new List <Placeholder>() { new Placeholder() { Content = "<html>", IsTagPair = true } }; var factory = DefaultDocumentItemFactory.CreateInstance(); var reporter = Substitute.For <ICleanUpMessageReporter>(); TargetCleanUpHandler handler = new TargetCleanUpHandler(settings, factory, reporter); // Act handler.VisitPlaceholderTag(phTag); handler.VisitSegment(segment); // Assert phTag.Received().RemoveFromParent(); segment.Received().Insert(Arg.Any <int>(), Arg.Is <IText>(txt => txt.Properties.Text == "<html>")); }
protected override void Execute() { //get the active segment pair from the current active document in the editor var activeSegmentPair = Controller.ActiveDocument.ActiveSegmentPair; if (activeSegmentPair == null) { return; } //Create an instance of the document item factory that is needed to create segment elements IDocumentItemFactory documentItemFactory = DefaultDocumentItemFactory.CreateInstance(); ITextProperties firstTextProp = documentItemFactory .PropertiesFactory .CreateTextProperties(OpusCatProviderLanguageDirection.CurrentTranslation.ToPlain()); IText firstText = documentItemFactory.CreateText(firstTextProp); activeSegmentPair.Target.Add(firstText); Controller.ActiveDocument.UpdateSegmentPair(activeSegmentPair); }
public SegmentBuilder() { ItemFactory = DefaultDocumentItemFactory.CreateInstance(); PropertiesFactory = DefaultPropertiesFactory.CreateInstance(); FormattingFactory = PropertiesFactory.FormattingItemFactory; }