pptx/shape-fill-color--orange

An auto-shape's solid fill color, set via shape.fill.solid() + shape.fill.fore_color.rgb = RGBColor(...), emits <a:solidFill>/<a:srgbClr val="HEX6"/> inside the shape's <p:spPr>. This manifest is a parameterised family over 10 RGB primaries: one manifest file expands into 10 cases, each backed by a distinct fixture pptx/shape-fill-color--<id>.pptx generated from the same gen_shape_fill_color.py script parameterised by --rgb.

Library verdicts: python-pptx: — pptxjs: —

Metadata

Feature idpptx/shape-fill-color--orange
Formatpptx
Categoryshapes
Familypptx/shape-fill-color
Axis valuescolor=orange
Spececma-376-5-part-1 § 20.1.8.54 a:solidFill

XPath assertions

ID / partPredicateXPathpython-pptxpptxjs
shape-fill-color-orange
ppt/slides/slide1.xml
equal = FFA500
The rectangle shape's <p:spPr> must declare <a:solidFill>/<a:srgbClr val="FFA500"/>.
//p:sp[p:spPr/a:prstGeom[@prst='rect']]/p:spPr/a:solidFill/a:srgbClr/@val

Render assertions

No render assertions declared.

Generator source

scripts/gen_shape_fill_color.py

#!/usr/bin/env python3
"""Generate a single ``fixtures/pptx/shape-fill-color--<id>.pptx`` fixture.

Parameterised generator for the ``pptx/shape-fill-color`` manifest
family. The conformance runner invokes this script once per case with
``--rgb <HEX6> --out <path>``.

Each invocation produces a single-slide presentation containing one
rectangle auto-shape whose solid fill is set via
``shape.fill.solid(); shape.fill.fore_color.rgb = RGBColor(...)``.
The underlying XML is ``<p:sp>/<p:spPr>/<a:solidFill>/<a:srgbClr val="..."/>``;
the manifest asserts the ``@val`` attribute equals the axis ``rgb`` field.
"""

from __future__ import annotations

import argparse
import datetime as _dt
from pathlib import Path

from pptx import Presentation
from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
from pptx.util import Inches

_REPO_ROOT = Path(__file__).resolve().parent.parent
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)


def _write(rgb_hex: str, out: Path) -> None:
    rgb = RGBColor.from_string(rgb_hex)
    prs = Presentation()
    # "Title Only" layout — an empty title placeholder plus our shape.
    slide = prs.slides.add_slide(prs.slide_layouts[5])
    shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(1), Inches(1), Inches(3), Inches(2)
    )
    shape.fill.solid()
    shape.fill.fore_color.rgb = rgb
    out.parent.mkdir(parents=True, exist_ok=True)
    prs.save(out, zip_date_time=_REPRODUCIBLE_DT)


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--rgb",
        required=True,
        help="Six-hex-digit RGB value, uppercase (e.g. 'FF0000').",
    )
    parser.add_argument(
        "--out",
        required=True,
        help="Output fixture path (absolute or repo-relative).",
    )
    args = parser.parse_args()

    out_path = Path(args.out)
    if not out_path.is_absolute():
        out_path = _REPO_ROOT / out_path
    _write(args.rgb, out_path)
    print(out_path)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "pptx/shape-fill-color--orange",
  "kind": "literal",
  "title": "Shape solid fill color",
  "format": "pptx",
  "category": "shapes",
  "summary": "An auto-shape's solid fill color, set via shape.fill.solid() + shape.fill.fore_color.rgb = RGBColor(...), emits <a:solidFill>/<a:srgbClr val=\"HEX6\"/> inside the shape's <p:spPr>. This manifest is a parameterised family over 10 RGB primaries: one manifest file expands into 10 cases, each backed by a distinct fixture pptx/shape-fill-color--<id>.pptx generated from the same gen_shape_fill_color.py script parameterised by --rgb.",
  "spec": {
    "source": "ecma-376-5-part-1",
    "clause": "20.1.8.54",
    "element": "a:solidFill",
    "rnc_reference": "spec/ecma-376-5/part-1/rnc/DrawingML.rnc",
    "xsd_reference": "spec/ecma-376-5/part-1/xsd/dml-fill.xsd",
    "notes": "DrawingML <a:solidFill> wraps a colour choice; when the colour is a literal RGB triplet the child is <a:srgbClr val=\"HEX6\"/>, with val an uppercase six-hex-digit RGB triplet (ST_HexColorRGB). python-pptx's ``shape.fill.solid()`` switches the shape's fill to the solidFill flavour and ``shape.fill.fore_color.rgb = RGBColor(r, g, b)`` writes the srgbClr child. The assertion targets the <p:sp> whose <a:prstGeom prst=\"rect\"/> identifies it as the test rectangle, avoiding false matches against placeholder shapes in the slide layout."
  },
  "fixtures": {
    "machine": "pptx/shape-fill-color--orange"
  },
  "generator": {
    "python": "scripts/gen_shape_fill_color.py",
    "arg_template": "--rgb {color.rgb} --out fixtures/pptx/shape-fill-color--{color.id}.pptx"
  },
  "_expansion": {
    "parent_id": "pptx/shape-fill-color",
    "bindings": {
      "color": "orange"
    }
  },
  "assertions": [
    {
      "id": "shape-fill-color-orange",
      "part": "ppt/slides/slide1.xml",
      "namespaces": {
        "p": "http://schemas.openxmlformats.org/presentationml/2006/main",
        "a": "http://schemas.openxmlformats.org/drawingml/2006/main"
      },
      "xpath": "//p:sp[p:spPr/a:prstGeom[@prst='rect']]/p:spPr/a:solidFill/a:srgbClr/@val",
      "must": "equal",
      "value": "FFA500",
      "description": "The rectangle shape's <p:spPr> must declare <a:solidFill>/<a:srgbClr val=\"FFA500\"/>."
    }
  ]
}

Fixture

Download shape-fill-color--orange.pptx (27.6 KB)

Reference preview

Reference (machine, page 1 PNG)

pptx/shape-fill-color--orange page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec notes

DrawingML <a:solidFill> wraps a colour choice; when the colour is a literal RGB triplet the child is <a:srgbClr val="HEX6"/>, with val an uppercase six-hex-digit RGB triplet (ST_HexColorRGB). python-pptx's ``shape.fill.solid()`` switches the shape's fill to the solidFill flavour and ``shape.fill.fore_color.rgb = RGBColor(r, g, b)`` writes the srgbClr child. The assertion targets the <p:sp> whose <a:prstGeom prst="rect"/> identifies it as the test rectangle, avoiding false matches against placeholder shapes in the slide layout.