Selaa lähdekoodia

Null check added. Was throwing exception when serializing document or part of document.

master
Luc Wuyts 9 vuotta sitten
vanhempi
commit
783b272d1a
2 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 6
    4
      DocX/Container.cs
  2. 2
    0
      DocX/Table.cs

+ 6
- 4
DocX/Container.cs Näytä tiedosto

} }
XElement body = Xml.Element(XName.Get("body", DocX.w.NamespaceName)); XElement body = Xml.Element(XName.Get("body", DocX.w.NamespaceName));
XElement baseSectionXml = body.Element(XName.Get("sectPr", DocX.w.NamespaceName));
var baseSection = new Section(Document, baseSectionXml) { SectionParagraphs = parasInASection };
sections.Add(baseSection);
if (body != null)
{
XElement baseSectionXml = body.Element(XName.Get("sectPr", DocX.w.NamespaceName));
var baseSection = new Section(Document, baseSectionXml) { SectionParagraphs = parasInASection };
sections.Add(baseSection);
}
return sections; return sections;
} }
} }

+ 2
- 0
DocX/Table.cs Näytä tiedosto

get get
{ {
XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName)); XElement trPr = Xml.Element(XName.Get("trPr", DocX.w.NamespaceName));
if (trPr == null)
return false;
XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName)); XElement tblHeader = trPr.Element(XName.Get("tblHeader", DocX.w.NamespaceName));
return tblHeader != null; return tblHeader != null;
} }

Loading…
Peruuta
Tallenna