Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(pptx-to-svg): enforce gradient rotation ownership

hugohe3d054e69e08b9
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index b626a955..6add4127 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -765,6 +765,11 @@ For the registered path-gradient approximation, omitted `a:path@path` uses the
schema default `rect`; explicit `circle`, `rect`, and `shape` are normalized to
the centered radial SVG form. Unknown or malformed enum values stop import
instead of being mislabeled as a supported radial gradient.
+The local SVG gradient rotates with its containing geometry. Imported
+`a:gradFill@rotWithShape` may therefore be omitted for the documented Office
+base default or be the exact XML booleans `1` / `true`. Explicit `0` / `false`
+and malformed booleans stop import instead of detaching the gradient direction
+from the shape during rotation.
The quality checker and exporter preflight both validate definition location,
references, gradient structure, and paint context from the same closed contract.
diff --git a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
index 278e1012..e5fc8764 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
@@ -119,6 +119,7 @@ def _resolve_solid_fill(elem: ET.Element, palette: ColorPalette | None,
def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
prefix: str, seq, placeholder_hex: str | None) -> FillResult:
"""Convert <a:gradFill> to an SVG linearGradient or radialGradient."""
+ _validate_gradient_rotation(elem)
if seq is None:
seq = [0]
seq[0] += 1
@@ -245,19 +246,11 @@ def _validate_linear_gradient_scaling(
angle: int,
) -> None:
"""Require a scaling mode representable by unit-box SVG geometry."""
- raw = lin.get("scaled")
- if raw is None:
- scaled = False
- else:
- token = raw.strip()
- if token in {"1", "true"}:
- scaled = True
- elif token in {"0", "false"}:
- scaled = False
- else:
- raise ValueError(
- f"Invalid DrawingML linear gradient scaled value: {raw!r}"
- )
+ scaled = _parse_ooxml_boolean(
+ lin.get("scaled"),
+ default=False,
+ label="linear gradient scaled value",
+ )
quarter_turn = 90 * ANGLE_UNIT
if not scaled and angle % quarter_turn:
raise ValueError(
@@ -266,6 +259,37 @@ def _validate_linear_gradient_scaling(
)
+def _validate_gradient_rotation(gradient: ET.Element) -> None:
+ """Require a gradient that rotates with its containing shape."""
+ rotates_with_shape = _parse_ooxml_boolean(
+ gradient.get("rotWithShape"),
+ default=True,
+ label="gradient rotWithShape value",
+ )
+ if not rotates_with_shape:
+ raise ValueError(
+ "DrawingML gradients that do not rotate with their shape are "
+ "not representable by the local SVG mapping"
+ )
+
+
+def _parse_ooxml_boolean(
+ raw: str | None,
+ *,
+ default: bool,
+ label: str,
+) -> bool:
+ """Parse one W3C XML Schema boolean without permissive aliases."""
+ if raw is None:
+ return default
+ token = raw.strip()
+ if token in {"1", "true"}:
+ return True
+ if token in {"0", "false"}:
+ return False
+ raise ValueError(f"Invalid DrawingML {label}: {raw!r}")
+
+
def _validate_path_gradient_type(path: ET.Element) -> None:
"""Require one registered DrawingML path-shade enum value."""
path_type = path.get("path", "rect")
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 281faec7..275c0c6e 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -3040,6 +3040,42 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
):
resolve_path(path_type)
+ def test_native_gradient_must_rotate_with_shape(self):
+ def resolve_rotation(rotates: str | None):
+ rotation_attr = (
+ '' if rotates is None else f' rotWithShape="{rotates}"'
+ )
+ sp_pr = ET.fromstring(f'''
+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
+ <a:gradFill{rotation_attr}>
+ <a:gsLst>
+ <a:gs pos="0"><a:srgbClr val="112233"/></a:gs>
+ </a:gsLst>
+ </a:gradFill>
+</p:spPr>''')
+ return resolve_fill(sp_pr, None)
+
+ for rotates in (None, '1', 'true'):
+ with self.subTest(valid_rotates=rotates):
+ self.assertTrue(resolve_rotation(rotates).defs)
+
+ for rotates in ('0', 'false'):
+ with self.subTest(unsupported_rotates=rotates):
+ with self.assertRaisesRegex(
+ ValueError,
+ 'do not rotate with their shape',
+ ):
+ resolve_rotation(rotates)
+
+ for rotates in ('', '2', 'TRUE', 'on', 'yes'):
+ with self.subTest(invalid_rotates=rotates):
+ with self.assertRaisesRegex(
+ ValueError,
+ 'Invalid DrawingML gradient rotWithShape value',
+ ):
+ resolve_rotation(rotates)
+
def test_compound_native_line_is_rejected_on_import(self):
for compound in ('dbl', 'thickThin', 'thinThick', 'tri'):
with self.subTest(compound=compound):