1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using System . Collections . Concurrent ;
44using DF = DocumentFormat . OpenXml ;
@@ -22,7 +22,7 @@ private OoxmlDocData(WordprocessingDocument doc)
2222 {
2323 lock ( _lockObject )
2424 {
25- _ooxmlDoc = OwDocument . CreateInstance ( ) ;
25+ _ooxmlDoc = OwDocument . CreateInstance ( doc ) ;
2626 _staticDocCount ++ ;
2727 _staticDocDict . TryAdd ( _staticDocCount , doc ) ;
2828 }
@@ -58,7 +58,9 @@ internal void Insert(FF.IElement newElement, int position,Document doc)
5858 _staticDocDict . TryGetValue ( doc . GetInstanceInfo ( ) , out WordprocessingDocument staticDoc ) ;
5959
6060 if ( staticDoc ? . MainDocumentPart ? . Document ? . Body == null ) throw new FileFormatException ( "Package or Document or Body is null" , new NullReferenceException ( ) ) ;
61-
61+
62+ _ooxmlDoc = OwDocument . CreateInstance ( staticDoc ) ;
63+
6264 var enumerable = staticDoc . MainDocumentPart . Document . Body . Elements ( ) . ToList ( ) ;
6365 var originalElements = new List < DF . OpenXmlElement > ( enumerable ) ;
6466
@@ -105,7 +107,9 @@ internal void Update(FF.IElement newElement, int position,Document doc)
105107 _staticDocDict . TryGetValue ( doc . GetInstanceInfo ( ) , out WordprocessingDocument staticDoc ) ;
106108
107109 if ( staticDoc ? . MainDocumentPart ? . Document ? . Body == null ) throw new FileFormatException ( "Package or Document or Body is null" , new NullReferenceException ( ) ) ;
108-
110+
111+ _ooxmlDoc = OwDocument . CreateInstance ( staticDoc ) ;
112+
109113 var enumerable = staticDoc . MainDocumentPart . Document . Body . Elements ( ) . ToList ( ) ;
110114 var originalElements = new List < DF . OpenXmlElement > ( enumerable ) ;
111115
@@ -183,6 +187,8 @@ internal void Append(FF.IElement newElement,Document doc)
183187
184188 if ( staticDoc ? . MainDocumentPart ? . Document ? . Body == null ) throw new FileFormatException ( "Package or Document or Body is null" , new NullReferenceException ( ) ) ;
185189
190+ _ooxmlDoc = OwDocument . CreateInstance ( staticDoc ) ;
191+
186192 var enumerable = staticDoc . MainDocumentPart . Document . Body . Elements ( ) . ToList ( ) ;
187193 var originalElements = new List < DF . OpenXmlElement > ( enumerable ) ;
188194
0 commit comments