using (Aspose.Slides.Presentation presentation1 = new Aspose.Slides.Presentation(fileName))
{
// Iterate through all the slide parts in the presentation part.
foreach (Aspose.Slides.Slide slide in presentation1.Slides)
{
List HypLinks = new List();
//Get an Array of TextFrameEx objects from the first slide
ITextFrame[] textFramesSlideOne = Aspose.Slides.Util.SlideUtil.GetAllTextBoxes(slide);
try
{
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.Length; i++)
{
try
{
//Loop through paragraphs in current TextFrame
foreach (Aspose.Slides.Paragraph para in textFramesSlideOne[i].Paragraphs)
{
//Loop through portions in the current Paragraph
foreach (Portion port in para.Portions)
{
try
{
if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick != null)
{
if (port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl != null)
{
HypLinks.Add(port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl);
string gatewayUrl = port.PortionFormat.AsIHyperlinkContainer.HyperlinkClick.ExternalUrl;
//gatewayUrl = "http://gateway/sites/Home/consumerbusiness/default.aspx";
if (gatewayUrl.Contains("http://gateway") || gatewayUrl.Contains("http://portail"))
{
if (gatewayUrl.ToLower().LastIndexOf('.') >= 0)
{
//if (gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".ppt" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".pptx" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".doc" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".docx" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".xls" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".xlsx" || gatewayUrl.ToLower().Substring(gatewayUrl.ToLower().LastIndexOf('.')) == ".pdf")
//if (gatewayUrl.Contains(".pdf") || gatewayUrl.Contains(".doc") || gatewayUrl.Contains(".docx") || gatewayUrl.Contains(".xls") || gatewayUrl.Contains(".xlsx") || gatewayUrl.Contains(".ppt") || gatewayUrl.Contains(".pptx"))
{
string newDocumentUrl = GetmyDeloitteDocumentUrl(pageUrl, gatewayUrl, logfile, exLog, dtDocumentUrls, dtPageUrls);
port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(newDocumentUrl);
//port.Text=port.Text.Replace(gatewayUrl, newDocumentUrl);
para.Text = para.Text.Replace(gatewayUrl, newDocumentUrl);
}
//else
//{
// string newPageUrl = GetmyDeloittePageUrl(pageUrl, gatewayUrl, exLog, dtPageUrls);
// port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(newPageUrl);
//}
}
else
{
string newPageUrl = GetmyDeloittePageUrl(pageUrl, gatewayUrl,logfile, exLog, dtPageUrls);
port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(newPageUrl);
port.Text= port.Text.Replace(gatewayUrl, newPageUrl);
//para.Text = para.Text.Replace(gatewayUrl, newPageUrl);
}
//port.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick("http://mydeloitte.com");
found = true;
count++;
}
}
//else
//{
// Console.WriteLine("Test");
//}
}
else if (port.Text.Contains("http://gateway") || port.Text.Contains("http://portail"))
{
foreach (Match m in Regex.Matches(port.Text, @"((http[s]?|ftp):\/)?\/?([^:\/\s]+)(:([^\/]*))?((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?$"))
{
string gatewayUrl = m.ToString().Trim().ToLower();
if (gatewayUrl.IndexOf("?") == gatewayUrl.Length - 1)
{
gatewayUrl = gatewayUrl.Replace("?", "");
}
if (gatewayUrl.IndexOf(".") == gatewayUrl.Length - 1)
{
gatewayUrl = gatewayUrl.Replace(".", "");
}
if (gatewayUrl.ToLower().LastIndexOf('.') >= 0)
{
string newDocumentUrl = GetmyDeloitteDocumentUrl(pageUrl, gatewayUrl, logfile, exLog, dtDocumentUrls, dtPageUrls);
port.Text=port.Text.ToLower().Replace(gatewayUrl, newDocumentUrl);
//para.Text = para.Text.Replace(gatewayUrl, newDocumentUrl);
found = true;
count++;
}
else
{
string newPageUrl = GetmyDeloittePageUrl(pageUrl, gatewayUrl, logfile, exLog, dtPageUrls);
port.Text=port.Text.ToLower().Replace(gatewayUrl, newPageUrl);
//para.Text = para.Text.Replace(gatewayUrl, newPageUrl);
found = true;
count++;
}
}
}
}
catch (Exception ex)
{
throw;
}
}
}
}
catch (Exception ex)
{
throw;
}
}
}
catch (Exception ex)
{
throw;
}
}