@@ -12,24 +12,24 @@ static void Main(string[] args)
1212 using ( FileStream destinationStreamPath = new FileStream ( Path . GetFullPath ( "Data/DestinationDocument.docx" ) , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
1313 {
1414 //Opens an source document from file system through constructor of WordDocument class
15- using ( WordDocument document = new WordDocument ( sourceStreamPath , FormatType . Automatic ) )
15+ using ( WordDocument sourceDocument = new WordDocument ( sourceStreamPath , FormatType . Automatic ) )
1616 {
1717 //Opens the destination document
1818 using ( WordDocument destinationDocument = new WordDocument ( destinationStreamPath , FormatType . Docx ) )
1919 {
2020
21- WSection section = document . Sections [ 0 ] as WSection ;
21+ WSection sourceDocumentSection = sourceDocument . Sections [ 0 ] as WSection ;
2222 //Move all the items from one collection to another collection
2323 for ( int i = 0 ; i < destinationDocument . Sections . Count ; i ++ )
2424 {
25- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . EvenHeader . ChildEntities , section . HeadersFooters . Header . ChildEntities ) ;
26- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . EvenFooter . ChildEntities , section . HeadersFooters . Footer . ChildEntities ) ;
27- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . OddHeader . ChildEntities , section . HeadersFooters . Header . ChildEntities ) ;
28- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . OddFooter . ChildEntities , section . HeadersFooters . Footer . ChildEntities ) ;
29- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . FirstPageHeader . ChildEntities , section . HeadersFooters . Header . ChildEntities ) ;
30- MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . FirstPageFooter . ChildEntities , section . HeadersFooters . Footer . ChildEntities ) ;
31- destinationDocument . Sections [ i ] . PageSetup . DifferentOddAndEvenPages = section . PageSetup . DifferentOddAndEvenPages ;
32- destinationDocument . Sections [ i ] . PageSetup . DifferentFirstPage = section . PageSetup . DifferentFirstPage ;
25+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . EvenHeader . ChildEntities , sourceDocumentSection . HeadersFooters . Header . ChildEntities ) ;
26+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . EvenFooter . ChildEntities , sourceDocumentSection . HeadersFooters . Footer . ChildEntities ) ;
27+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . OddHeader . ChildEntities , sourceDocumentSection . HeadersFooters . Header . ChildEntities ) ;
28+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . OddFooter . ChildEntities , sourceDocumentSection . HeadersFooters . Footer . ChildEntities ) ;
29+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . FirstPageHeader . ChildEntities , sourceDocumentSection . HeadersFooters . Header . ChildEntities ) ;
30+ MoveItems ( destinationDocument . Sections [ i ] . HeadersFooters . FirstPageFooter . ChildEntities , sourceDocumentSection . HeadersFooters . Footer . ChildEntities ) ;
31+ destinationDocument . Sections [ i ] . PageSetup . DifferentOddAndEvenPages = sourceDocumentSection . PageSetup . DifferentOddAndEvenPages ;
32+ destinationDocument . Sections [ i ] . PageSetup . DifferentFirstPage = sourceDocumentSection . PageSetup . DifferentFirstPage ;
3333 }
3434 using ( FileStream outputStream = new FileStream ( Path . GetFullPath ( "Output/Result.docx" ) , FileMode . Create ) )
3535 {
@@ -43,13 +43,12 @@ static void Main(string[] args)
4343 /// <summary>
4444 /// Move all the items from one collection to another collection.
4545 /// </summary>
46- /// <param name="childEntities1"> </param>
47- /// <param name="childEntities2"> </param>
48- private static void MoveItems ( EntityCollection childEntities1 , EntityCollection childEntities2 )
46+ /// <param name="detinationDocumentEntityCollection">Destination collection </param>
47+ /// <param name="sourceDocumentEntityCollection">Source collection </param>
48+ private static void MoveItems ( EntityCollection detinationDocumentEntityCollection , EntityCollection sourceDocumentEntityCollection )
4949 {
50- for ( int i = 0 ; i < childEntities2 . Count ; i ++ )
51- childEntities1 . Add ( childEntities2 [ i ] . Clone ( ) ) ;
50+ for ( int i = 0 ; i < sourceDocumentEntityCollection . Count ; i ++ )
51+ detinationDocumentEntityCollection . Add ( sourceDocumentEntityCollection [ i ] . Clone ( ) ) ;
5252 }
5353 }
54- }
55-
54+ }
0 commit comments