Пример #1
0
        private static WListItemElement GetListItemElementFromXMLData(XmlNode ListItemNode)
        {
            if (ListItemNode != null)
            {
                WListItemElement wlie = new WListItemElement();

                if (ListItemNode.Name == WordXMLTags.WordTagName_Paragraph)
                {
                    WParagraph WPrg = WParagraphReader.GetParagraphFromParagraphXMLNode(ListItemNode);
                    wlie.ListItemElement = WPrg;
                    wlie.ListID          = WPrg.ListID;
                    wlie.ListItemLevel   = WPrg.ListItemLevel;
                }
                else if (ListItemNode.Name == WordXMLTags.WTN_Table)
                {
                    WTable LTable = WTableReader.GetTableFromTableXMLData(ListItemNode.OuterXml);
                    wlie.ListItemElement = LTable;
                    wlie.ListItemLevel   = -1;
                    wlie.ListID          = -1;
                }

                return(wlie);
            }
            return(null);
        }
Пример #2
0
        public static WList GetListFromWordElements(IWBaseElement[] ListElements)
        {
            if (ListElements == null)
            {
                return(null);
            }

            WListItemElement[] WLIElems = new WListItemElement[ListElements.Length];

            for (int pi = 0; pi < ListElements.Length; pi++)
            {
                WLIElems[pi] = new WListItemElement();
                if (ListElements[pi].GetType() == typeof(WParagraph))
                {
                    WLIElems[pi].ListItemElement = ListElements[pi] as WParagraph;
                    WLIElems[pi].ListID          = (ListElements[pi] as WParagraph).ListID;
                    WLIElems[pi].ListItemLevel   = (ListElements[pi] as WParagraph).ListItemLevel;
                }
                else if (ListElements[pi].GetType() == typeof(WTable))
                {
                    WLIElems[pi].ListItemElement = ListElements[pi] as WTable;
                    WLIElems[pi].ListID          = -1;
                    WLIElems[pi].ListItemLevel   = -1;
                }
            }

            WList out_Rslt = new WList();

            PrepareListRecursively(out_Rslt, WLIElems);
            return(out_Rslt);
        }
Пример #3
0
        protected static int PrepareListRecursively(WList out_WList, WListItemElement[] ListItemElements)
        {
            if (ListItemElements == null)
            {
                return(0);
            }


            if (ListItemElements.Length < 1)
            {
                return(0);
            }

            //WList out_WList = new WList();
            int Level   = ListItemElements[0].ListItemLevel;
            int LIIndex = 0;

            while (LIIndex < ListItemElements.Length)
            {
                WListItem wli = new WListItem();

                if (ListItemElements[LIIndex].ListItemLevel > Level)
                {
                    WListItemElement[] nplist = new WListItemElement[ListItemElements.Length - LIIndex];

                    Array.Copy(ListItemElements, LIIndex, nplist, 0, nplist.Length);
                    WList tmpCWList = new WList();
                    LIIndex += PrepareListRecursively(tmpCWList, nplist);

                    out_WList.ListItems[out_WList.ListItems.Count - 1].ChildList = tmpCWList;

                    continue;
                }
                else if (ListItemElements[LIIndex].ListItemLevel < Level)
                {
                    if (ListItemElements[LIIndex].ListItemLevel < 0)
                    {
                        out_WList.ListItems[out_WList.ListItems.Count - 1].ItemElements.Add(ListItemElements[LIIndex]);
                        LIIndex++;
                        continue;
                    }
                    else
                    {
                        return(LIIndex);
                    }
                }
                else
                {
                    wli.ListID        = ListItemElements[LIIndex].ListID;
                    wli.ListItemLevel = ListItemElements[LIIndex].ListItemLevel;
                    wli.ItemElements.Add(ListItemElements[LIIndex]);
                }

                out_WList.ListItems.Add(wli);
                LIIndex++;
            }

            return(LIIndex);
        }
Пример #4
0
        public static WList GetListFromListXMLData(XmlNode in_XMLNode)
        {
            //XmlNodeList Prgs = GetAllNodes(XMLContent);
            List <WListItemElement> PListItems = new List <WListItemElement>();

            foreach (XmlNode P in in_XMLNode.ChildNodes)
            {
                WListItemElement tmpWLIElem = GetListItemElementFromXMLData(P);
                if (tmpWLIElem.ListItemElement != null)
                {
                    PListItems.Add(tmpWLIElem);
                }
            }
            WList out_Rslt = new WList();

            PrepareListRecursively(out_Rslt, PListItems.ToArray());
            return(out_Rslt);
        }