Commit 9a0131f
Fix XDocument mutation and duplicate singleton relationships in WmlComparer
This commit addresses two issues:
1. XDocument Mutation (Issue OpenXmlDev#3):
- WmlDocument.MainDocumentPart and PtMainDocumentPart.WordprocessingCommentsPart
were removing nodes from cached XDocuments, causing subsequent GetXDocument()
calls to return empty documents within the same package lifetime
- Fixed by cloning the root element before extracting and removing child nodes
- Location: WmlDocument.cs lines 67-81 and 20-37
2. Duplicate Singleton Relationships:
- WmlComparer.MoveRelatedPartsToDestination was creating duplicate relationships
for singleton parts (fontTable, styles, numbering, settings, webSettings, theme)
- This caused validation errors: "can only have one instance of relationship
that targets part fontTable"
- Fixed by checking if a singleton relationship already exists and reusing it
instead of creating a duplicate
- Location: WmlComparer.cs MoveRelatedPartsToDestination method
Test Results:
- Fixed 2 WmlComparer tests (RC-0020, WCB-1740) that were failing with fontTable errors
- Improved from 22 failing tests to 20 failing tests (956 -> 958 passing)
- Remaining failures are unrelated to these issues
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 1408924 commit 9a0131f
2 files changed
+28
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4771 | 4771 | | |
4772 | 4772 | | |
4773 | 4773 | | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
| 4796 | + | |
| 4797 | + | |
4774 | 4798 | | |
4775 | 4799 | | |
4776 | 4800 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
0 commit comments