Skip to content

fix(word): keep header and footer references when rejecting a section change - #550

Merged
sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
rmorgans:fix/reject-sectprchange-header-refs
Oct 17, 2026
Merged

sergey-tihon merged 1 commit into
sergey-tihon:masterfrom
rmorgans:fix/reject-sectprchange-header-refs

Conversation

@rmorgans

@rmorgans rmorgans commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Rejecting a w:sectPrChange makes the section lose all its headers and footers.

Reproduction. Two sections, each with a w:headerReference and w:footerReference, each with <w:sectPrChange> recording the old margins. After Reject the sections read pgSz pgMar@1440 | pgSz pgMar@1440; Word restores the old margins and keeps the references: rIdHeader1 rIdFooter1 pgSz pgMar@1440 | rIdHeader2 rIdFooter2 pgSz pgMar@1440.

Cause. RejectRevisionsForPartTransform replaces the whole w:sectPr with the recorded one. The recorded properties are CT_SectPrBase, which cannot contain header or footer references, so they are lost.

Fix. Build the rejected w:sectPr from the current header/footer references followed by the recorded properties (an empty recorded w:sectPr no longer throws).

Test. RP055_SectionPropertiesChangeKeepsHeadersAndFooters (a section break inside a paragraph and the final body section).


Found while using RevisionProcessor to check that Reject All of a tracked-change redline gives back the original document. Expected results are Microsoft Word for Mac 16.113's own Accept All / Reject All on the same markup. The regression test fails on current master and passes with the fix; ./build.sh passes.

This is one of six small, independent RevisionProcessor fixes (#548, #549, #550, #551, #552, #553). Each adds its test after RP001 in RevisionProcessorTests.cs, so whichever merges second will need a trivial rebase there; I'll rebase the rest as they land.

Prepared with an AI coding agent (Claude); I reviewed the change and ran the tests.

… change

RevisionProcessor.RejectRevisions replaced a w:sectPr that carries a
w:sectPrChange with the recorded w:sectPr. The recorded properties are
a CT_SectPrBase, which cannot hold w:headerReference or
w:footerReference, so the section lost every header and footer. Word's
Reject All restores the recorded properties and keeps the references.
Build the rejected w:sectPr from the current references and the
recorded properties, for body and paragraph-level sections alike.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized fix addresses the reported defect, with focused regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes Word revision rejection so restoring recorded section properties preserves the section’s current header and footer references.

Changes:

  • Retains header/footer references while restoring recorded properties.
  • Adds accept/reject regression coverage for paragraph-level and final body sections.
File Description
Clippit/​Word/​RevisionProcessor.cs Preserves references when rejecting section property changes.
Clippit.Tests/​Word/​RevisionProcessorTests.cs Verifies references, margins, and valid output for both section locations.

Review effort: Balanced

@sergey-tihon
sergey-tihon merged commit 827ba6d into sergey-tihon:master Oct 17, 2026
18 checks passed
@rmorgans
rmorgans deleted the fix/reject-sectprchange-header-refs branch October 18, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants