public void TagGettingWhichNotExistsReturnsEmpty() { using (var document = new DocxDocument(Resources.WithMainContentTag)) { var tags = DocumentTag.Get(document.GetWordDocument(), "NON_EXISTING"); Assert.IsEmpty(tags); } }
public void ManyTagsGettingFromDocumentCorrect() { using (var document = new DocxDocument(Resources.WithManyTags)) { var tags = DocumentTag.Get(document.GetWordDocument(), "SUB"); Assert.NotNull(tags); Assert.AreEqual(3, tags.Count()); } }
public DocxDocumentTagContextBuilder(WordprocessingDocument document, string tagName) : base(document) { _documentTags = DocumentTag.Get(document, tagName); foreach (DocumentTag documentTag in _documentTags) { ClearBetweenElements(documentTag.Opening, documentTag.Closing); } SaveDocument(); }
///<summary> /// Sets visibility for tag specified by <paramref name="tagName"/> ///</summary> ///<param name="tagName">Tag name</param> ///<param name="isVisible">Shows tag if set to true, otherwise hides it</param> public void SetTagVisibility(string tagName, bool isVisible) { var documentTags = DocumentTag.Get(_wordDocument, tagName); foreach (var documentTag in documentTags) { var paragraph = documentTag.Opening.NextSibling(); while (paragraph as Paragraph != documentTag.Closing) { SetVisibilityInParagraphProperty(paragraph, isVisible); SetVisibilityInParagraphRuns(paragraph, isVisible); paragraph = paragraph.NextSibling(); } } }