@officedk/pptxdk 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,1293 @@
|
|
|
1
|
+
import { geometrySchema } from "../../core/dist/geometry-schemas.js";
|
|
2
|
+
import { schemeColorNameSchema } from "../../core/dist/theme.js";
|
|
3
|
+
import { allocatePlaceholderAuthorKeys, layoutPlaceholderSpecSchema, masterPlaceholderSpecSchema, masterTextStylesSchema, placeholderLevelStyleSchema, placeholderOrientSchema, placeholderRoleSchema, placeholderSizeSchema, placeholderStyleSchema } from "../../core/dist/placeholders.js";
|
|
4
|
+
import { slideLayoutTypeSchema } from "../../core/dist/masters.js";
|
|
5
|
+
import "../../core/dist/index.js";
|
|
6
|
+
import { createSlideLayoutNode, createSlideMasterNode } from "../../core/dist/document.js";
|
|
7
|
+
import { readAlternateContent } from "./alternate-content.js";
|
|
8
|
+
import { readRunFontSlots } from "./fonts.js";
|
|
9
|
+
import { A_NS, P_NS, R_NS, XML_NS, emuToPx } from "./namespaces.js";
|
|
10
|
+
import { resolvePartPath } from "./opc.js";
|
|
11
|
+
import { inspectUnsupportedGraphicFrame, peekShapeTreeObjectIdentity } from "./resources.js";
|
|
12
|
+
import { isNonDefaultColorMap, readColorMapElement, readColorMapOverride, readThemeOverridePart, readThemePart } from "./themes.js";
|
|
13
|
+
import { readPlaceholderSpPrVisuals } from "./visual.js";
|
|
14
|
+
import { hexRgb6Schema, normalizeBulletCharacter, ooxmlAutoNumStartAtSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlLineSpacingPercentSchema, ooxmlLineSpacingPointsSchema, ooxmlNonNegativeIntSchema, ooxmlParagraphSpacingPointsSchema, ooxmlWritableExtentEmuSchema, ooxmlWritableInt32CoordEmuSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles } from "./xml-fragments.js";
|
|
15
|
+
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
// ../import/dist/masters.js
|
|
18
|
+
const minimumMasterLayoutId = 2147483648;
|
|
19
|
+
const maximumMasterLayoutId = 4294967295;
|
|
20
|
+
const slideMasterAttrsSchema = z.object({ preserve: ooxmlBoolSchema.optional() });
|
|
21
|
+
const slideLayoutAttrsSchema = z.object({
|
|
22
|
+
type: slideLayoutTypeSchema.optional(),
|
|
23
|
+
preserve: ooxmlBoolSchema.optional(),
|
|
24
|
+
matchingName: z.string().optional(),
|
|
25
|
+
userDrawn: ooxmlBoolSchema.optional(),
|
|
26
|
+
showMasterSp: ooxmlBoolSchema.optional(),
|
|
27
|
+
showMasterPhAnim: ooxmlBoolSchema.optional()
|
|
28
|
+
});
|
|
29
|
+
const headerFooterAttrsSchema = z.object({
|
|
30
|
+
sldNum: ooxmlBoolSchema.optional(),
|
|
31
|
+
hdr: ooxmlBoolSchema.optional(),
|
|
32
|
+
ftr: ooxmlBoolSchema.optional(),
|
|
33
|
+
dt: ooxmlBoolSchema.optional()
|
|
34
|
+
});
|
|
35
|
+
function readHeaderFooterElement(parentCursor, partPath, diagnostics) {
|
|
36
|
+
const hf = parentCursor.child(P_NS, "hf");
|
|
37
|
+
if (hf === void 0) return void 0;
|
|
38
|
+
const raw = hf.attrsObject([
|
|
39
|
+
"sldNum",
|
|
40
|
+
"hdr",
|
|
41
|
+
"ftr",
|
|
42
|
+
"dt"
|
|
43
|
+
]);
|
|
44
|
+
const parsed = headerFooterAttrsSchema.safeParse(raw);
|
|
45
|
+
if (!parsed.success) {
|
|
46
|
+
diagnostics.push({
|
|
47
|
+
code: "invalid-xml-value",
|
|
48
|
+
category: "corrupt-input",
|
|
49
|
+
disposition: "omitted",
|
|
50
|
+
location: {
|
|
51
|
+
part: partPath,
|
|
52
|
+
xpath: hf.xpath
|
|
53
|
+
},
|
|
54
|
+
attributeOrElement: "p:hf",
|
|
55
|
+
rawValue: JSON.stringify(raw)
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const result = {
|
|
60
|
+
...parsed.data.dt === void 0 ? {} : { dateTime: parsed.data.dt },
|
|
61
|
+
...parsed.data.ftr === void 0 ? {} : { footer: parsed.data.ftr },
|
|
62
|
+
...parsed.data.hdr === void 0 ? {} : { header: parsed.data.hdr },
|
|
63
|
+
...parsed.data.sldNum === void 0 ? {} : { slideNumber: parsed.data.sldNum }
|
|
64
|
+
};
|
|
65
|
+
return Object.keys(result).length === 0 ? {} : result;
|
|
66
|
+
}
|
|
67
|
+
const defaultColorMap = {
|
|
68
|
+
bg1: "lt1",
|
|
69
|
+
tx1: "dk1",
|
|
70
|
+
bg2: "lt2",
|
|
71
|
+
tx2: "dk2",
|
|
72
|
+
accent1: "accent1",
|
|
73
|
+
accent2: "accent2",
|
|
74
|
+
accent3: "accent3",
|
|
75
|
+
accent4: "accent4",
|
|
76
|
+
accent5: "accent5",
|
|
77
|
+
accent6: "accent6",
|
|
78
|
+
hlink: "hlink",
|
|
79
|
+
folHlink: "folHlink"
|
|
80
|
+
};
|
|
81
|
+
function readColorModifierVal(colorCursor, localName) {
|
|
82
|
+
const mod = colorCursor.child(A_NS, localName);
|
|
83
|
+
if (mod === void 0) return void 0;
|
|
84
|
+
const parsed = ooxmlNonNegativeIntSchema.safeParse(mod.attr("val"));
|
|
85
|
+
return parsed.success ? Math.min(1, parsed.data / 1e5) : void 0;
|
|
86
|
+
}
|
|
87
|
+
function readStyleColor(containerCursor, _clrMap) {
|
|
88
|
+
const srgb = containerCursor.child(A_NS, "srgbClr");
|
|
89
|
+
const scheme = srgb === void 0 ? containerCursor.child(A_NS, "schemeClr") : void 0;
|
|
90
|
+
const colorCursor = srgb ?? scheme;
|
|
91
|
+
if (colorCursor === void 0) return void 0;
|
|
92
|
+
let baseColor;
|
|
93
|
+
if (srgb !== void 0) {
|
|
94
|
+
const parsed = hexRgb6Schema.safeParse(srgb.attr("val"));
|
|
95
|
+
if (!parsed.success) return void 0;
|
|
96
|
+
baseColor = `#${parsed.data.toUpperCase()}`;
|
|
97
|
+
} else if (scheme !== void 0) {
|
|
98
|
+
const parsedScheme = schemeColorNameSchema.safeParse(scheme.attr("val"));
|
|
99
|
+
const slot = parsedScheme.success ? parsedScheme.data : void 0;
|
|
100
|
+
if (slot === void 0) return void 0;
|
|
101
|
+
const rawLumMod = readColorModifierVal(colorCursor, "lumMod");
|
|
102
|
+
const rawLumOff = readColorModifierVal(colorCursor, "lumOff");
|
|
103
|
+
const tint = readColorModifierVal(colorCursor, "tint");
|
|
104
|
+
const lumMod = rawLumMod ?? (rawLumOff === void 0 && tint !== void 0 ? tint : void 0);
|
|
105
|
+
const lumOff = rawLumOff ?? (rawLumMod === void 0 && tint !== void 0 ? 1 - tint : void 0);
|
|
106
|
+
baseColor = lumMod !== void 0 ? {
|
|
107
|
+
slot,
|
|
108
|
+
lumMod,
|
|
109
|
+
...lumOff === void 0 ? {} : { lumOff }
|
|
110
|
+
} : slot;
|
|
111
|
+
}
|
|
112
|
+
if (baseColor === void 0) return void 0;
|
|
113
|
+
const alpha = readColorModifierVal(colorCursor, "alpha");
|
|
114
|
+
return alpha !== void 0 ? {
|
|
115
|
+
color: baseColor,
|
|
116
|
+
alpha
|
|
117
|
+
} : baseColor;
|
|
118
|
+
}
|
|
119
|
+
function readDefRPr(rPr, clrMap, partPath, diagnostics) {
|
|
120
|
+
const attrStyles = readOoxmlRunAttrStyles({
|
|
121
|
+
rPrCursor: rPr,
|
|
122
|
+
location: { part: partPath },
|
|
123
|
+
diagnostics,
|
|
124
|
+
allowBaseline: false,
|
|
125
|
+
allowNoneTextDecoration: true,
|
|
126
|
+
diagnoseUnsupportedEnums: false
|
|
127
|
+
});
|
|
128
|
+
const solidFill = rPr.child(A_NS, "solidFill");
|
|
129
|
+
const color = solidFill === void 0 ? void 0 : readStyleColor(solidFill, clrMap);
|
|
130
|
+
rPr.ignoreEmptyChild(A_NS, "noFill");
|
|
131
|
+
let textShadow;
|
|
132
|
+
const effectLst = rPr.child(A_NS, "effectLst");
|
|
133
|
+
if (effectLst !== void 0) {
|
|
134
|
+
const outerShdw = effectLst.child(A_NS, "outerShdw");
|
|
135
|
+
if (outerShdw !== void 0) {
|
|
136
|
+
const shdwAttrs = outerShdw.attrsObject([
|
|
137
|
+
"blurRad",
|
|
138
|
+
"dist",
|
|
139
|
+
"dir",
|
|
140
|
+
"algn",
|
|
141
|
+
"rotWithShape"
|
|
142
|
+
]);
|
|
143
|
+
const blurParsed = shdwAttrs["blurRad"] === void 0 ? void 0 : ooxmlWritableExtentEmuSchema.safeParse(shdwAttrs["blurRad"]);
|
|
144
|
+
const distParsed = shdwAttrs["dist"] === void 0 ? void 0 : ooxmlWritableExtentEmuSchema.safeParse(shdwAttrs["dist"]);
|
|
145
|
+
const dirParsed = shdwAttrs["dir"] === void 0 ? void 0 : ooxmlIntSchema.safeParse(shdwAttrs["dir"]);
|
|
146
|
+
if (blurParsed !== void 0 && !blurParsed.success || distParsed !== void 0 && !distParsed.success || dirParsed !== void 0 && !dirParsed.success) {
|
|
147
|
+
diagnostics.push({
|
|
148
|
+
code: "invalid-xml-value",
|
|
149
|
+
category: "corrupt-input",
|
|
150
|
+
disposition: "omitted",
|
|
151
|
+
location: {
|
|
152
|
+
part: partPath,
|
|
153
|
+
xpath: outerShdw.xpath
|
|
154
|
+
},
|
|
155
|
+
attributeOrElement: "a:outerShdw",
|
|
156
|
+
rawValue: JSON.stringify(shdwAttrs)
|
|
157
|
+
});
|
|
158
|
+
outerShdw.suppressUnconsumed();
|
|
159
|
+
} else {
|
|
160
|
+
const shdwColor = readStyleColor(outerShdw, clrMap);
|
|
161
|
+
textShadow = {
|
|
162
|
+
...shdwColor === void 0 ? {} : { color: shdwColor },
|
|
163
|
+
blur: blurParsed?.success ? emuToPx(blurParsed.data) : 0,
|
|
164
|
+
distance: distParsed?.success ? emuToPx(distParsed.data) : 0,
|
|
165
|
+
angle: dirParsed?.success ? dirParsed.data / 6e4 : 0
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
} else if (effectLst.element.children.length === 0) textShadow = "none";
|
|
169
|
+
}
|
|
170
|
+
const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPr);
|
|
171
|
+
return {
|
|
172
|
+
...fontFamily === void 0 ? {} : { fontFamily },
|
|
173
|
+
...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily },
|
|
174
|
+
...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
|
|
175
|
+
...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
|
|
176
|
+
...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
|
|
177
|
+
...color === void 0 ? {} : { color },
|
|
178
|
+
...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
|
|
179
|
+
...attrStyles.textTransform === void 0 ? {} : { textTransform: attrStyles.textTransform },
|
|
180
|
+
...attrStyles.textDecoration === void 0 ? {} : { textDecoration: attrStyles.textDecoration },
|
|
181
|
+
...textShadow === void 0 ? {} : { textShadow },
|
|
182
|
+
...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang }
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function pushBoundedAttrDiagnostic(diagnostics, partPath, xpath, attrName, rawValue) {
|
|
186
|
+
diagnostics.push({
|
|
187
|
+
code: "invalid-xml-value",
|
|
188
|
+
category: "corrupt-input",
|
|
189
|
+
disposition: "omitted",
|
|
190
|
+
location: {
|
|
191
|
+
part: partPath,
|
|
192
|
+
xpath: `${xpath}/@${attrName}`
|
|
193
|
+
},
|
|
194
|
+
attributeOrElement: `@${attrName}`,
|
|
195
|
+
rawValue
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function readLevelParagraphProperties(pPr, levelIndex0, clrMap, partPath, diagnostics) {
|
|
199
|
+
const rawAttrs = pPr.attrsObject([
|
|
200
|
+
"marL",
|
|
201
|
+
"indent",
|
|
202
|
+
"algn",
|
|
203
|
+
"defTabSz",
|
|
204
|
+
"rtl",
|
|
205
|
+
"eaLnBrk",
|
|
206
|
+
"latinLnBrk",
|
|
207
|
+
"hangingPunct",
|
|
208
|
+
"fontAlgn"
|
|
209
|
+
]);
|
|
210
|
+
let marginLeft;
|
|
211
|
+
if (rawAttrs["marL"] !== void 0) {
|
|
212
|
+
const marLParsed = ooxmlWritableExtentEmuSchema.safeParse(rawAttrs["marL"]);
|
|
213
|
+
if (marLParsed.success) marginLeft = emuToPx(marLParsed.data);
|
|
214
|
+
else pushBoundedAttrDiagnostic(diagnostics, partPath, pPr.xpath, "marL", rawAttrs["marL"]);
|
|
215
|
+
}
|
|
216
|
+
let indent;
|
|
217
|
+
if (rawAttrs["indent"] !== void 0) {
|
|
218
|
+
const indentParsed = ooxmlWritableInt32CoordEmuSchema.safeParse(rawAttrs["indent"]);
|
|
219
|
+
if (indentParsed.success) indent = emuToPx(indentParsed.data);
|
|
220
|
+
else pushBoundedAttrDiagnostic(diagnostics, partPath, pPr.xpath, "indent", rawAttrs["indent"]);
|
|
221
|
+
}
|
|
222
|
+
const align = rawAttrs["algn"] === void 0 ? void 0 : {
|
|
223
|
+
l: "left",
|
|
224
|
+
ctr: "center",
|
|
225
|
+
r: "right",
|
|
226
|
+
just: "justify"
|
|
227
|
+
}[rawAttrs["algn"]];
|
|
228
|
+
const spcBef = pPr.child(A_NS, "spcBef");
|
|
229
|
+
const spcBefPts = spcBef?.child(A_NS, "spcPts");
|
|
230
|
+
(spcBef?.child(A_NS, "spcPct"))?.consumeAttr("val");
|
|
231
|
+
let spacingBefore;
|
|
232
|
+
if (spcBefPts !== void 0) {
|
|
233
|
+
const rawVal = spcBefPts.attr("val");
|
|
234
|
+
const parsed = ooxmlParagraphSpacingPointsSchema.safeParse(rawVal);
|
|
235
|
+
if (parsed.success) spacingBefore = parsed.data / 75;
|
|
236
|
+
else if (rawVal !== void 0) pushBoundedAttrDiagnostic(diagnostics, partPath, spcBefPts.xpath, "val", rawVal);
|
|
237
|
+
}
|
|
238
|
+
const spcAft = pPr.child(A_NS, "spcAft");
|
|
239
|
+
const spcAftPts = spcAft?.child(A_NS, "spcPts");
|
|
240
|
+
(spcAft?.child(A_NS, "spcPct"))?.consumeAttr("val");
|
|
241
|
+
let spacingAfter;
|
|
242
|
+
if (spcAftPts !== void 0) {
|
|
243
|
+
const rawVal = spcAftPts.attr("val");
|
|
244
|
+
const parsed = ooxmlParagraphSpacingPointsSchema.safeParse(rawVal);
|
|
245
|
+
if (parsed.success) spacingAfter = parsed.data / 75;
|
|
246
|
+
else if (rawVal !== void 0) pushBoundedAttrDiagnostic(diagnostics, partPath, spcAftPts.xpath, "val", rawVal);
|
|
247
|
+
}
|
|
248
|
+
const lnSpc = pPr.child(A_NS, "lnSpc");
|
|
249
|
+
const lnSpcPts = lnSpc?.child(A_NS, "spcPts");
|
|
250
|
+
const lnSpcPct = lnSpc?.child(A_NS, "spcPct");
|
|
251
|
+
let lineHeight;
|
|
252
|
+
if (lnSpcPts !== void 0) {
|
|
253
|
+
const rawVal = lnSpcPts.attr("val");
|
|
254
|
+
const parsed = ooxmlLineSpacingPointsSchema.safeParse(rawVal);
|
|
255
|
+
if (parsed.success) lineHeight = `${parsed.data / 100}pt`;
|
|
256
|
+
else if (rawVal !== void 0) pushBoundedAttrDiagnostic(diagnostics, partPath, lnSpcPts.xpath, "val", rawVal);
|
|
257
|
+
} else if (lnSpcPct !== void 0) {
|
|
258
|
+
const rawVal = lnSpcPct.attr("val");
|
|
259
|
+
const parsed = ooxmlLineSpacingPercentSchema.safeParse(rawVal);
|
|
260
|
+
if (parsed.success) lineHeight = `${parsed.data / 1e3}%`;
|
|
261
|
+
else if (rawVal !== void 0) pushBoundedAttrDiagnostic(diagnostics, partPath, lnSpcPct.xpath, "val", rawVal);
|
|
262
|
+
}
|
|
263
|
+
pPr.ignoreEmptyChild(A_NS, "buNone");
|
|
264
|
+
const buFont = pPr.child(A_NS, "buFont");
|
|
265
|
+
if (buFont !== void 0) {
|
|
266
|
+
buFont.consumeAttr("typeface");
|
|
267
|
+
buFont.consumeAttr("pitchFamily");
|
|
268
|
+
buFont.consumeAttr("charset");
|
|
269
|
+
buFont.consumeAttr("panose");
|
|
270
|
+
}
|
|
271
|
+
const buChar = pPr.child(A_NS, "buChar");
|
|
272
|
+
const buAutoNum = pPr.child(A_NS, "buAutoNum");
|
|
273
|
+
let list;
|
|
274
|
+
if (buChar !== void 0) {
|
|
275
|
+
const rawChar = buChar.attr("char");
|
|
276
|
+
const normalized = normalizeBulletCharacter(rawChar);
|
|
277
|
+
if (normalized.recovered) diagnostics.push({
|
|
278
|
+
code: "invalid-xml-value",
|
|
279
|
+
category: "corrupt-input",
|
|
280
|
+
disposition: "recovered",
|
|
281
|
+
location: {
|
|
282
|
+
part: partPath,
|
|
283
|
+
xpath: `${buChar.xpath}/@char`
|
|
284
|
+
},
|
|
285
|
+
attributeOrElement: "a:buChar/@char",
|
|
286
|
+
rawValue: rawChar ?? ""
|
|
287
|
+
});
|
|
288
|
+
list = {
|
|
289
|
+
type: "bullet",
|
|
290
|
+
character: normalized.character,
|
|
291
|
+
...levelIndex0 > 0 ? { level: levelIndex0 } : {}
|
|
292
|
+
};
|
|
293
|
+
} else if (buAutoNum !== void 0) {
|
|
294
|
+
buAutoNum.consumeAttr("type");
|
|
295
|
+
const rawStartAt = buAutoNum.attr("startAt");
|
|
296
|
+
let startAt;
|
|
297
|
+
if (rawStartAt !== void 0) {
|
|
298
|
+
const startParsed = ooxmlAutoNumStartAtSchema.safeParse(rawStartAt);
|
|
299
|
+
if (startParsed.success) startAt = startParsed.data;
|
|
300
|
+
else pushBoundedAttrDiagnostic(diagnostics, partPath, buAutoNum.xpath, "startAt", rawStartAt);
|
|
301
|
+
}
|
|
302
|
+
list = {
|
|
303
|
+
type: "number",
|
|
304
|
+
style: "arabicPeriod",
|
|
305
|
+
...startAt === void 0 ? {} : { startAt },
|
|
306
|
+
...levelIndex0 > 0 ? { level: levelIndex0 } : {}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const defRPr = pPr.child(A_NS, "defRPr");
|
|
310
|
+
return {
|
|
311
|
+
...defRPr === void 0 ? {} : readDefRPr(defRPr, clrMap, partPath, diagnostics),
|
|
312
|
+
...list === void 0 ? {} : { list },
|
|
313
|
+
...marginLeft === void 0 ? {} : { marginLeft },
|
|
314
|
+
...indent === void 0 ? {} : { indent },
|
|
315
|
+
...spacingBefore === void 0 ? {} : { spacingBefore },
|
|
316
|
+
...align === void 0 ? {} : { align },
|
|
317
|
+
...lineHeight === void 0 ? {} : { lineHeight },
|
|
318
|
+
...spacingAfter === void 0 ? {} : { spacingAfter }
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function sanitizeObjectBySchema(candidate, fullSchema, singleFieldValidate) {
|
|
322
|
+
const direct = fullSchema.safeParse(candidate);
|
|
323
|
+
if (direct.success) return direct.data;
|
|
324
|
+
const cleaned = {};
|
|
325
|
+
for (const [key, value] of Object.entries(candidate)) {
|
|
326
|
+
if (value === void 0) continue;
|
|
327
|
+
if (singleFieldValidate(key, value)) cleaned[key] = value;
|
|
328
|
+
}
|
|
329
|
+
const reparsed = fullSchema.safeParse(cleaned);
|
|
330
|
+
return reparsed.success ? reparsed.data : void 0;
|
|
331
|
+
}
|
|
332
|
+
function readPlaceholderListStyles(container, clrMap, partPath, diagnostics) {
|
|
333
|
+
if (container === void 0) return void 0;
|
|
334
|
+
const levels = {};
|
|
335
|
+
let count = 0;
|
|
336
|
+
for (const levelNum of [
|
|
337
|
+
1,
|
|
338
|
+
2,
|
|
339
|
+
3,
|
|
340
|
+
4,
|
|
341
|
+
5,
|
|
342
|
+
6,
|
|
343
|
+
7,
|
|
344
|
+
8,
|
|
345
|
+
9
|
|
346
|
+
]) {
|
|
347
|
+
const pPr = container.child(A_NS, `lvl${levelNum}pPr`);
|
|
348
|
+
if (pPr === void 0) continue;
|
|
349
|
+
const sanitized = sanitizeObjectBySchema(readLevelParagraphProperties(pPr, levelNum - 1, clrMap, partPath, diagnostics), placeholderLevelStyleSchema, (key, value) => placeholderLevelStyleSchema.safeParse({ [key]: value }).success);
|
|
350
|
+
if (sanitized !== void 0 && Object.keys(sanitized).length > 0) {
|
|
351
|
+
levels[levelNum] = sanitized;
|
|
352
|
+
count += 1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return count === 0 ? void 0 : levels;
|
|
356
|
+
}
|
|
357
|
+
function readMasterTextStyles(txStyles, clrMap, partPath, diagnostics) {
|
|
358
|
+
if (txStyles === void 0) return void 0;
|
|
359
|
+
const titleStyleCursor = txStyles.child(P_NS, "titleStyle");
|
|
360
|
+
const bodyStyleCursor = txStyles.child(P_NS, "bodyStyle");
|
|
361
|
+
const otherStyleCursor = txStyles.child(P_NS, "otherStyle");
|
|
362
|
+
const titleStyle = readPlaceholderListStyles(titleStyleCursor, clrMap, partPath, diagnostics);
|
|
363
|
+
const bodyStyle = readPlaceholderListStyles(bodyStyleCursor, clrMap, partPath, diagnostics);
|
|
364
|
+
const otherStyle = readPlaceholderListStyles(otherStyleCursor, clrMap, partPath, diagnostics);
|
|
365
|
+
const candidate = {
|
|
366
|
+
...titleStyle === void 0 ? {} : { titleStyle },
|
|
367
|
+
...bodyStyle === void 0 ? {} : { bodyStyle },
|
|
368
|
+
...otherStyle === void 0 ? {} : { otherStyle }
|
|
369
|
+
};
|
|
370
|
+
if (Object.keys(candidate).length === 0) return void 0;
|
|
371
|
+
const parsed = masterTextStylesSchema.safeParse(candidate);
|
|
372
|
+
return parsed.success ? parsed.data : void 0;
|
|
373
|
+
}
|
|
374
|
+
function directPlaceholderChild(el) {
|
|
375
|
+
for (let child = el.firstChild; child !== null; child = child.nextSibling) {
|
|
376
|
+
if (child.nodeType !== 1) continue;
|
|
377
|
+
const childEl = child;
|
|
378
|
+
if ((childEl.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (childEl.localName ?? childEl.tagName) === "nvSpPr") for (let nv = childEl.firstChild; nv !== null; nv = nv.nextSibling) {
|
|
379
|
+
if (nv.nodeType !== 1) continue;
|
|
380
|
+
const nvEl = nv;
|
|
381
|
+
if ((nvEl.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (nvEl.localName ?? nvEl.tagName) === "nvPr") for (let ph = nvEl.firstChild; ph !== null; ph = ph.nextSibling) {
|
|
382
|
+
if (ph.nodeType !== 1) continue;
|
|
383
|
+
const phEl = ph;
|
|
384
|
+
if ((phEl.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (phEl.localName ?? phEl.tagName) === "ph") return true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
function readPlaceholderSpList(spTree, clrMap, isMaster, pkg, partPath, diagnostics, readPlaceholderVisuals) {
|
|
391
|
+
const placeholderKeyBySpid = /* @__PURE__ */ new Map();
|
|
392
|
+
if (spTree === void 0) return { placeholderKeyBySpid };
|
|
393
|
+
const rawSpecs = [];
|
|
394
|
+
const rawSpids = [];
|
|
395
|
+
for (const sp of spTree.matchingChildren((el) => (el.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (el.localName ?? el.tagName) === "sp" && directPlaceholderChild(el))) {
|
|
396
|
+
const nvSpPr = sp.child(P_NS, "nvSpPr");
|
|
397
|
+
const cNvPr = nvSpPr?.child(P_NS, "cNvPr");
|
|
398
|
+
const rawId = cNvPr?.attr("id");
|
|
399
|
+
const parsedSpid = ooxmlNonNegativeIntSchema.safeParse(rawId);
|
|
400
|
+
const spid = parsedSpid.success && parsedSpid.data > 0 ? parsedSpid.data : void 0;
|
|
401
|
+
const rawName = cNvPr?.attr("name");
|
|
402
|
+
const name = rawName !== void 0 && rawName.trim() !== "" ? rawName : void 0;
|
|
403
|
+
const cNvSpPr = nvSpPr?.child(P_NS, "cNvSpPr");
|
|
404
|
+
if (cNvSpPr !== void 0) {
|
|
405
|
+
cNvSpPr.consumeAttr("txBox");
|
|
406
|
+
cNvSpPr.child(A_NS, "spLocks")?.consumeAttr("noGrp");
|
|
407
|
+
}
|
|
408
|
+
const ph = (nvSpPr?.child(P_NS, "nvPr"))?.child(P_NS, "ph");
|
|
409
|
+
if (ph === void 0) continue;
|
|
410
|
+
const rawType = ph.attr("type");
|
|
411
|
+
const explicitType = rawType !== void 0;
|
|
412
|
+
const typeRes = placeholderRoleSchema.safeParse(rawType ?? "obj");
|
|
413
|
+
const phType = typeRes.success ? typeRes.data : "obj";
|
|
414
|
+
const idxParsed = ooxmlNonNegativeIntSchema.safeParse(ph.attr("idx"));
|
|
415
|
+
const idx = idxParsed.success ? idxParsed.data : void 0;
|
|
416
|
+
const sizeParsed = placeholderSizeSchema.safeParse(ph.attr("sz"));
|
|
417
|
+
const orientParsed = placeholderOrientSchema.safeParse(ph.attr("orient"));
|
|
418
|
+
const customPromptParsed = ooxmlBoolSchema.safeParse(ph.attr("hasCustomPrompt"));
|
|
419
|
+
let geometry;
|
|
420
|
+
const styleProps = {};
|
|
421
|
+
const spPr = sp.child(P_NS, "spPr");
|
|
422
|
+
if (spPr !== void 0) {
|
|
423
|
+
const phLocation = {
|
|
424
|
+
part: partPath,
|
|
425
|
+
xpath: spPr.xpath,
|
|
426
|
+
...spid === void 0 ? {} : { objectId: spid },
|
|
427
|
+
...name === void 0 ? {} : { objectName: name }
|
|
428
|
+
};
|
|
429
|
+
const importedSpPr = (readPlaceholderVisuals ?? readPlaceholderSpPrVisuals)({
|
|
430
|
+
spPr,
|
|
431
|
+
pkg,
|
|
432
|
+
location: phLocation,
|
|
433
|
+
diagnostics
|
|
434
|
+
});
|
|
435
|
+
geometry = importedSpPr.geometry;
|
|
436
|
+
if (importedSpPr.style !== void 0) Object.assign(styleProps, importedSpPr.style);
|
|
437
|
+
}
|
|
438
|
+
let listStyles;
|
|
439
|
+
let promptText;
|
|
440
|
+
const txBody = sp.child(P_NS, "txBody");
|
|
441
|
+
if (txBody !== void 0) {
|
|
442
|
+
const bodyPr = txBody.child(A_NS, "bodyPr");
|
|
443
|
+
if (bodyPr !== void 0) {
|
|
444
|
+
const b = bodyPr.attrsObject([
|
|
445
|
+
"wrap",
|
|
446
|
+
"rtlCol",
|
|
447
|
+
"lIns",
|
|
448
|
+
"tIns",
|
|
449
|
+
"rIns",
|
|
450
|
+
"bIns",
|
|
451
|
+
"anchor",
|
|
452
|
+
"anchorCtr",
|
|
453
|
+
"numCol",
|
|
454
|
+
"spcCol"
|
|
455
|
+
]);
|
|
456
|
+
if (b["wrap"] === "none") styleProps["textWrap"] = "nowrap";
|
|
457
|
+
else if (b["wrap"] === "square") styleProps["textWrap"] = "normal";
|
|
458
|
+
if (b["anchor"] === "t") styleProps["verticalAlign"] = "top";
|
|
459
|
+
else if (b["anchor"] === "ctr") styleProps["verticalAlign"] = "middle";
|
|
460
|
+
else if (b["anchor"] === "b") styleProps["verticalAlign"] = "bottom";
|
|
461
|
+
Object.assign(styleProps, readOoxmlBoxInsets({
|
|
462
|
+
rawAttrs: b,
|
|
463
|
+
attrNames: {
|
|
464
|
+
left: "lIns",
|
|
465
|
+
top: "tIns",
|
|
466
|
+
right: "rIns",
|
|
467
|
+
bottom: "bIns"
|
|
468
|
+
},
|
|
469
|
+
elementXpath: bodyPr.xpath,
|
|
470
|
+
location: {
|
|
471
|
+
part: partPath,
|
|
472
|
+
...spid === void 0 ? {} : { objectId: spid },
|
|
473
|
+
...name === void 0 ? {} : { objectName: name }
|
|
474
|
+
},
|
|
475
|
+
diagnostics
|
|
476
|
+
}));
|
|
477
|
+
bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
|
|
478
|
+
bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
|
|
479
|
+
const normAutofit = bodyPr.child(A_NS, "normAutofit");
|
|
480
|
+
normAutofit?.consumeAttr("fontScale");
|
|
481
|
+
normAutofit?.consumeAttr("lnSpcReduction");
|
|
482
|
+
}
|
|
483
|
+
listStyles = readPlaceholderListStyles(txBody.child(A_NS, "lstStyle"), clrMap, partPath, diagnostics);
|
|
484
|
+
const promptParagraphs = [];
|
|
485
|
+
let promptLvl1Fallback;
|
|
486
|
+
for (const p of txBody.children(A_NS, "p")) {
|
|
487
|
+
const pPr = p.child(A_NS, "pPr");
|
|
488
|
+
const pStyle = pPr === void 0 ? void 0 : readLevelParagraphProperties(pPr, 0, clrMap, partPath, diagnostics);
|
|
489
|
+
const runTexts = [];
|
|
490
|
+
for (const r of p.children(A_NS, "r")) {
|
|
491
|
+
const rPr = r.child(A_NS, "rPr");
|
|
492
|
+
const rStyle = rPr === void 0 ? void 0 : readDefRPr(rPr, clrMap, partPath, diagnostics);
|
|
493
|
+
if (promptLvl1Fallback === void 0 && (pStyle !== void 0 || rStyle !== void 0)) promptLvl1Fallback = {
|
|
494
|
+
...pStyle,
|
|
495
|
+
...rStyle
|
|
496
|
+
};
|
|
497
|
+
const t = r.child(A_NS, "t");
|
|
498
|
+
if (t !== void 0) {
|
|
499
|
+
t.consumeAttr("space", XML_NS);
|
|
500
|
+
runTexts.push(t.textContent);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const fld = p.child(A_NS, "fld");
|
|
504
|
+
if (fld !== void 0) {
|
|
505
|
+
fld.consumeAttr("id");
|
|
506
|
+
fld.consumeAttr("type");
|
|
507
|
+
const rPr = fld.child(A_NS, "rPr");
|
|
508
|
+
const rStyle = rPr === void 0 ? void 0 : readDefRPr(rPr, clrMap, partPath, diagnostics);
|
|
509
|
+
if (promptLvl1Fallback === void 0 && (pStyle !== void 0 || rStyle !== void 0)) promptLvl1Fallback = {
|
|
510
|
+
...pStyle,
|
|
511
|
+
...rStyle
|
|
512
|
+
};
|
|
513
|
+
fld.ignoreEmptyChild(A_NS, "pPr");
|
|
514
|
+
const t = fld.child(A_NS, "t");
|
|
515
|
+
if (t !== void 0) {
|
|
516
|
+
t.consumeAttr("space", XML_NS);
|
|
517
|
+
runTexts.push(t.textContent);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const endPara = p.child(A_NS, "endParaRPr");
|
|
521
|
+
if (endPara !== void 0) {
|
|
522
|
+
const endStyle = readDefRPr(endPara, clrMap, partPath, diagnostics);
|
|
523
|
+
if (promptLvl1Fallback === void 0 && (pStyle !== void 0 || Object.keys(endStyle).length > 0)) promptLvl1Fallback = {
|
|
524
|
+
...pStyle,
|
|
525
|
+
...endStyle
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
if (runTexts.length > 0) promptParagraphs.push(runTexts.join(""));
|
|
529
|
+
}
|
|
530
|
+
if (promptParagraphs.length > 0) promptText = promptParagraphs.join("\n");
|
|
531
|
+
const sanitizedPromptLvl1 = listStyles === void 0 && promptLvl1Fallback !== void 0 && Object.keys(promptLvl1Fallback).length > 0 ? sanitizeObjectBySchema(promptLvl1Fallback, placeholderLevelStyleSchema, (key, value) => placeholderLevelStyleSchema.safeParse({ [key]: value }).success) : void 0;
|
|
532
|
+
if (listStyles === void 0 && sanitizedPromptLvl1 !== void 0 && Object.keys(sanitizedPromptLvl1).length > 0) listStyles = { 1: sanitizedPromptLvl1 };
|
|
533
|
+
}
|
|
534
|
+
const rawStyle = Object.keys(styleProps).length === 0 ? void 0 : sanitizeObjectBySchema(styleProps, placeholderStyleSchema, (key, value) => placeholderStyleSchema.safeParse({ [key]: value }).success);
|
|
535
|
+
const style = rawStyle !== void 0 && Object.keys(rawStyle).length > 0 ? rawStyle : void 0;
|
|
536
|
+
const candidate = {
|
|
537
|
+
type: phType,
|
|
538
|
+
...explicitType ? {} : { explicitType: false },
|
|
539
|
+
...idx === void 0 ? {} : { idx },
|
|
540
|
+
...sizeParsed.success ? { size: sizeParsed.data } : {},
|
|
541
|
+
...orientParsed.success ? { orient: orientParsed.data } : {},
|
|
542
|
+
...customPromptParsed.success && customPromptParsed.data ? { hasCustomPrompt: true } : {},
|
|
543
|
+
...name === void 0 ? {} : { name },
|
|
544
|
+
...geometry !== void 0 && geometrySchema.safeParse(geometry).success ? { geometry } : {},
|
|
545
|
+
...style === void 0 ? {} : { style },
|
|
546
|
+
...listStyles === void 0 ? {} : { listStyles },
|
|
547
|
+
...promptText === void 0 ? {} : { promptText }
|
|
548
|
+
};
|
|
549
|
+
const schema = isMaster ? masterPlaceholderSpecSchema : layoutPlaceholderSpecSchema;
|
|
550
|
+
const validated = schema.safeParse(candidate);
|
|
551
|
+
if (validated.success) {
|
|
552
|
+
rawSpecs.push(validated.data);
|
|
553
|
+
rawSpids.push(spid);
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
diagnostics.push({
|
|
557
|
+
code: "invalid-xml-value",
|
|
558
|
+
category: "corrupt-input",
|
|
559
|
+
disposition: "recovered",
|
|
560
|
+
location: {
|
|
561
|
+
part: partPath,
|
|
562
|
+
xpath: sp.xpath,
|
|
563
|
+
...spid === void 0 ? {} : { objectId: spid },
|
|
564
|
+
...name === void 0 ? {} : { objectName: name }
|
|
565
|
+
},
|
|
566
|
+
attributeOrElement: "p:sp"
|
|
567
|
+
});
|
|
568
|
+
const sanitizedSpec = sanitizeObjectBySchema(candidate, schema, (key, value) => schema.safeParse({
|
|
569
|
+
type: phType,
|
|
570
|
+
[key]: value
|
|
571
|
+
}).success);
|
|
572
|
+
if (sanitizedSpec !== void 0) {
|
|
573
|
+
rawSpecs.push(sanitizedSpec);
|
|
574
|
+
rawSpids.push(spid);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (rawSpecs.length === 0) return { placeholderKeyBySpid };
|
|
578
|
+
const keys = allocatePlaceholderAuthorKeys(rawSpecs);
|
|
579
|
+
const map = {};
|
|
580
|
+
for (let i = 0; i < rawSpecs.length; i += 1) {
|
|
581
|
+
const key = keys[i];
|
|
582
|
+
map[key] = rawSpecs[i];
|
|
583
|
+
const spid = rawSpids[i];
|
|
584
|
+
if (spid !== void 0) placeholderKeyBySpid.set(spid, key);
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
placeholders: Object.freeze(map),
|
|
588
|
+
placeholderKeyBySpid
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/** Allocates a deterministic unique author id within `used`, disambiguating collisions with `-2`, `-3`, ... */
|
|
592
|
+
function allocateScopedAuthorId(requested, used, fallbackBase) {
|
|
593
|
+
const base = requested !== void 0 && requested.trim().length > 0 ? requested.trim() : fallbackBase;
|
|
594
|
+
if (!used.has(base)) {
|
|
595
|
+
used.add(base);
|
|
596
|
+
return base;
|
|
597
|
+
}
|
|
598
|
+
let suffix = 2;
|
|
599
|
+
while (used.has(`${base}-${suffix}`)) suffix += 1;
|
|
600
|
+
const unique = `${base}-${suffix}`;
|
|
601
|
+
used.add(unique);
|
|
602
|
+
return unique;
|
|
603
|
+
}
|
|
604
|
+
/** Consumes standard identity `<p:nvGrpSpPr>` and `<p:grpSpPr>` transform boilerplate on an `spTree`. */
|
|
605
|
+
function consumeIdentityShapeTreeBoilerplate(spTree) {
|
|
606
|
+
const nvGrpSpPr = spTree.child(P_NS, "nvGrpSpPr");
|
|
607
|
+
if (nvGrpSpPr !== void 0) {
|
|
608
|
+
const cNvPr = nvGrpSpPr.child(P_NS, "cNvPr");
|
|
609
|
+
if (cNvPr !== void 0) {
|
|
610
|
+
cNvPr.consumeAttr("id");
|
|
611
|
+
cNvPr.consumeAttr("name");
|
|
612
|
+
}
|
|
613
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "cNvGrpSpPr");
|
|
614
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "nvPr");
|
|
615
|
+
}
|
|
616
|
+
const grpSpPr = spTree.child(P_NS, "grpSpPr");
|
|
617
|
+
if (grpSpPr !== void 0) {
|
|
618
|
+
const xfrm = grpSpPr.child(A_NS, "xfrm");
|
|
619
|
+
if (xfrm !== void 0) {
|
|
620
|
+
const off = xfrm.child(A_NS, "off");
|
|
621
|
+
if (off !== void 0 && off.attr("x") === "0" && off.attr("y") === "0") {}
|
|
622
|
+
const ext = xfrm.child(A_NS, "ext");
|
|
623
|
+
if (ext !== void 0 && ext.attr("cx") === "0" && ext.attr("cy") === "0") {}
|
|
624
|
+
const chOff = xfrm.child(A_NS, "chOff");
|
|
625
|
+
if (chOff !== void 0 && chOff.attr("x") === "0" && chOff.attr("y") === "0") {}
|
|
626
|
+
const chExt = xfrm.child(A_NS, "chExt");
|
|
627
|
+
if (chExt !== void 0 && chExt.attr("cx") === "0" && chExt.attr("cy") === "0") {}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/** Records `unconsumed-xml` diagnostics for all unconsumed attributes/elements under a root cursor. */
|
|
632
|
+
function appendUnconsumedDiagnostics(cursor, slideIndex, diagnostics) {
|
|
633
|
+
for (const item of cursor.collectUnconsumed()) diagnostics.push({
|
|
634
|
+
code: "unconsumed-xml",
|
|
635
|
+
category: "unsupported",
|
|
636
|
+
disposition: "omitted",
|
|
637
|
+
kind: item.kind,
|
|
638
|
+
location: {
|
|
639
|
+
...item.location,
|
|
640
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
641
|
+
},
|
|
642
|
+
namespaceUri: item.namespaceUri,
|
|
643
|
+
localName: item.localName
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
function validateMasterLayoutNumericId(rawId, part, xpath, diagnostics) {
|
|
647
|
+
if (rawId === void 0) return;
|
|
648
|
+
const parsed = ooxmlNonNegativeIntSchema.safeParse(rawId);
|
|
649
|
+
if (!parsed.success || parsed.data < minimumMasterLayoutId || parsed.data > maximumMasterLayoutId) diagnostics.push({
|
|
650
|
+
code: "invalid-xml-value",
|
|
651
|
+
category: "corrupt-input",
|
|
652
|
+
disposition: "recovered",
|
|
653
|
+
location: {
|
|
654
|
+
part,
|
|
655
|
+
xpath: `${xpath}/@id`
|
|
656
|
+
},
|
|
657
|
+
attributeOrElement: "@id",
|
|
658
|
+
rawValue: rawId
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
const p14Namespace = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
|
662
|
+
const creationIdExtensionUri = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}";
|
|
663
|
+
/** Consumes benign PowerPoint `<p:cSld>/<p:extLst>` creationId metadata without altering author models. */
|
|
664
|
+
function consumeCommonSlideCreationId(cSld) {
|
|
665
|
+
const extLst = cSld.child(P_NS, "extLst");
|
|
666
|
+
if (extLst === void 0) return;
|
|
667
|
+
for (const ext of extLst.children(P_NS, "ext")) {
|
|
668
|
+
if (ext.attr("uri") !== creationIdExtensionUri) continue;
|
|
669
|
+
const creationId = ext.child(p14Namespace, "creationId");
|
|
670
|
+
if (creationId !== void 0) creationId.consumeAttr("val");
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function stripSlideIndexFromDiagnostics(entries) {
|
|
674
|
+
if (entries === void 0 || entries.length === 0) return [];
|
|
675
|
+
return entries.map((entry) => {
|
|
676
|
+
const { slideIndex: _ignored, ...locationRest } = entry.location;
|
|
677
|
+
return {
|
|
678
|
+
...entry,
|
|
679
|
+
location: locationRest
|
|
680
|
+
};
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
const supportedShapeTreeNamespaces = /* @__PURE__ */ new Set([
|
|
684
|
+
P_NS,
|
|
685
|
+
A_NS,
|
|
686
|
+
R_NS
|
|
687
|
+
]);
|
|
688
|
+
function readSingleShapeTreeItem(itemCursor, pkg, partPath, slideIndex, relIndex, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, containerNode, layoutPlaceholders, clrMap, registerImportedObject, omittedSpids, masterPlaceholders, registerDeferredConnector, scopeObjectsBySpid, usedAuthorIds, masterTextStyles, slideDimensions, claimedPlaceholderKeys) {
|
|
689
|
+
const identity = peekShapeTreeObjectIdentity(itemCursor.element);
|
|
690
|
+
const match = shapeTreeHandlers.find((handler) => itemCursor.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && (handler.localName === itemCursor.localName || handler.alternateLocalNames?.includes(itemCursor.localName) === true) && (handler.matches === void 0 || handler.matches(itemCursor)));
|
|
691
|
+
if (match === void 0) {
|
|
692
|
+
if (omittedSpids !== void 0 && identity.objectId !== void 0) omittedSpids.set(identity.objectId, {
|
|
693
|
+
...identity.objectName === void 0 ? {} : { objectName: identity.objectName },
|
|
694
|
+
reason: "unsupported"
|
|
695
|
+
});
|
|
696
|
+
const frameInfo = itemCursor.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && itemCursor.localName === "graphicFrame" ? inspectUnsupportedGraphicFrame(itemCursor, partPath, relIndex.byId, relIndex.entries) : void 0;
|
|
697
|
+
diagnostics.push({
|
|
698
|
+
code: "unsupported-mechanism",
|
|
699
|
+
category: "unsupported",
|
|
700
|
+
disposition: "omitted",
|
|
701
|
+
location: {
|
|
702
|
+
part: partPath,
|
|
703
|
+
xpath: itemCursor.xpath,
|
|
704
|
+
...slideIndex === void 0 ? {} : { slideIndex },
|
|
705
|
+
...identity
|
|
706
|
+
},
|
|
707
|
+
namespaceUri: itemCursor.namespaceUri,
|
|
708
|
+
localName: itemCursor.localName,
|
|
709
|
+
...frameInfo?.mechanismHint === void 0 ? {} : { mechanismHint: frameInfo.mechanismHint },
|
|
710
|
+
...frameInfo === void 0 || frameInfo.cascaded.length === 0 ? {} : { cascaded: frameInfo.cascaded }
|
|
711
|
+
});
|
|
712
|
+
itemCursor.suppressUnconsumed();
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
const outcome = match.read({
|
|
716
|
+
cursor: itemCursor,
|
|
717
|
+
part: partPath,
|
|
718
|
+
slideIndex: slideIndex ?? 0,
|
|
719
|
+
package: pkg,
|
|
720
|
+
...containerNode === void 0 ? {} : { containerNode },
|
|
721
|
+
relationships: relIndex.byId,
|
|
722
|
+
relationshipEntries: relIndex.entries,
|
|
723
|
+
registerDeferredSlideLink,
|
|
724
|
+
...registerImportedObject === void 0 ? {} : { registerImportedObject },
|
|
725
|
+
...registerDeferredConnector === void 0 ? {} : { registerDeferredConnector },
|
|
726
|
+
...layoutPlaceholders === void 0 ? {} : { layoutPlaceholders },
|
|
727
|
+
...masterPlaceholders === void 0 ? {} : { masterPlaceholders },
|
|
728
|
+
...masterTextStyles === void 0 ? {} : { masterTextStyles },
|
|
729
|
+
...slideDimensions === void 0 ? {} : { slideDimensions },
|
|
730
|
+
...claimedPlaceholderKeys === void 0 ? {} : { claimedPlaceholderKeys },
|
|
731
|
+
...clrMap === void 0 ? {} : { clrMap }
|
|
732
|
+
});
|
|
733
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...slideIndex === void 0 ? stripSlideIndexFromDiagnostics(outcome.diagnostics) : outcome.diagnostics);
|
|
734
|
+
if (outcome.node === void 0) {
|
|
735
|
+
if (omittedSpids !== void 0 && identity.objectId !== void 0) omittedSpids.set(identity.objectId, {
|
|
736
|
+
...identity.objectName === void 0 ? {} : { objectName: identity.objectName },
|
|
737
|
+
reason: "corrupt"
|
|
738
|
+
});
|
|
739
|
+
itemCursor.suppressUnconsumed();
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (identity.objectId !== void 0) {
|
|
743
|
+
registerImportedObject?.(identity.objectId, outcome.node);
|
|
744
|
+
scopeObjectsBySpid?.set(identity.objectId, outcome.node);
|
|
745
|
+
}
|
|
746
|
+
const authorId = outcome.node.props["id"];
|
|
747
|
+
if (typeof authorId === "string" && authorId.length > 0) usedAuthorIds?.add(authorId);
|
|
748
|
+
return outcome.node;
|
|
749
|
+
}
|
|
750
|
+
/** Shared `<p:spTree>` child reader for slides, slide layouts, and slide masters. */
|
|
751
|
+
function readShapeTreeItems(args) {
|
|
752
|
+
const { spTree, pkg, partPath, slideIndex, relIndex, shapeTreeHandlers, registerDeferredSlideLink, appendNode, diagnostics, containerNode, layoutPlaceholders, masterPlaceholders, masterTextStyles, slideDimensions, claimedPlaceholderKeys, clrMap, registerImportedObject, omittedSpids } = args;
|
|
753
|
+
consumeIdentityShapeTreeBoilerplate(spTree);
|
|
754
|
+
const scopeObjectsBySpid = /* @__PURE__ */ new Map();
|
|
755
|
+
const usedAuthorIds = /* @__PURE__ */ new Set();
|
|
756
|
+
const deferredConnectors = [];
|
|
757
|
+
const registerDeferredConnector = (resolve) => {
|
|
758
|
+
deferredConnectors.push(resolve);
|
|
759
|
+
};
|
|
760
|
+
for (const itemCursor of spTree.remainingElementChildren()) {
|
|
761
|
+
if (itemCursor.namespaceUri === MC_NS_IMPORT_PLACEHOLDER && itemCursor.localName === "AlternateContent") {
|
|
762
|
+
const selection = readAlternateContent(itemCursor, (ns) => supportedShapeTreeNamespaces.has(ns));
|
|
763
|
+
if (selection.branch === "choice") for (const childCursor of selection.children) {
|
|
764
|
+
const node = readSingleShapeTreeItem(childCursor, pkg, partPath, slideIndex, relIndex, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, containerNode, layoutPlaceholders, clrMap, registerImportedObject, omittedSpids, masterPlaceholders, registerDeferredConnector, scopeObjectsBySpid, usedAuthorIds, masterTextStyles, slideDimensions, claimedPlaceholderKeys);
|
|
765
|
+
if (node !== void 0) appendNode(node);
|
|
766
|
+
}
|
|
767
|
+
else if (selection.branch === "fallback") {
|
|
768
|
+
let adoptedFallback = false;
|
|
769
|
+
for (const childCursor of selection.children) {
|
|
770
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
771
|
+
const node = readSingleShapeTreeItem(childCursor, pkg, partPath, slideIndex, relIndex, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, containerNode, layoutPlaceholders, clrMap, registerImportedObject, omittedSpids, masterPlaceholders, registerDeferredConnector, scopeObjectsBySpid, usedAuthorIds, masterTextStyles, slideDimensions, claimedPlaceholderKeys);
|
|
772
|
+
if (node !== void 0) {
|
|
773
|
+
adoptedFallback = true;
|
|
774
|
+
appendNode(node);
|
|
775
|
+
diagnostics.push({
|
|
776
|
+
code: "compatibility-fallback",
|
|
777
|
+
category: "unsupported",
|
|
778
|
+
disposition: "fallback",
|
|
779
|
+
location: {
|
|
780
|
+
part: partPath,
|
|
781
|
+
xpath: itemCursor.xpath,
|
|
782
|
+
...slideIndex === void 0 ? {} : { slideIndex },
|
|
783
|
+
...identity
|
|
784
|
+
},
|
|
785
|
+
preferredMechanism: selection.preferredMechanism,
|
|
786
|
+
selectedFallback: node.kind,
|
|
787
|
+
loss: {
|
|
788
|
+
lost: "native-mechanism",
|
|
789
|
+
retainedAs: node.kind
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (!adoptedFallback) itemCursor.suppressUnconsumed();
|
|
795
|
+
} else {
|
|
796
|
+
diagnostics.push({
|
|
797
|
+
code: "unsupported-mechanism",
|
|
798
|
+
category: "unsupported",
|
|
799
|
+
disposition: "omitted",
|
|
800
|
+
location: {
|
|
801
|
+
part: partPath,
|
|
802
|
+
xpath: itemCursor.xpath,
|
|
803
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
804
|
+
},
|
|
805
|
+
namespaceUri: itemCursor.namespaceUri,
|
|
806
|
+
localName: itemCursor.localName,
|
|
807
|
+
mechanismHint: selection.preferredMechanism
|
|
808
|
+
});
|
|
809
|
+
itemCursor.suppressUnconsumed();
|
|
810
|
+
}
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
const node = readSingleShapeTreeItem(itemCursor, pkg, partPath, slideIndex, relIndex, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, containerNode, layoutPlaceholders, clrMap, registerImportedObject, omittedSpids, masterPlaceholders, registerDeferredConnector, scopeObjectsBySpid, usedAuthorIds, masterTextStyles, slideDimensions, claimedPlaceholderKeys);
|
|
814
|
+
if (node !== void 0) appendNode(node);
|
|
815
|
+
}
|
|
816
|
+
if (deferredConnectors.length > 0) {
|
|
817
|
+
const scopeContext = {
|
|
818
|
+
scopeObjectsBySpid,
|
|
819
|
+
omittedSpids: omittedSpids ?? /* @__PURE__ */ new Map(),
|
|
820
|
+
usedAuthorIds,
|
|
821
|
+
diagnostics
|
|
822
|
+
};
|
|
823
|
+
for (const resolveConnector of deferredConnectors) resolveConnector(scopeContext);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
const MC_NS_IMPORT_PLACEHOLDER = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
827
|
+
function readSlideLayoutPart(pkg, layoutPartPath, ownerMasterPartPath, layoutOrder, usedLayoutIds, masterClrMap, masterLevelSlideHandlers, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, readPlaceholderVisuals) {
|
|
828
|
+
const xmlText = pkg.readTextPart(layoutPartPath);
|
|
829
|
+
if (xmlText === void 0) return void 0;
|
|
830
|
+
let layoutEl;
|
|
831
|
+
try {
|
|
832
|
+
layoutEl = parseXmlPart(layoutPartPath, xmlText);
|
|
833
|
+
} catch {
|
|
834
|
+
diagnostics.push({
|
|
835
|
+
code: "corrupt-part",
|
|
836
|
+
category: "corrupt-input",
|
|
837
|
+
disposition: "omitted",
|
|
838
|
+
location: { part: layoutPartPath }
|
|
839
|
+
});
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if ((layoutEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (layoutEl.localName ?? layoutEl.tagName) !== "sldLayout") {
|
|
843
|
+
diagnostics.push({
|
|
844
|
+
code: "corrupt-part",
|
|
845
|
+
category: "corrupt-input",
|
|
846
|
+
disposition: "omitted",
|
|
847
|
+
location: { part: layoutPartPath }
|
|
848
|
+
});
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const layoutCursor = XmlElementCursor.createRoot(layoutEl, layoutPartPath, "/p:sldLayout");
|
|
852
|
+
const rawAttrs = layoutCursor.attrsObject([
|
|
853
|
+
"type",
|
|
854
|
+
"preserve",
|
|
855
|
+
"matchingName",
|
|
856
|
+
"userDrawn",
|
|
857
|
+
"showMasterSp",
|
|
858
|
+
"showMasterPhAnim"
|
|
859
|
+
]);
|
|
860
|
+
const parsedAttrs = slideLayoutAttrsSchema.safeParse(rawAttrs);
|
|
861
|
+
let layoutType;
|
|
862
|
+
let preserve;
|
|
863
|
+
let matchingName;
|
|
864
|
+
let userDrawn;
|
|
865
|
+
let showMasterShapes;
|
|
866
|
+
let showMasterPlaceholderAnimations;
|
|
867
|
+
if (parsedAttrs.success) {
|
|
868
|
+
layoutType = parsedAttrs.data.type;
|
|
869
|
+
preserve = parsedAttrs.data.preserve;
|
|
870
|
+
matchingName = parsedAttrs.data.matchingName;
|
|
871
|
+
userDrawn = parsedAttrs.data.userDrawn;
|
|
872
|
+
showMasterShapes = parsedAttrs.data.showMasterSp;
|
|
873
|
+
showMasterPlaceholderAnimations = parsedAttrs.data.showMasterPhAnim;
|
|
874
|
+
} else {
|
|
875
|
+
for (const issue of parsedAttrs.error.issues) {
|
|
876
|
+
const key = String(issue.path[0] ?? "sldLayout");
|
|
877
|
+
diagnostics.push({
|
|
878
|
+
code: "invalid-xml-value",
|
|
879
|
+
category: "corrupt-input",
|
|
880
|
+
disposition: "recovered",
|
|
881
|
+
location: {
|
|
882
|
+
part: layoutPartPath,
|
|
883
|
+
xpath: `${layoutCursor.xpath}/@${key}`
|
|
884
|
+
},
|
|
885
|
+
attributeOrElement: `@${key}`,
|
|
886
|
+
rawValue: rawAttrs[key] ?? ""
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
const typeRes = slideLayoutTypeSchema.safeParse(rawAttrs["type"]);
|
|
890
|
+
if (typeRes.success) layoutType = typeRes.data;
|
|
891
|
+
const preserveRes = ooxmlBoolSchema.safeParse(rawAttrs["preserve"]);
|
|
892
|
+
if (preserveRes.success) preserve = preserveRes.data;
|
|
893
|
+
if (rawAttrs["matchingName"] !== void 0) matchingName = rawAttrs["matchingName"];
|
|
894
|
+
const userDrawnRes = ooxmlBoolSchema.safeParse(rawAttrs["userDrawn"]);
|
|
895
|
+
if (userDrawnRes.success) userDrawn = userDrawnRes.data;
|
|
896
|
+
const showSpRes = ooxmlBoolSchema.safeParse(rawAttrs["showMasterSp"]);
|
|
897
|
+
if (showSpRes.success) showMasterShapes = showSpRes.data;
|
|
898
|
+
const showPhAnimRes = ooxmlBoolSchema.safeParse(rawAttrs["showMasterPhAnim"]);
|
|
899
|
+
if (showPhAnimRes.success) showMasterPlaceholderAnimations = showPhAnimRes.data;
|
|
900
|
+
}
|
|
901
|
+
const cSld = layoutCursor.child(P_NS, "cSld");
|
|
902
|
+
let layoutName;
|
|
903
|
+
if (cSld === void 0) {
|
|
904
|
+
diagnostics.push({
|
|
905
|
+
code: "corrupt-part",
|
|
906
|
+
category: "corrupt-input",
|
|
907
|
+
disposition: "omitted",
|
|
908
|
+
location: {
|
|
909
|
+
part: layoutPartPath,
|
|
910
|
+
xpath: layoutCursor.xpath
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
layoutName = cSld.attr("name");
|
|
916
|
+
consumeCommonSlideCreationId(cSld);
|
|
917
|
+
const spTree = cSld.child(P_NS, "spTree");
|
|
918
|
+
let placeholders;
|
|
919
|
+
let layoutPlaceholderKeyBySpid;
|
|
920
|
+
if (spTree !== void 0) {
|
|
921
|
+
consumeIdentityShapeTreeBoilerplate(spTree);
|
|
922
|
+
const placeholderRead = readPlaceholderSpList(spTree, masterClrMap, false, pkg, layoutPartPath, diagnostics, readPlaceholderVisuals);
|
|
923
|
+
placeholders = placeholderRead.placeholders;
|
|
924
|
+
layoutPlaceholderKeyBySpid = placeholderRead.placeholderKeyBySpid;
|
|
925
|
+
}
|
|
926
|
+
const clrMapOvr = layoutCursor.child(P_NS, "clrMapOvr");
|
|
927
|
+
let colorMapOverride;
|
|
928
|
+
if (clrMapOvr !== void 0) {
|
|
929
|
+
const parsedOvr = readColorMapOverride(clrMapOvr, layoutPartPath, void 0, diagnostics);
|
|
930
|
+
if (parsedOvr !== void 0 && parsedOvr !== "master") colorMapOverride = parsedOvr;
|
|
931
|
+
}
|
|
932
|
+
const layoutHeaderFooter = readHeaderFooterElement(layoutCursor, layoutPartPath, diagnostics);
|
|
933
|
+
const layoutRels = pkg.readRelationships(layoutPartPath);
|
|
934
|
+
diagnostics.push(...layoutRels.diagnostics);
|
|
935
|
+
const backMasterRel = layoutRels.entries.find((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" && entry.TargetMode !== "External");
|
|
936
|
+
if (backMasterRel !== void 0) {
|
|
937
|
+
if (resolvePartPath(layoutPartPath, backMasterRel.Target) !== ownerMasterPartPath) diagnostics.push({
|
|
938
|
+
code: "broken-relationship",
|
|
939
|
+
category: "corrupt-input",
|
|
940
|
+
disposition: "omitted",
|
|
941
|
+
location: {
|
|
942
|
+
part: layoutPartPath,
|
|
943
|
+
xpath: backMasterRel.xpath
|
|
944
|
+
},
|
|
945
|
+
relationshipId: backMasterRel.Id
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
let themeOverride;
|
|
949
|
+
const themeOverrideRel = layoutRels.entries.find((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride" && entry.TargetMode !== "External");
|
|
950
|
+
if (themeOverrideRel !== void 0) {
|
|
951
|
+
const overridePart = resolvePartPath(layoutPartPath, themeOverrideRel.Target);
|
|
952
|
+
if (overridePart === void 0 || !pkg.hasPart(overridePart)) diagnostics.push({
|
|
953
|
+
code: "missing-target-part",
|
|
954
|
+
category: "corrupt-input",
|
|
955
|
+
disposition: "omitted",
|
|
956
|
+
location: {
|
|
957
|
+
part: layoutPartPath,
|
|
958
|
+
xpath: themeOverrideRel.xpath
|
|
959
|
+
},
|
|
960
|
+
relationshipId: themeOverrideRel.Id,
|
|
961
|
+
targetPart: overridePart ?? themeOverrideRel.Target
|
|
962
|
+
});
|
|
963
|
+
else themeOverride = readThemeOverridePart(pkg, overridePart, void 0, diagnostics);
|
|
964
|
+
}
|
|
965
|
+
const props = {
|
|
966
|
+
id: allocateScopedAuthorId(layoutName, usedLayoutIds, `layout-${layoutOrder}`),
|
|
967
|
+
...layoutName === void 0 ? {} : { name: layoutName },
|
|
968
|
+
...layoutType === void 0 ? {} : { type: layoutType },
|
|
969
|
+
...preserve === void 0 ? {} : { preserve },
|
|
970
|
+
...matchingName === void 0 ? {} : { matchingName },
|
|
971
|
+
...userDrawn === void 0 ? {} : { userDrawn },
|
|
972
|
+
...showMasterShapes === void 0 ? {} : { showMasterShapes },
|
|
973
|
+
...showMasterPlaceholderAnimations === void 0 ? {} : { showMasterPlaceholderAnimations },
|
|
974
|
+
...placeholders === void 0 ? {} : { placeholders },
|
|
975
|
+
...colorMapOverride === void 0 ? {} : { colorMapOverride },
|
|
976
|
+
...themeOverride === void 0 ? {} : { themeOverride },
|
|
977
|
+
...layoutHeaderFooter === void 0 ? {} : { headerFooter: layoutHeaderFooter }
|
|
978
|
+
};
|
|
979
|
+
const layoutNode = createSlideLayoutNode(props);
|
|
980
|
+
const layoutObjectBySpid = /* @__PURE__ */ new Map();
|
|
981
|
+
const layoutOmittedSpids = /* @__PURE__ */ new Map();
|
|
982
|
+
if (spTree !== void 0 && shapeTreeHandlers.length > 0) readShapeTreeItems({
|
|
983
|
+
spTree,
|
|
984
|
+
pkg,
|
|
985
|
+
partPath: layoutPartPath,
|
|
986
|
+
slideIndex: void 0,
|
|
987
|
+
relIndex: {
|
|
988
|
+
entries: layoutRels.entries,
|
|
989
|
+
byId: new Map(layoutRels.entries.map((entry) => [entry.Id, entry])),
|
|
990
|
+
diagnostics: []
|
|
991
|
+
},
|
|
992
|
+
shapeTreeHandlers,
|
|
993
|
+
registerDeferredSlideLink,
|
|
994
|
+
registerImportedObject: (spid, node) => {
|
|
995
|
+
layoutObjectBySpid.set(spid, node);
|
|
996
|
+
},
|
|
997
|
+
omittedSpids: layoutOmittedSpids,
|
|
998
|
+
appendNode: (node) => layoutNode.append(node),
|
|
999
|
+
diagnostics,
|
|
1000
|
+
containerNode: layoutNode,
|
|
1001
|
+
clrMap: masterClrMap
|
|
1002
|
+
});
|
|
1003
|
+
for (const slideHandler of masterLevelSlideHandlers) {
|
|
1004
|
+
if (slideHandler.matches !== void 0 && !slideHandler.matches(layoutCursor)) continue;
|
|
1005
|
+
const outcome = slideHandler.read({
|
|
1006
|
+
slideCursor: layoutCursor,
|
|
1007
|
+
slideNode: layoutNode,
|
|
1008
|
+
part: layoutPartPath,
|
|
1009
|
+
...slideHandler.slot === "transition" ? {} : { slideIndex: 0 },
|
|
1010
|
+
package: pkg,
|
|
1011
|
+
objectBySpid: layoutObjectBySpid,
|
|
1012
|
+
omittedSpids: layoutOmittedSpids,
|
|
1013
|
+
...layoutPlaceholderKeyBySpid === void 0 ? {} : { placeholderKeyBySpid: layoutPlaceholderKeyBySpid }
|
|
1014
|
+
});
|
|
1015
|
+
diagnostics.push(...stripSlideIndexFromDiagnostics(outcome.diagnostics));
|
|
1016
|
+
}
|
|
1017
|
+
appendUnconsumedDiagnostics(layoutCursor, void 0, diagnostics);
|
|
1018
|
+
return layoutNode;
|
|
1019
|
+
}
|
|
1020
|
+
function readSlideMasterPart(pkg, masterPartPath, masterOrder, usedDeckIds, themesByPartPath, layoutNodeByPartPath, clrMapByLayoutPartPath, masterLevelSlideHandlers, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, readPlaceholderVisuals) {
|
|
1021
|
+
const xmlText = pkg.readTextPart(masterPartPath);
|
|
1022
|
+
if (xmlText === void 0) return void 0;
|
|
1023
|
+
let masterEl;
|
|
1024
|
+
try {
|
|
1025
|
+
masterEl = parseXmlPart(masterPartPath, xmlText);
|
|
1026
|
+
} catch {
|
|
1027
|
+
diagnostics.push({
|
|
1028
|
+
code: "corrupt-part",
|
|
1029
|
+
category: "corrupt-input",
|
|
1030
|
+
disposition: "omitted",
|
|
1031
|
+
location: { part: masterPartPath }
|
|
1032
|
+
});
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
if ((masterEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (masterEl.localName ?? masterEl.tagName) !== "sldMaster") {
|
|
1036
|
+
diagnostics.push({
|
|
1037
|
+
code: "corrupt-part",
|
|
1038
|
+
category: "corrupt-input",
|
|
1039
|
+
disposition: "omitted",
|
|
1040
|
+
location: { part: masterPartPath }
|
|
1041
|
+
});
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const masterCursor = XmlElementCursor.createRoot(masterEl, masterPartPath, "/p:sldMaster");
|
|
1045
|
+
const rawAttrs = masterCursor.attrsObject(["preserve"]);
|
|
1046
|
+
const parsedAttrs = slideMasterAttrsSchema.safeParse(rawAttrs);
|
|
1047
|
+
let preserve;
|
|
1048
|
+
if (!parsedAttrs.success) diagnostics.push({
|
|
1049
|
+
code: "invalid-xml-value",
|
|
1050
|
+
category: "corrupt-input",
|
|
1051
|
+
disposition: "recovered",
|
|
1052
|
+
location: {
|
|
1053
|
+
part: masterPartPath,
|
|
1054
|
+
xpath: `${masterCursor.xpath}/@preserve`
|
|
1055
|
+
},
|
|
1056
|
+
attributeOrElement: "@preserve",
|
|
1057
|
+
rawValue: rawAttrs["preserve"] ?? ""
|
|
1058
|
+
});
|
|
1059
|
+
else preserve = parsedAttrs.data.preserve;
|
|
1060
|
+
const cSld = masterCursor.child(P_NS, "cSld");
|
|
1061
|
+
if (cSld === void 0) {
|
|
1062
|
+
diagnostics.push({
|
|
1063
|
+
code: "corrupt-part",
|
|
1064
|
+
category: "corrupt-input",
|
|
1065
|
+
disposition: "omitted",
|
|
1066
|
+
location: {
|
|
1067
|
+
part: masterPartPath,
|
|
1068
|
+
xpath: masterCursor.xpath
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const masterName = cSld.attr("name");
|
|
1074
|
+
consumeCommonSlideCreationId(cSld);
|
|
1075
|
+
const clrMap = masterCursor.child(P_NS, "clrMap");
|
|
1076
|
+
let colorMap;
|
|
1077
|
+
let masterClrMap = defaultColorMap;
|
|
1078
|
+
if (clrMap !== void 0) {
|
|
1079
|
+
const parsedMap = readColorMapElement(clrMap, masterPartPath, void 0, diagnostics);
|
|
1080
|
+
masterClrMap = parsedMap;
|
|
1081
|
+
if (isNonDefaultColorMap(parsedMap)) colorMap = parsedMap;
|
|
1082
|
+
}
|
|
1083
|
+
const spTree = cSld.child(P_NS, "spTree");
|
|
1084
|
+
let masterPlaceholders;
|
|
1085
|
+
let masterPlaceholderKeyBySpid;
|
|
1086
|
+
if (spTree !== void 0) {
|
|
1087
|
+
consumeIdentityShapeTreeBoilerplate(spTree);
|
|
1088
|
+
const placeholderRead = readPlaceholderSpList(spTree, masterClrMap, true, pkg, masterPartPath, diagnostics, readPlaceholderVisuals);
|
|
1089
|
+
masterPlaceholders = placeholderRead.placeholders;
|
|
1090
|
+
masterPlaceholderKeyBySpid = placeholderRead.placeholderKeyBySpid;
|
|
1091
|
+
}
|
|
1092
|
+
const txStylesCursor = masterCursor.child(P_NS, "txStyles");
|
|
1093
|
+
let textStyles;
|
|
1094
|
+
if (txStylesCursor !== void 0) {
|
|
1095
|
+
txStylesCursor.ignoreEmptyChild(P_NS, "titleStyle");
|
|
1096
|
+
txStylesCursor.ignoreEmptyChild(P_NS, "bodyStyle");
|
|
1097
|
+
txStylesCursor.ignoreEmptyChild(P_NS, "otherStyle");
|
|
1098
|
+
textStyles = readMasterTextStyles(txStylesCursor, masterClrMap, masterPartPath, diagnostics);
|
|
1099
|
+
}
|
|
1100
|
+
const masterHeaderFooter = readHeaderFooterElement(masterCursor, masterPartPath, diagnostics);
|
|
1101
|
+
const masterRels = pkg.readRelationships(masterPartPath);
|
|
1102
|
+
diagnostics.push(...masterRels.diagnostics);
|
|
1103
|
+
const masterRelById = /* @__PURE__ */ new Map();
|
|
1104
|
+
for (const rel of masterRels.entries) masterRelById.set(rel.Id, rel);
|
|
1105
|
+
let masterTheme;
|
|
1106
|
+
const themeRel = masterRels.entries.find((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" && entry.TargetMode !== "External");
|
|
1107
|
+
if (themeRel !== void 0) {
|
|
1108
|
+
const themePartPath = resolvePartPath(masterPartPath, themeRel.Target);
|
|
1109
|
+
if (themePartPath === void 0 || !pkg.hasPart(themePartPath)) diagnostics.push({
|
|
1110
|
+
code: "missing-target-part",
|
|
1111
|
+
category: "corrupt-input",
|
|
1112
|
+
disposition: "omitted",
|
|
1113
|
+
location: {
|
|
1114
|
+
part: masterPartPath,
|
|
1115
|
+
xpath: themeRel.xpath
|
|
1116
|
+
},
|
|
1117
|
+
relationshipId: themeRel.Id,
|
|
1118
|
+
targetPart: themePartPath ?? themeRel.Target
|
|
1119
|
+
});
|
|
1120
|
+
else masterTheme = readThemePart(pkg, themePartPath, themesByPartPath, diagnostics);
|
|
1121
|
+
}
|
|
1122
|
+
const masterProps = {
|
|
1123
|
+
id: allocateScopedAuthorId(masterName, usedDeckIds, `master-${masterOrder}`),
|
|
1124
|
+
...masterName === void 0 ? {} : { name: masterName },
|
|
1125
|
+
...preserve === void 0 ? {} : { preserve },
|
|
1126
|
+
...masterPlaceholders === void 0 ? {} : { placeholders: masterPlaceholders },
|
|
1127
|
+
...textStyles === void 0 ? {} : { textStyles },
|
|
1128
|
+
...masterTheme === void 0 ? {} : { theme: masterTheme },
|
|
1129
|
+
...colorMap === void 0 ? {} : { colorMap },
|
|
1130
|
+
...masterHeaderFooter === void 0 ? {} : { headerFooter: masterHeaderFooter }
|
|
1131
|
+
};
|
|
1132
|
+
const masterNode = createSlideMasterNode(masterProps);
|
|
1133
|
+
const masterObjectBySpid = /* @__PURE__ */ new Map();
|
|
1134
|
+
const masterOmittedSpids = /* @__PURE__ */ new Map();
|
|
1135
|
+
if (spTree !== void 0 && shapeTreeHandlers.length > 0) readShapeTreeItems({
|
|
1136
|
+
spTree,
|
|
1137
|
+
pkg,
|
|
1138
|
+
partPath: masterPartPath,
|
|
1139
|
+
slideIndex: void 0,
|
|
1140
|
+
relIndex: {
|
|
1141
|
+
entries: masterRels.entries,
|
|
1142
|
+
byId: masterRelById,
|
|
1143
|
+
diagnostics: []
|
|
1144
|
+
},
|
|
1145
|
+
shapeTreeHandlers,
|
|
1146
|
+
registerDeferredSlideLink,
|
|
1147
|
+
registerImportedObject: (spid, node) => {
|
|
1148
|
+
masterObjectBySpid.set(spid, node);
|
|
1149
|
+
},
|
|
1150
|
+
omittedSpids: masterOmittedSpids,
|
|
1151
|
+
appendNode: (node) => masterNode.append(node),
|
|
1152
|
+
diagnostics,
|
|
1153
|
+
containerNode: masterNode,
|
|
1154
|
+
clrMap: masterClrMap
|
|
1155
|
+
});
|
|
1156
|
+
for (const slideHandler of masterLevelSlideHandlers) {
|
|
1157
|
+
if (slideHandler.matches !== void 0 && !slideHandler.matches(masterCursor)) continue;
|
|
1158
|
+
const outcome = slideHandler.read({
|
|
1159
|
+
slideCursor: masterCursor,
|
|
1160
|
+
slideNode: masterNode,
|
|
1161
|
+
part: masterPartPath,
|
|
1162
|
+
...slideHandler.slot === "transition" ? {} : { slideIndex: 0 },
|
|
1163
|
+
package: pkg,
|
|
1164
|
+
objectBySpid: masterObjectBySpid,
|
|
1165
|
+
omittedSpids: masterOmittedSpids,
|
|
1166
|
+
...masterPlaceholderKeyBySpid === void 0 ? {} : { placeholderKeyBySpid: masterPlaceholderKeyBySpid }
|
|
1167
|
+
});
|
|
1168
|
+
diagnostics.push(...stripSlideIndexFromDiagnostics(outcome.diagnostics));
|
|
1169
|
+
}
|
|
1170
|
+
const usedLayoutIds = /* @__PURE__ */ new Set();
|
|
1171
|
+
const sldLayoutIdLst = masterCursor.child(P_NS, "sldLayoutIdLst");
|
|
1172
|
+
if (sldLayoutIdLst !== void 0) {
|
|
1173
|
+
const layoutIdEntries = sldLayoutIdLst.children(P_NS, "sldLayoutId");
|
|
1174
|
+
for (let index = 0; index < layoutIdEntries.length; index += 1) {
|
|
1175
|
+
const layoutIdCursor = layoutIdEntries[index];
|
|
1176
|
+
validateMasterLayoutNumericId(layoutIdCursor.attr("id"), masterPartPath, layoutIdCursor.xpath, diagnostics);
|
|
1177
|
+
const rId = layoutIdCursor.attr("id", R_NS);
|
|
1178
|
+
if (rId === void 0) {
|
|
1179
|
+
diagnostics.push({
|
|
1180
|
+
code: "broken-relationship",
|
|
1181
|
+
category: "corrupt-input",
|
|
1182
|
+
disposition: "omitted",
|
|
1183
|
+
location: {
|
|
1184
|
+
part: masterPartPath,
|
|
1185
|
+
xpath: layoutIdCursor.xpath
|
|
1186
|
+
},
|
|
1187
|
+
relationshipId: ""
|
|
1188
|
+
});
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
const rel = masterRelById.get(rId);
|
|
1192
|
+
if (rel === void 0 || rel.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" || rel.TargetMode === "External") {
|
|
1193
|
+
diagnostics.push({
|
|
1194
|
+
code: "broken-relationship",
|
|
1195
|
+
category: "corrupt-input",
|
|
1196
|
+
disposition: "omitted",
|
|
1197
|
+
location: {
|
|
1198
|
+
part: masterPartPath,
|
|
1199
|
+
xpath: layoutIdCursor.xpath
|
|
1200
|
+
},
|
|
1201
|
+
relationshipId: rId
|
|
1202
|
+
});
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
const layoutPart = resolvePartPath(masterPartPath, rel.Target);
|
|
1206
|
+
if (layoutPart === void 0 || !pkg.hasPart(layoutPart)) {
|
|
1207
|
+
diagnostics.push({
|
|
1208
|
+
code: "missing-target-part",
|
|
1209
|
+
category: "corrupt-input",
|
|
1210
|
+
disposition: "omitted",
|
|
1211
|
+
location: {
|
|
1212
|
+
part: masterPartPath,
|
|
1213
|
+
xpath: layoutIdCursor.xpath
|
|
1214
|
+
},
|
|
1215
|
+
relationshipId: rId,
|
|
1216
|
+
targetPart: layoutPart ?? rel.Target
|
|
1217
|
+
});
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
const layoutNode = readSlideLayoutPart(pkg, layoutPart, masterPartPath, index + 1, usedLayoutIds, masterClrMap, masterLevelSlideHandlers, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, readPlaceholderVisuals);
|
|
1221
|
+
if (layoutNode !== void 0) {
|
|
1222
|
+
masterNode.append(layoutNode);
|
|
1223
|
+
layoutNodeByPartPath.set(layoutPart, layoutNode);
|
|
1224
|
+
clrMapByLayoutPartPath.set(layoutPart, masterClrMap);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
appendUnconsumedDiagnostics(masterCursor, void 0, diagnostics);
|
|
1229
|
+
return masterNode;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Traverses `<p:sldMasterIdLst>` and `<p:sldLayoutIdLst>` relationships to reconstruct explicit
|
|
1233
|
+
* `SlideMaster` and `SlideLayout` ownership (including idle layouts) onto `deckNode`.
|
|
1234
|
+
*/
|
|
1235
|
+
function importMastersAndLayouts(presCursor, pkg, presRelById, deckNode, usedDeckIds, diagnostics, slideHandlers = [], shapeTreeHandlers = [], registerDeferredSlideLink = () => {}, clrMapByLayoutPartPath = /* @__PURE__ */ new Map(), readPlaceholderVisuals) {
|
|
1236
|
+
const masterLevelSlideHandlers = slideHandlers.filter((handler) => handler.slot === "background" || handler.slot === "header-footer" || handler.slot === "transition" || handler.slot === "timing");
|
|
1237
|
+
const layoutNodeByPartPath = /* @__PURE__ */ new Map();
|
|
1238
|
+
const themesByPartPath = /* @__PURE__ */ new Map();
|
|
1239
|
+
const masterIdLst = presCursor.child(P_NS, "sldMasterIdLst");
|
|
1240
|
+
if (masterIdLst === void 0) return layoutNodeByPartPath;
|
|
1241
|
+
const masterIdEntries = masterIdLst.children(P_NS, "sldMasterId");
|
|
1242
|
+
for (let index = 0; index < masterIdEntries.length; index += 1) {
|
|
1243
|
+
const masterIdCursor = masterIdEntries[index];
|
|
1244
|
+
validateMasterLayoutNumericId(masterIdCursor.attr("id"), pkg.presentationPath, masterIdCursor.xpath, diagnostics);
|
|
1245
|
+
const rId = masterIdCursor.attr("id", R_NS);
|
|
1246
|
+
if (rId === void 0) {
|
|
1247
|
+
diagnostics.push({
|
|
1248
|
+
code: "broken-relationship",
|
|
1249
|
+
category: "corrupt-input",
|
|
1250
|
+
disposition: "omitted",
|
|
1251
|
+
location: {
|
|
1252
|
+
part: pkg.presentationPath,
|
|
1253
|
+
xpath: masterIdCursor.xpath
|
|
1254
|
+
},
|
|
1255
|
+
relationshipId: ""
|
|
1256
|
+
});
|
|
1257
|
+
continue;
|
|
1258
|
+
}
|
|
1259
|
+
const rel = presRelById.get(rId);
|
|
1260
|
+
if (rel === void 0 || rel.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" || rel.TargetMode === "External") {
|
|
1261
|
+
diagnostics.push({
|
|
1262
|
+
code: "broken-relationship",
|
|
1263
|
+
category: "corrupt-input",
|
|
1264
|
+
disposition: "omitted",
|
|
1265
|
+
location: {
|
|
1266
|
+
part: pkg.presentationPath,
|
|
1267
|
+
xpath: masterIdCursor.xpath
|
|
1268
|
+
},
|
|
1269
|
+
relationshipId: rId
|
|
1270
|
+
});
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
const masterPart = resolvePartPath(pkg.presentationPath, rel.Target);
|
|
1274
|
+
if (masterPart === void 0 || !pkg.hasPart(masterPart)) {
|
|
1275
|
+
diagnostics.push({
|
|
1276
|
+
code: "missing-target-part",
|
|
1277
|
+
category: "corrupt-input",
|
|
1278
|
+
disposition: "omitted",
|
|
1279
|
+
location: {
|
|
1280
|
+
part: pkg.presentationPath,
|
|
1281
|
+
xpath: masterIdCursor.xpath
|
|
1282
|
+
},
|
|
1283
|
+
relationshipId: rId,
|
|
1284
|
+
targetPart: masterPart ?? rel.Target
|
|
1285
|
+
});
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
const masterNode = readSlideMasterPart(pkg, masterPart, index + 1, usedDeckIds, themesByPartPath, layoutNodeByPartPath, clrMapByLayoutPartPath, masterLevelSlideHandlers, shapeTreeHandlers, registerDeferredSlideLink, diagnostics, readPlaceholderVisuals);
|
|
1289
|
+
if (masterNode !== void 0) deckNode.append(masterNode);
|
|
1290
|
+
}
|
|
1291
|
+
return layoutNodeByPartPath;
|
|
1292
|
+
}
|
|
1293
|
+
export { allocateScopedAuthorId, appendUnconsumedDiagnostics, consumeCommonSlideCreationId, consumeIdentityShapeTreeBoilerplate, importMastersAndLayouts, readShapeTreeItems };
|