Skip to content

fix(pptx): center resized slide content in pixel coordinates - #86

Merged
ChristopherVR merged 2 commits into
ChristopherVR:mainfrom
yunfeizhu:fix/pptx-slide-size-centering
Oct 16, 2026
Merged

ChristopherVR merged 2 commits into
ChristopherVR:mainfrom
yunfeizhu:fix/pptx-slide-size-centering

Conversation

@yunfeizhu

@yunfeizhu yunfeizhu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What does this change?

Fixes #85.

Convert the shared slide-size centering offsets from EMU to pixels before applying them to element frames. Ensure Fit and Maximize now keep content correctly positioned in all five framework bindings, including after saving and reopening.

Type of change

  • Bug fix (non-breaking)

Area

src/core/pptx/editor/render: one DOM-free fix shared by every binding.

Testing

  • Regression tests fail on the original implementation; both resize modes pass a real PPTX save/reload check.
  • bun run verify --base 260a953eabdd657fb744b8c4881d03f51da27a45: all 21 steps passed, including affected core/UI tests, builds, typechecks and viewer suites with React 18 compatibility.
  • Browser regression: 10/10 passed, Ensure Fit and Maximize in React, Vue, Angular, Vanilla and Svelte, checking visible content and the downloaded PPTX.
  • Previous fork CI passed for 9819b2661a322f42d9774f9602fb7d4bb0d71612 with scope=changed.

Screenshots / recordings

Reproduction PPTX

Before and after: saved and reopened PPTX exported to SVG

Summary by CodeRabbit

  • Bug Fixes

    • Corrected slide-resizing offsets so content is centred at the expected position when fitting or maximising slides, including portrait layouts.
  • Tests

    • Added coverage for resizing, saving and reloading presentations, checking slide dimensions, content positions and slide bounds.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests Test-only change area: pptx PowerPoint engine viewer: pptx PowerPoint viewer, demos and tests size: M Fewer than 500 changed lines labels Oct 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
  • ooxml-office-preview

    npm i https://pkg.pr.new/ooxml-core@87ffeda
    
    npm i https://pkg.pr.new/ooxml-ui@87ffeda
    

commit: 87ffeda

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⛔ Files ignored due to path filters: 1
  • src/core/pptx/__tests__/fixtures/slide-size-centering.pptx is excluded by !**/*.pptx, !**/fixtures/**
⚙️ Run configuration
  • Configuration used: Repository: ChristopherVR/ooxml/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b2299a8-6f6b-4a06-9e2b-1660c3242842
📥 Commits

Reviewing files that changed from the base of the PR and between 4e0c49b and 87ffeda.

⛔ Files ignored due to path filters: 1
  • src/core/pptx/__tests__/fixtures/slide-size-centering.pptx is excluded by !**/*.pptx, !**/fixtures/**

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: ChristopherVR/ooxml/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1068b58f-7139-4bbc-a8c5-9ef6bcad593e
📥 Commits

Reviewing files that changed from the base of the PR and between 260a953 and 9819b26.

⛔ Files ignored due to path filters: 2
  • docs/bug-repros/pptx-slide-size-centering.png is excluded by !**/*.png
  • src/core/pptx/__tests__/fixtures/slide-size-centering.pptx is excluded by !**/*.pptx, !**/fixtures/**
📒 Files selected for processing: 4
  • e2e/pptx/slide-size-centering.spec.ts
  • src/core/pptx/editor/render/slide-size-rescale.roundtrip.test.ts
  • src/core/pptx/editor/render/slide-size-rescale.test.ts
  • src/core/pptx/editor/render/slide-size-rescale.ts

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

📝 Walkthrough

The slide-size transform now converts its centred offsets from EMU to pixels. Unit, round-trip, and end-to-end tests cover ensure-fit and maximize, including element positions after saving and reloading.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 9819b

No actionable issue remains identified for this slide-centering change; it is mergeable after normal checks.

Security architecture risk: 🔵 Low · up to 9819b

The change corrects slide positioning without introducing a new security boundary or privileged operation. Compatibility risk is limited to callers that may have interpreted the exported helper’s previous offsets as EMU rather than pixels.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed computation affects slide-element geometry through an existing document-editing path. The inspected implementation performs numeric transformation and object copying, not credential access, network operations, or privileged execution.
Pre-merge checks: Passed 5
Check name Status Explanation
Linked Issues check Passed Issue #85 requires the shared slide-size operation to keep content centred and visible for Ensure Fit and Maximize after a 4:3-to-widescreen change, including after save and reload, for all framework …
Out of Scope Changes check Passed The implementation changes only the shared slide-size rescale transform. The added unit, round-trip, and Playwright tests verify the linked issue behaviour. No unrelated product or API changes are ide…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 4 files.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the PPTX fix and the change from EMU to pixel coordinates. It matches the main purpose of the pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@ChristopherVR ChristopherVR left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, this is a real bug and the fix is in the right place.

Element frames are in pixels but the centring offsets were in EMU, so Ensure Fit and Maximize pushed content far off the slide. Every binding goes through the shared scaleSlidesForSizeChange, so converting the offsets once in resolveSlideSizeRescaleTransform covers all five, and nothing else in the repository depended on EMU offsets. The tests are good: the portrait cases, the save-and-reload round trip on a real deck and the cross-binding browser spec.

Two small requests before merge:

  • Please drop docs/bug-repros/pptx-slide-size-centering.png. It starts a new folder of PR screenshots in the repository; the image is better kept in the PR description.
  • resolveSlideSizeRescaleTransform is exported (ooxml-core/pptx/editor, re-exported from ooxml-ui/pptx) and its offsets change from EMU to pixels. A line in the commit body saying so would help any outside caller.

The exported resolveSlideSizeRescaleTransform now returns offsetX and
offsetY in pixels instead of EMU, matching slide element frame coordinates.
@yunfeizhu
yunfeizhu force-pushed the fix/pptx-slide-size-centering branch from 9819b26 to 4e0c49b Compare October 16, 2026 02:11
@github-actions github-actions Bot removed the documentation Improvements or additions to documentation label Oct 16, 2026
@yunfeizhu

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @ChristopherVR! Updated in 4e0c49b: removed the PNG from the commit and moved it to GitHub attachments in the PR and issue descriptions. The commit body now explicitly documents that resolveSlideSizeRescaleTransform returns offsetX/offsetY in pixels instead of EMU.

The .pptx fixture remains because the round-trip and browser tests load it directly. The PR still contains one commit.

@ChristopherVR
ChristopherVR merged commit fbbdfee into ChristopherVR:main Oct 16, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: pptx PowerPoint engine size: M Fewer than 500 changed lines tests Test-only change viewer: pptx PowerPoint viewer, demos and tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slide Size moves content off canvas when changing aspect ratio

2 participants