I have two documents that I try to merge partially.
I take some parts from document A that are inside a RTF content control and copy all child elements of the sdtContent
of the content control to another sdtContent
in document B using AppendChild and CloneNode(true) (deep cloning):
foreach (var srcChildElement in sourceDocumentSdtContentBlockNode.ChildElements)
{
targetSdtContentBlock.AppendChild(srcChildElement.CloneNode(true);
}
The problem is, that if the content (list items) in my source document A is formatted with bullet points the result in document B will be numbered list items.
Why isn't the resulting style like in the source when I clone it? I thought it would just keep its style as I don't manipulate it. In document B there seems also no to be a formatting issue. I can manually insert bullets or a numbered list without a problem.
I even created two completly new word documents and the same thing happend, so it is surely not some issue with the existing files.
Update:
I found out that there is a separate numbering definition in a document (https://msdn.microsoft.com/en-us/library/office/ee922775(v=office.14).aspx) which is not part of the node I copy. When I clone the node this information is not included at it is in a separate numbering definition. Is there a way to copy a node to a new document and tell it to retain the numbering styles from the numbering definition? The other option would be to manually check if the cloned node contains a numPr
element and if yes to extract also the definition (including changing and reassigning the IDs) - would prefer a less complex way to copy an element and hope there is one :-)
Any ideas?