浏览代码

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

master
Luc Wuyts 9 年前
父节点
当前提交
783b272d1a
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 6
    4
      DocX/Container.cs
  2. 2
    0
      DocX/Table.cs

+ 6
- 4
DocX/Container.cs 查看文件

} }
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 查看文件

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;
} }

正在加载...
取消
保存