Skip to content

[BUG] pptx: set width on a group silently scales height too (implicit aspect-ratio lock, no opt-out) #237

Closed

Description

@jasonwei1002

Summary

set on a group silently locks the aspect ratio: setting only width also scales height (and vice versa). There is no way at L2 to resize a group along a single axis; the only workaround is raw-set on p:grpSpPr/a:xfrm/a:ext.

Repro (v1.0.136)

officecli create g.pptx
officecli add g.pptx / --type slide
officecli add g.pptx '/slide[1]' --type shape --prop geometry=rect --prop x=2cm --prop y=2cm --prop width=4cm --prop height=2cm
officecli add g.pptx '/slide[1]' --type shape --prop geometry=rect --prop x=8cm --prop y=5cm --prop width=4cm --prop height=2cm
officecli add g.pptx '/slide[1]' --type group --prop shapes=1,2
officecli get g.pptx '/slide[1]/group[1]'
# -> x=2cm y=2cm width=10cm height=5cm

officecli set g.pptx '/slide[1]/group[1]' --prop x=1cm --prop width=12cm
officecli get g.pptx '/slide[1]/group[1]'
# -> width=12cm height=6cm   <-- height changed from 5cm to 6cm, was never requested

Expected

set width on a group should change only ext.cx (children scale horizontally via the chExt mapping), matching the behavior of set width on a plain shape. If the aspect lock is intentional, it should be opt-in (e.g. --prop keepAspect=true) and the default should honor exactly the properties the caller passed.

Workaround for others hitting this

officecli raw-set deck.pptx ppt/slides/slideN.xml \
  --xpath "//p:grpSp[...]/p:grpSpPr/a:xfrm/a:ext" \
  --action setattr --xml 'cy=<original EMU>'

Activity

  1. goworm commented on Jul 19, 2026

    @goworm
    Contributor

    Confirmed — the implicit aspect lock was intentional (it protected add --type diagram groups from single-axis squashing) but leaking it onto every group with no opt-out was wrong. Fixed on main (45e432b), will be in the next release:

    • set on a group now changes exactly the axes you pass — --prop width=12cm leaves height untouched (children still scale horizontally via the chExt baseline). Same fix applied to docx groups.
    • The proportional behavior is now opt-in: --prop width=12cm --prop keepAspect=true scales height by the same ratio and re-bakes child font sizes with the uniform resize.

    Verified against your repro:

    officecli set g.pptx '/slide[1]/group[1]' --prop x=1cm --prop width=12cm
    officecli get g.pptx '/slide[1]/group[1]'
    # -> x=1cm width=12cm height=5cm        (height untouched)
    
    officecli set g.pptx '/slide[1]/group[1]' --prop width=6cm --prop keepAspect=true
    # -> width=6cm height=2.5cm             (opt-in proportional)

    Thanks for the precise repro and the raw-set workaround for others in the meantime.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions