@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,649 @@
|
|
|
1
|
+
import { pxToEmu } from "../../../emit/dist/ooxml.js";
|
|
2
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
3
|
+
import "../../../emit/dist/index.js";
|
|
4
|
+
import { A_NS, DIAGRAM_NS, DSP_NS, P_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
5
|
+
import { XmlElementCursor, parseXmlPart } from "../../../import/dist/xml-reader.js";
|
|
6
|
+
import { resolvePartPath } from "../../../import/dist/opc.js";
|
|
7
|
+
import { extentEmuFragmentSchema, offsetEmuFragmentSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
8
|
+
import { readTransformXml } from "../../../import/dist/visual.js";
|
|
9
|
+
import { buildRelationshipIndex, inspectUnsupportedGraphicFrame, peekShapeTreeObjectIdentity } from "../../../import/dist/resources.js";
|
|
10
|
+
import "../../../import/dist/index.js";
|
|
11
|
+
import { imageImportHandler } from "../image/image-import.js";
|
|
12
|
+
import { isLineNormalizedSpElement, readLineCxnSp, readLineSp } from "../line/line-import.js";
|
|
13
|
+
import { readNonVisualCommonProperties, readShapeSp } from "../shape/shape-import.js";
|
|
14
|
+
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readClickLink } from "../shared/identity.js";
|
|
15
|
+
import { directElementChild } from "../shared/placeholder-import.js";
|
|
16
|
+
import { textBoxImportHandler } from "../text/text-import.js";
|
|
17
|
+
import { createGroupNode } from "./group-declaration.js";
|
|
18
|
+
// ../capabilities/dist/group/group-import.js
|
|
19
|
+
function readNodeStyleBox(node) {
|
|
20
|
+
const style = node.props.style;
|
|
21
|
+
if (style !== void 0 && typeof style["left"] === "number" && typeof style["top"] === "number" && typeof style["width"] === "number" && typeof style["height"] === "number") return {
|
|
22
|
+
x: style["left"],
|
|
23
|
+
y: style["top"],
|
|
24
|
+
width: style["width"],
|
|
25
|
+
height: style["height"]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function nodeBoundsPx(node) {
|
|
29
|
+
const styleBox = readNodeStyleBox(node);
|
|
30
|
+
if (styleBox !== void 0) return styleBox;
|
|
31
|
+
if (node.type === "group") return memberUnionPx(node.children.filter((child) => child instanceof CommonNode));
|
|
32
|
+
}
|
|
33
|
+
function memberUnionPx(members) {
|
|
34
|
+
if (members.length === 0) return void 0;
|
|
35
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
36
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
37
|
+
let maxRight = Number.NEGATIVE_INFINITY;
|
|
38
|
+
let maxBottom = Number.NEGATIVE_INFINITY;
|
|
39
|
+
for (const member of members) {
|
|
40
|
+
const box = nodeBoundsPx(member);
|
|
41
|
+
if (box === void 0) return void 0;
|
|
42
|
+
minX = Math.min(minX, box.x);
|
|
43
|
+
minY = Math.min(minY, box.y);
|
|
44
|
+
maxRight = Math.max(maxRight, box.x + box.width);
|
|
45
|
+
maxBottom = Math.max(maxBottom, box.y + box.height);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
x: minX,
|
|
49
|
+
y: minY,
|
|
50
|
+
width: maxRight - minX,
|
|
51
|
+
height: maxBottom - minY
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const isValidMappedBox = (box, allowZeroExtent = false) => {
|
|
55
|
+
if (!Number.isFinite(box.x) || !Number.isFinite(box.y) || Math.abs(box.x) > 1e6 || Math.abs(box.y) > 1e6 || !Number.isFinite(box.width) || !Number.isFinite(box.height)) return false;
|
|
56
|
+
const cx = pxToEmu(box.width);
|
|
57
|
+
const cy = pxToEmu(box.height);
|
|
58
|
+
if (!Number.isSafeInteger(cx) || !Number.isSafeInteger(cy)) return false;
|
|
59
|
+
if (cx > 2147483647 || cy > 2147483647) return false;
|
|
60
|
+
if (allowZeroExtent) return cx >= 0 && cy >= 0 && (cx > 0 || cy > 0);
|
|
61
|
+
return cx >= 1 && cy >= 1;
|
|
62
|
+
};
|
|
63
|
+
const identityMapper = (box) => box;
|
|
64
|
+
function applyMemberMapper(node, memberMapper) {
|
|
65
|
+
const box = readNodeStyleBox(node);
|
|
66
|
+
if (box !== void 0) {
|
|
67
|
+
const mapped = memberMapper(box);
|
|
68
|
+
node.style({
|
|
69
|
+
position: "absolute",
|
|
70
|
+
left: mapped.x,
|
|
71
|
+
top: mapped.y,
|
|
72
|
+
width: mapped.width,
|
|
73
|
+
height: mapped.height
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Converts slide-space coordinates computed in phase 1 into CSS containing-block-relative
|
|
79
|
+
* coordinates. Only positioned groups establish a containing block for their descendants;
|
|
80
|
+
* unpositioned groups inherit the nearest positioned ancestor's origin.
|
|
81
|
+
*/
|
|
82
|
+
function relativizeToContainingBlock(nodes, originX, originY) {
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
const style = node.props.style;
|
|
85
|
+
const isPositioned = style !== void 0 && (style["position"] === "absolute" || style["position"] === "relative") && typeof style["left"] === "number" && typeof style["top"] === "number";
|
|
86
|
+
if (node.type === "group") {
|
|
87
|
+
const childNodes = node.children.filter((child) => child instanceof CommonNode);
|
|
88
|
+
if (isPositioned) {
|
|
89
|
+
const groupOriginX = style["left"];
|
|
90
|
+
const groupOriginY = style["top"];
|
|
91
|
+
if (originX !== 0 || originY !== 0) node.style({
|
|
92
|
+
left: groupOriginX - originX,
|
|
93
|
+
top: groupOriginY - originY
|
|
94
|
+
});
|
|
95
|
+
relativizeToContainingBlock(childNodes, groupOriginX, groupOriginY);
|
|
96
|
+
} else relativizeToContainingBlock(childNodes, originX, originY);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (isPositioned && (originX !== 0 || originY !== 0)) node.style({
|
|
100
|
+
left: style["left"] - originX,
|
|
101
|
+
top: style["top"] - originY
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function readGroupSpSlideSpace(context, parentMapper) {
|
|
106
|
+
const { cursor, part, slideIndex } = context;
|
|
107
|
+
const diagnostics = [];
|
|
108
|
+
const nvGrpSpPr = cursor.child(P_NS, "nvGrpSpPr");
|
|
109
|
+
if (nvGrpSpPr === void 0) {
|
|
110
|
+
diagnostics.push({
|
|
111
|
+
code: "corrupt-part",
|
|
112
|
+
category: "corrupt-input",
|
|
113
|
+
disposition: "omitted",
|
|
114
|
+
location: {
|
|
115
|
+
part,
|
|
116
|
+
xpath: cursor.xpath,
|
|
117
|
+
slideIndex
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return { diagnostics };
|
|
121
|
+
}
|
|
122
|
+
const cNvPr = nvGrpSpPr.child(P_NS, "cNvPr");
|
|
123
|
+
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
124
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "cNvGrpSpPr");
|
|
125
|
+
consumeNonPlaceholderNvPr(nvGrpSpPr);
|
|
126
|
+
const location = {
|
|
127
|
+
part,
|
|
128
|
+
slideIndex,
|
|
129
|
+
...objectId === void 0 ? {} : { objectId },
|
|
130
|
+
...objectName === void 0 ? {} : { objectName }
|
|
131
|
+
};
|
|
132
|
+
const grpSpPr = cursor.child(P_NS, "grpSpPr");
|
|
133
|
+
if (grpSpPr === void 0) {
|
|
134
|
+
diagnostics.push({
|
|
135
|
+
code: "corrupt-part",
|
|
136
|
+
category: "corrupt-input",
|
|
137
|
+
disposition: "omitted",
|
|
138
|
+
location: {
|
|
139
|
+
...location,
|
|
140
|
+
xpath: cursor.xpath
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return { diagnostics };
|
|
144
|
+
}
|
|
145
|
+
const xfrm = grpSpPr.child(A_NS, "xfrm");
|
|
146
|
+
const off = xfrm?.child(A_NS, "off");
|
|
147
|
+
const ext = xfrm?.child(A_NS, "ext");
|
|
148
|
+
const chOff = xfrm?.child(A_NS, "chOff");
|
|
149
|
+
const chExt = xfrm?.child(A_NS, "chExt");
|
|
150
|
+
if (xfrm === void 0 || off === void 0 || ext === void 0 || chOff === void 0 || chExt === void 0) {
|
|
151
|
+
diagnostics.push({
|
|
152
|
+
code: "corrupt-part",
|
|
153
|
+
category: "corrupt-input",
|
|
154
|
+
disposition: "omitted",
|
|
155
|
+
location: {
|
|
156
|
+
...location,
|
|
157
|
+
xpath: grpSpPr.xpath
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return { diagnostics };
|
|
161
|
+
}
|
|
162
|
+
const parsedXfrm = transformAttributesFragmentSchema.safeParse(xfrm.attrsObject([
|
|
163
|
+
"rot",
|
|
164
|
+
"flipH",
|
|
165
|
+
"flipV"
|
|
166
|
+
]));
|
|
167
|
+
const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
|
|
168
|
+
const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
|
|
169
|
+
const parsedChOff = offsetEmuFragmentSchema.safeParse(chOff.attrsObject(["x", "y"]));
|
|
170
|
+
const parsedChExt = extentEmuFragmentSchema.safeParse(chExt.attrsObject(["cx", "cy"]));
|
|
171
|
+
if (!parsedOff.success || !parsedExt.success || !parsedChOff.success || !parsedChExt.success) {
|
|
172
|
+
diagnostics.push({
|
|
173
|
+
code: "invalid-xml-value",
|
|
174
|
+
category: "corrupt-input",
|
|
175
|
+
disposition: "omitted",
|
|
176
|
+
location: {
|
|
177
|
+
...location,
|
|
178
|
+
xpath: xfrm.xpath
|
|
179
|
+
},
|
|
180
|
+
attributeOrElement: "a:xfrm"
|
|
181
|
+
});
|
|
182
|
+
return { diagnostics };
|
|
183
|
+
}
|
|
184
|
+
const flipH = parsedXfrm.success && parsedXfrm.data.flipH === true;
|
|
185
|
+
const flipV = parsedXfrm.success && parsedXfrm.data.flipV === true;
|
|
186
|
+
const rotate = parsedXfrm.success && parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0 ? parsedXfrm.data.rot / 6e4 : void 0;
|
|
187
|
+
const offX = emuToPx(parsedOff.data.x);
|
|
188
|
+
const offY = emuToPx(parsedOff.data.y);
|
|
189
|
+
const extW = emuToPx(parsedExt.data.cx);
|
|
190
|
+
const extH = emuToPx(parsedExt.data.cy);
|
|
191
|
+
const chX = emuToPx(parsedChOff.data.x);
|
|
192
|
+
const chY = emuToPx(parsedChOff.data.y);
|
|
193
|
+
const chW = emuToPx(parsedChExt.data.cx);
|
|
194
|
+
const chH = emuToPx(parsedChExt.data.cy);
|
|
195
|
+
const scaleX = chW > 0 ? extW / chW : 1;
|
|
196
|
+
const scaleY = chH > 0 ? extH / chH : 1;
|
|
197
|
+
grpSpPr.ignoreEmptyChild(A_NS, "noFill");
|
|
198
|
+
grpSpPr.ignoreEmptyChild(A_NS, "effectLst");
|
|
199
|
+
for (const extraChild of grpSpPr.remainingElementChildren()) diagnostics.push({
|
|
200
|
+
code: "unsupported-mechanism",
|
|
201
|
+
category: "unsupported",
|
|
202
|
+
disposition: "omitted",
|
|
203
|
+
location: {
|
|
204
|
+
...location,
|
|
205
|
+
xpath: extraChild.xpath
|
|
206
|
+
},
|
|
207
|
+
namespaceUri: extraChild.namespaceUri,
|
|
208
|
+
localName: extraChild.localName,
|
|
209
|
+
mechanismHint: `group:${extraChild.localName}`
|
|
210
|
+
});
|
|
211
|
+
const memberMapper = (box) => parentMapper({
|
|
212
|
+
x: offX + (box.x - chX) * scaleX,
|
|
213
|
+
y: offY + (box.y - chY) * scaleY,
|
|
214
|
+
width: box.width * scaleX,
|
|
215
|
+
height: box.height * scaleY
|
|
216
|
+
});
|
|
217
|
+
const members = [];
|
|
218
|
+
const groupObjectsBySpid = /* @__PURE__ */ new Map();
|
|
219
|
+
const groupOmittedSpids = /* @__PURE__ */ new Map();
|
|
220
|
+
const groupUsedAuthorIds = /* @__PURE__ */ new Set();
|
|
221
|
+
const groupDeferredConnectors = [];
|
|
222
|
+
const recordGroupOmission = (spid, name) => {
|
|
223
|
+
if (spid !== void 0) groupOmittedSpids.set(spid, {
|
|
224
|
+
...name === void 0 ? {} : { objectName: name },
|
|
225
|
+
reason: "corrupt"
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
const recordGroupMember = (spid, memberName, memberNode, memberXpath) => {
|
|
229
|
+
const memberBox = nodeBoundsPx(memberNode);
|
|
230
|
+
if (memberBox !== void 0 && !isValidMappedBox(memberBox, memberNode.type === "line")) {
|
|
231
|
+
diagnostics.push({
|
|
232
|
+
code: "invalid-xml-value",
|
|
233
|
+
category: "corrupt-input",
|
|
234
|
+
disposition: "omitted",
|
|
235
|
+
location: {
|
|
236
|
+
...location,
|
|
237
|
+
xpath: memberXpath
|
|
238
|
+
},
|
|
239
|
+
attributeOrElement: "a:xfrm"
|
|
240
|
+
});
|
|
241
|
+
recordGroupOmission(spid, memberName);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (spid !== void 0) {
|
|
245
|
+
context.registerImportedObject?.(spid, memberNode);
|
|
246
|
+
groupObjectsBySpid.set(spid, memberNode);
|
|
247
|
+
}
|
|
248
|
+
const authorId = memberNode.props["id"];
|
|
249
|
+
if (typeof authorId === "string" && authorId.length > 0) groupUsedAuthorIds.add(authorId);
|
|
250
|
+
members.push(memberNode);
|
|
251
|
+
};
|
|
252
|
+
for (const childCursor of cursor.remainingElementChildren()) {
|
|
253
|
+
if (childCursor.namespaceUri !== "http://schemas.openxmlformats.org/presentationml/2006/main") {
|
|
254
|
+
diagnostics.push({
|
|
255
|
+
code: "unsupported-mechanism",
|
|
256
|
+
category: "unsupported",
|
|
257
|
+
disposition: "omitted",
|
|
258
|
+
location: {
|
|
259
|
+
...location,
|
|
260
|
+
xpath: childCursor.xpath
|
|
261
|
+
},
|
|
262
|
+
namespaceUri: childCursor.namespaceUri,
|
|
263
|
+
localName: childCursor.localName
|
|
264
|
+
});
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const childContext = {
|
|
268
|
+
...context,
|
|
269
|
+
cursor: childCursor,
|
|
270
|
+
registerDeferredConnector: (resolve) => {
|
|
271
|
+
groupDeferredConnectors.push(resolve);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
if (childCursor.localName === "grpSp") {
|
|
275
|
+
const outcome = readGroupSpSlideSpace(childContext, memberMapper);
|
|
276
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
277
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
278
|
+
if (outcome.node !== void 0) recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
279
|
+
else recordGroupOmission(identity.objectId, identity.objectName);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (childCursor.localName === "sp") {
|
|
283
|
+
if (textBoxImportHandler.matches?.(childCursor)) {
|
|
284
|
+
const outcome = textBoxImportHandler.read(childContext);
|
|
285
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
286
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
287
|
+
if (outcome.node !== void 0) {
|
|
288
|
+
applyMemberMapper(outcome.node, memberMapper);
|
|
289
|
+
recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
290
|
+
} else recordGroupOmission(identity.objectId, identity.objectName);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (isLineNormalizedSpElement(childCursor)) {
|
|
294
|
+
const outcome = readLineSp(childContext, memberMapper);
|
|
295
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
296
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
297
|
+
if (outcome.node !== void 0) recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
298
|
+
else recordGroupOmission(identity.objectId, identity.objectName);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const outcome = readShapeSp(childContext, memberMapper);
|
|
302
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
303
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
304
|
+
if (outcome.node !== void 0) recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
305
|
+
else recordGroupOmission(identity.objectId, identity.objectName);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (childCursor.localName === "cxnSp") {
|
|
309
|
+
const outcome = readLineCxnSp(childContext, memberMapper);
|
|
310
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
311
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
312
|
+
if (outcome.node !== void 0) recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
313
|
+
else recordGroupOmission(identity.objectId, identity.objectName);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (childCursor.localName === "pic") {
|
|
317
|
+
const outcome = imageImportHandler.read(childContext);
|
|
318
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
319
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
320
|
+
if (outcome.node !== void 0) {
|
|
321
|
+
applyMemberMapper(outcome.node, memberMapper);
|
|
322
|
+
recordGroupMember(identity.objectId, identity.objectName, outcome.node, childCursor.xpath);
|
|
323
|
+
} else recordGroupOmission(identity.objectId, identity.objectName);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
diagnostics.push({
|
|
327
|
+
code: "unsupported-mechanism",
|
|
328
|
+
category: "unsupported",
|
|
329
|
+
disposition: "omitted",
|
|
330
|
+
location: {
|
|
331
|
+
...location,
|
|
332
|
+
xpath: childCursor.xpath
|
|
333
|
+
},
|
|
334
|
+
namespaceUri: childCursor.namespaceUri,
|
|
335
|
+
localName: childCursor.localName
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
if (members.length === 0) {
|
|
339
|
+
if (diagnostics.length === 0) diagnostics.push({
|
|
340
|
+
code: "corrupt-part",
|
|
341
|
+
category: "corrupt-input",
|
|
342
|
+
disposition: "omitted",
|
|
343
|
+
location: {
|
|
344
|
+
...location,
|
|
345
|
+
xpath: cursor.xpath
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
return { diagnostics };
|
|
349
|
+
}
|
|
350
|
+
const mappedGroupBox = parentMapper({
|
|
351
|
+
x: offX,
|
|
352
|
+
y: offY,
|
|
353
|
+
width: extW,
|
|
354
|
+
height: extH
|
|
355
|
+
});
|
|
356
|
+
const unionPx = memberUnionPx(members);
|
|
357
|
+
if (unionPx !== void 0 && !isValidMappedBox(unionPx, false) || !isValidMappedBox(mappedGroupBox, true)) {
|
|
358
|
+
if (!diagnostics.some((d) => d.disposition === "omitted")) diagnostics.push({
|
|
359
|
+
code: "invalid-xml-value",
|
|
360
|
+
category: "corrupt-input",
|
|
361
|
+
disposition: "omitted",
|
|
362
|
+
location: {
|
|
363
|
+
...location,
|
|
364
|
+
xpath: cursor.xpath
|
|
365
|
+
},
|
|
366
|
+
attributeOrElement: cursor.localName,
|
|
367
|
+
rawValue: unionPx !== void 0 && pxToEmu(unionPx.width) < 1 ? "width=0" : unionPx !== void 0 && pxToEmu(unionPx.height) < 1 ? "height=0" : "bounds-overflow"
|
|
368
|
+
});
|
|
369
|
+
return { diagnostics };
|
|
370
|
+
}
|
|
371
|
+
const matchesMemberUnion = unionPx !== void 0 && Math.abs(mappedGroupBox.x - unionPx.x) <= .001 && Math.abs(mappedGroupBox.y - unionPx.y) <= .001 && Math.abs(mappedGroupBox.width - unionPx.width) <= .001 && Math.abs(mappedGroupBox.height - unionPx.height) <= .001;
|
|
372
|
+
const isPositionedGroup = pxToEmu(mappedGroupBox.width) > 0 && pxToEmu(mappedGroupBox.height) > 0 && !matchesMemberUnion;
|
|
373
|
+
if (groupDeferredConnectors.length > 0) {
|
|
374
|
+
const scopeContext = {
|
|
375
|
+
scopeObjectsBySpid: groupObjectsBySpid,
|
|
376
|
+
omittedSpids: groupOmittedSpids,
|
|
377
|
+
usedAuthorIds: groupUsedAuthorIds,
|
|
378
|
+
diagnostics
|
|
379
|
+
};
|
|
380
|
+
for (const resolveConnector of groupDeferredConnectors) resolveConnector(scopeContext);
|
|
381
|
+
}
|
|
382
|
+
const groupStyle = {
|
|
383
|
+
...isPositionedGroup ? {
|
|
384
|
+
position: "absolute",
|
|
385
|
+
left: mappedGroupBox.x,
|
|
386
|
+
top: mappedGroupBox.y,
|
|
387
|
+
width: mappedGroupBox.width,
|
|
388
|
+
height: mappedGroupBox.height
|
|
389
|
+
} : {},
|
|
390
|
+
...rotate === void 0 ? {} : { rotate },
|
|
391
|
+
...flipH ? { flipH: true } : {},
|
|
392
|
+
...flipV ? { flipV: true } : {}
|
|
393
|
+
};
|
|
394
|
+
const props = {
|
|
395
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
396
|
+
...link === void 0 ? {} : { link },
|
|
397
|
+
...Object.keys(groupStyle).length === 0 ? {} : { style: groupStyle }
|
|
398
|
+
};
|
|
399
|
+
const node = createGroupNode(props);
|
|
400
|
+
node.append(...members);
|
|
401
|
+
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
402
|
+
return {
|
|
403
|
+
node,
|
|
404
|
+
diagnostics
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Reads a Transitional `<p:grpSp>` recursively into an editable `GroupNode`,
|
|
409
|
+
* applying affine `(chOff, chExt) -> (off, ext)` coordinate mapping and
|
|
410
|
+
* converting positioned group descendants to containing-block-relative coordinates.
|
|
411
|
+
*/
|
|
412
|
+
function readGroupSp(context, parentMapper = identityMapper) {
|
|
413
|
+
const outcome = readGroupSpSlideSpace(context, parentMapper);
|
|
414
|
+
if (outcome.node !== void 0 && parentMapper === identityMapper) relativizeToContainingBlock([outcome.node], 0, 0);
|
|
415
|
+
return outcome;
|
|
416
|
+
}
|
|
417
|
+
function isDiagramGraphicFrame(cursor) {
|
|
418
|
+
if (cursor.namespaceUri !== "http://schemas.openxmlformats.org/presentationml/2006/main" || cursor.localName !== "graphicFrame") return false;
|
|
419
|
+
const graphic = directElementChild(cursor.element, A_NS, "graphic");
|
|
420
|
+
if (graphic === void 0) return false;
|
|
421
|
+
return directElementChild(graphic, A_NS, "graphicData")?.getAttribute("uri") === DIAGRAM_NS;
|
|
422
|
+
}
|
|
423
|
+
function findDescendantByLocalName(root, namespaceUri, localName) {
|
|
424
|
+
for (let child = root.firstChild; child !== null; child = child.nextSibling) {
|
|
425
|
+
if (child.nodeType !== 1) continue;
|
|
426
|
+
const el = child;
|
|
427
|
+
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
428
|
+
const nested = findDescendantByLocalName(el, namespaceUri, localName);
|
|
429
|
+
if (nested !== void 0) return nested;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function resolveDiagramDrawingPartPath(cursor, context) {
|
|
433
|
+
const { package: pkg, part, relationships, relationshipEntries } = context;
|
|
434
|
+
if (relationships === void 0) return void 0;
|
|
435
|
+
const graphic = directElementChild(cursor.element, A_NS, "graphic");
|
|
436
|
+
const graphicData = graphic === void 0 ? void 0 : directElementChild(graphic, A_NS, "graphicData");
|
|
437
|
+
const dmRelId = (graphicData === void 0 ? void 0 : directElementChild(graphicData, "http://schemas.openxmlformats.org/drawingml/2006/diagram", "relIds"))?.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "dm") || void 0;
|
|
438
|
+
if (dmRelId !== void 0) {
|
|
439
|
+
const dataRel = relationships.get(dmRelId);
|
|
440
|
+
if (dataRel !== void 0 && dataRel.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData" && dataRel.TargetMode !== "External") {
|
|
441
|
+
const dataPartPath = resolvePartPath(part, dataRel.Target);
|
|
442
|
+
const dataXml = dataPartPath === void 0 ? void 0 : pkg.readTextPart(dataPartPath);
|
|
443
|
+
if (dataPartPath !== void 0 && dataXml !== void 0) try {
|
|
444
|
+
const drawingRelId = findDescendantByLocalName(parseXmlPart(dataPartPath, dataXml), "http://schemas.microsoft.com/office/drawing/2008/diagram", "dataModelExt")?.getAttribute("relId") ?? void 0;
|
|
445
|
+
if (drawingRelId !== void 0 && drawingRelId !== "") {
|
|
446
|
+
const drawingRel = relationships.get(drawingRelId);
|
|
447
|
+
if (drawingRel !== void 0 && drawingRel.Type === "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" && drawingRel.TargetMode !== "External") return resolvePartPath(part, drawingRel.Target);
|
|
448
|
+
}
|
|
449
|
+
return;
|
|
450
|
+
} catch {}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const dataRels = (relationshipEntries ?? []).filter((entry) => entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData" && entry.TargetMode !== "External");
|
|
454
|
+
const singleDrawingRels = (relationshipEntries ?? []).filter((entry) => entry.Type === "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" && entry.TargetMode !== "External");
|
|
455
|
+
if (dataRels.length <= 1 && singleDrawingRels.length === 1) return resolvePartPath(part, singleDrawingRels[0].Target);
|
|
456
|
+
}
|
|
457
|
+
function cloneDiagramNodeAsPresentation(source, isRootSpTree) {
|
|
458
|
+
const doc = source.ownerDocument;
|
|
459
|
+
const ns = source.namespaceURI ?? "";
|
|
460
|
+
const local = source.localName ?? source.tagName;
|
|
461
|
+
const isDsp = ns === DSP_NS;
|
|
462
|
+
const targetNs = isDsp ? P_NS : ns;
|
|
463
|
+
const targetQualified = isDsp ? `p:${isDsp && isRootSpTree && local === "spTree" ? "grpSp" : local}` : source.tagName;
|
|
464
|
+
const cloned = targetNs === "" ? doc.createElement(targetQualified) : doc.createElementNS(targetNs, targetQualified);
|
|
465
|
+
for (let i = 0; i < source.attributes.length; i += 1) {
|
|
466
|
+
const attr = source.attributes.item(i);
|
|
467
|
+
if (attr === null) continue;
|
|
468
|
+
const attrNs = attr.namespaceURI ?? "";
|
|
469
|
+
if (attrNs === "http://www.w3.org/2000/xmlns/" || attr.name === "xmlns" || attr.prefix === "xmlns") continue;
|
|
470
|
+
const attrLocal = attr.localName ?? attr.name;
|
|
471
|
+
if (isDsp && attrLocal === "modelId" && attrNs === "") continue;
|
|
472
|
+
if (attrNs === "") cloned.setAttribute(attrLocal, attr.value);
|
|
473
|
+
else cloned.setAttributeNS(attrNs, attr.name, attr.value);
|
|
474
|
+
}
|
|
475
|
+
for (let child = source.firstChild; child !== null; child = child.nextSibling) {
|
|
476
|
+
if (child.nodeType === 3 || child.nodeType === 4) {
|
|
477
|
+
cloned.appendChild(doc.createTextNode(child.nodeValue ?? ""));
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (child.nodeType !== 1) continue;
|
|
481
|
+
const childEl = child;
|
|
482
|
+
const childNs = childEl.namespaceURI ?? "";
|
|
483
|
+
const childLocal = childEl.localName ?? childEl.tagName;
|
|
484
|
+
if (childNs === "http://schemas.microsoft.com/office/drawing/2008/diagram" && (childLocal === "style" || childLocal === "txXfrm")) continue;
|
|
485
|
+
cloned.appendChild(cloneDiagramNodeAsPresentation(childEl, false));
|
|
486
|
+
}
|
|
487
|
+
return cloned;
|
|
488
|
+
}
|
|
489
|
+
function appendOrPopulateGroupXfrm(grpSp, frameTransform, objectName) {
|
|
490
|
+
const doc = grpSp.ownerDocument;
|
|
491
|
+
let nvGrpSpPr = directElementChild(grpSp, P_NS, "nvGrpSpPr");
|
|
492
|
+
if (nvGrpSpPr === void 0) {
|
|
493
|
+
nvGrpSpPr = doc.createElementNS(P_NS, "p:nvGrpSpPr");
|
|
494
|
+
grpSp.insertBefore(nvGrpSpPr, grpSp.firstChild);
|
|
495
|
+
}
|
|
496
|
+
let cNvPr = directElementChild(nvGrpSpPr, P_NS, "cNvPr");
|
|
497
|
+
if (cNvPr === void 0) {
|
|
498
|
+
cNvPr = doc.createElementNS(P_NS, "p:cNvPr");
|
|
499
|
+
cNvPr.setAttribute("id", "0");
|
|
500
|
+
cNvPr.setAttribute("name", objectName ?? "");
|
|
501
|
+
nvGrpSpPr.insertBefore(cNvPr, nvGrpSpPr.firstChild);
|
|
502
|
+
} else if (objectName !== void 0 && (cNvPr.getAttribute("name") ?? "").trim() === "") cNvPr.setAttribute("name", objectName);
|
|
503
|
+
if (directElementChild(nvGrpSpPr, "http://schemas.openxmlformats.org/presentationml/2006/main", "cNvGrpSpPr") === void 0) nvGrpSpPr.appendChild(doc.createElementNS(P_NS, "p:cNvGrpSpPr"));
|
|
504
|
+
if (directElementChild(nvGrpSpPr, "http://schemas.openxmlformats.org/presentationml/2006/main", "nvPr") === void 0) nvGrpSpPr.appendChild(doc.createElementNS(P_NS, "p:nvPr"));
|
|
505
|
+
let grpSpPr = directElementChild(grpSp, P_NS, "grpSpPr");
|
|
506
|
+
if (grpSpPr === void 0) {
|
|
507
|
+
grpSpPr = doc.createElementNS(P_NS, "p:grpSpPr");
|
|
508
|
+
grpSp.appendChild(grpSpPr);
|
|
509
|
+
}
|
|
510
|
+
const existingXfrm = directElementChild(grpSpPr, A_NS, "xfrm");
|
|
511
|
+
if (existingXfrm !== void 0 && directElementChild(existingXfrm, "http://schemas.openxmlformats.org/drawingml/2006/main", "off") !== void 0 && directElementChild(existingXfrm, "http://schemas.openxmlformats.org/drawingml/2006/main", "ext") !== void 0 && directElementChild(existingXfrm, "http://schemas.openxmlformats.org/drawingml/2006/main", "chOff") !== void 0 && directElementChild(existingXfrm, "http://schemas.openxmlformats.org/drawingml/2006/main", "chExt") !== void 0) return true;
|
|
512
|
+
if (existingXfrm !== void 0) grpSpPr.removeChild(existingXfrm);
|
|
513
|
+
const xfrm = doc.createElementNS(A_NS, "a:xfrm");
|
|
514
|
+
if (frameTransform.rotate !== void 0 && frameTransform.rotate !== 0) xfrm.setAttribute("rot", String(Math.round(frameTransform.rotate * 6e4)));
|
|
515
|
+
if (frameTransform.flipH) xfrm.setAttribute("flipH", "1");
|
|
516
|
+
if (frameTransform.flipV) xfrm.setAttribute("flipV", "1");
|
|
517
|
+
const off = doc.createElementNS(A_NS, "a:off");
|
|
518
|
+
off.setAttribute("x", String(frameTransform.xEmu));
|
|
519
|
+
off.setAttribute("y", String(frameTransform.yEmu));
|
|
520
|
+
const ext = doc.createElementNS(A_NS, "a:ext");
|
|
521
|
+
ext.setAttribute("cx", String(frameTransform.cxEmu));
|
|
522
|
+
ext.setAttribute("cy", String(frameTransform.cyEmu));
|
|
523
|
+
const chOff = doc.createElementNS(A_NS, "a:chOff");
|
|
524
|
+
chOff.setAttribute("x", "0");
|
|
525
|
+
chOff.setAttribute("y", "0");
|
|
526
|
+
const chExt = doc.createElementNS(A_NS, "a:chExt");
|
|
527
|
+
chExt.setAttribute("cx", String(frameTransform.cxEmu));
|
|
528
|
+
chExt.setAttribute("cy", String(frameTransform.cyEmu));
|
|
529
|
+
xfrm.appendChild(off);
|
|
530
|
+
xfrm.appendChild(ext);
|
|
531
|
+
xfrm.appendChild(chOff);
|
|
532
|
+
xfrm.appendChild(chExt);
|
|
533
|
+
grpSpPr.insertBefore(xfrm, grpSpPr.firstChild);
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Recovers an external SmartArt `<p:graphicFrame>` (`DIAGRAM_NS`) as a native editable `Group`
|
|
538
|
+
* when its pre-computed `ppt/diagrams/drawing*.xml` cache is readable and non-empty.
|
|
539
|
+
*/
|
|
540
|
+
function readDiagramGraphicFrame(context) {
|
|
541
|
+
const { cursor, part, slideIndex, package: pkg } = context;
|
|
542
|
+
const identity = peekShapeTreeObjectIdentity(cursor.element);
|
|
543
|
+
const omitUnsupported = () => {
|
|
544
|
+
const frameInfo = inspectUnsupportedGraphicFrame(cursor, part, context.relationships ?? /* @__PURE__ */ new Map(), context.relationshipEntries ?? []);
|
|
545
|
+
cursor.suppressUnconsumed();
|
|
546
|
+
return { diagnostics: [{
|
|
547
|
+
code: "unsupported-mechanism",
|
|
548
|
+
category: "unsupported",
|
|
549
|
+
disposition: "omitted",
|
|
550
|
+
location: {
|
|
551
|
+
part,
|
|
552
|
+
xpath: cursor.xpath,
|
|
553
|
+
slideIndex,
|
|
554
|
+
...identity
|
|
555
|
+
},
|
|
556
|
+
namespaceUri: cursor.namespaceUri,
|
|
557
|
+
localName: cursor.localName,
|
|
558
|
+
...frameInfo.mechanismHint === void 0 ? {} : { mechanismHint: frameInfo.mechanismHint },
|
|
559
|
+
...frameInfo.cascaded.length === 0 ? {} : { cascaded: frameInfo.cascaded }
|
|
560
|
+
}] };
|
|
561
|
+
};
|
|
562
|
+
const drawingPartPath = resolveDiagramDrawingPartPath(cursor, context);
|
|
563
|
+
const drawingXml = drawingPartPath === void 0 ? void 0 : pkg.readTextPart(drawingPartPath);
|
|
564
|
+
if (drawingPartPath === void 0 || drawingXml === void 0) return omitUnsupported();
|
|
565
|
+
let drawingRootEl;
|
|
566
|
+
try {
|
|
567
|
+
drawingRootEl = parseXmlPart(drawingPartPath, drawingXml);
|
|
568
|
+
} catch {
|
|
569
|
+
return omitUnsupported();
|
|
570
|
+
}
|
|
571
|
+
if ((drawingRootEl.namespaceURI ?? "") !== "http://schemas.microsoft.com/office/drawing/2008/diagram" || (drawingRootEl.localName ?? drawingRootEl.tagName) !== "drawing") return omitUnsupported();
|
|
572
|
+
const dspSpTree = directElementChild(drawingRootEl, DSP_NS, "spTree");
|
|
573
|
+
if (dspSpTree === void 0) return omitUnsupported();
|
|
574
|
+
const diagnostics = [];
|
|
575
|
+
const nvGraphicFramePr = cursor.child(P_NS, "nvGraphicFramePr");
|
|
576
|
+
let clickResult;
|
|
577
|
+
const cNvPr = nvGraphicFramePr?.child(P_NS, "cNvPr");
|
|
578
|
+
if (cNvPr !== void 0) {
|
|
579
|
+
cNvPr.attrsObject(["id", "name"]);
|
|
580
|
+
const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
|
|
581
|
+
if (hlinkClick !== void 0) {
|
|
582
|
+
clickResult = readClickLink(hlinkClick, context, identity);
|
|
583
|
+
diagnostics.push(...clickResult.diagnostics);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const xfrmCursor = cursor.child(P_NS, "xfrm");
|
|
587
|
+
if (xfrmCursor === void 0) return omitUnsupported();
|
|
588
|
+
const frameTransform = readTransformXml(xfrmCursor, {
|
|
589
|
+
part,
|
|
590
|
+
xpath: xfrmCursor.xpath,
|
|
591
|
+
slideIndex,
|
|
592
|
+
...identity
|
|
593
|
+
}, diagnostics);
|
|
594
|
+
if (frameTransform === void 0) return omitUnsupported();
|
|
595
|
+
const clonedGrpSp = cloneDiagramNodeAsPresentation(dspSpTree, true);
|
|
596
|
+
const hadOwnXfrm = appendOrPopulateGroupXfrm(clonedGrpSp, frameTransform, identity.objectName);
|
|
597
|
+
const drawingRelIndex = buildRelationshipIndex(pkg, drawingPartPath);
|
|
598
|
+
diagnostics.push(...drawingRelIndex.diagnostics);
|
|
599
|
+
const grpCursor = XmlElementCursor.createRoot(clonedGrpSp, drawingPartPath, "/dsp:drawing/dsp:spTree");
|
|
600
|
+
const parentMapper = hadOwnXfrm ? (box) => ({
|
|
601
|
+
x: frameTransform.x + box.x,
|
|
602
|
+
y: frameTransform.y + box.y,
|
|
603
|
+
width: box.width,
|
|
604
|
+
height: box.height
|
|
605
|
+
}) : identityMapper;
|
|
606
|
+
const { registerImportedObject: _ignoredReg, claimedPlaceholderKeys: _ignoredClaimed, ...restContext } = context;
|
|
607
|
+
const outcome = readGroupSpSlideSpace({
|
|
608
|
+
...restContext,
|
|
609
|
+
cursor: grpCursor,
|
|
610
|
+
part: drawingPartPath,
|
|
611
|
+
relationships: drawingRelIndex.byId,
|
|
612
|
+
relationshipEntries: drawingRelIndex.entries
|
|
613
|
+
}, parentMapper);
|
|
614
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
615
|
+
if (outcome.node === void 0) return omitUnsupported();
|
|
616
|
+
relativizeToContainingBlock([outcome.node], 0, 0);
|
|
617
|
+
if (clickResult?.link !== void 0) outcome.node.set({ link: clickResult.link });
|
|
618
|
+
attachDeferredSlideLink(outcome.node, clickResult?.deferredSlideLink, context);
|
|
619
|
+
cursor.suppressUnconsumed();
|
|
620
|
+
diagnostics.push({
|
|
621
|
+
code: "compatibility-fallback",
|
|
622
|
+
category: "unsupported",
|
|
623
|
+
disposition: "fallback",
|
|
624
|
+
location: {
|
|
625
|
+
part,
|
|
626
|
+
xpath: cursor.xpath,
|
|
627
|
+
slideIndex,
|
|
628
|
+
...identity
|
|
629
|
+
},
|
|
630
|
+
preferredMechanism: DIAGRAM_NS,
|
|
631
|
+
selectedFallback: "group",
|
|
632
|
+
loss: {
|
|
633
|
+
lost: "native-mechanism",
|
|
634
|
+
retainedAs: "group"
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
return {
|
|
638
|
+
node: outcome.node,
|
|
639
|
+
diagnostics
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const groupImportHandler = {
|
|
643
|
+
target: "shape-tree",
|
|
644
|
+
localName: "grpSp",
|
|
645
|
+
alternateLocalNames: ["graphicFrame"],
|
|
646
|
+
matches: (cursor) => cursor.localName === "grpSp" || isDiagramGraphicFrame(cursor),
|
|
647
|
+
read: (context) => context.cursor.localName === "graphicFrame" ? readDiagramGraphicFrame(context) : readGroupSp(context)
|
|
648
|
+
};
|
|
649
|
+
export { groupImportHandler, readGroupSp };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ../capabilities/dist/group/group-xml.js
|
|
2
|
+
/** Internal PresentationML wrapper for native groups; member baselines stay in slide coordinates. */
|
|
3
|
+
function groupXml(id, escapedName, box, members, rotation, linkXml, flipH = false, flipV = false) {
|
|
4
|
+
const angle = rotation === void 0 ? void 0 : Math.round((rotation % 360 + 360) % 360 * 6e4);
|
|
5
|
+
const flipAttrs = `${flipH ? " flipH=\"1\"" : ""}${flipV ? " flipV=\"1\"" : ""}`;
|
|
6
|
+
return `<p:grpSp><p:nvGrpSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm${angle === void 0 || angle === 0 ? "" : ` rot="${angle}"`}${flipAttrs}><a:off x="${box.x}" y="${box.y}"/><a:ext cx="${box.width}" cy="${box.height}"/><a:chOff x="${box.x}" y="${box.y}"/><a:chExt cx="${box.width}" cy="${box.height}"/></a:xfrm></p:grpSpPr>${members}</p:grpSp>`;
|
|
7
|
+
}
|
|
8
|
+
export { groupXml };
|