Example #1
0
        /// <summary>
        /// Replaces a text (tag) by another inside the slide.
        /// </summary>
        /// <param name="tag">The tag to replace by newText, if null or empty do nothing; tag is a regex string.</param>
        /// <param name="newText">The new text to replace the tag with, if null replaced by empty string.</param>
        /// <param name="replacementType">The type of replacement to perform.</param>
        public void ReplaceTagWithHyperlink(string tag, string newText, ReplacementType replacementType, string relationshipId, string fontName = "Calibri", int fontSize = 800)
        {
            foreach (A.Paragraph p in this.slidePart.Slide.Descendants <A.Paragraph>())
            {
                switch (replacementType)
                {
                case ReplacementType.Global:
                    PptxParagraph.ReplaceTagWithHyperlink(p, tag, newText, relationshipId, fontName, fontSize);
                    break;

                case ReplacementType.NoTable:
                    var tables = p.Ancestors <A.Table>();
                    if (!tables.Any())
                    {
                        // If the paragraph has no table ancestor
                        PptxParagraph.ReplaceTagWithHyperlink(p, tag, newText, relationshipId, fontName, fontSize);
                    }
                    break;
                }
            }

            this.Save();
        }