Skip to content

Commit 1e0501c

Browse files
committed
Addressed the feedback
1 parent 37bbfd2 commit 1e0501c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Bookmarks/Find-Bookmark-Owner-TextBody-or-Header-Footer/.NET/Find-Bookmark-Owner-TextBody-or-Header-Footer/Program.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,13 @@ public static void Main(string[] args)
1717
{
1818
// Get the paragraphs that contain the bookmark's start.
1919
WParagraph startPara = bkmkStart.OwnerParagraph;
20-
if (startPara == null)
21-
continue;
22-
2320
Entity ownerEntity = startPara;
24-
if (ownerEntity != null)
21+
// Traverse the owner hierarchy until reaching the section, stopping if a HeaderFooter is found
22+
while (!(ownerEntity is WSection))
2523
{
26-
// Traverse the owner hierarchy until reaching the section, stopping if a HeaderFooter is found
27-
while (!(ownerEntity is WSection))
28-
{
29-
if (ownerEntity.EntityType == EntityType.HeaderFooter)
30-
break;
31-
ownerEntity = ownerEntity.Owner;
32-
}
24+
if (ownerEntity.EntityType == EntityType.HeaderFooter)
25+
break;
26+
ownerEntity = ownerEntity.Owner;
3327
}
3428
// Check if the bookmark is in the text body, header, or footer
3529
string ownerLabel = (ownerEntity.EntityType == EntityType.Section)

0 commit comments

Comments
 (0)