public void Remove(bool trackChanges)
{
if (trackChanges)
{
DateTime now = DateTime.Now.ToUniversalTime();
List<XElement> elements = Xml.Elements().ToList();
List<XElement> temp = new List<XElement>();
for (int i = 0; i < elements.Count(); i++)
{
XElement e = elements[i];
if (e.Name.LocalName != "del")
{
temp.Add(e);
e.Remove();
}
else
{
if (temp.Count() > 0)
{
e.AddBeforeSelf(CreateEdit(EditType.del, now, temp.Elements()));
temp.Clear();
}
}
}
if (temp.Count() > 0)
Xml.Add(CreateEdit(EditType.del, now, temp));
}
else
{
// If this is the only Paragraph in the Cell then we cannot remove it.
if (Xml.Parent.Name.LocalName == "tc" && Xml.Parent.Elements(XName.Get("p", DocX.w.NamespaceName)).Count() == 1)
Xml.Value = string.Empty;
else
{
// Remove this paragraph from the document
Xml.Remove();
Xml = null;
}
}
}