Exemple #1
0
        public static int CreateHyperLinkMap(PPTXSlide SlideContent, SlidePart slidePart1, Dictionary <string, string> HyperLinkIDMap)
        {
            int lastIndex = 2;

            var textRuns = SlideContent.TextAreas
                           .SelectMany(_textArea => _textArea.Texts.SelectMany(_text => _text.Texts))
                           .Where(_textRun => _textRun.Link.IsEnable)
                           .Select((_textRun, _Index) => new { Link = _textRun.Link, Index = _Index });

            foreach (var linkItem in textRuns)
            {
                if (HyperLinkIDMap.ContainsKey(linkItem.Link.LinkKey))
                {
                    continue;
                }

                var linkId = $"rId{linkItem.Index + 2}";
                lastIndex = linkItem.Index + 2;

                slidePart1.AddHyperlinkRelationship(new System.Uri(linkItem.Link.LinkURL, System.UriKind.Absolute), true, linkId);

                HyperLinkIDMap.Add(linkItem.Link.LinkKey, linkId);
            }

            return(lastIndex);
        }