Skip to content

fix: undo the stored rotation of a singly flipped .ppt shape - #2411

Open
mahesh-desu wants to merge 1 commit into
storytold:mainfrom
mahesh-desu:fix/2407-ppt-flipped-rotation
Open

mahesh-desu wants to merge 1 commit into
storytold:mainfrom
mahesh-desu:fix/2407-ppt-flipped-rotation

Conversation

@mahesh-desu

@mahesh-desu mahesh-desu commented Nov 27, 2026 •

Copy link
Copy Markdown

Legacy .ppt shapes that are rotated and flipped in one direction now import at the angle they have in the source.

Fixes #2407.

What the user saw. A shape rotated 30° and flipped horizontally imported as 330° (rot="19800000" instead of rot="1800000"); a 90° shape imported as 270°. The shapes turned the wrong way, so rounded corners and arrows landed on the wrong side. Unflipped shapes and shapes flipped both ways were correct.

Cause. A .ppt stores the angle of a shape with exactly one flip as 360° - θ. xfrm in crates/ppt/src/convert.rs copied that stored angle into a:xfrm rot unchanged. The box-swap decision was already right because the mirrored quadrants map onto each other.

What changed. xfrm keeps the box-swap decision on the stored angle, then returns (360° - stored_rot).rem_euclid(360.0) when exactly one of flip_h/flip_v is set. Both flips, no flip and the finite/rem_euclid handling are unchanged. The .ppt reader, the .pptx writer and the editor's flip behaviour (#901) are untouched.

Test. a_single_flip_mirrors_the_stored_legacy_rotation_back drives xfrm with a 30°/330° pair, both single flips, both-flip and no-flip controls, a 270°/90° box swap, the 360°/-30° wrap, and a non-identity group map. It fails on the base with rot = 330.0 for the first case and passes after the fix. No full-import duplicate was added because xfrm is the only changed branch.

Verification.

  • cargo fmt --all --check — passed.
  • cargo clippy -p deckcraft-ppt --all-targets -- -D warnings — passed.
  • cargo test -p deckcraft-ppt — 52 passed, 0 failed.
  • A LibreOffice/reference-render check on the issue's .ppt fixture — not run; the unit test drives the only changed branch.

The expected angles come from the legacy drawing format, not from a value we chose.

Summary by CodeRabbit

  • Bug Fixes
    • Improved shape rotation and flipping behavior, including correct width and height handling for rotated shapes.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PPT transform conversion now uses normalized rotation to determine box swapping. When exactly one flip is set, it reverses the rotation. Tests cover flip combinations, wrapped angles, box swapping, and group mapping.

Changes: PPT flip rotation

Layer / File(s) Summary
Rotation correction and coverage
crates/ppt/src/convert.rs
The transform conversion adjusts the normalized rotation when exactly one of flip_h and flip_v is set. It retains the rotation when both or neither flip is set. Tests cover the rotation cases, box swapping, angle wrapping, and group mapping.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: oliwoly

Merge Risk: Minimal · up to e00af

This change corrects the rotation of imported legacy presentation shapes that have exactly one flip. Other shapes are unaffected, and the reported tests cover the changed behavior. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change accurately: a fix that undoes the stored rotation for a .ppt shape with exactly one flip. The raw summary and PR objectives both describe this change, which swaps the box fo…
Linked Issues check Passed Issue #2407 requires that a .ppt shape with exactly one flip (fFlipH or fFlipV) imports with the visual angle, not the stored 360° − θ angle. The whole-PR diff against the merge base changes only `x…
Out of Scope Changes check Passed All changes lie in crates/ppt/src/convert.rs. The production change is limited to the xfrm rotation correction and a comment. The added test directly exercises that same function and its stated case…
Full details: Title check

Explanation

The title names the change accurately: a fix that undoes the stored rotation for a .ppt shape with exactly one flip. The raw summary and PR objectives both describe this change, which swaps the box for the normalized rotation and reverses the angle when exactly one flip is set. The title is concise and specific, and it does not describe anything absent from the changeset. It omits the box-swap detail, which is acceptable for a title.

Full details: Linked Issues check

Explanation

Issue #2407 requires that a .ppt shape with exactly one flip (fFlipH or fFlipV) imports with the visual angle, not the stored 360° − θ angle. The whole-PR diff against the merge base changes only xfrm in crates/ppt/src/convert.rs. It keeps the box-swap test on stored_rot and then sets rot = (360.0 - stored_rot).rem_euclid(360.0) when flip_h ^ flip_v. Both-flip and no-flip paths keep stored_rot. For the issue's example, stored 330° with flipH gives 30° (rot="1800000"). For the 90° case, stored 270° with one flip gives 90° (rot="5400000", not 16200000). The added test a_single_flip_mirrors_the_stored_legacy_rotation_back asserts these values, the both-flip and no-flip controls, the 360°/−30° wrap, and a group child map. The issue's expected a:xfrm values match the unit-test assertions. The unit test checks xfrm output, not a full .ppt import or a LibreOffice render. The issue does not require those checks. Residual uncertainty: the reference-render comparison in the issue was not run, so visual parity is not verified here.

Full details: Out of Scope Changes check

Explanation

All changes lie in crates/ppt/src/convert.rs. The production change is limited to the xfrm rotation correction and a comment. The added test directly exercises that same function and its stated cases. No change touches the .ppt reader, the .pptx writer, or editor flip behaviour (#901), which the PR description and the objectives list as out of scope. No unrelated changes were found in the reviewed whole-PR diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 62b8306 and e00af8e.

Files selected for processing: 1

  • crates/ppt/src/convert.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@autocraft-bot autocraft-bot Bot added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.ppt import: a rotated shape with one flip (fFlipH or fFlipV) turns the wrong way

1 participant