fix(comparer): preserve legal numbering when comparing documents#75
Merged
fix(comparer): preserve legal numbering when comparing documents#75
Conversation
When comparing Word documents where one has legal numbering (w:isLgl) and the other doesn't, the comparison result was losing the legal numbering definitions entirely. Root cause: The result document starts as a copy of source1, and while styles were copied from source2 via CopyMissingStylesFromOneDocToAnother, there was no equivalent for numbering definitions. Fix: Added CopyMissingNumberingFromOneDocToAnother that: - Copies missing w:abstractNum elements from revised to result - Copies missing w:num elements with proper abstractNumId remapping - Handles ID conflicts by assigning new IDs when definitions differ - Compares by content (not just ID) to detect different definitions Fixes: dotnet/Open-XML-SDK#1634
…ring merge - Add null-safe GetIntAttribute helper for robust attribute extraction - Check for matching abstractNum content across ALL destination elements (not just by ID) to avoid duplicate definitions - Use explicit PutXDocument(toNumberingXDoc) for clarity - Add null-checks when setting abstractNumId element values - Improve code comments for maintainability
- Update main README.md: - Fix installation instructions (NuGet, not GitHub Packages) - Update repository URLs from JSv4/Redlines to JSv4/Docxodus - Add format change detection to features - Expand HTML converter features (comments, pagination, headers/footers) - Add OpenContractExporter to features list - Update npm example with new APIs (metadata, format changes) - Update test count (~1,100) - Update npm/README.md: - Add new features (move detection, format changes, pagination, etc.) - Update RevisionType enum with Moved and FormatChanged - Add getDocumentMetadata and exportToOpenContract API docs - Add Web Worker API section - Add additional React hooks (useAnnotations, useDocumentStructure) - Expand ConversionOptions with new properties - Fix credits URL - Update tools READMEs: - Add environment variable documentation (DEBUG flags) - Remove outdated limitation (headers/footers now supported) - Fix license URLs to JSv4/Docxodus - Fix repository URLs in all .csproj files: - Docxodus/Docxodus.csproj - tools/redline/redline.csproj - tools/docx2html/docx2html.csproj - tools/docx2oc/docx2oc.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
w:isLgl) being lost when comparing Word documents where one has legal numbering and the other doesn'tCopyMissingNumberingFromOneDocToAnothermethod that copies missing numbering definitions from the revised document to the comparison resultBackground
This addresses the issue reported in dotnet/Open-XML-SDK#1634. When comparing documents:
w:isLgl)The comparison result was losing the legal numbering entirely because:
CopyMissingStylesFromOneDocToAnotherTest plan
WmlComparerLegalNumberingTests.cs:WC_LegalNum_001: Original has legal numbering, revised doesn't → preserves legalWC_LegalNum_002: Revised has legal numbering, original doesn't → now preserves legal (was failing)WC_LegalNum_003: Both have legal numbering → preserves legalWC_LegalNum_004: Multi-level numbering scenario → now preserves legal (was failing)WC_LegalNum_005: Different numIds with legal numbering → merges correctly