|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Insert the contents of another document at the end of this document.
|
|
|
/// Insert the contents of another document at the end of this document.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="document">The document to insert at the end of this document.</param>
|
|
|
|
|
|
|
|
|
/// <param name="remote_document">The document to insert at the end of this document.</param>
|
|
|
/// <example>
|
|
|
/// <example>
|
|
|
/// Create a new document and insert an old document into it.
|
|
|
/// Create a new document and insert an old document into it.
|
|
|
/// <code>
|
|
|
/// <code>
|
|
|
|
|
|
|
|
|
merge_customs(remote_pp, local_pp, remote_mainDoc);
|
|
|
merge_customs(remote_pp, local_pp, remote_mainDoc);
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// Merge footnotes (and endnotes) before merging styles, then set the remote_footnotes to the just updated footnotes
|
|
|
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":
|
|
|
|
|
|
merge_footnotes(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes);
|
|
|
|
|
|
remote_footnotes = footnotes;
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":
|
|
|
|
|
|
merge_endnotes(remote_pp, local_pp, remote_mainDoc, remote_document, remote_endnotes);
|
|
|
|
|
|
remote_endnotes = endnotes;
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":
|
|
|
merge_styles(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes, remote_endnotes);
|
|
|
merge_styles(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes, remote_endnotes);
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// Merge styles after merging the footnotes, so the changes will be applied to the correct document/footnotes
|
|
|
case "application/vnd.ms-word.stylesWithEffects+xml":
|
|
|
case "application/vnd.ms-word.stylesWithEffects+xml":
|
|
|
merge_styles(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes, remote_endnotes);
|
|
|
merge_styles(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes, remote_endnotes);
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
merge_numbering(remote_pp, local_pp, remote_mainDoc, remote_document);
|
|
|
merge_numbering(remote_pp, local_pp, remote_mainDoc, remote_document);
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":
|
|
|
|
|
|
merge_footnotes(remote_pp, local_pp, remote_mainDoc, remote_document, remote_footnotes);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":
|
|
|
|
|
|
merge_endnotes(remote_pp, local_pp, remote_mainDoc, remote_document, remote_endnotes);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
default:
|
|
|
break;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
guidd++;
|
|
|
guidd++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
numbering.Root.Elements(XName.Get("abstractNum", DocX.w.NamespaceName)).Last().AddAfterSelf(remote_abstractNums);
|
|
|
|
|
|
numbering.Root.Elements(XName.Get("num", DocX.w.NamespaceName)).Last().AddAfterSelf(remote_nums);
|
|
|
|
|
|
|
|
|
// Checking whether there were more than 0 elements, helped me get rid of exceptions thrown while using InsertDocument
|
|
|
|
|
|
if (numbering.Root.Elements(XName.Get("abstractNum", DocX.w.NamespaceName)).Count() > 0)
|
|
|
|
|
|
numbering.Root.Elements(XName.Get("abstractNum", DocX.w.NamespaceName)).Last().AddAfterSelf(remote_abstractNums);
|
|
|
|
|
|
|
|
|
|
|
|
if (numbering.Root.Elements(XName.Get("num", DocX.w.NamespaceName)).Count() > 0)
|
|
|
|
|
|
numbering.Root.Elements(XName.Get("num", DocX.w.NamespaceName)).Last().AddAfterSelf(remote_nums);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private void merge_fonts(PackagePart remote_pp, PackagePart local_pp, XDocument remote_mainDoc, DocX remote)
|
|
|
private void merge_fonts(PackagePart remote_pp, PackagePart local_pp, XDocument remote_mainDoc, DocX remote)
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
|
|
|
{
|
|
|
guuid = Guid.NewGuid().ToString();
|
|
|
guuid = Guid.NewGuid().ToString();
|
|
|
|
|
|
// Set the styleId in the remote_style to this new Guid
|
|
|
|
|
|
// [Fixed the issue that my document referred to a new Guid while my styles still had the old value ("Titel")]
|
|
|
|
|
|
remote_style.SetAttributeValue(XName.Get("styleId", DocX.w.NamespaceName), guuid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
foreach (XElement e in remote_mainDoc.Root.Descendants(XName.Get("pStyle", DocX.w.NamespaceName)))
|
|
|
foreach (XElement e in remote_mainDoc.Root.Descendants(XName.Get("pStyle", DocX.w.NamespaceName)))
|
|
|
{
|
|
|
{
|