Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
 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);
         }
     }
 }
Beispiel #3
0
        /// <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);
                    }
                }
            }
        }
Beispiel #4
0
        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('—');
                        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);
            }
        }
Beispiel #5
0
 internal void AddRange(RTFNodeList list)
 {
     this.InnerList.AddRange(list);
 }