コード例 #1
0
 /// <summary>
 /// search child node special keyword
 /// </summary>
 /// <param name="Key">special keyword</param>
 /// <param name="Deeply">whether search deeplyl</param>
 /// <returns>node find</returns>
 public RTFNode SearchKey(string Key, bool Deeply)
 {
     foreach (RTFNode node in myNodes)
     {
         if (node.Type == RTFNodeType.Keyword ||
             node.Type == RTFNodeType.ExtKeyword ||
             node.Type == RTFNodeType.Control)
         {
             if (node.Keyword == Key)
             {
                 return(node);
             }
         }
         if (Deeply)
         {
             if (node is RTFNodeGroup)
             {
                 RTFNodeGroup g = ( RTFNodeGroup )node;
                 RTFNode      n = g.SearchKey(Key, true);
                 if (n != null)
                 {
                     return(n);
                 }
             }
         }
     }
     return(null);
 }
コード例 #2
0
ファイル: RTFRawDocument.cs プロジェクト: ywscr/CSharpWriter
        private DateTime ReadDateTime(RTFNode g)
        {
            int yr  = g.Nodes.GetParameter("yr", 1900);
            int mo  = g.Nodes.GetParameter("mo", 1);
            int dy  = g.Nodes.GetParameter("dy", 1);
            int hr  = g.Nodes.GetParameter("hr", 0);
            int min = g.Nodes.GetParameter("min", 0);
            int sec = g.Nodes.GetParameter("sec", 0);

            return(new DateTime(yr, mo, dy, hr, min, sec));
        }
コード例 #3
0
 /// <summary>
 /// delete node
 /// </summary>
 /// <param name="node">node</param>
 public void RemoveChild(RTFNode node)
 {
     CheckNodes();
     if (node == null)
     {
         throw new System.ArgumentNullException("node");
     }
     if (node == this)
     {
         throw new System.ArgumentException("node != this");
     }
     this.Nodes.Remove(node);
 }
コード例 #4
0
 /// <summary>
 /// insert node
 /// </summary>
 /// <param name="index">index</param>
 /// <param name="node">node</param>
 public void InsertNode(int index, RTFNode node)
 {
     CheckNodes();
     if (node == null)
     {
         throw new System.ArgumentNullException("node");
     }
     if (node == this)
     {
         throw new System.ArgumentException("node != this");
     }
     node.Parent        = this;
     node.OwnerDocument = myOwnerDocument;
     this.Nodes.Insert(index, node);
 }
コード例 #5
0
 /// <summary>
 /// append child node
 /// </summary>
 /// <param name="node">node</param>
 public void AppendChild(RTFNode node)
 {
     CheckNodes();
     if (node == null)
     {
         throw new System.ArgumentNullException("node");
     }
     if (node == this)
     {
         throw new System.ArgumentException("node != this");
     }
     node.Parent        = this;
     node.OwnerDocument = myOwnerDocument;
     this.Nodes.Add(node);
 }
コード例 #6
0
ファイル: RTFRawDocument.cs プロジェクト: ywscr/CSharpWriter
        /// <summary>
        /// load rtf
        /// </summary>
        /// <param name="reader">RTF text reader</param>
        public void Load(RTFReader reader)
        {
            myNodes.Clear();
            System.Collections.Stack groups   = new System.Collections.Stack();
            RTFNodeGroup             NewGroup = null;
            RTFNode NewNode = null;

            while (reader.ReadToken() != null)
            {
                if (reader.TokenType == RTFTokenType.GroupStart)
                {
                    // begin group
                    if (NewGroup == null)
                    {
                        NewGroup = this;
                    }
                    else
                    {
                        NewGroup = new RTFNodeGroup();
                        NewGroup.OwnerDocument = this;
                    }
                    if (NewGroup != this)
                    {
                        RTFNodeGroup g = ( RTFNodeGroup )groups.Peek();
                        g.AppendChild(NewGroup);
                    }
                    groups.Push(NewGroup);
                }
                else if (reader.TokenType == RTFTokenType.GroupEnd)
                {
                    // end group
                    NewGroup = ( RTFNodeGroup )groups.Pop();
                    NewGroup.MergeText();
                    if (NewGroup.FirstNode is RTFNode)
                    {
                        switch (NewGroup.Keyword)
                        {
                        case RTFConsts._fonttbl:
                            // read font table
                            ReadFontTable(NewGroup);
                            break;

                        case RTFConsts._colortbl:
                            // read color table
                            ReadColorTable(NewGroup);
                            break;

                        case RTFConsts._info:
                            // read document information
                            ReadDocumentInfo(NewGroup);
                            break;
                        }
                    }
                    if (groups.Count > 0)
                    {
                        NewGroup = (RTFNodeGroup)groups.Peek();
                    }
                    else
                    {
                        break;
                    }
                    //NewGroup.MergeText();
                }
                else
                {
                    // read content

                    NewNode = new RTFNode(reader.CurrentToken);
                    NewNode.OwnerDocument = this;
                    NewGroup.AppendChild(NewNode);
                    if (NewNode.Keyword == RTFConsts._f)
                    {
                        RTFFont font = this.FontTable[NewNode.Parameter];
                        if (font != null)
                        {
                            myFontChartset = font.Encoding;
                        }
                        else
                        {
                            myFontChartset = null;
                        }
                        //myFontChartset = RTFFont.GetRTFEncoding( NewNode.Parameter );
                    }
                    else if (NewNode.Keyword == RTFConsts._af)
                    {
                        RTFFont font = this.FontTable[NewNode.Parameter];
                        if (font != null)
                        {
                            myAssociateFontChartset = font.Encoding;
                        }
                        else
                        {
                            myAssociateFontChartset = null;
                        }
                    }
                }
            }            // while( reader.ReadToken() != null )
            while (groups.Count > 0)
            {
                NewGroup = ( RTFNodeGroup )groups.Pop();
                NewGroup.MergeText();
            }
            //this.UpdateInformation();
        }
コード例 #7
0
ファイル: RTFNodeList.cs プロジェクト: sylarfan/CSharpWriter
 /// <summary>
 /// insert node
 /// </summary>
 /// <param name="index">index</param>
 /// <param name="node">node</param>
 internal void Insert(int index, RTFNode node)
 {
     this.List.Insert(index, node);
 }
コード例 #8
0
ファイル: RTFNodeList.cs プロジェクト: sylarfan/CSharpWriter
 /// <summary>
 /// remvoe node
 /// </summary>
 /// <param name="node">node</param>
 internal void Remove(RTFNode node)
 {
     this.Remove(node);
 }
コード例 #9
0
ファイル: RTFNodeList.cs プロジェクト: sylarfan/CSharpWriter
 /// <summary>
 /// add node
 /// </summary>
 /// <param name="node">node</param>
 internal void Add(RTFNode node)
 {
     //node.OwnerList = this ;
     this.List.Add(node);
 }
コード例 #10
0
ファイル: RTFNodeList.cs プロジェクト: sylarfan/CSharpWriter
 /// <summary>
 /// get index of node in this list
 /// </summary>
 /// <param name="node">node</param>
 /// <returns>index , if node does no in this list , return -1</returns>
 public int IndexOf(RTFNode node)
 {
     return(this.List.IndexOf(node));
 }