import { BodyElement, FloatAnchor, ShapeBlock, ShapeFill, ShapeGeometry, ShapeTextBody } from '../core/document-model/index.js'; import { ColorResolver } from '../core/drawingml/colors.js'; import { ThemeFonts } from '../core/drawingml/theme-parser.js'; import { Loss, Pt, ResourceId } from '../core/ir/index.js'; import { PoNode } from '../core/po-helpers.js'; import { PlaceholderCascade } from './placeholder-cascade.js'; import { PlaceholderRef, ShapeBoxEmu } from './sp-helpers.js'; /** * Per-slide parsing context: the placeholder cascade (PX2), an image resolver * that turns a slide-scoped relationship id (`a:blip @r:embed`) into a * {@link ResourceId} (PX3a), and a chart resolver that parses a referenced chart * part (`c:chart @r:id`) and returns its document-unique key (PX4a). All optional * — a bare slide needs none. */ export interface SlideContext { readonly cascade?: PlaceholderCascade; /** A slide-scoped blip relationship id (`a:blip @r:embed`) → a stored resource (PX3a). */ readonly resolveImage?: (relId: string) => ResourceId | undefined; /** The deck theme's fill style lists, for a `p:bgRef` on this slide. */ readonly themeFills?: ThemeFillStyles; /** * §20.1.4.1.16 — the two typefaces the deck's theme names. A run states its * own by TOKEN (`+mn-lt`) more often than by name. */ readonly themeFonts?: ThemeFonts; /** §20.1.4.1.21 `a:lnStyleLst` — the widths an `a:lnRef` indexes, in points. */ readonly themeLineWidths?: ReadonlyArray; /** * §19.3.1.43 — the slide's own background fill, which a shape marked * `useBgFill` is painted with. */ readonly backgroundFill?: ShapeFill; /** The slide's size, which says WHERE that background lies under a shape. */ readonly slideSize?: { readonly widthPt: Pt; readonly heightPt: Pt; }; /** * §19.3.2.4 — the picture an embedded object shows, by the `@spid` of its * shape in the slide's legacy VML drawing. */ readonly resolveOlePreview?: (spid: string) => ResourceId | undefined; /** * §20.1.4.2.24 — the `a:tblStyle` a table names by GUID, from the deck's * `tableStyles.xml`. A table that names none wears none. */ readonly resolveTableStyle?: (styleId: string | undefined) => PoNode | undefined; /** A chart relationship id (`c:chart @r:id`) → its document-unique key (PX4a). */ readonly resolveChart?: (relId: string) => string | undefined; /** * The deck's colour resolver (master theme palette, PX5); defaults to the * Office palette when absent. */ readonly colors?: ColorResolver; /** A run hyperlink (`a:hlinkClick @r:id`) → its external URL (PX6). */ readonly resolveHyperlink?: (relId: string) => string | undefined; /** * A SmartArt data relationship (`dgm:relIds @r:dm`) → the diagram's pre-rendered * drawing override (its `dsp:spTree`), or `undefined` when the file ships no * override (E-SMARTART SA0). */ readonly resolveDiagram?: (relId: string, frame: { readonly cx: number; readonly cy: number; }) => PoNode | undefined; /** * Sink for graceful-degradation notices (E-SMARTART SA3): a SmartArt that * declares a diagram but ships no drawing override records a dropped-feature * {@link Loss} here rather than vanishing without a trace. */ readonly onLoss?: (loss: Loss) => void; } type LinkResolver = ((relId: string) => string | undefined) | undefined; type GroupTransform = (box: ShapeBoxEmu) => ShapeBoxEmu; /** * Walk a shape container (`p:spTree` or a `p:grpSp`), turning each `p:sp` into a * floating text/graphic shape, each `p:pic` into a floating image, each * `p:graphicFrame` into a chart/table, and recursing into nested `p:grpSp` groups * (composing their transforms). * * @param container The shape container node. * @param ctx The per-slide parsing context. * @param transform Maps child-space boxes to the slide (identity at the top level). * @returns The container's shapes as positioned {@link BodyElement}s. */ export declare function parseSlideShapes(container: PoNode, ctx?: SlideContext, transform?: GroupTransform, skipPlaceholders?: boolean): Array; /** * The diagram's child shapes live in the spTree's own coordinate space * (`dsp:grpSpPr/a:xfrm` `chOff`/`chExt`); map that onto a target box (the frame on * a slide, or the inline/anchored box in docx). Usually the child space equals * the box, so the scale is 1. Shared by pptx and docx (E-SMARTART). * * @param spTree The diagram drawing's `dsp:spTree`. * @param frame The target box the diagram is placed into. * @returns A transform mapping diagram-space boxes onto `frame`. */ export declare function diagramTransform(spTree: PoNode, frame: ShapeBoxEmu): GroupTransform; /** * A {@link Loss} for a SmartArt diagram that declares its data part but ships no * pre-rendered drawing override (older files, or a generator that omitted the * fallback). Ream renders the override rather than executing Office's layout * engine, so without it the diagram can't be drawn — this records the gap as a * dropped feature instead of letting it vanish. Shared by pptx and docx * (E-SMARTART SA3). * * @param where Optional location tag for the loss report (e.g. `slide 3`). */ export declare function noDiagramOverrideLoss(where?: string): Loss; /** One SmartArt node: the box it occupies in the target space, and its shape. */ export interface DiagramNode { readonly box: ShapeBoxEmu; readonly shape: ShapeBlock; } /** * Read a SmartArt drawing override (a `dsp:spTree`) into its nodes. The `dsp:` * wrapper holds an ordinary `a:` `spPr`/`txBody`, so the shared DrawingML * readers apply unchanged. Shared by pptx and docx (E-SMARTART); diagrams carry * no placeholder cascade. * * @param spTree The diagram drawing's `dsp:spTree`. * @param transform Maps each shape's diagram-space box to the target space. * @param colors The colour resolver for the shapes' fills/strokes/text. * @param resolveLink A run hyperlink resolver, or `undefined`. * @param resolveImage Resolves a picture fill's `r:embed` against the DRAWING * part's own relationships, or `undefined`. * @returns The diagram's visible nodes, in drawing order. */ export declare function parseDiagramNodes(spTree: PoNode, transform: GroupTransform, colors: ColorResolver, resolveLink: LinkResolver, resolveImage?: (relId: string) => ResourceId | undefined): Array; /** * The same nodes as free-standing floating shapes — what a slide wants, where * every shape is anchored to the page. * * @param spTree The diagram drawing's `dsp:spTree`. * @param transform Maps each shape's diagram-space box to the target space. * @param makeFloat Anchors a node's box. * @param colors The colour resolver for the shapes' fills/strokes/text. * @param resolveLink A run hyperlink resolver, or `undefined`. * @returns The diagram's visible shapes as positioned {@link ShapeBlock}s. */ export declare function parseDiagramDrawing(spTree: PoNode, transform: GroupTransform, makeFloat: (box: ShapeBoxEmu) => FloatAnchor, colors: ColorResolver, resolveLink: LinkResolver): Array; /** * The theme fill styles a `p:bgRef` indexes into (§19.3.1.2), as the raw nodes * the fill readers take. */ export interface ThemeFillStyles { /** `a:fillStyleLst` — what an index of 1…999 names. */ readonly fills: ReadonlyArray; /** `a:bgFillStyleLst` — what an index past 1000 names, 1001 being the first. */ readonly backgrounds: ReadonlyArray; /** * A picture named inside a style belongs to the THEME part: the Office * "Berlin" background is a photograph the theme carries and its `r:embed` * means nothing in the master's relationships (corpus: tdf123684, where it * resolved to a different image entirely). */ readonly resolveImage?: (relId: string) => ResourceId | undefined; } /** * `p:bg` → the background fill, or `undefined` when it declares none. * * Two spellings. `p:bgPr` carries the fill itself — solid, gradient, or a * PICTURE, which needs the owning part's image resolver since the blip's * relationship is scoped to the part the background is written in. `p:bgRef` * (§19.3.1.2) carries no fill at all: an index into the theme's style lists and * the colour to put wherever that style says `phClr`. Read as its colour alone * — which is all this did — a deck whose theme opens with a black-to-grey * gradient came out flat, and one whose first background slot is a picture came * out a single colour. * * Used for the slide's own background and the inherited layout/master one (PX5b). * * @param bg The `p:bg` node. * @param colors The deck's colour resolver. * @param resolveImage Resolver for a picture background's relationship, scoped * to the part this `p:bg` is written in. * @param theme The theme's fill style lists, for a `p:bgRef`. */ export declare function parseBackgroundFill(bg: PoNode, colors: ColorResolver, resolveImage?: (relId: string) => ResourceId | undefined, theme?: ThemeFillStyles): ShapeFill | undefined; /** * A full-slide backdrop element for a background fill: a rectangle covering the * page, anchored behind the content (PX5b). * * @param fill The resolved background fill. * @param widthPt The page width in points. * @param heightPt The page height in points. */ export declare function backdropElement(fill: ShapeFill, widthPt: Pt, heightPt: Pt): BodyElement; /** * The same element, painted BEHIND the slide's own content. * * §19.3.1 — a slide's shape tree is drawn over its layout's, and that over the * master's; nothing a deck states once can bury what a slide puts on it. Our * page paints by KIND (every image, then every shape), so without this a * layout's white card landed on top of the photograph the slide is made of — * themes.pptx's fifth slide is one picture and it vanished under the card. * * @param el The inherited element. * @returns The element with its float sunk to the backdrop layer. */ export declare function asBackdrop(el: BodyElement): BodyElement; export declare function parseGeometry(spPr: PoNode | undefined): ShapeGeometry; /** * `p:txBody` → {@link ShapeTextBody}. `a:bodyPr` carries the insets and the * vertical anchor (PX6: anchor `t`/`ctr`/`b`). Exported for sheet shapes * (E-SHEET W2) — like SmartArt, they pass no placeholder cascade, so runs use * their direct `a:rPr` formatting. * * @param txBody The `p:txBody` node. * @param ph The owning placeholder ref, when this is a placeholder shape. * @param cascade The placeholder cascade supplying inherited run defaults. * @param colors The colour resolver for run colours. * @param resolveLink A run hyperlink resolver, or `undefined`. * @returns The text body, or `undefined` when it holds no paragraphs. */ export declare function parseTxBody(txBody: PoNode, ph: PlaceholderRef | undefined, cascade: PlaceholderCascade | undefined, colors: ColorResolver, resolveLink: LinkResolver, styleColor?: string, themeFonts?: ThemeFonts): ShapeTextBody | undefined; export {};