reamkit 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core/bmp.d.ts +33 -0
- package/dist/esm/core/bmp.js +276 -0
- package/dist/esm/core/converter/ream.d.ts +16 -0
- package/dist/esm/core/converter/ream.js +59 -9
- package/dist/esm/core/document-model/types.d.ts +55 -0
- package/dist/esm/core/drawingml/chart-geometry.js +14 -7
- package/dist/esm/core/drawingml/colors.d.ts +4 -2
- package/dist/esm/core/drawingml/colors.js +15 -0
- package/dist/esm/core/drawingml/diagram/colors.d.ts +52 -0
- package/dist/esm/core/drawingml/diagram/colors.js +125 -0
- package/dist/esm/core/drawingml/diagram/data-model.d.ts +47 -0
- package/dist/esm/core/drawingml/diagram/data-model.js +119 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.d.ts +46 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.js +948 -0
- package/dist/esm/core/drawingml/diagram/run.d.ts +37 -0
- package/dist/esm/core/drawingml/diagram/run.js +50 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.d.ts +16 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.js +86 -0
- package/dist/esm/core/drawingml/preset-geometry.js +116 -6
- package/dist/esm/core/drawingml/text-warp.d.ts +58 -0
- package/dist/esm/core/drawingml/text-warp.js +355 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +38 -0
- package/dist/esm/core/drawingml/theme-parser.js +73 -4
- package/dist/esm/core/font/measure.d.ts +12 -0
- package/dist/esm/core/font/measure.js +36 -0
- package/dist/esm/core/fonts/families.d.ts +10 -0
- package/dist/esm/core/fonts/families.js +44 -0
- package/dist/esm/core/fonts/index.d.ts +3 -2
- package/dist/esm/core/fonts/remote-fonts.d.ts +50 -0
- package/dist/esm/core/fonts/remote-fonts.js +114 -8
- package/dist/esm/core/fonts/scripts.d.ts +26 -0
- package/dist/esm/core/fonts/scripts.js +177 -0
- package/dist/esm/core/images.d.ts +30 -2
- package/dist/esm/core/images.js +121 -5
- package/dist/esm/core/metafile/blit.d.ts +33 -0
- package/dist/esm/core/metafile/blit.js +67 -0
- package/dist/esm/core/metafile/dib.d.ts +61 -0
- package/dist/esm/core/metafile/dib.js +205 -0
- package/dist/esm/core/metafile/emf.js +280 -38
- package/dist/esm/core/metafile/picture.d.ts +61 -1
- package/dist/esm/core/metafile/picture.js +70 -1
- package/dist/esm/core/metafile/wmf.js +202 -13
- package/dist/esm/core/ole/escher-blip.d.ts +12 -0
- package/dist/esm/core/ole/escher-blip.js +98 -0
- package/dist/esm/{pdf-reader → core}/png-encode.js +1 -1
- package/dist/esm/excel/print-model.js +5 -3
- package/dist/esm/excel/sheet-drawing.js +1 -1
- package/dist/esm/excel/sheet-to-flow.js +16 -2
- package/dist/esm/excel/styles-parser.js +1 -1
- package/dist/esm/excel/xls/biff-reader.js +53 -18
- package/dist/esm/excel/xls/biff-styles.d.ts +5 -2
- package/dist/esm/excel/xls/biff-styles.js +9 -7
- package/dist/esm/excel/xls/escher.js +90 -24
- package/dist/esm/html/html-writer.js +2 -1
- package/dist/esm/layout/page-doc.d.ts +74 -0
- package/dist/esm/layout/page-doc.js +14 -1
- package/dist/esm/layout/styled-layout.d.ts +2 -2
- package/dist/esm/layout/styled-layout.js +475 -48
- package/dist/esm/pdf/shading.js +8 -6
- package/dist/esm/pdf/styled-page-emitter.js +77 -5
- package/dist/esm/pdf/vector-graphics.js +1 -1
- package/dist/esm/pdf-reader/image-decode.js +1 -1
- package/dist/esm/pptx/embedded-fonts.d.ts +31 -0
- package/dist/esm/pptx/embedded-fonts.js +104 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +73 -6
- package/dist/esm/pptx/placeholder-cascade.js +114 -18
- package/dist/esm/pptx/ppt/ppt-reader.js +191 -13
- package/dist/esm/pptx/ppt/ppt-text.d.ts +107 -1
- package/dist/esm/pptx/ppt/ppt-text.js +873 -144
- package/dist/esm/pptx/pptx-reader.d.ts +8 -0
- package/dist/esm/pptx/pptx-reader.js +117 -15
- package/dist/esm/pptx/preset-table-styles.d.ts +9 -0
- package/dist/esm/pptx/preset-table-styles.js +27 -0
- package/dist/esm/pptx/slide-parser.d.ts +11 -2
- package/dist/esm/pptx/slide-parser.js +203 -44
- package/dist/esm/pptx/sp-helpers.d.ts +9 -4
- package/dist/esm/pptx/sp-helpers.js +48 -9
- package/dist/esm/pptx/table-style.d.ts +16 -1
- package/dist/esm/pptx/table-style.js +104 -10
- package/dist/esm/svg/svg-writer.js +1 -0
- package/dist/esm/word/document-parser.d.ts +11 -2
- package/dist/esm/word/document-parser.js +10 -7
- package/dist/esm/word/docx-reader.js +32 -16
- package/dist/esm/word/docx-to-pdf.d.ts +8 -7
- package/dist/esm/word/docx-to-pdf.js +25 -7
- package/dist/esm/word/docx-writer.js +4 -0
- package/dist/esm/word/drawing-parser.d.ts +20 -0
- package/dist/esm/word/drawing-parser.js +67 -22
- package/dist/esm/word/numbering-parser.d.ts +2 -1
- package/dist/esm/word/numbering-parser.js +6 -6
- package/dist/esm/word/paragraph-properties.d.ts +2 -1
- package/dist/esm/word/paragraph-properties.js +2 -2
- package/dist/esm/word/run-properties.d.ts +5 -2
- package/dist/esm/word/run-properties.js +13 -8
- package/dist/esm/word/styles-parser.d.ts +2 -1
- package/dist/esm/word/styles-parser.js +12 -12
- package/dist/esm/word/table-parser.js +6 -3
- package/dist/esm/word/theme-fonts.d.ts +10 -0
- package/dist/esm/word/theme-fonts.js +28 -0
- package/package.json +1 -1
- /package/dist/esm/{pdf-reader → core}/png-encode.d.ts +0 -0
|
@@ -17,6 +17,14 @@ export declare function readPptx(bytes: Uint8Array): ReadResult<FlowDoc>;
|
|
|
17
17
|
* Parse an OOXML part's bytes into preserve-order {@link PoNode} roots with the
|
|
18
18
|
* module's shared, presentation-tuned {@link XMLParser} (attributes kept, values
|
|
19
19
|
* not coerced, whitespace preserved). Shared with the slide-style resolvers.
|
|
20
|
+
*
|
|
21
|
+
* ISO/IEC 29500-3 §10.2 — `mc:AlternateContent` is resolved first, to the
|
|
22
|
+
* `mc:Fallback` a reader takes when it implements none of the namespaces the
|
|
23
|
+
* choices require. A deck writes the same shape twice this way, and reading the
|
|
24
|
+
* CHOICE means reading markup written for someone else: tdf143222's whole slide
|
|
25
|
+
* is an embedded worksheet whose preview picture lives in the fallback alone,
|
|
26
|
+
* and the choice — written for VML — carries no picture at all, so the slide
|
|
27
|
+
* came out blank. 82 of the corpus's decks carry such a block.
|
|
20
28
|
*/
|
|
21
29
|
export declare function parseXml(data: Uint8Array): Array<PoNode>;
|
|
22
30
|
/**
|
|
@@ -4,12 +4,16 @@ import { FEATURES } from "../core/ir/features.js";
|
|
|
4
4
|
import { EMPTY_STYLE_SHEET, resolveBodyStyles } from "../core/style-cascade/resolver.js";
|
|
5
5
|
import "../core/style-cascade/index.js";
|
|
6
6
|
import { poAttr, poChildren, poFindDescendant, poIntAttr, poIs } from "../core/po-helpers.js";
|
|
7
|
+
import { cachedDiagramTree, laidOutDiagramTree } from "../core/drawingml/diagram/run.js";
|
|
7
8
|
import { packageHasPart } from "../core/bytes.js";
|
|
8
9
|
import { DEFAULT_SCHEME_ALIAS, DEFAULT_THEME_PALETTE, defaultColorResolver, makeColorResolver } from "../core/drawingml/colors.js";
|
|
9
10
|
import { parseChart, withChartColorStyle } from "../core/drawingml/chart-parser.js";
|
|
10
|
-
import { parseTheme, parseThemeBgFillStyles, parseThemeFillStyles, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
11
|
+
import { parseTheme, parseThemeBgFillStyles, parseThemeFillStyles, parseThemeFonts, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
11
12
|
import { OpcPackage } from "../core/opc/package.js";
|
|
12
13
|
import "../core/opc/index.js";
|
|
14
|
+
import { loadPptxEmbeddedFonts } from "./embedded-fonts.js";
|
|
15
|
+
import { presetTableStyle } from "./preset-table-styles.js";
|
|
16
|
+
import { resolveAlternateContent } from "../core/opc/alternate-content.js";
|
|
13
17
|
import { buildPlaceholderCascade, parseLevelStyles } from "./placeholder-cascade.js";
|
|
14
18
|
import { normalizeSpid, parseVmlImageRels } from "./ole-preview.js";
|
|
15
19
|
import { asBackdrop, backdropElement, parseBackgroundFill, parseSlideShapes } from "./slide-parser.js";
|
|
@@ -19,6 +23,7 @@ var EMU_PER_PT = 12700;
|
|
|
19
23
|
var DEFAULT_CX = 9144e3;
|
|
20
24
|
var DEFAULT_CY = 6858e3;
|
|
21
25
|
var decoder = new TextDecoder();
|
|
26
|
+
var encoder = new TextEncoder();
|
|
22
27
|
var parser = new XMLParser({
|
|
23
28
|
htmlEntities: true,
|
|
24
29
|
ignoreAttributes: false,
|
|
@@ -55,9 +60,11 @@ function readPptx(bytes) {
|
|
|
55
60
|
let cx = DEFAULT_CX;
|
|
56
61
|
let cy = DEFAULT_CY;
|
|
57
62
|
let defaultTextStyle;
|
|
63
|
+
let embeddedFonts = /* @__PURE__ */ new Map();
|
|
58
64
|
const slideParts = [];
|
|
59
65
|
if (presData) {
|
|
60
66
|
const pres = parser.parse(decoder.decode(presData)).find((n) => poIs(n, "p:presentation"));
|
|
67
|
+
embeddedFonts = loadPptxEmbeddedFonts(pkg, presPath, pres, (loss) => losses.push(loss));
|
|
61
68
|
const kids = pres ? poChildren(pres) : [];
|
|
62
69
|
defaultTextStyle = kids.find((c) => poIs(c, "p:defaultTextStyle"));
|
|
63
70
|
const sldSz = kids.find((c) => poIs(c, "p:sldSz"));
|
|
@@ -123,6 +130,7 @@ function readPptx(bytes) {
|
|
|
123
130
|
widthPt: pageW,
|
|
124
131
|
heightPt: pageH
|
|
125
132
|
},
|
|
133
|
+
...styles.themeFonts ? { themeFonts: styles.themeFonts } : {},
|
|
126
134
|
...styles.themeFills ? { themeFills: styles.themeFills } : {},
|
|
127
135
|
...styles.themeLineWidths ? { themeLineWidths: styles.themeLineWidths } : {},
|
|
128
136
|
resolveImage: makeSlideImageResolver(pkg, part.path, resources),
|
|
@@ -162,7 +170,8 @@ function readPptx(bytes) {
|
|
|
162
170
|
section,
|
|
163
171
|
styles: EMPTY_STYLE_SHEET,
|
|
164
172
|
resources,
|
|
165
|
-
...charts.size > 0 ? { charts } : {}
|
|
173
|
+
...charts.size > 0 ? { charts } : {},
|
|
174
|
+
...embeddedFonts.size > 0 ? { embeddedFonts } : {}
|
|
166
175
|
},
|
|
167
176
|
losses
|
|
168
177
|
};
|
|
@@ -171,9 +180,17 @@ function readPptx(bytes) {
|
|
|
171
180
|
* Parse an OOXML part's bytes into preserve-order {@link PoNode} roots with the
|
|
172
181
|
* module's shared, presentation-tuned {@link XMLParser} (attributes kept, values
|
|
173
182
|
* not coerced, whitespace preserved). Shared with the slide-style resolvers.
|
|
183
|
+
*
|
|
184
|
+
* ISO/IEC 29500-3 §10.2 — `mc:AlternateContent` is resolved first, to the
|
|
185
|
+
* `mc:Fallback` a reader takes when it implements none of the namespaces the
|
|
186
|
+
* choices require. A deck writes the same shape twice this way, and reading the
|
|
187
|
+
* CHOICE means reading markup written for someone else: tdf143222's whole slide
|
|
188
|
+
* is an embedded worksheet whose preview picture lives in the fallback alone,
|
|
189
|
+
* and the choice — written for VML — carries no picture at all, so the slide
|
|
190
|
+
* came out blank. 82 of the corpus's decks carry such a block.
|
|
174
191
|
*/
|
|
175
192
|
function parseXml(data) {
|
|
176
|
-
return parser.parse(decoder.decode(data));
|
|
193
|
+
return parser.parse(resolveAlternateContent(decoder.decode(data)));
|
|
177
194
|
}
|
|
178
195
|
function parseSlide(tree, ctx, inheritedBg, pageW, pageH, inheritedShapes = []) {
|
|
179
196
|
const sld = tree.find((n) => poIs(n, "p:sld"));
|
|
@@ -191,7 +208,81 @@ function parseSlide(tree, ctx, inheritedBg, pageW, pageH, inheritedShapes = [])
|
|
|
191
208
|
if (bg) out.push(backdropElement(bg, pageW, pageH));
|
|
192
209
|
out.push(...inheritedShapes.map(asBackdrop));
|
|
193
210
|
if (spTree) out.push(...parseSlideShapes(spTree, shapeCtx));
|
|
194
|
-
|
|
211
|
+
out.push(...parseSlideControls(cSld, shapeCtx));
|
|
212
|
+
return inPaintOrder(out);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* §19.3.1 — a slide's shape tree IS its z-order: what stands later in it is
|
|
216
|
+
* drawn over what stands earlier, whatever KIND either of them is.
|
|
217
|
+
*
|
|
218
|
+
* The page otherwise paints kind by kind — every image, then every shape — and
|
|
219
|
+
* on a slide that is simply wrong. 54542_cropped_bitmap.pptx is six logos each
|
|
220
|
+
* standing on its own coloured panel, written panel-then-logo six times over,
|
|
221
|
+
* and painted by kind all six logos went down first and all six panels covered
|
|
222
|
+
* them.
|
|
223
|
+
*
|
|
224
|
+
* @param elements The slide's elements, in the order the tree gives them.
|
|
225
|
+
* @returns The same elements, each float carrying its place in that order.
|
|
226
|
+
*/
|
|
227
|
+
function inPaintOrder(elements) {
|
|
228
|
+
return elements.map((el, z) => {
|
|
229
|
+
if (el.kind === "shape") return {
|
|
230
|
+
...el,
|
|
231
|
+
shape: withZ(el.shape, z)
|
|
232
|
+
};
|
|
233
|
+
if (el.kind === "image") return {
|
|
234
|
+
...el,
|
|
235
|
+
image: withZ(el.image, z)
|
|
236
|
+
};
|
|
237
|
+
if (el.kind === "table") {
|
|
238
|
+
const anchor = el.table.properties.float;
|
|
239
|
+
return anchor ? {
|
|
240
|
+
...el,
|
|
241
|
+
table: {
|
|
242
|
+
...el.table,
|
|
243
|
+
properties: {
|
|
244
|
+
...el.table.properties,
|
|
245
|
+
float: {
|
|
246
|
+
...anchor,
|
|
247
|
+
zOrder: z
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} : el;
|
|
252
|
+
}
|
|
253
|
+
return el;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** The same block with its float carrying `z`, when it floats at all. */
|
|
257
|
+
function withZ(block, z) {
|
|
258
|
+
return block.float ? {
|
|
259
|
+
...block,
|
|
260
|
+
float: {
|
|
261
|
+
...block.float,
|
|
262
|
+
zOrder: z
|
|
263
|
+
}
|
|
264
|
+
} : block;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* §19.3.1.15 `p:controls` — the ActiveX controls a slide carries.
|
|
268
|
+
*
|
|
269
|
+
* They sit BESIDE the shape tree rather than in it, so a reader that walks
|
|
270
|
+
* `p:spTree` alone never sees them. Each one's `mc:Fallback` is a `p:pic` of
|
|
271
|
+
* what the control looks like — the picture PowerPoint cached precisely so that
|
|
272
|
+
* a reader which cannot run the control still draws it — and by the time the
|
|
273
|
+
* slide is parsed the alternate content is already resolved to that fallback.
|
|
274
|
+
* activex_picture.pptx is seventeen of them over an EMPTY `p:spTree`, and it
|
|
275
|
+
* rendered as a blank page.
|
|
276
|
+
*
|
|
277
|
+
* @param cSld The slide's `p:cSld`.
|
|
278
|
+
* @param ctx The slide's parsing context.
|
|
279
|
+
* @returns The controls' cached pictures as ordinary floating pictures.
|
|
280
|
+
*/
|
|
281
|
+
function parseSlideControls(cSld, ctx) {
|
|
282
|
+
const controls = cSld ? poChildren(cSld).find((c) => poIs(c, "p:controls")) : void 0;
|
|
283
|
+
if (!controls) return [];
|
|
284
|
+
const pics = poChildren(controls).flatMap((c) => poIs(c, "p:control") ? poChildren(c).filter((k) => poIs(k, "p:pic")) : []);
|
|
285
|
+
return pics.length === 0 ? [] : parseSlideShapes({ "p:spTree": pics }, ctx);
|
|
195
286
|
}
|
|
196
287
|
function partBackground(tree, root, colors, resolveImage, themeFills) {
|
|
197
288
|
const sld = tree.find((n) => poIs(n, root));
|
|
@@ -247,6 +338,9 @@ function makeOlePreviewResolver(pkg, slidePath, resources) {
|
|
|
247
338
|
* table that names none wears none — table-with-no-theme's two rows are bare
|
|
248
339
|
* text in a plain frame, not the blue banding `@def` points at.
|
|
249
340
|
*
|
|
341
|
+
* A GUID the part does not hold may still be one of the GALLERY's own, which
|
|
342
|
+
* every deck names and none ships (see `preset-table-styles`).
|
|
343
|
+
*
|
|
250
344
|
* The part is read once, on the first table in the deck.
|
|
251
345
|
*/
|
|
252
346
|
function makeTableStyleResolver(pkg, presPath) {
|
|
@@ -265,7 +359,8 @@ function makeTableStyleResolver(pkg, presPath) {
|
|
|
265
359
|
}
|
|
266
360
|
}
|
|
267
361
|
}
|
|
268
|
-
|
|
362
|
+
if (styleId === void 0) return void 0;
|
|
363
|
+
return byId.get(styleId) ?? presetTableStyle(styleId, (xml) => parseXml(encoder.encode(xml)));
|
|
269
364
|
};
|
|
270
365
|
}
|
|
271
366
|
function makeHyperlinkResolver(pkg, slidePath) {
|
|
@@ -292,23 +387,28 @@ function makeSlideChartResolver(pkg, slidePath, charts, colors, resources) {
|
|
|
292
387
|
}
|
|
293
388
|
function makeSlideDiagramResolver(pkg, slidePath) {
|
|
294
389
|
const cache = /* @__PURE__ */ new Map();
|
|
295
|
-
return (relId) => {
|
|
390
|
+
return (relId, frame) => {
|
|
296
391
|
if (cache.has(relId)) return cache.get(relId);
|
|
297
|
-
let spTree;
|
|
298
392
|
const dataRel = pkg.getPartRelationships(slidePath).find((r) => r.id === relId);
|
|
299
393
|
const data = dataRel ? pkg.resolveRelatedPart(slidePath, dataRel) : void 0;
|
|
300
394
|
const draw = data ? drawingPart(pkg, slidePath, data) : void 0;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (found) {
|
|
304
|
-
spTree = found;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
395
|
+
let spTree = draw ? cachedDiagramTree(draw.data, parseXml) : void 0;
|
|
396
|
+
if (!spTree && data) spTree = laidOutDiagram(pkg, slidePath, data, frame);
|
|
308
397
|
cache.set(relId, spTree);
|
|
309
398
|
return spTree;
|
|
310
399
|
};
|
|
311
400
|
}
|
|
401
|
+
function laidOutDiagram(pkg, slidePath, data, frame) {
|
|
402
|
+
const related = (type) => {
|
|
403
|
+
const rel = pkg.getPartRelationships(slidePath).find((r) => r.type.endsWith(type));
|
|
404
|
+
return rel ? pkg.resolveRelatedPart(slidePath, rel)?.data : void 0;
|
|
405
|
+
};
|
|
406
|
+
return laidOutDiagramTree({
|
|
407
|
+
data: data.data,
|
|
408
|
+
layout: related("/diagramLayout"),
|
|
409
|
+
colors: related("/diagramColors")
|
|
410
|
+
}, frame, parseXml);
|
|
411
|
+
}
|
|
312
412
|
/**
|
|
313
413
|
* The pre-rendered drawing a diagram's data part points at.
|
|
314
414
|
*
|
|
@@ -358,7 +458,8 @@ function slideStylesFor(pkg, slidePath, cache, resources, charts, onLoss, deckDe
|
|
|
358
458
|
resolveImage: makeSlideImageResolver(pkg, theme.path, resources)
|
|
359
459
|
} : void 0;
|
|
360
460
|
const themeLineWidths = theme ? parseThemeLineWidths(theme.data) : void 0;
|
|
361
|
-
const
|
|
461
|
+
const themeFonts = theme ? parseThemeFonts(theme.data) : void 0;
|
|
462
|
+
const cascade = buildPlaceholderCascade(layoutTree, masterTree, colors, parseLevelStyles(deckDefaultTextStyle, colors, themeFonts), themeFonts);
|
|
362
463
|
const background = partBackground(layoutTree, "p:sldLayout", inheritedColors, makeSlideImageResolver(pkg, layout.path, resources), themeFills) ?? (masterTree && master ? partBackground(masterTree, "p:sldMaster", inheritedColors, makeSlideImageResolver(pkg, master.path, resources), themeFills) : void 0);
|
|
363
464
|
const deps = {
|
|
364
465
|
colors: inheritedColors,
|
|
@@ -376,6 +477,7 @@ function slideStylesFor(pkg, slidePath, cache, resources, charts, onLoss, deckDe
|
|
|
376
477
|
const styles = {
|
|
377
478
|
cascade,
|
|
378
479
|
colors,
|
|
480
|
+
...themeFonts ? { themeFonts } : {},
|
|
379
481
|
...themeFills ? { themeFills } : {},
|
|
380
482
|
...themeLineWidths && themeLineWidths.length > 0 ? { themeLineWidths } : {},
|
|
381
483
|
...background ? { background } : {},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PoNode } from '../core/po-helpers.js';
|
|
2
|
+
/**
|
|
3
|
+
* The built-in table style a GUID names, or `undefined` when it is not one this
|
|
4
|
+
* reader holds.
|
|
5
|
+
*
|
|
6
|
+
* @param styleId The `a:tableStyleId` a table states.
|
|
7
|
+
* @param parse The module's XML reader, injected so this file needs none.
|
|
8
|
+
*/
|
|
9
|
+
export declare function presetTableStyle(styleId: string, parse: (xml: string) => ReadonlyArray<PoNode>): PoNode | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { poAttr, poIs } from "../core/po-helpers.js";
|
|
2
|
+
//#region src/pptx/preset-table-styles.ts
|
|
3
|
+
/** The gallery styles this reader knows, by the GUID a table names. */
|
|
4
|
+
var PRESETS = new Map([
|
|
5
|
+
["{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}", "<a:tblStyle styleId=\"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}\" styleName=\"Medium Style 2 - Accent 1\"><a:wholeTbl><a:tcTxStyle><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"dk1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:left><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:left><a:right><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:right><a:top><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:top><a:bottom><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:bottom><a:insideH><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:insideH><a:insideV><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:insideV></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"accent1\"><a:tint val=\"20000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:wholeTbl><a:band1H><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"accent1\"><a:tint val=\"40000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:band1H><a:band2H><a:tcStyle><a:tcBdr/></a:tcStyle></a:band2H><a:band1V><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"accent1\"><a:tint val=\"40000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:band1V><a:band2V><a:tcStyle><a:tcBdr/></a:tcStyle></a:band2V><a:lastCol><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"accent1\"/></a:solidFill></a:fill></a:tcStyle></a:lastCol><a:firstCol><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"accent1\"/></a:solidFill></a:fill></a:tcStyle></a:firstCol><a:lastRow><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:top><a:ln w=\"38100\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:top></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"accent1\"/></a:solidFill></a:fill></a:tcStyle></a:lastRow><a:firstRow><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:bottom><a:ln w=\"38100\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:bottom></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"accent1\"/></a:solidFill></a:fill></a:tcStyle></a:firstRow></a:tblStyle>"],
|
|
6
|
+
["{073A0DAA-6AF3-43AB-8588-CEC1D06C72B9}", "<a:tblStyle styleId=\"{073A0DAA-6AF3-43AB-8588-CEC1D06C72B9}\" styleName=\"Medium Style 2\"><a:wholeTbl><a:tcTxStyle><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"dk1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:left><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:left><a:right><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:right><a:top><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:top><a:bottom><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:bottom><a:insideH><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:insideH><a:insideV><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:insideV></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"dk1\"><a:tint val=\"20000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:wholeTbl><a:band1H><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"dk1\"><a:tint val=\"40000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:band1H><a:band2H><a:tcStyle><a:tcBdr/></a:tcStyle></a:band2H><a:band1V><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"dk1\"><a:tint val=\"40000\"/></a:schemeClr></a:solidFill></a:fill></a:tcStyle></a:band1V><a:band2V><a:tcStyle><a:tcBdr/></a:tcStyle></a:band2V><a:lastCol><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"dk1\"/></a:solidFill></a:fill></a:tcStyle></a:lastCol><a:firstCol><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr/><a:fill><a:solidFill><a:schemeClr val=\"dk1\"/></a:solidFill></a:fill></a:tcStyle></a:firstCol><a:lastRow><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:top><a:ln w=\"38100\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:top></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"dk1\"/></a:solidFill></a:fill></a:tcStyle></a:lastRow><a:firstRow><a:tcTxStyle b=\"on\"><a:fontRef idx=\"minor\"><a:prstClr val=\"black\"/></a:fontRef><a:schemeClr val=\"lt1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:bottom><a:ln w=\"38100\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></a:bottom></a:tcBdr><a:fill><a:solidFill><a:schemeClr val=\"dk1\"/></a:solidFill></a:fill></a:tcStyle></a:firstRow></a:tblStyle>"],
|
|
7
|
+
["{5940675A-B579-460E-94D1-54222C63F5DA}", "<a:tblStyle styleId=\"{5940675A-B579-460E-94D1-54222C63F5DA}\" styleName=\"No Style, Table Grid\"><a:wholeTbl><a:tcTxStyle><a:fontRef idx=\"minor\"><a:scrgbClr r=\"0\" g=\"0\" b=\"0\"/></a:fontRef><a:schemeClr val=\"tx1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:left><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:left><a:right><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:right><a:top><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:top><a:bottom><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:bottom><a:insideH><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:insideH><a:insideV><a:ln w=\"12700\" cmpd=\"sng\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill></a:ln></a:insideV></a:tcBdr><a:fill><a:noFill/></a:fill></a:tcStyle></a:wholeTbl></a:tblStyle>"],
|
|
8
|
+
["{2D5ABB26-0587-4C30-8999-92F81FD0307C}", "<a:tblStyle styleId=\"{2D5ABB26-0587-4C30-8999-92F81FD0307C}\" styleName=\"No Style, No Grid\"><a:wholeTbl><a:tcTxStyle><a:fontRef idx=\"minor\"><a:scrgbClr r=\"0\" g=\"0\" b=\"0\"/></a:fontRef><a:schemeClr val=\"tx1\"/></a:tcTxStyle><a:tcStyle><a:tcBdr><a:left><a:ln><a:noFill/></a:ln></a:left><a:right><a:ln><a:noFill/></a:ln></a:right><a:top><a:ln><a:noFill/></a:ln></a:top><a:bottom><a:ln><a:noFill/></a:ln></a:bottom><a:insideH><a:ln><a:noFill/></a:ln></a:insideH><a:insideV><a:ln><a:noFill/></a:ln></a:insideV></a:tcBdr><a:fill><a:noFill/></a:fill></a:tcStyle></a:wholeTbl></a:tblStyle>"]
|
|
9
|
+
]);
|
|
10
|
+
var parsed = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* The built-in table style a GUID names, or `undefined` when it is not one this
|
|
13
|
+
* reader holds.
|
|
14
|
+
*
|
|
15
|
+
* @param styleId The `a:tableStyleId` a table states.
|
|
16
|
+
* @param parse The module's XML reader, injected so this file needs none.
|
|
17
|
+
*/
|
|
18
|
+
function presetTableStyle(styleId, parse) {
|
|
19
|
+
const seen = parsed.get(styleId);
|
|
20
|
+
if (seen !== void 0 || parsed.has(styleId)) return seen;
|
|
21
|
+
const xml = PRESETS.get(styleId);
|
|
22
|
+
const style = xml ? parse(xml).find((n) => poIs(n, "a:tblStyle") && poAttr(n, "styleId") === styleId) : void 0;
|
|
23
|
+
parsed.set(styleId, style);
|
|
24
|
+
return style;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { presetTableStyle };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BodyElement, FloatAnchor, ShapeBlock, ShapeFill, ShapeGeometry, ShapeTextBody } from '../core/document-model/index.js';
|
|
2
2
|
import { ColorResolver } from '../core/drawingml/colors.js';
|
|
3
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
3
4
|
import { Loss, Pt, ResourceId } from '../core/ir/index.js';
|
|
4
5
|
import { PoNode } from '../core/po-helpers.js';
|
|
5
6
|
import { PlaceholderCascade } from './placeholder-cascade.js';
|
|
@@ -17,6 +18,11 @@ export interface SlideContext {
|
|
|
17
18
|
readonly resolveImage?: (relId: string) => ResourceId | undefined;
|
|
18
19
|
/** The deck theme's fill style lists, for a `p:bgRef` on this slide. */
|
|
19
20
|
readonly themeFills?: ThemeFillStyles;
|
|
21
|
+
/**
|
|
22
|
+
* §20.1.4.1.16 — the two typefaces the deck's theme names. A run states its
|
|
23
|
+
* own by TOKEN (`+mn-lt`) more often than by name.
|
|
24
|
+
*/
|
|
25
|
+
readonly themeFonts?: ThemeFonts;
|
|
20
26
|
/** §20.1.4.1.21 `a:lnStyleLst` — the widths an `a:lnRef` indexes, in points. */
|
|
21
27
|
readonly themeLineWidths?: ReadonlyArray<number>;
|
|
22
28
|
/**
|
|
@@ -53,7 +59,10 @@ export interface SlideContext {
|
|
|
53
59
|
* drawing override (its `dsp:spTree`), or `undefined` when the file ships no
|
|
54
60
|
* override (E-SMARTART SA0).
|
|
55
61
|
*/
|
|
56
|
-
readonly resolveDiagram?: (relId: string
|
|
62
|
+
readonly resolveDiagram?: (relId: string, frame: {
|
|
63
|
+
readonly cx: number;
|
|
64
|
+
readonly cy: number;
|
|
65
|
+
}) => PoNode | undefined;
|
|
57
66
|
/**
|
|
58
67
|
* Sink for graceful-degradation notices (E-SMARTART SA3): a SmartArt that
|
|
59
68
|
* declares a diagram but ships no drawing override records a dropped-feature
|
|
@@ -203,5 +212,5 @@ export declare function parseGeometry(spPr: PoNode | undefined): ShapeGeometry;
|
|
|
203
212
|
* @param resolveLink A run hyperlink resolver, or `undefined`.
|
|
204
213
|
* @returns The text body, or `undefined` when it holds no paragraphs.
|
|
205
214
|
*/
|
|
206
|
-
export declare function parseTxBody(txBody: PoNode, ph: PlaceholderRef | undefined, cascade: PlaceholderCascade | undefined, colors: ColorResolver, resolveLink: LinkResolver, styleColor?: string): ShapeTextBody | undefined;
|
|
215
|
+
export declare function parseTxBody(txBody: PoNode, ph: PlaceholderRef | undefined, cascade: PlaceholderCascade | undefined, colors: ColorResolver, resolveLink: LinkResolver, styleColor?: string, themeFonts?: ThemeFonts): ShapeTextBody | undefined;
|
|
207
216
|
export {};
|