/// <summary> /// get all child node deeply /// </summary> /// <param name="IncludeGroupNode">contains group type node</param> /// <returns>child nodes list</returns> public RTFNodeList GetAllNodes(bool IncludeGroupNode) { RTFNodeList list = new RTFNodeList(); this.AddAllNodes(list, IncludeGroupNode); return(list); }
private void AddAllNodes(RTFNodeList list, bool IncludeGroupNode) { foreach (RTFNode node in myNodes) { if (node is RTFNodeGroup) { if (IncludeGroupNode) { list.Add(node); } (( RTFNodeGroup )node).AddAllNodes(list, IncludeGroupNode); } else { list.Add(node); } } }
/// <summary> /// read document information /// </summary> /// <param name="group"></param> private void ReadDocumentInfo(RTFNodeGroup group) { myInfo.Clear(); RTFNodeList list = group.GetAllNodes(false); foreach (RTFNode node in group.Nodes) { if ((node is RTFNodeGroup) == false) { continue; } if (node.Keyword == "creatim") { myInfo.Creatim = ReadDateTime(node); } else if (node.Keyword == "revtim") { myInfo.Revtim = ReadDateTime(node); } else if (node.Keyword == "printim") { myInfo.Printim = ReadDateTime(node); } else if (node.Keyword == "buptim") { myInfo.Buptim = ReadDateTime(node); } else { if (node.HasParameter) { myInfo.SetInfo(node.Keyword, node.Parameter.ToString()); } else { myInfo.SetInfo(node.Keyword, node.Nodes.Text); } } } }
internal void AddRange(RTFNodeList list) { InnerList.AddRange(list); }
private void AddAllNodes(RTFNodeList list, bool includeGroupNode) { foreach (var node in MyNodes) { if (node is RTFNodeGroup) { if (includeGroupNode) list.Add(node); ((RTFNodeGroup) node).AddAllNodes(list, includeGroupNode); } else list.Add(node); } }
internal void MergeText() { var list = new RTFNodeList(); var myStr = new StringBuilder(); var buffer = new ByteBuffer(); //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //System.Text.Encoding encode = myOwnerDocument.Encoding ; foreach (var node in MyNodes) { if (node.Type == RTFNodeType.Text) { AddString(myStr, buffer); myStr.Append(node.Keyword); continue; } if (node.Type == RTFNodeType.Control && node.Keyword == "\'" && node.HasParameter) { buffer.Add((byte) node.Parameter); continue; } if (node.Type == RTFNodeType.Control || node.Type == RTFNodeType.Keyword) { if (node.Keyword == "tab") { AddString(myStr, buffer); myStr.Append('\t'); continue; } if (node.Keyword == "emdash") { AddString(myStr, buffer); // notice!! This code may cause compiler error in OS which not support chinese character. // you can change to myStr.Append('-'); myStr.Append('j'); continue; } if (node.Keyword == "") { AddString(myStr, buffer); // notice!! This code may cause compiler error in OS which not support chinese character. // you can change to myStr.Append('-'); myStr.Append('Ƀ'); continue; } } AddString(myStr, buffer); if (myStr.Length > 0) { list.Add(new RTFNode(RTFNodeType.Text, myStr.ToString())); myStr = new StringBuilder(); } list.Add(node); } //foreach( RTFNode node in myNodes ) AddString(myStr, buffer); if (myStr.Length > 0) { list.Add(new RTFNode(RTFNodeType.Text, myStr.ToString())); } MyNodes.Clear(); foreach (var node in list) { node.Parent = this; node.OwnerDocument = MyOwnerDocument; MyNodes.Add(node); } }
/// <summary> /// get all child node deeply /// </summary> /// <param name="includeGroupNode">contains group type node</param> /// <returns>child nodes list</returns> public RTFNodeList GetAllNodes(bool includeGroupNode) { var list = new RTFNodeList(); AddAllNodes(list, includeGroupNode); return list; }
internal void MergeText() { RTFNodeList list = new RTFNodeList(); System.Text.StringBuilder myStr = new System.Text.StringBuilder(); ByteBuffer buffer = new ByteBuffer(); //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //System.Text.Encoding encode = myOwnerDocument.Encoding ; foreach (RTFNode node in myNodes) { if (node.Type == RTFNodeType.Text) { AddString(myStr, buffer); myStr.Append(node.Keyword); continue; } if (node.Type == RTFNodeType.Control && node.Keyword == "\'" && node.HasParameter) { buffer.Add(( byte )node.Parameter); continue; } else if (node.Type == RTFNodeType.Control || node.Type == RTFNodeType.Keyword) { if (node.Keyword == "tab") { AddString(myStr, buffer); myStr.Append('\t'); continue; } if (node.Keyword == "emdash") { AddString(myStr, buffer); // notice!! This code may cause compiler error in OS which not support chinese character. // you can change to myStr.Append('-'); myStr.Append('j'); continue; } if (node.Keyword == "") { AddString(myStr, buffer); // notice!! This code may cause compiler error in OS which not support chinese character. // you can change to myStr.Append('-'); myStr.Append('Ƀ'); continue; } } AddString(myStr, buffer); if (myStr.Length > 0) { list.Add(new RTFNode(RTFNodeType.Text, myStr.ToString())); myStr = new System.Text.StringBuilder(); } list.Add(node); } //foreach( RTFNode node in myNodes ) AddString(myStr, buffer); if (myStr.Length > 0) { list.Add(new RTFNode(RTFNodeType.Text, myStr.ToString())); } myNodes.Clear(); foreach (RTFNode node in list) { node.Parent = this; node.OwnerDocument = myOwnerDocument; myNodes.Add(node); } }
internal void AddRange( RTFNodeList list ) { this.InnerList.AddRange( list ); }