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): validate path gradient focus rectangles
hugohe32bf47cade85c
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 295a2974..9257cbfd 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -778,6 +778,11 @@ An imported `a:tileRect` may be absent or occur once as an empty/full-arearelative rectangle. Explicit `l/t/r/b` values use strict DrawingML percentagesyntax and must resolve to zero. Duplicate or malformed rectangles and non-zerotile offsets stop import because project SVG has no gradient tiling model.+Within an imported `a:path`, zero or one leaf `a:fillToRect` is accepted. Its+optional `l/t/r/b` edges must use the same strict DrawingML percentage syntax;+the registered `Approximate` mapping validates but normalizes the focus rectangle+to the centered radial SVG form. Duplicate or malformed focus rectangles stop+import instead of being silently discarded.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.pyindex f5e32a45..48d873f8 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@@ -192,6 +192,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,)elif rad is not None:_validate_path_gradient_type(rad)+ _validate_path_gradient_focus(rad)# Treat as radial regardless of path="circle" / "rect" / "shape" — SVG# only has circle/ellipse, and path="circle" maps to fillToRect=center.defs_xml = (@@ -297,18 +298,11 @@ def _validate_gradient_tile_rect(gradient: ET.Element) -> None:)if not tile_rects:return- tile_rect = tile_rects[0]- if (- set(tile_rect.attrib) - {"l", "t", "r", "b"}- or list(tile_rect)- or (tile_rect.text or "").strip()- ):- raise ValueError("Invalid DrawingML gradient tileRect structure")- for edge, raw in tile_rect.attrib.items():- value = _parse_ooxml_percentage(- raw,- label=f"gradient tileRect {edge}",- )+ values = _relative_rect_values(+ tile_rects[0],+ label="gradient tileRect",+ )+ for value in values.values():if value != 0:raise ValueError("Non-zero DrawingML gradient tileRect is not representable "@@ -316,6 +310,38 @@ def _validate_gradient_tile_rect(gradient: ET.Element) -> None:)+def _validate_path_gradient_focus(path: ET.Element) -> None:+ """Validate the focus rectangle normalized by the radial approximation."""+ focus_rects = path.findall("a:fillToRect", NS)+ if len(focus_rects) > 1:+ raise ValueError(+ "DrawingML path gradient must contain at most one fillToRect"+ )+ if focus_rects:+ _relative_rect_values(+ focus_rects[0],+ label="path gradient fillToRect",+ )+++def _relative_rect_values(+ rect: ET.Element,+ *,+ label: str,+) -> dict[str, Decimal]:+ """Validate one DrawingML relative-rectangle leaf and parse its edges."""+ if (+ set(rect.attrib) - {"l", "t", "r", "b"}+ or list(rect)+ or (rect.text or "").strip()+ ):+ raise ValueError(f"Invalid DrawingML {label} structure")+ return {+ edge: _parse_ooxml_percentage(raw, label=f"{label} {edge}")+ for edge, raw in rect.attrib.items()+ }++def _parse_ooxml_percentage(raw: str, *, label: str) -> Decimal:"""Parse one DrawingML ST_Percentage as an exact normalized ratio."""token = raw.strip()diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex b926a280..4c12f891 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -3159,6 +3159,55 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):):resolve_tile_rect(tile_rect)+ def test_native_path_gradient_focus_rect_must_be_valid(self):+ def resolve_focus_rect(focus_rect: str):+ 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>+ <a:gsLst>+ <a:gs pos="0"><a:srgbClr val="112233"/></a:gs>+ </a:gsLst>+ <a:path path="circle">{focus_rect}</a:path>+ </a:gradFill>+</p:spPr>''')+ return resolve_fill(sp_pr, None)++ valid_rects = (+ '',+ '<a:fillToRect/>',+ '<a:fillToRect l="50000" t="50%" r="-25000" b="125%"/>',+ )+ for focus_rect in valid_rects:+ with self.subTest(valid_focus_rect=focus_rect):+ fill = resolve_focus_rect(focus_rect)+ self.assertEqual(+ ET.fromstring(fill.defs[0]).tag,+ 'radialGradient',+ )++ for raw in ('', 'NaN', '1e2', '0px', '2147483648'):+ with self.subTest(invalid_focus_value=raw):+ with self.assertRaisesRegex(+ ValueError,+ 'Invalid DrawingML path gradient fillToRect l',+ ):+ resolve_focus_rect(f'<a:fillToRect l="{raw}"/>')++ invalid_structures = (+ '<a:fillToRect/><a:fillToRect/>',+ '<a:fillToRect future="0"/>',+ '<a:fillToRect><a:ext/></a:fillToRect>',+ '<a:fillToRect>payload</a:fillToRect>',+ )+ for focus_rect in invalid_structures:+ with self.subTest(invalid_focus_rect=focus_rect):+ with self.assertRaisesRegex(+ ValueError,+ 'fillToRect',+ ):+ resolve_focus_rect(focus_rect)+def test_compound_native_line_is_rejected_on_import(self):for compound in ('dbl', 'thickThin', 'thinThick', 'tri'):with self.subTest(compound=compound):