Ejemplo n.º 1
0
 public StiRtfTreeNode(StiRtfNodeType nodeType, string key, bool hasParameter, int parameter)
 {
     this.children = new StiRtfNodeCollection();
     this.type     = nodeType;
     this.key      = key;
     this.hasParam = hasParameter;
     this.param    = parameter;
 }
Ejemplo n.º 2
0
 internal StiRtfTreeNode(StiRtfToken token)
 {
     this.children = new StiRtfNodeCollection();
     this.type     = (StiRtfNodeType)token.Type;
     this.key      = token.Key;
     this.hasParam = token.HasParameter;
     this.param    = token.Parameter;
 }
Ejemplo n.º 3
0
        private string toStringInm(StiRtfTreeNode curNode, int level, bool showNodeTypes)
        {
            StringBuilder        res      = new StringBuilder();
            StiRtfNodeCollection children = curNode.ChildNodes;

            for (int i = 0; i < level; i++)
            {
                res.Append("  ");
            }
            if (curNode.NodeType == StiRtfNodeType.Root)
            {
                res.Append("ROOT\r\n");
            }
            else if (curNode.NodeType == StiRtfNodeType.Group)
            {
                res.Append("GROUP\r\n");
            }
            else
            {
                if (showNodeTypes)
                {
                    res.Append(curNode.NodeType);
                    res.Append(": ");
                }
                res.Append(curNode.NodeKey);
                if (curNode.HasParameter)
                {
                    res.Append(" ");
                    res.Append(Convert.ToString(curNode.Parameter));
                }
                res.Append("\r\n");
            }
            foreach (StiRtfTreeNode node in children)
            {
                res.Append(toStringInm(node, level + 1, showNodeTypes));
            }
            return(res.ToString());
        }
Ejemplo n.º 4
0
        public ArrayList GetBandsData()
        {
            StiRtfNodeCollection main         = rootNode.ChildNodes[0].ChildNodes;
            StiRtfTreeNode       lastRootNode = rootNode.ChildNodes[0].LastChild;

            #region Skip header and info
            int pos = 0;
            //find first group
            while ((pos < main.Count) && (main[pos].NodeType != StiRtfNodeType.Group))
            {
                pos++;
            }
            //find last group in header or info
            while (pos < main.Count)
            {
                if (main[pos].NodeType == StiRtfNodeType.Group)
                {
                    pos++;
                }
                else
                {
                    //find next group
                    int pos2 = pos;
                    while ((pos2 < main.Count) && (main[pos2].NodeType != StiRtfNodeType.Group))
                    {
                        if ((main[pos2].NodeType == StiRtfNodeType.Keyword) &&
                            (TokensHash.ContainsKey(main[pos2].NodeKey)) && ((int)TokensHash[main[pos2].NodeKey] == 1))
                        {
                            pos  = pos2;
                            pos2 = main.Count;  //for break loop
                            break;
                        }
                        pos2++;
                    }
                    //check for header or info
                    if (pos2 < main.Count)
                    {
                        StiRtfTreeNode tempNode = main[pos2].ChildNodes[0];
                        if (((tempNode.NodeType == StiRtfNodeType.Keyword) &&
                             (TokensHash.ContainsKey(tempNode.NodeKey) && (int)TokensHash[tempNode.NodeKey] == 0)) ||
                            ((tempNode.NodeType == StiRtfNodeType.Control) && (tempNode.NodeKey == "*")))
                        {
                            pos = pos2;
                            pos++;
                            continue;
                        }
                    }
                    break;
                }
            }
            #endregion

            ArrayList bandsList = new ArrayList();

            StiRtfTreeNode node     = main[pos];
            StiRtfTreeNode lastNode = null;
            StiRtfBandData data     = null;

            while ((node != null) && (node != lastRootNode))
            {
                data       = new StiRtfBandData();
                data.start = node;
                bool tableFounded = false;

                while ((node != null) && (node != lastRootNode))
                {
                    if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "page") && (node != data.start))
                    {
                        break;
                    }
                    if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "sect") && (node != data.start))
                    {
                        break;
                    }
                    if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "trowd"))
                    {
                        tableFounded = true;
                        break;
                    }
                    if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "intbl"))
                    {
                        node         = data.start;
                        tableFounded = true;
                        break;
                    }
                    lastNode = node;
                    node     = node.NextFlateToken;
                }
                if (node != data.start)
                {
                    data.end        = lastNode;
                    data.isTableRow = false;
                    bandsList.Add(data);
                }

                if ((tableFounded) && (node != null) && (node != lastRootNode))
                {
                    data            = new StiRtfBandData();
                    data.start      = node;
                    data.isTableRow = true;
                    if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "trowd"))
                    {
                        node = node.NextFlateToken;
                    }
                    else
                    {
                        data.isIntbl = true;
                    }

                    while ((node != null) && (node != lastRootNode))
                    {
                        if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "row"))
                        {
                            node = node.NextFlateToken;
                            break;
                        }
                        //if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "trowd")) break;
                        lastNode = node;
                        node     = node.NextFlateToken;
                    }
                    while ((node != null) && (node != lastRootNode) && ((node.NodeType == StiRtfNodeType.Group) || (node.NodeType == StiRtfNodeType.GroupEnd)))
                    {
                        lastNode = node;
                        node     = node.NextFlateToken;
                    }
                    data.end = lastNode;
                    //if ((node.NodeType == StiRtfNodeType.Keyword) && (node.NodeKey == "trowd"))
                    //{
                    //    data.end = node;	//
                    //}
                    bandsList.Add(data);
                }
            }

            return(bandsList);
        }
Ejemplo n.º 5
0
 public void AddRange(StiRtfNodeCollection collection)
 {
     InnerList.AddRange(collection);
 }