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
feat(pptx-objects): extend native table and chart reconstruction
hugohe3ac8bb9df7271
diff --git a/skills/ppt-master/scripts/pptx_to_svg/chart_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/chart_to_svg.pyindex 719e23b6..2027ffef 100644--- a/skills/ppt-master/scripts/pptx_to_svg/chart_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/chart_to_svg.py@@ -125,15 +125,43 @@ def _payload_from_chart_xml(]if not chart_nodes:raise _UnsupportedChart("unsupported-chart-plot")+ date_system = chart_root.find("c:date1904", C_NS)+ if date_system is not None and (+ not set(date_system.attrib).issubset({"val"}) or list(date_system)+ ):+ raise _UnsupportedChart("unsupported-date-system")+ uses_1904_dates = _strict_axis_bool(+ date_system,+ date_system is not None,+ )if len(chart_nodes) > 1:- raise _UnsupportedChart("unsupported-combo-chart")- if plot_area.find("c:dateAx", C_NS) is not None:- raise _UnsupportedChart("unsupported-date-axis")+ if uses_1904_dates and any(+ _category_cache_is_numeric(chart) for chart in chart_nodes+ ):+ raise _UnsupportedChart("unsupported-date-system")+ payload, visual_styles = _combo_payload(+ chart_root,+ plot_area,+ chart_nodes,+ xfrm,+ palette=palette,+ )+ return payload, visual_styleschart = chart_nodes[0]chart_tag = _local_name(chart.tag)+ has_date_axis = plot_area.find("c:dateAx", C_NS) is not None+ if uses_1904_dates and has_date_axis:+ raise _UnsupportedChart("unsupported-date-system")+ if has_date_axis:+ _validate_canonical_series_order(+ [chart],+ "unsupported-chart-series-order",+ )if chart_tag in {"area3DChart", "bar3DChart", "line3DChart", "pie3DChart", "surface3DChart"}:raise _UnsupportedChart("unsupported-3d-chart")+ if has_date_axis and chart_tag not in {"areaChart", "stockChart"}:+ raise _UnsupportedChart("unsupported-date-axis")if chart_tag == "barChart":payload = _category_payload(chart, _bar_chart_type(chart), xfrm)elif chart_tag in {"areaChart", "lineChart", "ofPieChart", "pieChart", "doughnutChart"}:@@ -144,20 +172,374 @@ def _payload_from_chart_xml("pieChart": "pie","doughnutChart": "doughnut",}[chart_tag]- payload = _category_payload(chart, chart_type, xfrm)+ payload = _category_payload(+ chart,+ chart_type,+ xfrm,+ category_kind="date" if has_date_axis else "text",+ )elif chart_tag == "scatterChart":payload = _xy_payload(chart, "scatter", xfrm)elif chart_tag == "bubbleChart":payload = _xy_payload(chart, "bubble", xfrm)+ elif chart_tag == "stockChart":+ payload, visual_styles = _stock_payload(+ chart_root,+ plot_area,+ chart,+ xfrm,+ palette=palette,+ )+ return payload, visual_styleselse:raise _UnsupportedChart("unsupported-chart-type")+ if has_date_axis:+ payload["axes"] = _single_axis_contract(+ plot_area,+ chart,+ category_kind="date",+ cross_between="midCat",+ )+ expected_category_format = payload["axes"]["category"].get(+ "number_format",+ "m/d/yyyy",+ )+ if _numeric_category_cache_format(chart) != expected_category_format:+ raise _UnsupportedChart("unsupported-chart-category-format")+visual_styles = _validate_chart_semantics(payload,plot_area,chart,palette=palette,+ validate_axes=not has_date_axis,+ )+ _apply_chart_metadata(payload, chart_root, plot_area, chart)+ return payload, visual_styles+++def _combo_payload(+ chart_root: ET.Element,+ plot_area: ET.Element,+ chart_nodes: list[ET.Element],+ xfrm: Xfrm,+ *,+ palette: ColorPalette | None,+) -> tuple[dict[str, Any], list[SeriesVisualStyle]]:+ series_indices_by_plot = [+ _plot_series_indices(chart, "unsupported-combo-series-order")+ for chart in chart_nodes+ ]+ flat_series_indices = [+ index+ for series_indices in series_indices_by_plot+ for index in series_indices+ ]+ if sorted(flat_series_indices) != list(range(len(flat_series_indices))):+ raise _UnsupportedChart("unsupported-combo-series-order")+ axes_by_id = _axis_nodes_by_id(plot_area)+ if not axes_by_id:+ raise _UnsupportedChart("unsupported-combo-chart")+ axes: dict[str, dict[str, Any]] = {}+ axis_pairs: dict[str, tuple[str, str]] = {}+ primary_categories: list[Any] | None = None+ primary_categories_are_numeric = False+ plots: list[dict[str, Any]] = []+ visual_styles: list[SeriesVisualStyle] = []+ colors: list[str] = []+ referenced_axis_ids: set[str] = set()++ for chart, series_indices in zip(chart_nodes, series_indices_by_plot):+ chart_tag = _local_name(chart.tag)+ if chart_tag == "barChart":+ if _bar_chart_type(chart) != "column":+ raise _UnsupportedChart("unsupported-combo-chart")+ chart_type = "column"+ elif chart_tag == "lineChart":+ chart_type = "line"+ elif chart_tag == "areaChart":+ chart_type = "area"+ else:+ raise _UnsupportedChart("unsupported-combo-chart")++ cat_id, cat_axis, val_id, val_axis = _plot_axis_pair(chart, axes_by_id)+ if _local_name(cat_axis.tag) != "catAx":+ raise _UnsupportedChart("unsupported-combo-chart")+ val_position = _element_val(val_axis.find("c:axPos", C_NS))+ if val_position == "l":+ axis_name = "primary"+ category_role = "category"+ value_role = "value"+ allowed_value_crosses = {"autoZero"}+ elif val_position == "r":+ axis_name = "secondary"+ category_role = "secondary_category"+ value_role = "secondary_value"+ allowed_value_crosses = {"max"}+ else:+ raise _UnsupportedChart("unsupported-combo-chart")++ axis_pair = (cat_id, val_id)+ previous_pair = axis_pairs.get(axis_name)+ if previous_pair is not None and previous_pair != axis_pair:+ raise _UnsupportedChart("unsupported-combo-chart")+ if any(+ set(existing_pair).intersection(axis_pair)+ for name, existing_pair in axis_pairs.items()+ if name != axis_name+ ):+ raise _UnsupportedChart("unsupported-combo-chart")+ axis_pairs[axis_name] = axis_pair++ category_axis = _axis_config_from_xml(+ cat_axis,+ role=category_role,+ expected_cross_axis_id=val_id,+ allowed_crosses={"autoZero"},+ expected_cross_between=None,+ )+ value_axis = _axis_config_from_xml(+ val_axis,+ role=value_role,+ expected_cross_axis_id=cat_id,+ allowed_crosses=allowed_value_crosses,+ expected_cross_between="between",+ )+ for role, config in (+ (category_role, category_axis),+ (value_role, value_axis),+ ):+ if role in axes and axes[role] != config:+ raise _UnsupportedChart("unsupported-combo-chart")+ axes[role] = config+ referenced_axis_ids.update((cat_id, val_id))++ categories_are_numeric = _category_cache_is_numeric(chart)+ if categories_are_numeric:+ expected_category_format = category_axis.get(+ "number_format",+ "General",+ )+ if _numeric_category_cache_format(chart) != expected_category_format:+ raise _UnsupportedChart("unsupported-combo-category-format")+ plot_payload = _category_payload(+ chart,+ chart_type,+ xfrm,+ category_kind="numeric" if categories_are_numeric else "text",+ )+ if axis_name == "primary" and primary_categories is None:+ primary_categories = list(plot_payload["categories"])+ primary_categories_are_numeric = categories_are_numeric+ plot_styles = _validate_chart_semantics(+ plot_payload,+ plot_area,+ chart,+ palette=palette,+ validate_axes=False,+ )+ visual_styles.extend(plot_styles)+ colors.extend(+ str(color)+ for color in plot_payload.get("style", {}).get("colors", [])+ )+ _apply_plot_data_labels(plot_payload, chart)+ plot_entry: dict[str, Any] = {+ "axis": axis_name,+ "categories": list(plot_payload["categories"]),+ "category_numeric": categories_are_numeric,+ "series": plot_payload["series"],+ "series_indices": series_indices,+ "type": chart_type,+ }+ for key in ("data_labels", "grouping", "line_style"):+ if plot_payload.get(key) is not None:+ plot_entry[key] = plot_payload[key]+ plots.append(plot_entry)++ if primary_categories is None or not plots:+ raise _UnsupportedChart("unsupported-combo-chart")+ if referenced_axis_ids != set(axes_by_id):+ raise _UnsupportedChart("unsupported-combo-chart")++ category_layouts = {+ (+ bool(plot["category_numeric"]),+ tuple(plot["categories"]),+ )+ for plot in plots+ }+ if len(category_layouts) == 1:+ for plot in plots:+ plot.pop("categories")+ plot.pop("category_numeric")+ payload: dict[str, Any] = {+ **_bounds_payload(xfrm),+ "axes": axes,+ "categories": primary_categories,+ "plots": plots,+ "type": "combo",+ }+ if primary_categories_are_numeric:+ payload["category_numeric"] = True+ if colors:+ payload["style"] = {"colors": colors}+ _apply_chart_metadata(+ payload,+ chart_root,+ plot_area,+ chart_nodes[0],+ include_plot_labels=False,)+ return payload, visual_styles+++def _validate_stock_semantics(+ plot_area: ET.Element,+ chart: ET.Element,+) -> None:+ allowed_children = {"axId", "dLbls", "hiLowLines", "ser", "upDownBars"}+ if any(_local_name(child.tag) not in allowed_children for child in chart):+ raise _UnsupportedChart("unsupported-stock-chart")+ if plot_area.find("c:dTable", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-data-table")+ for tag in ("dropLines", "errBars", "trendline"):+ if chart.find(f".//c:{tag}", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-analysis-features")+ if _data_labels_payload(chart.find("c:dLbls", C_NS)) is not None:+ raise _UnsupportedChart("unsupported-chart-data-labels")+ if len(chart.findall("c:dLbls", C_NS)) > 1:+ raise _UnsupportedChart("unsupported-stock-chart")++ hi_low_lines = chart.findall("c:hiLowLines", C_NS)+ up_down_bars = chart.findall("c:upDownBars", C_NS)+ if len(hi_low_lines) != 1 or len(up_down_bars) != 1:+ raise _UnsupportedChart("unsupported-stock-chart")+ hi_low_styles = hi_low_lines[0].findall("c:spPr", C_NS)+ if (+ hi_low_lines[0].attrib+ or len(hi_low_styles) > 1+ or any(_local_name(child.tag) != "spPr" for child in hi_low_lines[0])+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ up_down = up_down_bars[0]+ if up_down.attrib or any(+ _local_name(child.tag) not in {"downBars", "gapWidth", "upBars"}+ for child in up_down+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ gap_widths = up_down.findall("c:gapWidth", C_NS)+ if (+ len(gap_widths) != 1+ or set(gap_widths[0].attrib) != {"val"}+ or list(gap_widths[0])+ or _element_val(gap_widths[0]) != "150"+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ for tag in ("upBars", "downBars"):+ nodes = up_down.findall(f"c:{tag}", C_NS)+ styles = nodes[0].findall("c:spPr", C_NS) if nodes else []+ if (+ len(nodes) != 1+ or nodes[0].attrib+ or len(styles) > 1+ or any(_local_name(child.tag) != "spPr" for child in nodes[0])+ ):+ raise _UnsupportedChart("unsupported-stock-chart")++ allowed_series_children = {+ "cat", "extLst", "idx", "marker", "order", "smooth", "spPr",+ "tx", "val",+ }+ for series_node in chart.findall("c:ser", C_NS):+ if any(+ _local_name(child.tag) not in allowed_series_children+ for child in series_node+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ for child_name in allowed_series_children - {"extLst"}:+ if len(series_node.findall(f"c:{child_name}", C_NS)) > 1:+ raise _UnsupportedChart("unsupported-stock-chart")+ marker = series_node.find("c:marker", C_NS)+ symbol = marker.find("c:symbol", C_NS) if marker is not None else None+ if (+ marker is not None+ and (+ marker.attrib+ or len(marker) != 1+ or symbol is None+ or set(symbol.attrib) != {"val"}+ or list(symbol)+ or _element_val(symbol) != "none"+ )+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ smooth = series_node.find("c:smooth", C_NS)+ if smooth is not None:+ if set(smooth.attrib) != {"val"} or list(smooth):+ raise _UnsupportedChart("unsupported-stock-chart")+ if _strict_axis_bool(smooth, False):+ raise _UnsupportedChart("unsupported-stock-chart")+ for child_name in ("idx", "order"):+ child = series_node.find(f"c:{child_name}", C_NS)+ if child is None or set(child.attrib) != {"val"} or list(child):+ raise _UnsupportedChart("unsupported-stock-chart")+++def _stock_payload(+ chart_root: ET.Element,+ plot_area: ET.Element,+ chart: ET.Element,+ xfrm: Xfrm,+ *,+ palette: ColorPalette | None,+) -> tuple[dict[str, Any], list[SeriesVisualStyle]]:+ series_nodes = chart.findall("c:ser", C_NS)+ if len(series_nodes) != 4:+ raise _UnsupportedChart("unsupported-stock-chart")+ categories = _numeric_values(series_nodes[0].find("c:cat", C_NS))+ if not categories:+ raise _UnsupportedChart("unsupported-chart-cache")+ series: list[dict[str, Any]] = []+ for index, series_node in enumerate(series_nodes, start=1):+ expected_index = str(index - 1)+ if (+ _element_val(series_node.find("c:idx", C_NS)) != expected_index+ or _element_val(series_node.find("c:order", C_NS)) != expected_index+ ):+ raise _UnsupportedChart("unsupported-stock-chart")+ if _numeric_values(series_node.find("c:cat", C_NS)) != categories:+ raise _UnsupportedChart("unsupported-chart-cache")+ values = _numeric_values(series_node.find("c:val", C_NS))+ if len(values) != len(categories):+ raise _UnsupportedChart("unsupported-chart-cache")+ series.append({+ "name": _series_name(series_node, index),+ "values": values,+ })+ axes = _single_axis_contract(+ plot_area,+ chart,+ category_kind="date",+ cross_between="between",+ )+ expected_category_format = axes["category"].get(+ "number_format",+ "m/d/yyyy",+ )+ category_cache_format = _numeric_category_cache_format(chart)+ if category_cache_format not in {"General", expected_category_format}:+ raise _UnsupportedChart("unsupported-chart-category-format")+ _validate_stock_semantics(plot_area, chart)+ payload: dict[str, Any] = {+ **_bounds_payload(xfrm),+ "axes": axes,+ "categories": categories,+ "series": series,+ "type": "stock",+ }+ visual_styles = _chart_visual_styles(payload, chart, palette)_apply_chart_metadata(payload, chart_root, plot_area, chart)return payload, visual_styles@@ -539,29 +921,299 @@ def _chart_visual_styles(return styles-def _validate_chart_semantics(- payload: dict[str, Any],- plot_area: ET.Element,+def _strict_axis_bool(elem: ET.Element | None, default: bool) -> bool:+ if elem is None:+ return default+ raw = elem.attrib.get("val")+ if raw is None:+ return default+ key = raw.strip().lower()+ if key in {"1", "on", "true"}:+ return True+ if key in {"0", "false", "off"}:+ return False+ raise _UnsupportedChart("unsupported-chart-axis-options")+++def _validate_canonical_series_order(+ plots: list[ET.Element],+ status: str,+) -> None:+ expected_index = 0+ for plot in plots:+ for series in plot.findall("c:ser", C_NS):+ expected = str(expected_index)+ for child_name in ("idx", "order"):+ child = series.find(f"c:{child_name}", C_NS)+ if (+ child is None+ or set(child.attrib) != {"val"}+ or list(child)+ or _element_val(child) != expected+ ):+ raise _UnsupportedChart(status)+ expected_index += 1+++def _plot_series_indices(plot: ET.Element, status: str) -> list[int]:+ indices: list[int] = []+ for series in plot.findall("c:ser", C_NS):+ values: list[int] = []+ for child_name in ("idx", "order"):+ child = series.find(f"c:{child_name}", C_NS)+ raw_value = _element_val(child)+ if (+ child is None+ or set(child.attrib) != {"val"}+ or list(child)+ or raw_value is None+ or re.fullmatch(r"[0-9]+", raw_value) is None+ ):+ raise _UnsupportedChart(status)+ values.append(int(raw_value))+ if values[0] != values[1]:+ raise _UnsupportedChart(status)+ indices.append(values[0])+ if not indices or len(set(indices)) != len(indices):+ raise _UnsupportedChart(status)+ return indices+++def _axis_number(elem: ET.Element | None) -> int | float | None:+ if elem is None:+ return None+ raw = elem.attrib.get("val")+ try:+ number = float(raw) if raw is not None else math.nan+ except (TypeError, ValueError, OverflowError):+ raise _UnsupportedChart("unsupported-chart-axis-options") from None+ if not math.isfinite(number):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ return int(number) if number.is_integer() else number+++def _axis_nodes_by_id(plot_area: ET.Element) -> dict[str, ET.Element]:+ if plot_area.find("c:serAx", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ axes: dict[str, ET.Element] = {}+ for tag in ("catAx", "dateAx", "valAx"):+ for axis in plot_area.findall(f"c:{tag}", C_NS):+ axis_id = _element_val(axis.find("c:axId", C_NS))+ if not axis_id or axis_id in axes:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ axes[axis_id] = axis+ return axes+++def _plot_axis_pair(plot: ET.Element,+ axes_by_id: dict[str, ET.Element],+) -> tuple[str, ET.Element, str, ET.Element]:+ axis_ids = [_element_val(elem) for elem in plot.findall("c:axId", C_NS)]+ if len(axis_ids) != 2 or any(not axis_id for axis_id in axis_ids):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if len(set(axis_ids)) != 2:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ resolved = [(axis_id, axes_by_id.get(str(axis_id))) for axis_id in axis_ids]+ if any(axis is None for _, axis in resolved):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ category_axes = [+ (str(axis_id), axis)+ for axis_id, axis in resolved+ if axis is not None and _local_name(axis.tag) in {"catAx", "dateAx"}+ ]+ value_axes = [+ (str(axis_id), axis)+ for axis_id, axis in resolved+ if axis is not None and _local_name(axis.tag) == "valAx"+ ]+ if len(category_axes) != 1 or len(value_axes) != 1:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ cat_id, cat_axis = category_axes[0]+ val_id, val_axis = value_axes[0]+ return cat_id, cat_axis, val_id, val_axis+++def _axis_config_from_xml(+ axis: ET.Element,*,- palette: ColorPalette | None = None,-) -> list[SeriesVisualStyle]:- """Reject valid chart features the compact marker cannot reproduce."""- chart_type = payload["type"]- visual_styles = _chart_visual_styles(payload, plot, palette)- for tag in (- "trendline", "errBars", "dropLines", "hiLowLines", "upDownBars",+ role: str,+ expected_cross_axis_id: str,+ allowed_crosses: set[str],+ expected_cross_between: str | None,+) -> dict[str, Any]:+ axis_kind = _local_name(axis.tag)+ allowed_children = {+ "auto", "axId", "axPos", "baseTimeUnit", "crossAx", "crossBetween",+ "crosses", "delete", "lblAlgn", "lblOffset", "majorGridlines",+ "majorTickMark", "majorUnit", "minorTickMark", "noMultiLvlLbl",+ "numFmt", "scaling", "spPr", "tickLblPos", "title", "txPr",+ }+ if any(_local_name(child.tag) not in allowed_children for child in axis):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if axis.attrib:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ for child_name in allowed_children:+ if len(axis.findall(f"c:{child_name}", C_NS)) > 1:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ simple_children = {+ "auto", "axId", "axPos", "baseTimeUnit", "crossAx",+ "crossBetween", "crosses", "delete", "lblAlgn", "lblOffset",+ "majorTickMark", "majorUnit", "minorTickMark", "noMultiLvlLbl",+ "tickLblPos",+ }+ if any(+ _local_name(child.tag) in simple_children+ and (set(child.attrib) != {"val"} or list(child))+ for child in axis):- if plot.find(f".//c:{tag}", C_NS) is not None:- raise _UnsupportedChart("unsupported-chart-analysis-features")- if plot_area.find("c:dTable", C_NS) is not None:- raise _UnsupportedChart("unsupported-chart-data-table")- ser_lines = plot.find("c:serLines", C_NS)- if ser_lines is not None and (- chart_type != "of_pie" or ser_lines.attrib or list(ser_lines)+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if axis.find("c:minorGridlines", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-axis-options")++ scaling = axis.find("c:scaling", C_NS)+ config: dict[str, Any] = {}+ if scaling is not None:+ if scaling.attrib or any(+ _local_name(child.tag) not in {"max", "min", "orientation"}+ for child in scaling+ ):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ for child_name in ("orientation", "max", "min"):+ if len(scaling.findall(f"c:{child_name}", C_NS)) > 1:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if any(+ set(child.attrib) != {"val"} or list(child)+ for child in scaling+ ):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ orientation = _element_val(scaling.find("c:orientation", C_NS)) or "minMax"+ if orientation not in {"maxMin", "minMax"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ config["reverse"] = orientation == "maxMin"+ minimum = _axis_number(scaling.find("c:min", C_NS))+ maximum = _axis_number(scaling.find("c:max", C_NS))+ if minimum is not None:+ config["minimum"] = minimum+ if maximum is not None:+ config["maximum"] = maximum+ if minimum is not None and maximum is not None and minimum >= maximum:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ else:+ config["reverse"] = False++ position_aliases = {"b": "bottom", "l": "left", "r": "right", "t": "top"}+ position = position_aliases.get(_element_val(axis.find("c:axPos", C_NS)) or "")+ if position is None:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if role in {"category", "secondary_category"}:+ if position not in {"bottom", "top"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ config["kind"] = "date" if axis_kind == "dateAx" else "text"+ else:+ if position not in {"left", "right"} or axis_kind != "valAx":+ raise _UnsupportedChart("unsupported-chart-axis-options")+ config["kind"] = "value"+ config["position"] = position+ config["visible"] = not _strict_axis_bool(axis.find("c:delete", C_NS), False)++ tick_label_aliases = {+ "high": "high",+ "low": "low",+ "nextTo": "next_to",+ "none": "none",+ }+ tick_label_position = _element_val(axis.find("c:tickLblPos", C_NS)) or "nextTo"+ if tick_label_position not in tick_label_aliases:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ config["label_position"] = tick_label_aliases[tick_label_position]+ config["major_gridlines"] = axis.find("c:majorGridlines", C_NS) is not None++ num_fmt = axis.find("c:numFmt", C_NS)+ if num_fmt is not None:+ if list(num_fmt) or not set(num_fmt.attrib).issubset({"formatCode", "sourceLinked"}):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ number_format = num_fmt.attrib.get("formatCode", "")+ if not number_format.strip():+ raise _UnsupportedChart("unsupported-chart-axis-number-format")+ config["number_format"] = number_format++ major_unit = _axis_number(axis.find("c:majorUnit", C_NS))+ if major_unit is not None:+ if role not in {"value", "secondary_value"} or major_unit <= 0:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ config["major_unit"] = major_unit++ if _element_val(axis.find("c:crossAx", C_NS)) != expected_cross_axis_id:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ crosses = _element_val(axis.find("c:crosses", C_NS)) or "autoZero"+ if crosses not in allowed_crosses:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ cross_between = _element_val(axis.find("c:crossBetween", C_NS))+ if cross_between != expected_cross_between:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ auto = axis.find("c:auto", C_NS)+ if auto is not None and not _strict_axis_bool(auto, True):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ major_tick = _element_val(axis.find("c:majorTickMark", C_NS))+ minor_tick = _element_val(axis.find("c:minorTickMark", C_NS))+ if major_tick not in {None, "none", "out"} or minor_tick not in {None, "none"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ label_alignment = _element_val(axis.find("c:lblAlgn", C_NS))+ label_offset = _element_val(axis.find("c:lblOffset", C_NS))+ no_multi_level = _element_val(axis.find("c:noMultiLvlLbl", C_NS))+ if role in {"category", "secondary_category"}:+ if label_alignment not in {None, "ctr"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if label_offset not in {None, "100"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if no_multi_level not in {None, "0"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ elif any(+ value is not None+ for value in (label_alignment, label_offset, no_multi_level, auto)):- raise _UnsupportedChart("unsupported-chart-analysis-features")+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if axis_kind == "dateAx":+ if _element_val(axis.find("c:baseTimeUnit", C_NS)) not in {None, "days"}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ elif axis.find("c:baseTimeUnit", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ return config+++def _single_axis_contract(+ plot_area: ET.Element,+ plot: ET.Element,+ *,+ category_kind: str,+ cross_between: str,+) -> dict[str, dict[str, Any]]:+ axes_by_id = _axis_nodes_by_id(plot_area)+ cat_id, cat_axis, val_id, val_axis = _plot_axis_pair(plot, axes_by_id)+ if set(axes_by_id) != {cat_id, val_id}:+ raise _UnsupportedChart("unsupported-chart-axis-options")+ if _local_name(cat_axis.tag) != ("dateAx" if category_kind == "date" else "catAx"):+ raise _UnsupportedChart("unsupported-chart-axis-options")+ category = _axis_config_from_xml(+ cat_axis,+ role="category",+ expected_cross_axis_id=val_id,+ allowed_crosses={"autoZero"},+ expected_cross_between=None,+ )+ value = _axis_config_from_xml(+ val_axis,+ role="value",+ expected_cross_axis_id=cat_id,+ allowed_crosses={"autoZero"},+ expected_cross_between=cross_between,+ )+ return {"category": category, "value": value}++def _validate_legacy_axes(payload: dict[str, Any], plot_area: ET.Element) -> None:+ """Keep the original narrow axis gate for payloads without axes metadata."""grouping = payload.get("grouping")axes = plot_area.findall("c:catAx", C_NS) + plot_area.findall("c:valAx", C_NS)for axis in axes:@@ -617,6 +1269,34 @@ def _validate_chart_semantics(if axis.find("c:minorGridlines", C_NS) is not None:raise _UnsupportedChart("unsupported-chart-axis-options")++def _validate_chart_semantics(+ payload: dict[str, Any],+ plot_area: ET.Element,+ plot: ET.Element,+ *,+ palette: ColorPalette | None = None,+ validate_axes: bool = True,+) -> list[SeriesVisualStyle]:+ """Reject valid chart features the compact marker cannot reproduce."""+ chart_type = payload["type"]+ grouping = payload.get("grouping")+ visual_styles = _chart_visual_styles(payload, plot, palette)+ for tag in (+ "trendline", "errBars", "dropLines", "hiLowLines", "upDownBars",+ ):+ if plot.find(f".//c:{tag}", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-analysis-features")+ if plot_area.find("c:dTable", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-data-table")+ ser_lines = plot.find("c:serLines", C_NS)+ if ser_lines is not None and (+ chart_type != "of_pie" or ser_lines.attrib or list(ser_lines)+ ):+ raise _UnsupportedChart("unsupported-chart-analysis-features")+ if validate_axes:+ _validate_legacy_axes(payload, plot_area)+if chart_type == "line":smooth_nodes = [plot.find("c:smooth", C_NS), *plot.findall("c:ser/c:smooth", C_NS)]if any(@@ -720,11 +1400,32 @@ def _validate_chart_semantics(return visual_styles+def _apply_plot_data_labels(payload: dict[str, Any], plot: ET.Element) -> None:+ if plot.find("c:ser/c:dLbls", C_NS) is not None:+ raise _UnsupportedChart("unsupported-chart-series-data-labels")+ data_labels = _data_labels_payload(plot.find("c:dLbls", C_NS))+ if not data_labels:+ return+ if payload["type"] not in {"area", "bar", "column", "line"}:+ raise _UnsupportedChart("unsupported-chart-data-labels")+ try:+ validate_data_label_position(+ data_labels.get("position"),+ payload["type"],+ payload.get("grouping"),+ )+ except RuntimeError:+ raise _UnsupportedChart("unsupported-chart-data-labels") from None+ payload["data_labels"] = data_labels++def _apply_chart_metadata(payload: dict[str, Any],chart_root: ET.Element,plot_area: ET.Element,plot: ET.Element,+ *,+ include_plot_labels: bool = True,) -> None:"""Copy visible classic-chart chrome supported by the native schema."""chart = chart_root.find("c:chart", C_NS)@@ -766,26 +1467,17 @@ def _apply_chart_metadata(payload["show_legend"] = Truepayload["legend_position"] = position- if plot.find("c:ser/c:dLbls", C_NS) is not None:- raise _UnsupportedChart("unsupported-chart-series-data-labels")- data_labels = _data_labels_payload(plot.find("c:dLbls", C_NS))- if data_labels:- if payload["type"] not in {"area", "bar", "column", "line"}:- raise _UnsupportedChart("unsupported-chart-data-labels")- try:- validate_data_label_position(- data_labels.get("position"),- payload["type"],- payload.get("grouping"),- )- except RuntimeError:- raise _UnsupportedChart("unsupported-chart-data-labels") from None- payload["data_labels"] = data_labels+ if include_plot_labels:+ _apply_plot_data_labels(payload, plot)axis_titles: dict[str, str] = {}+ category_axis_nodes = (+ plot_area.findall("c:catAx", C_NS)+ + plot_area.findall("c:dateAx", C_NS)+ )category_titles = [text- for axis in plot_area.findall("c:catAx", C_NS)+ for axis in category_axis_nodesif (text := _chart_text(axis.find("c:title", C_NS)))]value_titles = [@@ -793,7 +1485,21 @@ def _apply_chart_metadata(for axis in plot_area.findall("c:valAx", C_NS)if (text := _chart_text(axis.find("c:title", C_NS)))]- if payload["type"] in {"scatter", "bubble"}:+ if payload["type"] == "combo":+ if len(set(category_titles)) > 1:+ raise _UnsupportedChart("unsupported-chart-axis-titles")+ if category_titles:+ axis_titles["category"] = category_titles[0]+ for axis in plot_area.findall("c:valAx", C_NS):+ text = _chart_text(axis.find("c:title", C_NS))+ if not text:+ continue+ position = _element_val(axis.find("c:axPos", C_NS))+ key = "secondary_value" if position == "r" else "value"+ if key in axis_titles:+ raise _UnsupportedChart("unsupported-chart-axis-titles")+ axis_titles[key] = text+ elif payload["type"] in {"scatter", "bubble"}:if category_titles:raise _UnsupportedChart("unsupported-chart-axis-titles")titled_value_axes = [@@ -1116,18 +1822,29 @@ def _data_labels_payload(dlabels: ET.Element | None) -> dict[str, Any] | None:return config-def _category_payload(chart: ET.Element, chart_type: str, xfrm: Xfrm) -> dict[str, Any]:+def _category_payload(+ chart: ET.Element,+ chart_type: str,+ xfrm: Xfrm,+ *,+ category_kind: str = "text",+) -> dict[str, Any]:series_nodes = chart.findall("c:ser", C_NS)if not series_nodes:raise _UnsupportedChart("unsupported-chart-cache")- categories = _category_values(series_nodes[0].find("c:cat", C_NS))+ category_reader = (+ _numeric_values+ if category_kind in {"date", "numeric"}+ else _category_values+ )+ categories = category_reader(series_nodes[0].find("c:cat", C_NS))if not categories:raise _UnsupportedChart("unsupported-chart-cache")series: list[dict[str, Any]] = []for idx, ser in enumerate(series_nodes, start=1):- if _category_values(ser.find("c:cat", C_NS)) != categories:+ if category_reader(ser.find("c:cat", C_NS)) != categories:raise _UnsupportedChart("unsupported-chart-cache")values = _numeric_values(ser.find("c:val", C_NS))if not values or len(values) != len(categories):@@ -1221,6 +1938,47 @@ def _category_values(cat: ET.Element | None) -> list[str]:return [str(value) for value in numbers]+def _category_cache_is_numeric(chart: ET.Element) -> bool:+ """Return the cache representation shared by every series in one plot."""+ result: bool | None = None+ for series in chart.findall("c:ser", C_NS):+ category = series.find("c:cat", C_NS)+ has_text = _first_cache(category, ("strCache", "strLit")) is not None+ has_number = _first_cache(category, ("numCache", "numLit")) is not None+ if has_text == has_number:+ raise _UnsupportedChart("unsupported-combo-category-layout")+ current = has_number+ if result is not None and current != result:+ raise _UnsupportedChart("unsupported-combo-category-layout")+ result = current+ if result is None:+ raise _UnsupportedChart("unsupported-combo-category-layout")+ return result+++def _numeric_category_cache_format(chart: ET.Element) -> str:+ """Return one exact numeric category-cache format shared by the plot."""+ formats: set[str] = set()+ for series in chart.findall("c:ser", C_NS):+ cache = _first_cache(+ series.find("c:cat", C_NS),+ ("numCache", "numLit"),+ )+ if cache is None:+ raise _UnsupportedChart("unsupported-chart-category-format")+ number_format = cache.findtext(+ "c:formatCode",+ default="",+ namespaces=C_NS,+ )+ if not number_format.strip():+ raise _UnsupportedChart("unsupported-chart-category-format")+ formats.add(number_format)+ if len(formats) != 1:+ raise _UnsupportedChart("unsupported-chart-category-format")+ return next(iter(formats))++def _series_name(ser: ET.Element, index: int) -> str:tx = ser.find("c:tx", C_NS)values = _text_cache_values(tx)diff --git a/skills/ppt-master/scripts/pptx_to_svg/normalized_chart_svg.py b/skills/ppt-master/scripts/pptx_to_svg/normalized_chart_svg.pyindex 5cbb55cd..afaabd70 100644--- a/skills/ppt-master/scripts/pptx_to_svg/normalized_chart_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/normalized_chart_svg.py@@ -12,6 +12,7 @@ import htmlimport mathimport refrom dataclasses import dataclass+from datetime import date, timedeltafrom decimal import Decimal, ROUND_HALF_UPfrom typing import Any@@ -201,9 +202,9 @@ def _render_category(content: _Rect,chart_type: str,) -> list[str]:- categories = [str(value) for value in payload.get("categories") or []]+ categories = _category_labels(payload)series = payload.get("series") or []- if not categories or not series:+ if categories is None or not categories or not series:return []styles = _complete_styles(styles, len(series))axis_titles = payload.get("axis_titles") if isinstance(payload.get("axis_titles"), dict) else {}@@ -299,6 +300,52 @@ def _render_category(return parts+def _category_labels(payload: dict[str, Any]) -> list[str] | None:+ raw_categories = payload.get("categories") or []+ axes = payload.get("axes")+ category_axis = axes.get("category") if isinstance(axes, dict) else None+ if not isinstance(category_axis, dict) or category_axis.get("kind") != "date":+ return [str(value) for value in raw_categories]++ number_format = str(category_axis.get("number_format") or "").lower()+ normalized_format = re.sub(r'\\.|"[^"]*"|\[[^]]*]', "", number_format)+ labels: list[str] = []+ for raw_value in raw_categories:+ try:+ serial = float(raw_value)+ except (TypeError, ValueError, OverflowError):+ return None+ if not math.isfinite(serial):+ return None+ date_parts = _excel_1900_date_parts(serial)+ if date_parts is None:+ return None+ year, month, day = date_parts+ if "yyyy-mm-dd" in normalized_format:+ labels.append(f"{year:04d}-{month:02d}-{day:02d}")+ elif "mm/dd/yyyy" in normalized_format:+ labels.append(f"{month:02d}/{day:02d}/{year:04d}")+ elif "m/d/yyyy" in normalized_format:+ labels.append(f"{month}/{day}/{year:04d}")+ else:+ labels.append(f"{year:04d}-{month:02d}-{day:02d}")+ return labels+++def _excel_1900_date_parts(serial: float) -> tuple[int, int, int] | None:+ day_number = math.floor(serial)+ if day_number < 1:+ return None+ if day_number == 60:+ return 1900, 2, 29+ epoch = date(1899, 12, 31) if day_number < 60 else date(1899, 12, 30)+ try:+ value = epoch + timedelta(days=day_number)+ except (OverflowError, ValueError):+ return None+ return value.year, value.month, value.day++def _category_segments(series: list[dict[str, Any]],count: int,diff --git a/skills/ppt-master/scripts/pptx_to_svg/tbl_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/tbl_to_svg.pyindex 312a72e7..21703a62 100644--- a/skills/ppt-master/scripts/pptx_to_svg/tbl_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/tbl_to_svg.py@@ -305,10 +305,11 @@ def convert_tbl(# and dropped cells don't render anything. PowerPoint expresses merges via# gridSpan/rowSpan on the anchor cell + hMerge/vMerge on the dropped cells.cells = _build_cell_grid(rows, len(col_widths))+ merge_status = _canonical_native_merge_status(rows, len(col_widths))if xfrm.rot or xfrm.flip_h or xfrm.flip_v:native_status = "unsupported-native-transform"- elif _table_has_merges(rows):- native_status = "unsupported-merge"+ elif merge_status:+ native_status = merge_statuselif len(rows) > 1000 or len(col_widths) > 1000:native_status = "unsupported-table-size"elif (@@ -474,6 +475,14 @@ class _CellSlot:is_dropped: bool = False # True for h/vMerge slaves: don't paint anything+@dataclass(frozen=True)+class _CanonicalMergeRegion:+ row: int+ col: int+ row_span: int+ col_span: int++def _build_cell_grid(rows: list[ET.Element], col_count: int) -> list[list[_CellSlot | None]]:"""Map each (row, col) to the <a:tc> that owns it.@@ -544,17 +553,130 @@ def _safe_int(value: str | None, default: int) -> int:return default-def _table_has_merges(rows: list[ET.Element]) -> bool:- """Return True when the table uses merged cells."""- for row in rows:- for tc in row.findall("a:tc", NS):- if ooxml_bool(tc.attrib.get("hMerge")) or ooxml_bool(tc.attrib.get("vMerge")):- return True- if _safe_int(tc.attrib.get("gridSpan"), 1) > 1:- return True- if _safe_int(tc.attrib.get("rowSpan"), 1) > 1:- return True- return False+def _strict_merge_bool(value: str | None) -> bool:+ if value is None:+ return False+ normalized = value.strip().lower()+ if normalized in {"1", "on", "true"}:+ return True+ if normalized in {"0", "false", "off"}:+ return False+ raise ValueError("invalid OOXML boolean")+++def _strict_merge_span(value: str | None) -> int:+ if value is None:+ return 1+ normalized = value.strip()+ if not normalized.isdigit():+ raise ValueError("invalid OOXML span")+ span = int(normalized)+ if span <= 0:+ raise ValueError("invalid OOXML span")+ return span+++def _canonical_merge_slave_is_empty(tc: ET.Element) -> bool:+ tc_pr = tc.find("a:tcPr", NS)+ if tc_pr is None or tc_pr.attrib or list(tc_pr):+ return False+ tx_body = tc.find("a:txBody", NS)+ if tx_body is None:+ return False+ paragraph_count = 0+ for child in tx_body:+ name = child.tag.rsplit("}", 1)[-1]+ if name in {"bodyPr", "lstStyle"}:+ if child.attrib or list(child):+ return False+ continue+ if name == "p" and not child.attrib and not list(child):+ paragraph_count += 1+ continue+ return False+ return paragraph_count > 0 and not (tx_body.text or "").strip()+++def _canonical_native_merge_status(+ rows: list[ET.Element],+ col_count: int,+) -> str | None:+ """Accept only explicit rectangular merge topology safe for regeneration."""+ physical_rows = [row.findall("a:tc", NS) for row in rows]+ merge_attrs = {"gridSpan", "rowSpan", "hMerge", "vMerge"}+ if not any(+ any(name in tc.attrib for name in merge_attrs)+ for row_cells in physical_rows+ for tc in row_cells+ ):+ return None+ if col_count <= 0 or any(+ len(row_cells) != col_count for row_cells in physical_rows+ ):+ return "unsupported-merge-topology"++ states: dict[tuple[int, int], tuple[ET.Element, int, int, bool, bool]] = {}+ try:+ for row_idx, row_cells in enumerate(physical_rows):+ for col_idx, tc in enumerate(row_cells):+ states[(row_idx, col_idx)] = (+ tc,+ _strict_merge_span(tc.get("rowSpan")),+ _strict_merge_span(tc.get("gridSpan")),+ _strict_merge_bool(tc.get("hMerge")),+ _strict_merge_bool(tc.get("vMerge")),+ )+ except ValueError:+ return "unsupported-merge-topology"++ anchors: list[_CanonicalMergeRegion] = []+ for (+ (row_idx, col_idx),+ (_tc, row_span, col_span, h_merge, v_merge),+ ) in states.items():+ if not h_merge and not v_merge and (row_span > 1 or col_span > 1):+ anchors.append(+ _CanonicalMergeRegion(row_idx, col_idx, row_span, col_span)+ )++ owners: dict[tuple[int, int], _CanonicalMergeRegion] = {}+ for region in anchors:+ if (+ region.row + region.row_span > len(rows)+ or region.col + region.col_span > col_count+ ):+ return "unsupported-merge-topology"+ for covered_row in range(region.row, region.row + region.row_span):+ for covered_col in range(region.col, region.col + region.col_span):+ position = (covered_row, covered_col)+ if position in owners:+ return "unsupported-merge-topology"+ owners[position] = region++ for (+ (row_idx, col_idx),+ (tc, row_span, col_span, h_merge, v_merge),+ ) in states.items():+ region = owners.get((row_idx, col_idx))+ if region is None:+ if h_merge or v_merge or row_span != 1 or col_span != 1:+ return "unsupported-merge-topology"+ continue++ is_anchor = row_idx == region.row and col_idx == region.col+ expected_row_span = region.row_span if row_idx == region.row else 1+ expected_col_span = region.col_span if col_idx == region.col else 1+ if (+ row_span != expected_row_span+ or col_span != expected_col_span+ or h_merge != (col_idx > region.col)+ or v_merge != (row_idx > region.row)+ ):+ return "unsupported-merge-topology"+ if not is_anchor and not _canonical_merge_slave_is_empty(tc):+ return "unsupported-merge-topology"++ return Nonedef _table_has_unsupported_style(tbl: ET.Element) -> bool:@@ -578,6 +700,105 @@ def _table_has_unsupported_style(tbl: ET.Element) -> bool:)+_DIRECT_BORDER_TAGS = {+ "lnL": "left",+ "lnR": "right",+ "lnT": "top",+ "lnB": "bottom",+}+_DIRECT_BORDER_WIDTH_MAX = 20116800+_OPAQUE_COLOR_MODIFIERS = {+ "tint",+ "shade",+ "lumMod",+ "lumOff",+ "satMod",+ "satOff",+}+++def _validate_opaque_border_color(color_elem: ET.Element | None) -> None:+ if color_elem is None:+ raise ValueError("missing border color")+ name = color_elem.tag.rsplit("}", 1)[-1]+ if name not in {"srgbClr", "schemeClr"} or set(color_elem.attrib) != {"val"}:+ raise ValueError("unsupported border color")+ for modifier in color_elem:+ modifier_name = modifier.tag.rsplit("}", 1)[-1]+ if (+ modifier_name not in _OPAQUE_COLOR_MODIFIERS+ or set(modifier.attrib) != {"val"}+ or list(modifier)+ ):+ raise ValueError("unsupported border color modifier")+ value = modifier.get("val", "")+ if not value.isdigit() or not 0 <= int(value) <= 100000:+ raise ValueError("invalid border color modifier")+++def _direct_border_payload(+ ln: ET.Element,+ palette: ColorPalette | None,+) -> dict[str, Any]:+ if set(ln.attrib) - {"w"}:+ raise ValueError("unsupported border line attribute")+ width_emu: int | None = None+ if "w" in ln.attrib:+ raw_width = ln.get("w", "")+ if not raw_width.isdigit():+ raise ValueError("invalid border width")+ width_emu = int(raw_width)+ if not 0 < width_emu <= _DIRECT_BORDER_WIDTH_MAX:+ raise ValueError("invalid border width")++ children = list(ln)+ child_names = [child.tag.rsplit("}", 1)[-1] for child in children]+ if child_names == ["noFill"]:+ no_fill = children[0]+ if no_fill.attrib or list(no_fill):+ raise ValueError("invalid noFill border")+ return {"style": "none"}++ if child_names.count("solidFill") != 1 or any(+ name not in {"solidFill", "prstDash"} for name in child_names+ ):+ raise ValueError("unsupported border paint")+ if child_names.count("prstDash") > 1 or width_emu is None:+ raise ValueError("invalid solid border")+ dash = next(+ (child for child in children if child.tag.rsplit("}", 1)[-1] == "prstDash"),+ None,+ )+ if dash is not None and (+ dash.attrib != {"val": "solid"} or list(dash)+ ):+ raise ValueError("unsupported border dash")++ solid_fill = next(+ child for child in children+ if child.tag.rsplit("}", 1)[-1] == "solidFill"+ )+ if solid_fill.attrib or len(list(solid_fill)) != 1:+ raise ValueError("invalid solid border fill")+ color_elem = find_color_elem(solid_fill)+ _validate_opaque_border_color(color_elem)+ try:+ color, alpha = resolve_color(color_elem, palette)+ except (TypeError, ValueError, OverflowError) as exc:+ raise ValueError("invalid solid border color") from exc+ if color is None or alpha != 1.0:+ raise ValueError("border color must resolve to opaque RGB")++ width = _round_payload_number(emu_to_px(str(width_emu)))+ if width <= 0:+ raise ValueError("border width is too small")+ return {+ "style": "solid",+ "color": color,+ "width": width,+ }++def _table_has_unsupported_direct_formatting(tbl: ET.Element,palette: ColorPalette | None,@@ -592,10 +813,20 @@ def _table_has_unsupported_direct_formatting(if tc_pr.get("anchor") not in {None, "t", "ctr", "b"}:return Trueif any(- child.tag.rsplit("}", 1)[-1] != "solidFill"+ child.tag.rsplit("}", 1)[-1]+ not in {"solidFill", *_DIRECT_BORDER_TAGS}for child in tc_pr):return True+ for border_tag in _DIRECT_BORDER_TAGS:+ borders = tc_pr.findall(f"a:{border_tag}", NS)+ if len(borders) > 1:+ return True+ if borders:+ try:+ _direct_border_payload(borders[0], palette)+ except ValueError:+ return Truesolid_fill = tc_pr.find("a:solidFill", NS)if solid_fill is not None:if solid_fill.find(".//a:alpha", NS) is not None:@@ -631,17 +862,12 @@ def _text_body_has_unsupported_formatting(tx_body: ET.Element | None) -> bool:return Trueparagraphs = tx_body.findall("a:p", NS)- if len(paragraphs) > 1:- return True-- alignments: set[str | None] = set()run_signatures: set[tuple[str | None, str | None, bytes | None]] = set()for paragraph in paragraphs:p_pr = paragraph.find("a:pPr", NS)alignment = p_pr.get("algn") if p_pr is not None else Noneif alignment not in {None, "l", "ctr", "r"}:return True- alignments.add(alignment)if p_pr is not None:if any(name != "algn" for name in p_pr.attrib):return True@@ -665,7 +891,7 @@ def _text_body_has_unsupported_formatting(tx_body: ET.Element | None) -> bool:if not paragraph.findall("a:r", NS) and end_r_pr is not None:run_signatures.add(_effective_run_signature(end_r_pr, default_r_pr))- return len(alignments) > 1 or len(run_signatures) > 1+ return len(run_signatures) > 1def _run_props_have_unsupported_formatting(r_pr: ET.Element | None) -> bool:@@ -761,7 +987,12 @@ def _native_table_payload(if slot is None or slot.is_dropped:row_payload.append("")continue- row_payload.append(_native_cell_payload(slot.element, palette))+ cell_payload = _native_cell_payload(slot.element, palette)+ if slot.row_span > 1:+ cell_payload["row_span"] = slot.row_span+ if slot.col_span > 1:+ cell_payload["col_span"] = slot.col_span+ row_payload.append(cell_payload)rows_payload.append(row_payload)payload["rows"] = rows_payloadreturn payload@@ -770,7 +1001,11 @@ def _native_table_payload(def _native_cell_payload(tc: ET.Element, palette: ColorPalette | None) -> dict[str, Any]:tx_body = tc.find("a:txBody", NS)tc_pr = tc.find("a:tcPr", NS)- cell: dict[str, Any] = {"text": _cell_plain_text(tx_body)}+ paragraph_payloads = _cell_paragraph_payloads(tx_body)+ if len(paragraph_payloads) > 1:+ cell: dict[str, Any] = {"paragraphs": paragraph_payloads}+ else:+ cell = {"text": _cell_plain_text(tx_body)}fill = _cell_fill_hex(tc_pr, palette)if fill:@@ -781,15 +1016,19 @@ def _native_cell_payload(tc: ET.Element, palette: ColorPalette | None) -> dict[sfont_size = _cell_font_size_px(tx_body)if font_size:cell["font_size"] = font_size- align = _cell_align(tx_body)- if align:- cell["align"] = align+ if len(paragraph_payloads) <= 1:+ align = _cell_align(tx_body)+ if align:+ cell["align"] = alignvalign = _cell_valign(tc_pr)if valign:cell["valign"] = valignbold = _cell_bold(tx_body)if bold is not None:cell["bold"] = bold+ borders = _cell_borders_payload(tc_pr, palette)+ if borders:+ cell["borders"] = borders_copy_cell_margins(tc_pr, cell)return cell@@ -805,6 +1044,23 @@ def _cell_plain_text(tx_body: ET.Element | None) -> str:return "\n".join(paragraphs)+def _cell_paragraph_payloads(+ tx_body: ET.Element | None,+) -> list[str | dict[str, str]]:+ if tx_body is None:+ return []+ payloads: list[str | dict[str, str]] = []+ for paragraph in tx_body.findall("a:p", NS):+ text = "".join(node.text or "" for node in paragraph.findall(".//a:t", NS))+ p_pr = paragraph.find("a:pPr", NS)+ align = p_pr.get("algn") if p_pr is not None else None+ if align in {"l", "ctr", "r"}:+ payloads.append({"text": text, "align": align})+ else:+ payloads.append(text)+ return payloads++def _cell_fill_hex(tc_pr: ET.Element | None, palette: ColorPalette | None) -> str | None:fill = resolve_fill(tc_pr, palette)color = fill.attrs.get("fill") if fill.attrs else None@@ -858,6 +1114,20 @@ def _cell_bold(tx_body: ET.Element | None) -> bool | None:return None+def _cell_borders_payload(+ tc_pr: ET.Element | None,+ palette: ColorPalette | None,+) -> dict[str, dict[str, Any]]:+ if tc_pr is None:+ return {}+ borders: dict[str, dict[str, Any]] = {}+ for border_tag, side in _DIRECT_BORDER_TAGS.items():+ ln = tc_pr.find(f"a:{border_tag}", NS)+ if ln is not None:+ borders[side] = _direct_border_payload(ln, palette)+ return borders++def _text_run_props_in_priority(tx_body: ET.Element | None) -> list[ET.Element]:if tx_body is None:return []diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.pyindex c2b8f310..ac03d4e9 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py@@ -200,7 +200,7 @@ def _validate_native_object_marker_payload(off_x, off_y, ext_cx, ext_cy, _ = _validate_bounds_inputs(elem, payload, bounds_ctx)table_rows = Noneif kind == "table":- table_rows, col_count = _validate_table_payload(payload)+ table_rows, col_count, _merge_layout = _validate_table_payload(payload)if ext_cx < col_count or ext_cy < len(table_rows):raise RuntimeError("Native PPTX table bounds must provide at least one EMU per row and column"diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.pyindex 71443167..83cd227d 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py@@ -222,6 +222,153 @@ _DEFAULT_CHART_COLORS = ["9E480E",]+_AXIS_ROLE_DEFAULTS = {+ "category": ("text", "bottom"),+ "secondary_category": ("text", "bottom"),+ "secondary_value": ("value", "right"),+ "value": ("value", "left"),+}+++def _chart_axes(+ payload: dict[str, Any],+ allowed_roles: set[str],+) -> dict[str, dict[str, Any]]:+ """Normalize the narrow classic-chart axis contract."""+ raw_axes = payload.get("axes")+ if raw_axes is None:+ return {}+ if not isinstance(raw_axes, dict):+ raise RuntimeError("Native PPTX chart axes must be an object")++ unknown_roles = set(raw_axes) - allowed_roles+ if unknown_roles:+ roles = ", ".join(sorted(unknown_roles))+ raise RuntimeError(f"Native PPTX chart axes contains unsupported role(s): {roles}")++ axes: dict[str, dict[str, Any]] = {}+ for role, raw_config in raw_axes.items():+ if not isinstance(raw_config, dict):+ raise RuntimeError(f"Native PPTX chart axes.{role} must be an object")+ allowed_fields = {+ "kind", "label_position", "major_gridlines", "major_unit",+ "maximum", "minimum", "number_format", "position", "reverse",+ "visible",+ }+ unknown_fields = set(raw_config) - allowed_fields+ if unknown_fields:+ fields = ", ".join(sorted(unknown_fields))+ raise RuntimeError(+ f"Native PPTX chart axes.{role} contains unsupported field(s): {fields}"+ )+ default_kind, default_position = _AXIS_ROLE_DEFAULTS[role]+ kind = _compact_key(raw_config.get("kind") or default_kind)+ if kind not in {"date", "text", "value"}:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.kind must be date, text, or value"+ )+ if role in {"category", "secondary_category"} and kind not in {"date", "text"}:+ raise RuntimeError(f"Native PPTX chart axes.{role}.kind must be date or text")+ if role in {"value", "secondary_value"} and kind != "value":+ raise RuntimeError(f"Native PPTX chart axes.{role}.kind must be value")++ position_aliases = {+ "b": "bottom",+ "bottom": "bottom",+ "l": "left",+ "left": "left",+ "r": "right",+ "right": "right",+ "t": "top",+ "top": "top",+ }+ position = position_aliases.get(+ _compact_key(raw_config.get("position") or default_position)+ )+ if position is None:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.position must be bottom, left, right, or top"+ )+ allowed_positions = (+ {"bottom", "top"}+ if role in {"category", "secondary_category"}+ else {"left", "right"}+ )+ if position not in allowed_positions:+ choices = ", ".join(sorted(allowed_positions))+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.position must be one of: {choices}"+ )++ config: dict[str, Any] = {"kind": kind, "position": position}+ for field in ("visible", "reverse", "major_gridlines"):+ value = raw_config.get(field)+ if value is None:+ continue+ if not isinstance(value, bool):+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.{field} must be a boolean"+ )+ config[field] = value++ raw_label_position = raw_config.get("label_position")+ if raw_label_position is not None:+ label_aliases = {+ "high": "high",+ "low": "low",+ "nextto": "next_to",+ "none": "none",+ }+ label_position = label_aliases.get(_compact_key(raw_label_position))+ if label_position is None:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.label_position must be one of: "+ "high, low, next_to, none"+ )+ config["label_position"] = label_position++ raw_number_format = raw_config.get("number_format")+ if raw_number_format is not None:+ if not isinstance(raw_number_format, str):+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.number_format must be a string"+ )+ if not raw_number_format.strip():+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.number_format must be non-empty"+ )+ config["number_format"] = raw_number_format++ for field in ("minimum", "maximum", "major_unit"):+ value = raw_config.get(field)+ if value is None:+ continue+ number = _chart_number(value)+ if field == "major_unit":+ if role not in {"value", "secondary_value"}:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.major_unit is unsupported"+ )+ if number <= 0:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.major_unit must be positive"+ )+ config[field] = number+ if (+ config.get("minimum") is not None+ and config.get("maximum") is not None+ and config["minimum"] >= config["maximum"]+ ):+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.minimum must be less than maximum"+ )+ axes[role] = config+ return axes+++def _category_axis_is_date(axes: dict[str, dict[str, Any]]) -> bool:+ return axes.get("category", {}).get("kind") == "date"+def _chart_kind(payload: dict[str, Any]) -> tuple[str, str | None, str | None]:raw_type = payload.get("type") or payload.get("chart_type") or "column"@@ -440,7 +587,7 @@ def _radar_style(payload: dict[str, Any], alias_style: str | None) -> tuple[str,return style-def _category_series(payload: dict[str, Any], categories: list[str]) -> list[dict[str, Any]]:+def _category_series(payload: dict[str, Any], categories: list[Any]) -> list[dict[str, Any]]:raw_series = payload.get("series", [])if not categories or not isinstance(raw_series, list) or not raw_series:raise RuntimeError("Native PPTX chart requires non-empty categories and series")@@ -506,7 +653,21 @@ def _category_chart_data(alias_grouping: str | None,alias_style: str | None,) -> dict[str, Any]:- categories = [str(item) for item in _chart_list(payload.get("categories", []), "categories")]+ axes = _chart_axes(payload, {"category", "value"})+ if axes and chart_type in {"bar", "doughnut", "of_pie", "pie"}:+ raise RuntimeError(+ f"Native PPTX {chart_type} chart axes are outside current support"+ )+ if _category_axis_is_date(axes) and chart_type != "area":+ raise RuntimeError(+ "Native PPTX date category axes are currently supported for area charts only"+ )+ raw_categories = _chart_list(payload.get("categories", []), "categories")+ categories = (+ [_chart_number(item) for item in raw_categories]+ if _category_axis_is_date(axes)+ else [str(item) for item in raw_categories]+ )style = payload.get("style") if isinstance(payload.get("style"), dict) else {}series = _category_series(payload, categories)@@ -571,6 +732,7 @@ def _category_chart_data(grouping,len(categories),),+ "axes": axes,"series": series,}@@ -615,10 +777,33 @@ def _plot_series_area_style(plot_payload: dict[str, Any]) -> bool:return False+def _combo_series_indices(+ plot_payload: dict[str, Any],+ series_count: int,+) -> list[int] | None:+ raw_indices = plot_payload.get("series_indices")+ if raw_indices is None:+ return None+ indices: list[int] = []+ for value in _chart_list(raw_indices, "plots[].series_indices"):+ if isinstance(value, bool) or not isinstance(value, int) or value < 0:+ raise RuntimeError(+ "Native PPTX combo series_indices must contain non-negative integers"+ )+ indices.append(value)+ if len(indices) != series_count or len(set(indices)) != len(indices):+ raise RuntimeError(+ "Native PPTX combo series_indices must be unique and match series length"+ )+ return indices++def _combo_plot_entry(plot_payload: dict[str, Any],- categories: list[str],+ categories: list[Any],*,+ category_is_numeric: bool,+ axes: dict[str, dict[str, Any]],fallback_series: list[dict[str, Any]] | None = None,) -> dict[str, Any]:chart_type, alias_grouping, alias_style = _combo_plot_type(plot_payload)@@ -626,31 +811,82 @@ def _combo_plot_entry(raise RuntimeError("Native PPTX combo line plot with series fill_opacity requires area_fill: true")- plot_series = fallback_series or _category_series(plot_payload, categories)+ axis = _combo_axis_name(plot_payload)+ category_role = "secondary_category" if axis == "secondary" else "category"+ axis_is_date = axes.get(category_role, {}).get("kind") == "date"+ raw_numeric = plot_payload.get("category_numeric")+ if raw_numeric is not None and not isinstance(raw_numeric, bool):+ raise RuntimeError(+ "Native PPTX combo plot category_numeric must be a boolean"+ )+ if axis_is_date and raw_numeric is False:+ raise RuntimeError(+ "Native PPTX combo date-axis categories must remain numeric"+ )+ plot_category_is_numeric = axis_is_date or (+ raw_numeric if raw_numeric is not None else category_is_numeric+ )+ raw_plot_categories = plot_payload.get("categories")+ category_items = (+ categories+ if raw_plot_categories is None+ else _chart_list(raw_plot_categories, "plots[].categories")+ )+ plot_categories = (+ [_chart_number(item) for item in category_items]+ if plot_category_is_numeric+ else [str(item) for item in category_items]+ )+ if not plot_categories:+ raise RuntimeError("Native PPTX combo plot categories must be non-empty")+ plot_series = fallback_series or _category_series(plot_payload, plot_categories)grouping = (_chart_grouping(chart_type, plot_payload, alias_grouping)if chart_type in {"area", "column", "line"}else None)entry: dict[str, Any] = {- "axis": _combo_axis_name(plot_payload),+ "axis": axis,+ "categories": plot_categories,+ "category_is_numeric": plot_category_is_numeric,"data_labels": _chart_data_labels(plot_payload,chart_type,grouping,- len(categories),+ len(plot_categories),),"grouping": grouping,"series": plot_series,"type": chart_type,}+ series_indices = _combo_series_indices(plot_payload, len(plot_series))+ if series_indices is not None:+ entry["series_indices"] = series_indicesif chart_type == "line":entry["line_style"] = _line_style(plot_payload, alias_style)return entrydef _combo_chart_data(payload: dict[str, Any]) -> dict[str, Any]:- categories = [str(item) for item in _chart_list(payload.get("categories", []), "categories")]+ axes = _chart_axes(+ payload,+ {"category", "secondary_category", "secondary_value", "value"},+ )+ raw_category_numeric = payload.get("category_numeric")+ if raw_category_numeric is not None and not isinstance(raw_category_numeric, bool):+ raise RuntimeError("Native PPTX combo category_numeric must be a boolean")+ primary_axis_is_date = _category_axis_is_date(axes)+ if primary_axis_is_date and raw_category_numeric is False:+ raise RuntimeError("Native PPTX combo date-axis categories must remain numeric")+ category_is_numeric = primary_axis_is_date or raw_category_numeric is True+ raw_categories = _chart_list(payload.get("categories", []), "categories")+ categories = (+ [_chart_number(item) for item in raw_categories]+ if category_is_numeric+ else [str(item) for item in raw_categories]+ )+ if not categories:+ raise RuntimeError("Native PPTX combo chart categories must be non-empty")raw_plots = payload.get("plots", payload.get("chart_plots"))plots: list[dict[str, Any]] = []@@ -658,7 +894,12 @@ def _combo_chart_data(payload: dict[str, Any]) -> dict[str, Any]:for item in _chart_list(raw_plots, "plots"):if not isinstance(item, dict):raise RuntimeError("Native PPTX combo plots must be objects")- plots.append(_combo_plot_entry(item, categories))+ plots.append(_combo_plot_entry(+ item,+ categories,+ category_is_numeric=category_is_numeric,+ axes=axes,+ ))else:raw_series = _chart_list(payload.get("series", []), "series")if not raw_series:@@ -668,8 +909,22 @@ def _combo_chart_data(payload: dict[str, Any]) -> dict[str, Any]:raise RuntimeError("Native PPTX chart series entries must be objects")if not (item.get("type") or item.get("chart_type")):raise RuntimeError("Native PPTX combo series entries require type")+ if any(+ field in item+ for field in ("categories", "category_numeric", "series_indices")+ ):+ raise RuntimeError(+ "Native PPTX combo typed series with plot-scoped metadata "+ "must use plots"+ )one_series = _category_series({"series": [item]}, categories)- plot = _combo_plot_entry(item, categories, fallback_series=one_series)+ plot = _combo_plot_entry(+ item,+ categories,+ category_is_numeric=category_is_numeric,+ axes=axes,+ fallback_series=one_series,+ )signature = (plot["axis"],plot.get("grouping"),@@ -694,15 +949,52 @@ def _combo_chart_data(payload: dict[str, Any]) -> dict[str, Any]:if not plots:raise RuntimeError("Native PPTX combo chart requires at least one plot")+ if not any(plot["axis"] == "primary" for plot in plots):+ raise RuntimeError("Native PPTX combo chart requires a primary-axis plot")+ has_secondary_plot = any(plot["axis"] == "secondary" for plot in plots)+ if not has_secondary_plot and {+ "secondary_category", "secondary_value",+ }.intersection(axes):+ raise RuntimeError(+ "Native PPTX combo secondary axes require a secondary-axis plot"+ )+ series_index_groups = [plot.get("series_indices") for plot in plots]+ if any(group is not None for group in series_index_groups):+ if any(group is None for group in series_index_groups):+ raise RuntimeError(+ "Native PPTX combo series_indices must cover every plot"+ )+ flat_indices = [+ index+ for group in series_index_groups+ for index in group+ ]+ if sorted(flat_indices) != list(range(len(flat_indices))):+ raise RuntimeError(+ "Native PPTX combo series_indices must form one contiguous range"+ )flat_series: list[dict[str, Any]] = []+ independent_categories = any(+ plot["categories"] != categories+ or plot["category_is_numeric"] != category_is_numeric+ for plot in plots+ )+ next_column = 1for plot in plots:plot["start_index"] = len(flat_series)+ if independent_categories:+ plot["category_column"] = next_column+ plot["start_column"] = next_column + 1+ next_column += len(plot["series"]) + 1flat_series.extend(plot["series"])if not flat_series:raise RuntimeError("Native PPTX combo chart requires at least one series")return {+ "axes": axes,"categories": categories,+ "category_is_numeric": category_is_numeric,+ "independent_categories": independent_categories,"kind": "combo","plots": plots,"series": flat_series,@@ -866,6 +1158,9 @@ def _chartex_chart_data(payload: dict[str, Any], chart_type: str) -> dict[str, Adef _stock_chart_data(payload: dict[str, Any]) -> dict[str, Any]:if _data_labels_config(payload) is not None:raise RuntimeError("Native PPTX stock chart data labels are outside current support")+ axes = _chart_axes(payload, {"category", "value"})+ if "category" in axes and not _category_axis_is_date(axes):+ raise RuntimeError("Native PPTX stock chart category axis must be date")categories = [_chart_number(item)for item in _chart_list(payload.get("categories", payload.get("dates", [])), "categories")@@ -884,6 +1179,7 @@ def _stock_chart_data(payload: dict[str, Any]) -> dict[str, Any]:if len(series) != 4:raise RuntimeError("Native PPTX stock chart requires exactly four series: open, high, low, close")return {+ "axes": axes,"categories": categories,"kind": "category","series": series,diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.pyindex d6500514..b21dc825 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py@@ -8,6 +8,7 @@ from xml.etree import ElementTree as ETfrom ..drawingml.utils import detect_text_lang, _xml_escapefrom .chart_data import (_DEFAULT_CHART_COLORS,+ _category_axis_is_date,_chart_list,_data_label_position,_data_label_point_items,@@ -51,17 +52,42 @@ def _string_cache(values: list[str]) -> str:return f'<c:strCache><c:ptCount val="{len(values)}"/>{points}</c:strCache>'-def _number_cache(values: list[int | float]) -> str:+def _number_cache(+ values: list[int | float],+ number_format: str = "General",+) -> str:points = "".join(f'<c:pt idx="{idx}"><c:v>{value}</c:v></c:pt>'for idx, value in enumerate(values))return (- '<c:numCache><c:formatCode>General</c:formatCode>'+ f'<c:numCache><c:formatCode>{_xml_escape(number_format)}</c:formatCode>'f'<c:ptCount val="{len(values)}"/>{points}</c:numCache>')+def _category_reference_xml(+ categories: list[Any],+ *,+ column_index: int = 1,+ numeric: bool,+ number_format: str | None = None,+) -> str:+ reference_tag = "numRef" if numeric else "strRef"+ cache = (+ _number_cache(categories, number_format or "General")+ if numeric+ else _string_cache([str(value) for value in categories])+ )+ return (+ f"<c:cat><c:{reference_tag}>"+ f"<c:f>Sheet1!${_excel_col(column_index)}$2:"+ f"${_excel_col(column_index)}${len(categories) + 1}</c:f>"+ f"{cache}"+ f"</c:{reference_tag}></c:cat>"+ )++def _series_color_xml(color: str | None,*,@@ -273,7 +299,7 @@ def _marker_xml(symbol: str | None) -> str:def _series_xml(- categories: list[str],+ categories: list[Any],series: list[dict[str, Any]],*,chart_type: str,@@ -282,21 +308,41 @@ def _series_xml(radar_marker_style: str | None = None,radar_style: str = "marker",colors: list[str],+ category_is_numeric: bool = False,+ category_number_format: str | None = None,data_labels: dict[str, Any] | None = None,data_label_font_size: int = 900,data_label_color: str | None = None,data_label_font_face: str | None = None,+ category_column: int = 1,+ color_start_index: int | None = None,+ series_indices: list[int] | None = None,start_column: int = 2,start_index: int = 0,) -> str:parts: list[str] = []+ category_xml = _category_reference_xml(+ categories,+ column_index=category_column,+ numeric=category_is_numeric,+ number_format=category_number_format,+ )for offset, item in enumerate(series):- index = start_index + offset+ index = (+ series_indices[offset]+ if series_indices is not None+ else start_index + offset+ )+ color_index = (+ color_start_index+ if color_start_index is not None+ else start_index+ ) + offsetcolumn_index = offset + start_columnfill_opacity = item.get("fill_opacity") if chart_type == "area" else Noneline_width = item.get("line_width") if chart_type in {"area", "line"} else Nonecolor_xml = _series_color_xml(- _chart_color(colors, index),+ _chart_color(colors, color_index),fill_opacity=fill_opacity,line_width=line_width,)@@ -325,7 +371,10 @@ def _series_xml(smooth_xml = '<c:smooth val="0"/>'if chart_type == "radar":if radar_style == "filled":- color_xml = _series_color_xml(_chart_color(colors, index), line=False)+ color_xml = _series_color_xml(+ _chart_color(colors, color_index),+ line=False,+ )marker_xml = _marker_xml(radar_marker_style)invert_xml = '<c:invertIfNegative val="0"/>' if chart_type in {"bar", "column"} else ""data_labels_xml = (@@ -351,10 +400,7 @@ def _series_xml("</c:strRef></c:tx>"f"{color_xml}{invert_xml}{marker_xml}{point_colors_xml}"f"{data_labels_xml}"- "<c:cat><c:strRef>"- f"<c:f>Sheet1!$A$2:$A${len(categories) + 1}</c:f>"- f"{_string_cache(categories)}"- "</c:strRef></c:cat>"+ f"{category_xml}""<c:val><c:numRef>"f"<c:f>Sheet1!${_excel_col(column_index)}$2:${_excel_col(column_index)}${len(categories) + 1}</c:f>"f"{_number_cache(item['values'])}"@@ -573,7 +619,58 @@ def _line_area_chart_group_xml()-def _secondary_axis_xml(+def _axis_scaling_xml(config: dict[str, Any]) -> str:+ orientation = "maxMin" if config.get("reverse") else "minMax"+ maximum = (+ f'<c:max val="{config["maximum"]}"/>'+ if config.get("maximum") is not None else ""+ )+ minimum = (+ f'<c:min val="{config["minimum"]}"/>'+ if config.get("minimum") is not None else ""+ )+ return f'<c:scaling><c:orientation val="{orientation}"/>{maximum}{minimum}</c:scaling>'+++def _axis_position(config: dict[str, Any], default: str) -> str:+ return {+ "bottom": "b",+ "left": "l",+ "right": "r",+ "top": "t",+ }.get(str(config.get("position") or ""), default)+++def _axis_label_position(config: dict[str, Any], default: str) -> str:+ return {+ "high": "high",+ "low": "low",+ "next_to": "nextTo",+ "none": "none",+ }.get(str(config.get("label_position") or ""), default)+++def _axis_number_format_xml(+ config: dict[str, Any],+ default: str | None = None,+) -> str:+ number_format = config.get("number_format", default)+ if number_format is None:+ return ""+ return f'<c:numFmt formatCode="{_xml_escape(str(number_format))}" sourceLinked="0"/>'+++def _axis_major_gridlines_xml(+ config: dict[str, Any],+ *,+ default: bool,+ color: str | None,+) -> str:+ enabled = config.get("major_gridlines", default)+ return _major_gridlines_xml(color) if enabled else ""+++def _axis_pair_xml(cat_ax_id: str,val_ax_id: str,*,@@ -581,46 +678,132 @@ def _secondary_axis_xml(axis_title_font_size: int,axis_titles: dict[str, Any],chart_style: dict[str, str | None],- grouping: str | None = None,+ chart_type: str,+ grouping: str | None,+ show_value_axis_labels: bool,+ axes: dict[str, dict[str, Any]],+ secondary: bool,) -> str:- val_num_fmt = (- '<c:numFmt formatCode="0%" sourceLinked="0"/>'- if grouping == "percentStacked"- else ""+ category_role = "secondary_category" if secondary else "category"+ value_role = "secondary_value" if secondary else "value"+ category = axes.get(category_role, {})+ value = axes.get(value_role, {})+ category_kind = str(category.get("kind") or ("date" if chart_type == "stock" else "text"))+ category_tag = "dateAx" if category_kind == "date" else "catAx"+ default_cat_pos = "l" if chart_type == "bar" else "b"+ default_val_pos = "r" if secondary else ("b" if chart_type == "bar" else "l")+ cat_pos = _axis_position(category, default_cat_pos)+ val_pos = _axis_position(value, default_val_pos)+ cat_delete = _bool_attr(not category.get("visible", not secondary))+ val_delete = _bool_attr(not value.get("visible", True))+ cat_tick_label_pos = _axis_label_position(category, "nextTo")+ default_val_tick = "nextTo" if show_value_axis_labels else "none"+ val_tick_label_pos = _axis_label_position(value, default_val_tick)+ default_value_format = "0%" if grouping == "percentStacked" else None+ cat_number_format = _axis_number_format_xml(+ category,+ "m/d/yyyy" if category_kind == "date" else None,)+ val_number_format = _axis_number_format_xml(value, default_value_format)axis_sp_pr = _chart_line_sp_pr_xml(chart_style.get("axis_color"))axis_tx_pr = _chart_tx_pr_xml(axis_font_size,chart_style.get("text_color"),font_face=chart_style.get("font_face"),)+ cat_title_xml = "" if secondary else _axis_title_xml(+ _first_present(axis_titles.get("category"), axis_titles.get("x")),+ font_size=axis_title_font_size,+ color=chart_style.get("text_color"),+ font_face=chart_style.get("font_face"),+ )+ value_title_key = "secondary_value" if secondary else "value"+ value_title = axis_titles.get(value_title_key)+ if not secondary:+ value_title = _first_present(value_title, axis_titles.get("y"))val_title_xml = _axis_title_xml(- axis_titles.get("secondary_value"),+ value_title,font_size=axis_title_font_size,color=chart_style.get("text_color"),font_face=chart_style.get("font_face"),)- # Hidden secondary category axis controls secondary area fill baseline.+ cat_gridlines = _axis_major_gridlines_xml(+ category,+ default=False,+ color=chart_style.get("grid_color"),+ )+ val_gridlines = _axis_major_gridlines_xml(+ value,+ default=not secondary,+ color=chart_style.get("grid_color"),+ )+ if category_kind == "date":+ category_tail = '<c:auto val="1"/><c:lblOffset val="100"/><c:baseTimeUnit val="days"/>'+ else:+ category_tail = (+ '<c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/>'+ '<c:noMultiLvlLbl val="0"/>'+ )+ is_combo = chart_type == "combo"+ cross_between = ""+ if chart_type == "area" and category_kind == "date":+ cross_between = '<c:crossBetween val="midCat"/>'+ elif chart_type == "stock" or is_combo:+ cross_between = '<c:crossBetween val="between"/>'+ major_unit = (+ f'<c:majorUnit val="{value["major_unit"]}"/>'+ if value.get("major_unit") is not None else ""+ )+ value_crosses = "max" if secondary else "autoZero"return (- "<c:catAx>"- f'<c:axId val="{cat_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- '<c:delete val="1"/><c:axPos val="b"/><c:majorTickMark val="none"/>'- '<c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/>'+ f"<c:{category_tag}>"+ f'<c:axId val="{cat_ax_id}"/>{_axis_scaling_xml(category)}'+ f'<c:delete val="{cat_delete}"/><c:axPos val="{cat_pos}"/>'+ f"{cat_gridlines}{cat_title_xml}{cat_number_format}"+ '<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'+ f'<c:tickLblPos val="{cat_tick_label_pos}"/>'f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{val_ax_id}"/><c:crosses val="autoZero"/><c:auto val="1"/>'- '<c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/>'- "</c:catAx>"+ f'<c:crossAx val="{val_ax_id}"/><c:crosses val="autoZero"/>{category_tail}'+ f"</c:{category_tag}>""<c:valAx>"- f'<c:axId val="{val_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- f'<c:delete val="0"/><c:axPos val="r"/>{val_title_xml}{val_num_fmt}'+ f'<c:axId val="{val_ax_id}"/>{_axis_scaling_xml(value)}'+ f'<c:delete val="{val_delete}"/><c:axPos val="{val_pos}"/>'+ f"{val_gridlines}{val_title_xml}{val_number_format}"'<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'- '<c:tickLblPos val="nextTo"/>'+ f'<c:tickLblPos val="{val_tick_label_pos}"/>'f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{cat_ax_id}"/><c:crosses val="max"/>'+ f'<c:crossAx val="{cat_ax_id}"/><c:crosses val="{value_crosses}"/>'+ f"{cross_between}{major_unit}""</c:valAx>")+def _secondary_axis_xml(+ cat_ax_id: str,+ val_ax_id: str,+ *,+ axis_font_size: int,+ axis_title_font_size: int,+ axis_titles: dict[str, Any],+ chart_style: dict[str, str | None],+ grouping: str | None = None,+ axes: dict[str, dict[str, Any]] | None = None,+) -> str:+ return _axis_pair_xml(+ cat_ax_id,+ val_ax_id,+ axis_font_size=axis_font_size,+ axis_title_font_size=axis_title_font_size,+ axis_titles=axis_titles,+ chart_style=chart_style,+ chart_type="combo",+ grouping=grouping,+ show_value_axis_labels=True,+ axes=axes or {},+ secondary=True,+ )++def _combo_axis_grouping(plots: list[dict[str, Any]], axis: str) -> str | None:for plot in plots:if plot.get("axis") == axis and plot.get("grouping") == "percentStacked":@@ -645,7 +828,7 @@ def _combo_plot_xml(axis_titles: dict[str, Any],chart_style: dict[str, str | None],) -> str:- categories = chart_data["categories"]+ axes = chart_data.get("axes") or {}primary_cat_ax_id = "2068027336"primary_val_ax_id = "2113994440"secondary_cat_ax_id = "2080229232"@@ -653,10 +836,14 @@ def _combo_plot_xml(parts: list[str] = []for plot in sorted(chart_data["plots"], key=_combo_plot_layer):+ categories = plot["categories"]+ category_is_numeric = bool(plot.get("category_is_numeric"))chart_type = plot["type"]axis = plot.get("axis", "primary")cat_ax_id = secondary_cat_ax_id if axis == "secondary" else primary_cat_ax_idval_ax_id = secondary_val_ax_id if axis == "secondary" else primary_val_ax_id+ category_role = "secondary_category" if axis == "secondary" else "category"+ category_number_format = axes.get(category_role, {}).get("number_format")start_index = int(plot.get("start_index", 0))grouping = plot.get("grouping") or ("clustered" if chart_type == "column" else "standard")ser_xml = _series_xml(@@ -665,12 +852,17 @@ def _combo_plot_xml(chart_type=chart_type,grouping=grouping,colors=colors,+ category_is_numeric=category_is_numeric,+ category_number_format=category_number_format,data_labels=_data_labels_config(plot),data_label_font_size=axis_font_size,data_label_color=chart_style.get("text_color"),data_label_font_face=chart_style.get("font_face"),line_style=plot.get("line_style", "line"),- start_column=2 + start_index,+ category_column=int(plot.get("category_column", 1)),+ color_start_index=start_index,+ series_indices=plot.get("series_indices"),+ start_column=int(plot.get("start_column", 2 + start_index)),start_index=start_index,)data_labels = _data_labels_config(plot)@@ -717,8 +909,9 @@ def _combo_plot_xml(axis_title_font_size=axis_title_font_size,axis_titles=axis_titles,chart_style=chart_style,- chart_type="column",+ chart_type="combo",grouping=_combo_axis_grouping(chart_data["plots"], "primary"),+ axes=axes,)if has_secondary_axis:axes_xml += _secondary_axis_xml(@@ -729,6 +922,7 @@ def _combo_plot_xml(axis_titles=axis_titles,chart_style=chart_style,grouping=_combo_axis_grouping(chart_data["plots"], "secondary"),+ axes=axes,)return "".join(parts) + axes_xml@@ -803,6 +997,19 @@ def _chart_plot_xml(if chart_type == "stock":stock_cat_ax_id = "2068027336"stock_val_ax_id = "2113994440"+ stock_axes = chart_data.get("axes") or {}+ stock_category_format = None+ if stock_axes:+ stock_category_format = (+ stock_axes.get("category", {}).get("number_format")+ or "m/d/yyyy"+ )+ stock_series_xml = _stock_series_xml(+ categories,+ series,+ colors=colors,+ category_number_format=stock_category_format,+ )axes_xml = _stock_axis_xml(stock_cat_ax_id,stock_val_ax_id,@@ -810,10 +1017,11 @@ def _chart_plot_xml(axis_title_font_size=axis_title_font_size,axis_titles=axis_titles,chart_style=chart_style,+ axes=stock_axes,)return ("<c:stockChart>"- f"{_stock_series_xml(categories, series, colors=colors)}"+ f"{stock_series_xml}"'<c:hiLowLines/>''<c:upDownBars><c:gapWidth val="150"/><c:upBars/><c:downBars/></c:upDownBars>'f'<c:axId val="{stock_cat_ax_id}"/><c:axId val="{stock_val_ax_id}"/>'@@ -832,6 +1040,17 @@ def _chart_plot_xml(radar_marker_style=chart_data.get("radar_marker_style"),radar_style=chart_data.get("radar_style", "marker"),colors=colors,+ category_is_numeric=_category_axis_is_date(chart_data.get("axes") or {}),+ category_number_format=(+ (chart_data.get("axes") or {})+ .get("category", {})+ .get(+ "number_format",+ "m/d/yyyy"+ if _category_axis_is_date(chart_data.get("axes") or {})+ else None,+ )+ ),data_labels=chart_data.get("data_labels"),data_label_font_size=axis_font_size,data_label_color=chart_style.get("text_color"),@@ -865,6 +1084,7 @@ def _chart_plot_xml(chart_type=chart_type,grouping=grouping,show_value_axis_labels=chart_data.get("show_value_axis_labels", True),+ axes=chart_data.get("axes") or {},)overlap_xml = ('<c:overlap val="100"/>'@@ -901,6 +1121,7 @@ def _chart_plot_xml(chart_type=chart_type,grouping=grouping,show_value_axis_labels=chart_data.get("show_value_axis_labels", True),+ axes=chart_data.get("axes") or {},)line_tail_xml = '<c:marker val="1"/><c:smooth val="0"/>' if chart_type == "line" else ""return (@@ -939,6 +1160,7 @@ def _chart_plot_xml(chart_style=chart_style,chart_type=chart_type,show_value_axis_labels=chart_data.get("show_value_axis_labels", True),+ axes=chart_data.get("axes") or {},)return (f'<c:radarChart><c:radarStyle val="{radar_style}"/>'@@ -962,51 +1184,20 @@ def _axis_xml(chart_type: str,grouping: str | None = None,show_value_axis_labels: bool = True,+ axes: dict[str, dict[str, Any]] | None = None,) -> str:- cat_pos = "l" if chart_type == "bar" else "b"- val_pos = "b" if chart_type == "bar" else "l"- val_num_fmt = (- '<c:numFmt formatCode="0%" sourceLinked="0"/>'- if grouping == "percentStacked"- else ""- )- val_tick_label_pos = "nextTo" if show_value_axis_labels else "none"- axis_sp_pr = _chart_line_sp_pr_xml(chart_style.get("axis_color"))- axis_tx_pr = _chart_tx_pr_xml(- axis_font_size,- chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- cat_title_xml = _axis_title_xml(- _first_present(axis_titles.get("category"), axis_titles.get("x")),- font_size=axis_title_font_size,- color=chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- val_title_xml = _axis_title_xml(- _first_present(axis_titles.get("value"), axis_titles.get("y")),- font_size=axis_title_font_size,- color=chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- return (- "<c:catAx>"- f'<c:axId val="{cat_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- f'<c:delete val="0"/><c:axPos val="{cat_pos}"/>{cat_title_xml}<c:majorTickMark val="out"/>'- '<c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/>'- f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{val_ax_id}"/><c:crosses val="autoZero"/><c:auto val="1"/>'- '<c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/>'- "</c:catAx>"- "<c:valAx>"- f'<c:axId val="{val_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- f'<c:delete val="0"/><c:axPos val="{val_pos}"/>{_major_gridlines_xml(chart_style.get("grid_color"))}'- f"{val_title_xml}{val_num_fmt}"- '<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'- f'<c:tickLblPos val="{val_tick_label_pos}"/>'- f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{cat_ax_id}"/><c:crosses val="autoZero"/>'- "</c:valAx>"+ return _axis_pair_xml(+ cat_ax_id,+ val_ax_id,+ axis_font_size=axis_font_size,+ axis_title_font_size=axis_title_font_size,+ axis_titles=axis_titles,+ chart_style=chart_style,+ chart_type=chart_type,+ grouping=grouping,+ show_value_axis_labels=show_value_axis_labels,+ axes=axes or {},+ secondary=False,)@@ -1063,6 +1254,7 @@ def _stock_series_xml(series: list[dict[str, Any]],*,colors: list[str],+ category_number_format: str | None = None,) -> str:parts: list[str] = []for index, item in enumerate(series):@@ -1078,7 +1270,7 @@ def _stock_series_xml('<c:marker><c:symbol val="none"/></c:marker>'"<c:cat><c:numRef>"f"<c:f>Sheet1!$A$2:$A${len(categories) + 1}</c:f>"- f"{_number_cache(categories)}"+ f"{_number_cache(categories, category_number_format or 'General')}""</c:numRef></c:cat>""<c:val><c:numRef>"f"<c:f>Sheet1!${_excel_col(column_index)}$2:${_excel_col(column_index)}${len(categories) + 1}</c:f>"@@ -1098,44 +1290,22 @@ def _stock_axis_xml(axis_title_font_size: int,axis_titles: dict[str, Any],chart_style: dict[str, str | None],+ axes: dict[str, dict[str, Any]] | None = None,) -> str:- axis_sp_pr = _chart_line_sp_pr_xml(chart_style.get("axis_color"))- axis_tx_pr = _chart_tx_pr_xml(- axis_font_size,- chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- cat_title_xml = _axis_title_xml(- _first_present(axis_titles.get("category"), axis_titles.get("x")),- font_size=axis_title_font_size,- color=chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- val_title_xml = _axis_title_xml(- _first_present(axis_titles.get("value"), axis_titles.get("y")),- font_size=axis_title_font_size,- color=chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- )- return (- "<c:dateAx>"- f'<c:axId val="{cat_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- '<c:delete val="0"/><c:axPos val="b"/>'- f'{cat_title_xml}<c:numFmt formatCode="m/d/yyyy" sourceLinked="1"/>'- '<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'- '<c:tickLblPos val="nextTo"/>'- f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{val_ax_id}"/><c:crosses val="autoZero"/>'- '<c:auto val="1"/><c:lblOffset val="100"/><c:baseTimeUnit val="days"/>'- "</c:dateAx>"- "<c:valAx>"- f'<c:axId val="{val_ax_id}"/><c:scaling><c:orientation val="minMax"/></c:scaling>'- f'<c:delete val="0"/><c:axPos val="l"/>{_major_gridlines_xml(chart_style.get("grid_color"))}'- f'{val_title_xml}<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'- '<c:tickLblPos val="nextTo"/>'- f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{cat_ax_id}"/><c:crosses val="autoZero"/>'- "</c:valAx>"+ normalized_axes = dict(axes or {})+ normalized_axes.setdefault("category", {"kind": "date", "position": "bottom"})+ return _axis_pair_xml(+ cat_ax_id,+ val_ax_id,+ axis_font_size=axis_font_size,+ axis_title_font_size=axis_title_font_size,+ axis_titles=axis_titles,+ chart_style=chart_style,+ chart_type="stock",+ grouping=None,+ show_value_axis_labels=True,+ axes=normalized_axes,+ secondary=False,)diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.pyindex 5c5b02b8..1359715c 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py@@ -2,6 +2,7 @@from __future__ import annotations+from dataclasses import dataclassfrom typing import Anyfrom xml.etree import ElementTree as ET@@ -59,15 +60,17 @@ def _cell_payload(value: Any) -> dict[str, Any]:return {"text": "" if value is None else str(value)}-_TABLE_SPAN_KEYS = {+_TABLE_CANONICAL_SPAN_KEYS = {"col_span",+ "row_span",+}+_TABLE_UNSUPPORTED_SPAN_KEYS = {"colSpan","grid_span","gridSpan","hMerge","merge","merged",- "row_span","rowSpan","vMerge",}@@ -81,6 +84,27 @@ _TABLE_MAX_ROWS = 1000_TABLE_MAX_COLUMNS = 1000+@dataclass(frozen=True)+class _TableMergeRegion:+ row: int+ col: int+ row_span: int+ col_span: int+++@dataclass(frozen=True)+class _TableBorderSpec:+ style: str+ color: str | None = None+ width: float | None = None+++@dataclass(frozen=True)+class _TableParagraph:+ text: str+ align: str | None = None++def _table_rows(payload: dict[str, Any]) -> list[list[Any]]:columns = payload.get("columns") or []rows = payload.get("rows") or []@@ -95,25 +119,154 @@ def _table_rows(payload: dict[str, Any]) -> list[list[Any]]:return table_rows-def _check_table_spans(payload: dict[str, Any], table_rows: list[list[Any]]) -> None:+def _table_cell_paragraphs(+ cell_data: dict[str, Any],+) -> tuple[_TableParagraph, ...] | None:+ if "paragraphs" not in cell_data:+ return None+ if "text" in cell_data:+ raise RuntimeError(+ "Native PPTX table cell text and paragraphs are mutually exclusive"+ )+ raw_paragraphs = cell_data.get("paragraphs")+ if not isinstance(raw_paragraphs, list) or not raw_paragraphs:+ raise RuntimeError(+ "Native PPTX table cell paragraphs must be a non-empty list"+ )++ paragraphs: list[_TableParagraph] = []+ for idx, value in enumerate(raw_paragraphs, start=1):+ if isinstance(value, str):+ paragraphs.append(_TableParagraph(value))+ continue+ if not isinstance(value, dict) or "text" not in value:+ raise RuntimeError(+ f"Native PPTX table paragraph {idx} must be a string or text object"+ )+ if set(value) - {"text", "align"}:+ raise RuntimeError(+ f"Native PPTX table paragraph {idx} accepts text/align only"+ )+ text = value.get("text")+ if not isinstance(text, str):+ raise RuntimeError(+ f"Native PPTX table paragraph {idx} text must be a string"+ )+ align = value.get("align")+ if align is not None and align not in {"l", "ctr", "r"}:+ raise RuntimeError(+ f"Native PPTX table paragraph {idx} align must be l, ctr, or r"+ )+ paragraphs.append(_TableParagraph(text, align))+ return tuple(paragraphs)+++def _table_span_value(+ cell_data: dict[str, Any],+ key: str,+ *,+ row_idx: int,+ col_idx: int,+) -> int:+ value = cell_data.get(key, 1)+ if isinstance(value, bool) or not isinstance(value, int) or value <= 0:+ raise RuntimeError(+ f"Native PPTX table cell R{row_idx}C{col_idx} {key} must be a "+ "positive JSON integer"+ )+ return value+++def _merge_covered_cell_is_blank(value: Any) -> bool:+ if value is None or value == "":+ return True+ if not isinstance(value, dict):+ return False+ if any(key != "text" for key in value):+ return False+ text = value.get("text")+ return text is None or text == ""+++def _resolve_table_merge_layout(+ payload: dict[str, Any],+ table_rows: list[list[Any]],+ col_count: int,+) -> dict[tuple[int, int], _TableMergeRegion]:for key in _TABLE_TOP_LEVEL_SPAN_KEYS:if key in payload:raise RuntimeError(- "Native PPTX table merged cells are not supported; use SVG fallback "- "or merge cells in PowerPoint after export"+ f"Native PPTX table uses unsupported top-level merged-cell field: {key}")++ owners: dict[tuple[int, int], _TableMergeRegion] = {}for row_idx, row in enumerate(table_rows, start=1):for col_idx, cell in enumerate(row, start=1):- if not isinstance(cell, dict):+ if isinstance(cell, dict):+ used_keys = sorted(+ key for key in _TABLE_UNSUPPORTED_SPAN_KEYS if key in cell+ )+ if used_keys:+ keys = ", ".join(used_keys)+ raise RuntimeError(+ f"Native PPTX table cell R{row_idx}C{col_idx} uses "+ f"unsupported merged-cell field(s): {keys}; use row_span/col_span "+ "on the merge anchor"+ )++ position = (row_idx - 1, col_idx - 1)+ owner = owners.get(position)+ if owner is not None:+ if isinstance(cell, dict) and any(+ key in cell for key in _TABLE_CANONICAL_SPAN_KEYS+ ):+ raise RuntimeError(+ f"Native PPTX table merge anchor R{row_idx}C{col_idx} overlaps "+ f"merge rooted at R{owner.row + 1}C{owner.col + 1}"+ )+ if not _merge_covered_cell_is_blank(cell):+ raise RuntimeError(+ f"Native PPTX table merge-covered cell R{row_idx}C{col_idx} "+ "must be blank"+ )continue- used_keys = sorted(key for key in _TABLE_SPAN_KEYS if key in cell)- if used_keys:- keys = ", ".join(used_keys)++ cell_data = _cell_payload(cell)+ row_span = _table_span_value(+ cell_data, "row_span", row_idx=row_idx, col_idx=col_idx,+ )+ col_span = _table_span_value(+ cell_data, "col_span", row_idx=row_idx, col_idx=col_idx,+ )+ if row_span == 1 and col_span == 1:+ continue+ if (+ row_idx - 1 + row_span > len(table_rows)+ or col_idx - 1 + col_span > col_count+ ):raise RuntimeError(- f"Native PPTX table cell R{row_idx}C{col_idx} uses unsupported "- f"merged-cell field(s): {keys}"+ f"Native PPTX table merge rooted at R{row_idx}C{col_idx} exceeds "+ f"the resolved {len(table_rows)}x{col_count} grid")+ region = _TableMergeRegion(+ row=row_idx - 1,+ col=col_idx - 1,+ row_span=row_span,+ col_span=col_span,+ )+ for covered_row in range(region.row, region.row + region.row_span):+ for covered_col in range(region.col, region.col + region.col_span):+ covered_position = (covered_row, covered_col)+ prior = owners.get(covered_position)+ if prior is not None:+ raise RuntimeError(+ f"Native PPTX table merge rooted at R{row_idx}C{col_idx} "+ f"overlaps merge rooted at R{prior.row + 1}C{prior.col + 1}"+ )+ owners[covered_position] = region+ return owners+def _grid_is_strict(payload: dict[str, Any]) -> bool:value = payload.get("strict_grid", payload.get("strictGrid"))@@ -177,29 +330,40 @@ def _validate_table_lengths(payload: dict[str, Any], table_rows: list[list[Any]]def _validate_table_cell_formatting(payload: dict[str, Any], table_rows: list[list[Any]]) -> None:style = payload.get("style") if isinstance(payload.get("style"), dict) else {}_table_bool(style.get("band_row"), "style.band_row", default=True)+ if "borders" in style:+ raise RuntimeError(+ "Native PPTX table per-side borders are supported on cells only"+ )for row in table_rows:for cell in row:cell_data = _cell_payload(cell)+ _table_cell_paragraphs(cell_data)if "bold" in cell_data:_table_bool(cell_data["bold"], "cell bold", default=False)for side in ("left", "right", "top", "bottom"):_table_padding_value(cell_data, style, side)- border_width = _table_border_width(cell_data, style)- if border_width > 0:+ for border in _table_border_specs(cell_data, style).values():+ if border is None or border.style == "none":+ continue+ assert border.width is not None_powerpoint_line_width_emu(- border_width,+ border.width,"table border_width",)_table_anchor(cell_data, style)-def _validate_table_payload(payload: dict[str, Any]) -> tuple[list[list[Any]], int]:+def _validate_table_payload(+ payload: dict[str, Any],+) -> tuple[list[list[Any]], int, dict[tuple[int, int], _TableMergeRegion]]:table_rows = _table_rows(payload)- _check_table_spans(payload, table_rows)col_count = _validate_table_lengths(payload, table_rows)+ for row in table_rows:+ row.extend([""] * (col_count - len(row)))+ merge_layout = _resolve_table_merge_layout(payload, table_rows, col_count)_table_header_rows(payload, len(table_rows))_validate_table_cell_formatting(payload, table_rows)- return table_rows, col_count+ return table_rows, col_count, merge_layoutdef _native_table_metadata_texts(table_rows: list[list[Any]]) -> dict[str, int]:@@ -207,9 +371,16 @@ def _native_table_metadata_texts(table_rows: list[list[Any]]) -> dict[str, int]:for row in table_rows:for cell in row:cell_data = _cell_payload(cell)- text = _normalized_fallback_text(cell_data.get("text"))- if text:- counts[text] = counts.get(text, 0) + 1+ paragraphs = _table_cell_paragraphs(cell_data)+ texts = (+ [paragraph.text for paragraph in paragraphs]+ if paragraphs is not None+ else [cell_data.get("text")]+ )+ for value in texts:+ text = _normalized_fallback_text(value)+ if text:+ counts[text] = counts.get(text, 0) + 1return counts@@ -363,35 +534,158 @@ def _table_border_width(cell_data: dict[str, Any], style: dict[str, Any]) -> floreturn _number(1 if width_raw is None else width_raw, "table border_width")+_TABLE_BORDER_SIDES = ("left", "right", "top", "bottom")+_TABLE_BORDER_TAGS = {+ "left": "lnL",+ "right": "lnR",+ "top": "lnT",+ "bottom": "lnB",+}+++def _strict_table_border_color(value: Any, side: str) -> str:+ raw = value if isinstance(value, str) else ""+ if len(raw) != 7 or not raw.startswith("#"):+ raise RuntimeError(+ f"Native PPTX table {side} border color must be #RRGGBB"+ )+ try:+ int(raw[1:], 16)+ except ValueError as exc:+ raise RuntimeError(+ f"Native PPTX table {side} border color must be #RRGGBB"+ ) from exc+ return raw[1:].upper()+++def _table_border_override(value: Any, side: str) -> _TableBorderSpec:+ if not isinstance(value, dict):+ raise RuntimeError(+ f"Native PPTX table {side} border must be an object"+ )+ border_style = value.get("style")+ if border_style == "none":+ if set(value) != {"style"}:+ raise RuntimeError(+ f"Native PPTX table {side} border style none accepts no other fields"+ )+ return _TableBorderSpec("none")+ if border_style != "solid":+ raise RuntimeError(+ f"Native PPTX table {side} border style must be solid or none"+ )+ if set(value) != {"style", "color", "width"}:+ raise RuntimeError(+ f"Native PPTX table {side} solid border requires style/color/width only"+ )+ width = _number(value.get("width"), f"table {side} border width")+ if width <= 0:+ raise RuntimeError(+ f"Native PPTX table {side} solid border width must be positive"+ )+ _powerpoint_line_width_emu(width, f"table {side} border width")+ return _TableBorderSpec(+ "solid",+ color=_strict_table_border_color(value.get("color"), side),+ width=width,+ )+++def _table_border_specs(+ cell_data: dict[str, Any],+ style: dict[str, Any],+) -> dict[str, _TableBorderSpec | None]:+ raw_borders = cell_data.get("borders")+ if raw_borders is None:+ border_overrides: dict[str, Any] = {}+ elif not isinstance(raw_borders, dict):+ raise RuntimeError("Native PPTX table cell borders must be an object")+ else:+ unknown = sorted(set(raw_borders) - set(_TABLE_BORDER_SIDES))+ if unknown:+ raise RuntimeError(+ "Native PPTX table cell borders use unsupported side(s): "+ + ", ".join(unknown)+ )+ border_overrides = raw_borders++ legacy_width = _table_border_width(cell_data, style)+ legacy_spec = (+ _TableBorderSpec(+ "solid",+ color=_clean_hex(+ cell_data.get(+ "border_color",+ cell_data.get("borderColor", style.get("border_color")),+ ),+ "#D9DEE7",+ ),+ width=legacy_width,+ )+ if legacy_width > 0+ else None+ )+ return {+ side: (+ _table_border_override(border_overrides[side], side)+ if side in border_overrides+ else legacy_spec+ )+ for side in _TABLE_BORDER_SIDES+ }++def _table_border_xml(cell_data: dict[str, Any],style: dict[str, Any],theme_color_spec: ThemeColorSpec | None,) -> str:- color_raw = cell_data.get("border_color", cell_data.get("borderColor", style.get("border_color")))- width = _table_border_width(cell_data, style)- if width <= 0:+ border_xml: list[str] = []+ for side, border in _table_border_specs(cell_data, style).items():+ if border is None:+ continue+ tag = _TABLE_BORDER_TAGS[side]+ if border.style == "none":+ border_xml.append(f'<a:{tag}><a:noFill/></a:{tag}>')+ continue+ assert border.color is not None and border.width is not None+ line_width = _powerpoint_line_width_emu(+ border.width, f"table {side} border width",+ )+ border_xml.append(+ f'<a:{tag} w="{line_width}">'+ f'<a:solidFill>{color_node_xml(border.color, theme_color_spec, "stroke")}'+ '</a:solidFill>'+ '<a:prstDash val="solid"/>'+ f'</a:{tag}>'+ )+ return "".join(border_xml)+++def _table_merge_attrs(+ region: _TableMergeRegion | None,+ row_idx: int,+ col_idx: int,+) -> str:+ if region is None:return ""- color = _clean_hex(color_raw, "#D9DEE7")- line = (- f'<a:solidFill>{color_node_xml(color, theme_color_spec, "stroke")}</a:solidFill>'- '<a:prstDash val="solid"/>'- )- line_width = _powerpoint_line_width_emu(width, "table border_width")- return "".join(- f'<a:{tag} w="{line_width}">{line}</a:{tag}>'- for tag in ("lnL", "lnR", "lnT", "lnB")- )+ attrs: list[str] = []+ if row_idx == region.row and region.row_span > 1:+ attrs.append(f'rowSpan="{region.row_span}"')+ if col_idx == region.col and region.col_span > 1:+ attrs.append(f'gridSpan="{region.col_span}"')+ if col_idx > region.col:+ attrs.append('hMerge="1"')+ if row_idx > region.row:+ attrs.append('vMerge="1"')+ return (" " + " ".join(attrs)) if attrs else ""def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str, Any]) -> ShapeResult:- table_rows, col_count = _validate_table_payload(payload)+ table_rows, col_count, merge_layout = _validate_table_payload(payload)header_rows = _table_header_rows(payload, len(table_rows))preserve_source_style = elem.get("data-pptx-native-source") == "pptx"- for row in table_rows:- row.extend([""] * (col_count - len(row)))-style = payload.get("style") if isinstance(payload.get("style"), dict) else {}header_fill = _clean_hex(style.get("header_fill"), "#1F4E79")header_text = _clean_hex(style.get("header_text"), "#FFFFFF")@@ -432,7 +726,20 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[strfor row_idx, row in enumerate(table_rows):is_header = row_idx < header_rowscells_xml: list[str] = []- for cell in row:+ for col_idx, cell in enumerate(row):+ merge_region = merge_layout.get((row_idx, col_idx))+ merge_attrs = _table_merge_attrs(merge_region, row_idx, col_idx)+ if merge_region is not None and (+ row_idx != merge_region.row or col_idx != merge_region.col+ ):+ cells_xml.append(+ f'<a:tc{merge_attrs}>'+ '<a:txBody><a:bodyPr/><a:lstStyle/><a:p/></a:txBody>'+ '<a:tcPr/>'+ '</a:tc>'+ )+ continue+cell_data = _cell_payload(cell)if preserve_source_style:fill = (@@ -460,7 +767,7 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[stralign = str(cell_data.get("align") or ("ctr" if is_header else "l"))if align not in {"l", "ctr", "r"}:align = "l"- text = "" if cell_data.get("text") is None else str(cell_data.get("text"))+ paragraphs = _table_cell_paragraphs(cell_data)if preserve_source_style:bold = (_table_bool(cell_data["bold"], "cell bold", default=False)@@ -479,7 +786,52 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str)if is_header and "font_size" not in cell_data:cell_font_size = header_font_size- paragraph_props = f'<a:pPr algn="{align}"/>' if align != "l" else "<a:pPr/>"+ language = (+ str(cell_data.get("lang") or style.get("lang") or "").strip()+ or None+ )+ if paragraphs is None:+ text = (+ "" if cell_data.get("text") is None+ else str(cell_data.get("text"))+ )+ paragraph_props = (+ f'<a:pPr algn="{align}"/>' if align != "l" else "<a:pPr/>"+ )+ text_run_xml = _table_text_run(+ text,+ color=color,+ bold=bold,+ font_size=cell_font_size,+ font_face=font_face,+ language=language,+ theme_color_spec=ctx.theme_color_spec,+ )+ paragraphs_xml = (+ f"<a:p>{paragraph_props}{text_run_xml}</a:p>"+ )+ else:+ paragraph_parts: list[str] = []+ for paragraph in paragraphs:+ paragraph_align = paragraph.align or align+ paragraph_props = (+ f'<a:pPr algn="{paragraph_align}"/>'+ if paragraph.align is not None or paragraph_align != "l"+ else "<a:pPr/>"+ )+ text_run_xml = _table_text_run(+ paragraph.text,+ color=color,+ bold=bold,+ font_size=cell_font_size,+ font_face=font_face,+ language=language,+ theme_color_spec=ctx.theme_color_spec,+ )+ paragraph_parts.append(+ f"<a:p>{paragraph_props}{text_run_xml}</a:p>"+ )+ paragraphs_xml = "".join(paragraph_parts)anchor_keys = {"valign", "vertical_align"}anchor_attr = ""if not preserve_source_style or anchor_keys.intersection(cell_data) or anchor_keys.intersection(style):@@ -496,24 +848,11 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str'</a:solidFill>'if fill else "")- text_run_xml = _table_text_run(- text,- color=color,- bold=bold,- font_size=cell_font_size,- font_face=font_face,- language=(- str(cell_data.get("lang") or style.get("lang") or "").strip()- or None- ),- theme_color_spec=ctx.theme_color_spec,- )cells_xml.append(- "<a:tc>"+ f"<a:tc{merge_attrs}>""<a:txBody><a:bodyPr/><a:lstStyle/>"- f"<a:p>{paragraph_props}"- f"{text_run_xml}"- "</a:p></a:txBody>"+ f"{paragraphs_xml}"+ "</a:txBody>"f'<a:tcPr{tc_pr_attrs}>{border_xml}{fill_xml}</a:tcPr>'"</a:tc>")diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/workbook.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/workbook.pyindex f2ce2c4d..29770395 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/workbook.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/workbook.py@@ -127,6 +127,28 @@ def _minimal_workbook(rows: list[list[Any]]) -> bytes:def _minimal_category_chart_workbook(chart_data: dict[str, Any]) -> bytes:+ if chart_data.get("kind") == "combo" and chart_data.get("independent_categories"):+ plots = chart_data["plots"]+ column_count = max(+ int(plot["start_column"]) + len(plot["series"]) - 1+ for plot in plots+ )+ rows: list[list[Any]] = [[None] * column_count]+ for plot in plots:+ category_column = int(plot["category_column"]) - 1+ start_column = int(plot["start_column"]) - 1+ for offset, series in enumerate(plot["series"]):+ rows[0][start_column + offset] = series["name"]+ for point_index, category in enumerate(plot["categories"], start=1):+ while len(rows) <= point_index:+ rows.append([None] * column_count)+ rows[point_index][category_column] = category+ for offset, series in enumerate(plot["series"]):+ rows[point_index][start_column + offset] = (+ series["values"][point_index - 1]+ )+ return _minimal_workbook(rows)+categories = chart_data["categories"]series = chart_data["series"]rows: list[list[Any]] = [[None] + [item["name"] for item in series]]