/** * Shape property (spPr) and text property (txPr) utilities. * * During chart parsing, spPr and txPr elements are captured as raw XML strings * for perfect round-trip fidelity. These utilities provide structured read/write * access to the most commonly used properties: * * - Fill color (solid sRGB / theme) * - Line/outline color and width * - Font size, bold, italic, color, family * * The approach: parse raw XML on demand using regex extraction (no full DOM), * and generate raw XML from structured models when creating new properties. */ import type { ShapeProperties, ChartTextProperties, ChartColor, ChartFill, ChartLine } from "./types.js"; /** * Check if the object is purely a raw XML capture — `_rawXml` is set * and NO structured fields have been populated. The parser produces * dual-state objects (both `_rawXml` and structured) from raw bytes so * downstream consumers get the best of both worlds: cheap byte-perfect * round-trip PLUS typed access. Getters (`getSpPrFillColor` et al.) * must prefer structured when present; setters must NOT reparse from * `_rawXml` because doing so wipes any prior structured mutation. * * Writers must ALSO consult this predicate before short-circuiting to * the raw bytes: if the model has been mutated through a direct * property assignment (`spPr.fill = {...}` without routing through * `setSpPrFill`), the raw bytes are stale and the structured path * must win. Exported for use by `_renderSpPr` in both the classic * chart-space xform and the ChartEx renderer. * * Previously `isRawXml` returned `true` whenever `_rawXml` was a * string, which caused `setSpPrFill` → `parseSpPr` to re-read from * raw and discard pending `line.width` / `fill.solid` assignments. */ export declare function isRawXmlShape(obj: { _rawXml?: string; } | undefined): boolean; /** * Whether a `ChartTextProperties` object is a pure raw-XML capture * with no structured fields set. Analogous to {@link isRawXmlShape} * for shape properties: when a caller directly assigns `txPr.color`, * `txPr.size`, etc., the stale `_rawXml` must NOT win — the writer * should fall through to the structured rendering path. */ export declare function isRawXmlTxPr(obj: { _rawXml?: string; } | undefined): boolean; /** * Extract structured fill and line properties from a raw spPr XML string. * Returns the structured ShapeProperties if extraction succeeds. */ export declare function parseSpPr(spPr: ShapeProperties): ShapeProperties; /** * Get the solid fill color from a ShapeProperties object. * Works for both raw XML and structured models. */ export declare function getSpPrFillColor(spPr: ShapeProperties): ChartColor | undefined; /** * Get the complete fill (solid / gradient / pattern / noFill) from a * ShapeProperties object. Works for both raw XML and structured models. * Prefer this over {@link getSpPrFillColor} when the caller needs to * distinguish between "no fill", "gradient", etc. — the color-only * accessor collapses all three to `undefined`. */ export declare function getSpPrFill(spPr: ShapeProperties): ChartFill | undefined; /** * Get the line/outline properties from a ShapeProperties object. */ export declare function getSpPrLine(spPr: ShapeProperties): ChartLine | undefined; /** * Get the gradient fill from a ShapeProperties object. */ export declare function getSpPrGradient(spPr: ShapeProperties): ChartFill["gradient"] | undefined; /** * Get the pattern fill from a ShapeProperties object. */ export declare function getSpPrPattern(spPr: ShapeProperties): ChartFill["pattern"] | undefined; /** * Extract structured text properties from a raw txPr XML string. * * Parses the fields the structured {@link ChartTextProperties} model * declares: * - `size`, `bold`, `italic`, `underline`, `strike`, `cap`, `baseline`, * `kern`, `spacing`, `lang` (from the first `` / ``) * - `color` (from `` inside the same element) * - `fontFamily`, `eastAsianFamily`, `complexScriptFamily` * (from `` / `` / `` children) * - `rotation` (from ``) * * Callers that want to preserve every attribute OOXML might carry * (e.g. `spc="100"`, `u="sng"`, `baseline="30000"`) must not rely on * this function round-tripping via structured fields alone — keep the * `_rawXml` on the txPr. This parser is a best-effort structural view * for consumers that want to READ the common properties; `_rawXml` * remains authoritative for write-side fidelity. */ export declare function parseTxPr(txPr: ChartTextProperties): ChartTextProperties; /** * Get font size from a ChartTextProperties object (returns points, e.g. 10). */ export declare function getTxPrFontSize(txPr: ChartTextProperties): number | undefined; /** * Get font color from a ChartTextProperties object. */ export declare function getTxPrColor(txPr: ChartTextProperties): ChartColor | undefined; /** * Get the font family (typeface) declared on `` / `` * within a `txPr` raw or structured object. Returns `undefined` if the * properties do not carry a typeface, in which case renderers should * use their own default. */ export declare function getTxPrFontFamily(txPr: ChartTextProperties): string | undefined; /** * Get the boolean bold flag from a `txPr`'s first `a:defRPr`/`a:rPr`. */ export declare function getTxPrBold(txPr: ChartTextProperties): boolean | undefined; /** * Get the boolean italic flag from a `txPr`'s first `a:defRPr`/`a:rPr`. */ export declare function getTxPrItalic(txPr: ChartTextProperties): boolean | undefined; /** * Build a structured ShapeProperties object, preserving every field that * `parseSpPr` can produce (fill, line, effectList, scene3d, sp3d, transform, * presetGeometry, customGeometry, bwMode). * * Previous versions only copied a five-field subset, which caused * `setSpPrFill` / `setSpPrLine` to silently strip `xfrm` / `prstGeom` / * `custGeom` off the returned spPr whenever the input had been parsed from * raw XML. The earlier `_rawXml` round-trip path was dropped because it lost * effectList/scene3d/sp3d; we now keep all structured fields and intentionally * omit `_rawXml` so that `_renderSpPr` (chart-space-xform) re-emits the spPr * from the structured data. */ export declare function buildSpPr(props: ShapeProperties): ShapeProperties; /** * Build a structured {@link ChartTextProperties} object. * * Returns a plain structured copy (no `_rawXml`) so downstream mutations * (`props.size = 1400`) take effect when the txPr is later serialised. * The writer (`_renderTxPr` / `_renderRunProperties` in * `chart-space-xform.ts`) fully supports structured txPr data and only * falls back to raw XML pass-through when `_rawXml` is present; returning * `_rawXml` here would freeze the txPr and silently discard subsequent * edits, which is a trap API. */ export declare function buildTxPr(props: ChartTextProperties): ChartTextProperties; /** * Modify a property on an existing spPr (raw or structured). * Returns a new ShapeProperties object with the modification applied. */ export declare function setSpPrFill(spPr: ShapeProperties | undefined, fill: ChartFill): ShapeProperties; /** * Modify line properties on an existing spPr. */ export declare function setSpPrLine(spPr: ShapeProperties | undefined, line: ChartLine): ShapeProperties;