Skip to content

ODPresentation Writer and Reader : Give a text box the insets, the wrap and the alignment it was told - #976

Open
dkulyk wants to merge 2 commits into
PHPOffice:masterfrom
sapientpro:fix/odp-textbox-frame
Open

ODPresentation Writer and Reader : Give a text box the insets, the wrap and the alignment it was told#976
dkulyk wants to merge 2 commits into
PHPOffice:masterfrom
sapientpro:fix/odp-textbox-frame

Conversation

@dkulyk

@dkulyk dkulyk commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #975

Six properties of a text box never reached the file, and none of them was read back. OpenDocument states the four insets as the padding of the frame, fo:padding-left and the three beside it; the vertical alignment as draw:textarea-vertical-align; and the wrap as fo:wrap-option, which was written as the literal wrap whatever the shape said. The PowerPoint2007 Writer writes all six.

An inset is a float in pixels and the two defaults are 9.6 and 4.8, while pixelsToCentimeters() takes an int, so the conversion is spelled out rather than rounding the insets to whole pixels first. The padding is written to six decimals rather than the three the lengths beside it carry: a pixel is 127/4800 cm, so three decimals lose about a sixtieth of a pixel, and six put the common values in exactly. The two defaults come out as 0.254cm and 0.127cm, which is what LibreOffice writes for them.

getName() is missing from the same frame and is deliberately left alone: loadShapeDescription() falls back to draw:name for files written by older versions, so writing a text box's name there would come back as its description. That is a separate decision.

One existing test replaced fo:wrap-option and style:writing-mode as a single string; the two are no longer neighbours, so it replaces the writing mode alone.

Found by walking every property of a shape through each Writer/Reader pair and diffing what came back; this closes six of the differences the ODP pair showed.

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported

phpunit, phpstan, phpmd and php-cs-fixer all clean.

  • The new code is covered by unit tests

Two Writer tests, one over the six values and one over the defaults, and two Reader round trips for the same pair. Three of the four fail on develop; the fourth guards the defaults against the change itself.

  • I have updated the documentation to describe the changes

docs/changes/1.3.0.md.

  • I have added my name to the Changelog

Same file.

@coveralls

coveralls commented Sep 2, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 94.174% (+0.06%) from 94.111% — sapientpro:fix/odp-textbox-frame into PHPOffice:master

@dkulyk
dkulyk force-pushed the fix/odp-textbox-frame branch 4 times, most recently from dc553b3 to f914167 Compare September 8, 2026 08:41
…ap and the alignment it was told

Six properties of a text box never reached the file. OpenDocument states the four insets as the
padding of the frame, `fo:padding-left` and the three beside it; the vertical alignment as
`draw:textarea-vertical-align`; and the wrap as `fo:wrap-option`, which was written as the literal
`wrap` whatever the shape said. Nothing read any of the three back either, so a text box came back
wearing the defaults it was born with. The PowerPoint2007 Writer writes all six.

An inset is a float in pixels and the two defaults are 9.6 and 4.8, while `pixelsToCentimeters()`
takes an int, so the conversion is spelled out rather than rounding the insets to whole pixels
first. The padding is written to six decimals rather than the three the lengths beside it carry: a
pixel is 127/4800 cm, so three decimals lose about a sixtieth of a pixel, and six put the common
values in exactly -- the two defaults come out as `0.254cm` and `0.127cm`, which is what LibreOffice
writes for them.

`getName()` is missing from the same frame and is left alone: `loadShapeDescription()` falls back to
`draw:name` for files written by older versions, so writing a text box's name there would come back
as its description.

`testTextColumnsRTLWritingModes()` replaced `fo:wrap-option` and `style:writing-mode` as one string.
The two are no longer neighbours, so it replaces the writing mode alone.
@dkulyk
dkulyk force-pushed the fix/odp-textbox-frame branch 2 times, most recently from f914167 to 55f32c0 Compare September 8, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

ODPresentation : A text box writes neither its insets, nor its wrap, nor its vertical alignment

2 participants