fix(pptx): reject adjust handles undeclared by the preset geometry (#235) - #238
Open
jasonwei1002 wants to merge 1 commit into
Open
fix(pptx): reject adjust handles undeclared by the preset geometry (#235)#238jasonwei1002 wants to merge 1 commit into
jasonwei1002 wants to merge 1 commit into
Conversation
…OfficeAI#235) PowerPoint reports a file as corrupt (0x80070570) when a shape's avLst contains a <a:gd> whose name is not declared by the preset's ECMA-376 definition — most commonly an adj value on a preset with no adjust handles at all (rect, ellipse, line, ...). officecli previously wrote such files without complaint and validate stayed green. Replace the two hand-maintained partial tables (MultiGuidePresetDefaults, CanonicalAdjName) with PresetAdjustGuides, a complete table of all 187 preset geometries' declared guide names and spec-default formulas, generated from ECMA-376 presetShapeDefinitions.xml. ApplyAdjustHandles now: - rejects any adj= spec on a preset that declares no adjust handles, with an actionable error instead of an unopenable file; - rejects guide names not declared by multi-guide presets, listing the valid names; - generalizes the single-guide remap (donut/noSmoking special case) to every single-guide preset; - emits the complete guide set for every multi-guide preset (previously only hexagon/star5/star6/star7/star10), fixing the same 0x80070570 subset corruption for e.g. round2SameRect authored with only adj1. Fixes iOfficeAI#235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #235.
Root cause
Real PowerPoint validates every
<a:gd name="…">in a shape'savLstagainst the guide names the preset's ECMA-376 definition declares, and refuses the file (0x80070570, "repair/corrupt" dialog) on any mismatch.ApplyAdjustHandlesalready guarded two slices of this (the R18 donut/noSmoking remap and the R19b multi-guide subset fix for 5 star/hexagon presets), but presets outside those hand tables fell through to verbatim pass-through — most damagingly presets that declare no adjust guides at all (rect,ellipse,line, … 64 of the 187 presets), where any authoredadj=silently produces an unopenable file whilevalidatestays green.Change
One mechanism replaces the two hand-maintained tables:
PresetAdjustGuides, a complete map of all 187 preset geometries → declared guide names + spec-default formulas, generated from the ECMA-376presetShapeDefinitions.xml.ApplyAdjustHandlesnow authors theavLststrictly per the preset's declaration:adj=is rejected with an actionable error instead of writing a corrupt file.adj1onroundRectnow yieldsadjinstead of a corrupt file); extra handles are rejected.round2SameRectauthored with onlyadj1.The generated defaults for the 5 previously hand-listed presets are byte-identical to the old
MultiGuidePresetDefaultsentries. Unknown/custom presets keep today's pass-through behavior.Verification (macOS, net10.0 build of this branch)
Output files re-verified with an independent reader (python-pptx).
dotnet buildclean (the single CS8602 warning is pre-existing in ExcelHandler.SheetShift.cs).Per CONTRIBUTING Rule 1 this PR is one atomic change: "author avLst strictly per the preset's ECMA-376 declaration". A follow-up candidate (not included): make
validateflag pre-existing illegal<a:gd>entries in already-authored files using the same table.