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(scripts): hidden clip shapes hide the picture, hidden groups leave the animation target set, inline dx enters the bounds check, zero-width strokes export noFill
hugohe3f67baebd9643
diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.pyindex dfa57080..40f729cb 100644--- a/skills/ppt-master/scripts/svg_quality/checker.py+++ b/skills/ppt-master/scripts/svg_quality/checker.py@@ -100,7 +100,9 @@ try:parse_project_image_aspect_ratio as _parse_project_image_aspect_ratio,parse_project_opacity as _parse_project_opacity,parse_svg_color as _parse_export_color,+ parse_svg_length as _parse_svg_length,parse_transform_matrix as _parse_transform_matrix,+ project_definition_index as _project_definition_index,project_mask_errors as _project_mask_errors,rect_to_dml_xfrm as _rect_to_dml_xfrm,split_project_text_clusters as _split_project_text_clusters,@@ -121,7 +123,9 @@ except ImportError:_parse_project_image_aspect_ratio = None_parse_project_opacity = None_parse_export_color = None+ _parse_svg_length = None_parse_transform_matrix = None+ _project_definition_index = None_project_mask_errors = None_rect_to_dml_xfrm = None_split_project_text_clusters = None@@ -160,6 +164,7 @@ except ImportError:try:from svg_to_pptx.drawingml.elements import (drawingml_text_frame_width_emu as _drawingml_text_frame_width_emu,+ empty_clip_path_reason as _empty_clip_path_reason,estimate_single_line_text_frame_width as _estimate_single_line_text_frame_width,project_image_errors as _project_image_errors,validate_single_line_text_run_advances as _validate_single_line_text_run_advances,@@ -167,6 +172,7 @@ try:)except ImportError:_drawingml_text_frame_width_emu = None+ _empty_clip_path_reason = None_estimate_single_line_text_frame_width = None_project_image_errors = None_validate_single_line_text_run_advances = None@@ -2803,11 +2809,14 @@ class SVGQualityChecker:cls,container: ET.Element,inherited_xml_space: str,+ *,+ include_container_dx: bool = False,) -> List[Tuple[ET.Element, str, str]] | None:- """Collect inline text while rejecting descendant positioning."""+ """Collect inline text and empty dx markers, rejecting baseline jumps."""if (_normalize_project_text_segments is Noneor _resolve_project_xml_space is None+ or _parse_svg_length is None):return Noneraw_runs: List[Tuple[ET.Element, str, str]] = []@@ -2824,6 +2833,17 @@ class SVGQualityChecker:)except ValueError:return False+ if (+ cls._is_tspan(element)+ and element.get('dx') is not None+ and (element is not container or include_container_dx)+ ):+ try:+ dx = _parse_svg_length(element.get('dx'))+ except ValueError:+ return False+ if dx:+ raw_runs.append((element, xml_space, ''))if element.text:append_run(element, element.text, xml_space)for child in list(element):@@ -2832,7 +2852,9 @@ class SVGQualityChecker:# container: its runs are measured like any other inline run.if not (cls._is_tspan(child) or _local_name(child) == 'a'):return False- if any(child.get(name) is not None for name in ('x', 'y', 'dx', 'dy')):+ if any(child.get(name) is not None for name in ('x', 'y', 'dy')):+ return False+ if child.get('dx') is not None and not cls._is_tspan(child):return Falseif any(name.startswith('data-paragraph-')@@ -2854,13 +2876,14 @@ class SVGQualityChecker:raw_runs: List[Tuple[ET.Element, str, str]],) -> List[Tuple[ET.Element, str]]:"""Normalize collected segments while retaining their style owner."""- normalized = _normalize_project_text_segments([+ normalized = dict(_normalize_project_text_segments([(xml_space, raw)for _owner, xml_space, raw in raw_runs- ])+ ]))return [- (raw_runs[index][0], text)- for index, text in normalized+ (owner, normalized.get(index, ''))+ for index, (owner, _xml_space, raw) in enumerate(raw_runs)+ if not raw or index in normalized]@classmethod@@ -2887,7 +2910,11 @@ class SVGQualityChecker:if member.text:raw_runs.append((text_el, parent_xml_space, member.text))continue- member_runs = cls._inline_text_segments(member, parent_xml_space)+ member_runs = cls._inline_text_segments(+ member,+ parent_xml_space,+ include_container_dx=member is not line_group[0],+ )if member_runs is None:return Noneraw_runs.extend(member_runs)@@ -3055,6 +3082,12 @@ class SVGQualityChecker:'opacity_chain': tuple(reversed(opacity_chain)),'inline_formula': owner.get(_INLINE_FORMULA_ATTR),})+ if not text:+ resolved[-1]['_inline_dx'] = _parse_svg_length(+ owner.get('dx'),+ font_size=font_sizes[id(owner)],+ )+ resolved[-1]['inline_formula'] = Nonereturn cls._coalesce_checker_text_runs(resolved)@staticmethod@@ -3086,7 +3119,7 @@ class SVGQualityChecker:merged: List[Dict] = []previous_signature: Tuple | None = Nonefor run in runs:- if run.get('inline_formula') is not None:+ if run.get('inline_formula') is not None or '_inline_dx' in run:merged.append(run)previous_signature = Nonecontinue@@ -3225,6 +3258,8 @@ class SVGQualityChecker:children = list(text_el)if not children:return None+ line_groups = None+ synthetic_first = Noneif (text_el.text or '').strip():if _classify_paragraph_block is None:return None@@ -3235,6 +3270,23 @@ class SVGQualityChecker:if paragraph is None:return None_base, _extras, _breaks, line_groups, synthetic_first = paragraph+ elif any(+ descendant.get('dx') is not None+ for child in children+ if not cls._is_line_tspan(child)+ for descendant in child.iter()+ ):+ line_groups = []+ for child in children:+ if not (cls._is_tspan(child) or _local_name(child) == 'a'):+ return None+ if cls._is_line_tspan(child):+ line_groups.append([child])+ elif line_groups:+ line_groups[-1].append(child)+ else:+ return None+ if line_groups is not None:try:current_y = _parse_project_geometry_length(text_el.get('y') or '0',@@ -3945,8 +3997,23 @@ class SVGQualityChecker:element: ET.Element,parent_by_id: Dict[int, ET.Element],) -> bool:- """Return whether inherited display or visibility hides an element."""- return _svg_hidden_reason is not None and _svg_hidden_reason(element, parent_by_id) is not None+ """Resolve ordinary suppression and empty clips before measuring visuals."""+ if _svg_hidden_reason is not None and _svg_hidden_reason(element, parent_by_id) is not None:+ return True+ if _empty_clip_path_reason is None or _project_definition_index is None:+ return False+ clipped = []+ root = element+ current = element+ while current is not None:+ if current.get('clip-path') is not None:+ clipped.append(current)+ root = current+ current = parent_by_id.get(id(current))+ if not clipped:+ return False+ definitions, _duplicates = _project_definition_index(root)+ return any(_empty_clip_path_reason(item, definitions, parent_by_id) for item in clipped)def _check_hidden_elements(self, root: ET.Element, result: Dict) -> None:"""Advise which hidden SVG objects will be omitted during native export."""diff --git a/skills/ppt-master/scripts/svg_to_pptx/animation_config.py b/skills/ppt-master/scripts/svg_to_pptx/animation_config.pyindex 457cbe1b..ff5d4386 100644--- a/skills/ppt-master/scripts/svg_to_pptx/animation_config.py+++ b/skills/ppt-master/scripts/svg_to_pptx/animation_config.py@@ -81,6 +81,7 @@ class GroupTarget:chrome: bool = Falsestructurally_static: bool = Falsehas_hyperlink: bool = False+ hidden_reason: str | None = None@dataclass(frozen=True)@@ -197,9 +198,17 @@ def usable_animation_group_id(raw: str | None) -> str | None:return raw if raw and raw.strip() else None-def scan_svg_targets(svg_path: Path) -> tuple[list[GroupTarget], list[str]]:+def scan_svg_targets(+ svg_path: Path,+ *,+ include_hidden: bool = False,+) -> tuple[list[GroupTarget], list[str]]:"""Scan one SVG for top-level visible group ids and anonymous groups."""+ # The converter imports animation policy; defer this shared visibility scan.+ from .drawingml.converter import collect_hidden_visuals+root = ET.parse(str(svg_path)).getroot()+ hidden_by_id = {id(element): reason for element, reason in collect_hidden_visuals(root)}targets: list[GroupTarget] = []anonymous_groups: list[str] = []visual_index = 0@@ -212,9 +221,13 @@ def scan_svg_targets(svg_path: Path) -> tuple[list[GroupTarget], list[str]]:visual_index += 1if tag != 'g':continue+ hidden_reason = hidden_by_id.get(id(child))+ if hidden_reason and not include_hidden:+ continuegroup_id = usable_animation_group_id(child.get('id'))if group_id is None:- anonymous_groups.append(f'{svg_path.stem}: top-level group #{visual_index}')+ if hidden_reason is None:+ anonymous_groups.append(f'{svg_path.stem}: top-level group #{visual_index}')continuerole = child.get('data-pptx-role')placeholder = child.get('data-pptx-placeholder')@@ -248,6 +261,7 @@ def scan_svg_targets(svg_path: Path) -> tuple[list[GroupTarget], list[str]]:order=visual_index,chrome=chrome,structurally_static=structurally_static,+ hidden_reason=hidden_reason,has_hyperlink=any(_tag_name(descendant) == 'a'or descendant.get(SHAPE_HYPERLINK_ATTR) is not None@@ -288,6 +302,7 @@ def scan_project_targets(project_path: Path,*,svg_files: list[Path] | None = None,+ include_hidden: bool = False,) -> tuple[dict[str, list[GroupTarget]], list[str]]:"""Scan selected SVG files, defaulting to ``svg_output/*.svg``."""targets_by_slide: dict[str, list[GroupTarget]] = {}@@ -299,7 +314,7 @@ def scan_project_targets(svg_files = discover_slide_svgs(svg_dir)for svg_path in svg_files:- targets, anonymous = scan_svg_targets(svg_path)+ targets, anonymous = scan_svg_targets(svg_path, include_hidden=include_hidden)targets_by_slide[svg_path.stem] = targetsanonymous_groups.extend(anonymous)@@ -1469,6 +1484,7 @@ def validate_animation_config(targets_by_slide, anonymous_groups = scan_project_targets(project_path,svg_files=svg_files,+ include_hidden=True,)for item in anonymous_groups:warnings.append(f'{item} has no id and cannot be customized in animations.json')@@ -1536,6 +1552,12 @@ def validate_animation_config()continuetarget = known_groups[group_id]+ if target.hidden_reason:+ warnings.append(+ f'animations.json {path} references a group that is '+ f'hidden, not exported ({target.hidden_reason})'+ )+ continueif not isinstance(group_cfg, dict):continuetry:@@ -1583,6 +1605,12 @@ def validate_animation_config(f'animations.json {effect_path}.trigger_shape 'f'references missing group {trigger_shape!r}')+ elif trigger_target.hidden_reason:+ warnings.append(+ f'animations.json {effect_path}.trigger_shape '+ f'references group {trigger_shape!r} that is hidden, '+ f'not exported ({trigger_target.hidden_reason})'+ )elif trigger_target.structurally_static:warnings.append(f'animations.json {effect_path}.trigger_shape '@@ -1629,6 +1657,11 @@ def validate_animation_config('animations.json Morph references missing or ambiguous group: 'f'{slide_name}/{group_id}')+ elif target.hidden_reason:+ warnings.append(+ f'animations.json Morph endpoint {slide_name}/{group_id} '+ f'is hidden, not exported ({target.hidden_reason})'+ )elif target.structurally_static:warnings.append('animations.json Morph references structural group: '@@ -1692,12 +1725,13 @@ def build_group_listing(project_path: Path) -> tuple[list[str], list[str]]:listing reflects exactly what an editor can override. Returns``(lines, anonymous_warnings)``."""- targets_by_slide, anonymous = scan_project_targets(project_path)+ targets_by_slide, anonymous = scan_project_targets(project_path, include_hidden=True)lines: list[str] = []for slide_name, targets in targets_by_slide.items():_require_unique_target_ids(slide_name, targets)- ids = [t.group_id for t in targets if not t.chrome]- chrome_ids = [t.group_id for t in targets if t.chrome]+ ids = [t.group_id for t in targets if not t.chrome and not t.hidden_reason]+ chrome_ids = [t.group_id for t in targets if t.chrome and not t.hidden_reason]+ hidden_ids = [t.group_id for t in targets if t.hidden_reason]if not ids:line = f'{slide_name}: (no animatable groups)'else:@@ -1706,6 +1740,8 @@ def build_group_listing(project_path: Path) -> tuple[list[str], list[str]]:# Name what was dropped so an id like ``takeaway-rule`` is seen# as chrome-by-token rather than silently missing.line += f' [chrome, animates only when named: {", ".join(chrome_ids)}]'+ if hidden_ids:+ line += f' [hidden, not exported: {", ".join(hidden_ids)}]'lines.append(line)return lines, anonymousdiff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.pyindex 56a34aea..c0c68f01 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py@@ -94,6 +94,7 @@ from .styles import ()from .elements import (complete_preset_adjustments,+ empty_clip_path_reason,convert_rect, convert_circle, convert_ellipse,convert_line, convert_path,convert_polygon, convert_polyline,@@ -1761,17 +1762,27 @@ def _geometry_trace_metadata(elem: ET.Element, result: ShapeResult) -> dict[str,def collect_hidden_visuals(root: ET.Element) -> list[tuple[ET.Element, str]]:"""List suppressed visual objects while preserving native transport carriers."""parents = {id(child): parent for parent in root.iter() for child in parent}+ definitions, _duplicates = project_definition_index(root)hidden: list[tuple[ET.Element, str]] = []- def visit(element: ET.Element) -> None:+ def visit(element: ET.Element) -> bool:tag = _local_tag(element)if tag in _NON_VISUAL_TAGS:- return+ return Falsereason = svg_hidden_reason(element, parents, preserve_native_carriers=True)- if reason and (tag not in {'g', 'a', 'svg'} or reason == 'display:none'):+ clip_reason = empty_clip_path_reason(element, definitions, parents)+ reason = reason or clip_reason+ hidden_before_children = len(hidden)+ children_visible = [visit(child) for child in element]+ container = tag in {'g', 'a', 'svg'}+ if container and reason != 'display:none' and clip_reason is None:+ if any(children_visible):+ return True+ if reason is None and tag != 'svg' and len(hidden) > hidden_before_children:+ reason = 'hidden descendants'+ if reason:hidden.append((element, reason))- for child in element:- visit(child)+ return reason is None and (not container or any(children_visible))visit(root)return hidden@@ -1832,6 +1843,10 @@ def convert_element(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Nonereturn Nonehidden_reason = svg_hidden_reason(elem, ctx.parent_by_id, preserve_native_carriers=True)+ clip_reason = empty_clip_path_reason(elem, ctx.defs, ctx.parent_by_id)+ if clip_reason:+ trace('skip', reason=clip_reason)+ return Noneif hidden_reason and (tag not in {'g', 'a'} or hidden_reason == 'display:none'):trace('skip', reason=hidden_reason)return Nonediff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex 94a236dc..72835254 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -82,6 +82,7 @@ from .utils import (parse_project_stroke_dasharray,quantize_ooxml_alpha,project_definition_index,+ svg_hidden_reason,matrix_multiply, parse_transform_matrix, parse_transform_operations,transform_point, _xml_escape,)@@ -3894,6 +3895,35 @@ def _nested_crop_clip_preset_geometry_error()+def _visible_clip_shapes(+ clip: ET.Element,+ parent_by_id: dict[int, ET.Element],+) -> list[ET.Element]:+ """Resolve clip children with the same inherited visibility as visuals."""+ return [+ child for child in clip+ if child.tag not in _CLIP_NON_VISUAL_ELEMENTS+ and svg_hidden_reason(child, parent_by_id) is None+ ]+++def empty_clip_path_reason(+ element: ET.Element,+ definitions: dict[str, ET.Element],+ parent_by_id: dict[int, ET.Element],+) -> str | None:+ """Identify a valid clip reference whose children are all hidden."""+ clip_id = resolve_url_id(element.get('clip-path', ''))+ clip = definitions.get(clip_id)+ if clip is not None and clip.tag == f'{{{SVG_NS}}}clipPath':+ if (+ any(child.tag not in _CLIP_NON_VISUAL_ELEMENTS for child in clip)+ and not _visible_clip_shapes(clip, parent_by_id)+ ):+ return f'empty clip: url(#{clip_id})'+ return None++def project_clip_path_errors(root: ET.Element) -> list[str]:"""Return clip-path errors that would otherwise degrade picture geometry."""definitions, duplicates = project_definition_index(root)@@ -3961,10 +3991,9 @@ def project_clip_path_errors(root: ET.Element) -> list[str]:f'{clip_label} cannot use {", ".join(clip_rules)}; native ''picture geometry has no equivalent winding-rule control')- visual_children = [- child for child in list(clip)- if child.tag not in _CLIP_NON_VISUAL_ELEMENTS- ]+ visual_children = _visible_clip_shapes(clip, parent_by_id)+ if not visual_children and empty_clip_path_reason(elem, definitions, parent_by_id):+ continueif len(visual_children) != 1:errors.add(f'{clip_label} must contain exactly one direct supported shape'@@ -4047,16 +4076,12 @@ def _resolve_clip_geometry(if clip_tag != 'clipPath':return DEFAULT- # Find the first shape child of the clipPath- shape = None- for child in clip_elem:- child_tag = child.tag.replace(f'{{{SVG_NS}}}', '')- if child_tag in ('circle', 'ellipse', 'rect', 'path', 'polygon'):- shape = child- break-- if shape is None:+ shapes = _visible_clip_shapes(clip_elem, ctx.parent_by_id)+ if not shapes:return DEFAULT+ if len(shapes) != 1:+ raise ValueError('clipPath must contain exactly one direct supported shape')+ shape = shapes[0]shape_tag = shape.tag.replace(f'{{{SVG_NS}}}', '')is_obb = clip_elem.get('clipPathUnits') == 'objectBoundingBox'@@ -5301,17 +5326,12 @@ def _resolve_nested_svg_clip_geometry(if not clip_id or clip_id not in ctx.defs:return defaultclip_elem = ctx.defs[clip_id]- shape = next(- (- child- for child in clip_elem- if child.tag.rsplit('}', 1)[-1]- in {'circle', 'ellipse', 'rect', 'path', 'polygon'}- ),- None,- )- if shape is None:+ shapes = _visible_clip_shapes(clip_elem, ctx.parent_by_id)+ if not shapes:return default+ if len(shapes) != 1:+ raise ValueError('clipPath must contain exactly one direct supported shape')+ shape = shapes[0]if (clip_elem.get('clipPathUnits', 'userSpaceOnUse')!= 'userSpaceOnUse'@@ -5369,7 +5389,7 @@ def _resolve_nested_svg_clip_geometry()-def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult:+def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:"""Convert a nested <svg> sprite-crop wrapper to a DrawingML picture.Pattern produced by pptx_to_svg::@@ -5383,6 +5403,8 @@ def convert_nested_svg(elem: ET.Element, ctx: ConvertContext) -> ShapeResult:"""crop = parse_project_nested_svg_crop(elem)image_elem = crop.image+ if empty_clip_path_reason(image_elem, ctx.defs, ctx.parent_by_id):+ return Nonesource = load_project_image_source(image_elem,ctx.svg_dir,diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.pyindex a427e516..889ba379 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py@@ -502,6 +502,8 @@ def build_stroke_xml(return '<a:ln><a:noFill/></a:ln>'source_width = parse_svg_length(_get_attr(elem, 'stroke-width', ctx), 1.0)+ if source_width <= 0:+ return '<a:ln><a:noFill/></a:ln>'width_emu = px_to_emu(source_width * _effective_stroke_scale(elem, ctx))validate_ooxml_line_width(width_emu)diff --git a/skills/ppt-master/scripts/tests/test_native_export_guards.py b/skills/ppt-master/scripts/tests/test_native_export_guards.pyindex 144a65a1..b968971f 100644--- a/skills/ppt-master/scripts/tests/test_native_export_guards.py+++ b/skills/ppt-master/scripts/tests/test_native_export_guards.py@@ -4,10 +4,11 @@from __future__ import annotationsimport io+import jsonimport sysimport tempfileimport unittest-from contextlib import redirect_stderr+from contextlib import redirect_stderr, redirect_stdoutfrom pathlib import Pathfrom unittest.mock import patchfrom xml.etree import ElementTree as ET@@ -18,9 +19,16 @@ if str(SCRIPTS_DIR) not in sys.path:sys.path.insert(0, str(SCRIPTS_DIR))from pptx_shapes.formula import OOXML_COORDINATE_MAX # noqa: E402+from animation_config import main as animation_config_main # noqa: E402from pptx_gradients import native_gradient_metadata, preserved_native_gradient_xml # noqa: E402from svg_finalize.flatten_tspan import flatten_text_with_tspans # noqa: E402from svg_quality.checker import SVGQualityChecker # noqa: E402+from svg_to_pptx.animation_config import ( # noqa: E402+ build_group_listing,+ build_scaffold,+ scan_svg_targets,+ validate_animation_config,+)from svg_to_pptx.drawingml.converter import ( # noqa: E402SvgNativeConversionError,convert_svg_to_slide_shapes,@@ -33,6 +41,10 @@ NS = {'a': 'http://schemas.openxmlformats.org/drawingml/2006/main','p': 'http://schemas.openxmlformats.org/presentationml/2006/main',}+PNG_DATA = (+ 'data:image/png;base64,'+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC'+)class NativeExportGuardTests(unittest.TestCase):@@ -109,6 +121,171 @@ class NativeExportGuardTests(unittest.TestCase):self.assertTrue(any('hidden' in warning and 'not be exported' in warningfor warning in report['warnings']), report['warnings'])+ def _clipped_image(self, shapes: str, clip_attributes: str = '') -> None:+ self._svg(+ f'<defs><clipPath id="clip" {clip_attributes}>{shapes}</clipPath></defs>'+ '<image id="picture" x="100" y="100" width="200" height="100" '+ f'preserveAspectRatio="xMidYMid slice" href="{PNG_DATA}" clip-path="url(#clip)"/>'+ )++ def test_hidden_clip_shapes_omit_picture_and_report_empty_clip(self) -> None:+ for hiding in ('visibility="hidden"', 'style="visibility:hidden"',+ 'display="none"', 'style="display:none"'):+ for inherited in (False, True):+ with self.subTest(hiding=hiding, inherited=inherited):+ self._clipped_image(+ '<rect x="100" y="100" width="200" height="100" '+ f'{"" if inherited else hiding}/>',+ hiding if inherited else '',+ )+ self.assertFalse(self._export().findall('.//p:pic', NS))+ report = self._check()+ self.assertFalse(report['errors'], report['errors'])+ self.assertTrue(any(+ 'Hidden element <image id="picture"> will not be exported' in warning+ and 'empty clip: url(#clip)' in warning and 'advisory only' in warning+ for warning in report['warnings']+ ), report['warnings'])++ def test_visible_clip_keeps_picture_crop_and_ignores_hidden_siblings(self) -> None:+ visible = '<rect x="100" y="100" width="200" height="100" rx="10"/>'+ self._clipped_image(visible)+ picture = self._export().find('.//p:pic', NS)+ crop = picture.find('.//a:srcRect', NS).attrib+ self.assertEqual(crop, {'l': '0', 't': '25000', 'r': '0', 'b': '25000'})+ for shapes, clip_attributes in (+ ('<circle cx="200" cy="150" r="50" visibility="hidden"/>' + visible, ''),+ (visible + '<rect display="none" width="1" height="1"/>', ''),+ (visible.replace('rx="10"', 'rx="10" visibility="visible"'), 'visibility="hidden"'),+ ):+ with self.subTest(shapes=shapes, clip_attributes=clip_attributes):+ self._clipped_image(shapes, clip_attributes)+ self.assertFalse(self._check()['errors'])+ actual = self._export().find('.//p:pic', NS)+ self.assertEqual(actual.find('.//a:srcRect', NS).attrib, crop)+ self.assertEqual(actual.find('.//a:prstGeom', NS).get('prst'), 'roundRect')++ def test_empty_clip_is_omitted_from_checker_coordinate_measurement(self) -> None:+ self._clipped_image('<rect visibility="hidden"/>')+ tree = ET.parse(self.svg_path)+ tree.getroot().find('{http://www.w3.org/2000/svg}image').set('x', '100000000000000000000')+ tree.write(self.svg_path, encoding='utf-8')+ self.assertFalse(self._check()['errors'])+ self.assertFalse(self._export().findall('.//p:pic', NS))++ def test_clip_still_rejects_multiple_visible_shapes(self) -> None:+ self._clipped_image('<rect x="100" y="100" width="200" height="100"/>' * 2)+ self.assertTrue(any('exactly one' in error for error in self._check()['errors']))+ with self.assertRaisesRegex(SvgNativeConversionError, 'exactly one'):+ self._export()+ self._clipped_image('<rect visibility="hidden"/><circle display="none"/>')+ self.assertFalse(self._export().findall('.//p:pic', NS))++ def test_nested_crop_uses_visible_clip_shape_and_omits_empty_clip(self) -> None:+ for hidden in (False, True):+ with self.subTest(hidden=hidden):+ self._svg(+ '<defs><clipPath id="clip"><circle display="none"/>'+ '<rect x="0.25" y="0.25" width="0.5" height="0.5" rx="0.1" '+ f'visibility="{"hidden" if hidden else "visible"}"/></clipPath></defs>'+ '<svg x="100" y="100" width="200" height="200" viewBox="0.25 0.25 0.5 0.5" '+ 'data-pptx-crop="1" overflow="hidden" preserveAspectRatio="none">'+ '<image x="0" y="0" width="1" height="1" preserveAspectRatio="none" '+ f'href="{PNG_DATA}" clip-path="url(#clip)"/></svg>'+ )+ self.assertFalse(self._check()['errors'])+ pictures = self._export().findall('.//p:pic', NS)+ self.assertEqual(len(pictures), 0 if hidden else 1)+ if not hidden:+ self.assertEqual(pictures[0].find('.//a:prstGeom', NS).get('prst'), 'roundRect')+ self.assertEqual(pictures[0].find('.//a:srcRect', NS).attrib,+ {'l': '25000', 't': '25000', 'r': '25000', 'b': '25000'})++ def test_zero_width_strokes_export_no_fill_including_style_and_inheritance(self) -> None:+ for width in ('0', '0.5'):+ for placement in ('attribute', 'style', 'inherited_attribute', 'inherited_style'):+ with self.subTest(width=width, placement=placement):+ attribute = (f'style="stroke-width:{width}"' if placement.endswith('style')+ else f'stroke-width="{width}"')+ direct = '' if placement.startswith('inherited') else attribute+ parent = attribute if placement.startswith('inherited') else ''+ self._svg(+ f'<g stroke="#123456" data-pptx-bounds="80 80 340 100" {parent}>'+ f'<line x1="100" y1="100" x2="200" y2="150" {direct}/>'+ f'<rect x="300" y="100" width="100" height="50" {direct}/></g>'+ )+ self.assertFalse(self._check()['errors'])+ strokes = self._export().findall('.//p:sp/p:spPr/a:ln', NS)+ self.assertEqual(len(strokes), 2)+ for stroke in strokes:+ if width == '0':+ self.assertEqual(stroke.attrib, {})+ self.assertIsNotNone(stroke.find('a:noFill', NS))+ self.assertIsNone(stroke.find('a:solidFill', NS))+ else:+ self.assertEqual(stroke.get('w'), '4762')+ self.assertIsNotNone(stroke.find('a:solidFill', NS))++ def _motion_project(self, hiding: str, child_attributes: str = '') -> None:+ self._svg(+ f'<g id="shape" {hiding} data-pptx-bounds="80 70 300 150">'+ f'<rect x="100" y="100" width="100" height="50" {child_attributes}/></g>'+ '<g id="shown"><rect x="400" y="100" width="100" height="50"/></g>'+ )+ output = self.root / 'svg_output'+ output.mkdir(exist_ok=True)+ for name in ('01', '02'):+ (output / f'{name}.svg').write_text(self.svg_path.read_text(encoding='utf-8'), encoding='utf-8')++ def test_hidden_animation_groups_are_excluded_from_scan_listing_and_scaffold(self) -> None:+ for hiding in ('display="none"', 'style="display:none"',+ 'visibility="hidden"', 'style="visibility:hidden"'):+ with self.subTest(hiding=hiding):+ self._motion_project(hiding)+ targets, anonymous = scan_svg_targets(self.root / 'svg_output/01.svg')+ self.assertEqual([target.group_id for target in targets], ['shown'])+ self.assertFalse(anonymous)+ self.assertEqual(build_group_listing(self.root)[0], [+ f'{name}: shown [hidden, not exported: shape]' for name in ('01', '02')+ ])+ for slide in build_scaffold(self.root)['slides'].values():+ self.assertEqual(slide['groups'], {'shown': {}})++ def test_hidden_animation_references_fail_validation_before_morph_export(self) -> None:+ self._motion_project('display="none"')+ config = {+ 'version': 1,+ 'defaults': {'animation': {'effect': 'none'}},+ 'slides': {+ '01': {'groups': {+ 'shape': {'effect': 'fade', 'order': 1},+ 'shown': {'effect': 'fade', 'trigger': 'on-click', 'trigger_shape': 'shape'},+ }},+ '02': {'transition': {'effect': 'morph', 'duration': 1},+ 'morph': {'from': '01', 'pairs': {'key': {'from': 'shape', 'to': 'shape'}}}},+ },+ }+ messages = validate_animation_config(self.root, config)+ self.assertEqual(len(messages), 4, messages)+ self.assertTrue(all('hidden, not exported' in message for message in messages), messages)+ self.assertTrue(any('trigger_shape' in message for message in messages))+ self.assertTrue(any('groups["shape"]' in message for message in messages))+ for name in ('01', '02'):+ self.assertTrue(any(f'Morph endpoint {name}/shape' in message for message in messages))+ (self.root / 'animations.json').write_text(json.dumps(config), encoding='utf-8')+ with redirect_stderr(io.StringIO()) as stderr, redirect_stdout(io.StringIO()):+ self.assertEqual(animation_config_main(['validate', str(self.root)]), 1)+ self.assertIn('hidden, not exported', stderr.getvalue())++ def test_visibility_override_remains_an_exported_animation_target(self) -> None:+ self._motion_project('visibility="hidden"', 'visibility="visible"')+ targets, _anonymous = scan_svg_targets(self.root / 'svg_output/01.svg')+ self.assertEqual([target.group_id for target in targets], ['shape', 'shown'])+ self.assertIn('shape', build_scaffold(self.root)['slides']['01']['groups'])+ self.assertEqual(len(self._export().findall('.//p:sp', NS)), 2)+ config = {'slides': {'01': {'groups': {'shape': {'effect': 'fade'}}}}}+ self.assertEqual(validate_animation_config(self.root, config), [])+def test_display_none_group_cannot_be_overridden_by_descendants(self) -> None:for hiding in ('display="none"', 'style="display:none"'):with self.subTest(hiding=hiding):diff --git a/skills/ppt-master/scripts/tests/test_svg_quality_checker.py b/skills/ppt-master/scripts/tests/test_svg_quality_checker.pyindex 460d2d69..ede9a219 100644--- a/skills/ppt-master/scripts/tests/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/tests/test_svg_quality_checker.py@@ -37,6 +37,126 @@ def _empty_result() -> dict:class SVGQualityCheckerBoundsTests(unittest.TestCase):+ @staticmethod+ def _text_bounds(root: ET.Element, *, include_headroom: bool = False) -> tuple:+ text = root.find(f'.//{{{SVG_NS}}}text')+ parents = {id(child): parent for parent in root.iter() for child in parent}+ sizes = checker_module._resolve_project_font_sizes(root)+ spacings = checker_module._resolve_project_letter_spacings(root, sizes)+ return SVGQualityChecker._estimated_text_bounds(+ text, parents, sizes, spacings, include_headroom=include_headroom,+ )++ def test_inline_dx_triggers_module_and_canvas_overflow_for_each_anchor(self) -> None:+ for anchor, x in (('start', 1200), ('middle', 1200), ('end', 100)):+ with self.subTest(anchor=anchor):+ root = _parse_svg(+ '<g id="title" data-pptx-bounds="80 70 1190 80">'+ f'<text x="{x}" y="110" text-anchor="{anchor}" font-size="24">'+ 'A<tspan dx="400">B</tspan></text></g>',+ 'font-family="Arial"', view_box='0 0 1280 720',+ )+ result = _empty_result()+ SVGQualityChecker()._check_text_bounds(root, result)+ self.assertTrue(any('root viewBox on the horizontal axis' in error+ for error in result['errors']), result)+ self.assertFalse(any('Cannot verify' in warning for warning in result['warnings']), result)+ root.find(f'.//{{{SVG_NS}}}text').set('x', '600')+ root.find(f'{{{SVG_NS}}}g').set('data-pptx-bounds', '580 70 90 80')+ module_result = _empty_result()+ SVGQualityChecker()._check_text_bounds(root, module_result)+ self.assertTrue(any('data-pptx-bounds on the horizontal axis' in error+ for error in module_result['errors']), module_result)++ def test_inline_dx_uses_signed_advances_and_preserves_anchor(self) -> None:+ for anchor in ('start', 'middle', 'end'):+ for headroom in (False, True):+ with self.subTest(anchor=anchor, headroom=headroom):+ template = (+ f'<text x="600" y="110" text-anchor="{anchor}" font-size="24">'+ 'A<tspan dx="{dx}">B</tspan></text>'+ )+ bounds = {}+ for dx in (0, 400, -400):+ root = _parse_svg(template.format(dx=dx), 'font-family="Arial"')+ bounds[dx] = self._text_bounds(root, include_headroom=headroom)+ self.assertIsNotNone(bounds[dx])+ left0, _top, right0, _bottom = bounds[0]+ left, _top, right, _bottom = bounds[400]+ self.assertAlmostEqual((right - left) - (right0 - left0), 400)+ if anchor == 'start':+ self.assertAlmostEqual(left, 600)+ elif anchor == 'middle':+ self.assertAlmostEqual((left + right) / 2, 600)+ else:+ self.assertAlmostEqual(right, 600)+ single = _parse_svg(+ f'<text x="600" y="110" text-anchor="{anchor}" font-size="24">A</text>',+ 'font-family="Arial"',+ )+ self.assertEqual(bounds[-400], self._text_bounds(single, include_headroom=headroom))++ def test_end_anchor_negative_dx_has_no_false_overflow(self) -> None:+ root = _parse_svg(+ '<g id="title" data-pptx-bounds="1100 70 180 80">'+ '<text x="1270" y="110" text-anchor="end" font-size="24">'+ 'ABCD<tspan dx="-20">EFGH</tspan></text></g>',+ 'font-family="Arial"', view_box='0 0 1280 720',+ )+ result = _empty_result()+ SVGQualityChecker()._check_text_bounds(root, result)+ self.assertEqual(result, _empty_result())++ def test_inline_dx_measures_cjk_links_empty_spans_and_line_start(self) -> None:+ for content in (+ '中<tspan dx="400">文</tspan>',+ 'A<a href="https://example.com"><tspan dx="400">B</tspan></a>',+ '<tspan dx="400">B</tspan>',+ '<tspan dx="400"/><tspan>B</tspan>',+ '<tspan dx="250">A<tspan dx="150">B</tspan>C</tspan>D',+ ):+ with self.subTest(content=content):+ root = _parse_svg(+ f'<text x="1200" y="110" font-size="24">{content}</text>',+ 'font-family="Arial"', view_box='0 0 1280 720',+ )+ bounds = self._text_bounds(root)+ self.assertIsNotNone(bounds)+ self.assertGreater(bounds[2], 1600)+ result = _empty_result()+ SVGQualityChecker()._check_text_bounds(root, result)+ self.assertTrue(any('root viewBox' in error for error in result['errors']), result)++ def test_non_scalar_and_percentage_dx_remain_unmeasurable(self) -> None:+ for dx in ('20%', '10 20', '10,20', 'calc(20 + 30)'):+ with self.subTest(dx=dx):+ root = _parse_svg(+ f'<text x="1200" y="110" font-size="24">A<tspan dx="{dx}">B</tspan></text>',+ 'font-family="Arial"', view_box='0 0 1280 720',+ )+ self.assertIsNone(self._text_bounds(root))+ result = _empty_result()+ SVGQualityChecker()._check_text_bounds(root, result)+ self.assertTrue(any('Cannot verify root viewBox bounds' in warning+ for warning in result['warnings']), result)++ def test_positioned_lines_count_starter_and_inline_dx_once(self) -> None:+ root = _parse_svg(+ '<text x="100" y="110" font-size="24">'+ '<tspan x="100" dx="10">A</tspan><tspan dx="400">B</tspan>'+ '<tspan x="100" dx="-5" dy="30">C</tspan><tspan dx="-20">D</tspan></text>',+ 'font-family="Arial"',+ )+ parents = {id(child): parent for parent in root.iter() for child in parent}+ sizes = checker_module._resolve_project_font_sizes(root)+ spacings = checker_module._resolve_project_letter_spacings(root, sizes)+ lines = SVGQualityChecker._resolved_text_lines(root[0], parents, sizes, spacings)+ self.assertIsNotNone(lines)+ self.assertEqual([(line[1], line[2]) for line in lines], [(110, 110), (95, 140)])+ self.assertEqual([+ [run['_inline_dx'] for run in line[3] if '_inline_dx' in run] for line in lines+ ], [[400], [-20]])+def test_leading_direct_text_and_positioned_tspans_are_estimable(self) -> None:root = _parse_svg('<g id="module" data-pptx-bounds="0 0 1000 1000">'