internal Hyperlink(FieldStart fieldStart) { if (fieldStart == null) { throw new ArgumentNullException("fieldStart"); } if (!fieldStart.FieldType.Equals(FieldType.FieldHyperlink)) { throw new ArgumentException("Field start type must be FieldHyperlink."); } mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = fieldStart.GetField().Separator; if (mFieldSeparator == null) { throw new InvalidOperationException("Cannot find field separator."); } mFieldEnd = fieldStart.GetField().End; // Field code looks something like [ HYPERLINK "http:\\www.myurl.com" ], but it can consist of several runs. string fieldCode = fieldStart.GetField().GetFieldCode(); Match match = gRegex.Match(fieldCode.Trim()); mIsLocal = (match.Groups[1].Length > 0); //The link is local if \l is present in the field code. mTarget = match.Groups[2].Value; }
internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) throw new ArgumentNullException("fieldStart"); if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) throw new ArgumentException("Field start type must be FieldMergeField."); mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = fieldStart.GetField().Separator; if (mFieldSeparator == null) throw new InvalidOperationException("Cannot find field separator."); mFieldEnd = fieldStart.GetField().End; }
internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) { throw new ArgumentNullException("fieldStart"); } if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) { throw new ArgumentException("Field start type must be FieldMergeField."); } mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = fieldStart.GetField().Separator; if (mFieldSeparator == null) { throw new InvalidOperationException("Cannot find field separator."); } mFieldEnd = fieldStart.GetField().End; }
public void GetFieldFromDocument() { //ExStart //ExFor:FieldChar.GetField //ExId:GetField //ExSummary:Demonstrates how to retrieve the field class from an existing FieldStart node in the document. Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.TableOfContents.doc"); FieldStart fieldStart = (FieldStart)doc.GetChild(NodeType.FieldStart, 0, true); // Retrieve the facade object which represents the field in the document. Field field = fieldStart.GetField(); Console.WriteLine("Field code:" + field.GetFieldCode()); Console.WriteLine("Field result: " + field.Result); Console.WriteLine("Is locked: " + field.IsLocked); // This updates only this field in the document. field.Update(); //ExEnd }