Exemple #1
0
        private static int GetLinkedStyleNumId(DocX document, string numId)
        {
            Debug.Assert(document != null, "document should not be null");

            var abstractNumElement = HelperFunctions.GetAbstractNum(document, numId);

            if (abstractNumElement != null)
            {
                var numStyleLink = abstractNumElement.Element(XName.Get("numStyleLink", DocX.w.NamespaceName));
                if (numStyleLink != null)
                {
                    var val = numStyleLink.Attribute(XName.Get("val", DocX.w.NamespaceName));
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        var linkedStyle = HelperFunctions.GetStyle(document, val.Value);
                        if (linkedStyle != null)
                        {
                            var linkedNumId = linkedStyle.Descendants(XName.Get("numId", DocX.w.NamespaceName)).FirstOrDefault();
                            if (linkedNumId != null)
                            {
                                var linkedNumIdVal = linkedNumId.Attribute(XName.Get("val", DocX.w.NamespaceName));
                                if (!string.IsNullOrEmpty(linkedNumIdVal.Value))
                                {
                                    return(Int32.Parse(linkedNumIdVal.Value));
                                }
                            }
                        }
                    }
                }
            }

            return(-1);
        }