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): close gradient fill attributes

hugohe3dbbc7f7c57be
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 9257cbfd..c7460b3c 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -770,6 +770,9 @@ The local SVG gradient rotates with its containing geometry. Imported
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 imported `a:gradFill` attribute set is closed to `flip` and
+`rotWithShape`; unknown, namespaced, or misspelled attributes stop import rather
+than being ignored as if their semantics were already supported.
Project SVG has no gradient-tile flip mapping. Imported `a:gradFill@flip` may
therefore be omitted for the documented Office `none` baseline or be exactly
`none`; `x`, `y`, `xy`, malformed, and unknown values stop import instead of
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 48d873f8..83b09c60 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
@@ -125,6 +125,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_attributes(elem)
_validate_gradient_rotation(elem)
_validate_gradient_flip(elem)
_validate_gradient_tile_rect(elem)
@@ -282,6 +283,16 @@ def _validate_gradient_rotation(gradient: ET.Element) -> None:
)
+def _validate_gradient_attributes(gradient: ET.Element) -> None:
+ """Reject attributes outside the registered gradient-fill contract."""
+ unsupported = sorted(set(gradient.attrib) - {"flip", "rotWithShape"})
+ if unsupported:
+ raise ValueError(
+ "Unsupported DrawingML gradient fill attribute(s): "
+ + ", ".join(unsupported)
+ )
+
+
def _validate_gradient_flip(gradient: ET.Element) -> None:
"""Reject gradient tile flipping absent from project SVG."""
flip = gradient.get("flip", "none")
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 4c12f891..234dbfba 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -3102,6 +3102,23 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
):
resolve_flip(flip)
+ def test_native_gradient_rejects_unknown_attributes(self):
+ sp_pr = ET.fromstring('''
+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
+ xmlns:future="urn:future">
+ <a:gradFill futureMode="x" future:mode="y">
+ <a:gsLst>
+ <a:gs pos="0"><a:srgbClr val="112233"/></a:gs>
+ </a:gsLst>
+ </a:gradFill>
+</p:spPr>''')
+ with self.assertRaisesRegex(
+ ValueError,
+ 'Unsupported DrawingML gradient fill attribute',
+ ):
+ resolve_fill(sp_pr, None)
+
def test_native_gradient_tile_rect_must_cover_full_area(self):
def resolve_tile_rect(tile_rect: str):
sp_pr = ET.fromstring(f'''