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 linear gradient angles
hugohe302678469e4e7
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex f3132d53..195efad6 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -748,6 +748,10 @@ An explicit non-line imported `a:gradFill` requires exactly one `a:gsLst` withat least one `a:gs`, and every stop must provide a resolvable color. Missing orduplicate lists, empty lists, and unresolvable stops stop import instead ofbecoming an inherited fill or a partial gradient.+An imported non-line `a:lin@ang` may be omitted for the schema-defined zero+default. When present, it must be an integer from `0` through `21599999`+(1/60000 degree); malformed or out-of-range values stop import instead of+silently becoming a horizontal gradient.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 66981c7a..73a746cd 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@@ -19,6 +19,7 @@ from xml.etree import ElementTree as ETfrom .color_resolver import ColorPalette, find_color_elem, resolve_colorfrom .emu_units import (+ ANGLE_UNIT,NS,PERCENT_UNIT,fmt_num,@@ -28,6 +29,7 @@ from .emu_units import (_OOXML_INTEGER_RE = re.compile(r"[+-]?[0-9]+")+_OOXML_FULL_CIRCLE = 360 * ANGLE_UNIT@dataclass@@ -161,10 +163,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,if lin is not None:# ang is 1/60000 deg. 0° = horizontal left-to-right.- try:- angle_deg = float(lin.attrib.get("ang", "0")) / 60000.0- except ValueError:- angle_deg = 0.0+ angle_deg = _linear_gradient_angle(lin)x1, y1, x2, y2 = _angle_to_unit_endpoints(angle_deg)defs_xml = (f'<linearGradient id="{grad_id}" '@@ -214,6 +213,23 @@ def _gradient_stop_position(gs: ET.Element) -> float:return position / PERCENT_UNIT+def _linear_gradient_angle(lin: ET.Element) -> float:+ """Parse one optional DrawingML positive fixed angle in degrees."""+ raw = lin.get("ang")+ if raw is None:+ return 0.0+ token = raw.strip()+ if _OOXML_INTEGER_RE.fullmatch(token) is None:+ raise ValueError(f"Invalid DrawingML linear gradient angle: {raw!r}")+ angle = int(token)+ if not 0 <= angle < _OOXML_FULL_CIRCLE:+ raise ValueError(+ f"DrawingML linear gradient angle={angle} is outside "+ f"0..{_OOXML_FULL_CIRCLE - 1}"+ )+ return angle / ANGLE_UNIT++def _resolve_blip_fill(_elem, _palette, _prefix, _seq, _placeholder_hex) -> FillResult:"""blipFill on <p:spPr> means a shape filled with an image — handled atpic_to_svg level. For now mark as transparent so the shape's outlinediff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex c7a80865..3cafbe53 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -2874,6 +2874,57 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):with self.assertRaisesRegex(ValueError, expected):resolve_fill(sp_pr, None)+ def test_native_linear_gradient_angle_must_be_valid(self):+ valid_angles = ((None, 0.0), ('0', 0.0), ('21599999', 360.0))+ for angle, expected_degrees in valid_angles:+ with self.subTest(angle=angle):+ angle_attr = '' if angle is None else f' ang="{angle}"'+ 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:lin{angle_attr}/>+ </a:gradFill>+</p:spPr>''')+ fill = resolve_fill(sp_pr, None)+ gradient = ET.fromstring(fill.defs[0])+ x1 = float(gradient.get('x1'))+ y1 = float(gradient.get('y1'))+ x2 = float(gradient.get('x2'))+ y2 = float(gradient.get('y2'))+ actual_degrees = math.degrees(math.atan2(y2 - y1, x2 - x1))+ self.assertAlmostEqual(+ actual_degrees % 360,+ expected_degrees % 360,+ places=4,+ )++ invalid_angles = (+ ('', 'Invalid DrawingML linear gradient angle'),+ ('1.5', 'Invalid DrawingML linear gradient angle'),+ ('1e2', 'Invalid DrawingML linear gradient angle'),+ ('NaN', 'Invalid DrawingML linear gradient angle'),+ ('-1', 'angle=-1 is outside 0..21599999'),+ ('21600000', 'angle=21600000 is outside 0..21599999'),+ )+ for angle, expected in invalid_angles:+ with self.subTest(angle=angle):+ 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:lin ang="{angle}"/>+ </a:gradFill>+</p:spPr>''')+ with self.assertRaisesRegex(ValueError, expected):+ resolve_fill(sp_pr, None)+def test_compound_native_line_is_rejected_on_import(self):for compound in ('dbl', 'thickThin', 'thinThick', 'tri'):with self.subTest(compound=compound):