Parse() public static method

public static Parse ( System.Xml.Linq.XElement rPr ) : Formatting
rPr System.Xml.Linq.XElement
return Formatting
コード例 #1
0
ファイル: HelperFunctions.cs プロジェクト: code-mtnit/WPFSM
        internal static FormattedText ToFormattedText(XElement e)
        {
            // The text representation of e.
            String text = ToText(e);

            if (text == String.Empty)
            {
                return(null);
            }

            // e is a w:t element, it must exist inside a w:r element or a w:tabs, lets climb until we find it.
            while (!e.Name.Equals(XName.Get("r", DocX.w.NamespaceName)) &&
                   !e.Name.Equals(XName.Get("tabs", DocX.w.NamespaceName)))
            {
                e = e.Parent;
            }

            // e is a w:r element, lets find the rPr element.
            XElement rPr = e.Element(XName.Get("rPr", DocX.w.NamespaceName));

            FormattedText ft = new FormattedText();

            ft.text       = text;
            ft.index      = 0;
            ft.formatting = null;

            // Return text with formatting.
            if (rPr != null)
            {
                ft.formatting = Formatting.Parse(rPr);
            }

            return(ft);
        }
コード例 #2
0
        internal static FormattedText ToFormattedText(XElement e)
        {
            // The text representation of e.
            var text = ToText(e);

            if (text == string.Empty)
            {
                return(null);
            }

            // Save footnoteId for lookup
            string footnoteId = null;

            if (e.Name.Equals(XName.Get("footnoteReference", DocX.w.NamespaceName)))
            {
                footnoteId = e.GetAttribute(XName.Get("id", DocX.w.NamespaceName));
            }

            // e is a w:t element, it must exist inside a w:r element or a w:tabs, lets climb until we find it.
            while (!e.Name.Equals(XName.Get("r", DocX.w.NamespaceName)) &&
                   !e.Name.Equals(XName.Get("tabs", DocX.w.NamespaceName)))
            {
                e = e.Parent;
            }

            // e is a w:r element, lets find the rPr element.
            XElement rPr = e.Element(XName.Get("rPr", DocX.w.NamespaceName));

            // Find the id of the containing hyperlink, if any.
            var containingHyperlink = e.AncestorsAndSelf(XName.Get("hyperlink", DocX.w.NamespaceName)).FirstOrDefault();
            var ft = new FormattedText {
                text = text,
                containingHyperlinkId = containingHyperlink != null?containingHyperlink.GetAttribute(XName.Get("id", DocX.r.NamespaceName), null) : null,
                                            footnoteId = footnoteId
            };

            // Return text with formatting.
            if (rPr != null)
            {
                ft.formatting = Formatting.Parse(rPr);
            }

            return(ft);
        }
コード例 #3
0
ファイル: HelperFunctions.cs プロジェクト: ysking/DocXCore
        internal static FormattedText ToFormattedText(XElement e)
        {
            string text = ToText(e);

            if (text == string.Empty)
            {
                return(null);
            }
            while (!e.Name.Equals(XName.Get("r", DocX.w.NamespaceName)) && !e.Name.Equals(XName.Get("tabs", DocX.w.NamespaceName)))
            {
                e = e.Parent;
            }
            XElement      xElement      = e.Element(XName.Get("rPr", DocX.w.NamespaceName));
            FormattedText formattedText = new FormattedText();

            formattedText.text       = text;
            formattedText.index      = 0;
            formattedText.formatting = null;
            if (xElement != null)
            {
                formattedText.formatting = Formatting.Parse(xElement);
            }
            return(formattedText);
        }