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: —
| Feature id | pptx/shape-fill-color--green |
|---|---|
| Format | pptx |
| Category | shapes |
| Family | pptx/shape-fill-color |
| Axis values | color=green |
| Spec | ecma-376-5-part-1 § 20.1.8.54 a:solidFill |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
shape-fill-color-greenppt/slides/slide1.xml | equal = 00FF00The rectangle shape's <p:spPr> must declare <a:solidFill>/<a:srgbClr val="00FF00"/>. | //p:sp[p:spPr/a:prstGeom[@prst='rect']]/p:spPr/a:solidFill/a:srgbClr/@val | — | — |
No render assertions declared.
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())
{
"$schema": "../manifest.schema.json",
"id": "pptx/shape-fill-color--green",
"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--green"
},
"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": "green"
}
},
"assertions": [
{
"id": "shape-fill-color-green",
"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": "00FF00",
"description": "The rectangle shape's <p:spPr> must declare <a:solidFill>/<a:srgbClr val=\"00FF00\"/>."
}
]
}
