/// <summary> /// Annotate hyper link in content /// </summary> /// <param name="rootElement"></param> private void AnnotateHyperlinkContent(XElement rootElement) { var state = AnnotateState.NotInHyperlink; foreach (var blockLevelContentContainer in rootElement.Descendants().Where(e => W.BlockLevelContentContainers.Contains(e.Name))) { FieldInfo fieldInfo = null; foreach (XElement runLevelContent in blockLevelContentContainer .LogicalChildrenContent(W.p).LogicalChildrenContent(W.r)) { if (runLevelContent.Elements(W.fldChar).Attributes(W.fldCharType) .Any(a => a.Value == "begin")) { state = AnnotateState.InFirstSection; } XElement instrText = runLevelContent.Elements(W.instrText).FirstOrDefault(); if (instrText != null && state == AnnotateState.InFirstSection) { FieldInfo tempFieldInfo = FieldParser.ParseField(instrText.Value); if (tempFieldInfo.FieldType == "HYPERLINK") { fieldInfo = tempFieldInfo; } } if (runLevelContent.Elements(W.fldChar).Attributes(W.fldCharType) .Any(a => a.Value == "separate")) { state = AnnotateState.InSecondSection; } if (runLevelContent.Elements(W.fldChar).Attributes(W.fldCharType) .Any(a => a.Value == "end")) { fieldInfo = null; state = AnnotateState.NotInHyperlink; } if (state == AnnotateState.InSecondSection && fieldInfo != null && (string)runLevelContent.Elements(W.rPr).Elements(W.rStyle) .Attributes(W.val).FirstOrDefault() == "Hyperlink") { runLevelContent.AddAnnotation(fieldInfo); } } } }