Ejemplo n.º 1
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);
         }
     }
 }
Ejemplo n.º 2
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);
            }
        }