Example #1
0
        internal static void GetFormattedTextRecursive(XElement Xml, ref List <FormattedText> alist)
        {
            FormattedText formattedText  = ToFormattedText(Xml);
            FormattedText formattedText2 = null;

            if (formattedText != null)
            {
                if (alist.Count() > 0)
                {
                    formattedText2 = alist.Last();
                }
                if (formattedText2 != null && formattedText2.CompareTo(formattedText) == 0)
                {
                    formattedText2.text += formattedText.text;
                }
                else
                {
                    if (formattedText2 != null)
                    {
                        formattedText.index = formattedText2.index + formattedText2.text.Length;
                    }
                    alist.Add(formattedText);
                }
            }
            if (Xml.HasElements)
            {
                foreach (XElement item in Xml.Elements())
                {
                    GetFormattedTextRecursive(item, ref alist);
                }
            }
        }
        internal static void GetFormattedTextRecursive(XElement Xml, ref List <FormattedText> alist)
        {
            FormattedText ft   = ToFormattedText(Xml);
            FormattedText last = null;

            if (ft != null)
            {
                if (alist.Any())
                {
                    last = alist.Last();
                }

                // Join adjacent runs that have the same formatting and do not cross a hyperlink boundary (they must both be inside a hyperlink or both be outside)
                if (last != null && last.CompareTo(ft) == 0 && (last.containingHyperlinkId == null) == (ft.containingHyperlinkId == null) && ft.footnoteId == null)
                {
                    // Update text of last entry.
                    last.text += ft.text;
                }
                else
                {
                    if (last != null)
                    {
                        ft.index = last.index + last.text.Length;
                    }

                    alist.Add(ft);
                }
            }

            if (Xml.HasElements)
            {
                foreach (XElement e in Xml.Elements())
                {
                    GetFormattedTextRecursive(e, ref alist);
                }
            }
        }
Example #3
0
        internal static void GetFormattedTextRecursive(XElement Xml, ref List <FormattedText> alist)
        {
            FormattedText ft   = ToFormattedText(Xml);
            FormattedText last = null;

            if (ft != null)
            {
                if (alist.Count() > 0)
                {
                    last = alist.Last();
                }

                if (last != null && last.CompareTo(ft) == 0)
                {
                    // Update text of last entry.
                    last.text += ft.text;
                }

                else
                {
                    if (last != null)
                    {
                        ft.index = last.index + last.text.Length;
                    }

                    alist.Add(ft);
                }
            }

            if (Xml.HasElements)
            {
                foreach (XElement e in Xml.Elements())
                {
                    GetFormattedTextRecursive(e, ref alist);
                }
            }
        }