pptx-glimpse 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +3885 -3802
- package/dist/browser.js +2 -2
- package/dist/{chunk-XGCLQP2P.js → chunk-3UFL5U77.js} +1 -1
- package/dist/{chunk-ZZKN4U5J.js → chunk-5YFLSUKM.js} +1 -1
- package/dist/{chunk-NMAO44T7.js → chunk-AQ35JYTB.js} +3872 -3789
- package/dist/cli.cjs +1642 -1609
- package/dist/cli.js +2 -2
- package/dist/index.cjs +1642 -1609
- package/dist/index.js +3 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6139,104 +6139,21 @@ init_warning_logger();
|
|
|
6139
6139
|
|
|
6140
6140
|
// ../document/dist/index.js
|
|
6141
6141
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
6142
|
-
var import_fflate = require("fflate");
|
|
6143
6142
|
var import_fast_xml_parser2 = require("fast-xml-parser");
|
|
6143
|
+
var import_fflate = require("fflate");
|
|
6144
6144
|
var import_fflate2 = require("fflate");
|
|
6145
|
+
var import_fast_xml_parser3 = require("fast-xml-parser");
|
|
6145
6146
|
function unsafeOoxmlBoundaryAssertion(value) {
|
|
6146
6147
|
return value;
|
|
6147
6148
|
}
|
|
6148
6149
|
function unsafeBrandAssertion2(value) {
|
|
6149
6150
|
return value;
|
|
6150
6151
|
}
|
|
6151
|
-
function asPartPath(value) {
|
|
6152
|
-
return unsafeBrandAssertion2(value);
|
|
6153
|
-
}
|
|
6154
|
-
function asRelationshipId(value) {
|
|
6155
|
-
return unsafeBrandAssertion2(value);
|
|
6156
|
-
}
|
|
6157
|
-
function asSourceNodeId(value) {
|
|
6158
|
-
return unsafeBrandAssertion2(value);
|
|
6159
|
-
}
|
|
6160
|
-
function asRawSidecarId(value) {
|
|
6161
|
-
return unsafeBrandAssertion2(value);
|
|
6162
|
-
}
|
|
6163
|
-
var RELS_SUFFIX = ".rels";
|
|
6164
|
-
var RELS_MARKER = "_rels/";
|
|
6165
|
-
var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
6166
|
-
function isRelationshipPart(path) {
|
|
6167
|
-
return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
|
|
6168
|
-
}
|
|
6169
|
-
function relationshipsSourcePartPath(relsPath) {
|
|
6170
|
-
const idx = relsPath.lastIndexOf(RELS_MARKER);
|
|
6171
|
-
const dir = relsPath.slice(0, idx);
|
|
6172
|
-
const file = relsPath.slice(idx + RELS_MARKER.length);
|
|
6173
|
-
const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
|
|
6174
|
-
return asPartPath(dir + base);
|
|
6175
|
-
}
|
|
6176
|
-
function resolveRelationshipTarget(sourcePartPath, target) {
|
|
6177
|
-
if (ABSOLUTE_URI_PATTERN.test(target)) return target;
|
|
6178
|
-
const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
|
|
6179
|
-
return normalizePackagePath(combined);
|
|
6180
|
-
}
|
|
6181
|
-
function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
|
|
6182
|
-
if (relationship.targetMode === "External") return void 0;
|
|
6183
|
-
return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
|
|
6184
|
-
}
|
|
6185
|
-
function parseRelationshipTargetMode(value) {
|
|
6186
|
-
if (value === "Internal" || value === "External") return value;
|
|
6187
|
-
return void 0;
|
|
6188
|
-
}
|
|
6189
|
-
function joinPackageRelativeTarget(sourcePartPath, target) {
|
|
6190
|
-
const slash = sourcePartPath.lastIndexOf("/");
|
|
6191
|
-
const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
|
|
6192
|
-
return baseDir === "" ? target : `${baseDir}/${target}`;
|
|
6193
|
-
}
|
|
6194
|
-
function normalizePackagePath(path) {
|
|
6195
|
-
const segments = [];
|
|
6196
|
-
for (const segment of path.split("/")) {
|
|
6197
|
-
if (segment === "" || segment === ".") continue;
|
|
6198
|
-
if (segment === "..") {
|
|
6199
|
-
segments.pop();
|
|
6200
|
-
continue;
|
|
6201
|
-
}
|
|
6202
|
-
segments.push(segment);
|
|
6203
|
-
}
|
|
6204
|
-
return segments.join("/");
|
|
6205
|
-
}
|
|
6206
|
-
var EDITABLE_TEXT_RUN_PROPERTIES = [
|
|
6207
|
-
"bold",
|
|
6208
|
-
"italic",
|
|
6209
|
-
"underline",
|
|
6210
|
-
"fontSize",
|
|
6211
|
-
"color",
|
|
6212
|
-
"typeface"
|
|
6213
|
-
];
|
|
6214
|
-
var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
|
|
6215
|
-
function asEmu2(value) {
|
|
6216
|
-
return unsafeBrandAssertion2(value);
|
|
6217
|
-
}
|
|
6218
|
-
function asPt(value) {
|
|
6219
|
-
return unsafeBrandAssertion2(value);
|
|
6220
|
-
}
|
|
6221
|
-
function asHundredthPt2(value) {
|
|
6222
|
-
return unsafeBrandAssertion2(value);
|
|
6223
|
-
}
|
|
6224
|
-
function asOoxmlPercent(value) {
|
|
6225
|
-
return unsafeBrandAssertion2(value);
|
|
6226
|
-
}
|
|
6227
|
-
function asOoxmlAngle(value) {
|
|
6228
|
-
return unsafeBrandAssertion2(value);
|
|
6229
|
-
}
|
|
6230
|
-
function parseEnumValue(value, allowed) {
|
|
6231
|
-
return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
|
|
6232
|
-
}
|
|
6233
|
-
function parseEnumValueWithDefault(value, allowed, fallback) {
|
|
6234
|
-
return parseEnumValue(value, allowed) ?? fallback;
|
|
6235
|
-
}
|
|
6236
6152
|
var parser = new import_fast_xml_parser.XMLParser({
|
|
6237
6153
|
ignoreAttributes: false,
|
|
6238
6154
|
attributeNamePrefix: "@_",
|
|
6239
6155
|
parseAttributeValue: false,
|
|
6156
|
+
parseTagValue: false,
|
|
6240
6157
|
// Retain prefix. See the comment at the beginning of the file for the reason.
|
|
6241
6158
|
removeNSPrefix: false,
|
|
6242
6159
|
// Do not trim text run (`a:t`) to preserve significant white space at the beginning and end.
|
|
@@ -6349,6 +6266,62 @@ function scalarToString(value) {
|
|
|
6349
6266
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
6350
6267
|
return void 0;
|
|
6351
6268
|
}
|
|
6269
|
+
function asPartPath(value) {
|
|
6270
|
+
return unsafeBrandAssertion2(value);
|
|
6271
|
+
}
|
|
6272
|
+
function asRelationshipId(value) {
|
|
6273
|
+
return unsafeBrandAssertion2(value);
|
|
6274
|
+
}
|
|
6275
|
+
function asSourceNodeId(value) {
|
|
6276
|
+
return unsafeBrandAssertion2(value);
|
|
6277
|
+
}
|
|
6278
|
+
function asRawSidecarId(value) {
|
|
6279
|
+
return unsafeBrandAssertion2(value);
|
|
6280
|
+
}
|
|
6281
|
+
var RELS_SUFFIX = ".rels";
|
|
6282
|
+
var RELS_MARKER = "_rels/";
|
|
6283
|
+
var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
6284
|
+
function isRelationshipPart(path) {
|
|
6285
|
+
return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
|
|
6286
|
+
}
|
|
6287
|
+
function relationshipsSourcePartPath(relsPath) {
|
|
6288
|
+
const idx = relsPath.lastIndexOf(RELS_MARKER);
|
|
6289
|
+
const dir = relsPath.slice(0, idx);
|
|
6290
|
+
const file = relsPath.slice(idx + RELS_MARKER.length);
|
|
6291
|
+
const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
|
|
6292
|
+
return asPartPath(dir + base);
|
|
6293
|
+
}
|
|
6294
|
+
function resolveRelationshipTarget(sourcePartPath, target) {
|
|
6295
|
+
if (ABSOLUTE_URI_PATTERN.test(target)) return target;
|
|
6296
|
+
const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
|
|
6297
|
+
return normalizePackagePath(combined);
|
|
6298
|
+
}
|
|
6299
|
+
function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
|
|
6300
|
+
if (relationship.targetMode === "External") return void 0;
|
|
6301
|
+
return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
|
|
6302
|
+
}
|
|
6303
|
+
function parseRelationshipTargetMode(value) {
|
|
6304
|
+
if (value === "Internal" || value === "External") return value;
|
|
6305
|
+
return void 0;
|
|
6306
|
+
}
|
|
6307
|
+
function joinPackageRelativeTarget(sourcePartPath, target) {
|
|
6308
|
+
const slash = sourcePartPath.lastIndexOf("/");
|
|
6309
|
+
const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
|
|
6310
|
+
return baseDir === "" ? target : `${baseDir}/${target}`;
|
|
6311
|
+
}
|
|
6312
|
+
function normalizePackagePath(path) {
|
|
6313
|
+
const segments = [];
|
|
6314
|
+
for (const segment of path.split("/")) {
|
|
6315
|
+
if (segment === "" || segment === ".") continue;
|
|
6316
|
+
if (segment === "..") {
|
|
6317
|
+
segments.pop();
|
|
6318
|
+
continue;
|
|
6319
|
+
}
|
|
6320
|
+
segments.push(segment);
|
|
6321
|
+
}
|
|
6322
|
+
return segments.join("/");
|
|
6323
|
+
}
|
|
6324
|
+
var textDecoder = new TextDecoder();
|
|
6352
6325
|
var ATTR_PREFIX = "@_";
|
|
6353
6326
|
var TEXT_KEY = "#text";
|
|
6354
6327
|
function createSidecarIdFactory(partPath) {
|
|
@@ -6418,790 +6391,365 @@ function scalarText(value) {
|
|
|
6418
6391
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
6419
6392
|
return void 0;
|
|
6420
6393
|
}
|
|
6421
|
-
|
|
6422
|
-
"
|
|
6423
|
-
"
|
|
6424
|
-
|
|
6425
|
-
"
|
|
6426
|
-
"
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
]
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
var RAW_FILL_LOCAL_NAMES = ["grpFill"];
|
|
6440
|
-
var PRESET_COLOR_HEX = {
|
|
6441
|
-
black: "000000",
|
|
6442
|
-
white: "FFFFFF",
|
|
6443
|
-
red: "FF0000",
|
|
6444
|
-
green: "008000",
|
|
6445
|
-
blue: "0000FF",
|
|
6446
|
-
yellow: "FFFF00",
|
|
6447
|
-
cyan: "00FFFF",
|
|
6448
|
-
magenta: "FF00FF"
|
|
6449
|
-
};
|
|
6450
|
-
function parseColorElement(parent) {
|
|
6451
|
-
if (!parent) return void 0;
|
|
6452
|
-
const srgb = getChild(parent, "srgbClr");
|
|
6453
|
-
if (srgb) {
|
|
6454
|
-
const hex = getAttr(srgb, "val");
|
|
6455
|
-
if (hex !== void 0) {
|
|
6456
|
-
return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
|
|
6457
|
-
}
|
|
6458
|
-
}
|
|
6459
|
-
const scheme = getChild(parent, "schemeClr");
|
|
6460
|
-
if (scheme) {
|
|
6461
|
-
const name = getAttr(scheme, "val");
|
|
6462
|
-
if (name !== void 0) {
|
|
6463
|
-
return withTransforms({ kind: "scheme", scheme: name }, scheme);
|
|
6464
|
-
}
|
|
6465
|
-
}
|
|
6466
|
-
const sys = getChild(parent, "sysClr");
|
|
6467
|
-
if (sys) {
|
|
6468
|
-
const val = getAttr(sys, "val");
|
|
6469
|
-
if (val !== void 0) {
|
|
6470
|
-
const lastClr = getAttr(sys, "lastClr");
|
|
6471
|
-
return withTransforms(
|
|
6472
|
-
{
|
|
6473
|
-
kind: "system",
|
|
6474
|
-
value: val,
|
|
6475
|
-
...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
|
|
6476
|
-
},
|
|
6477
|
-
sys
|
|
6478
|
-
);
|
|
6479
|
-
}
|
|
6394
|
+
function parseCustomGeometry(custGeom, orderedCustGeom) {
|
|
6395
|
+
const pathLst = getChild(custGeom, "pathLst");
|
|
6396
|
+
const paths = getChildArray(pathLst, "path");
|
|
6397
|
+
if (paths.length === 0) return void 0;
|
|
6398
|
+
const avGuides = parseGuideList(getChild(custGeom, "avLst"));
|
|
6399
|
+
const guides = parseGuideList(getChild(custGeom, "gdLst"));
|
|
6400
|
+
const orderedPaths = orderedChildEntries(
|
|
6401
|
+
orderedChildChildren(orderedCustGeom, "pathLst"),
|
|
6402
|
+
"path"
|
|
6403
|
+
);
|
|
6404
|
+
const result = [];
|
|
6405
|
+
for (const [index, path] of paths.entries()) {
|
|
6406
|
+
const width = numericAttr(path, "w") ?? 0;
|
|
6407
|
+
const height = numericAttr(path, "h") ?? 0;
|
|
6408
|
+
if (width === 0 && height === 0) continue;
|
|
6409
|
+
const variables = evaluateGuides(avGuides, guides, width, height);
|
|
6410
|
+
const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
|
|
6411
|
+
if (commands !== void 0) result.push({ width, height, commands });
|
|
6480
6412
|
}
|
|
6481
|
-
return void 0;
|
|
6482
|
-
}
|
|
6483
|
-
function parseEffectList(effectList) {
|
|
6484
|
-
if (effectList === void 0) return void 0;
|
|
6485
|
-
const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
|
|
6486
|
-
const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
|
|
6487
|
-
const glow = parseGlow(getChild(effectList, "glow"));
|
|
6488
|
-
const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
|
|
6489
|
-
const parsed = {
|
|
6490
|
-
...outerShadow !== void 0 ? { outerShadow } : {},
|
|
6491
|
-
...innerShadow !== void 0 ? { innerShadow } : {},
|
|
6492
|
-
...glow !== void 0 ? { glow } : {},
|
|
6493
|
-
...softEdge !== void 0 ? { softEdge } : {}
|
|
6494
|
-
};
|
|
6495
|
-
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
6413
|
+
return result.length > 0 ? result : void 0;
|
|
6496
6414
|
}
|
|
6497
|
-
function
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
const lum = parseLumEffect(getChild(blip, "lum"));
|
|
6503
|
-
const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
|
|
6504
|
-
const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
|
|
6505
|
-
const parsed = {
|
|
6506
|
-
grayscale,
|
|
6507
|
-
...biLevel !== void 0 ? { biLevel } : {},
|
|
6508
|
-
...blur !== void 0 ? { blur } : {},
|
|
6509
|
-
...lum !== void 0 ? { lum } : {},
|
|
6510
|
-
...duotone !== void 0 ? { duotone } : {},
|
|
6511
|
-
...clrChange !== void 0 ? { clrChange } : {}
|
|
6512
|
-
};
|
|
6513
|
-
return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
|
|
6415
|
+
function parseGuideList(parent) {
|
|
6416
|
+
return getChildArray(parent, "gd").map((guide) => ({
|
|
6417
|
+
name: getAttr(guide, "name") ?? "",
|
|
6418
|
+
formula: getAttr(guide, "fmla") ?? ""
|
|
6419
|
+
})).filter((guide) => guide.name !== "" && guide.formula !== "");
|
|
6514
6420
|
}
|
|
6515
|
-
function
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6421
|
+
function buildPathCommands(path, variables, orderedCommands) {
|
|
6422
|
+
const parts = [];
|
|
6423
|
+
let currentX = 0;
|
|
6424
|
+
let currentY = 0;
|
|
6425
|
+
let startX = 0;
|
|
6426
|
+
let startY = 0;
|
|
6427
|
+
for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
|
|
6428
|
+
for (const node of nodes) {
|
|
6429
|
+
if (local === "moveTo") {
|
|
6430
|
+
const point = firstPoint(node, variables);
|
|
6431
|
+
if (point !== void 0) {
|
|
6432
|
+
parts.push(`M ${point.x} ${point.y}`);
|
|
6433
|
+
currentX = point.x;
|
|
6434
|
+
currentY = point.y;
|
|
6435
|
+
startX = point.x;
|
|
6436
|
+
startY = point.y;
|
|
6437
|
+
}
|
|
6438
|
+
} else if (local === "lnTo") {
|
|
6439
|
+
const point = firstPoint(node, variables);
|
|
6440
|
+
if (point !== void 0) {
|
|
6441
|
+
parts.push(`L ${point.x} ${point.y}`);
|
|
6442
|
+
currentX = point.x;
|
|
6443
|
+
currentY = point.y;
|
|
6444
|
+
}
|
|
6445
|
+
} else if (local === "cubicBezTo") {
|
|
6446
|
+
const points = allPoints(node, variables);
|
|
6447
|
+
if (points.length >= 3) {
|
|
6448
|
+
parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
|
|
6449
|
+
currentX = points[points.length - 1].x;
|
|
6450
|
+
currentY = points[points.length - 1].y;
|
|
6451
|
+
}
|
|
6452
|
+
} else if (local === "quadBezTo") {
|
|
6453
|
+
const points = allPoints(node, variables);
|
|
6454
|
+
if (points.length >= 2) {
|
|
6455
|
+
parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
|
|
6456
|
+
currentX = points[points.length - 1].x;
|
|
6457
|
+
currentY = points[points.length - 1].y;
|
|
6458
|
+
}
|
|
6459
|
+
} else if (local === "arcTo") {
|
|
6460
|
+
const arc = convertArcTo(node, currentX, currentY, variables);
|
|
6461
|
+
if (arc !== void 0) {
|
|
6462
|
+
parts.push(arc.command);
|
|
6463
|
+
currentX = arc.endX;
|
|
6464
|
+
currentY = arc.endY;
|
|
6465
|
+
}
|
|
6466
|
+
} else if (local === "close") {
|
|
6467
|
+
parts.push("Z");
|
|
6468
|
+
currentX = startX;
|
|
6469
|
+
currentY = startY;
|
|
6470
|
+
}
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
6527
6474
|
}
|
|
6528
|
-
function
|
|
6529
|
-
if (
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6475
|
+
function pathCommandNodes(path, orderedCommands) {
|
|
6476
|
+
if (orderedCommands === void 0) {
|
|
6477
|
+
return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
|
|
6478
|
+
}
|
|
6479
|
+
const counters = {};
|
|
6480
|
+
const result = [];
|
|
6481
|
+
for (const command of orderedCommands) {
|
|
6482
|
+
const key = orderedNodeKey(command);
|
|
6483
|
+
if (key === void 0) continue;
|
|
6484
|
+
const local = localName(key);
|
|
6485
|
+
const index = counters[local] ?? 0;
|
|
6486
|
+
counters[local] = index + 1;
|
|
6487
|
+
const node = getChildArray(path, local)[index];
|
|
6488
|
+
if (node !== void 0) result.push({ local, nodes: [node] });
|
|
6489
|
+
}
|
|
6490
|
+
return result;
|
|
6538
6491
|
}
|
|
6539
|
-
function
|
|
6540
|
-
|
|
6541
|
-
const color = parseColorElement(node);
|
|
6542
|
-
if (color === void 0) return void 0;
|
|
6543
|
-
return {
|
|
6544
|
-
radius: asEmu2(numericAttr(node, "rad") ?? 0),
|
|
6545
|
-
color
|
|
6546
|
-
};
|
|
6492
|
+
function firstPoint(node, variables) {
|
|
6493
|
+
return allPoints(node, variables)[0];
|
|
6547
6494
|
}
|
|
6548
|
-
function
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
};
|
|
6495
|
+
function allPoints(node, variables) {
|
|
6496
|
+
return getChildArray(node, "pt").map((point) => ({
|
|
6497
|
+
x: resolveValue(getAttr(point, "x") ?? "0", variables),
|
|
6498
|
+
y: resolveValue(getAttr(point, "y") ?? "0", variables)
|
|
6499
|
+
}));
|
|
6553
6500
|
}
|
|
6554
|
-
function
|
|
6555
|
-
|
|
6501
|
+
function convertArcTo(arc, currentX, currentY, variables) {
|
|
6502
|
+
const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
|
|
6503
|
+
const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
|
|
6504
|
+
const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
|
|
6505
|
+
const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
|
|
6506
|
+
if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
|
|
6507
|
+
const startRadians = startAngle / 6e4 * (Math.PI / 180);
|
|
6508
|
+
const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
|
|
6509
|
+
const centerX = currentX - widthRadius * Math.cos(startRadians);
|
|
6510
|
+
const centerY = currentY - heightRadius * Math.sin(startRadians);
|
|
6511
|
+
const endX = centerX + widthRadius * Math.cos(endRadians);
|
|
6512
|
+
const endY = centerY + heightRadius * Math.sin(endRadians);
|
|
6513
|
+
const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
|
|
6514
|
+
const sweepFlag = sweepAngle > 0 ? 1 : 0;
|
|
6556
6515
|
return {
|
|
6557
|
-
|
|
6516
|
+
command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
|
|
6517
|
+
endX,
|
|
6518
|
+
endY
|
|
6558
6519
|
};
|
|
6559
6520
|
}
|
|
6560
|
-
function
|
|
6561
|
-
|
|
6521
|
+
function evaluateGuides(avGuides, guides, width, height) {
|
|
6522
|
+
const variables = createBuiltinVariables(width, height);
|
|
6523
|
+
for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
|
|
6524
|
+
for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
|
|
6525
|
+
return variables;
|
|
6526
|
+
}
|
|
6527
|
+
function createBuiltinVariables(width, height) {
|
|
6562
6528
|
return {
|
|
6563
|
-
|
|
6564
|
-
|
|
6529
|
+
w: width,
|
|
6530
|
+
h: height,
|
|
6531
|
+
l: 0,
|
|
6532
|
+
t: 0,
|
|
6533
|
+
r: width,
|
|
6534
|
+
b: height,
|
|
6535
|
+
wd2: width / 2,
|
|
6536
|
+
hd2: height / 2,
|
|
6537
|
+
wd4: width / 4,
|
|
6538
|
+
hd4: height / 4,
|
|
6539
|
+
ss: Math.min(width, height),
|
|
6540
|
+
ls: Math.max(width, height),
|
|
6541
|
+
cd2: 108e5,
|
|
6542
|
+
cd4: 54e5,
|
|
6543
|
+
cd8: 27e5,
|
|
6544
|
+
"3cd4": 162e5
|
|
6565
6545
|
};
|
|
6566
6546
|
}
|
|
6567
|
-
function
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6547
|
+
function evaluateFormula(formula, variables) {
|
|
6548
|
+
const tokens = formula.trim().split(/\s+/);
|
|
6549
|
+
const op = tokens[0];
|
|
6550
|
+
const resolve = (token) => {
|
|
6551
|
+
if (token === void 0) return 0;
|
|
6552
|
+
const value = Number(token);
|
|
6553
|
+
return Number.isNaN(value) ? variables[token] ?? 0 : value;
|
|
6572
6554
|
};
|
|
6555
|
+
if (op === "val") return resolve(tokens[1]);
|
|
6556
|
+
if (op === "+-") return resolve(tokens[1]) + resolve(tokens[2]) - resolve(tokens[3]);
|
|
6557
|
+
if (op === "*/")
|
|
6558
|
+
return Math.round(resolve(tokens[1]) * resolve(tokens[2]) / (resolve(tokens[3]) || 1));
|
|
6559
|
+
if (op === "+/")
|
|
6560
|
+
return Math.round((resolve(tokens[1]) + resolve(tokens[2])) / (resolve(tokens[3]) || 1));
|
|
6561
|
+
if (op === "pin")
|
|
6562
|
+
return Math.max(resolve(tokens[1]), Math.min(resolve(tokens[2]), resolve(tokens[3])));
|
|
6563
|
+
if (op === "min") return Math.min(resolve(tokens[1]), resolve(tokens[2]));
|
|
6564
|
+
if (op === "max") return Math.max(resolve(tokens[1]), resolve(tokens[2]));
|
|
6565
|
+
if (op === "abs") return Math.abs(resolve(tokens[1]));
|
|
6566
|
+
if (op === "sqrt") return Math.round(Math.sqrt(resolve(tokens[1])));
|
|
6567
|
+
if (op === "sin") return Math.round(resolve(tokens[1]) * Math.sin(toRadians(resolve(tokens[2]))));
|
|
6568
|
+
if (op === "cos") return Math.round(resolve(tokens[1]) * Math.cos(toRadians(resolve(tokens[2]))));
|
|
6569
|
+
if (op === "tan") return Math.round(resolve(tokens[1]) * Math.tan(toRadians(resolve(tokens[2]))));
|
|
6570
|
+
if (op === "at2")
|
|
6571
|
+
return Math.round(Math.atan2(resolve(tokens[2]), resolve(tokens[1])) * (180 / Math.PI) * 6e4);
|
|
6572
|
+
if (op === "mod") {
|
|
6573
|
+
const a = resolve(tokens[1]);
|
|
6574
|
+
const b = resolve(tokens[2]);
|
|
6575
|
+
const c = resolve(tokens[3]);
|
|
6576
|
+
return Math.round(Math.sqrt(a * a + b * b + c * c));
|
|
6577
|
+
}
|
|
6578
|
+
if (op === "cat2") {
|
|
6579
|
+
return Math.round(
|
|
6580
|
+
resolve(tokens[1]) * Math.cos(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
|
|
6581
|
+
);
|
|
6582
|
+
}
|
|
6583
|
+
if (op === "sat2") {
|
|
6584
|
+
return Math.round(
|
|
6585
|
+
resolve(tokens[1]) * Math.sin(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
|
|
6586
|
+
);
|
|
6587
|
+
}
|
|
6588
|
+
if (op === "?:") return resolve(tokens[1]) > 0 ? resolve(tokens[2]) : resolve(tokens[3]);
|
|
6589
|
+
return 0;
|
|
6573
6590
|
}
|
|
6574
|
-
function
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
if (colors.length < 2) return void 0;
|
|
6578
|
-
return { color1: colors[0], color2: colors[1] };
|
|
6591
|
+
function resolveValue(value, variables) {
|
|
6592
|
+
const numeric = Number(value);
|
|
6593
|
+
return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
|
|
6579
6594
|
}
|
|
6580
|
-
function
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
const
|
|
6584
|
-
return
|
|
6595
|
+
function numericAttr(node, name) {
|
|
6596
|
+
const raw = getAttr(node, name);
|
|
6597
|
+
if (raw === void 0) return void 0;
|
|
6598
|
+
const value = Number(raw);
|
|
6599
|
+
return Number.isFinite(value) ? value : void 0;
|
|
6585
6600
|
}
|
|
6586
|
-
function
|
|
6587
|
-
|
|
6588
|
-
for (const [key, value] of Object.entries(parent)) {
|
|
6589
|
-
if (key.startsWith("@_")) continue;
|
|
6590
|
-
const nodes = Array.isArray(value) ? value : [value];
|
|
6591
|
-
for (const node of nodes) {
|
|
6592
|
-
if (!isXmlNode(node)) continue;
|
|
6593
|
-
const color = parseColorChild(key, node);
|
|
6594
|
-
if (color !== void 0) colors.push(color);
|
|
6595
|
-
}
|
|
6596
|
-
}
|
|
6597
|
-
return colors;
|
|
6601
|
+
function round4(value) {
|
|
6602
|
+
return Math.round(value * 1e3) / 1e3;
|
|
6598
6603
|
}
|
|
6599
|
-
function
|
|
6600
|
-
return
|
|
6604
|
+
function toRadians(ooxmlAngle) {
|
|
6605
|
+
return ooxmlAngle / 6e4 * (Math.PI / 180);
|
|
6601
6606
|
}
|
|
6602
|
-
function
|
|
6603
|
-
const
|
|
6604
|
-
return
|
|
6607
|
+
function orderedChildChildren(parent, childLocalName) {
|
|
6608
|
+
const child = orderedChildEntries(parent, childLocalName)[0];
|
|
6609
|
+
return orderedNodeChildren(child);
|
|
6605
6610
|
}
|
|
6606
|
-
function
|
|
6607
|
-
|
|
6611
|
+
function orderedChildEntries(parent, childLocalName) {
|
|
6612
|
+
if (parent === void 0) return [];
|
|
6613
|
+
return parent.filter((child) => {
|
|
6614
|
+
const key = orderedNodeKey(child);
|
|
6615
|
+
return key !== void 0 && localName(key) === childLocalName;
|
|
6616
|
+
});
|
|
6608
6617
|
}
|
|
6609
|
-
function
|
|
6610
|
-
const
|
|
6611
|
-
const
|
|
6612
|
-
return
|
|
6618
|
+
function orderedNodeChildren(node) {
|
|
6619
|
+
const key = node !== void 0 ? orderedNodeKey(node) : void 0;
|
|
6620
|
+
const value = key !== void 0 ? node?.[key] : void 0;
|
|
6621
|
+
return Array.isArray(value) ? value : void 0;
|
|
6613
6622
|
}
|
|
6614
|
-
function
|
|
6615
|
-
|
|
6616
|
-
const solid = getChild(parent, "solidFill");
|
|
6617
|
-
if (solid) {
|
|
6618
|
-
const color = parseColorElement(solid);
|
|
6619
|
-
if (color) return { kind: "solid", color };
|
|
6620
|
-
return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
|
|
6621
|
-
}
|
|
6622
|
-
if (hasChild(parent, "noFill")) return { kind: "none" };
|
|
6623
|
-
const grad = getChild(parent, "gradFill");
|
|
6624
|
-
if (grad) {
|
|
6625
|
-
const fill = parseGradientFill(grad);
|
|
6626
|
-
return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
|
|
6627
|
-
}
|
|
6628
|
-
const blip = getChild(parent, "blipFill");
|
|
6629
|
-
if (blip) {
|
|
6630
|
-
return parseBlipFill(blip) ?? { kind: "raw", raw: makeSidecar("a:blipFill", blip, nextId) };
|
|
6631
|
-
}
|
|
6632
|
-
const pattern = getChild(parent, "pattFill");
|
|
6633
|
-
if (pattern) {
|
|
6634
|
-
const fill = parsePatternFill(pattern);
|
|
6635
|
-
return fill ?? { kind: "raw", raw: makeSidecar("a:pattFill", pattern, nextId) };
|
|
6636
|
-
}
|
|
6637
|
-
for (const name of RAW_FILL_LOCAL_NAMES) {
|
|
6638
|
-
if (hasChild(parent, name)) {
|
|
6639
|
-
return { kind: "raw", raw: makeSidecar(`a:${name}`, getChild(parent, name) ?? {}, nextId) };
|
|
6640
|
-
}
|
|
6641
|
-
}
|
|
6642
|
-
return void 0;
|
|
6643
|
-
}
|
|
6644
|
-
function parseGradientFill(grad) {
|
|
6645
|
-
const stops = [];
|
|
6646
|
-
for (const gs of getChildArray(getChild(grad, "gsLst"), "gs")) {
|
|
6647
|
-
const color = parseColorElement(gs);
|
|
6648
|
-
if (color === void 0) continue;
|
|
6649
|
-
stops.push({
|
|
6650
|
-
position: (numericAttr(gs, "pos") ?? 0) / 1e5,
|
|
6651
|
-
color
|
|
6652
|
-
});
|
|
6653
|
-
}
|
|
6654
|
-
if (stops.length === 0) return void 0;
|
|
6655
|
-
const path = getChild(grad, "path");
|
|
6656
|
-
if (path !== void 0) {
|
|
6657
|
-
const fillToRect = getChild(path, "fillToRect");
|
|
6658
|
-
const l = numericAttr(fillToRect, "l") ?? 0;
|
|
6659
|
-
const t = numericAttr(fillToRect, "t") ?? 0;
|
|
6660
|
-
const r = numericAttr(fillToRect, "r") ?? 0;
|
|
6661
|
-
const b = numericAttr(fillToRect, "b") ?? 0;
|
|
6662
|
-
return {
|
|
6663
|
-
kind: "gradient",
|
|
6664
|
-
gradientType: "radial",
|
|
6665
|
-
stops,
|
|
6666
|
-
centerX: (l + (1e5 - r)) / 2 / 1e5,
|
|
6667
|
-
centerY: (t + (1e5 - b)) / 2 / 1e5
|
|
6668
|
-
};
|
|
6669
|
-
}
|
|
6670
|
-
return {
|
|
6671
|
-
kind: "gradient",
|
|
6672
|
-
gradientType: "linear",
|
|
6673
|
-
stops,
|
|
6674
|
-
angle: asOoxmlAngle(numericAttr(getChild(grad, "lin"), "ang") ?? 0)
|
|
6675
|
-
};
|
|
6676
|
-
}
|
|
6677
|
-
function parseBlipFill(blipFill) {
|
|
6678
|
-
const blip = getChild(blipFill, "blip");
|
|
6679
|
-
const embed = getNamespacedAttr(blip, "embed");
|
|
6680
|
-
if (embed === void 0) return void 0;
|
|
6681
|
-
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
6682
|
-
return {
|
|
6683
|
-
kind: "image",
|
|
6684
|
-
blipRelationshipId: asRelationshipId(embed),
|
|
6685
|
-
...tile !== void 0 ? { tile } : {}
|
|
6686
|
-
};
|
|
6687
|
-
}
|
|
6688
|
-
function parseImageFillTile(tile) {
|
|
6689
|
-
if (tile === void 0) return void 0;
|
|
6690
|
-
const flip = getAttr(tile, "flip") ?? "none";
|
|
6691
|
-
return {
|
|
6692
|
-
tx: asEmu2(numericAttr(tile, "tx") ?? 0),
|
|
6693
|
-
ty: asEmu2(numericAttr(tile, "ty") ?? 0),
|
|
6694
|
-
sx: (numericAttr(tile, "sx") ?? 1e5) / 1e5,
|
|
6695
|
-
sy: (numericAttr(tile, "sy") ?? 1e5) / 1e5,
|
|
6696
|
-
flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
|
|
6697
|
-
align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
|
|
6698
|
-
};
|
|
6699
|
-
}
|
|
6700
|
-
function parseRectangleAlignment(value, fallback) {
|
|
6701
|
-
return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
|
|
6623
|
+
function orderedNodeKey(node) {
|
|
6624
|
+
return Object.keys(node).find((key) => key !== ":@");
|
|
6702
6625
|
}
|
|
6703
|
-
function
|
|
6704
|
-
|
|
6705
|
-
const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
|
|
6706
|
-
if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
|
|
6707
|
-
return {
|
|
6708
|
-
kind: "pattern",
|
|
6709
|
-
preset: getAttr(pattern, "prst") ?? "ltDnDiag",
|
|
6710
|
-
foregroundColor,
|
|
6711
|
-
backgroundColor
|
|
6712
|
-
};
|
|
6626
|
+
function parseEnumValue(value, allowed) {
|
|
6627
|
+
return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
|
|
6713
6628
|
}
|
|
6714
|
-
function
|
|
6715
|
-
|
|
6716
|
-
return parseLine(ln, nextId);
|
|
6629
|
+
function parseEnumValueWithDefault(value, allowed, fallback) {
|
|
6630
|
+
return parseEnumValue(value, allowed) ?? fallback;
|
|
6717
6631
|
}
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6632
|
+
var KNOWN_TXBODY_CHILDREN = /* @__PURE__ */ new Set(["bodyPr", "lstStyle", "p"]);
|
|
6633
|
+
var KNOWN_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
|
|
6634
|
+
"pPr",
|
|
6635
|
+
"r",
|
|
6636
|
+
"fld",
|
|
6637
|
+
"br",
|
|
6638
|
+
"endParaRPr"
|
|
6639
|
+
]);
|
|
6640
|
+
var KNOWN_RUN_CHILDREN = /* @__PURE__ */ new Set(["rPr", "t"]);
|
|
6641
|
+
var KNOWN_RUN_PROPERTY_CHILDREN = /* @__PURE__ */ new Set([
|
|
6642
|
+
"latin",
|
|
6643
|
+
"ea",
|
|
6644
|
+
"cs",
|
|
6645
|
+
"solidFill"
|
|
6646
|
+
]);
|
|
6647
|
+
var ALIGN_MAP = {
|
|
6648
|
+
l: "left",
|
|
6649
|
+
ctr: "center",
|
|
6650
|
+
r: "right",
|
|
6651
|
+
just: "justify"
|
|
6652
|
+
};
|
|
6653
|
+
var ANCHOR_MAP = {
|
|
6654
|
+
t: "top",
|
|
6655
|
+
ctr: "middle",
|
|
6656
|
+
b: "bottom"
|
|
6657
|
+
};
|
|
6658
|
+
var WRAP_VALUES = /* @__PURE__ */ new Set(["square", "none"]);
|
|
6659
|
+
var VERTICAL_VALUES = /* @__PURE__ */ new Set([
|
|
6660
|
+
"horz",
|
|
6661
|
+
"vert",
|
|
6662
|
+
"vert270",
|
|
6663
|
+
"eaVert",
|
|
6664
|
+
"wordArtVert",
|
|
6665
|
+
"mongolianVert"
|
|
6666
|
+
]);
|
|
6667
|
+
var VALID_AUTO_NUM_SCHEMES = /* @__PURE__ */ new Set([
|
|
6668
|
+
"arabicPeriod",
|
|
6669
|
+
"arabicParenR",
|
|
6670
|
+
"romanUcPeriod",
|
|
6671
|
+
"romanLcPeriod",
|
|
6672
|
+
"alphaUcPeriod",
|
|
6673
|
+
"alphaLcPeriod",
|
|
6674
|
+
"alphaLcParenR",
|
|
6675
|
+
"alphaUcParenR",
|
|
6676
|
+
"arabicPlain"
|
|
6677
|
+
]);
|
|
6678
|
+
function parseTextBody(txBody, partPath, nextId, ownerNodeId, ownerOrderingSlot, orderedTxBody) {
|
|
6679
|
+
if (!txBody) return void 0;
|
|
6680
|
+
const properties = parseBodyProperties(getChild(txBody, "bodyPr"));
|
|
6681
|
+
const listStyle = parseTextStyle(getChild(txBody, "lstStyle"));
|
|
6682
|
+
const orderedParagraphs = orderedTxBody?.filter((child) => orderedLocalName(child) === "p").map((child) => {
|
|
6683
|
+
const key = orderedKey(child);
|
|
6684
|
+
const value = key !== void 0 ? child[key] : void 0;
|
|
6685
|
+
return Array.isArray(value) ? value : void 0;
|
|
6686
|
+
});
|
|
6687
|
+
const paragraphs = [];
|
|
6688
|
+
let logicalParagraphIndex = 0;
|
|
6689
|
+
getChildArray(txBody, "p").forEach((p, paragraphIndex) => {
|
|
6690
|
+
const orderedChildren = orderedParagraphs?.[paragraphIndex];
|
|
6691
|
+
if (orderedChildren !== void 0 && hasMultipleBulletPPr(p, orderedChildren)) {
|
|
6692
|
+
const split = splitInterleavedParagraph(
|
|
6693
|
+
p,
|
|
6694
|
+
orderedChildren,
|
|
6695
|
+
partPath,
|
|
6696
|
+
nextId,
|
|
6697
|
+
ownerNodeId,
|
|
6698
|
+
ownerOrderingSlot,
|
|
6699
|
+
logicalParagraphIndex
|
|
6700
|
+
);
|
|
6701
|
+
paragraphs.push(...split);
|
|
6702
|
+
logicalParagraphIndex += split.length;
|
|
6703
|
+
return;
|
|
6704
|
+
}
|
|
6705
|
+
paragraphs.push(
|
|
6706
|
+
parseParagraph(
|
|
6707
|
+
p,
|
|
6708
|
+
partPath,
|
|
6709
|
+
nextId,
|
|
6710
|
+
ownerNodeId,
|
|
6711
|
+
ownerOrderingSlot,
|
|
6712
|
+
logicalParagraphIndex,
|
|
6713
|
+
orderedChildren
|
|
6714
|
+
)
|
|
6715
|
+
);
|
|
6716
|
+
logicalParagraphIndex++;
|
|
6717
|
+
});
|
|
6718
|
+
const rawSidecars = collectUnknownSidecars(txBody, KNOWN_TXBODY_CHILDREN, nextId);
|
|
6728
6719
|
return {
|
|
6729
|
-
|
|
6730
|
-
...
|
|
6731
|
-
...
|
|
6732
|
-
|
|
6733
|
-
...
|
|
6734
|
-
...lineJoin !== void 0 ? { lineJoin } : {},
|
|
6735
|
-
...headEnd !== void 0 ? { headEnd } : {},
|
|
6736
|
-
...tailEnd !== void 0 ? { tailEnd } : {}
|
|
6720
|
+
paragraphs,
|
|
6721
|
+
...properties !== void 0 ? { properties } : {},
|
|
6722
|
+
...listStyle !== void 0 ? { listStyle } : {},
|
|
6723
|
+
handle: { partPath },
|
|
6724
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
6737
6725
|
};
|
|
6738
6726
|
}
|
|
6739
|
-
function
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
const
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
const height = numericAttr(ext, "cy");
|
|
6748
|
-
if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
|
|
6727
|
+
function parseTextStyle(node) {
|
|
6728
|
+
if (node === void 0) return void 0;
|
|
6729
|
+
const defaultParagraph = parseParagraphProperties(getChild(node, "defPPr"));
|
|
6730
|
+
const levels = Array.from(
|
|
6731
|
+
{ length: 9 },
|
|
6732
|
+
(_, index) => parseParagraphProperties(getChild(node, `lvl${index + 1}pPr`))
|
|
6733
|
+
);
|
|
6734
|
+
if (defaultParagraph === void 0 && levels.every((level) => level === void 0)) {
|
|
6749
6735
|
return void 0;
|
|
6750
6736
|
}
|
|
6751
|
-
|
|
6752
|
-
const flipH = getAttr(xfrm, "flipH");
|
|
6753
|
-
const flipV = getAttr(xfrm, "flipV");
|
|
6754
|
-
return {
|
|
6755
|
-
offsetX: asEmu2(offsetX),
|
|
6756
|
-
offsetY: asEmu2(offsetY),
|
|
6757
|
-
width: asEmu2(width),
|
|
6758
|
-
height: asEmu2(height),
|
|
6759
|
-
...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
|
|
6760
|
-
...isTrue(flipH) ? { flipHorizontal: true } : {},
|
|
6761
|
-
...isTrue(flipV) ? { flipVertical: true } : {}
|
|
6762
|
-
};
|
|
6737
|
+
return { ...defaultParagraph !== void 0 ? { defaultParagraph } : {}, levels };
|
|
6763
6738
|
}
|
|
6764
|
-
function
|
|
6765
|
-
const
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
|
|
6775
|
-
if (raw === void 0) continue;
|
|
6776
|
-
const numeric = Number(raw);
|
|
6777
|
-
if (!Number.isFinite(numeric)) continue;
|
|
6778
|
-
transforms.push({
|
|
6779
|
-
kind: transformKind,
|
|
6780
|
-
value: asOoxmlPercent(numeric)
|
|
6781
|
-
});
|
|
6739
|
+
function hasMultipleBulletPPr(p, orderedChildren) {
|
|
6740
|
+
const pPrList = getChildArray(p, "pPr");
|
|
6741
|
+
let bulletPPrCount = 0;
|
|
6742
|
+
let pPrCounter = 0;
|
|
6743
|
+
for (const child of orderedChildren) {
|
|
6744
|
+
if (orderedLocalName(child) !== "pPr") continue;
|
|
6745
|
+
const pPr = pPrList[pPrCounter];
|
|
6746
|
+
if (pPr !== void 0 && (getChild(pPr, "buChar") !== void 0 || getChild(pPr, "buAutoNum") !== void 0)) {
|
|
6747
|
+
bulletPPrCount++;
|
|
6748
|
+
if (bulletPPrCount >= 2) return true;
|
|
6782
6749
|
}
|
|
6750
|
+
pPrCounter++;
|
|
6783
6751
|
}
|
|
6784
|
-
return
|
|
6785
|
-
}
|
|
6786
|
-
function numericAttr(node, name) {
|
|
6787
|
-
const raw = getAttr(node, name);
|
|
6788
|
-
if (raw === void 0) return void 0;
|
|
6789
|
-
const value = Number(raw);
|
|
6790
|
-
return Number.isFinite(value) ? value : void 0;
|
|
6791
|
-
}
|
|
6792
|
-
function isTrue(value) {
|
|
6793
|
-
return value === "1" || value === "true";
|
|
6794
|
-
}
|
|
6795
|
-
function parseDashStyle(prstDash) {
|
|
6796
|
-
const value = getAttr(prstDash, "val");
|
|
6797
|
-
return parseEnumValue(value, DASH_STYLES);
|
|
6798
|
-
}
|
|
6799
|
-
function parseCustomDash(ln) {
|
|
6800
|
-
const custDash = getChild(ln, "custDash");
|
|
6801
|
-
const segments = getChildArray(custDash, "ds");
|
|
6802
|
-
if (segments.length === 0) return void 0;
|
|
6803
|
-
return segments.flatMap((segment) => [
|
|
6804
|
-
(numericAttr(segment, "d") ?? 1e5) / 1e5,
|
|
6805
|
-
(numericAttr(segment, "sp") ?? 1e5) / 1e5
|
|
6806
|
-
]);
|
|
6807
|
-
}
|
|
6808
|
-
var LINE_CAP_MAP = {
|
|
6809
|
-
flat: "butt",
|
|
6810
|
-
sq: "square",
|
|
6811
|
-
rnd: "round"
|
|
6812
|
-
};
|
|
6813
|
-
function parseLineCap(value) {
|
|
6814
|
-
return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
|
|
6815
|
-
}
|
|
6816
|
-
function parseLineJoin(ln) {
|
|
6817
|
-
if (hasChild(ln, "round")) return "round";
|
|
6818
|
-
if (hasChild(ln, "bevel")) return "bevel";
|
|
6819
|
-
if (hasChild(ln, "miter")) return "miter";
|
|
6820
|
-
return void 0;
|
|
6821
|
-
}
|
|
6822
|
-
function parseArrowEndpoint(node) {
|
|
6823
|
-
if (!node) return void 0;
|
|
6824
|
-
const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES2);
|
|
6825
|
-
if (type === void 0) return void 0;
|
|
6826
|
-
const width = getAttr(node, "w") ?? "med";
|
|
6827
|
-
const length = getAttr(node, "len") ?? "med";
|
|
6828
|
-
return {
|
|
6829
|
-
type,
|
|
6830
|
-
width: parseEnumValueWithDefault(width, ARROW_SIZES2, "med"),
|
|
6831
|
-
length: parseEnumValueWithDefault(length, ARROW_SIZES2, "med")
|
|
6832
|
-
};
|
|
6833
|
-
}
|
|
6834
|
-
var DASH_STYLES = /* @__PURE__ */ new Set([
|
|
6835
|
-
"solid",
|
|
6836
|
-
"dash",
|
|
6837
|
-
"dot",
|
|
6838
|
-
"dashDot",
|
|
6839
|
-
"lgDash",
|
|
6840
|
-
"lgDashDot",
|
|
6841
|
-
"sysDash",
|
|
6842
|
-
"sysDot"
|
|
6843
|
-
]);
|
|
6844
|
-
var ARROW_TYPES2 = /* @__PURE__ */ new Set([
|
|
6845
|
-
"triangle",
|
|
6846
|
-
"stealth",
|
|
6847
|
-
"diamond",
|
|
6848
|
-
"oval",
|
|
6849
|
-
"arrow"
|
|
6850
|
-
]);
|
|
6851
|
-
var ARROW_SIZES2 = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
|
|
6852
|
-
function parseCustomGeometry(custGeom, orderedCustGeom) {
|
|
6853
|
-
const pathLst = getChild(custGeom, "pathLst");
|
|
6854
|
-
const paths = getChildArray(pathLst, "path");
|
|
6855
|
-
if (paths.length === 0) return void 0;
|
|
6856
|
-
const avGuides = parseGuideList(getChild(custGeom, "avLst"));
|
|
6857
|
-
const guides = parseGuideList(getChild(custGeom, "gdLst"));
|
|
6858
|
-
const orderedPaths = orderedChildEntries(
|
|
6859
|
-
orderedChildChildren(orderedCustGeom, "pathLst"),
|
|
6860
|
-
"path"
|
|
6861
|
-
);
|
|
6862
|
-
const result = [];
|
|
6863
|
-
for (const [index, path] of paths.entries()) {
|
|
6864
|
-
const width = numericAttr2(path, "w") ?? 0;
|
|
6865
|
-
const height = numericAttr2(path, "h") ?? 0;
|
|
6866
|
-
if (width === 0 && height === 0) continue;
|
|
6867
|
-
const variables = evaluateGuides(avGuides, guides, width, height);
|
|
6868
|
-
const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
|
|
6869
|
-
if (commands !== void 0) result.push({ width, height, commands });
|
|
6870
|
-
}
|
|
6871
|
-
return result.length > 0 ? result : void 0;
|
|
6872
|
-
}
|
|
6873
|
-
function parseGuideList(parent) {
|
|
6874
|
-
return getChildArray(parent, "gd").map((guide) => ({
|
|
6875
|
-
name: getAttr(guide, "name") ?? "",
|
|
6876
|
-
formula: getAttr(guide, "fmla") ?? ""
|
|
6877
|
-
})).filter((guide) => guide.name !== "" && guide.formula !== "");
|
|
6878
|
-
}
|
|
6879
|
-
function buildPathCommands(path, variables, orderedCommands) {
|
|
6880
|
-
const parts = [];
|
|
6881
|
-
let currentX = 0;
|
|
6882
|
-
let currentY = 0;
|
|
6883
|
-
let startX = 0;
|
|
6884
|
-
let startY = 0;
|
|
6885
|
-
for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
|
|
6886
|
-
for (const node of nodes) {
|
|
6887
|
-
if (local === "moveTo") {
|
|
6888
|
-
const point = firstPoint(node, variables);
|
|
6889
|
-
if (point !== void 0) {
|
|
6890
|
-
parts.push(`M ${point.x} ${point.y}`);
|
|
6891
|
-
currentX = point.x;
|
|
6892
|
-
currentY = point.y;
|
|
6893
|
-
startX = point.x;
|
|
6894
|
-
startY = point.y;
|
|
6895
|
-
}
|
|
6896
|
-
} else if (local === "lnTo") {
|
|
6897
|
-
const point = firstPoint(node, variables);
|
|
6898
|
-
if (point !== void 0) {
|
|
6899
|
-
parts.push(`L ${point.x} ${point.y}`);
|
|
6900
|
-
currentX = point.x;
|
|
6901
|
-
currentY = point.y;
|
|
6902
|
-
}
|
|
6903
|
-
} else if (local === "cubicBezTo") {
|
|
6904
|
-
const points = allPoints(node, variables);
|
|
6905
|
-
if (points.length >= 3) {
|
|
6906
|
-
parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
|
|
6907
|
-
currentX = points[points.length - 1].x;
|
|
6908
|
-
currentY = points[points.length - 1].y;
|
|
6909
|
-
}
|
|
6910
|
-
} else if (local === "quadBezTo") {
|
|
6911
|
-
const points = allPoints(node, variables);
|
|
6912
|
-
if (points.length >= 2) {
|
|
6913
|
-
parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
|
|
6914
|
-
currentX = points[points.length - 1].x;
|
|
6915
|
-
currentY = points[points.length - 1].y;
|
|
6916
|
-
}
|
|
6917
|
-
} else if (local === "arcTo") {
|
|
6918
|
-
const arc = convertArcTo(node, currentX, currentY, variables);
|
|
6919
|
-
if (arc !== void 0) {
|
|
6920
|
-
parts.push(arc.command);
|
|
6921
|
-
currentX = arc.endX;
|
|
6922
|
-
currentY = arc.endY;
|
|
6923
|
-
}
|
|
6924
|
-
} else if (local === "close") {
|
|
6925
|
-
parts.push("Z");
|
|
6926
|
-
currentX = startX;
|
|
6927
|
-
currentY = startY;
|
|
6928
|
-
}
|
|
6929
|
-
}
|
|
6930
|
-
}
|
|
6931
|
-
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
6932
|
-
}
|
|
6933
|
-
function pathCommandNodes(path, orderedCommands) {
|
|
6934
|
-
if (orderedCommands === void 0) {
|
|
6935
|
-
return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
|
|
6936
|
-
}
|
|
6937
|
-
const counters = {};
|
|
6938
|
-
const result = [];
|
|
6939
|
-
for (const command of orderedCommands) {
|
|
6940
|
-
const key = orderedNodeKey(command);
|
|
6941
|
-
if (key === void 0) continue;
|
|
6942
|
-
const local = localName(key);
|
|
6943
|
-
const index = counters[local] ?? 0;
|
|
6944
|
-
counters[local] = index + 1;
|
|
6945
|
-
const node = getChildArray(path, local)[index];
|
|
6946
|
-
if (node !== void 0) result.push({ local, nodes: [node] });
|
|
6947
|
-
}
|
|
6948
|
-
return result;
|
|
6949
|
-
}
|
|
6950
|
-
function firstPoint(node, variables) {
|
|
6951
|
-
return allPoints(node, variables)[0];
|
|
6952
|
-
}
|
|
6953
|
-
function allPoints(node, variables) {
|
|
6954
|
-
return getChildArray(node, "pt").map((point) => ({
|
|
6955
|
-
x: resolveValue(getAttr(point, "x") ?? "0", variables),
|
|
6956
|
-
y: resolveValue(getAttr(point, "y") ?? "0", variables)
|
|
6957
|
-
}));
|
|
6958
|
-
}
|
|
6959
|
-
function convertArcTo(arc, currentX, currentY, variables) {
|
|
6960
|
-
const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
|
|
6961
|
-
const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
|
|
6962
|
-
const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
|
|
6963
|
-
const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
|
|
6964
|
-
if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
|
|
6965
|
-
const startRadians = startAngle / 6e4 * (Math.PI / 180);
|
|
6966
|
-
const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
|
|
6967
|
-
const centerX = currentX - widthRadius * Math.cos(startRadians);
|
|
6968
|
-
const centerY = currentY - heightRadius * Math.sin(startRadians);
|
|
6969
|
-
const endX = centerX + widthRadius * Math.cos(endRadians);
|
|
6970
|
-
const endY = centerY + heightRadius * Math.sin(endRadians);
|
|
6971
|
-
const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
|
|
6972
|
-
const sweepFlag = sweepAngle > 0 ? 1 : 0;
|
|
6973
|
-
return {
|
|
6974
|
-
command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
|
|
6975
|
-
endX,
|
|
6976
|
-
endY
|
|
6977
|
-
};
|
|
6978
|
-
}
|
|
6979
|
-
function evaluateGuides(avGuides, guides, width, height) {
|
|
6980
|
-
const variables = createBuiltinVariables(width, height);
|
|
6981
|
-
for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
|
|
6982
|
-
for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
|
|
6983
|
-
return variables;
|
|
6984
|
-
}
|
|
6985
|
-
function createBuiltinVariables(width, height) {
|
|
6986
|
-
return {
|
|
6987
|
-
w: width,
|
|
6988
|
-
h: height,
|
|
6989
|
-
l: 0,
|
|
6990
|
-
t: 0,
|
|
6991
|
-
r: width,
|
|
6992
|
-
b: height,
|
|
6993
|
-
wd2: width / 2,
|
|
6994
|
-
hd2: height / 2,
|
|
6995
|
-
wd4: width / 4,
|
|
6996
|
-
hd4: height / 4,
|
|
6997
|
-
ss: Math.min(width, height),
|
|
6998
|
-
ls: Math.max(width, height),
|
|
6999
|
-
cd2: 108e5,
|
|
7000
|
-
cd4: 54e5,
|
|
7001
|
-
cd8: 27e5,
|
|
7002
|
-
"3cd4": 162e5
|
|
7003
|
-
};
|
|
7004
|
-
}
|
|
7005
|
-
function evaluateFormula(formula, variables) {
|
|
7006
|
-
const tokens = formula.trim().split(/\s+/);
|
|
7007
|
-
const op = tokens[0];
|
|
7008
|
-
const resolve = (token) => {
|
|
7009
|
-
if (token === void 0) return 0;
|
|
7010
|
-
const value = Number(token);
|
|
7011
|
-
return Number.isNaN(value) ? variables[token] ?? 0 : value;
|
|
7012
|
-
};
|
|
7013
|
-
if (op === "val") return resolve(tokens[1]);
|
|
7014
|
-
if (op === "+-") return resolve(tokens[1]) + resolve(tokens[2]) - resolve(tokens[3]);
|
|
7015
|
-
if (op === "*/")
|
|
7016
|
-
return Math.round(resolve(tokens[1]) * resolve(tokens[2]) / (resolve(tokens[3]) || 1));
|
|
7017
|
-
if (op === "+/")
|
|
7018
|
-
return Math.round((resolve(tokens[1]) + resolve(tokens[2])) / (resolve(tokens[3]) || 1));
|
|
7019
|
-
if (op === "pin")
|
|
7020
|
-
return Math.max(resolve(tokens[1]), Math.min(resolve(tokens[2]), resolve(tokens[3])));
|
|
7021
|
-
if (op === "min") return Math.min(resolve(tokens[1]), resolve(tokens[2]));
|
|
7022
|
-
if (op === "max") return Math.max(resolve(tokens[1]), resolve(tokens[2]));
|
|
7023
|
-
if (op === "abs") return Math.abs(resolve(tokens[1]));
|
|
7024
|
-
if (op === "sqrt") return Math.round(Math.sqrt(resolve(tokens[1])));
|
|
7025
|
-
if (op === "sin") return Math.round(resolve(tokens[1]) * Math.sin(toRadians(resolve(tokens[2]))));
|
|
7026
|
-
if (op === "cos") return Math.round(resolve(tokens[1]) * Math.cos(toRadians(resolve(tokens[2]))));
|
|
7027
|
-
if (op === "tan") return Math.round(resolve(tokens[1]) * Math.tan(toRadians(resolve(tokens[2]))));
|
|
7028
|
-
if (op === "at2")
|
|
7029
|
-
return Math.round(Math.atan2(resolve(tokens[2]), resolve(tokens[1])) * (180 / Math.PI) * 6e4);
|
|
7030
|
-
if (op === "mod") {
|
|
7031
|
-
const a = resolve(tokens[1]);
|
|
7032
|
-
const b = resolve(tokens[2]);
|
|
7033
|
-
const c = resolve(tokens[3]);
|
|
7034
|
-
return Math.round(Math.sqrt(a * a + b * b + c * c));
|
|
7035
|
-
}
|
|
7036
|
-
if (op === "cat2") {
|
|
7037
|
-
return Math.round(
|
|
7038
|
-
resolve(tokens[1]) * Math.cos(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
|
|
7039
|
-
);
|
|
7040
|
-
}
|
|
7041
|
-
if (op === "sat2") {
|
|
7042
|
-
return Math.round(
|
|
7043
|
-
resolve(tokens[1]) * Math.sin(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
|
|
7044
|
-
);
|
|
7045
|
-
}
|
|
7046
|
-
if (op === "?:") return resolve(tokens[1]) > 0 ? resolve(tokens[2]) : resolve(tokens[3]);
|
|
7047
|
-
return 0;
|
|
7048
|
-
}
|
|
7049
|
-
function resolveValue(value, variables) {
|
|
7050
|
-
const numeric = Number(value);
|
|
7051
|
-
return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
|
|
7052
|
-
}
|
|
7053
|
-
function numericAttr2(node, name) {
|
|
7054
|
-
const raw = getAttr(node, name);
|
|
7055
|
-
if (raw === void 0) return void 0;
|
|
7056
|
-
const value = Number(raw);
|
|
7057
|
-
return Number.isFinite(value) ? value : void 0;
|
|
7058
|
-
}
|
|
7059
|
-
function round4(value) {
|
|
7060
|
-
return Math.round(value * 1e3) / 1e3;
|
|
7061
|
-
}
|
|
7062
|
-
function toRadians(ooxmlAngle) {
|
|
7063
|
-
return ooxmlAngle / 6e4 * (Math.PI / 180);
|
|
7064
|
-
}
|
|
7065
|
-
function orderedChildChildren(parent, childLocalName) {
|
|
7066
|
-
const child = orderedChildEntries(parent, childLocalName)[0];
|
|
7067
|
-
return orderedNodeChildren(child);
|
|
7068
|
-
}
|
|
7069
|
-
function orderedChildEntries(parent, childLocalName) {
|
|
7070
|
-
if (parent === void 0) return [];
|
|
7071
|
-
return parent.filter((child) => {
|
|
7072
|
-
const key = orderedNodeKey(child);
|
|
7073
|
-
return key !== void 0 && localName(key) === childLocalName;
|
|
7074
|
-
});
|
|
7075
|
-
}
|
|
7076
|
-
function orderedNodeChildren(node) {
|
|
7077
|
-
const key = node !== void 0 ? orderedNodeKey(node) : void 0;
|
|
7078
|
-
const value = key !== void 0 ? node?.[key] : void 0;
|
|
7079
|
-
return Array.isArray(value) ? value : void 0;
|
|
7080
|
-
}
|
|
7081
|
-
function orderedNodeKey(node) {
|
|
7082
|
-
return Object.keys(node).find((key) => key !== ":@");
|
|
7083
|
-
}
|
|
7084
|
-
var KNOWN_TXBODY_CHILDREN = /* @__PURE__ */ new Set(["bodyPr", "lstStyle", "p"]);
|
|
7085
|
-
var KNOWN_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
|
|
7086
|
-
"pPr",
|
|
7087
|
-
"r",
|
|
7088
|
-
"fld",
|
|
7089
|
-
"br",
|
|
7090
|
-
"endParaRPr"
|
|
7091
|
-
]);
|
|
7092
|
-
var KNOWN_RUN_CHILDREN = /* @__PURE__ */ new Set(["rPr", "t"]);
|
|
7093
|
-
var KNOWN_RUN_PROPERTY_CHILDREN = /* @__PURE__ */ new Set([
|
|
7094
|
-
"latin",
|
|
7095
|
-
"ea",
|
|
7096
|
-
"cs",
|
|
7097
|
-
"solidFill"
|
|
7098
|
-
]);
|
|
7099
|
-
var ALIGN_MAP = {
|
|
7100
|
-
l: "left",
|
|
7101
|
-
ctr: "center",
|
|
7102
|
-
r: "right",
|
|
7103
|
-
just: "justify"
|
|
7104
|
-
};
|
|
7105
|
-
var ANCHOR_MAP = {
|
|
7106
|
-
t: "top",
|
|
7107
|
-
ctr: "middle",
|
|
7108
|
-
b: "bottom"
|
|
7109
|
-
};
|
|
7110
|
-
var WRAP_VALUES = /* @__PURE__ */ new Set(["square", "none"]);
|
|
7111
|
-
var VERTICAL_VALUES = /* @__PURE__ */ new Set([
|
|
7112
|
-
"horz",
|
|
7113
|
-
"vert",
|
|
7114
|
-
"vert270",
|
|
7115
|
-
"eaVert",
|
|
7116
|
-
"wordArtVert",
|
|
7117
|
-
"mongolianVert"
|
|
7118
|
-
]);
|
|
7119
|
-
var VALID_AUTO_NUM_SCHEMES = /* @__PURE__ */ new Set([
|
|
7120
|
-
"arabicPeriod",
|
|
7121
|
-
"arabicParenR",
|
|
7122
|
-
"romanUcPeriod",
|
|
7123
|
-
"romanLcPeriod",
|
|
7124
|
-
"alphaUcPeriod",
|
|
7125
|
-
"alphaLcPeriod",
|
|
7126
|
-
"alphaLcParenR",
|
|
7127
|
-
"alphaUcParenR",
|
|
7128
|
-
"arabicPlain"
|
|
7129
|
-
]);
|
|
7130
|
-
function parseTextBody(txBody, partPath, nextId, ownerNodeId, ownerOrderingSlot, orderedTxBody) {
|
|
7131
|
-
if (!txBody) return void 0;
|
|
7132
|
-
const properties = parseBodyProperties(getChild(txBody, "bodyPr"));
|
|
7133
|
-
const listStyle = parseTextStyle(getChild(txBody, "lstStyle"));
|
|
7134
|
-
const orderedParagraphs = orderedTxBody?.filter((child) => orderedLocalName(child) === "p").map((child) => {
|
|
7135
|
-
const key = orderedKey(child);
|
|
7136
|
-
const value = key !== void 0 ? child[key] : void 0;
|
|
7137
|
-
return Array.isArray(value) ? value : void 0;
|
|
7138
|
-
});
|
|
7139
|
-
const paragraphs = [];
|
|
7140
|
-
let logicalParagraphIndex = 0;
|
|
7141
|
-
getChildArray(txBody, "p").forEach((p, paragraphIndex) => {
|
|
7142
|
-
const orderedChildren = orderedParagraphs?.[paragraphIndex];
|
|
7143
|
-
if (orderedChildren !== void 0 && hasMultipleBulletPPr(p, orderedChildren)) {
|
|
7144
|
-
const split = splitInterleavedParagraph(
|
|
7145
|
-
p,
|
|
7146
|
-
orderedChildren,
|
|
7147
|
-
partPath,
|
|
7148
|
-
nextId,
|
|
7149
|
-
ownerNodeId,
|
|
7150
|
-
ownerOrderingSlot,
|
|
7151
|
-
logicalParagraphIndex
|
|
7152
|
-
);
|
|
7153
|
-
paragraphs.push(...split);
|
|
7154
|
-
logicalParagraphIndex += split.length;
|
|
7155
|
-
return;
|
|
7156
|
-
}
|
|
7157
|
-
paragraphs.push(
|
|
7158
|
-
parseParagraph(
|
|
7159
|
-
p,
|
|
7160
|
-
partPath,
|
|
7161
|
-
nextId,
|
|
7162
|
-
ownerNodeId,
|
|
7163
|
-
ownerOrderingSlot,
|
|
7164
|
-
logicalParagraphIndex,
|
|
7165
|
-
orderedChildren
|
|
7166
|
-
)
|
|
7167
|
-
);
|
|
7168
|
-
logicalParagraphIndex++;
|
|
7169
|
-
});
|
|
7170
|
-
const rawSidecars = collectUnknownSidecars(txBody, KNOWN_TXBODY_CHILDREN, nextId);
|
|
7171
|
-
return {
|
|
7172
|
-
paragraphs,
|
|
7173
|
-
...properties !== void 0 ? { properties } : {},
|
|
7174
|
-
...listStyle !== void 0 ? { listStyle } : {},
|
|
7175
|
-
handle: { partPath },
|
|
7176
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7177
|
-
};
|
|
7178
|
-
}
|
|
7179
|
-
function parseTextStyle(node) {
|
|
7180
|
-
if (node === void 0) return void 0;
|
|
7181
|
-
const defaultParagraph = parseParagraphProperties(getChild(node, "defPPr"));
|
|
7182
|
-
const levels = Array.from(
|
|
7183
|
-
{ length: 9 },
|
|
7184
|
-
(_, index) => parseParagraphProperties(getChild(node, `lvl${index + 1}pPr`))
|
|
7185
|
-
);
|
|
7186
|
-
if (defaultParagraph === void 0 && levels.every((level) => level === void 0)) {
|
|
7187
|
-
return void 0;
|
|
7188
|
-
}
|
|
7189
|
-
return { ...defaultParagraph !== void 0 ? { defaultParagraph } : {}, levels };
|
|
7190
|
-
}
|
|
7191
|
-
function hasMultipleBulletPPr(p, orderedChildren) {
|
|
7192
|
-
const pPrList = getChildArray(p, "pPr");
|
|
7193
|
-
let bulletPPrCount = 0;
|
|
7194
|
-
let pPrCounter = 0;
|
|
7195
|
-
for (const child of orderedChildren) {
|
|
7196
|
-
if (orderedLocalName(child) !== "pPr") continue;
|
|
7197
|
-
const pPr = pPrList[pPrCounter];
|
|
7198
|
-
if (pPr !== void 0 && (getChild(pPr, "buChar") !== void 0 || getChild(pPr, "buAutoNum") !== void 0)) {
|
|
7199
|
-
bulletPPrCount++;
|
|
7200
|
-
if (bulletPPrCount >= 2) return true;
|
|
7201
|
-
}
|
|
7202
|
-
pPrCounter++;
|
|
7203
|
-
}
|
|
7204
|
-
return false;
|
|
6752
|
+
return false;
|
|
7205
6753
|
}
|
|
7206
6754
|
function splitInterleavedParagraph(p, orderedChildren, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex) {
|
|
7207
6755
|
const pPrList = getChildArray(p, "pPr");
|
|
@@ -7302,20 +6850,20 @@ function splitInterleavedParagraph(p, orderedChildren, partPath, nextId, ownerNo
|
|
|
7302
6850
|
}
|
|
7303
6851
|
function parseBodyProperties(bodyPr) {
|
|
7304
6852
|
if (!bodyPr) return void 0;
|
|
7305
|
-
const marginLeft =
|
|
7306
|
-
const marginRight =
|
|
7307
|
-
const marginTop =
|
|
7308
|
-
const marginBottom =
|
|
6853
|
+
const marginLeft = numericAttr2(bodyPr, "lIns");
|
|
6854
|
+
const marginRight = numericAttr2(bodyPr, "rIns");
|
|
6855
|
+
const marginTop = numericAttr2(bodyPr, "tIns");
|
|
6856
|
+
const marginBottom = numericAttr2(bodyPr, "bIns");
|
|
7309
6857
|
const anchorToken = getAttr(bodyPr, "anchor");
|
|
7310
6858
|
const anchor = anchorToken !== void 0 ? ANCHOR_MAP[anchorToken] : void 0;
|
|
7311
6859
|
const wrap = parseWrap(getAttr(bodyPr, "wrap"));
|
|
7312
6860
|
const vert = parseVerticalType(getAttr(bodyPr, "vert"));
|
|
7313
|
-
const numCol =
|
|
6861
|
+
const numCol = numericAttr2(bodyPr, "numCol");
|
|
7314
6862
|
const normAutofit = getChild(bodyPr, "normAutofit");
|
|
7315
6863
|
const hasSpAutofit = getChild(bodyPr, "spAutoFit") !== void 0;
|
|
7316
6864
|
const hasNoAutofit = getChild(bodyPr, "noAutofit") !== void 0;
|
|
7317
|
-
const fontScale =
|
|
7318
|
-
const lnSpcReduction =
|
|
6865
|
+
const fontScale = numericAttr2(normAutofit, "fontScale");
|
|
6866
|
+
const lnSpcReduction = numericAttr2(normAutofit, "lnSpcReduction");
|
|
7319
6867
|
const properties = {
|
|
7320
6868
|
...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
|
|
7321
6869
|
...marginRight !== void 0 ? { marginRight: emu(marginRight) } : {},
|
|
@@ -7447,16 +6995,16 @@ function parseParagraphProperties(pPr) {
|
|
|
7447
6995
|
if (!pPr) return void 0;
|
|
7448
6996
|
const alignToken = getAttr(pPr, "algn");
|
|
7449
6997
|
const align = alignToken !== void 0 ? ALIGN_MAP[alignToken] : void 0;
|
|
7450
|
-
const level =
|
|
6998
|
+
const level = numericAttr2(pPr, "lvl");
|
|
7451
6999
|
const lineSpacing = parseSpacing(getChild(pPr, "lnSpc"));
|
|
7452
7000
|
const spaceBefore = parseSpacing(getChild(pPr, "spcBef"));
|
|
7453
7001
|
const spaceAfter = parseSpacing(getChild(pPr, "spcAft"));
|
|
7454
|
-
const marginLeft =
|
|
7455
|
-
const indent =
|
|
7002
|
+
const marginLeft = numericAttr2(pPr, "marL");
|
|
7003
|
+
const indent = numericAttr2(pPr, "indent");
|
|
7456
7004
|
const bullet = parseBullet(pPr);
|
|
7457
7005
|
const bulletFont = getAttr(getChild(pPr, "buFont"), "typeface");
|
|
7458
7006
|
const bulletColor = parseColorElement(getChild(pPr, "buClr"));
|
|
7459
|
-
const bulletSizePct =
|
|
7007
|
+
const bulletSizePct = numericAttr2(getChild(pPr, "buSzPct"), "val");
|
|
7460
7008
|
const tabStops = parseTabStops(pPr);
|
|
7461
7009
|
const defaultRunProperties = parseRunProperties(getChild(pPr, "defRPr"));
|
|
7462
7010
|
const properties = {
|
|
@@ -7476,859 +7024,1344 @@ function parseParagraphProperties(pPr) {
|
|
|
7476
7024
|
};
|
|
7477
7025
|
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7478
7026
|
}
|
|
7479
|
-
function parseTabStops(pPr) {
|
|
7480
|
-
return getChildArray(getChild(pPr, "tabLst"), "tab").map((tab) => ({
|
|
7481
|
-
position: emu(
|
|
7482
|
-
alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
|
|
7483
|
-
}));
|
|
7027
|
+
function parseTabStops(pPr) {
|
|
7028
|
+
return getChildArray(getChild(pPr, "tabLst"), "tab").map((tab) => ({
|
|
7029
|
+
position: emu(numericAttr2(tab, "pos") ?? 0),
|
|
7030
|
+
alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
|
|
7031
|
+
}));
|
|
7032
|
+
}
|
|
7033
|
+
function parseSpacing(node) {
|
|
7034
|
+
const points = numericAttr2(getChild(node, "spcPts"), "val");
|
|
7035
|
+
if (points !== void 0) return { type: "pts", value: asHundredthPt2(points) };
|
|
7036
|
+
const percent = numericAttr2(getChild(node, "spcPct"), "val");
|
|
7037
|
+
if (percent !== void 0) return { type: "pct", value: percent };
|
|
7038
|
+
return void 0;
|
|
7039
|
+
}
|
|
7040
|
+
function parseBullet(pPr) {
|
|
7041
|
+
if (pPr === void 0) return void 0;
|
|
7042
|
+
if (getChild(pPr, "buNone") !== void 0) return { type: "none" };
|
|
7043
|
+
const buChar = getChild(pPr, "buChar");
|
|
7044
|
+
if (buChar !== void 0) {
|
|
7045
|
+
return { type: "char", char: decodeXmlCharRef(getAttr(buChar, "char") ?? "\u2022") };
|
|
7046
|
+
}
|
|
7047
|
+
const buAutoNum = getChild(pPr, "buAutoNum");
|
|
7048
|
+
if (buAutoNum !== void 0) {
|
|
7049
|
+
const scheme = getAttr(buAutoNum, "type") ?? "arabicPeriod";
|
|
7050
|
+
return {
|
|
7051
|
+
type: "autoNum",
|
|
7052
|
+
scheme: parseEnumValueWithDefault(scheme, VALID_AUTO_NUM_SCHEMES, "arabicPeriod"),
|
|
7053
|
+
startAt: numericAttr2(buAutoNum, "startAt") ?? 1
|
|
7054
|
+
};
|
|
7055
|
+
}
|
|
7056
|
+
return void 0;
|
|
7057
|
+
}
|
|
7058
|
+
function decodeXmlCharRef(value) {
|
|
7059
|
+
return value.replace(
|
|
7060
|
+
/&#x([0-9a-fA-F]+);|&#([0-9]+);/g,
|
|
7061
|
+
(_match, hex, decimal) => String.fromCodePoint(parseInt(hex ?? decimal ?? "0", hex !== void 0 ? 16 : 10))
|
|
7062
|
+
);
|
|
7063
|
+
}
|
|
7064
|
+
function parseRun(r, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7065
|
+
const properties = parseRunProperties(getChild(r, "rPr"));
|
|
7066
|
+
const rawSidecars = collectRunSidecars(r, nextId);
|
|
7067
|
+
return {
|
|
7068
|
+
kind: "textRun",
|
|
7069
|
+
text: decodeXmlCharRef(getChildText(r, "t") ?? ""),
|
|
7070
|
+
...properties !== void 0 ? { properties } : {},
|
|
7071
|
+
handle: {
|
|
7072
|
+
partPath,
|
|
7073
|
+
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7074
|
+
orderingSlot: runIndex
|
|
7075
|
+
},
|
|
7076
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7077
|
+
};
|
|
7078
|
+
}
|
|
7079
|
+
function parseBreakRun(br, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7080
|
+
const properties = parseRunProperties(getChild(br, "rPr"));
|
|
7081
|
+
return {
|
|
7082
|
+
kind: "textRun",
|
|
7083
|
+
text: "\n",
|
|
7084
|
+
...properties !== void 0 ? { properties } : {},
|
|
7085
|
+
handle: {
|
|
7086
|
+
partPath,
|
|
7087
|
+
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7088
|
+
orderingSlot: runIndex
|
|
7089
|
+
}
|
|
7090
|
+
};
|
|
7091
|
+
}
|
|
7092
|
+
function parseRunProperties(rPr) {
|
|
7093
|
+
if (!rPr) return void 0;
|
|
7094
|
+
const bold = getAttr(rPr, "b");
|
|
7095
|
+
const italic = getAttr(rPr, "i");
|
|
7096
|
+
const underline = getAttr(rPr, "u");
|
|
7097
|
+
const strike = getAttr(rPr, "strike");
|
|
7098
|
+
const baseline = numericAttr2(rPr, "baseline");
|
|
7099
|
+
const size = numericAttr2(rPr, "sz");
|
|
7100
|
+
const typeface = getAttr(getChild(rPr, "latin"), "typeface");
|
|
7101
|
+
const typefaceEa = getAttr(getChild(rPr, "ea"), "typeface");
|
|
7102
|
+
const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
|
|
7103
|
+
const hasHyperlink = getChild(rPr, "hlinkClick") !== void 0;
|
|
7104
|
+
const color = parseColorElement(getChild(rPr, "solidFill"));
|
|
7105
|
+
const properties = {
|
|
7106
|
+
...bold !== void 0 ? { bold: isTrue(bold) } : {},
|
|
7107
|
+
...italic !== void 0 ? { italic: isTrue(italic) } : {},
|
|
7108
|
+
...underline !== void 0 ? { underline: underline !== "none" } : hasHyperlink ? { underline: true } : {},
|
|
7109
|
+
...strike !== void 0 ? { strikethrough: strike !== "noStrike" } : {},
|
|
7110
|
+
...baseline !== void 0 ? { baseline: baseline / 1e3 } : {},
|
|
7111
|
+
// `a:rPr@sz` is in 1/100 pt unit. Convert to pt and save.
|
|
7112
|
+
...size !== void 0 ? { fontSize: asPt(size / 100) } : {},
|
|
7113
|
+
...typeface !== void 0 ? { typeface } : {},
|
|
7114
|
+
...typefaceEa !== void 0 ? { typefaceEa } : {},
|
|
7115
|
+
...typefaceCs !== void 0 ? { typefaceCs } : {},
|
|
7116
|
+
...color !== void 0 ? { color } : hasHyperlink ? { color: { kind: "scheme", scheme: "hlink" } } : {}
|
|
7117
|
+
};
|
|
7118
|
+
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7119
|
+
}
|
|
7120
|
+
function collectRunSidecars(r, nextId) {
|
|
7121
|
+
const runLevel = collectUnknownSidecars(r, KNOWN_RUN_CHILDREN, nextId);
|
|
7122
|
+
const propLevel = collectUnknownSidecars(getChild(r, "rPr"), KNOWN_RUN_PROPERTY_CHILDREN, nextId);
|
|
7123
|
+
return [...runLevel, ...propLevel];
|
|
7484
7124
|
}
|
|
7485
|
-
function
|
|
7486
|
-
|
|
7487
|
-
if (points !== void 0) return { type: "pts", value: asHundredthPt2(points) };
|
|
7488
|
-
const percent = numericAttr(getChild(node, "spcPct"), "val");
|
|
7489
|
-
if (percent !== void 0) return { type: "pct", value: percent };
|
|
7490
|
-
return void 0;
|
|
7125
|
+
function emu(value) {
|
|
7126
|
+
return asEmu2(value);
|
|
7491
7127
|
}
|
|
7492
|
-
function
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7128
|
+
function textNodeId(kind, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7129
|
+
const owner = ownerNodeId !== void 0 ? `shape:${ownerNodeId}` : `shapeSlot:${ownerOrderingSlot}`;
|
|
7130
|
+
const suffix = kind === "paragraph" ? `p:${paragraphIndex}` : `p:${paragraphIndex}:r:${runIndex}`;
|
|
7131
|
+
return asSourceNodeId(`text:${owner}:${suffix}`);
|
|
7132
|
+
}
|
|
7133
|
+
function orderedKey(node) {
|
|
7134
|
+
return Object.keys(node).find((key) => key !== ":@");
|
|
7135
|
+
}
|
|
7136
|
+
function orderedLocalName(node) {
|
|
7137
|
+
const key = orderedKey(node);
|
|
7138
|
+
return key !== void 0 ? localName(key) : void 0;
|
|
7139
|
+
}
|
|
7140
|
+
var KNOWN_SHAPE_CHILDREN = /* @__PURE__ */ new Set(["nvSpPr", "spPr", "style", "txBody"]);
|
|
7141
|
+
var KNOWN_CONNECTOR_CHILDREN = /* @__PURE__ */ new Set(["nvCxnSpPr", "spPr", "style"]);
|
|
7142
|
+
var KNOWN_GROUP_CHILDREN = /* @__PURE__ */ new Set(["nvGrpSpPr", "grpSpPr"]);
|
|
7143
|
+
var KNOWN_PICTURE_CHILDREN = /* @__PURE__ */ new Set(["nvPicPr", "blipFill", "spPr"]);
|
|
7144
|
+
var KNOWN_BLIP_FILL_CHILDREN = /* @__PURE__ */ new Set([
|
|
7145
|
+
"blip",
|
|
7146
|
+
"srcRect",
|
|
7147
|
+
"stretch",
|
|
7148
|
+
"tile"
|
|
7149
|
+
]);
|
|
7150
|
+
var KNOWN_BLIP_CHILDREN = /* @__PURE__ */ new Set([
|
|
7151
|
+
"grayscl",
|
|
7152
|
+
"biLevel",
|
|
7153
|
+
"blur",
|
|
7154
|
+
"lum",
|
|
7155
|
+
"duotone",
|
|
7156
|
+
"clrChange"
|
|
7157
|
+
]);
|
|
7158
|
+
var KNOWN_EFFECT_CHILDREN = /* @__PURE__ */ new Set([
|
|
7159
|
+
"outerShdw",
|
|
7160
|
+
"innerShdw",
|
|
7161
|
+
"glow",
|
|
7162
|
+
"softEdge"
|
|
7163
|
+
]);
|
|
7164
|
+
var KNOWN_GRAPHIC_FRAME_CHILDREN = /* @__PURE__ */ new Set([
|
|
7165
|
+
"nvGraphicFramePr",
|
|
7166
|
+
"xfrm",
|
|
7167
|
+
"graphic"
|
|
7168
|
+
]);
|
|
7169
|
+
var KNOWN_GRAPHIC_CHILDREN = /* @__PURE__ */ new Set(["graphicData"]);
|
|
7170
|
+
var KNOWN_GRAPHIC_DATA_CHILDREN = /* @__PURE__ */ new Set(["tbl"]);
|
|
7171
|
+
var KNOWN_TABLE_CHILDREN = /* @__PURE__ */ new Set(["tblPr", "tblGrid", "tr"]);
|
|
7172
|
+
var KNOWN_TABLE_CELL_CHILDREN = /* @__PURE__ */ new Set(["txBody", "tcPr"]);
|
|
7173
|
+
var KNOWN_TABLE_CELL_PROPERTIES_CHILDREN = /* @__PURE__ */ new Set([
|
|
7174
|
+
"lnL",
|
|
7175
|
+
"lnR",
|
|
7176
|
+
"lnT",
|
|
7177
|
+
"lnB",
|
|
7178
|
+
"solidFill",
|
|
7179
|
+
"noFill",
|
|
7180
|
+
"gradFill",
|
|
7181
|
+
"blipFill",
|
|
7182
|
+
"pattFill",
|
|
7183
|
+
"grpFill"
|
|
7184
|
+
]);
|
|
7185
|
+
var KNOWN_SP_PR_CHILDREN = /* @__PURE__ */ new Set([
|
|
7186
|
+
"xfrm",
|
|
7187
|
+
"prstGeom",
|
|
7188
|
+
"solidFill",
|
|
7189
|
+
"noFill",
|
|
7190
|
+
"gradFill",
|
|
7191
|
+
"blipFill",
|
|
7192
|
+
"pattFill",
|
|
7193
|
+
"grpFill",
|
|
7194
|
+
"ln",
|
|
7195
|
+
"effectLst"
|
|
7196
|
+
]);
|
|
7197
|
+
var SHAPE_TREE_NODE_TAGS = /* @__PURE__ */ new Set([
|
|
7198
|
+
"sp",
|
|
7199
|
+
"pic",
|
|
7200
|
+
"cxnSp",
|
|
7201
|
+
"grpSp",
|
|
7202
|
+
"graphicFrame"
|
|
7203
|
+
]);
|
|
7204
|
+
var CHART_GRAPHIC_DATA_URIS = /* @__PURE__ */ new Set([
|
|
7205
|
+
"http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
7206
|
+
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
7207
|
+
]);
|
|
7208
|
+
var SMARTART_DIAGRAM_URIS = /* @__PURE__ */ new Set([
|
|
7209
|
+
"http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
7210
|
+
"http://purl.oclc.org/ooxml/drawingml/diagram"
|
|
7211
|
+
]);
|
|
7212
|
+
function parseShapeTree(spTree, partPath, nextId, orderedChildren) {
|
|
7213
|
+
if (!spTree) return [];
|
|
7214
|
+
if (orderedChildren !== void 0) {
|
|
7215
|
+
return parseShapeTreeOrdered(spTree, partPath, nextId, orderedChildren);
|
|
7498
7216
|
}
|
|
7499
|
-
const
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7217
|
+
const nodes = [];
|
|
7218
|
+
let orderingSlot = 0;
|
|
7219
|
+
for (const key of Object.keys(spTree)) {
|
|
7220
|
+
if (key.startsWith("@_")) continue;
|
|
7221
|
+
if (key === "#text") continue;
|
|
7222
|
+
const local = localName(key);
|
|
7223
|
+
if (local === "nvGrpSpPr" || local === "grpSpPr") continue;
|
|
7224
|
+
const value = spTree[key];
|
|
7225
|
+
const items = Array.isArray(value) ? value : [value];
|
|
7226
|
+
for (const item of items) {
|
|
7227
|
+
const node = unsafeOoxmlBoundaryAssertion(item);
|
|
7228
|
+
if (local === "sp") {
|
|
7229
|
+
nodes.push(parseShape(node, partPath, nextId, orderingSlot));
|
|
7230
|
+
} else if (local === "pic") {
|
|
7231
|
+
nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
7232
|
+
} else if (local === "cxnSp") {
|
|
7233
|
+
nodes.push(parseConnector(node, partPath, nextId, orderingSlot));
|
|
7234
|
+
} else if (local === "grpSp") {
|
|
7235
|
+
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
7236
|
+
} else if (local === "graphicFrame") {
|
|
7237
|
+
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
7238
|
+
} else if (local === "AlternateContent") {
|
|
7239
|
+
const parsed = parseAlternateContent(node, partPath, nextId, orderingSlot);
|
|
7240
|
+
nodes.push(...parsed);
|
|
7241
|
+
} else {
|
|
7242
|
+
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
7243
|
+
}
|
|
7244
|
+
orderingSlot++;
|
|
7245
|
+
}
|
|
7507
7246
|
}
|
|
7508
|
-
return
|
|
7247
|
+
return nodes;
|
|
7509
7248
|
}
|
|
7510
|
-
function
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7249
|
+
function parseShapeTreeOrdered(spTree, partPath, nextId, orderedChildren) {
|
|
7250
|
+
const nodes = [];
|
|
7251
|
+
const tagCounters = {};
|
|
7252
|
+
let orderingSlot = 0;
|
|
7253
|
+
for (const child of orderedChildren) {
|
|
7254
|
+
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
7255
|
+
if (key === void 0) continue;
|
|
7256
|
+
const local = localName(key);
|
|
7257
|
+
if (local === "AlternateContent") {
|
|
7258
|
+
const index2 = tagCounters[local] ?? 0;
|
|
7259
|
+
tagCounters[local] = index2 + 1;
|
|
7260
|
+
const alternateContents = getChildArray(spTree, "AlternateContent");
|
|
7261
|
+
const alternateContent = alternateContents[index2];
|
|
7262
|
+
if (alternateContent !== void 0) {
|
|
7263
|
+
nodes.push(...parseAlternateContent(alternateContent, partPath, nextId, orderingSlot));
|
|
7264
|
+
orderingSlot++;
|
|
7265
|
+
}
|
|
7266
|
+
continue;
|
|
7267
|
+
}
|
|
7268
|
+
if (!SHAPE_TREE_NODE_TAGS.has(local)) continue;
|
|
7269
|
+
const index = tagCounters[local] ?? 0;
|
|
7270
|
+
tagCounters[local] = index + 1;
|
|
7271
|
+
const node = getChildArray(spTree, local)[index];
|
|
7272
|
+
if (node === void 0) continue;
|
|
7273
|
+
nodes.push(parseShapeTreeNode(local, node, child, partPath, nextId, orderingSlot));
|
|
7274
|
+
orderingSlot++;
|
|
7275
|
+
}
|
|
7276
|
+
return nodes;
|
|
7277
|
+
}
|
|
7278
|
+
function parseShapeTreeNode(local, node, orderedNode, partPath, nextId, orderingSlot) {
|
|
7279
|
+
if (local === "sp") return parseShape(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7280
|
+
if (local === "pic") return parseImage(node, partPath, nextId, orderingSlot);
|
|
7281
|
+
if (local === "cxnSp") {
|
|
7282
|
+
return parseConnector(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7283
|
+
}
|
|
7284
|
+
if (local === "grpSp") {
|
|
7285
|
+
const orderedGroupChildren = unsafeOoxmlBoundaryAssertion(orderedNode?.[local]);
|
|
7286
|
+
return parseGroup(node, partPath, nextId, orderingSlot, orderedGroupChildren);
|
|
7287
|
+
}
|
|
7288
|
+
if (local === "graphicFrame") {
|
|
7289
|
+
return parseGraphicFrame(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7290
|
+
}
|
|
7291
|
+
return parseRawShapeNode(`p:${local}`, node, partPath, nextId, orderingSlot);
|
|
7292
|
+
}
|
|
7293
|
+
function parseShape(sp, partPath, nextId, orderingSlot, orderedNode) {
|
|
7294
|
+
const nvSpPr = getChild(sp, "nvSpPr");
|
|
7295
|
+
const cNvPr = getChild(nvSpPr, "cNvPr");
|
|
7296
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7297
|
+
const name = getAttr(cNvPr, "name");
|
|
7298
|
+
const placeholder = parsePlaceholder(getChild(getChild(nvSpPr, "nvPr"), "ph"));
|
|
7299
|
+
const spPr = getChild(sp, "spPr");
|
|
7300
|
+
const transform = parseTransform(spPr);
|
|
7301
|
+
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "sp", "spPr"));
|
|
7302
|
+
const fill = parseFill(spPr, nextId);
|
|
7303
|
+
const outline = parseOutline(spPr, nextId);
|
|
7304
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7305
|
+
const style = parseShapeStyle(getChild(sp, "style"));
|
|
7306
|
+
const textBody = parseTextBody(
|
|
7307
|
+
getChild(sp, "txBody"),
|
|
7308
|
+
partPath,
|
|
7309
|
+
nextId,
|
|
7310
|
+
nodeId,
|
|
7311
|
+
orderingSlot,
|
|
7312
|
+
orderedNestedChildChildren(orderedNode, "sp", "txBody")
|
|
7514
7313
|
);
|
|
7314
|
+
const rawSidecars = [
|
|
7315
|
+
...collectUnknownSidecars(sp, KNOWN_SHAPE_CHILDREN, nextId),
|
|
7316
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7317
|
+
...collectEffectSidecars(spPr, effects, nextId)
|
|
7318
|
+
];
|
|
7319
|
+
return {
|
|
7320
|
+
kind: "shape",
|
|
7321
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7322
|
+
...name !== void 0 ? { name } : {},
|
|
7323
|
+
...transform !== void 0 ? { transform } : {},
|
|
7324
|
+
...geometry !== void 0 ? { geometry } : {},
|
|
7325
|
+
...fill !== void 0 ? { fill } : {},
|
|
7326
|
+
...outline !== void 0 ? { outline } : {},
|
|
7327
|
+
...effects !== void 0 ? { effects } : {},
|
|
7328
|
+
...style !== void 0 ? { style } : {},
|
|
7329
|
+
...textBody !== void 0 ? { textBody } : {},
|
|
7330
|
+
...placeholder !== void 0 ? { placeholder } : {},
|
|
7331
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7332
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7333
|
+
};
|
|
7515
7334
|
}
|
|
7516
|
-
function
|
|
7517
|
-
const
|
|
7518
|
-
const
|
|
7335
|
+
function parseConnector(cxnSp, partPath, nextId, orderingSlot, orderedNode) {
|
|
7336
|
+
const nvCxnSpPr = getChild(cxnSp, "nvCxnSpPr");
|
|
7337
|
+
const cNvPr = getChild(nvCxnSpPr, "cNvPr");
|
|
7338
|
+
const cNvCxnSpPr = getChild(nvCxnSpPr, "cNvCxnSpPr");
|
|
7339
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7340
|
+
const name = getAttr(cNvPr, "name");
|
|
7341
|
+
const connection = parseConnectorConnection(cNvCxnSpPr);
|
|
7342
|
+
const spPr = getChild(cxnSp, "spPr");
|
|
7343
|
+
const transform = parseTransform(spPr);
|
|
7344
|
+
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "cxnSp", "spPr"));
|
|
7345
|
+
const outline = parseOutline(spPr, nextId);
|
|
7346
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7347
|
+
const style = parseShapeStyle(getChild(cxnSp, "style"));
|
|
7348
|
+
const rawSidecars = [
|
|
7349
|
+
...collectUnknownSidecars(cxnSp, KNOWN_CONNECTOR_CHILDREN, nextId),
|
|
7350
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7351
|
+
...collectEffectSidecars(spPr, effects, nextId)
|
|
7352
|
+
];
|
|
7519
7353
|
return {
|
|
7520
|
-
kind: "
|
|
7521
|
-
|
|
7522
|
-
...
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
},
|
|
7354
|
+
kind: "connector",
|
|
7355
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7356
|
+
...name !== void 0 ? { name } : {},
|
|
7357
|
+
...connection !== void 0 ? { connection } : {},
|
|
7358
|
+
...transform !== void 0 ? { transform } : {},
|
|
7359
|
+
...geometry !== void 0 ? { geometry } : {},
|
|
7360
|
+
...outline !== void 0 ? { outline } : {},
|
|
7361
|
+
...effects !== void 0 ? { effects } : {},
|
|
7362
|
+
...style !== void 0 ? { style } : {},
|
|
7363
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7528
7364
|
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7529
7365
|
};
|
|
7530
7366
|
}
|
|
7531
|
-
function
|
|
7532
|
-
const
|
|
7367
|
+
function parseConnectorConnection(cNvCxnSpPr) {
|
|
7368
|
+
const start = parseConnectorConnectionEndpoint(getChild(cNvCxnSpPr, "stCxn"));
|
|
7369
|
+
const end = parseConnectorConnectionEndpoint(getChild(cNvCxnSpPr, "endCxn"));
|
|
7370
|
+
return start !== void 0 || end !== void 0 ? {
|
|
7371
|
+
...start !== void 0 ? { start } : {},
|
|
7372
|
+
...end !== void 0 ? { end } : {}
|
|
7373
|
+
} : void 0;
|
|
7374
|
+
}
|
|
7375
|
+
function parseConnectorConnectionEndpoint(node) {
|
|
7376
|
+
const shapeId = getAttr(node, "id");
|
|
7377
|
+
const connectionSiteIndex = numericAttr2(node, "idx");
|
|
7378
|
+
if (shapeId === void 0 || connectionSiteIndex === void 0) return void 0;
|
|
7533
7379
|
return {
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
...properties !== void 0 ? { properties } : {},
|
|
7537
|
-
handle: {
|
|
7538
|
-
partPath,
|
|
7539
|
-
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7540
|
-
orderingSlot: runIndex
|
|
7541
|
-
}
|
|
7380
|
+
shapeId: asSourceNodeId(shapeId),
|
|
7381
|
+
connectionSiteIndex
|
|
7542
7382
|
};
|
|
7543
7383
|
}
|
|
7544
|
-
function
|
|
7545
|
-
if (
|
|
7546
|
-
const
|
|
7547
|
-
const
|
|
7548
|
-
const
|
|
7549
|
-
const
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
const typefaceEa = getAttr(getChild(rPr, "ea"), "typeface");
|
|
7554
|
-
const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
|
|
7555
|
-
const hasHyperlink = getChild(rPr, "hlinkClick") !== void 0;
|
|
7556
|
-
const color = parseColorElement(getChild(rPr, "solidFill"));
|
|
7557
|
-
const properties = {
|
|
7558
|
-
...bold !== void 0 ? { bold: isTrue(bold) } : {},
|
|
7559
|
-
...italic !== void 0 ? { italic: isTrue(italic) } : {},
|
|
7560
|
-
...underline !== void 0 ? { underline: underline !== "none" } : hasHyperlink ? { underline: true } : {},
|
|
7561
|
-
...strike !== void 0 ? { strikethrough: strike !== "noStrike" } : {},
|
|
7562
|
-
...baseline !== void 0 ? { baseline: baseline / 1e3 } : {},
|
|
7563
|
-
// `a:rPr@sz` is in 1/100 pt unit. Convert to pt and save.
|
|
7564
|
-
...size !== void 0 ? { fontSize: asPt(size / 100) } : {},
|
|
7565
|
-
...typeface !== void 0 ? { typeface } : {},
|
|
7566
|
-
...typefaceEa !== void 0 ? { typefaceEa } : {},
|
|
7567
|
-
...typefaceCs !== void 0 ? { typefaceCs } : {},
|
|
7568
|
-
...color !== void 0 ? { color } : hasHyperlink ? { color: { kind: "scheme", scheme: "hlink" } } : {}
|
|
7384
|
+
function parseShapeStyle(style) {
|
|
7385
|
+
if (style === void 0) return void 0;
|
|
7386
|
+
const fillRef = parseStyleReference(getChild(style, "fillRef"));
|
|
7387
|
+
const lineRef = parseStyleReference(getChild(style, "lnRef"));
|
|
7388
|
+
const effectRef = parseStyleReference(getChild(style, "effectRef"));
|
|
7389
|
+
const parsed = {
|
|
7390
|
+
...fillRef !== void 0 ? { fillRef } : {},
|
|
7391
|
+
...lineRef !== void 0 ? { lineRef } : {},
|
|
7392
|
+
...effectRef !== void 0 ? { effectRef } : {}
|
|
7569
7393
|
};
|
|
7570
|
-
return Object.keys(
|
|
7571
|
-
}
|
|
7572
|
-
function collectRunSidecars(r, nextId) {
|
|
7573
|
-
const runLevel = collectUnknownSidecars(r, KNOWN_RUN_CHILDREN, nextId);
|
|
7574
|
-
const propLevel = collectUnknownSidecars(getChild(r, "rPr"), KNOWN_RUN_PROPERTY_CHILDREN, nextId);
|
|
7575
|
-
return [...runLevel, ...propLevel];
|
|
7576
|
-
}
|
|
7577
|
-
function emu(value) {
|
|
7578
|
-
return asEmu2(value);
|
|
7394
|
+
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
7579
7395
|
}
|
|
7580
|
-
function
|
|
7581
|
-
|
|
7582
|
-
const
|
|
7583
|
-
|
|
7396
|
+
function parseStyleReference(ref) {
|
|
7397
|
+
if (ref === void 0) return void 0;
|
|
7398
|
+
const index = numericAttr2(ref, "idx") ?? 0;
|
|
7399
|
+
const color = parseColorElement(ref);
|
|
7400
|
+
return {
|
|
7401
|
+
index,
|
|
7402
|
+
...color !== void 0 ? { color } : {}
|
|
7403
|
+
};
|
|
7584
7404
|
}
|
|
7585
|
-
function
|
|
7586
|
-
|
|
7405
|
+
function parseGroup(grpSp, partPath, nextId, orderingSlot, orderedChildren) {
|
|
7406
|
+
const nvGrpSpPr = getChild(grpSp, "nvGrpSpPr");
|
|
7407
|
+
const cNvPr = getChild(nvGrpSpPr, "cNvPr");
|
|
7408
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7409
|
+
const name = getAttr(cNvPr, "name");
|
|
7410
|
+
const grpSpPr = getChild(grpSp, "grpSpPr");
|
|
7411
|
+
const transform = parseTransform(grpSpPr);
|
|
7412
|
+
const childTransform = parseChildTransform(grpSpPr, transform);
|
|
7413
|
+
const fill = parseFill(grpSpPr, nextId);
|
|
7414
|
+
const effects = parseEffectList(getChild(grpSpPr, "effectLst"));
|
|
7415
|
+
const rawSidecars = [
|
|
7416
|
+
...collectUnknownSidecars(grpSp, KNOWN_GROUP_CHILDREN, nextId),
|
|
7417
|
+
...collectUnknownSidecars(grpSpPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7418
|
+
...collectEffectSidecars(grpSpPr, effects, nextId)
|
|
7419
|
+
];
|
|
7420
|
+
return {
|
|
7421
|
+
kind: "group",
|
|
7422
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7423
|
+
...name !== void 0 ? { name } : {},
|
|
7424
|
+
...transform !== void 0 ? { transform } : {},
|
|
7425
|
+
...childTransform !== void 0 ? { childTransform } : {},
|
|
7426
|
+
...fill !== void 0 ? { fill } : {},
|
|
7427
|
+
...effects !== void 0 ? { effects } : {},
|
|
7428
|
+
children: parseShapeTree(grpSp, partPath, nextId, orderedChildren),
|
|
7429
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7430
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7431
|
+
};
|
|
7587
7432
|
}
|
|
7588
|
-
function
|
|
7589
|
-
const
|
|
7590
|
-
|
|
7433
|
+
function parseImage(pic, partPath, nextId, orderingSlot) {
|
|
7434
|
+
const cNvPr = getChild(getChild(pic, "nvPicPr"), "cNvPr");
|
|
7435
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7436
|
+
const name = getAttr(cNvPr, "name");
|
|
7437
|
+
const blipFill = getChild(pic, "blipFill");
|
|
7438
|
+
const blip = getChild(blipFill, "blip");
|
|
7439
|
+
const embed = getNamespacedAttr(blip, "embed");
|
|
7440
|
+
const crop = parseCrop(getChild(blipFill, "srcRect"));
|
|
7441
|
+
const stretch = parseStretch(getChild(blipFill, "stretch"));
|
|
7442
|
+
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
7443
|
+
const blipEffects = parseBlipEffects(blip);
|
|
7444
|
+
const spPr = getChild(pic, "spPr");
|
|
7445
|
+
const transform = parseTransform(spPr);
|
|
7446
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7447
|
+
const rawSidecars = [
|
|
7448
|
+
...collectUnknownSidecars(pic, KNOWN_PICTURE_CHILDREN, nextId),
|
|
7449
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7450
|
+
...collectEffectSidecars(spPr, effects, nextId),
|
|
7451
|
+
// Retains fill mode such as `a:stretch` / `a:tile` and recolor operation under blip.
|
|
7452
|
+
...collectUnknownSidecars(blipFill, KNOWN_BLIP_FILL_CHILDREN, nextId),
|
|
7453
|
+
...collectBlipEffectSidecars(blip, blipEffects, nextId)
|
|
7454
|
+
];
|
|
7455
|
+
return {
|
|
7456
|
+
kind: "image",
|
|
7457
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7458
|
+
...name !== void 0 ? { name } : {},
|
|
7459
|
+
...transform !== void 0 ? { transform } : {},
|
|
7460
|
+
...embed !== void 0 ? { blipRelationshipId: asRelationshipId(embed) } : {},
|
|
7461
|
+
...crop !== void 0 ? { crop } : {},
|
|
7462
|
+
...stretch !== void 0 ? { stretch } : {},
|
|
7463
|
+
...tile !== void 0 ? { tile } : {},
|
|
7464
|
+
...effects !== void 0 ? { effects } : {},
|
|
7465
|
+
...blipEffects !== void 0 ? { blipEffects } : {},
|
|
7466
|
+
handle: {
|
|
7467
|
+
partPath,
|
|
7468
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7469
|
+
...embed !== void 0 ? { relationshipId: asRelationshipId(embed) } : {},
|
|
7470
|
+
orderingSlot
|
|
7471
|
+
},
|
|
7472
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7473
|
+
};
|
|
7591
7474
|
}
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
]
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
]
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
]
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
"
|
|
7631
|
-
"
|
|
7632
|
-
"
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
"
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
"
|
|
7646
|
-
"
|
|
7647
|
-
"
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7475
|
+
function collectEffectSidecars(spPr, effects, nextId) {
|
|
7476
|
+
const effectList = getChild(spPr, "effectLst");
|
|
7477
|
+
if (effectList === void 0) return [];
|
|
7478
|
+
const sidecars = collectUnknownSidecars(effectList, KNOWN_EFFECT_CHILDREN, nextId);
|
|
7479
|
+
const supportedChildren = [
|
|
7480
|
+
["outerShdw", effects?.outerShadow],
|
|
7481
|
+
["innerShdw", effects?.innerShadow],
|
|
7482
|
+
["glow", effects?.glow],
|
|
7483
|
+
["softEdge", effects?.softEdge]
|
|
7484
|
+
];
|
|
7485
|
+
for (const [name, parsed] of supportedChildren) {
|
|
7486
|
+
const node = getChild(effectList, name);
|
|
7487
|
+
if (node !== void 0 && parsed === void 0) {
|
|
7488
|
+
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7489
|
+
}
|
|
7490
|
+
}
|
|
7491
|
+
return sidecars;
|
|
7492
|
+
}
|
|
7493
|
+
function collectBlipEffectSidecars(blip, effects, nextId) {
|
|
7494
|
+
if (blip === void 0) return [];
|
|
7495
|
+
const sidecars = collectUnknownSidecars(blip, KNOWN_BLIP_CHILDREN, nextId);
|
|
7496
|
+
const supportedChildren = [
|
|
7497
|
+
["grayscl", effects?.grayscale === true],
|
|
7498
|
+
["biLevel", effects?.biLevel],
|
|
7499
|
+
["blur", effects?.blur],
|
|
7500
|
+
["lum", effects?.lum],
|
|
7501
|
+
["duotone", effects?.duotone],
|
|
7502
|
+
["clrChange", effects?.clrChange]
|
|
7503
|
+
];
|
|
7504
|
+
for (const [name, parsed] of supportedChildren) {
|
|
7505
|
+
const node = getChild(blip, name);
|
|
7506
|
+
if (node !== void 0 && (parsed === void 0 || parsed === false)) {
|
|
7507
|
+
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7508
|
+
}
|
|
7509
|
+
}
|
|
7510
|
+
return sidecars;
|
|
7511
|
+
}
|
|
7512
|
+
function parseGraphicFrame(graphicFrame, partPath, nextId, orderingSlot, orderedNode) {
|
|
7513
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
7514
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
7515
|
+
const uri = getAttr(graphicData, "uri");
|
|
7516
|
+
if (uri !== void 0 && CHART_GRAPHIC_DATA_URIS.has(uri)) {
|
|
7517
|
+
const parsedChart = parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7518
|
+
if (parsedChart !== void 0) return parsedChart;
|
|
7519
|
+
}
|
|
7520
|
+
if (uri !== void 0 && SMARTART_DIAGRAM_URIS.has(uri)) {
|
|
7521
|
+
const parsedSmartArt = parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7522
|
+
if (parsedSmartArt !== void 0) return parsedSmartArt;
|
|
7523
|
+
}
|
|
7524
|
+
const table = getChild(graphicData, "tbl");
|
|
7525
|
+
if (table === void 0) {
|
|
7526
|
+
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7527
|
+
}
|
|
7528
|
+
const orderedGraphicChildren = orderedNestedChildChildren(orderedNode, "graphicFrame", "graphic");
|
|
7529
|
+
const orderedGraphicDataChildren = orderedChildChildren2(orderedGraphicChildren, "graphicData");
|
|
7530
|
+
const orderedTableChildren = orderedChildChildren2(orderedGraphicDataChildren, "tbl");
|
|
7531
|
+
const parsedTable = parseTable(
|
|
7532
|
+
table,
|
|
7533
|
+
graphicFrame,
|
|
7534
|
+
partPath,
|
|
7535
|
+
nextId,
|
|
7536
|
+
orderingSlot,
|
|
7537
|
+
orderedTableChildren
|
|
7538
|
+
);
|
|
7539
|
+
if (parsedTable === void 0) {
|
|
7540
|
+
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7541
|
+
}
|
|
7542
|
+
return parsedTable;
|
|
7543
|
+
}
|
|
7544
|
+
function parseAlternateContent(alternateContent, partPath, nextId, orderingSlot) {
|
|
7545
|
+
const branches = [
|
|
7546
|
+
...getChildArray(alternateContent, "Choice"),
|
|
7547
|
+
...getChildArray(alternateContent, "Fallback")
|
|
7548
|
+
];
|
|
7549
|
+
for (const branch of branches) {
|
|
7550
|
+
const parsed = parseAlternateContentBranch(branch, partPath, nextId, orderingSlot);
|
|
7551
|
+
if (parsed.length > 0) {
|
|
7552
|
+
if (parsed.every((node) => node.kind === "raw")) {
|
|
7553
|
+
continue;
|
|
7554
|
+
}
|
|
7555
|
+
return parsed.map(
|
|
7556
|
+
(node) => attachRawSidecar(node, makeSidecar("mc:AlternateContent", alternateContent, nextId))
|
|
7557
|
+
);
|
|
7558
|
+
}
|
|
7668
7559
|
}
|
|
7560
|
+
return [
|
|
7561
|
+
parseRawShapeNode("mc:AlternateContent", alternateContent, partPath, nextId, orderingSlot)
|
|
7562
|
+
];
|
|
7563
|
+
}
|
|
7564
|
+
function attachRawSidecar(node, sidecar) {
|
|
7565
|
+
if (node.kind === "raw") return node;
|
|
7566
|
+
return {
|
|
7567
|
+
...node,
|
|
7568
|
+
rawSidecars: [...node.rawSidecars ?? [], sidecar]
|
|
7569
|
+
};
|
|
7570
|
+
}
|
|
7571
|
+
function parseAlternateContentBranch(branch, partPath, nextId, orderingSlot) {
|
|
7669
7572
|
const nodes = [];
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
if (key.startsWith("@_")) continue;
|
|
7673
|
-
if (key === "#text") continue;
|
|
7573
|
+
for (const key of Object.keys(branch)) {
|
|
7574
|
+
if (key.startsWith("@_") || key === "#text") continue;
|
|
7674
7575
|
const local = localName(key);
|
|
7675
|
-
|
|
7676
|
-
const value = spTree[key];
|
|
7576
|
+
const value = branch[key];
|
|
7677
7577
|
const items = Array.isArray(value) ? value : [value];
|
|
7678
7578
|
for (const item of items) {
|
|
7679
7579
|
const node = unsafeOoxmlBoundaryAssertion(item);
|
|
7680
|
-
if (local === "sp")
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
7684
|
-
} else if (local === "cxnSp") {
|
|
7580
|
+
if (local === "sp") nodes.push(parseShape(node, partPath, nextId, orderingSlot));
|
|
7581
|
+
else if (local === "pic") nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
7582
|
+
else if (local === "cxnSp") {
|
|
7685
7583
|
nodes.push(parseConnector(node, partPath, nextId, orderingSlot));
|
|
7686
7584
|
} else if (local === "grpSp") {
|
|
7687
7585
|
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
7688
7586
|
} else if (local === "graphicFrame") {
|
|
7689
7587
|
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
7690
|
-
} else if (local === "AlternateContent") {
|
|
7691
|
-
const parsed = parseAlternateContent(node, partPath, nextId, orderingSlot);
|
|
7692
|
-
nodes.push(...parsed);
|
|
7693
7588
|
} else {
|
|
7694
7589
|
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
7695
7590
|
}
|
|
7696
|
-
orderingSlot++;
|
|
7697
7591
|
}
|
|
7698
7592
|
}
|
|
7699
7593
|
return nodes;
|
|
7700
7594
|
}
|
|
7701
|
-
function
|
|
7702
|
-
const
|
|
7703
|
-
const
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
}
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7595
|
+
function parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot) {
|
|
7596
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
7597
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
7598
|
+
const chart = getChild(graphicData, "chart");
|
|
7599
|
+
const rId = getNamespacedAttr(chart, "id") ?? getAttr(chart, "id");
|
|
7600
|
+
if (rId === void 0) return void 0;
|
|
7601
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
7602
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
7603
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7604
|
+
const name = getAttr(cNvPr, "name");
|
|
7605
|
+
const transform = parseTransform(graphicFrame);
|
|
7606
|
+
const rawSidecars = [
|
|
7607
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
7608
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
7609
|
+
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
7610
|
+
];
|
|
7611
|
+
return {
|
|
7612
|
+
kind: "chart",
|
|
7613
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7614
|
+
...name !== void 0 ? { name } : {},
|
|
7615
|
+
...transform !== void 0 ? { transform } : {},
|
|
7616
|
+
chartRelationshipId: asRelationshipId(rId),
|
|
7617
|
+
handle: {
|
|
7618
|
+
partPath,
|
|
7619
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7620
|
+
relationshipId: asRelationshipId(rId),
|
|
7621
|
+
orderingSlot
|
|
7622
|
+
},
|
|
7623
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7624
|
+
};
|
|
7729
7625
|
}
|
|
7730
|
-
function
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7626
|
+
function parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot) {
|
|
7627
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
7628
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
7629
|
+
const relIds = getChild(graphicData, "relIds");
|
|
7630
|
+
const dmRId = getNamespacedAttr(relIds, "dm") ?? getAttr(relIds, "dm");
|
|
7631
|
+
if (dmRId === void 0) return void 0;
|
|
7632
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
7633
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
7634
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7635
|
+
const name = getAttr(cNvPr, "name");
|
|
7636
|
+
const transform = parseTransform(graphicFrame);
|
|
7637
|
+
const rawSidecars = [
|
|
7638
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
7639
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
7640
|
+
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
7641
|
+
];
|
|
7642
|
+
return {
|
|
7643
|
+
kind: "smartArt",
|
|
7644
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7645
|
+
...name !== void 0 ? { name } : {},
|
|
7646
|
+
...transform !== void 0 ? { transform } : {},
|
|
7647
|
+
dataRelationshipId: asRelationshipId(dmRId),
|
|
7648
|
+
handle: {
|
|
7649
|
+
partPath,
|
|
7650
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7651
|
+
relationshipId: asRelationshipId(dmRId),
|
|
7652
|
+
orderingSlot
|
|
7653
|
+
},
|
|
7654
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7655
|
+
};
|
|
7656
|
+
}
|
|
7657
|
+
function parseTable(tbl, graphicFrame, partPath, nextId, orderingSlot, orderedTableChildren) {
|
|
7658
|
+
const columns = parseTableColumns(getChild(tbl, "tblGrid"));
|
|
7659
|
+
if (columns.length === 0) return void 0;
|
|
7660
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
7661
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
7662
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7663
|
+
const name = getAttr(cNvPr, "name");
|
|
7664
|
+
const tblPr = getChild(tbl, "tblPr");
|
|
7665
|
+
const tableStyleId = getChildText(tblPr, "tableStyleId");
|
|
7666
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
7667
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
7668
|
+
const transform = parseTransform(graphicFrame);
|
|
7669
|
+
const rows = parseTableRows(tbl, partPath, nextId, nodeId, orderingSlot, orderedTableChildren);
|
|
7670
|
+
const rawSidecars = [
|
|
7671
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
7672
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
7673
|
+
...collectUnknownSidecars(graphicData, KNOWN_GRAPHIC_DATA_CHILDREN, nextId),
|
|
7674
|
+
...collectUnknownSidecars(tbl, KNOWN_TABLE_CHILDREN, nextId)
|
|
7675
|
+
];
|
|
7676
|
+
return {
|
|
7677
|
+
kind: "table",
|
|
7678
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7679
|
+
...name !== void 0 ? { name } : {},
|
|
7680
|
+
...transform !== void 0 ? { transform } : {},
|
|
7681
|
+
table: {
|
|
7682
|
+
columns,
|
|
7683
|
+
rows,
|
|
7684
|
+
...tableStyleId !== void 0 ? { tableStyleId } : {}
|
|
7685
|
+
},
|
|
7686
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7687
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7688
|
+
};
|
|
7689
|
+
}
|
|
7690
|
+
function parseTableColumns(tblGrid) {
|
|
7691
|
+
return getChildArray(tblGrid, "gridCol").map((col) => ({ width: emuAttr(col, "w") }));
|
|
7692
|
+
}
|
|
7693
|
+
function parseTableRows(tbl, partPath, nextId, tableNodeId, tableOrderingSlot, orderedTableChildren) {
|
|
7694
|
+
const orderedRows = orderedChildChildrenList(orderedTableChildren, "tr");
|
|
7695
|
+
return getChildArray(tbl, "tr").map((tr, rowIndex) => ({
|
|
7696
|
+
height: emuAttr(tr, "h"),
|
|
7697
|
+
cells: getChildArray(tr, "tc").map((tc, cellIndex) => {
|
|
7698
|
+
const orderedCells = orderedChildChildrenList(orderedRows[rowIndex], "tc");
|
|
7699
|
+
return parseTableCell(
|
|
7700
|
+
tc,
|
|
7701
|
+
partPath,
|
|
7702
|
+
nextId,
|
|
7703
|
+
tableNodeId,
|
|
7704
|
+
tableOrderingSlot,
|
|
7705
|
+
rowIndex,
|
|
7706
|
+
cellIndex,
|
|
7707
|
+
orderedCells[cellIndex]
|
|
7708
|
+
);
|
|
7709
|
+
})
|
|
7710
|
+
}));
|
|
7744
7711
|
}
|
|
7745
|
-
function
|
|
7746
|
-
const
|
|
7747
|
-
const
|
|
7748
|
-
const nodeId = sourceNodeId(cNvPr);
|
|
7749
|
-
const name = getAttr(cNvPr, "name");
|
|
7750
|
-
const placeholder = parsePlaceholder(getChild(getChild(nvSpPr, "nvPr"), "ph"));
|
|
7751
|
-
const spPr = getChild(sp, "spPr");
|
|
7752
|
-
const transform = parseTransform(spPr);
|
|
7753
|
-
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "sp", "spPr"));
|
|
7754
|
-
const fill = parseFill(spPr, nextId);
|
|
7755
|
-
const outline = parseOutline(spPr, nextId);
|
|
7756
|
-
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7757
|
-
const style = parseShapeStyle(getChild(sp, "style"));
|
|
7712
|
+
function parseTableCell(tc, partPath, nextId, tableNodeId, tableOrderingSlot, rowIndex, cellIndex, orderedCellChildren) {
|
|
7713
|
+
const tcPr = getChild(tc, "tcPr");
|
|
7714
|
+
const textOrderingSlot = tableOrderingSlot * 1e9 + rowIndex * 1e6 + cellIndex;
|
|
7758
7715
|
const textBody = parseTextBody(
|
|
7759
|
-
getChild(
|
|
7716
|
+
getChild(tc, "txBody"),
|
|
7760
7717
|
partPath,
|
|
7761
7718
|
nextId,
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7719
|
+
tableNodeId,
|
|
7720
|
+
textOrderingSlot,
|
|
7721
|
+
orderedChildChildren2(orderedCellChildren, "txBody")
|
|
7765
7722
|
);
|
|
7723
|
+
const fill = parseFill(tcPr, nextId);
|
|
7724
|
+
const borders = parseCellBorders(tcPr, nextId);
|
|
7766
7725
|
const rawSidecars = [
|
|
7767
|
-
...collectUnknownSidecars(
|
|
7768
|
-
...collectUnknownSidecars(
|
|
7769
|
-
...collectEffectSidecars(spPr, effects, nextId)
|
|
7726
|
+
...collectUnknownSidecars(tc, KNOWN_TABLE_CELL_CHILDREN, nextId),
|
|
7727
|
+
...collectUnknownSidecars(tcPr, KNOWN_TABLE_CELL_PROPERTIES_CHILDREN, nextId)
|
|
7770
7728
|
];
|
|
7771
7729
|
return {
|
|
7772
|
-
kind: "shape",
|
|
7773
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7774
|
-
...name !== void 0 ? { name } : {},
|
|
7775
|
-
...transform !== void 0 ? { transform } : {},
|
|
7776
|
-
...geometry !== void 0 ? { geometry } : {},
|
|
7777
|
-
...fill !== void 0 ? { fill } : {},
|
|
7778
|
-
...outline !== void 0 ? { outline } : {},
|
|
7779
|
-
...effects !== void 0 ? { effects } : {},
|
|
7780
|
-
...style !== void 0 ? { style } : {},
|
|
7781
7730
|
...textBody !== void 0 ? { textBody } : {},
|
|
7782
|
-
...
|
|
7783
|
-
|
|
7731
|
+
...fill !== void 0 ? { fill } : {},
|
|
7732
|
+
...borders !== void 0 ? { borders } : {},
|
|
7733
|
+
gridSpan: numericAttr2(tc, "gridSpan") ?? 1,
|
|
7734
|
+
rowSpan: numericAttr2(tc, "rowSpan") ?? 1,
|
|
7735
|
+
hMerge: isTrue(getAttr(tc, "hMerge") ?? getAttr(tcPr, "hMerge")),
|
|
7736
|
+
vMerge: isTrue(getAttr(tc, "vMerge") ?? getAttr(tcPr, "vMerge")),
|
|
7784
7737
|
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7785
7738
|
};
|
|
7786
7739
|
}
|
|
7787
|
-
function
|
|
7788
|
-
const
|
|
7789
|
-
const
|
|
7790
|
-
const
|
|
7791
|
-
const
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
const transform = parseTransform(spPr);
|
|
7796
|
-
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "cxnSp", "spPr"));
|
|
7797
|
-
const outline = parseOutline(spPr, nextId);
|
|
7798
|
-
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7799
|
-
const style = parseShapeStyle(getChild(cxnSp, "style"));
|
|
7800
|
-
const rawSidecars = [
|
|
7801
|
-
...collectUnknownSidecars(cxnSp, KNOWN_CONNECTOR_CHILDREN, nextId),
|
|
7802
|
-
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7803
|
-
...collectEffectSidecars(spPr, effects, nextId)
|
|
7804
|
-
];
|
|
7740
|
+
function parseCellBorders(tcPr, nextId) {
|
|
7741
|
+
const left = parseLine(getChild(tcPr, "lnL"), nextId);
|
|
7742
|
+
const right = parseLine(getChild(tcPr, "lnR"), nextId);
|
|
7743
|
+
const top = parseLine(getChild(tcPr, "lnT"), nextId);
|
|
7744
|
+
const bottom = parseLine(getChild(tcPr, "lnB"), nextId);
|
|
7745
|
+
if (left === void 0 && right === void 0 && top === void 0 && bottom === void 0) {
|
|
7746
|
+
return void 0;
|
|
7747
|
+
}
|
|
7805
7748
|
return {
|
|
7806
|
-
|
|
7749
|
+
...top !== void 0 ? { top } : {},
|
|
7750
|
+
...bottom !== void 0 ? { bottom } : {},
|
|
7751
|
+
...left !== void 0 ? { left } : {},
|
|
7752
|
+
...right !== void 0 ? { right } : {}
|
|
7753
|
+
};
|
|
7754
|
+
}
|
|
7755
|
+
function parseRawShapeNode(key, node, partPath, nextId, orderingSlot) {
|
|
7756
|
+
const nodeId = sourceNodeId(getChild(getChild(node, "nvSpPr"), "cNvPr"));
|
|
7757
|
+
return {
|
|
7758
|
+
kind: "raw",
|
|
7807
7759
|
...nodeId !== void 0 ? { nodeId } : {},
|
|
7808
|
-
|
|
7809
|
-
...
|
|
7810
|
-
...transform !== void 0 ? { transform } : {},
|
|
7811
|
-
...geometry !== void 0 ? { geometry } : {},
|
|
7812
|
-
...outline !== void 0 ? { outline } : {},
|
|
7813
|
-
...effects !== void 0 ? { effects } : {},
|
|
7814
|
-
...style !== void 0 ? { style } : {},
|
|
7815
|
-
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7816
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7760
|
+
raw: makeSidecar(key, node, nextId),
|
|
7761
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot }
|
|
7817
7762
|
};
|
|
7818
7763
|
}
|
|
7819
|
-
function
|
|
7820
|
-
|
|
7821
|
-
const
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7764
|
+
function parsePlaceholder(ph) {
|
|
7765
|
+
if (!ph) return void 0;
|
|
7766
|
+
const type = getAttr(ph, "type");
|
|
7767
|
+
const index = numericAttr2(ph, "idx");
|
|
7768
|
+
if (type === void 0 && index === void 0) return void 0;
|
|
7769
|
+
return {
|
|
7770
|
+
...type !== void 0 ? { type } : {},
|
|
7771
|
+
...index !== void 0 ? { index } : {}
|
|
7772
|
+
};
|
|
7826
7773
|
}
|
|
7827
|
-
function
|
|
7828
|
-
const
|
|
7829
|
-
|
|
7830
|
-
|
|
7774
|
+
function parseGeometry(spPr, orderedSpPr) {
|
|
7775
|
+
const prstGeom = getChild(spPr, "prstGeom");
|
|
7776
|
+
if (prstGeom) {
|
|
7777
|
+
const preset = getAttr(prstGeom, "prst");
|
|
7778
|
+
const adjustValues = parseAdjustValues(getChild(prstGeom, "avLst"));
|
|
7779
|
+
return preset !== void 0 ? {
|
|
7780
|
+
preset,
|
|
7781
|
+
...Object.keys(adjustValues).length > 0 ? { adjustValues } : {}
|
|
7782
|
+
} : void 0;
|
|
7783
|
+
}
|
|
7784
|
+
const customPaths = parseCustomGeometry(
|
|
7785
|
+
getChild(spPr, "custGeom"),
|
|
7786
|
+
orderedChildChildren2(orderedSpPr, "custGeom")
|
|
7787
|
+
);
|
|
7788
|
+
if (customPaths !== void 0) return { kind: "custom", paths: customPaths };
|
|
7789
|
+
return void 0;
|
|
7790
|
+
}
|
|
7791
|
+
function parseAdjustValues(avLst) {
|
|
7792
|
+
const adjustValues = {};
|
|
7793
|
+
for (const guide of getChildArray(avLst, "gd")) {
|
|
7794
|
+
const name = getAttr(guide, "name");
|
|
7795
|
+
const formula = getAttr(guide, "fmla");
|
|
7796
|
+
const match = formula?.match(/val\s+(-?\d+)/);
|
|
7797
|
+
if (name !== void 0 && match !== void 0 && match !== null) {
|
|
7798
|
+
adjustValues[name] = Number(match[1]);
|
|
7799
|
+
}
|
|
7800
|
+
}
|
|
7801
|
+
return adjustValues;
|
|
7802
|
+
}
|
|
7803
|
+
function parseChildTransform(grpSpPr, fallback) {
|
|
7804
|
+
const xfrm = getChild(grpSpPr, "xfrm");
|
|
7805
|
+
const childOff = getChild(xfrm, "chOff");
|
|
7806
|
+
const childExt = getChild(xfrm, "chExt");
|
|
7807
|
+
const offsetX = numericAttr2(childOff, "x") ?? 0;
|
|
7808
|
+
const offsetY = numericAttr2(childOff, "y") ?? 0;
|
|
7809
|
+
const width = numericAttr2(childExt, "cx") ?? fallback?.width;
|
|
7810
|
+
const height = numericAttr2(childExt, "cy") ?? fallback?.height;
|
|
7811
|
+
if (width === void 0 || height === void 0) return void 0;
|
|
7831
7812
|
return {
|
|
7832
|
-
|
|
7833
|
-
|
|
7813
|
+
offsetX: asEmu2(offsetX),
|
|
7814
|
+
offsetY: asEmu2(offsetY),
|
|
7815
|
+
width: asEmu2(Number(width)),
|
|
7816
|
+
height: asEmu2(Number(height))
|
|
7817
|
+
};
|
|
7818
|
+
}
|
|
7819
|
+
function parseCrop(srcRect) {
|
|
7820
|
+
if (!srcRect) return void 0;
|
|
7821
|
+
const left = numericAttr2(srcRect, "l");
|
|
7822
|
+
const top = numericAttr2(srcRect, "t");
|
|
7823
|
+
const right = numericAttr2(srcRect, "r");
|
|
7824
|
+
const bottom = numericAttr2(srcRect, "b");
|
|
7825
|
+
const crop = {
|
|
7826
|
+
...left !== void 0 ? { left: asOoxmlPercent(left) } : {},
|
|
7827
|
+
...top !== void 0 ? { top: asOoxmlPercent(top) } : {},
|
|
7828
|
+
...right !== void 0 ? { right: asOoxmlPercent(right) } : {},
|
|
7829
|
+
...bottom !== void 0 ? { bottom: asOoxmlPercent(bottom) } : {}
|
|
7834
7830
|
};
|
|
7831
|
+
return Object.keys(crop).length > 0 ? crop : void 0;
|
|
7832
|
+
}
|
|
7833
|
+
function parseStretch(stretch) {
|
|
7834
|
+
const fillRect = getChild(stretch, "fillRect");
|
|
7835
|
+
if (fillRect === void 0) return void 0;
|
|
7836
|
+
const left = (numericAttr2(fillRect, "l") ?? 0) / 1e5;
|
|
7837
|
+
const top = (numericAttr2(fillRect, "t") ?? 0) / 1e5;
|
|
7838
|
+
const right = (numericAttr2(fillRect, "r") ?? 0) / 1e5;
|
|
7839
|
+
const bottom = (numericAttr2(fillRect, "b") ?? 0) / 1e5;
|
|
7840
|
+
if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
|
|
7841
|
+
return { left, top, right, bottom };
|
|
7842
|
+
}
|
|
7843
|
+
function sourceNodeId(cNvPr) {
|
|
7844
|
+
const id = getAttr(cNvPr, "id");
|
|
7845
|
+
return id !== void 0 ? asSourceNodeId(id) : void 0;
|
|
7846
|
+
}
|
|
7847
|
+
function emuAttr(node, attrName) {
|
|
7848
|
+
return asEmu2(numericAttr2(node, attrName) ?? 0);
|
|
7849
|
+
}
|
|
7850
|
+
var EMPTY_KNOWN = /* @__PURE__ */ new Set();
|
|
7851
|
+
function orderedChildChildren2(parent, childLocalName) {
|
|
7852
|
+
const child = parent?.find((entry) => {
|
|
7853
|
+
const key2 = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
7854
|
+
return key2 !== void 0 && localName(key2) === childLocalName;
|
|
7855
|
+
});
|
|
7856
|
+
if (child === void 0) return void 0;
|
|
7857
|
+
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
7858
|
+
const value = key !== void 0 ? child[key] : void 0;
|
|
7859
|
+
return Array.isArray(value) ? value : void 0;
|
|
7860
|
+
}
|
|
7861
|
+
function orderedChildChildrenList(parent, childLocalName) {
|
|
7862
|
+
if (parent === void 0) return [];
|
|
7863
|
+
return parent.filter((entry) => {
|
|
7864
|
+
const key = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
7865
|
+
return key !== void 0 && localName(key) === childLocalName;
|
|
7866
|
+
}).map((entry) => {
|
|
7867
|
+
const key = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
7868
|
+
const value = key !== void 0 ? entry[key] : void 0;
|
|
7869
|
+
return Array.isArray(value) ? value : void 0;
|
|
7870
|
+
});
|
|
7871
|
+
}
|
|
7872
|
+
function orderedNestedChildChildren(node, parentLocalName, childLocalName) {
|
|
7873
|
+
if (node === void 0) return void 0;
|
|
7874
|
+
const parentChildren = node[parentLocalName];
|
|
7875
|
+
return orderedChildChildren2(
|
|
7876
|
+
Array.isArray(parentChildren) ? parentChildren : void 0,
|
|
7877
|
+
childLocalName
|
|
7878
|
+
);
|
|
7879
|
+
}
|
|
7880
|
+
var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
|
|
7881
|
+
ignoreAttributes: false,
|
|
7882
|
+
attributeNamePrefix: "@_",
|
|
7883
|
+
format: false,
|
|
7884
|
+
suppressEmptyNode: true
|
|
7885
|
+
});
|
|
7886
|
+
var EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS = {
|
|
7887
|
+
bold: (value) => requireBooleanOrUndefined(value, "bold"),
|
|
7888
|
+
italic: (value) => requireBooleanOrUndefined(value, "italic"),
|
|
7889
|
+
underline: (value) => requireBooleanOrUndefined(value, "underline"),
|
|
7890
|
+
fontSize: (value) => {
|
|
7891
|
+
if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
|
|
7892
|
+
throw new Error("updateTextRunProperties: fontSize must be a finite positive pt value");
|
|
7893
|
+
}
|
|
7894
|
+
},
|
|
7895
|
+
color: (value) => {
|
|
7896
|
+
if (value === void 0) return;
|
|
7897
|
+
if (value.kind !== "srgb") {
|
|
7898
|
+
throw new Error("updateTextRunProperties: only srgb text run color is supported");
|
|
7899
|
+
}
|
|
7900
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(value.hex)) {
|
|
7901
|
+
throw new Error("updateTextRunProperties: srgb text run color must be a 6-digit hex value");
|
|
7902
|
+
}
|
|
7903
|
+
},
|
|
7904
|
+
typeface: (value) => {
|
|
7905
|
+
if (value !== void 0 && value.trim() === "") {
|
|
7906
|
+
throw new Error("updateTextRunProperties: typeface must be a non-empty string");
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
7909
|
+
};
|
|
7910
|
+
var EDITABLE_TEXT_RUN_PROPERTIES = Object.keys(EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS).filter(
|
|
7911
|
+
(property) => property in EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS
|
|
7912
|
+
);
|
|
7913
|
+
var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
|
|
7914
|
+
function requireBooleanOrUndefined(value, fieldName) {
|
|
7915
|
+
if (value !== void 0 && typeof value !== "boolean") {
|
|
7916
|
+
throw new Error(`updateTextRunProperties: ${fieldName} must be a boolean value`);
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
function asEmu2(value) {
|
|
7920
|
+
return unsafeBrandAssertion2(value);
|
|
7921
|
+
}
|
|
7922
|
+
function asPt(value) {
|
|
7923
|
+
return unsafeBrandAssertion2(value);
|
|
7924
|
+
}
|
|
7925
|
+
function asHundredthPt2(value) {
|
|
7926
|
+
return unsafeBrandAssertion2(value);
|
|
7927
|
+
}
|
|
7928
|
+
function asOoxmlPercent(value) {
|
|
7929
|
+
return unsafeBrandAssertion2(value);
|
|
7930
|
+
}
|
|
7931
|
+
function asOoxmlAngle(value) {
|
|
7932
|
+
return unsafeBrandAssertion2(value);
|
|
7933
|
+
}
|
|
7934
|
+
var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
|
|
7935
|
+
"tl",
|
|
7936
|
+
"t",
|
|
7937
|
+
"tr",
|
|
7938
|
+
"l",
|
|
7939
|
+
"ctr",
|
|
7940
|
+
"r",
|
|
7941
|
+
"bl",
|
|
7942
|
+
"b",
|
|
7943
|
+
"br"
|
|
7944
|
+
]);
|
|
7945
|
+
var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
|
|
7946
|
+
"lumMod",
|
|
7947
|
+
"lumOff",
|
|
7948
|
+
"tint",
|
|
7949
|
+
"shade",
|
|
7950
|
+
"alpha"
|
|
7951
|
+
]);
|
|
7952
|
+
var RAW_FILL_LOCAL_NAMES = ["grpFill"];
|
|
7953
|
+
var PRESET_COLOR_HEX = {
|
|
7954
|
+
black: "000000",
|
|
7955
|
+
white: "FFFFFF",
|
|
7956
|
+
red: "FF0000",
|
|
7957
|
+
green: "008000",
|
|
7958
|
+
blue: "0000FF",
|
|
7959
|
+
yellow: "FFFF00",
|
|
7960
|
+
cyan: "00FFFF",
|
|
7961
|
+
magenta: "FF00FF"
|
|
7962
|
+
};
|
|
7963
|
+
function parseColorElement(parent) {
|
|
7964
|
+
if (!parent) return void 0;
|
|
7965
|
+
const srgb = getChild(parent, "srgbClr");
|
|
7966
|
+
if (srgb) {
|
|
7967
|
+
const hex = getAttr(srgb, "val");
|
|
7968
|
+
if (hex !== void 0) {
|
|
7969
|
+
return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
const scheme = getChild(parent, "schemeClr");
|
|
7973
|
+
if (scheme) {
|
|
7974
|
+
const name = getAttr(scheme, "val");
|
|
7975
|
+
if (name !== void 0) {
|
|
7976
|
+
return withTransforms({ kind: "scheme", scheme: name }, scheme);
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
const sys = getChild(parent, "sysClr");
|
|
7980
|
+
if (sys) {
|
|
7981
|
+
const val = getAttr(sys, "val");
|
|
7982
|
+
if (val !== void 0) {
|
|
7983
|
+
const lastClr = getAttr(sys, "lastClr");
|
|
7984
|
+
return withTransforms(
|
|
7985
|
+
{
|
|
7986
|
+
kind: "system",
|
|
7987
|
+
value: val,
|
|
7988
|
+
...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
|
|
7989
|
+
},
|
|
7990
|
+
sys
|
|
7991
|
+
);
|
|
7992
|
+
}
|
|
7993
|
+
}
|
|
7994
|
+
return void 0;
|
|
7835
7995
|
}
|
|
7836
|
-
function
|
|
7837
|
-
if (
|
|
7838
|
-
const
|
|
7839
|
-
const
|
|
7840
|
-
const
|
|
7996
|
+
function parseEffectList(effectList) {
|
|
7997
|
+
if (effectList === void 0) return void 0;
|
|
7998
|
+
const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
|
|
7999
|
+
const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
|
|
8000
|
+
const glow = parseGlow(getChild(effectList, "glow"));
|
|
8001
|
+
const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
|
|
7841
8002
|
const parsed = {
|
|
7842
|
-
...
|
|
7843
|
-
...
|
|
7844
|
-
...
|
|
8003
|
+
...outerShadow !== void 0 ? { outerShadow } : {},
|
|
8004
|
+
...innerShadow !== void 0 ? { innerShadow } : {},
|
|
8005
|
+
...glow !== void 0 ? { glow } : {},
|
|
8006
|
+
...softEdge !== void 0 ? { softEdge } : {}
|
|
7845
8007
|
};
|
|
7846
8008
|
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
7847
8009
|
}
|
|
7848
|
-
function
|
|
7849
|
-
if (
|
|
7850
|
-
const
|
|
7851
|
-
const
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
8010
|
+
function parseBlipEffects(blip) {
|
|
8011
|
+
if (blip === void 0) return void 0;
|
|
8012
|
+
const grayscale = getChild(blip, "grayscl") !== void 0;
|
|
8013
|
+
const biLevel = parseBiLevel(getChild(blip, "biLevel"));
|
|
8014
|
+
const blur = parseBlurEffect(getChild(blip, "blur"));
|
|
8015
|
+
const lum = parseLumEffect(getChild(blip, "lum"));
|
|
8016
|
+
const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
|
|
8017
|
+
const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
|
|
8018
|
+
const parsed = {
|
|
8019
|
+
grayscale,
|
|
8020
|
+
...biLevel !== void 0 ? { biLevel } : {},
|
|
8021
|
+
...blur !== void 0 ? { blur } : {},
|
|
8022
|
+
...lum !== void 0 ? { lum } : {},
|
|
8023
|
+
...duotone !== void 0 ? { duotone } : {},
|
|
8024
|
+
...clrChange !== void 0 ? { clrChange } : {}
|
|
7855
8025
|
};
|
|
8026
|
+
return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
|
|
7856
8027
|
}
|
|
7857
|
-
function
|
|
7858
|
-
|
|
7859
|
-
const
|
|
7860
|
-
|
|
7861
|
-
const name = getAttr(cNvPr, "name");
|
|
7862
|
-
const grpSpPr = getChild(grpSp, "grpSpPr");
|
|
7863
|
-
const transform = parseTransform(grpSpPr);
|
|
7864
|
-
const childTransform = parseChildTransform(grpSpPr, transform);
|
|
7865
|
-
const fill = parseFill(grpSpPr, nextId);
|
|
7866
|
-
const effects = parseEffectList(getChild(grpSpPr, "effectLst"));
|
|
7867
|
-
const rawSidecars = [
|
|
7868
|
-
...collectUnknownSidecars(grpSp, KNOWN_GROUP_CHILDREN, nextId),
|
|
7869
|
-
...collectUnknownSidecars(grpSpPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7870
|
-
...collectEffectSidecars(grpSpPr, effects, nextId)
|
|
7871
|
-
];
|
|
8028
|
+
function parseOuterShadow(node) {
|
|
8029
|
+
if (node === void 0) return void 0;
|
|
8030
|
+
const color = parseColorElement(node);
|
|
8031
|
+
if (color === void 0) return void 0;
|
|
7872
8032
|
return {
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
...effects !== void 0 ? { effects } : {},
|
|
7880
|
-
children: parseShapeTree(grpSp, partPath, nextId, orderedChildren),
|
|
7881
|
-
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7882
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8033
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
8034
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
8035
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
8036
|
+
color,
|
|
8037
|
+
alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
|
|
8038
|
+
rotateWithShape: getAttr(node, "rotWithShape") !== "0"
|
|
7883
8039
|
};
|
|
7884
8040
|
}
|
|
7885
|
-
function
|
|
7886
|
-
|
|
7887
|
-
const
|
|
7888
|
-
|
|
7889
|
-
const blipFill = getChild(pic, "blipFill");
|
|
7890
|
-
const blip = getChild(blipFill, "blip");
|
|
7891
|
-
const embed = getNamespacedAttr(blip, "embed");
|
|
7892
|
-
const crop = parseCrop(getChild(blipFill, "srcRect"));
|
|
7893
|
-
const stretch = parseStretch(getChild(blipFill, "stretch"));
|
|
7894
|
-
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
7895
|
-
const blipEffects = parseBlipEffects(blip);
|
|
7896
|
-
const spPr = getChild(pic, "spPr");
|
|
7897
|
-
const transform = parseTransform(spPr);
|
|
7898
|
-
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7899
|
-
const rawSidecars = [
|
|
7900
|
-
...collectUnknownSidecars(pic, KNOWN_PICTURE_CHILDREN, nextId),
|
|
7901
|
-
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7902
|
-
...collectEffectSidecars(spPr, effects, nextId),
|
|
7903
|
-
// Retains fill mode such as `a:stretch` / `a:tile` and recolor operation under blip.
|
|
7904
|
-
...collectUnknownSidecars(blipFill, KNOWN_BLIP_FILL_CHILDREN, nextId),
|
|
7905
|
-
...collectBlipEffectSidecars(blip, blipEffects, nextId)
|
|
7906
|
-
];
|
|
8041
|
+
function parseInnerShadow(node) {
|
|
8042
|
+
if (node === void 0) return void 0;
|
|
8043
|
+
const color = parseColorElement(node);
|
|
8044
|
+
if (color === void 0) return void 0;
|
|
7907
8045
|
return {
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
...embed !== void 0 ? { blipRelationshipId: asRelationshipId(embed) } : {},
|
|
7913
|
-
...crop !== void 0 ? { crop } : {},
|
|
7914
|
-
...stretch !== void 0 ? { stretch } : {},
|
|
7915
|
-
...tile !== void 0 ? { tile } : {},
|
|
7916
|
-
...effects !== void 0 ? { effects } : {},
|
|
7917
|
-
...blipEffects !== void 0 ? { blipEffects } : {},
|
|
7918
|
-
handle: {
|
|
7919
|
-
partPath,
|
|
7920
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7921
|
-
...embed !== void 0 ? { relationshipId: asRelationshipId(embed) } : {},
|
|
7922
|
-
orderingSlot
|
|
7923
|
-
},
|
|
7924
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8046
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
8047
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
8048
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
8049
|
+
color
|
|
7925
8050
|
};
|
|
7926
8051
|
}
|
|
7927
|
-
function
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
const supportedChildren = [
|
|
7932
|
-
["outerShdw", effects?.outerShadow],
|
|
7933
|
-
["innerShdw", effects?.innerShadow],
|
|
7934
|
-
["glow", effects?.glow],
|
|
7935
|
-
["softEdge", effects?.softEdge]
|
|
7936
|
-
];
|
|
7937
|
-
for (const [name, parsed] of supportedChildren) {
|
|
7938
|
-
const node = getChild(effectList, name);
|
|
7939
|
-
if (node !== void 0 && parsed === void 0) {
|
|
7940
|
-
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7941
|
-
}
|
|
7942
|
-
}
|
|
7943
|
-
return sidecars;
|
|
7944
|
-
}
|
|
7945
|
-
function collectBlipEffectSidecars(blip, effects, nextId) {
|
|
7946
|
-
if (blip === void 0) return [];
|
|
7947
|
-
const sidecars = collectUnknownSidecars(blip, KNOWN_BLIP_CHILDREN, nextId);
|
|
7948
|
-
const supportedChildren = [
|
|
7949
|
-
["grayscl", effects?.grayscale === true],
|
|
7950
|
-
["biLevel", effects?.biLevel],
|
|
7951
|
-
["blur", effects?.blur],
|
|
7952
|
-
["lum", effects?.lum],
|
|
7953
|
-
["duotone", effects?.duotone],
|
|
7954
|
-
["clrChange", effects?.clrChange]
|
|
7955
|
-
];
|
|
7956
|
-
for (const [name, parsed] of supportedChildren) {
|
|
7957
|
-
const node = getChild(blip, name);
|
|
7958
|
-
if (node !== void 0 && (parsed === void 0 || parsed === false)) {
|
|
7959
|
-
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7960
|
-
}
|
|
7961
|
-
}
|
|
7962
|
-
return sidecars;
|
|
7963
|
-
}
|
|
7964
|
-
function parseGraphicFrame(graphicFrame, partPath, nextId, orderingSlot, orderedNode) {
|
|
7965
|
-
const graphic = getChild(graphicFrame, "graphic");
|
|
7966
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
7967
|
-
const uri = getAttr(graphicData, "uri");
|
|
7968
|
-
if (uri !== void 0 && CHART_GRAPHIC_DATA_URIS.has(uri)) {
|
|
7969
|
-
const parsedChart = parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7970
|
-
if (parsedChart !== void 0) return parsedChart;
|
|
7971
|
-
}
|
|
7972
|
-
if (uri !== void 0 && SMARTART_DIAGRAM_URIS.has(uri)) {
|
|
7973
|
-
const parsedSmartArt = parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7974
|
-
if (parsedSmartArt !== void 0) return parsedSmartArt;
|
|
7975
|
-
}
|
|
7976
|
-
const table = getChild(graphicData, "tbl");
|
|
7977
|
-
if (table === void 0) {
|
|
7978
|
-
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7979
|
-
}
|
|
7980
|
-
const orderedGraphicChildren = orderedNestedChildChildren(orderedNode, "graphicFrame", "graphic");
|
|
7981
|
-
const orderedGraphicDataChildren = orderedChildChildren2(orderedGraphicChildren, "graphicData");
|
|
7982
|
-
const orderedTableChildren = orderedChildChildren2(orderedGraphicDataChildren, "tbl");
|
|
7983
|
-
const parsedTable = parseTable(
|
|
7984
|
-
table,
|
|
7985
|
-
graphicFrame,
|
|
7986
|
-
partPath,
|
|
7987
|
-
nextId,
|
|
7988
|
-
orderingSlot,
|
|
7989
|
-
orderedTableChildren
|
|
7990
|
-
);
|
|
7991
|
-
if (parsedTable === void 0) {
|
|
7992
|
-
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7993
|
-
}
|
|
7994
|
-
return parsedTable;
|
|
7995
|
-
}
|
|
7996
|
-
function parseAlternateContent(alternateContent, partPath, nextId, orderingSlot) {
|
|
7997
|
-
const branches = [
|
|
7998
|
-
...getChildArray(alternateContent, "Choice"),
|
|
7999
|
-
...getChildArray(alternateContent, "Fallback")
|
|
8000
|
-
];
|
|
8001
|
-
for (const branch of branches) {
|
|
8002
|
-
const parsed = parseAlternateContentBranch(branch, partPath, nextId, orderingSlot);
|
|
8003
|
-
if (parsed.length > 0) {
|
|
8004
|
-
if (parsed.every((node) => node.kind === "raw")) {
|
|
8005
|
-
continue;
|
|
8006
|
-
}
|
|
8007
|
-
return parsed.map(
|
|
8008
|
-
(node) => attachRawSidecar(node, makeSidecar("mc:AlternateContent", alternateContent, nextId))
|
|
8009
|
-
);
|
|
8010
|
-
}
|
|
8011
|
-
}
|
|
8012
|
-
return [
|
|
8013
|
-
parseRawShapeNode("mc:AlternateContent", alternateContent, partPath, nextId, orderingSlot)
|
|
8014
|
-
];
|
|
8015
|
-
}
|
|
8016
|
-
function attachRawSidecar(node, sidecar) {
|
|
8017
|
-
if (node.kind === "raw") return node;
|
|
8052
|
+
function parseGlow(node) {
|
|
8053
|
+
if (node === void 0) return void 0;
|
|
8054
|
+
const color = parseColorElement(node);
|
|
8055
|
+
if (color === void 0) return void 0;
|
|
8018
8056
|
return {
|
|
8019
|
-
|
|
8020
|
-
|
|
8057
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0),
|
|
8058
|
+
color
|
|
8021
8059
|
};
|
|
8022
8060
|
}
|
|
8023
|
-
function
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
const value = branch[key];
|
|
8029
|
-
const items = Array.isArray(value) ? value : [value];
|
|
8030
|
-
for (const item of items) {
|
|
8031
|
-
const node = unsafeOoxmlBoundaryAssertion(item);
|
|
8032
|
-
if (local === "sp") nodes.push(parseShape(node, partPath, nextId, orderingSlot));
|
|
8033
|
-
else if (local === "pic") nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
8034
|
-
else if (local === "cxnSp") {
|
|
8035
|
-
nodes.push(parseConnector(node, partPath, nextId, orderingSlot));
|
|
8036
|
-
} else if (local === "grpSp") {
|
|
8037
|
-
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
8038
|
-
} else if (local === "graphicFrame") {
|
|
8039
|
-
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
8040
|
-
} else {
|
|
8041
|
-
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
8042
|
-
}
|
|
8043
|
-
}
|
|
8044
|
-
}
|
|
8045
|
-
return nodes;
|
|
8061
|
+
function parseSoftEdge(node) {
|
|
8062
|
+
if (node === void 0) return void 0;
|
|
8063
|
+
return {
|
|
8064
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0)
|
|
8065
|
+
};
|
|
8046
8066
|
}
|
|
8047
|
-
function
|
|
8048
|
-
|
|
8049
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
8050
|
-
const chart = getChild(graphicData, "chart");
|
|
8051
|
-
const rId = getNamespacedAttr(chart, "id") ?? getAttr(chart, "id");
|
|
8052
|
-
if (rId === void 0) return void 0;
|
|
8053
|
-
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8054
|
-
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8055
|
-
const nodeId = sourceNodeId(cNvPr);
|
|
8056
|
-
const name = getAttr(cNvPr, "name");
|
|
8057
|
-
const transform = parseTransform(graphicFrame);
|
|
8058
|
-
const rawSidecars = [
|
|
8059
|
-
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8060
|
-
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8061
|
-
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
8062
|
-
];
|
|
8067
|
+
function parseBiLevel(node) {
|
|
8068
|
+
if (node === void 0) return void 0;
|
|
8063
8069
|
return {
|
|
8064
|
-
|
|
8065
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
8066
|
-
...name !== void 0 ? { name } : {},
|
|
8067
|
-
...transform !== void 0 ? { transform } : {},
|
|
8068
|
-
chartRelationshipId: asRelationshipId(rId),
|
|
8069
|
-
handle: {
|
|
8070
|
-
partPath,
|
|
8071
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
8072
|
-
relationshipId: asRelationshipId(rId),
|
|
8073
|
-
orderingSlot
|
|
8074
|
-
},
|
|
8075
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8070
|
+
threshold: (numericAttr2(node, "thresh") ?? 5e4) / 1e5
|
|
8076
8071
|
};
|
|
8077
8072
|
}
|
|
8078
|
-
function
|
|
8079
|
-
|
|
8080
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
8081
|
-
const relIds = getChild(graphicData, "relIds");
|
|
8082
|
-
const dmRId = getNamespacedAttr(relIds, "dm") ?? getAttr(relIds, "dm");
|
|
8083
|
-
if (dmRId === void 0) return void 0;
|
|
8084
|
-
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8085
|
-
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8086
|
-
const nodeId = sourceNodeId(cNvPr);
|
|
8087
|
-
const name = getAttr(cNvPr, "name");
|
|
8088
|
-
const transform = parseTransform(graphicFrame);
|
|
8089
|
-
const rawSidecars = [
|
|
8090
|
-
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8091
|
-
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8092
|
-
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
8093
|
-
];
|
|
8073
|
+
function parseBlurEffect(node) {
|
|
8074
|
+
if (node === void 0) return void 0;
|
|
8094
8075
|
return {
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
...name !== void 0 ? { name } : {},
|
|
8098
|
-
...transform !== void 0 ? { transform } : {},
|
|
8099
|
-
dataRelationshipId: asRelationshipId(dmRId),
|
|
8100
|
-
handle: {
|
|
8101
|
-
partPath,
|
|
8102
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
8103
|
-
relationshipId: asRelationshipId(dmRId),
|
|
8104
|
-
orderingSlot
|
|
8105
|
-
},
|
|
8106
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8076
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0),
|
|
8077
|
+
grow: getAttr(node, "grow") !== "0"
|
|
8107
8078
|
};
|
|
8108
8079
|
}
|
|
8109
|
-
function
|
|
8110
|
-
|
|
8111
|
-
if (columns.length === 0) return void 0;
|
|
8112
|
-
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8113
|
-
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8114
|
-
const nodeId = sourceNodeId(cNvPr);
|
|
8115
|
-
const name = getAttr(cNvPr, "name");
|
|
8116
|
-
const tblPr = getChild(tbl, "tblPr");
|
|
8117
|
-
const tableStyleId = getChildText(tblPr, "tableStyleId");
|
|
8118
|
-
const graphic = getChild(graphicFrame, "graphic");
|
|
8119
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
8120
|
-
const transform = parseTransform(graphicFrame);
|
|
8121
|
-
const rows = parseTableRows(tbl, partPath, nextId, nodeId, orderingSlot, orderedTableChildren);
|
|
8122
|
-
const rawSidecars = [
|
|
8123
|
-
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8124
|
-
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8125
|
-
...collectUnknownSidecars(graphicData, KNOWN_GRAPHIC_DATA_CHILDREN, nextId),
|
|
8126
|
-
...collectUnknownSidecars(tbl, KNOWN_TABLE_CHILDREN, nextId)
|
|
8127
|
-
];
|
|
8080
|
+
function parseLumEffect(node) {
|
|
8081
|
+
if (node === void 0) return void 0;
|
|
8128
8082
|
return {
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
...name !== void 0 ? { name } : {},
|
|
8132
|
-
...transform !== void 0 ? { transform } : {},
|
|
8133
|
-
table: {
|
|
8134
|
-
columns,
|
|
8135
|
-
rows,
|
|
8136
|
-
...tableStyleId !== void 0 ? { tableStyleId } : {}
|
|
8137
|
-
},
|
|
8138
|
-
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
8139
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8083
|
+
brightness: (numericAttr2(node, "bright") ?? 0) / 1e5,
|
|
8084
|
+
contrast: (numericAttr2(node, "contrast") ?? 0) / 1e5
|
|
8140
8085
|
};
|
|
8141
8086
|
}
|
|
8142
|
-
function
|
|
8143
|
-
|
|
8087
|
+
function parseDuotoneEffect(node) {
|
|
8088
|
+
if (node === void 0) return void 0;
|
|
8089
|
+
const colors = collectColorChildren(node);
|
|
8090
|
+
if (colors.length < 2) return void 0;
|
|
8091
|
+
return { color1: colors[0], color2: colors[1] };
|
|
8144
8092
|
}
|
|
8145
|
-
function
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
const orderedCells = orderedChildChildrenList(orderedRows[rowIndex], "tc");
|
|
8151
|
-
return parseTableCell(
|
|
8152
|
-
tc,
|
|
8153
|
-
partPath,
|
|
8154
|
-
nextId,
|
|
8155
|
-
tableNodeId,
|
|
8156
|
-
tableOrderingSlot,
|
|
8157
|
-
rowIndex,
|
|
8158
|
-
cellIndex,
|
|
8159
|
-
orderedCells[cellIndex]
|
|
8160
|
-
);
|
|
8161
|
-
})
|
|
8162
|
-
}));
|
|
8093
|
+
function parseColorChangeEffect(node) {
|
|
8094
|
+
if (node === void 0) return void 0;
|
|
8095
|
+
const from = firstColorChild(getChild(node, "clrFrom"));
|
|
8096
|
+
const to = firstColorChild(getChild(node, "clrTo"));
|
|
8097
|
+
return from !== void 0 && to !== void 0 ? { from, to } : void 0;
|
|
8163
8098
|
}
|
|
8164
|
-
function
|
|
8165
|
-
const
|
|
8166
|
-
const
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8099
|
+
function collectColorChildren(parent) {
|
|
8100
|
+
const colors = [];
|
|
8101
|
+
for (const [key, value] of Object.entries(parent)) {
|
|
8102
|
+
if (key.startsWith("@_")) continue;
|
|
8103
|
+
const nodes = Array.isArray(value) ? value : [value];
|
|
8104
|
+
for (const node of nodes) {
|
|
8105
|
+
if (!isXmlNode(node)) continue;
|
|
8106
|
+
const color = parseColorChild(key, node);
|
|
8107
|
+
if (color !== void 0) colors.push(color);
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
return colors;
|
|
8111
|
+
}
|
|
8112
|
+
function firstColorChild(parent) {
|
|
8113
|
+
return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
|
|
8114
|
+
}
|
|
8115
|
+
function parseColorChild(key, node) {
|
|
8116
|
+
const name = localName(key);
|
|
8117
|
+
return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
|
|
8118
|
+
}
|
|
8119
|
+
function isXmlNode(value) {
|
|
8120
|
+
return typeof value === "object" && value !== null;
|
|
8121
|
+
}
|
|
8122
|
+
function parsePresetColor(node) {
|
|
8123
|
+
const value = getAttr(node, "val");
|
|
8124
|
+
const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
|
|
8125
|
+
return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
|
|
8126
|
+
}
|
|
8127
|
+
function parseFill(parent, nextId) {
|
|
8128
|
+
if (!parent) return void 0;
|
|
8129
|
+
const solid = getChild(parent, "solidFill");
|
|
8130
|
+
if (solid) {
|
|
8131
|
+
const color = parseColorElement(solid);
|
|
8132
|
+
if (color) return { kind: "solid", color };
|
|
8133
|
+
return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
|
|
8134
|
+
}
|
|
8135
|
+
if (hasChild(parent, "noFill")) return { kind: "none" };
|
|
8136
|
+
const grad = getChild(parent, "gradFill");
|
|
8137
|
+
if (grad) {
|
|
8138
|
+
const fill = parseGradientFill(grad);
|
|
8139
|
+
return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
|
|
8140
|
+
}
|
|
8141
|
+
const blip = getChild(parent, "blipFill");
|
|
8142
|
+
if (blip) {
|
|
8143
|
+
return parseBlipFill(blip) ?? { kind: "raw", raw: makeSidecar("a:blipFill", blip, nextId) };
|
|
8144
|
+
}
|
|
8145
|
+
const pattern = getChild(parent, "pattFill");
|
|
8146
|
+
if (pattern) {
|
|
8147
|
+
const fill = parsePatternFill(pattern);
|
|
8148
|
+
return fill ?? { kind: "raw", raw: makeSidecar("a:pattFill", pattern, nextId) };
|
|
8149
|
+
}
|
|
8150
|
+
for (const name of RAW_FILL_LOCAL_NAMES) {
|
|
8151
|
+
if (hasChild(parent, name)) {
|
|
8152
|
+
return { kind: "raw", raw: makeSidecar(`a:${name}`, getChild(parent, name) ?? {}, nextId) };
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
return void 0;
|
|
8156
|
+
}
|
|
8157
|
+
function parseGradientFill(grad) {
|
|
8158
|
+
const stops = [];
|
|
8159
|
+
for (const gs of getChildArray(getChild(grad, "gsLst"), "gs")) {
|
|
8160
|
+
const color = parseColorElement(gs);
|
|
8161
|
+
if (color === void 0) continue;
|
|
8162
|
+
stops.push({
|
|
8163
|
+
position: (numericAttr2(gs, "pos") ?? 0) / 1e5,
|
|
8164
|
+
color
|
|
8165
|
+
});
|
|
8166
|
+
}
|
|
8167
|
+
if (stops.length === 0) return void 0;
|
|
8168
|
+
const path = getChild(grad, "path");
|
|
8169
|
+
if (path !== void 0) {
|
|
8170
|
+
const fillToRect = getChild(path, "fillToRect");
|
|
8171
|
+
const l = numericAttr2(fillToRect, "l") ?? 0;
|
|
8172
|
+
const t = numericAttr2(fillToRect, "t") ?? 0;
|
|
8173
|
+
const r = numericAttr2(fillToRect, "r") ?? 0;
|
|
8174
|
+
const b = numericAttr2(fillToRect, "b") ?? 0;
|
|
8175
|
+
return {
|
|
8176
|
+
kind: "gradient",
|
|
8177
|
+
gradientType: "radial",
|
|
8178
|
+
stops,
|
|
8179
|
+
centerX: (l + (1e5 - r)) / 2 / 1e5,
|
|
8180
|
+
centerY: (t + (1e5 - b)) / 2 / 1e5
|
|
8181
|
+
};
|
|
8182
|
+
}
|
|
8183
|
+
return {
|
|
8184
|
+
kind: "gradient",
|
|
8185
|
+
gradientType: "linear",
|
|
8186
|
+
stops,
|
|
8187
|
+
angle: asOoxmlAngle(numericAttr2(getChild(grad, "lin"), "ang") ?? 0)
|
|
8190
8188
|
};
|
|
8191
8189
|
}
|
|
8192
|
-
function
|
|
8193
|
-
const
|
|
8194
|
-
const
|
|
8195
|
-
|
|
8196
|
-
const
|
|
8197
|
-
if (left === void 0 && right === void 0 && top === void 0 && bottom === void 0) {
|
|
8198
|
-
return void 0;
|
|
8199
|
-
}
|
|
8190
|
+
function parseBlipFill(blipFill) {
|
|
8191
|
+
const blip = getChild(blipFill, "blip");
|
|
8192
|
+
const embed = getNamespacedAttr(blip, "embed");
|
|
8193
|
+
if (embed === void 0) return void 0;
|
|
8194
|
+
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
8200
8195
|
return {
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
...
|
|
8204
|
-
...right !== void 0 ? { right } : {}
|
|
8196
|
+
kind: "image",
|
|
8197
|
+
blipRelationshipId: asRelationshipId(embed),
|
|
8198
|
+
...tile !== void 0 ? { tile } : {}
|
|
8205
8199
|
};
|
|
8206
8200
|
}
|
|
8207
|
-
function
|
|
8208
|
-
|
|
8201
|
+
function parseImageFillTile(tile) {
|
|
8202
|
+
if (tile === void 0) return void 0;
|
|
8203
|
+
const flip = getAttr(tile, "flip") ?? "none";
|
|
8209
8204
|
return {
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8205
|
+
tx: asEmu2(numericAttr2(tile, "tx") ?? 0),
|
|
8206
|
+
ty: asEmu2(numericAttr2(tile, "ty") ?? 0),
|
|
8207
|
+
sx: (numericAttr2(tile, "sx") ?? 1e5) / 1e5,
|
|
8208
|
+
sy: (numericAttr2(tile, "sy") ?? 1e5) / 1e5,
|
|
8209
|
+
flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
|
|
8210
|
+
align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
|
|
8214
8211
|
};
|
|
8215
8212
|
}
|
|
8216
|
-
function
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8213
|
+
function parseRectangleAlignment(value, fallback) {
|
|
8214
|
+
return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
|
|
8215
|
+
}
|
|
8216
|
+
function parsePatternFill(pattern) {
|
|
8217
|
+
const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
|
|
8218
|
+
const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
|
|
8219
|
+
if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
|
|
8221
8220
|
return {
|
|
8222
|
-
|
|
8223
|
-
|
|
8221
|
+
kind: "pattern",
|
|
8222
|
+
preset: getAttr(pattern, "prst") ?? "ltDnDiag",
|
|
8223
|
+
foregroundColor,
|
|
8224
|
+
backgroundColor
|
|
8224
8225
|
};
|
|
8225
8226
|
}
|
|
8226
|
-
function
|
|
8227
|
-
const
|
|
8228
|
-
|
|
8229
|
-
const preset = getAttr(prstGeom, "prst");
|
|
8230
|
-
const adjustValues = parseAdjustValues(getChild(prstGeom, "avLst"));
|
|
8231
|
-
return preset !== void 0 ? {
|
|
8232
|
-
preset,
|
|
8233
|
-
...Object.keys(adjustValues).length > 0 ? { adjustValues } : {}
|
|
8234
|
-
} : void 0;
|
|
8235
|
-
}
|
|
8236
|
-
const customPaths = parseCustomGeometry(
|
|
8237
|
-
getChild(spPr, "custGeom"),
|
|
8238
|
-
orderedChildChildren2(orderedSpPr, "custGeom")
|
|
8239
|
-
);
|
|
8240
|
-
if (customPaths !== void 0) return { kind: "custom", paths: customPaths };
|
|
8241
|
-
return void 0;
|
|
8227
|
+
function parseOutline(spPr, nextId) {
|
|
8228
|
+
const ln = getChild(spPr, "ln");
|
|
8229
|
+
return parseLine(ln, nextId);
|
|
8242
8230
|
}
|
|
8243
|
-
function
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
return
|
|
8231
|
+
function parseLine(ln, nextId) {
|
|
8232
|
+
if (!ln) return void 0;
|
|
8233
|
+
const width = numericAttr2(ln, "w");
|
|
8234
|
+
const fill = parseFill(ln, nextId);
|
|
8235
|
+
const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
|
|
8236
|
+
const customDash = parseCustomDash(ln);
|
|
8237
|
+
const lineCap = parseLineCap(getAttr(ln, "cap"));
|
|
8238
|
+
const lineJoin = parseLineJoin(ln);
|
|
8239
|
+
const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
|
|
8240
|
+
const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
|
|
8241
|
+
return {
|
|
8242
|
+
...width !== void 0 ? { width: asEmu2(width) } : {},
|
|
8243
|
+
...fill !== void 0 ? { fill } : {},
|
|
8244
|
+
...dashStyle !== void 0 ? { dashStyle } : {},
|
|
8245
|
+
...customDash !== void 0 ? { customDash } : {},
|
|
8246
|
+
...lineCap !== void 0 ? { lineCap } : {},
|
|
8247
|
+
...lineJoin !== void 0 ? { lineJoin } : {},
|
|
8248
|
+
...headEnd !== void 0 ? { headEnd } : {},
|
|
8249
|
+
...tailEnd !== void 0 ? { tailEnd } : {}
|
|
8250
|
+
};
|
|
8254
8251
|
}
|
|
8255
|
-
function
|
|
8256
|
-
const xfrm = getChild(
|
|
8257
|
-
|
|
8258
|
-
const
|
|
8259
|
-
const
|
|
8260
|
-
const
|
|
8261
|
-
const
|
|
8262
|
-
const
|
|
8263
|
-
|
|
8252
|
+
function parseTransform(spPr) {
|
|
8253
|
+
const xfrm = getChild(spPr, "xfrm");
|
|
8254
|
+
if (!xfrm) return void 0;
|
|
8255
|
+
const off = getChild(xfrm, "off");
|
|
8256
|
+
const ext = getChild(xfrm, "ext");
|
|
8257
|
+
const offsetX = numericAttr2(off, "x");
|
|
8258
|
+
const offsetY = numericAttr2(off, "y");
|
|
8259
|
+
const width = numericAttr2(ext, "cx");
|
|
8260
|
+
const height = numericAttr2(ext, "cy");
|
|
8261
|
+
if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
|
|
8262
|
+
return void 0;
|
|
8263
|
+
}
|
|
8264
|
+
const rotation = numericAttr2(xfrm, "rot");
|
|
8265
|
+
const flipH = getAttr(xfrm, "flipH");
|
|
8266
|
+
const flipV = getAttr(xfrm, "flipV");
|
|
8264
8267
|
return {
|
|
8265
8268
|
offsetX: asEmu2(offsetX),
|
|
8266
8269
|
offsetY: asEmu2(offsetY),
|
|
8267
|
-
width: asEmu2(
|
|
8268
|
-
height: asEmu2(
|
|
8270
|
+
width: asEmu2(width),
|
|
8271
|
+
height: asEmu2(height),
|
|
8272
|
+
...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
|
|
8273
|
+
...isTrue(flipH) ? { flipHorizontal: true } : {},
|
|
8274
|
+
...isTrue(flipV) ? { flipVertical: true } : {}
|
|
8269
8275
|
};
|
|
8270
8276
|
}
|
|
8271
|
-
function
|
|
8272
|
-
|
|
8273
|
-
const
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8277
|
+
function withTransforms(base, colorNode) {
|
|
8278
|
+
const transforms = [];
|
|
8279
|
+
for (const key of Object.keys(colorNode)) {
|
|
8280
|
+
if (key.startsWith("@_")) continue;
|
|
8281
|
+
const kind = localName(key);
|
|
8282
|
+
const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
|
|
8283
|
+
if (transformKind === void 0) continue;
|
|
8284
|
+
const value = colorNode[key];
|
|
8285
|
+
const items = Array.isArray(value) ? value : [value];
|
|
8286
|
+
for (const item of items) {
|
|
8287
|
+
const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
|
|
8288
|
+
if (raw === void 0) continue;
|
|
8289
|
+
const numeric = Number(raw);
|
|
8290
|
+
if (!Number.isFinite(numeric)) continue;
|
|
8291
|
+
transforms.push({
|
|
8292
|
+
kind: transformKind,
|
|
8293
|
+
value: asOoxmlPercent(numeric)
|
|
8294
|
+
});
|
|
8295
|
+
}
|
|
8296
|
+
}
|
|
8297
|
+
return transforms.length > 0 ? { ...base, transforms } : base;
|
|
8284
8298
|
}
|
|
8285
|
-
function
|
|
8286
|
-
const
|
|
8287
|
-
if (
|
|
8288
|
-
const
|
|
8289
|
-
|
|
8290
|
-
const right = (numericAttr(fillRect, "r") ?? 0) / 1e5;
|
|
8291
|
-
const bottom = (numericAttr(fillRect, "b") ?? 0) / 1e5;
|
|
8292
|
-
if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
|
|
8293
|
-
return { left, top, right, bottom };
|
|
8299
|
+
function numericAttr2(node, name) {
|
|
8300
|
+
const raw = getAttr(node, name);
|
|
8301
|
+
if (raw === void 0) return void 0;
|
|
8302
|
+
const value = Number(raw);
|
|
8303
|
+
return Number.isFinite(value) ? value : void 0;
|
|
8294
8304
|
}
|
|
8295
|
-
function
|
|
8296
|
-
|
|
8297
|
-
return id !== void 0 ? asSourceNodeId(id) : void 0;
|
|
8305
|
+
function isTrue(value) {
|
|
8306
|
+
return value === "1" || value === "true";
|
|
8298
8307
|
}
|
|
8299
|
-
function
|
|
8300
|
-
|
|
8308
|
+
function parseDashStyle(prstDash) {
|
|
8309
|
+
const value = getAttr(prstDash, "val");
|
|
8310
|
+
return parseEnumValue(value, DASH_STYLES);
|
|
8301
8311
|
}
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
const
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
const value = key !== void 0 ? child[key] : void 0;
|
|
8311
|
-
return Array.isArray(value) ? value : void 0;
|
|
8312
|
+
function parseCustomDash(ln) {
|
|
8313
|
+
const custDash = getChild(ln, "custDash");
|
|
8314
|
+
const segments = getChildArray(custDash, "ds");
|
|
8315
|
+
if (segments.length === 0) return void 0;
|
|
8316
|
+
return segments.flatMap((segment) => [
|
|
8317
|
+
(numericAttr2(segment, "d") ?? 1e5) / 1e5,
|
|
8318
|
+
(numericAttr2(segment, "sp") ?? 1e5) / 1e5
|
|
8319
|
+
]);
|
|
8312
8320
|
}
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
const value = key !== void 0 ? entry[key] : void 0;
|
|
8321
|
-
return Array.isArray(value) ? value : void 0;
|
|
8322
|
-
});
|
|
8321
|
+
var LINE_CAP_MAP = {
|
|
8322
|
+
flat: "butt",
|
|
8323
|
+
sq: "square",
|
|
8324
|
+
rnd: "round"
|
|
8325
|
+
};
|
|
8326
|
+
function parseLineCap(value) {
|
|
8327
|
+
return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
|
|
8323
8328
|
}
|
|
8324
|
-
function
|
|
8325
|
-
if (
|
|
8326
|
-
|
|
8327
|
-
return
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8329
|
+
function parseLineJoin(ln) {
|
|
8330
|
+
if (hasChild(ln, "round")) return "round";
|
|
8331
|
+
if (hasChild(ln, "bevel")) return "bevel";
|
|
8332
|
+
if (hasChild(ln, "miter")) return "miter";
|
|
8333
|
+
return void 0;
|
|
8334
|
+
}
|
|
8335
|
+
function parseArrowEndpoint(node) {
|
|
8336
|
+
if (!node) return void 0;
|
|
8337
|
+
const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES2);
|
|
8338
|
+
if (type === void 0) return void 0;
|
|
8339
|
+
const width = getAttr(node, "w") ?? "med";
|
|
8340
|
+
const length = getAttr(node, "len") ?? "med";
|
|
8341
|
+
return {
|
|
8342
|
+
type,
|
|
8343
|
+
width: parseEnumValueWithDefault(width, ARROW_SIZES2, "med"),
|
|
8344
|
+
length: parseEnumValueWithDefault(length, ARROW_SIZES2, "med")
|
|
8345
|
+
};
|
|
8331
8346
|
}
|
|
8347
|
+
var DASH_STYLES = /* @__PURE__ */ new Set([
|
|
8348
|
+
"solid",
|
|
8349
|
+
"dash",
|
|
8350
|
+
"dot",
|
|
8351
|
+
"dashDot",
|
|
8352
|
+
"lgDash",
|
|
8353
|
+
"lgDashDot",
|
|
8354
|
+
"sysDash",
|
|
8355
|
+
"sysDot"
|
|
8356
|
+
]);
|
|
8357
|
+
var ARROW_TYPES2 = /* @__PURE__ */ new Set([
|
|
8358
|
+
"triangle",
|
|
8359
|
+
"stealth",
|
|
8360
|
+
"diamond",
|
|
8361
|
+
"oval",
|
|
8362
|
+
"arrow"
|
|
8363
|
+
]);
|
|
8364
|
+
var ARROW_SIZES2 = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
|
|
8332
8365
|
var DEFAULT_COLOR_MAP = {
|
|
8333
8366
|
bg1: "lt1",
|
|
8334
8367
|
tx1: "dk1",
|
|
@@ -8747,7 +8780,7 @@ var DIAGRAM_DRAWING_REL_TYPES = /* @__PURE__ */ new Set([
|
|
|
8747
8780
|
"http://schemas.microsoft.com/office/2007/relationships/diagramDrawing",
|
|
8748
8781
|
"http://purl.oclc.org/ooxml/officeDocument/relationships/diagramDrawing"
|
|
8749
8782
|
]);
|
|
8750
|
-
var
|
|
8783
|
+
var textDecoder2 = new TextDecoder();
|
|
8751
8784
|
var DEFAULT_TABLE_STYLE_BORDERS = {
|
|
8752
8785
|
top: {
|
|
8753
8786
|
width: asEmu2(12700),
|
|
@@ -9458,7 +9491,7 @@ function isEmptyPlaceholder(shape) {
|
|
|
9458
9491
|
}
|
|
9459
9492
|
function readRawPackageText(source, partPath) {
|
|
9460
9493
|
const rawPart = source.packageGraph.rawParts?.find((part) => part.partPath === partPath);
|
|
9461
|
-
if (rawPart?.kind === "binary") return
|
|
9494
|
+
if (rawPart?.kind === "binary") return textDecoder2.decode(rawPart.bytes);
|
|
9462
9495
|
return void 0;
|
|
9463
9496
|
}
|
|
9464
9497
|
function numericAttr3(node, attrName) {
|
|
@@ -9585,7 +9618,7 @@ function parseBackground(bg, nextId) {
|
|
|
9585
9618
|
const bgRef = getChild(bg, "bgRef");
|
|
9586
9619
|
if (bgRef) {
|
|
9587
9620
|
const color = parseColorElement(bgRef);
|
|
9588
|
-
const index =
|
|
9621
|
+
const index = numericAttr2(bgRef, "idx");
|
|
9589
9622
|
if (color !== void 0) {
|
|
9590
9623
|
return { kind: "styleReference", index: index ?? 0, color };
|
|
9591
9624
|
}
|
|
@@ -9715,9 +9748,9 @@ function parseOuterShadow2(node) {
|
|
|
9715
9748
|
const color = parseColorElement(node);
|
|
9716
9749
|
if (node === void 0 || color === void 0) return void 0;
|
|
9717
9750
|
return {
|
|
9718
|
-
blurRadius: asEmu2(
|
|
9719
|
-
distance: asEmu2(
|
|
9720
|
-
direction: asOoxmlAngle(
|
|
9751
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
9752
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
9753
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
9721
9754
|
color,
|
|
9722
9755
|
alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
|
|
9723
9756
|
rotateWithShape: getAttr(node, "rotWithShape") !== "0"
|
|
@@ -9727,9 +9760,9 @@ function parseInnerShadow2(node) {
|
|
|
9727
9760
|
const color = parseColorElement(node);
|
|
9728
9761
|
if (node === void 0 || color === void 0) return void 0;
|
|
9729
9762
|
return {
|
|
9730
|
-
blurRadius: asEmu2(
|
|
9731
|
-
distance: asEmu2(
|
|
9732
|
-
direction: asOoxmlAngle(
|
|
9763
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
9764
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
9765
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
9733
9766
|
color
|
|
9734
9767
|
};
|
|
9735
9768
|
}
|
|
@@ -9737,14 +9770,14 @@ function parseGlow2(node) {
|
|
|
9737
9770
|
const color = parseColorElement(node);
|
|
9738
9771
|
if (node === void 0 || color === void 0) return void 0;
|
|
9739
9772
|
return {
|
|
9740
|
-
radius: asEmu2(
|
|
9773
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0),
|
|
9741
9774
|
color
|
|
9742
9775
|
};
|
|
9743
9776
|
}
|
|
9744
9777
|
function parseSoftEdge2(node) {
|
|
9745
9778
|
if (node === void 0) return void 0;
|
|
9746
9779
|
return {
|
|
9747
|
-
radius: asEmu2(
|
|
9780
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0)
|
|
9748
9781
|
};
|
|
9749
9782
|
}
|
|
9750
9783
|
function booleanAttr(node, name) {
|
|
@@ -9763,7 +9796,7 @@ var SLIDE_LAYOUT_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2
|
|
|
9763
9796
|
var SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
|
9764
9797
|
var THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
9765
9798
|
var PRESENTATION_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
|
|
9766
|
-
var
|
|
9799
|
+
var textDecoder3 = new TextDecoder();
|
|
9767
9800
|
function readPptx(input) {
|
|
9768
9801
|
const entries = unzipPackage(input);
|
|
9769
9802
|
const diagnostics = [];
|
|
@@ -9914,7 +9947,7 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
|
|
|
9914
9947
|
});
|
|
9915
9948
|
return void 0;
|
|
9916
9949
|
}
|
|
9917
|
-
const xml =
|
|
9950
|
+
const xml = textDecoder3.decode(bytes);
|
|
9918
9951
|
const root = getChild(parseXml(xml), rootLocalName);
|
|
9919
9952
|
if (root === void 0) {
|
|
9920
9953
|
diagnostics.push({
|
|
@@ -9965,7 +9998,7 @@ function unzipPackage(input) {
|
|
|
9965
9998
|
function readContentTypes(entries) {
|
|
9966
9999
|
const bytes = entries.get(CONTENT_TYPES_PART);
|
|
9967
10000
|
if (!bytes) return { defaults: [], overrides: [] };
|
|
9968
|
-
const root = getChild(parseXml(
|
|
10001
|
+
const root = getChild(parseXml(textDecoder3.decode(bytes)), "Types");
|
|
9969
10002
|
const defaults = [];
|
|
9970
10003
|
for (const node of getChildArray(root, "Default")) {
|
|
9971
10004
|
const extension = getAttr(node, "Extension");
|
|
@@ -9986,7 +10019,7 @@ function readRelationships(entries) {
|
|
|
9986
10019
|
const result = [];
|
|
9987
10020
|
for (const [path, bytes] of entries) {
|
|
9988
10021
|
if (!isRelationshipPart(path)) continue;
|
|
9989
|
-
const root = getChild(parseXml(
|
|
10022
|
+
const root = getChild(parseXml(textDecoder3.decode(bytes)), "Relationships");
|
|
9990
10023
|
const relationships = [];
|
|
9991
10024
|
for (const node of getChildArray(root, "Relationship")) {
|
|
9992
10025
|
const id = getAttr(node, "Id");
|
|
@@ -10017,7 +10050,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
|
|
|
10017
10050
|
);
|
|
10018
10051
|
}
|
|
10019
10052
|
const presentationPartPath = asPartPath(presentationPath);
|
|
10020
|
-
const root = getChild(parseXml(
|
|
10053
|
+
const root = getChild(parseXml(textDecoder3.decode(bytes)), "presentation");
|
|
10021
10054
|
if (root === void 0) {
|
|
10022
10055
|
throw new Error(
|
|
10023
10056
|
`readPptx: part '${presentationPath}' is not a presentation part (missing p:presentation root)`
|
|
@@ -10114,8 +10147,8 @@ function stripLeadingSlash(path) {
|
|
|
10114
10147
|
return path.startsWith("/") ? path.slice(1) : path;
|
|
10115
10148
|
}
|
|
10116
10149
|
var textEncoder = new TextEncoder();
|
|
10117
|
-
var
|
|
10118
|
-
var
|
|
10150
|
+
var textDecoder4 = new TextDecoder();
|
|
10151
|
+
var xmlBuilder2 = new import_fast_xml_parser3.XMLBuilder({
|
|
10119
10152
|
ignoreAttributes: false,
|
|
10120
10153
|
attributeNamePrefix: "@_",
|
|
10121
10154
|
format: false,
|