@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,984 @@
|
|
|
1
|
+
import { schemeColorNameSchema } from "../../../core/dist/theme.js";
|
|
2
|
+
import "../../../core/dist/capability.js";
|
|
3
|
+
import { A_NS, P_NS, REL_IMAGE, R_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
4
|
+
import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
5
|
+
import { resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "../../../import/dist/resources.js";
|
|
6
|
+
import "../../../import/dist/index.js";
|
|
7
|
+
import { arePathCommandsBounded, isValidPathUnit, isValidPositivePathExtent, preset, presetGeometryNames } from "../shared/geometry.js";
|
|
8
|
+
import { readClickLink } from "../shared/identity.js";
|
|
9
|
+
import { emitPlaceholderUnbindDiagnostic, isPlaceholderPicElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox } from "../shared/placeholder-import.js";
|
|
10
|
+
import { createImageNode } from "./image-declaration.js";
|
|
11
|
+
import { readImage } from "./image-decode.js";
|
|
12
|
+
import { alphaModFixFragmentSchema, customPathAttributesSchema, customPathPointSchema, geomGuideFragmentSchema, imageStyleSchema, imageVisualStyleKeys, lineAttributesFragmentSchema, nonVisualPicIdSchema, outerShadowFragmentSchema, presetDashFragmentSchema, presetGeomFragmentSchema, softEdgeFragmentSchema, srcRectFragmentSchema } from "./image-schemas.js";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
// ../capabilities/dist/image/image-import.js
|
|
15
|
+
const SchemeColorSchema = z.object({ val: schemeColorNameSchema });
|
|
16
|
+
const SrgbColorSchema = z.object({ val: hexRgb6Schema });
|
|
17
|
+
const AlphaModifierSchema = z.object({ val: ooxmlNonNegativeIntSchema });
|
|
18
|
+
function readColorElement(containerCursor, part, slideIndex, diagnostics) {
|
|
19
|
+
const srgb = containerCursor.child(A_NS, "srgbClr");
|
|
20
|
+
const scheme = srgb === void 0 ? containerCursor.child(A_NS, "schemeClr") : void 0;
|
|
21
|
+
const colorCursor = srgb ?? scheme;
|
|
22
|
+
if (colorCursor === void 0) return void 0;
|
|
23
|
+
let baseColor;
|
|
24
|
+
if (srgb !== void 0) {
|
|
25
|
+
const raw = srgb.attrsObject(["val"]);
|
|
26
|
+
const parsed = SrgbColorSchema.safeParse(raw);
|
|
27
|
+
if (!parsed.success) {
|
|
28
|
+
diagnostics.push({
|
|
29
|
+
code: "invalid-xml-value",
|
|
30
|
+
category: "corrupt-input",
|
|
31
|
+
disposition: "omitted",
|
|
32
|
+
location: {
|
|
33
|
+
part,
|
|
34
|
+
xpath: srgb.xpath,
|
|
35
|
+
slideIndex
|
|
36
|
+
},
|
|
37
|
+
attributeOrElement: "a:srgbClr/@val",
|
|
38
|
+
rawValue: raw["val"] ?? ""
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
baseColor = `#${parsed.data.val.toUpperCase()}`;
|
|
43
|
+
} else if (scheme !== void 0) {
|
|
44
|
+
const raw = scheme.attrsObject(["val"]);
|
|
45
|
+
const parsed = SchemeColorSchema.safeParse(raw);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
code: "invalid-xml-value",
|
|
49
|
+
category: "corrupt-input",
|
|
50
|
+
disposition: "omitted",
|
|
51
|
+
location: {
|
|
52
|
+
part,
|
|
53
|
+
xpath: scheme.xpath,
|
|
54
|
+
slideIndex
|
|
55
|
+
},
|
|
56
|
+
attributeOrElement: "a:schemeClr/@val",
|
|
57
|
+
rawValue: raw["val"] ?? ""
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
baseColor = parsed.data.val;
|
|
62
|
+
}
|
|
63
|
+
if (baseColor === void 0) return void 0;
|
|
64
|
+
const alphaCursor = colorCursor.child(A_NS, "alpha");
|
|
65
|
+
if (alphaCursor !== void 0) {
|
|
66
|
+
const rawAlpha = alphaCursor.attrsObject(["val"]);
|
|
67
|
+
const parsedAlpha = AlphaModifierSchema.safeParse(rawAlpha);
|
|
68
|
+
if (parsedAlpha.success) return {
|
|
69
|
+
color: baseColor,
|
|
70
|
+
alpha: parsedAlpha.data.val / 1e5
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return baseColor;
|
|
74
|
+
}
|
|
75
|
+
function readCustomPathPoint(ptCursor, part, slideIndex, diagnostics) {
|
|
76
|
+
const raw = ptCursor.attrsObject(["x", "y"]);
|
|
77
|
+
const parsed = customPathPointSchema.safeParse(raw);
|
|
78
|
+
if (!parsed.success) {
|
|
79
|
+
diagnostics.push({
|
|
80
|
+
code: "invalid-xml-value",
|
|
81
|
+
category: "corrupt-input",
|
|
82
|
+
disposition: "omitted",
|
|
83
|
+
location: {
|
|
84
|
+
part,
|
|
85
|
+
xpath: ptCursor.xpath,
|
|
86
|
+
slideIndex
|
|
87
|
+
},
|
|
88
|
+
attributeOrElement: "a:pt",
|
|
89
|
+
rawValue: JSON.stringify(raw)
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const x = parsed.data.x / 1e3;
|
|
94
|
+
const y = parsed.data.y / 1e3;
|
|
95
|
+
if (!isValidPathUnit(x) || !isValidPathUnit(y)) {
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
code: "invalid-xml-value",
|
|
98
|
+
category: "corrupt-input",
|
|
99
|
+
disposition: "omitted",
|
|
100
|
+
location: {
|
|
101
|
+
part,
|
|
102
|
+
xpath: ptCursor.xpath,
|
|
103
|
+
slideIndex
|
|
104
|
+
},
|
|
105
|
+
attributeOrElement: "a:pt",
|
|
106
|
+
rawValue: JSON.stringify(raw)
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
x,
|
|
112
|
+
y
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function readCustomGeometry(custGeom, part, slideIndex, fallbackExtentEmu, diagnostics) {
|
|
116
|
+
custGeom.ignoreEmptyChild(A_NS, "avLst");
|
|
117
|
+
const gdLst = custGeom.child(A_NS, "gdLst");
|
|
118
|
+
if (gdLst !== void 0 && gdLst.remainingElementChildren().length > 0) {
|
|
119
|
+
diagnostics.push({
|
|
120
|
+
code: "unsupported-mechanism",
|
|
121
|
+
category: "unsupported",
|
|
122
|
+
disposition: "omitted",
|
|
123
|
+
location: {
|
|
124
|
+
part,
|
|
125
|
+
xpath: gdLst.xpath,
|
|
126
|
+
slideIndex
|
|
127
|
+
},
|
|
128
|
+
namespaceUri: A_NS,
|
|
129
|
+
localName: "gdLst"
|
|
130
|
+
});
|
|
131
|
+
custGeom.suppressUnconsumed();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
custGeom.ignoreEmptyChild(A_NS, "ahLst");
|
|
135
|
+
custGeom.ignoreEmptyChild(A_NS, "cxnLst");
|
|
136
|
+
const rect = custGeom.child(A_NS, "rect");
|
|
137
|
+
if (rect !== void 0) {
|
|
138
|
+
rect.consumeAttr("l");
|
|
139
|
+
rect.consumeAttr("t");
|
|
140
|
+
rect.consumeAttr("r");
|
|
141
|
+
rect.consumeAttr("b");
|
|
142
|
+
}
|
|
143
|
+
const pathLst = custGeom.child(A_NS, "pathLst");
|
|
144
|
+
if (pathLst === void 0) return void 0;
|
|
145
|
+
const paths = [];
|
|
146
|
+
let viewWidth;
|
|
147
|
+
let viewHeight;
|
|
148
|
+
let custGeomFailed = false;
|
|
149
|
+
for (const pathCursor of pathLst.children(A_NS, "path")) {
|
|
150
|
+
if (custGeomFailed) {
|
|
151
|
+
pathCursor.suppressUnconsumed();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const rawPath = pathCursor.attrsObject([
|
|
155
|
+
"w",
|
|
156
|
+
"h",
|
|
157
|
+
"fill",
|
|
158
|
+
"stroke"
|
|
159
|
+
]);
|
|
160
|
+
const parsedPath = customPathAttributesSchema.safeParse(rawPath);
|
|
161
|
+
if (!parsedPath.success) {
|
|
162
|
+
diagnostics.push({
|
|
163
|
+
code: "invalid-xml-value",
|
|
164
|
+
category: "corrupt-input",
|
|
165
|
+
disposition: "omitted",
|
|
166
|
+
location: {
|
|
167
|
+
part,
|
|
168
|
+
xpath: pathCursor.xpath,
|
|
169
|
+
slideIndex
|
|
170
|
+
},
|
|
171
|
+
attributeOrElement: "a:path",
|
|
172
|
+
rawValue: JSON.stringify(rawPath)
|
|
173
|
+
});
|
|
174
|
+
pathCursor.suppressUnconsumed();
|
|
175
|
+
custGeomFailed = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const pathW = (parsedPath.data.w ?? fallbackExtentEmu.w) / 1e3;
|
|
179
|
+
const pathH = (parsedPath.data.h ?? fallbackExtentEmu.h) / 1e3;
|
|
180
|
+
if (!isValidPositivePathExtent(pathW) || !isValidPositivePathExtent(pathH)) {
|
|
181
|
+
diagnostics.push({
|
|
182
|
+
code: "invalid-xml-value",
|
|
183
|
+
category: "corrupt-input",
|
|
184
|
+
disposition: "omitted",
|
|
185
|
+
location: {
|
|
186
|
+
part,
|
|
187
|
+
xpath: pathCursor.xpath,
|
|
188
|
+
slideIndex
|
|
189
|
+
},
|
|
190
|
+
attributeOrElement: "a:path",
|
|
191
|
+
rawValue: JSON.stringify(rawPath)
|
|
192
|
+
});
|
|
193
|
+
pathCursor.suppressUnconsumed();
|
|
194
|
+
custGeomFailed = true;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
viewWidth ??= pathW;
|
|
198
|
+
viewHeight ??= pathH;
|
|
199
|
+
const scaleX = pathW === viewWidth ? 1 : viewWidth / pathW;
|
|
200
|
+
const scaleY = pathH === viewHeight ? 1 : viewHeight / pathH;
|
|
201
|
+
const commands = [];
|
|
202
|
+
let pathFailed = false;
|
|
203
|
+
for (const cmdCursor of pathCursor.remainingElementChildren()) {
|
|
204
|
+
if (pathFailed) {
|
|
205
|
+
cmdCursor.suppressUnconsumed();
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (cmdCursor.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") {
|
|
209
|
+
diagnostics.push({
|
|
210
|
+
code: "unconsumed-xml",
|
|
211
|
+
category: "unsupported",
|
|
212
|
+
disposition: "omitted",
|
|
213
|
+
kind: "element",
|
|
214
|
+
location: {
|
|
215
|
+
part,
|
|
216
|
+
xpath: cmdCursor.xpath,
|
|
217
|
+
slideIndex
|
|
218
|
+
},
|
|
219
|
+
namespaceUri: cmdCursor.namespaceUri,
|
|
220
|
+
localName: cmdCursor.localName
|
|
221
|
+
});
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
switch (cmdCursor.localName) {
|
|
225
|
+
case "moveTo": {
|
|
226
|
+
const pt = cmdCursor.child(A_NS, "pt");
|
|
227
|
+
const coords = pt === void 0 ? void 0 : readCustomPathPoint(pt, part, slideIndex, diagnostics);
|
|
228
|
+
if (coords === void 0) {
|
|
229
|
+
cmdCursor.suppressUnconsumed();
|
|
230
|
+
pathFailed = true;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
commands.push({
|
|
234
|
+
op: "M",
|
|
235
|
+
x: coords.x * scaleX,
|
|
236
|
+
y: coords.y * scaleY
|
|
237
|
+
});
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
case "lnTo": {
|
|
241
|
+
const pt = cmdCursor.child(A_NS, "pt");
|
|
242
|
+
const coords = pt === void 0 ? void 0 : readCustomPathPoint(pt, part, slideIndex, diagnostics);
|
|
243
|
+
if (coords === void 0) {
|
|
244
|
+
cmdCursor.suppressUnconsumed();
|
|
245
|
+
pathFailed = true;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
commands.push({
|
|
249
|
+
op: "L",
|
|
250
|
+
x: coords.x * scaleX,
|
|
251
|
+
y: coords.y * scaleY
|
|
252
|
+
});
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case "quadBezTo": {
|
|
256
|
+
const pts = cmdCursor.children(A_NS, "pt");
|
|
257
|
+
if (pts.length !== 2) {
|
|
258
|
+
cmdCursor.suppressUnconsumed();
|
|
259
|
+
pathFailed = true;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
const p1 = readCustomPathPoint(pts[0], part, slideIndex, diagnostics);
|
|
263
|
+
const p2 = readCustomPathPoint(pts[1], part, slideIndex, diagnostics);
|
|
264
|
+
if (p1 === void 0 || p2 === void 0) {
|
|
265
|
+
cmdCursor.suppressUnconsumed();
|
|
266
|
+
pathFailed = true;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
commands.push({
|
|
270
|
+
op: "Q",
|
|
271
|
+
x1: p1.x * scaleX,
|
|
272
|
+
y1: p1.y * scaleY,
|
|
273
|
+
x: p2.x * scaleX,
|
|
274
|
+
y: p2.y * scaleY
|
|
275
|
+
});
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case "cubicBezTo": {
|
|
279
|
+
const pts = cmdCursor.children(A_NS, "pt");
|
|
280
|
+
if (pts.length !== 3) {
|
|
281
|
+
cmdCursor.suppressUnconsumed();
|
|
282
|
+
pathFailed = true;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
const p1 = readCustomPathPoint(pts[0], part, slideIndex, diagnostics);
|
|
286
|
+
const p2 = readCustomPathPoint(pts[1], part, slideIndex, diagnostics);
|
|
287
|
+
const p3 = readCustomPathPoint(pts[2], part, slideIndex, diagnostics);
|
|
288
|
+
if (p1 === void 0 || p2 === void 0 || p3 === void 0) {
|
|
289
|
+
cmdCursor.suppressUnconsumed();
|
|
290
|
+
pathFailed = true;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
commands.push({
|
|
294
|
+
op: "C",
|
|
295
|
+
x1: p1.x * scaleX,
|
|
296
|
+
y1: p1.y * scaleY,
|
|
297
|
+
x2: p2.x * scaleX,
|
|
298
|
+
y2: p2.y * scaleY,
|
|
299
|
+
x: p3.x * scaleX,
|
|
300
|
+
y: p3.y * scaleY
|
|
301
|
+
});
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
case "close":
|
|
305
|
+
commands.push({ op: "Z" });
|
|
306
|
+
break;
|
|
307
|
+
default:
|
|
308
|
+
diagnostics.push({
|
|
309
|
+
code: "unsupported-mechanism",
|
|
310
|
+
category: "unsupported",
|
|
311
|
+
disposition: "omitted",
|
|
312
|
+
location: {
|
|
313
|
+
part,
|
|
314
|
+
xpath: cmdCursor.xpath,
|
|
315
|
+
slideIndex
|
|
316
|
+
},
|
|
317
|
+
namespaceUri: cmdCursor.namespaceUri,
|
|
318
|
+
localName: cmdCursor.localName
|
|
319
|
+
});
|
|
320
|
+
cmdCursor.suppressUnconsumed();
|
|
321
|
+
pathFailed = true;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (pathFailed) {
|
|
325
|
+
pathCursor.suppressUnconsumed();
|
|
326
|
+
custGeomFailed = true;
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (commands.length === 0) continue;
|
|
330
|
+
if (!arePathCommandsBounded(commands)) {
|
|
331
|
+
diagnostics.push({
|
|
332
|
+
code: "invalid-xml-value",
|
|
333
|
+
category: "corrupt-input",
|
|
334
|
+
disposition: "omitted",
|
|
335
|
+
location: {
|
|
336
|
+
part,
|
|
337
|
+
xpath: pathCursor.xpath,
|
|
338
|
+
slideIndex
|
|
339
|
+
},
|
|
340
|
+
attributeOrElement: "a:path"
|
|
341
|
+
});
|
|
342
|
+
pathCursor.suppressUnconsumed();
|
|
343
|
+
custGeomFailed = true;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const fill = parsedPath.data.fill === "none" ? false : true;
|
|
347
|
+
const stroke = parsedPath.data.stroke === "0" || parsedPath.data.stroke === "false" ? false : true;
|
|
348
|
+
paths.push({
|
|
349
|
+
commands,
|
|
350
|
+
...fill ? {} : { fill: false },
|
|
351
|
+
...stroke ? {} : { stroke: false }
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (custGeomFailed || paths.length === 0 || viewWidth === void 0 || viewHeight === void 0 || !isValidPositivePathExtent(viewWidth) || !isValidPositivePathExtent(viewHeight)) {
|
|
355
|
+
custGeom.suppressUnconsumed();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
type: "custom",
|
|
360
|
+
width: viewWidth,
|
|
361
|
+
height: viewHeight,
|
|
362
|
+
paths
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function readPictureGeometry(spPr, part, slideIndex, fallbackExtentEmu, diagnostics) {
|
|
366
|
+
const prstGeom = spPr.child(A_NS, "prstGeom");
|
|
367
|
+
if (prstGeom !== void 0) {
|
|
368
|
+
const rawGeom = prstGeom.attrsObject(["prst"]);
|
|
369
|
+
const parsedGeom = presetGeomFragmentSchema.safeParse(rawGeom);
|
|
370
|
+
const avLst = prstGeom.child(A_NS, "avLst");
|
|
371
|
+
const adjust = {};
|
|
372
|
+
if (avLst !== void 0) for (const gd of avLst.children(A_NS, "gd")) {
|
|
373
|
+
const rawGd = gd.attrsObject(["name", "fmla"]);
|
|
374
|
+
const parsedGd = geomGuideFragmentSchema.safeParse(rawGd);
|
|
375
|
+
if (!parsedGd.success) {
|
|
376
|
+
diagnostics.push({
|
|
377
|
+
code: "invalid-xml-value",
|
|
378
|
+
category: "corrupt-input",
|
|
379
|
+
disposition: "recovered",
|
|
380
|
+
location: {
|
|
381
|
+
part,
|
|
382
|
+
xpath: gd.xpath,
|
|
383
|
+
slideIndex
|
|
384
|
+
},
|
|
385
|
+
attributeOrElement: "a:gd",
|
|
386
|
+
rawValue: JSON.stringify(rawGd)
|
|
387
|
+
});
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const match = /^val (-?\d+)$/u.exec(parsedGd.data.fmla);
|
|
391
|
+
if (match !== null) adjust[parsedGd.data.name] = Number(match[1]);
|
|
392
|
+
}
|
|
393
|
+
if (!parsedGeom.success || !presetGeometryNames.has(parsedGeom.data.prst)) {
|
|
394
|
+
diagnostics.push({
|
|
395
|
+
code: "invalid-xml-value",
|
|
396
|
+
category: "corrupt-input",
|
|
397
|
+
disposition: "recovered",
|
|
398
|
+
location: {
|
|
399
|
+
part,
|
|
400
|
+
xpath: prstGeom.xpath,
|
|
401
|
+
slideIndex
|
|
402
|
+
},
|
|
403
|
+
attributeOrElement: "a:prstGeom/@prst",
|
|
404
|
+
rawValue: rawGeom["prst"] ?? ""
|
|
405
|
+
});
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const prstName = parsedGeom.data.prst;
|
|
409
|
+
if (Object.keys(adjust).length > 0) return preset(prstName, adjust);
|
|
410
|
+
return prstName === "rect" ? void 0 : prstName;
|
|
411
|
+
}
|
|
412
|
+
const custGeom = spPr.child(A_NS, "custGeom");
|
|
413
|
+
if (custGeom !== void 0) return readCustomGeometry(custGeom, part, slideIndex, fallbackExtentEmu, diagnostics);
|
|
414
|
+
}
|
|
415
|
+
function readBorderStyle(ln, part, slideIndex, diagnostics) {
|
|
416
|
+
if (ln.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "noFill")) return {};
|
|
417
|
+
const rawLn = ln.attrsObject(["w"]);
|
|
418
|
+
const parsedLn = lineAttributesFragmentSchema.safeParse(rawLn);
|
|
419
|
+
let borderWidth;
|
|
420
|
+
if (!parsedLn.success) diagnostics.push({
|
|
421
|
+
code: "invalid-xml-value",
|
|
422
|
+
category: "corrupt-input",
|
|
423
|
+
disposition: "recovered",
|
|
424
|
+
location: {
|
|
425
|
+
part,
|
|
426
|
+
xpath: ln.xpath,
|
|
427
|
+
slideIndex
|
|
428
|
+
},
|
|
429
|
+
attributeOrElement: "a:ln/@w",
|
|
430
|
+
rawValue: rawLn["w"] ?? ""
|
|
431
|
+
});
|
|
432
|
+
else if (parsedLn.data.w !== void 0) borderWidth = emuToPx(parsedLn.data.w);
|
|
433
|
+
let borderColor;
|
|
434
|
+
const solidFill = ln.child(A_NS, "solidFill");
|
|
435
|
+
if (solidFill !== void 0) borderColor = readColorElement(solidFill, part, slideIndex, diagnostics);
|
|
436
|
+
let borderStyle;
|
|
437
|
+
const prstDash = ln.child(A_NS, "prstDash");
|
|
438
|
+
if (prstDash !== void 0) {
|
|
439
|
+
const rawDash = prstDash.attrsObject(["val"]);
|
|
440
|
+
const parsedDash = presetDashFragmentSchema.safeParse(rawDash);
|
|
441
|
+
if (!parsedDash.success) diagnostics.push({
|
|
442
|
+
code: "invalid-xml-value",
|
|
443
|
+
category: "corrupt-input",
|
|
444
|
+
disposition: "recovered",
|
|
445
|
+
location: {
|
|
446
|
+
part,
|
|
447
|
+
xpath: prstDash.xpath,
|
|
448
|
+
slideIndex
|
|
449
|
+
},
|
|
450
|
+
attributeOrElement: "a:prstDash/@val",
|
|
451
|
+
rawValue: rawDash["val"] ?? ""
|
|
452
|
+
});
|
|
453
|
+
else switch (parsedDash.data.val) {
|
|
454
|
+
case "solid":
|
|
455
|
+
borderStyle = "solid";
|
|
456
|
+
break;
|
|
457
|
+
case "dash":
|
|
458
|
+
borderStyle = "dashed";
|
|
459
|
+
break;
|
|
460
|
+
case "sysDot":
|
|
461
|
+
case "dot": borderStyle = "dotted";
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (borderColor === void 0) return {};
|
|
465
|
+
return { border: {
|
|
466
|
+
color: borderColor,
|
|
467
|
+
...borderWidth === void 0 ? {} : { width: borderWidth },
|
|
468
|
+
...borderStyle === void 0 ? {} : { style: borderStyle }
|
|
469
|
+
} };
|
|
470
|
+
}
|
|
471
|
+
function readEffectList(effectLst, part, slideIndex, diagnostics) {
|
|
472
|
+
let boxShadow;
|
|
473
|
+
let softEdge;
|
|
474
|
+
const outerShdw = effectLst.child(A_NS, "outerShdw");
|
|
475
|
+
if (outerShdw !== void 0) {
|
|
476
|
+
const rawShadow = outerShdw.attrsObject([
|
|
477
|
+
"blurRad",
|
|
478
|
+
"dist",
|
|
479
|
+
"dir",
|
|
480
|
+
"algn",
|
|
481
|
+
"rotWithShape"
|
|
482
|
+
]);
|
|
483
|
+
const parsedShadow = outerShadowFragmentSchema.safeParse(rawShadow);
|
|
484
|
+
if (!parsedShadow.success) {
|
|
485
|
+
diagnostics.push({
|
|
486
|
+
code: "invalid-xml-value",
|
|
487
|
+
category: "corrupt-input",
|
|
488
|
+
disposition: "recovered",
|
|
489
|
+
location: {
|
|
490
|
+
part,
|
|
491
|
+
xpath: outerShdw.xpath,
|
|
492
|
+
slideIndex
|
|
493
|
+
},
|
|
494
|
+
attributeOrElement: "a:outerShdw",
|
|
495
|
+
rawValue: JSON.stringify(rawShadow)
|
|
496
|
+
});
|
|
497
|
+
outerShdw.suppressUnconsumed();
|
|
498
|
+
} else {
|
|
499
|
+
const color = readColorElement(outerShdw, part, slideIndex, diagnostics);
|
|
500
|
+
boxShadow = {
|
|
501
|
+
...color === void 0 ? {} : { color },
|
|
502
|
+
...parsedShadow.data.blurRad === void 0 ? {} : { blur: emuToPx(parsedShadow.data.blurRad) },
|
|
503
|
+
...parsedShadow.data.dist === void 0 ? {} : { distance: emuToPx(parsedShadow.data.dist) },
|
|
504
|
+
...parsedShadow.data.dir === void 0 ? {} : { angle: parsedShadow.data.dir / 6e4 }
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const softEdgeCursor = effectLst.child(A_NS, "softEdge");
|
|
509
|
+
if (softEdgeCursor !== void 0) {
|
|
510
|
+
const rawSoft = softEdgeCursor.attrsObject(["rad"]);
|
|
511
|
+
const parsedSoft = softEdgeFragmentSchema.safeParse(rawSoft);
|
|
512
|
+
if (!parsedSoft.success) diagnostics.push({
|
|
513
|
+
code: "invalid-xml-value",
|
|
514
|
+
category: "corrupt-input",
|
|
515
|
+
disposition: "recovered",
|
|
516
|
+
location: {
|
|
517
|
+
part,
|
|
518
|
+
xpath: softEdgeCursor.xpath,
|
|
519
|
+
slideIndex
|
|
520
|
+
},
|
|
521
|
+
attributeOrElement: "a:softEdge/@rad",
|
|
522
|
+
rawValue: rawSoft["rad"] ?? ""
|
|
523
|
+
});
|
|
524
|
+
else if (parsedSoft.data.rad > 0) softEdge = emuToPx(parsedSoft.data.rad);
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
...boxShadow === void 0 ? {} : { boxShadow },
|
|
528
|
+
...softEdge === void 0 ? {} : { softEdge }
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Reads a Transitional `<p:pic>` element into an editable `ImageNode`, supporting embedded media,
|
|
533
|
+
* external image links (without network access), crops, clipping geometries, visual effects, and click links.
|
|
534
|
+
*/
|
|
535
|
+
function readImagePic(context) {
|
|
536
|
+
const { cursor, part, slideIndex } = context;
|
|
537
|
+
const diagnostics = [];
|
|
538
|
+
const nvPicPr = cursor.child(P_NS, "nvPicPr");
|
|
539
|
+
if (nvPicPr === void 0) {
|
|
540
|
+
diagnostics.push({
|
|
541
|
+
code: "corrupt-part",
|
|
542
|
+
category: "corrupt-input",
|
|
543
|
+
disposition: "omitted",
|
|
544
|
+
location: {
|
|
545
|
+
part,
|
|
546
|
+
xpath: cursor.xpath,
|
|
547
|
+
slideIndex
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
return { diagnostics };
|
|
551
|
+
}
|
|
552
|
+
let objectId;
|
|
553
|
+
let objectName;
|
|
554
|
+
let alt;
|
|
555
|
+
let clickResult;
|
|
556
|
+
const cNvPr = nvPicPr.child(P_NS, "cNvPr");
|
|
557
|
+
if (cNvPr !== void 0) {
|
|
558
|
+
const rawCNvPr = cNvPr.attrsObject([
|
|
559
|
+
"id",
|
|
560
|
+
"name",
|
|
561
|
+
"descr"
|
|
562
|
+
]);
|
|
563
|
+
const parsedCNvPr = nonVisualPicIdSchema.safeParse(rawCNvPr);
|
|
564
|
+
if (!parsedCNvPr.success) diagnostics.push({
|
|
565
|
+
code: "invalid-xml-value",
|
|
566
|
+
category: "corrupt-input",
|
|
567
|
+
disposition: "recovered",
|
|
568
|
+
location: {
|
|
569
|
+
part,
|
|
570
|
+
xpath: cNvPr.xpath,
|
|
571
|
+
slideIndex
|
|
572
|
+
},
|
|
573
|
+
attributeOrElement: "p:cNvPr",
|
|
574
|
+
rawValue: JSON.stringify(rawCNvPr)
|
|
575
|
+
});
|
|
576
|
+
else {
|
|
577
|
+
objectId = parsedCNvPr.data.id;
|
|
578
|
+
if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
|
|
579
|
+
if (parsedCNvPr.data.descr !== void 0 && parsedCNvPr.data.descr !== "") alt = parsedCNvPr.data.descr;
|
|
580
|
+
}
|
|
581
|
+
const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
|
|
582
|
+
if (hlinkClick !== void 0) clickResult = readClickLink(hlinkClick, context, {
|
|
583
|
+
...objectId === void 0 ? {} : { objectId },
|
|
584
|
+
...objectName === void 0 ? {} : { objectName }
|
|
585
|
+
});
|
|
586
|
+
cNvPr.ignoreEmptyChild(A_NS, "extLst");
|
|
587
|
+
}
|
|
588
|
+
const cNvPicPr = nvPicPr.child(P_NS, "cNvPicPr");
|
|
589
|
+
if (cNvPicPr !== void 0) {
|
|
590
|
+
const picLocks = cNvPicPr.child(A_NS, "picLocks");
|
|
591
|
+
if (picLocks !== void 0) {
|
|
592
|
+
picLocks.consumeAttr("noChangeAspect");
|
|
593
|
+
picLocks.consumeAttr("noGrp");
|
|
594
|
+
picLocks.consumeAttr("preferRelativeResize");
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const picLocation = {
|
|
598
|
+
part,
|
|
599
|
+
xpath: cursor.xpath,
|
|
600
|
+
slideIndex,
|
|
601
|
+
...objectId === void 0 ? {} : { objectId },
|
|
602
|
+
...objectName === void 0 ? {} : { objectName }
|
|
603
|
+
};
|
|
604
|
+
const nvPr = nvPicPr.child(P_NS, "nvPr");
|
|
605
|
+
const phResult = readNvPrPlaceholder(nvPr, picLocation, diagnostics);
|
|
606
|
+
if (phResult.kind === "error") return { diagnostics };
|
|
607
|
+
const nativeRef = phResult.kind === "ok" ? phResult.nativeRef : void 0;
|
|
608
|
+
const cascadedForPicture = clickResult?.clickLocation !== void 0 ? [{
|
|
609
|
+
location: clickResult.clickLocation,
|
|
610
|
+
role: "link"
|
|
611
|
+
}] : [];
|
|
612
|
+
const blipFill = cursor.child(P_NS, "blipFill");
|
|
613
|
+
const spPr = cursor.child(P_NS, "spPr");
|
|
614
|
+
if (blipFill === void 0 || spPr === void 0) {
|
|
615
|
+
diagnostics.push({
|
|
616
|
+
code: "corrupt-part",
|
|
617
|
+
category: "corrupt-input",
|
|
618
|
+
disposition: "omitted",
|
|
619
|
+
location: picLocation,
|
|
620
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
621
|
+
});
|
|
622
|
+
return { diagnostics };
|
|
623
|
+
}
|
|
624
|
+
blipFill.consumeAttr("rotWithShape");
|
|
625
|
+
blipFill.consumeAttr("dpi");
|
|
626
|
+
const blip = blipFill.child(A_NS, "blip");
|
|
627
|
+
if (blip === void 0) {
|
|
628
|
+
diagnostics.push({
|
|
629
|
+
code: "corrupt-part",
|
|
630
|
+
category: "corrupt-input",
|
|
631
|
+
disposition: "omitted",
|
|
632
|
+
location: picLocation,
|
|
633
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
634
|
+
});
|
|
635
|
+
return { diagnostics };
|
|
636
|
+
}
|
|
637
|
+
const embedId = blip.attr("embed", R_NS);
|
|
638
|
+
const linkId = blip.attr("link", R_NS);
|
|
639
|
+
blip.consumeAttr("cstate");
|
|
640
|
+
let opacity;
|
|
641
|
+
const alphaModFix = blip.child(A_NS, "alphaModFix");
|
|
642
|
+
if (alphaModFix !== void 0) {
|
|
643
|
+
const rawAlpha = alphaModFix.attrsObject(["amt"]);
|
|
644
|
+
const parsedAlpha = alphaModFixFragmentSchema.safeParse(rawAlpha);
|
|
645
|
+
if (!parsedAlpha.success) diagnostics.push({
|
|
646
|
+
code: "invalid-xml-value",
|
|
647
|
+
category: "corrupt-input",
|
|
648
|
+
disposition: "recovered",
|
|
649
|
+
location: {
|
|
650
|
+
...picLocation,
|
|
651
|
+
xpath: alphaModFix.xpath
|
|
652
|
+
},
|
|
653
|
+
attributeOrElement: "a:alphaModFix/@amt",
|
|
654
|
+
rawValue: rawAlpha["amt"] ?? ""
|
|
655
|
+
});
|
|
656
|
+
else if (parsedAlpha.data.amt < 1e5) opacity = parsedAlpha.data.amt / 1e5;
|
|
657
|
+
}
|
|
658
|
+
const blipExtLst = blip.child(A_NS, "extLst");
|
|
659
|
+
if (blipExtLst !== void 0) {
|
|
660
|
+
for (const ext of blipExtLst.children(A_NS, "ext")) if (ext.attr("uri") === "{28A0092B-C50C-407E-A947-70E740481C1C}") for (const child of ext.remainingElementChildren()) child.consumeAttr("val");
|
|
661
|
+
}
|
|
662
|
+
let src;
|
|
663
|
+
const relationships = context.relationships ?? /* @__PURE__ */ new Map();
|
|
664
|
+
if (embedId !== void 0 && embedId !== "") {
|
|
665
|
+
const resolved = resolveInternalRelationshipTarget(context.package, relationships, part, embedId, picLocation, REL_IMAGE);
|
|
666
|
+
if (!resolved.ok) {
|
|
667
|
+
diagnostics.push({
|
|
668
|
+
...resolved.diagnostic,
|
|
669
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
670
|
+
});
|
|
671
|
+
return { diagnostics };
|
|
672
|
+
}
|
|
673
|
+
try {
|
|
674
|
+
readImage(resolved.bytes);
|
|
675
|
+
} catch {
|
|
676
|
+
const cascaded = [{
|
|
677
|
+
location: { part: resolved.targetPart },
|
|
678
|
+
role: "media"
|
|
679
|
+
}, ...cascadedForPicture];
|
|
680
|
+
diagnostics.push({
|
|
681
|
+
code: "corrupt-part",
|
|
682
|
+
category: "corrupt-input",
|
|
683
|
+
disposition: "omitted",
|
|
684
|
+
location: picLocation,
|
|
685
|
+
cascaded
|
|
686
|
+
});
|
|
687
|
+
return { diagnostics };
|
|
688
|
+
}
|
|
689
|
+
src = resolved.bytes;
|
|
690
|
+
} else if (linkId !== void 0 && linkId !== "") {
|
|
691
|
+
const resolved = resolveExternalRelationshipTarget(relationships, linkId, picLocation, REL_IMAGE);
|
|
692
|
+
if (!resolved.ok) {
|
|
693
|
+
diagnostics.push({
|
|
694
|
+
...resolved.diagnostic,
|
|
695
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
696
|
+
});
|
|
697
|
+
return { diagnostics };
|
|
698
|
+
}
|
|
699
|
+
src = { externalUrl: resolved.target };
|
|
700
|
+
} else {
|
|
701
|
+
diagnostics.push({
|
|
702
|
+
code: "corrupt-part",
|
|
703
|
+
category: "corrupt-input",
|
|
704
|
+
disposition: "omitted",
|
|
705
|
+
location: picLocation,
|
|
706
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
707
|
+
});
|
|
708
|
+
return { diagnostics };
|
|
709
|
+
}
|
|
710
|
+
let crop;
|
|
711
|
+
const srcRect = blipFill.child(A_NS, "srcRect");
|
|
712
|
+
if (srcRect !== void 0) {
|
|
713
|
+
const rawCrop = srcRect.attrsObject([
|
|
714
|
+
"l",
|
|
715
|
+
"t",
|
|
716
|
+
"r",
|
|
717
|
+
"b"
|
|
718
|
+
]);
|
|
719
|
+
const parsedCrop = srcRectFragmentSchema.safeParse(rawCrop);
|
|
720
|
+
if (!parsedCrop.success) diagnostics.push({
|
|
721
|
+
code: "invalid-xml-value",
|
|
722
|
+
category: "corrupt-input",
|
|
723
|
+
disposition: "recovered",
|
|
724
|
+
location: {
|
|
725
|
+
...picLocation,
|
|
726
|
+
xpath: srcRect.xpath
|
|
727
|
+
},
|
|
728
|
+
attributeOrElement: "a:srcRect",
|
|
729
|
+
rawValue: JSON.stringify(rawCrop)
|
|
730
|
+
});
|
|
731
|
+
else {
|
|
732
|
+
const { l, t, r, b } = parsedCrop.data;
|
|
733
|
+
const nextCrop = {
|
|
734
|
+
...l !== void 0 && l !== 0 ? { left: l / 1e5 } : {},
|
|
735
|
+
...t !== void 0 && t !== 0 ? { top: t / 1e5 } : {},
|
|
736
|
+
...r !== void 0 && r !== 0 ? { right: r / 1e5 } : {},
|
|
737
|
+
...b !== void 0 && b !== 0 ? { bottom: b / 1e5 } : {}
|
|
738
|
+
};
|
|
739
|
+
if (Object.keys(nextCrop).length > 0) crop = nextCrop;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
const stretch = blipFill.child(A_NS, "stretch");
|
|
743
|
+
if (stretch !== void 0) stretch.ignoreEmptyChild(A_NS, "fillRect");
|
|
744
|
+
const claim = nativeRef === void 0 ? void 0 : resolvePlaceholderImportClaim({
|
|
745
|
+
context,
|
|
746
|
+
nativeRef,
|
|
747
|
+
compatibleRoles: /* @__PURE__ */ new Set([
|
|
748
|
+
"pic",
|
|
749
|
+
"clipArt",
|
|
750
|
+
"obj"
|
|
751
|
+
])
|
|
752
|
+
});
|
|
753
|
+
const matchedKey = claim?.bound === true ? claim.key : void 0;
|
|
754
|
+
const matchedLayoutPh = claim?.layoutPlaceholder;
|
|
755
|
+
let localX;
|
|
756
|
+
let localY;
|
|
757
|
+
let localWidth;
|
|
758
|
+
let localHeight;
|
|
759
|
+
let localWidthEmu;
|
|
760
|
+
let localHeightEmu;
|
|
761
|
+
let rotate;
|
|
762
|
+
let flipH;
|
|
763
|
+
let flipV;
|
|
764
|
+
const xfrm = spPr.child(A_NS, "xfrm");
|
|
765
|
+
if (xfrm === void 0) {
|
|
766
|
+
if (nativeRef === void 0) {
|
|
767
|
+
diagnostics.push({
|
|
768
|
+
code: "corrupt-part",
|
|
769
|
+
category: "corrupt-input",
|
|
770
|
+
disposition: "omitted",
|
|
771
|
+
location: picLocation,
|
|
772
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
773
|
+
});
|
|
774
|
+
return { diagnostics };
|
|
775
|
+
}
|
|
776
|
+
} else {
|
|
777
|
+
const off = xfrm.child(A_NS, "off");
|
|
778
|
+
const ext = xfrm.child(A_NS, "ext");
|
|
779
|
+
if (off === void 0 || ext === void 0) {
|
|
780
|
+
diagnostics.push({
|
|
781
|
+
code: "corrupt-part",
|
|
782
|
+
category: "corrupt-input",
|
|
783
|
+
disposition: "omitted",
|
|
784
|
+
location: picLocation,
|
|
785
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
786
|
+
});
|
|
787
|
+
return { diagnostics };
|
|
788
|
+
}
|
|
789
|
+
const rawXfrm = xfrm.attrsObject([
|
|
790
|
+
"rot",
|
|
791
|
+
"flipH",
|
|
792
|
+
"flipV"
|
|
793
|
+
]);
|
|
794
|
+
const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
|
|
795
|
+
const rawOff = off.attrsObject(["x", "y"]);
|
|
796
|
+
const parsedOff = offsetEmuFragmentSchema.safeParse(rawOff);
|
|
797
|
+
const rawExt = ext.attrsObject(["cx", "cy"]);
|
|
798
|
+
const parsedExt = extentEmuFragmentSchema.safeParse(rawExt);
|
|
799
|
+
if (!parsedOff.success || !parsedExt.success) {
|
|
800
|
+
if (nativeRef !== void 0) diagnostics.push({
|
|
801
|
+
code: "invalid-xml-value",
|
|
802
|
+
category: "corrupt-input",
|
|
803
|
+
disposition: "recovered",
|
|
804
|
+
location: {
|
|
805
|
+
...picLocation,
|
|
806
|
+
xpath: xfrm.xpath
|
|
807
|
+
},
|
|
808
|
+
attributeOrElement: "a:xfrm"
|
|
809
|
+
});
|
|
810
|
+
else {
|
|
811
|
+
diagnostics.push({
|
|
812
|
+
code: "invalid-xml-value",
|
|
813
|
+
category: "corrupt-input",
|
|
814
|
+
disposition: "omitted",
|
|
815
|
+
location: {
|
|
816
|
+
...picLocation,
|
|
817
|
+
xpath: xfrm.xpath
|
|
818
|
+
},
|
|
819
|
+
attributeOrElement: "a:xfrm",
|
|
820
|
+
...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
|
|
821
|
+
});
|
|
822
|
+
return { diagnostics };
|
|
823
|
+
}
|
|
824
|
+
} else {
|
|
825
|
+
localX = emuToPx(parsedOff.data.x);
|
|
826
|
+
localY = emuToPx(parsedOff.data.y);
|
|
827
|
+
localWidth = emuToPx(parsedExt.data.cx);
|
|
828
|
+
localHeight = emuToPx(parsedExt.data.cy);
|
|
829
|
+
localWidthEmu = parsedExt.data.cx;
|
|
830
|
+
localHeightEmu = parsedExt.data.cy;
|
|
831
|
+
}
|
|
832
|
+
rotate = parsedXfrm.success && parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0 ? parsedXfrm.data.rot / 6e4 : void 0;
|
|
833
|
+
flipH = parsedXfrm.success && parsedXfrm.data.flipH === true ? true : void 0;
|
|
834
|
+
flipV = parsedXfrm.success && parsedXfrm.data.flipV === true ? true : void 0;
|
|
835
|
+
}
|
|
836
|
+
const layoutPhWidth = typeof matchedLayoutPh?.style?.width === "number" ? matchedLayoutPh.style.width : void 0;
|
|
837
|
+
const layoutPhHeight = typeof matchedLayoutPh?.style?.height === "number" ? matchedLayoutPh.style.height : void 0;
|
|
838
|
+
const geometry = readPictureGeometry(spPr, part, slideIndex, {
|
|
839
|
+
w: localWidthEmu ?? (layoutPhWidth !== void 0 ? Math.round(layoutPhWidth * 9525) : 952500),
|
|
840
|
+
h: localHeightEmu ?? (layoutPhHeight !== void 0 ? Math.round(layoutPhHeight * 9525) : 952500)
|
|
841
|
+
}, diagnostics);
|
|
842
|
+
spPr.ignoreEmptyChild(A_NS, "noFill");
|
|
843
|
+
let border = {};
|
|
844
|
+
const ln = spPr.child(A_NS, "ln");
|
|
845
|
+
if (ln !== void 0) border = readBorderStyle(ln, part, slideIndex, diagnostics);
|
|
846
|
+
let effects = {};
|
|
847
|
+
const effectLst = spPr.child(A_NS, "effectLst");
|
|
848
|
+
if (effectLst !== void 0) effects = readEffectList(effectLst, part, slideIndex, diagnostics);
|
|
849
|
+
if (clickResult !== void 0) diagnostics.push(...clickResult.diagnostics);
|
|
850
|
+
const localVisualStyle = {
|
|
851
|
+
...flipH === void 0 ? {} : { flipH },
|
|
852
|
+
...flipV === void 0 ? {} : { flipV },
|
|
853
|
+
...opacity === void 0 ? {} : { opacity },
|
|
854
|
+
...rotate === void 0 ? {} : { rotate },
|
|
855
|
+
...border,
|
|
856
|
+
...effects
|
|
857
|
+
};
|
|
858
|
+
if (claim !== void 0 && !claim.bound) {
|
|
859
|
+
const resolvedBox = resolveUnboundPlaceholderBox({
|
|
860
|
+
inheritanceContext: claim.inheritanceContext,
|
|
861
|
+
localBox: {
|
|
862
|
+
...localX === void 0 ? {} : { x: localX },
|
|
863
|
+
...localY === void 0 ? {} : { y: localY },
|
|
864
|
+
...localWidth === void 0 ? {} : { width: localWidth },
|
|
865
|
+
...localHeight === void 0 ? {} : { height: localHeight }
|
|
866
|
+
},
|
|
867
|
+
requireHeight: true
|
|
868
|
+
});
|
|
869
|
+
if (resolvedBox === void 0 || resolvedBox.height === void 0) {
|
|
870
|
+
diagnostics.push({
|
|
871
|
+
code: "unsupported-mechanism",
|
|
872
|
+
category: "unsupported",
|
|
873
|
+
disposition: "omitted",
|
|
874
|
+
location: picLocation,
|
|
875
|
+
namespaceUri: P_NS,
|
|
876
|
+
localName: "ph",
|
|
877
|
+
mechanismHint: "orphan-placeholder-without-box"
|
|
878
|
+
});
|
|
879
|
+
return { diagnostics };
|
|
880
|
+
}
|
|
881
|
+
const materialized = materializeUnboundVisualStyle({
|
|
882
|
+
inheritanceContext: claim.inheritanceContext,
|
|
883
|
+
localVisualStyle,
|
|
884
|
+
...geometry === void 0 ? {} : { localGeometry: geometry },
|
|
885
|
+
boxSize: {
|
|
886
|
+
width: resolvedBox.width,
|
|
887
|
+
height: resolvedBox.height
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
const imageVisual = {};
|
|
891
|
+
for (const [k, v] of Object.entries(materialized)) if (imageVisualStyleKeys.has(k)) imageVisual[k] = v;
|
|
892
|
+
const rawFreeStyle = {
|
|
893
|
+
position: "absolute",
|
|
894
|
+
left: resolvedBox.x,
|
|
895
|
+
top: resolvedBox.y,
|
|
896
|
+
width: resolvedBox.width,
|
|
897
|
+
height: resolvedBox.height,
|
|
898
|
+
...imageVisual
|
|
899
|
+
};
|
|
900
|
+
const parsedFreeStyle = imageStyleSchema.safeParse(rawFreeStyle);
|
|
901
|
+
const effectiveGeom = geometry ?? claim.layoutPlaceholder?.geometry ?? claim.masterPlaceholder?.geometry;
|
|
902
|
+
const freeNode = createImageNode({
|
|
903
|
+
src,
|
|
904
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
905
|
+
...alt === void 0 ? {} : { alt },
|
|
906
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
907
|
+
...effectiveGeom === void 0 ? {} : { geometry: effectiveGeom },
|
|
908
|
+
...crop === void 0 ? {} : { crop },
|
|
909
|
+
style: parsedFreeStyle.success ? parsedFreeStyle.data : {
|
|
910
|
+
position: "absolute",
|
|
911
|
+
left: resolvedBox.x,
|
|
912
|
+
top: resolvedBox.y,
|
|
913
|
+
width: resolvedBox.width,
|
|
914
|
+
height: resolvedBox.height
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
|
|
918
|
+
const pending = clickResult.deferredSlideLink;
|
|
919
|
+
context.registerDeferredSlideLink({
|
|
920
|
+
...pending,
|
|
921
|
+
apply(targetSlideId) {
|
|
922
|
+
freeNode.set({ link: { id: targetSlideId } });
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
emitPlaceholderUnbindDiagnostic({
|
|
927
|
+
diagnostics,
|
|
928
|
+
location: picLocation,
|
|
929
|
+
retainedAs: "image"
|
|
930
|
+
});
|
|
931
|
+
return {
|
|
932
|
+
node: freeNode,
|
|
933
|
+
diagnostics
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
const style = {
|
|
937
|
+
...localX !== void 0 && localY !== void 0 ? {
|
|
938
|
+
position: "absolute",
|
|
939
|
+
left: localX,
|
|
940
|
+
top: localY
|
|
941
|
+
} : {},
|
|
942
|
+
...localWidth === void 0 ? {} : { width: localWidth },
|
|
943
|
+
...localHeight === void 0 ? {} : { height: localHeight },
|
|
944
|
+
...localVisualStyle
|
|
945
|
+
};
|
|
946
|
+
const props = {
|
|
947
|
+
src,
|
|
948
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
949
|
+
...matchedKey === void 0 ? {} : { placeholder: matchedKey },
|
|
950
|
+
...matchedKey === void 0 || nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
|
|
951
|
+
...alt === void 0 ? {} : { alt },
|
|
952
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
953
|
+
...geometry === void 0 ? {} : { geometry },
|
|
954
|
+
...crop === void 0 ? {} : { crop },
|
|
955
|
+
...Object.keys(style).length === 0 ? {} : { style }
|
|
956
|
+
};
|
|
957
|
+
const node = createImageNode(props);
|
|
958
|
+
if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
|
|
959
|
+
const pending = clickResult.deferredSlideLink;
|
|
960
|
+
context.registerDeferredSlideLink({
|
|
961
|
+
...pending,
|
|
962
|
+
apply(targetSlideId) {
|
|
963
|
+
node.set({ link: { id: targetSlideId } });
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
node,
|
|
969
|
+
diagnostics
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
const imageImportHandler = {
|
|
973
|
+
target: "shape-tree",
|
|
974
|
+
localName: "pic",
|
|
975
|
+
matches: (cursor) => !isPlaceholderPicElement(cursor),
|
|
976
|
+
read: readImagePic
|
|
977
|
+
};
|
|
978
|
+
const picturePlaceholderImportHandler = {
|
|
979
|
+
target: "shape-tree",
|
|
980
|
+
localName: "pic",
|
|
981
|
+
matches: isPlaceholderPicElement,
|
|
982
|
+
read: readImagePic
|
|
983
|
+
};
|
|
984
|
+
export { imageImportHandler, picturePlaceholderImportHandler, readImagePic };
|