1
Vote

CloneElementAndSetContentInPlaceholders method changing

description

Hi!
What do you think about changing method CloneElementAndSetContentInPlaceholders of DocumentGenerator class (line 329) to always copy element before self and don't copy whole paragraph. For example I may want to have recursive inline (StdRun) elements, but i can't clone them in loop, because this method copies whole paragraph.

In code we will replace
SdtElement clonedSdtElement;
if (openXmlElementDataContext.Element.Parent != null && openXmlElementDataContext.Element.Parent is Paragraph)
{
    Paragraph clonedPara = openXmlElementDataContext.Element.Parent.InsertBeforeSelf(openXmlElementDataContext.Element.Parent.CloneNode(true) as Paragraph);
    clonedSdtElement = clonedPara.Descendants<SdtElement>().First();
}
else
{
    clonedSdtElement = openXmlElementDataContext.Element.InsertBeforeSelf(openXmlElementDataContext.Element.CloneNode(true) as SdtElement);
}
with
SdtElement clonedSdtElement = openXmlElementDataContext.Element.InsertBeforeSelf(openXmlElementDataContext.Element.CloneNode(true) as SdtElement);

comments