@@ -1172,9 +1172,10 @@ private static void AddSectionAndDependencies(WordprocessingDocument sourceDocum
11721172 {
11731173 string oldRid = footerReference . Attribute ( R . id ) . Value ;
11741174 var oldFooterPart2 = sourceDocument . MainDocumentPart . GetPartById ( oldRid ) ;
1175- if ( ! ( oldFooterPart2 is FooterPart oldFooterPart ) )
1175+ if ( ! ( oldFooterPart2 is FooterPart ) )
11761176 throw new DocumentBuilderException ( "Invalid document - invalid footer part." ) ;
11771177
1178+ FooterPart oldFooterPart = ( FooterPart ) oldFooterPart2 ;
11781179 XDocument oldFooterXDoc = oldFooterPart . GetXDocument ( ) ;
11791180 if ( oldFooterXDoc != null && oldFooterXDoc . Root != null )
11801181 CopyNumbering ( sourceDocument , newDocument , new [ ] { oldFooterXDoc . Root } , images ) ;
@@ -1579,13 +1580,15 @@ private static void CopyComments(WordprocessingDocument sourceDocument, Wordproc
15791580 newComments . Add ( new XElement ( W . comments , NamespaceAttributes ) ) ;
15801581 }
15811582 }
1582- if ( ! int . TryParse ( ( string ) comment . Attribute ( W . id ) , out int id ) )
1583+ int id ;
1584+ if ( ! int . TryParse ( ( string ) comment . Attribute ( W . id ) , out id ) )
15831585 throw new DocumentBuilderException ( "Invalid document - invalid comment id" ) ;
15841586 XElement element = oldComments
15851587 . Descendants ( )
15861588 . Elements ( W . comment )
15871589 . Where ( p => {
1588- if ( ! int . TryParse ( ( string ) p . Attribute ( W . id ) , out int thisId ) )
1590+ int thisId ;
1591+ if ( ! int . TryParse ( ( string ) p . Attribute ( W . id ) , out thisId ) )
15891592 throw new DocumentBuilderException ( "Invalid document - invalid comment id" ) ;
15901593 return thisId == id ;
15911594 } )
@@ -1633,7 +1636,8 @@ private static void AdjustUniqueIds(WordprocessingDocument sourceDocument,
16331636 foreach ( var item in newContent . DescendantsAndSelf ( ) . Where ( bm => bm . Name == W . bookmarkStart ||
16341637 bm . Name == W . bookmarkEnd ) )
16351638 {
1636- if ( ! int . TryParse ( ( string ) item . Attribute ( W . id ) , out int id ) )
1639+ int id ;
1640+ if ( ! int . TryParse ( ( string ) item . Attribute ( W . id ) , out id ) )
16371641 throw new DocumentBuilderException ( "Invalid document - invalid value for bookmark ID" ) ;
16381642 if ( ! bookmarkIdMap . ContainsKey ( id ) )
16391643 bookmarkIdMap . Add ( id , ++ maxId ) ;
@@ -2268,7 +2272,8 @@ private static void CopyNumbering(WordprocessingDocument sourceDocument, Wordpro
22682272 . Elements ( W . abstractNumId )
22692273 . First ( )
22702274 . Attribute ( W . val ) ;
2271- if ( ! int . TryParse ( abstractNumIdStr , out int abstractNumId ) )
2275+ int abstractNumId;
2276+ if ( ! int . TryParse ( abstractNumIdStr , out abstractNumId ) )
22722277 throw new DocumentBuilderException( "Invalid document - invalid value for abstractNumId" ) ;
22732278
22742279 XElement abstractElement = oldNumbering
@@ -2429,7 +2434,8 @@ private static void CopyNumberingForGlossaryDocumentPartFromGD(NumberingDefiniti
24292434 . Elements ( W . abstractNumId )
24302435 . First ( )
24312436 . Attribute ( W . val ) ;
2432- if ( ! int . TryParse ( abstractNumIdStr , out int abstractNumId ) )
2437+ int abstractNumId;
2438+ if ( ! int . TryParse ( abstractNumIdStr , out abstractNumId ) )
24332439 throw new DocumentBuilderException( "Invalid document - invalid value for abstractNumId" ) ;
24342440 XElement abstractElement = oldNumbering
24352441 . Descendants ( )
@@ -2590,7 +2596,8 @@ private static void CopyNumberingForGlossaryDocumentPartToGD(NumberingDefinition
25902596 . Elements ( W . abstractNumId )
25912597 . First ( )
25922598 . Attribute ( W . val ) ;
2593- if ( ! int . TryParse ( abstractNumIdStr , out int abstractNumId ) )
2599+ int abstractNumId;
2600+ if ( ! int . TryParse ( abstractNumIdStr , out abstractNumId ) )
25942601 throw new DocumentBuilderException( "Invalid document - invalid value for abstractNumId" ) ;
25952602 XElement abstractElement = oldNumbering
25962603 . Descendants ( )
0 commit comments