GetText() static private method

static private GetText ( System.Xml.Linq.XElement e ) : string
e System.Xml.Linq.XElement
return string
Beispiel #1
0
        internal Text GetFirstTextEffectedByEdit(int index, EditType type = EditType.ins)
        {
            if (index < 0 || index > HelperFunctions.GetText(base.Xml).Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            int  count  = 0;
            Text theOne = null;

            GetFirstTextEffectedByEditRecursive(base.Xml, index, ref count, ref theOne, type);
            return(theOne);
        }
Beispiel #2
0
        internal List <Paragraph> GetParagraphs(bool deepSearch = false)
        {
            int num = 0;
            List <Paragraph> list = new List <Paragraph>();

            foreach (XElement item2 in base.Xml.Descendants(XName.Get("p", DocX.w.NamespaceName)))
            {
                Paragraph item = new Paragraph(base.Document, item2, num);
                list.Add(item);
                num += HelperFunctions.GetText(item2).Length;
            }
            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// 找尋符合指定格式的所有文字
        /// </summary>
        /// <param name="matchFormatting"></param>
        /// <param name="IsIncludeHeader"></param>
        /// <param name="IsIncludeFooter"></param>
        /// <returns></returns>
        public virtual List <string> FindMatchFormattedTexts(Formatting matchFormatting,
                                                             bool IsIncludeHeader = false, bool IsIncludeFooter = false)
        {
            List <XElement> all_element_rst = FindMatchFormattedNodes(matchFormatting, IsIncludeHeader, IsIncludeFooter);

            List <string> all_texts = new List <string>();

            foreach (var ele in all_element_rst)
            {
                all_texts.Add(HelperFunctions.GetText(ele));
            }

            return(all_texts);
        }
Beispiel #4
0
        internal List <Paragraph> GetParagraphs(bool deepSearch = false)
        {
            // Need some memory that can be updated by the recursive search.
            int index = 0;
            List <Paragraph> paragraphs = new List <Paragraph>();

            foreach (XElement e in Xml.Descendants(XName.Get("p", DocX.w.NamespaceName)))
            {
                index += HelperFunctions.GetText(e).Length;
                Paragraph paragraph = new Paragraph(Document, e, index);
                paragraphs.Add(paragraph);
            }
            //  GetParagraphsRecursive(Xml, ref index, ref paragraphs, deepSearch);

            return(paragraphs);
        }
Beispiel #5
0
        internal void GetParagraphsRecursive(XElement Xml, ref int index, ref List <Paragraph> paragraphs, bool deepSearch = false)
        {
            bool flag = true;

            if (Xml.Name.LocalName == "p")
            {
                paragraphs.Add(new Paragraph(base.Document, Xml, index));
                index += HelperFunctions.GetText(Xml).Length;
                if (!deepSearch)
                {
                    flag = false;
                }
            }
            if (flag && Xml.HasElements)
            {
                foreach (XElement item in Xml.Elements())
                {
                    GetParagraphsRecursive(item, ref index, ref paragraphs, deepSearch);
                }
            }
        }
Beispiel #6
0
        internal void GetParagraphsRecursive(XElement Xml, ref int index, ref List <Paragraph> paragraphs)
        {
            // sdtContent are for PageNumbers inside Headers or Footers, don't go any deeper.
            //if (Xml.Name.LocalName == "sdtContent")
            //    return;

            if (Xml.Name.LocalName == "p")
            {
                paragraphs.Add(new Paragraph(Document, Xml, index));

                index += HelperFunctions.GetText(Xml).Length;
            }

            else
            {
                if (Xml.HasElements)
                {
                    foreach (XElement e in Xml.Elements())
                    {
                        GetParagraphsRecursive(e, ref index, ref paragraphs);
                    }
                }
            }
        }