private string GetAnchorLink(string outlineLinkTarget, XLink xLink)
{
try
{
string replaceMent = "|outline";
outlineLinkTarget = outlineLinkTarget.Replace(replaceMent, "");
//Get only the last part of the target and try to match a header
//beginning afer char index 6 should be a good decision
//TODO: Build the outline numbering via the outline element from the global styles
outlineLinkTarget = outlineLinkTarget.Substring(6);
if (xLink.Document != null)
if (xLink.Document.Content != null)
foreach(IContent iContent in xLink.Document.Content)
if (iContent is Header)
if (((Header)iContent).OutLineLevel != null)
{
string headerText = "";
//Get text only
foreach(IText iText in ((Header)iContent).TextContent)
if (iText.Text != null)
headerText += iText.Text;
if (headerText.EndsWith(outlineLinkTarget))
return headerText;
}
}
catch(Exception ex)
{
if (OnWarning != null)
{
AODLWarning warning = new AODLWarning("Exception while trying to get an anchor string from a XLink object.", ex);
//warning.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
//warning.OriginalException = ex;
warning.Node = xLink.Node;
OnWarning(warning);
}
}
return null;
}