Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

12.2 KB
Raw Blame

pptx_engine test corpus

PPTX files for fidelity (pixel-diff) and parser tests of pptx_engine.

tests/corpus/
  manifest.json      one entry per deck: hash, size, slide count, generator, provenance, features
  generated/*.pptx   synthetic, feature-focused decks (regenerated by scripts/generate_corpus.py)
  wild/*.pptx        real-world decks downloaded from public sources (never modified)
scripts/
  generate_corpus.py     builds generated/ (python-pptx + raw DrawingML), validates, refreshes the manifest
  corpus_xml.py          DrawingML/PresentationML snippet builders, deterministic packaging
  corpus_media.py        code-generated PNG/JPEG/GIF/BMP/TIFF/EMF/WMF/SVG media
  update_manifest.py     recomputes derived manifest fields; registers new wild files
  inspect_pptx.py        JSON feature inventory of a deck (used for manifest `features`)
  render_references.py   LibreOffice reference PNGs for pixel diffs

Requirements: Python 3.11 with python-pptx 1.0.2, lxml, Pillow, XlsxWriter; LibreOffice 24.2 with Impress (libreoffice-impress; libreoffice-core alone cannot open PPTX) and poppler (pdftoppm, pdfinfo) for rendering.

manifest.json

{
  "schema": "pptx_engine corpus manifest v1",
  "totals": {"files": 53, "generated": 35, "wild": 18, "bytes": 15266258},
  "files": [{
    "path": "wild/mesa-2012-strategic-budget-review.pptx",
    "kind": "wild",                       // "generated" | "wild"
    "sha256": "…", "bytes": 478993,
    "slides": 22,                         // includes hidden slides
    "generator": "Microsoft Office PowerPoint 14.0000",   // docProps/app.xml Application + AppVersion
    "source_url": "https://…",            // wild only
    "retrieved": "2026-10-03",            // wild only
    "provenance": "Public record: …",
    "description": "…",
    "features": ["emf", "table", …],      // inspect_pptx feature tags ∪ curated_features
    "curated_features": [ … ],            // optional hand-added tags (kept across refreshes)
    "notes": "…"                          // optional
  }]
}

update_manifest.py recomputes sha256, bytes, slides, generator and features on every run and keeps the curated fields. AppVersion 12.x = PowerPoint 2007 (Mac 2008 writes 12.0001), 14.x = 2010 / Mac 2011, 15.x = 2013, 16.x = 2016+. LibreOffice also writes 15.0000, so read Application too.

Generated decks

python3 crates/pptx_engine/scripts/generate_corpus.py rebuilds every deck, checks package integrity (each r:id resolves, each relationship target exists, each part has a content type), and refreshes the manifest. Useful flags: --only NAME…, --list, --no-libreoffice, --no-manifest, --xsd-dir DIR.

  • Deterministic: fixed core-property timestamps, rewritten docProps/app.xml (Application = pptx_engine corpus generator (python-pptx 1.0.2)), zip entries dated 1980-01-01, embedded workbooks with a fixed creation date, media generated from code. Output is byte-identical for the same python-pptx/XlsxWriter/Pillow/zlib (and LibreOffice) versions.
  • Schema-valid: with --xsd-dir pointing at the ECMA-376 Part 4 transitional schemas (OfficeOpenXML-XMLSchema-Transitional from https://ecma-international.org/publications-and-standards/standards/ecma-376/), every slide/layout/master/theme/chart part is validated after markup-compatibility preprocessing. The only deviation is a:buSzPct/@val, written in the integer form PowerPoint uses (50000). python-pptx chart quirks (negative axis ids, c:smooth in radar series) are fixed on save.
  • Each deck is small (2–11 slides), titled per slide with what it exercises, 4:3 unless noted.
Area Decks
Text text-fonts-sizes, text-run-formatting, text-paragraphs, text-bullets-numbering, text-autofit-vertical-columns, text-unicode
Placeholders, theme placeholders-all-layouts (all 11 default layouts), inheritance-master-layout (lstStyle overrides, layout override, clrMapOvr), theme-custom-colors-fonts (custom clrScheme/fontScheme, style matrix, bgRef)
Shapes shapes-presets-all (all 187 presets), shapes-adjust-values, shapes-rotation-flip, shapes-custom-geometry
Fills, lines, effects fills-solid-gradient, fills-pattern-picture (all 54 patterns, picture/tile fills, grpFill), backgrounds (master/layout/slide, bgRef 1001–1003), lines-widths-dashes, lines-arrows-connectors, effects-shadow-glow-reflection (incl. 3D, effectRef)
Pictures, OLE pictures-raster-formats (PNG alpha, JPEG, GIF, BMP, TIFF), pictures-vector-emf-wmf-svg (hand-built EMF/WMF, SVG + PNG fallback), pictures-crop-effects (srcRect incl. negative, blip effects), ole-embedded-objects (embedded xlsx with EMF preview / icon)
Tables tables-merge-borders, tables-builtin-styles (12 built-in style GUIDs, flags, custom tableStyles.xml style), tables-financial-statement
Charts charts-basic, charts-advanced (combo with secondary axis, scatter, bubble, radar, 100% stacked, waterfall)
Structure groups-nested-transforms, slide-features (hidden slide, notes, sections, hyperlinks, footers, fields, comments), size-a4-portrait, kitchen-sink-financial (16:9 earnings deck)
LibreOffice-written lo-roundtrip-text-bullets, lo-roundtrip-shapes-fills, lo-roundtrip-kitchen-sink (pptx → odp → pptx with LibreOffice 24.2)

The PNG fallback inside pictures-vector-emf-wmf-svg carries a magenta corner triangle so you can see whether a renderer used the SVG or the fallback. slide-features.pptx slide 4 holds live date/time fields; renderers substitute the current date, so mask that slide in pixel diffs. All other footers use fixed date text.

To add a generated deck: write a deck_*() builder in generate_corpus.py (use the helpers in corpus_xml.py; keep child elements in schema order), register it in DECKS, run the script with --xsd-dir, then render it and check the PNGs.

Wild decks

18 real decks (14 MB), chosen for financial content, older PowerPoint versions and hard rendering features: Excel charts and tables pasted as EMF/WMF, OLE objects with EMF/WMF previews, native and 3D charts, an Office 2016 chartEx waterfall, SmartArt, VML, SVG icons, glow/shadow/3D effects, tables, hidden slides, multiple masters. They span PowerPoint 2007/2010/2013/2016+, PowerPoint 2008 and 2011 for Mac, and two binary .ppt decks converted with LibreOffice. Sources are US city and county legislative portals (Legistar public records), the US Census Bureau, the Federal Reserve Bank of Dallas, and the Apache POI test-data corpus (the two Mac decks). No Google Slides or Keynote export was found; the LibreOffice-written XML flavor is covered by generated/lo-roundtrip-* and the two converted .ppt decks.

Provenance policy:

  • Only publicly published files, recorded with source_url, retrieved and a provenance statement (publisher, document, date, copyright status). Prefer US federal works (public domain) and government public records; note third-party copyright when it applies.
  • No private personal data. Public officials' names or work contact details on public presentations are acceptable.
  • Files are stored byte-for-byte as downloaded. The only exception is a legacy binary .ppt converted with soffice --headless --convert-to pptx, named *-from-ppt.pptx and tagged converted-from-ppt.
  • Keep each file ≤ 4 MB (≤ 8 MB for exceptional files) and the whole wild/ directory ≤ ~30 MB.

To add a wild deck:

unzip -l new.pptx >/dev/null && python3 crates/pptx_engine/scripts/inspect_pptx.py new.pptx
cp new.pptx crates/pptx_engine/tests/corpus/wild/<publisher>-<year>-<topic>.pptx
python3 crates/pptx_engine/scripts/update_manifest.py --add wild/<name>.pptx \
  --source-url URL --provenance "Publisher, document, date; copyright status" \
  --description "What it is and which rendering features it exercises"

update_manifest.py refuses to write a manifest with a wild file that has no source_url or provenance.

Reference renders

cargo run --release -p pptx_engine --features cli --bin pptx_corpus -- \
  fontconfig --out /tmp/pptx-fonts.conf
python3 crates/pptx_engine/scripts/render_references.py /tmp/pptx-refs \
  crates/pptx_engine/tests/corpus/*/*.pptx --jobs 6 --fontconfig /tmp/pptx-fonts.conf

--fontconfig makes LibreOffice use the engine's bundled fonts and its font substitutions (generated from font::SUBSTITUTES), so references differ from the engine in rendering, not in which fallback font each picked. Without it, LibreOffice substitutes DejaVu Sans for any family it does not know (Tahoma, Corbel, Century Gothic…), which is much wider than those fonts and wraps text that PowerPoint fit; the baseline records which reference set it was scored against (reference).

This writes /tmp/pptx-refs/<stem>/slide-NNN.png and meta.json (slides, width, height, libreoffice_version, source_sha256, pdf_pages, expected_slides). Hidden slides are exported. A deck is skipped while its meta.json matches the source hash and width. Each worker uses a private LibreOffice profile. The script warns when the PDF page count differs from the slide count. Write renders outside the repository.

LibreOffice is a reference renderer, not ground truth. Gaps seen in this corpus with 24.2: reflection, inner shadow, 3D bevel/extrusion, compound (dbl, thickThin…) and pattern/gradient outlines, gradient/pattern/outline-only text fills, text glow, wordArtVert/mongolianVert/wordArtVertRtl, vertOverflow, rtlCol, diagonal table cell borders, EMF EMR_GRADIENTFILL, EMF polygon fill mode and hatched brushes, some SmartArt layouts (wild census-fesac-2010-hogue-blumerman slide 11). Live date fields render as the current date. LibreOffice also re-runs normAutofit shrinking with its own algorithm, while PowerPoint (and the engine) use the stored fontScale/lnSpcReduction until the text is edited, so slides with shrunk text differ in size and line breaks. LibreOffice measures default tab stops from the paragraph's left margin (and ignores explicit stops in unbulleted paragraphs with an indent); the engine measures both from the text box edge, which is what tab-aligned text in the wild decks was laid out against. Fonts are substituted: Calibri → Carlito, Cambria → Caladea, Arial/Times New Roman/Courier New → Liberation. With --fontconfig LibreOffice and the engine use the same substitutes; families with no metric-compatible substitute (Candara, Corbel, Garamond, Franklin Gothic, Century Gothic, Segoe UI…) still differ from what PowerPoint shows.

Fidelity baseline and regression test

baseline.json records, for every slide of every deck, a render fingerprint (a 32-column grid of 4-bit luminance cells at 320 px) and, when references were available, the SSIM and mismatched-pixel fraction against them.

  • cargo test -p pptx_engine --test corpus (part of the normal test run, about 30 s in a debug build) opens every deck, renders every slide, compares the fingerprints with the baseline (cross-platform rounding is tolerated), and checks that saving without edits keeps every part's bytes. It needs no LibreOffice; decks still stored as Git LFS pointers are skipped.
  • pptx_corpus score --refs /tmp/pptx-refs [--out /tmp/pptx-report] renders the corpus, scores it against the references, and fails on any SSIM drop beyond --tolerance (0.005) or changed fingerprint. --out writes our renders, the references, red-on-gray diffs, and report.html.
  • After a deliberate rendering change, record it with --update. The baseline is a ratchet: --update refuses to lower a slide's SSIM unless you pass --accept-regressions. Review the report first.
  • A slide's note explains a legitimate difference from LibreOffice (kept across updates); unstable: true skips its fingerprint check (live fields).
  • pptx_corpus roundtrip [--out DIR --libreoffice] applies text, shape, table, and slide edits to every deck and checks that untouched slides render the same, the package stays consistent, undo restores the original bytes, and (with --libreoffice) LibreOffice opens every edited deck.

Adding a deck: put it under generated/ or wild/ (see above), render references for it, and run pptx_corpus score --refs … --update so the test knows its fingerprints.