@office-open/docx 0.10.0 → 0.10.2
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/{context-D9RMvxSu.mjs → context-vnFOOEWL.mjs} +28 -3
- package/dist/context-vnFOOEWL.mjs.map +1 -0
- package/dist/{core-properties-DNjQDzBy.d.mts → core-properties-CcpNQvVY.d.mts} +315 -96
- package/dist/core-properties-CcpNQvVY.d.mts.map +1 -0
- package/dist/{generate-h0Xp5BPT.mjs → generate-DQkv8c9y.mjs} +13 -8
- package/dist/generate-DQkv8c9y.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +2 -29
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{parse-T79KhZTq.mjs → parse-ZZPID0vi.mjs} +47 -33
- package/dist/parse-ZZPID0vi.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/{parts-BWmkYaBr.mjs → parts-DvRRYUug.mjs} +1488 -402
- package/dist/parts-DvRRYUug.mjs.map +1 -0
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-D9RMvxSu.mjs.map +0 -1
- package/dist/core-properties-DNjQDzBy.d.mts.map +0 -1
- package/dist/generate-h0Xp5BPT.mjs.map +0 -1
- package/dist/parse-T79KhZTq.mjs.map +0 -1
- package/dist/parts-BWmkYaBr.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, appPropertiesDesc, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, customPropertiesDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
|
|
2
|
-
import { attr, attrBool, attrNum, children, colorAttr, element, escapeXml, findChild, findDeep, stringify, textOf } from "@office-open/xml";
|
|
3
|
-
import { calculateEffectExtent, createColorElement, createEffectDag, createScene3D, createShape3D, customGeometryDesc as customGeometryDesc$1, effectListDesc as effectListDesc$1, extractBlipFillMedia, fillDesc as fillDesc$1, outlineDesc as outlineDesc$1, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
|
|
1
|
+
import { DOCX_PARTS, Relationships, TargetModeType, ThemeColor, appPropertiesDesc, blipDesc, buildContentTypeOverrides, convertEmuToPixels, convertInchesToTwip, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, customGeometryDesc, customPropertiesDesc, decimalNumber, derivePasswordHash, effectListDesc, eighthPointMeasureValue, fillDesc, hexColorValue, hpsMeasureValue, measurementOrPercentValue, outlineDesc, parseColorChoice, pointMeasureValue, presetGeometryDesc, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdVerticalMergeRev } from "@office-open/core";
|
|
2
|
+
import { attr, attrBool, attrMeasure, attrNum, children, colorAttr, element, escapeXml, findChild, findDeep, stringify, textOf } from "@office-open/xml";
|
|
3
|
+
import { calculateEffectExtent, createColorElement, createEffectDag, createScene3D, createShape3D, customGeometryDesc as customGeometryDesc$1, effectListDesc as effectListDesc$1, extractBlipFillMedia, fillDesc as fillDesc$1, outlineDesc as outlineDesc$1, presetGeometryDesc as presetGeometryDesc$1, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
|
|
4
4
|
import { chartSpaceDesc } from "@office-open/core/chart";
|
|
5
5
|
import { createDataModel } from "@office-open/core/smartart";
|
|
6
6
|
//#region src/parts/paragraph/formatting/alignment.ts
|
|
@@ -76,16 +76,6 @@ const AlignmentType = {
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/parts/paragraph/formatting/spacing.ts
|
|
78
78
|
/**
|
|
79
|
-
* Paragraph spacing module for WordprocessingML documents.
|
|
80
|
-
*
|
|
81
|
-
* This module provides spacing options for paragraphs including space before,
|
|
82
|
-
* space after, and line spacing.
|
|
83
|
-
*
|
|
84
|
-
* Reference: http://officeopenxml.com/WPspacing.php
|
|
85
|
-
*
|
|
86
|
-
* @module
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
79
|
* Line spacing rule types.
|
|
90
80
|
*
|
|
91
81
|
* Specifies how the line height is calculated.
|
|
@@ -177,6 +167,18 @@ const TextboxTightWrapType = {
|
|
|
177
167
|
//#endregion
|
|
178
168
|
//#region src/parts/paragraph/run/run.ts
|
|
179
169
|
/**
|
|
170
|
+
* Serialize a break option (count shorthand or structured with clear) to one or
|
|
171
|
+
* more `<w:br/>` tags.
|
|
172
|
+
*/
|
|
173
|
+
function breakXml(breakOpt) {
|
|
174
|
+
if (!breakOpt) return "";
|
|
175
|
+
const count = typeof breakOpt === "number" ? breakOpt : breakOpt.count ?? 1;
|
|
176
|
+
if (count <= 0) return "";
|
|
177
|
+
const clear = typeof breakOpt === "object" ? breakOpt.clear : void 0;
|
|
178
|
+
const one = clear ? `<w:br w:clear="${clear}"/>` : "<w:br/>";
|
|
179
|
+
return count === 1 ? one : one.repeat(count);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
180
182
|
* Constants for page number field types.
|
|
181
183
|
*
|
|
182
184
|
* These values are used to insert dynamic page number fields into a document.
|
|
@@ -570,13 +572,13 @@ const parseBodyProperties = (el) => {
|
|
|
570
572
|
if (vert !== void 0) result.vert = vert;
|
|
571
573
|
const wrap = attr(el, "wrap");
|
|
572
574
|
if (wrap !== void 0) result.wrap = wrap;
|
|
573
|
-
const lIns =
|
|
575
|
+
const lIns = attrMeasure(el, "lIns");
|
|
574
576
|
if (lIns !== void 0) result.lIns = lIns;
|
|
575
|
-
const tIns =
|
|
577
|
+
const tIns = attrMeasure(el, "tIns");
|
|
576
578
|
if (tIns !== void 0) result.tIns = tIns;
|
|
577
|
-
const rIns =
|
|
579
|
+
const rIns = attrMeasure(el, "rIns");
|
|
578
580
|
if (rIns !== void 0) result.rIns = rIns;
|
|
579
|
-
const bIns =
|
|
581
|
+
const bIns = attrMeasure(el, "bIns");
|
|
580
582
|
if (bIns !== void 0) result.bIns = bIns;
|
|
581
583
|
const numCol = attrNum(el, "numCol");
|
|
582
584
|
if (numCol !== void 0) result.numCol = numCol;
|
|
@@ -1328,6 +1330,149 @@ const WidthType = {
|
|
|
1328
1330
|
PERCENTAGE: "pct"
|
|
1329
1331
|
};
|
|
1330
1332
|
//#endregion
|
|
1333
|
+
//#region src/parts/object/object-element.ts
|
|
1334
|
+
/**
|
|
1335
|
+
* Object element for WordprocessingML documents — w:object.
|
|
1336
|
+
*
|
|
1337
|
+
* Embeds an OLE object (e.g. an Excel sheet) in a run via a VML preview shape and
|
|
1338
|
+
* exactly one of objectEmbed / objectLink / control / movie. The OLE binary is
|
|
1339
|
+
* registered as word/embeddings/oleObjectN.bin (EmbeddingCollection); the optional
|
|
1340
|
+
* preview icon as word/media/imageN.<type> (Media). Relationship ids are emitted
|
|
1341
|
+
* as `{fileName}` placeholders and rewritten by the compiler's media bridge.
|
|
1342
|
+
*
|
|
1343
|
+
* Reference: OOXML transitional, wml.xsd, CT_Object / CT_ObjectEmbed / CT_ObjectLink
|
|
1344
|
+
*
|
|
1345
|
+
* @module
|
|
1346
|
+
*/
|
|
1347
|
+
let objectShapeCounter = 1025;
|
|
1348
|
+
const objectDesc = {
|
|
1349
|
+
kind: "custom",
|
|
1350
|
+
stringify(opts, ctx) {
|
|
1351
|
+
const inner = [];
|
|
1352
|
+
const shapeId = opts.shapeId ?? `_x0000_i${objectShapeCounter++}`;
|
|
1353
|
+
const widthVal = opts.width ?? 100;
|
|
1354
|
+
const heightVal = opts.height ?? 100;
|
|
1355
|
+
const styleWidth = typeof widthVal === "number" ? `${widthVal}px` : widthVal;
|
|
1356
|
+
const styleHeight = typeof heightVal === "number" ? `${heightVal}px` : heightVal;
|
|
1357
|
+
const shapeChildren = [];
|
|
1358
|
+
if (opts.iconImage) {
|
|
1359
|
+
const iconFileName = ctx.file.media.nextMediaName(opts.iconImage.type);
|
|
1360
|
+
const iconMediaData = {
|
|
1361
|
+
type: opts.iconImage.type,
|
|
1362
|
+
...createImageData$1(toUint8Array(opts.iconImage.data), {
|
|
1363
|
+
width: widthVal,
|
|
1364
|
+
height: heightVal
|
|
1365
|
+
}, iconFileName)
|
|
1366
|
+
};
|
|
1367
|
+
ctx.file.media.addImage(iconFileName, iconMediaData);
|
|
1368
|
+
const titleAttr = opts.iconImage.title ? ` o:title="${opts.iconImage.title}"` : "";
|
|
1369
|
+
shapeChildren.push(`<v:imagedata r:id="{${iconFileName}}"${titleAttr}/>`);
|
|
1370
|
+
}
|
|
1371
|
+
inner.push(`<v:shape id="${shapeId}" type="#_x0000_t75" style="width:${styleWidth};height:${styleHeight}">${shapeChildren.join("")}</v:shape>`);
|
|
1372
|
+
if (opts.embed) {
|
|
1373
|
+
const fileName = registerEmbedding(opts.embed, ctx);
|
|
1374
|
+
inner.push(`<w:objectEmbed r:id="{${fileName}}"${embedAttrs(opts.embed)}/>`);
|
|
1375
|
+
} else if (opts.link) {
|
|
1376
|
+
const fileName = registerEmbedding(opts.link, ctx);
|
|
1377
|
+
const locked = opts.link.lockedField ? ` w:lockedField="true"` : "";
|
|
1378
|
+
inner.push(`<w:objectLink r:id="{${fileName}}"${embedAttrs(opts.link)} w:updateMode="${opts.link.updateMode}"${locked}/>`);
|
|
1379
|
+
} else if (opts.control) {
|
|
1380
|
+
const c = opts.control;
|
|
1381
|
+
const cAttrs = [` r:id="${c.rId}"`];
|
|
1382
|
+
if (c.name) cAttrs.push(` w:name="${c.name}"`);
|
|
1383
|
+
if (c.shapeid) cAttrs.push(` w:shapeid="${c.shapeid}"`);
|
|
1384
|
+
inner.push(`<w:control${cAttrs.join("")}/>`);
|
|
1385
|
+
} else if (opts.movie) inner.push(`<w:movie r:id="${opts.movie}"/>`);
|
|
1386
|
+
const objAttrs = [];
|
|
1387
|
+
if (opts.dxaOrig !== void 0) objAttrs.push(` w:dxaOrig="${opts.dxaOrig}"`);
|
|
1388
|
+
if (opts.dyaOrig !== void 0) objAttrs.push(` w:dyaOrig="${opts.dyaOrig}"`);
|
|
1389
|
+
return `<w:object${objAttrs.join("")}>${inner.join("")}</w:object>`;
|
|
1390
|
+
},
|
|
1391
|
+
parse(el, _ctx) {
|
|
1392
|
+
const result = {};
|
|
1393
|
+
const dxaOrig = attrNum(el, "w:dxaOrig");
|
|
1394
|
+
if (dxaOrig !== void 0) result.dxaOrig = dxaOrig;
|
|
1395
|
+
const dyaOrig = attrNum(el, "w:dyaOrig");
|
|
1396
|
+
if (dyaOrig !== void 0) result.dyaOrig = dyaOrig;
|
|
1397
|
+
const shape = findChild(el, "v:shape");
|
|
1398
|
+
if (shape) {
|
|
1399
|
+
const id = attr(shape, "id");
|
|
1400
|
+
if (id) result.shapeId = id;
|
|
1401
|
+
const style = attr(shape, "style");
|
|
1402
|
+
if (style) {
|
|
1403
|
+
const w = style.match(/width:([^;]+)/);
|
|
1404
|
+
const h = style.match(/height:([^;]+)/);
|
|
1405
|
+
if (w) result.width = w[1].trim();
|
|
1406
|
+
if (h) result.height = h[1].trim();
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
const embedEl = findChild(el, "w:objectEmbed");
|
|
1410
|
+
if (embedEl) result.embed = parseEmbed(embedEl);
|
|
1411
|
+
const linkEl = findChild(el, "w:objectLink");
|
|
1412
|
+
if (linkEl) {
|
|
1413
|
+
const base = parseEmbed(linkEl);
|
|
1414
|
+
const updateMode = attr(linkEl, "w:updateMode");
|
|
1415
|
+
const lockedField = attr(linkEl, "w:lockedField");
|
|
1416
|
+
result.link = {
|
|
1417
|
+
...base,
|
|
1418
|
+
...updateMode ? { updateMode } : {},
|
|
1419
|
+
...lockedField !== void 0 ? { lockedField: lockedField === "true" || lockedField === "1" } : {}
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
const controlEl = findChild(el, "w:control");
|
|
1423
|
+
if (controlEl) {
|
|
1424
|
+
const rId = attr(controlEl, "r:id") ?? "";
|
|
1425
|
+
const name = attr(controlEl, "w:name");
|
|
1426
|
+
const shapeid = attr(controlEl, "w:shapeid");
|
|
1427
|
+
result.control = {
|
|
1428
|
+
rId,
|
|
1429
|
+
...name ? { name } : {},
|
|
1430
|
+
...shapeid ? { shapeid } : {}
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
const movieEl = findChild(el, "w:movie");
|
|
1434
|
+
if (movieEl) {
|
|
1435
|
+
const rId = attr(movieEl, "r:id");
|
|
1436
|
+
if (rId) result.movie = rId;
|
|
1437
|
+
}
|
|
1438
|
+
return result;
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
/** Register an OLE embedding and return its allocated file name. */
|
|
1442
|
+
function registerEmbedding(opts, ctx) {
|
|
1443
|
+
const fileName = ctx.file.embeddings.nextEmbeddingName();
|
|
1444
|
+
const data = {
|
|
1445
|
+
fileName,
|
|
1446
|
+
data: toUint8Array(opts.data),
|
|
1447
|
+
...opts.progId ? { progId: opts.progId } : {}
|
|
1448
|
+
};
|
|
1449
|
+
ctx.file.embeddings.addEmbedding(fileName, data);
|
|
1450
|
+
return fileName;
|
|
1451
|
+
}
|
|
1452
|
+
/** Build the common objectEmbed/objectLink attribute string (excludes r:id). */
|
|
1453
|
+
function embedAttrs(opts) {
|
|
1454
|
+
const attrs = [];
|
|
1455
|
+
if (opts.drawAspect) attrs.push(` w:drawAspect="${opts.drawAspect}"`);
|
|
1456
|
+
if (opts.progId) attrs.push(` w:progId="${opts.progId}"`);
|
|
1457
|
+
if (opts.shapeId) attrs.push(` w:shapeId="${opts.shapeId}"`);
|
|
1458
|
+
if (opts.fieldCodes) attrs.push(` w:fieldCodes="${opts.fieldCodes}"`);
|
|
1459
|
+
return attrs.join("");
|
|
1460
|
+
}
|
|
1461
|
+
/** Parse common objectEmbed/objectLink attributes (excludes r:id — external on parse). */
|
|
1462
|
+
function parseEmbed(el) {
|
|
1463
|
+
const opts = {};
|
|
1464
|
+
const drawAspect = attr(el, "w:drawAspect");
|
|
1465
|
+
if (drawAspect === "content" || drawAspect === "icon") opts.drawAspect = drawAspect;
|
|
1466
|
+
const progId = attr(el, "w:progId");
|
|
1467
|
+
if (progId) opts.progId = progId;
|
|
1468
|
+
const shapeId = attr(el, "w:shapeId");
|
|
1469
|
+
if (shapeId) opts.shapeId = shapeId;
|
|
1470
|
+
const fieldCodes = attr(el, "w:fieldCodes");
|
|
1471
|
+
if (fieldCodes) opts.fieldCodes = fieldCodes;
|
|
1472
|
+
opts.data = new Uint8Array();
|
|
1473
|
+
return opts;
|
|
1474
|
+
}
|
|
1475
|
+
//#endregion
|
|
1331
1476
|
//#region src/util/stringify-element.ts
|
|
1332
1477
|
/**
|
|
1333
1478
|
* Element-to-XML serialization helpers shared across the parse layer.
|
|
@@ -1489,7 +1634,7 @@ function parseRunProperties(el) {
|
|
|
1489
1634
|
}
|
|
1490
1635
|
const spacing = findChild(el, "w:spacing");
|
|
1491
1636
|
if (spacing) {
|
|
1492
|
-
const val =
|
|
1637
|
+
const val = attrMeasure(spacing, "w:val");
|
|
1493
1638
|
if (val !== void 0) opts.characterSpacing = val;
|
|
1494
1639
|
}
|
|
1495
1640
|
const scale = findChild(el, "w:w");
|
|
@@ -1646,8 +1791,10 @@ const PARSED_LAST_RENDERED_PAGE_BREAK = Symbol("LastRenderedPageBreak");
|
|
|
1646
1791
|
function parseRun(el, _ctx) {
|
|
1647
1792
|
const rPr = findChild(el, "w:rPr");
|
|
1648
1793
|
const properties = rPr ? parseRunProperties(rPr) : void 0;
|
|
1649
|
-
const rPrRawXml = rPr ? stringifyElement(rPr) : void 0;
|
|
1650
1794
|
const children = [];
|
|
1795
|
+
const rsid = attr(el, "w:rsidR");
|
|
1796
|
+
const runPropertiesRsid = attr(el, "w:rsidRPr");
|
|
1797
|
+
const deletionRsid = attr(el, "w:rsidDel");
|
|
1651
1798
|
for (const child of el.elements ?? []) switch (child.name) {
|
|
1652
1799
|
case "w:rPr": break;
|
|
1653
1800
|
case "w:t": {
|
|
@@ -1664,8 +1811,13 @@ function parseRun(el, _ctx) {
|
|
|
1664
1811
|
}
|
|
1665
1812
|
case "w:br": {
|
|
1666
1813
|
const brType = attr(child, "w:type");
|
|
1814
|
+
const brClear = attr(child, "w:clear");
|
|
1667
1815
|
if (brType === "page") children.push(PARSED_PAGE_BREAK);
|
|
1668
1816
|
else if (brType === "column") children.push(PARSED_COLUMN_BREAK);
|
|
1817
|
+
else if (brClear) children.push({ break: {
|
|
1818
|
+
count: 1,
|
|
1819
|
+
clear: brClear
|
|
1820
|
+
} });
|
|
1669
1821
|
else children.push(PARSED_LINE_BREAK);
|
|
1670
1822
|
break;
|
|
1671
1823
|
}
|
|
@@ -1688,6 +1840,9 @@ function parseRun(el, _ctx) {
|
|
|
1688
1840
|
}
|
|
1689
1841
|
case "w:drawing":
|
|
1690
1842
|
case "w:pict": break;
|
|
1843
|
+
case "w:object":
|
|
1844
|
+
children.push({ object: objectDesc.parse(child, _ctx) });
|
|
1845
|
+
break;
|
|
1691
1846
|
case "w:sym": {
|
|
1692
1847
|
const charVal = attr(child, "w:char");
|
|
1693
1848
|
const fontVal = attr(child, "w:font");
|
|
@@ -1699,12 +1854,24 @@ function parseRun(el, _ctx) {
|
|
|
1699
1854
|
}
|
|
1700
1855
|
case "w:footnoteReference": {
|
|
1701
1856
|
const id = attrNum(child, "w:id");
|
|
1702
|
-
if (id !== void 0)
|
|
1857
|
+
if (id !== void 0) {
|
|
1858
|
+
const customMarkFollows = attrBool(child, "w:customMarkFollows") === true;
|
|
1859
|
+
children.push(customMarkFollows ? { footnoteReference: {
|
|
1860
|
+
id,
|
|
1861
|
+
customMarkFollows: true
|
|
1862
|
+
} } : { footnoteReference: id });
|
|
1863
|
+
}
|
|
1703
1864
|
break;
|
|
1704
1865
|
}
|
|
1705
1866
|
case "w:endnoteReference": {
|
|
1706
1867
|
const id = attrNum(child, "w:id");
|
|
1707
|
-
if (id !== void 0)
|
|
1868
|
+
if (id !== void 0) {
|
|
1869
|
+
const customMarkFollows = attrBool(child, "w:customMarkFollows") === true;
|
|
1870
|
+
children.push(customMarkFollows ? { endnoteReference: {
|
|
1871
|
+
id,
|
|
1872
|
+
customMarkFollows: true
|
|
1873
|
+
} } : { endnoteReference: id });
|
|
1874
|
+
}
|
|
1708
1875
|
break;
|
|
1709
1876
|
}
|
|
1710
1877
|
case "w:footnoteRef":
|
|
@@ -1748,8 +1915,10 @@ function parseRun(el, _ctx) {
|
|
|
1748
1915
|
}
|
|
1749
1916
|
return {
|
|
1750
1917
|
properties,
|
|
1751
|
-
|
|
1752
|
-
|
|
1918
|
+
children,
|
|
1919
|
+
rsid,
|
|
1920
|
+
runPropertiesRsid,
|
|
1921
|
+
deletionRsid
|
|
1753
1922
|
};
|
|
1754
1923
|
}
|
|
1755
1924
|
/**
|
|
@@ -1783,15 +1952,26 @@ function parsedRunToOptions(parsed) {
|
|
|
1783
1952
|
const contentChildren = parsed.children.filter((c) => c !== PARSED_FOOTNOTE_REF);
|
|
1784
1953
|
if (contentChildren.length === 0 && parsed.children.some((c) => c === PARSED_FOOTNOTE_REF)) return null;
|
|
1785
1954
|
const opts = { ...parsed.properties };
|
|
1786
|
-
if (parsed.
|
|
1955
|
+
if (parsed.rsid) opts.rsid = parsed.rsid;
|
|
1956
|
+
if (parsed.runPropertiesRsid) opts.runPropertiesRsid = parsed.runPropertiesRsid;
|
|
1957
|
+
if (parsed.deletionRsid) opts.deletionRsid = parsed.deletionRsid;
|
|
1787
1958
|
const isRefChild = (c) => typeof c === "object" && c !== null && ("commentReference" in c || "footnoteReference" in c || "endnoteReference" in c);
|
|
1788
1959
|
const refChildren = contentChildren.filter(isRefChild);
|
|
1789
1960
|
const nonRefChildren = contentChildren.filter((c) => !isRefChild(c));
|
|
1790
1961
|
if (refChildren.length > 0 && nonRefChildren.length === 0) return refChildren[0];
|
|
1791
1962
|
const symbolIdx = nonRefChildren.findIndex((c) => typeof c === "object" && c !== null && "symbolRun" in c);
|
|
1792
1963
|
if (symbolIdx >= 0 && nonRefChildren.length === 1 && !parsed.properties) return nonRefChildren[symbolIdx];
|
|
1964
|
+
const objectIdx = nonRefChildren.findIndex((c) => typeof c === "object" && c !== null && "object" in c);
|
|
1965
|
+
if (objectIdx >= 0) {
|
|
1966
|
+
const objectChild = nonRefChildren[objectIdx];
|
|
1967
|
+
return {
|
|
1968
|
+
...parsed.properties,
|
|
1969
|
+
...objectChild
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1793
1972
|
const textParts = [];
|
|
1794
1973
|
let breakCount = 0;
|
|
1974
|
+
const structuredBreaks = [];
|
|
1795
1975
|
let hasPageBreak = false;
|
|
1796
1976
|
let hasColumnBreak = false;
|
|
1797
1977
|
const extraChildren = [];
|
|
@@ -1799,16 +1979,19 @@ function parsedRunToOptions(parsed) {
|
|
|
1799
1979
|
else if (child === PARSED_LINE_BREAK) breakCount++;
|
|
1800
1980
|
else if (child === PARSED_PAGE_BREAK) hasPageBreak = true;
|
|
1801
1981
|
else if (child === PARSED_COLUMN_BREAK) hasColumnBreak = true;
|
|
1982
|
+
else if (typeof child === "object" && child !== null && "break" in child) structuredBreaks.push(child.break);
|
|
1802
1983
|
else {
|
|
1803
1984
|
const mapped = SYMBOL_TO_CHILD.get(child);
|
|
1804
1985
|
if (mapped) extraChildren.push(mapped);
|
|
1805
1986
|
}
|
|
1806
|
-
|
|
1987
|
+
const hasStructuredBreaks = structuredBreaks.length > 0;
|
|
1988
|
+
if (extraChildren.length > 0 || hasStructuredBreaks && (breakCount > 0 || structuredBreaks.length > 1 || hasPageBreak || hasColumnBreak)) {
|
|
1807
1989
|
const children = [];
|
|
1808
1990
|
for (const child of nonRefChildren) if (typeof child === "string") children.push(child);
|
|
1809
1991
|
else if (child === PARSED_LINE_BREAK) children.push({ break: 1 });
|
|
1810
1992
|
else if (child === PARSED_PAGE_BREAK) children.push({ pageBreak: true });
|
|
1811
1993
|
else if (child === PARSED_COLUMN_BREAK) children.push({ columnBreak: true });
|
|
1994
|
+
else if (typeof child === "object" && child !== null && "break" in child) children.push({ break: child.break });
|
|
1812
1995
|
else {
|
|
1813
1996
|
const mapped = SYMBOL_TO_CHILD.get(child);
|
|
1814
1997
|
if (mapped) children.push(mapped);
|
|
@@ -1817,6 +2000,7 @@ function parsedRunToOptions(parsed) {
|
|
|
1817
2000
|
} else {
|
|
1818
2001
|
if (textParts.length > 0) opts.text = textParts.join("");
|
|
1819
2002
|
if (breakCount > 0) opts.break = breakCount;
|
|
2003
|
+
else if (hasStructuredBreaks) opts.break = structuredBreaks[0];
|
|
1820
2004
|
if (hasPageBreak) opts.pageBreak = true;
|
|
1821
2005
|
if (hasColumnBreak) opts.columnBreak = true;
|
|
1822
2006
|
}
|
|
@@ -1872,13 +2056,13 @@ function shadingStr(opts) {
|
|
|
1872
2056
|
}
|
|
1873
2057
|
function spacingStr(opts) {
|
|
1874
2058
|
return `<w:spacing ${attrParts({
|
|
1875
|
-
"w:after": opts.after,
|
|
2059
|
+
"w:after": opts.after !== void 0 ? twipsMeasureValue(opts.after) : void 0,
|
|
1876
2060
|
"w:afterAutospacing": opts.afterAutoSpacing !== void 0 ? opts.afterAutoSpacing ? 1 : 0 : void 0,
|
|
1877
2061
|
"w:afterLines": opts.afterLines !== void 0 ? decimalNumber(opts.afterLines) : void 0,
|
|
1878
|
-
"w:before": opts.before,
|
|
2062
|
+
"w:before": opts.before !== void 0 ? twipsMeasureValue(opts.before) : void 0,
|
|
1879
2063
|
"w:beforeAutospacing": opts.beforeAutoSpacing !== void 0 ? opts.beforeAutoSpacing ? 1 : 0 : void 0,
|
|
1880
2064
|
"w:beforeLines": opts.beforeLines !== void 0 ? decimalNumber(opts.beforeLines) : void 0,
|
|
1881
|
-
"w:line": opts.line,
|
|
2065
|
+
"w:line": opts.line !== void 0 ? twipsMeasureValue(opts.line) : void 0,
|
|
1882
2066
|
"w:lineRule": opts.lineRule
|
|
1883
2067
|
})}/>`;
|
|
1884
2068
|
}
|
|
@@ -2141,9 +2325,9 @@ function stringifyRunPropertiesInner(opts) {
|
|
|
2141
2325
|
else if ("name" in opts.font) parts.push(runFontsStr(opts.font.name, opts.font.hint));
|
|
2142
2326
|
else parts.push(runFontsStr(opts.font));
|
|
2143
2327
|
if (opts.bold !== void 0) parts.push(onOff$1("w:b", opts.bold));
|
|
2144
|
-
if (
|
|
2328
|
+
if (opts.boldComplexScript !== void 0) parts.push(onOff$1("w:bCs", opts.boldComplexScript));
|
|
2145
2329
|
if (opts.italic !== void 0) parts.push(onOff$1("w:i", opts.italic));
|
|
2146
|
-
if (
|
|
2330
|
+
if (opts.italicComplexScript !== void 0) parts.push(onOff$1("w:iCs", opts.italicComplexScript));
|
|
2147
2331
|
if (opts.smallCaps !== void 0) parts.push(onOff$1("w:smallCaps", opts.smallCaps));
|
|
2148
2332
|
else if (opts.allCaps !== void 0) parts.push(onOff$1("w:caps", opts.allCaps));
|
|
2149
2333
|
if (opts.strike !== void 0) parts.push(onOff$1("w:strike", opts.strike));
|
|
@@ -2162,12 +2346,9 @@ function stringifyRunPropertiesInner(opts) {
|
|
|
2162
2346
|
if (opts.kern !== void 0) parts.push(`<w:kern w:val="${hpsMeasureValue(opts.kern)}"/>`);
|
|
2163
2347
|
if (opts.position) parts.push(`<w:position w:val="${opts.position}"/>`);
|
|
2164
2348
|
if (opts.size !== void 0) parts.push(`<w:sz w:val="${hpsMeasureValue(opts.size * 2)}"/>`);
|
|
2165
|
-
|
|
2166
|
-
if (szCs) parts.push(`<w:szCs w:val="${hpsMeasureValue(szCs * 2)}"/>`);
|
|
2349
|
+
if (opts.sizeComplexScript !== void 0) parts.push(`<w:szCs w:val="${hpsMeasureValue(opts.sizeComplexScript * 2)}"/>`);
|
|
2167
2350
|
if (opts.highlight) parts.push(`<w:highlight w:val="${opts.highlight}"/>`);
|
|
2168
|
-
if (opts.highlightComplexScript
|
|
2169
|
-
if (opts.highlight) parts.push(`<w:highlightCs w:val="${opts.highlight}"/>`);
|
|
2170
|
-
} else if (opts.highlightComplexScript !== void 0 && opts.highlightComplexScript !== false) parts.push(`<w:highlightCs w:val="${opts.highlightComplexScript}"/>`);
|
|
2351
|
+
if (opts.highlightComplexScript !== void 0) parts.push(`<w:highlightCs w:val="${opts.highlightComplexScript}"/>`);
|
|
2171
2352
|
if (opts.underline) parts.push(underlineStr(opts.underline.type, opts.underline.color));
|
|
2172
2353
|
if (opts.effect) parts.push(`<w:effect w:val="${opts.effect}"/>`);
|
|
2173
2354
|
if (opts.border) parts.push(borderStr("w:bdr", opts.border));
|
|
@@ -3292,32 +3473,6 @@ const PageOrientation = {
|
|
|
3292
3473
|
*/
|
|
3293
3474
|
LANDSCAPE: "landscape"
|
|
3294
3475
|
};
|
|
3295
|
-
/**
|
|
3296
|
-
* This element specifies the properties (size and orientation) for all pages in the current section.
|
|
3297
|
-
*
|
|
3298
|
-
* Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_pgSz_topic_ID0ENEDT.html?hl=pgsz%2Cpage%2Csize
|
|
3299
|
-
*
|
|
3300
|
-
* ## XSD Schema
|
|
3301
|
-
*
|
|
3302
|
-
* ```xml
|
|
3303
|
-
* <xsd:complexType name="CT_PageSz">
|
|
3304
|
-
* <xsd:attribute name="w" type="s:ST_TwipsMeasure"/>
|
|
3305
|
-
* <xsd:attribute name="h" type="s:ST_TwipsMeasure"/>
|
|
3306
|
-
* <xsd:attribute name="orient" type="ST_PageOrientation" use="optional"/>
|
|
3307
|
-
* <xsd:attribute name="code" type="ST_DecimalNumber" use="optional"/>
|
|
3308
|
-
* </xsd:complexType>
|
|
3309
|
-
* ```
|
|
3310
|
-
*/
|
|
3311
|
-
const createPageSize = ({ width = 11906, height = 16838, orientation, code }) => {
|
|
3312
|
-
const widthTwips = twipsMeasureValue(width);
|
|
3313
|
-
const heightTwips = twipsMeasureValue(height);
|
|
3314
|
-
return element("w:pgSz", {
|
|
3315
|
-
"w:code": code,
|
|
3316
|
-
"w:h": orientation === PageOrientation.LANDSCAPE ? widthTwips : heightTwips,
|
|
3317
|
-
"w:orient": orientation,
|
|
3318
|
-
"w:w": orientation === PageOrientation.LANDSCAPE ? heightTwips : widthTwips
|
|
3319
|
-
});
|
|
3320
|
-
};
|
|
3321
3476
|
//#endregion
|
|
3322
3477
|
//#region src/parts/document/body/section-properties/properties/page-text-direction.ts
|
|
3323
3478
|
/**
|
|
@@ -3492,8 +3647,10 @@ function stringifySectionPropertiesInner(opts) {
|
|
|
3492
3647
|
if (opts.footnotePr) parts.push(footnotePrXml("w:footnotePr", opts.footnotePr));
|
|
3493
3648
|
if (opts.endnotePr) parts.push(footnotePrXml("w:endnotePr", opts.endnotePr));
|
|
3494
3649
|
if (opts.type) parts.push(sectionTypeXml(opts.type));
|
|
3495
|
-
const
|
|
3496
|
-
const
|
|
3650
|
+
const wTwips = convertToTwip(width);
|
|
3651
|
+
const hTwips = convertToTwip(height);
|
|
3652
|
+
const pgW = orientation === "landscape" ? hTwips : wTwips;
|
|
3653
|
+
const pgH = orientation === "landscape" ? wTwips : hTwips;
|
|
3497
3654
|
parts.push(pageSizeXml(pgW, pgH, orientation, code));
|
|
3498
3655
|
parts.push(pageMarginXml(top, right, bottom, left, header, footer, gutter));
|
|
3499
3656
|
if (borders) parts.push(pageBordersXml(borders));
|
|
@@ -3543,20 +3700,20 @@ const sectionPropertiesDesc = {
|
|
|
3543
3700
|
function stringifySectionPropertiesXml(opts) {
|
|
3544
3701
|
const inner = stringifySectionPropertiesInner(opts);
|
|
3545
3702
|
const attrs = [];
|
|
3546
|
-
if (opts.
|
|
3547
|
-
if (opts.
|
|
3548
|
-
if (opts.
|
|
3549
|
-
if (opts.
|
|
3703
|
+
if (opts.runPropertiesRsid !== void 0) attrs.push(`w:rsidRPr="${opts.runPropertiesRsid}"`);
|
|
3704
|
+
if (opts.deletionRsid !== void 0) attrs.push(`w:rsidDel="${opts.deletionRsid}"`);
|
|
3705
|
+
if (opts.rsid !== void 0) attrs.push(`w:rsidR="${opts.rsid}"`);
|
|
3706
|
+
if (opts.sectionRsid !== void 0) attrs.push(`w:rsidSect="${opts.sectionRsid}"`);
|
|
3550
3707
|
return `<w:sectPr${attrs.length ? " " + attrs.join(" ") : ""}>${inner}</w:sectPr>`;
|
|
3551
3708
|
}
|
|
3552
3709
|
/** Parse a w:sectPr element into SectionPropertiesOptions. */
|
|
3553
3710
|
function parseSectionPropertiesEl(el) {
|
|
3554
3711
|
const opts = {};
|
|
3555
3712
|
for (const [attrName, optKey] of [
|
|
3556
|
-
["w:rsidR", "
|
|
3557
|
-
["w:rsidRPr", "
|
|
3558
|
-
["w:rsidDel", "
|
|
3559
|
-
["w:rsidSect", "
|
|
3713
|
+
["w:rsidR", "rsid"],
|
|
3714
|
+
["w:rsidRPr", "runPropertiesRsid"],
|
|
3715
|
+
["w:rsidDel", "deletionRsid"],
|
|
3716
|
+
["w:rsidSect", "sectionRsid"]
|
|
3560
3717
|
]) {
|
|
3561
3718
|
const val = attr(el, attrName);
|
|
3562
3719
|
if (val) opts[optKey] = val;
|
|
@@ -3616,7 +3773,7 @@ function parseSectionPropertiesEl(el) {
|
|
|
3616
3773
|
const column = {};
|
|
3617
3774
|
const count = attrNum(cols, "w:num");
|
|
3618
3775
|
if (count !== void 0) column.count = count;
|
|
3619
|
-
const space =
|
|
3776
|
+
const space = attrMeasure(cols, "w:space");
|
|
3620
3777
|
if (space !== void 0) column.space = space;
|
|
3621
3778
|
const separate = attrBool(cols, "w:sep");
|
|
3622
3779
|
if (separate !== void 0) column.separate = separate;
|
|
@@ -3625,10 +3782,10 @@ function parseSectionPropertiesEl(el) {
|
|
|
3625
3782
|
const colChildren = [];
|
|
3626
3783
|
for (const colEl of cols.elements ?? []) {
|
|
3627
3784
|
if (colEl.name !== "w:col") continue;
|
|
3628
|
-
const width =
|
|
3785
|
+
const width = attrMeasure(colEl, "w:w");
|
|
3629
3786
|
if (width === void 0) continue;
|
|
3630
3787
|
const colAttr = { width };
|
|
3631
|
-
const colSpace =
|
|
3788
|
+
const colSpace = attrMeasure(colEl, "w:space");
|
|
3632
3789
|
if (colSpace !== void 0) colAttr.space = colSpace;
|
|
3633
3790
|
colChildren.push(colAttr);
|
|
3634
3791
|
}
|
|
@@ -4077,7 +4234,7 @@ function stringifyMathInput(value) {
|
|
|
4077
4234
|
if (typeof value !== "object" || value === null) return "";
|
|
4078
4235
|
if ("subSuperScript" in value) {
|
|
4079
4236
|
const opts = value.subSuperScript;
|
|
4080
|
-
return `<m:sSubSup><m:sSubSupPr
|
|
4237
|
+
return `<m:sSubSup>${opts.alignScript ? "<m:sSubSupPr><m:alnScr m:val=\"1\"/></m:sSubSupPr>" : "<m:sSubSupPr/>"}<m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSubSup>`;
|
|
4081
4238
|
}
|
|
4082
4239
|
if ("preSubSuperScript" in value) {
|
|
4083
4240
|
const opts = value.preSubSuperScript;
|
|
@@ -4093,7 +4250,10 @@ function stringifyMathInput(value) {
|
|
|
4093
4250
|
}
|
|
4094
4251
|
if ("fraction" in value) {
|
|
4095
4252
|
const opts = value.fraction;
|
|
4096
|
-
|
|
4253
|
+
const pr = opts.fractionType ? `<m:fPr><m:type m:val="${opts.fractionType}"/></m:fPr>` : "";
|
|
4254
|
+
const numArgPr = argPrXml(opts.numeratorArgumentSize);
|
|
4255
|
+
const denArgPr = argPrXml(opts.denominatorArgumentSize);
|
|
4256
|
+
return `<m:f>${pr}<m:num>${numArgPr}${stringifyChildren(opts.numerator)}</m:num><m:den>${denArgPr}${stringifyChildren(opts.denominator)}</m:den></m:f>`;
|
|
4097
4257
|
}
|
|
4098
4258
|
if ("radical" in value) {
|
|
4099
4259
|
const opts = value.radical;
|
|
@@ -4136,10 +4296,22 @@ function stringifyMathInput(value) {
|
|
|
4136
4296
|
}
|
|
4137
4297
|
return `<m:m>${pr}${rows}</m:m>`;
|
|
4138
4298
|
}
|
|
4139
|
-
if ("roundBrackets" in value)
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4299
|
+
if ("roundBrackets" in value) {
|
|
4300
|
+
const spec = bracketSpec(value.roundBrackets);
|
|
4301
|
+
return stringifyDelimiters(spec.children, "(", ")", spec.properties);
|
|
4302
|
+
}
|
|
4303
|
+
if ("curlyBrackets" in value) {
|
|
4304
|
+
const spec = bracketSpec(value.curlyBrackets);
|
|
4305
|
+
return stringifyDelimiters(spec.children, "{", "}", spec.properties);
|
|
4306
|
+
}
|
|
4307
|
+
if ("angledBrackets" in value) {
|
|
4308
|
+
const spec = bracketSpec(value.angledBrackets);
|
|
4309
|
+
return stringifyDelimiters(spec.children, "〈", "〉", spec.properties);
|
|
4310
|
+
}
|
|
4311
|
+
if ("squareBrackets" in value) {
|
|
4312
|
+
const spec = bracketSpec(value.squareBrackets);
|
|
4313
|
+
return stringifyDelimiters(spec.children, "[", "]", spec.properties);
|
|
4314
|
+
}
|
|
4143
4315
|
if ("borderBox" in value) {
|
|
4144
4316
|
const opts = value.borderBox;
|
|
4145
4317
|
let pr = "";
|
|
@@ -4231,16 +4403,31 @@ function stringifyNAry(opts, chr) {
|
|
|
4231
4403
|
const hasSub = opts.subScript && opts.subScript.length > 0;
|
|
4232
4404
|
const hasSup = opts.superScript && opts.superScript.length > 0;
|
|
4233
4405
|
const prParts = [`<m:chr m:val="${chr}"/>`];
|
|
4406
|
+
if (opts.properties?.limitLocation) prParts.push(`<m:limLoc m:val="${opts.properties.limitLocation}"/>`);
|
|
4407
|
+
if (opts.properties?.grow !== void 0) prParts.push(`<m:grow m:val="${opts.properties.grow ? 1 : 0}"/>`);
|
|
4234
4408
|
if (!hasSub) prParts.push("<m:subHide m:val=\"1\"/>");
|
|
4235
4409
|
if (!hasSup) prParts.push("<m:supHide m:val=\"1\"/>");
|
|
4236
4410
|
return `<m:nary>${`<m:naryPr>${prParts.join("")}</m:naryPr>`}${hasSub ? `<m:sub>${stringifyChildren(opts.subScript)}</m:sub>` : "<m:sub/>"}${hasSup ? `<m:sup>${stringifyChildren(opts.superScript)}</m:sup>` : "<m:sup/>"}<m:e>${stringifyChildren(opts.children)}</m:e></m:nary>`;
|
|
4237
4411
|
}
|
|
4238
|
-
function stringifyDelimiters(children, begChr, endChr) {
|
|
4239
|
-
|
|
4240
|
-
}
|
|
4241
|
-
|
|
4242
|
-
if (
|
|
4243
|
-
|
|
4412
|
+
function stringifyDelimiters(children, begChr, endChr, properties) {
|
|
4413
|
+
const prParts = [`<m:begChr m:val="${properties?.beginCharacter ?? begChr}"/>`];
|
|
4414
|
+
if (properties?.separatorCharacter) prParts.push(`<m:sepChr m:val="${properties.separatorCharacter}"/>`);
|
|
4415
|
+
prParts.push(`<m:endChr m:val="${properties?.endCharacter ?? endChr}"/>`);
|
|
4416
|
+
if (properties?.grow !== void 0) prParts.push(`<m:grow m:val="${properties.grow ? 1 : 0}"/>`);
|
|
4417
|
+
if (properties?.shape) prParts.push(`<m:shp m:val="${properties.shape}"/>`);
|
|
4418
|
+
return `<m:d><m:dPr>${prParts.join("")}</m:dPr><m:e>${stringifyChildren(children)}</m:e></m:d>`;
|
|
4419
|
+
}
|
|
4420
|
+
/** Build an m:argPr/m:argSz block for an argument size scaling value. */
|
|
4421
|
+
function argPrXml(size) {
|
|
4422
|
+
return size !== void 0 ? `<m:argPr><m:argSz m:val="${size}"/></m:argPr>` : "";
|
|
4423
|
+
}
|
|
4424
|
+
/** Split a bracket shorthand into children + optional delimiter properties. */
|
|
4425
|
+
function bracketSpec(v) {
|
|
4426
|
+
if (Array.isArray(v)) return { children: v };
|
|
4427
|
+
return {
|
|
4428
|
+
children: v.children,
|
|
4429
|
+
properties: v.properties
|
|
4430
|
+
};
|
|
4244
4431
|
}
|
|
4245
4432
|
function stringifyMath(children) {
|
|
4246
4433
|
return `<m:oMath>${children.map((c) => stringifyMathInput(c)).join("")}</m:oMath>`;
|
|
@@ -4303,10 +4490,33 @@ function parseMathElement(el) {
|
|
|
4303
4490
|
function parseMathRun(el) {
|
|
4304
4491
|
return textOf(findChild(el, "m:t")) ?? "";
|
|
4305
4492
|
}
|
|
4493
|
+
/** Read an m:val on/off attribute (1/0/true/false; empty element = on). */
|
|
4494
|
+
function readOnOff$1(el) {
|
|
4495
|
+
if (!el) return void 0;
|
|
4496
|
+
const v = attr(el, "m:val");
|
|
4497
|
+
return v === void 0 ? true : v === "1" || v === "true" || v === "on";
|
|
4498
|
+
}
|
|
4499
|
+
/** Read an m:val numeric attribute. */
|
|
4500
|
+
function readNum$1(el) {
|
|
4501
|
+
if (!el) return void 0;
|
|
4502
|
+
const v = attr(el, "m:val");
|
|
4503
|
+
if (v === void 0 || v === "") return void 0;
|
|
4504
|
+
const n = Number(v);
|
|
4505
|
+
return Number.isFinite(n) ? n : void 0;
|
|
4506
|
+
}
|
|
4507
|
+
/** Read an m:argSz scaling value from an m:argPr-bearing argument element. */
|
|
4508
|
+
function readArgSize(argEl) {
|
|
4509
|
+
if (!argEl) return void 0;
|
|
4510
|
+
return readNum$1(findChild(argEl, "m:argSz"));
|
|
4511
|
+
}
|
|
4306
4512
|
function parseMathFraction(el) {
|
|
4513
|
+
const numeratorArgumentSize = readArgSize(findChild(el, "m:num"));
|
|
4514
|
+
const denominatorArgumentSize = readArgSize(findChild(el, "m:den"));
|
|
4307
4515
|
return { fraction: {
|
|
4308
4516
|
numerator: parseMathArg(el, "m:num"),
|
|
4309
|
-
denominator: parseMathArg(el, "m:den")
|
|
4517
|
+
denominator: parseMathArg(el, "m:den"),
|
|
4518
|
+
...numeratorArgumentSize !== void 0 ? { numeratorArgumentSize } : {},
|
|
4519
|
+
...denominatorArgumentSize !== void 0 ? { denominatorArgumentSize } : {}
|
|
4310
4520
|
} };
|
|
4311
4521
|
}
|
|
4312
4522
|
function parseMathRadical(el) {
|
|
@@ -4329,10 +4539,13 @@ function parseMathSubScript(el) {
|
|
|
4329
4539
|
} };
|
|
4330
4540
|
}
|
|
4331
4541
|
function parseMathSubSuperScript(el) {
|
|
4542
|
+
const pr = findChild(el, "m:sSubSupPr");
|
|
4543
|
+
const alignScript = pr ? readOnOff$1(findChild(pr, "m:alnScr")) : void 0;
|
|
4332
4544
|
return { subSuperScript: {
|
|
4333
4545
|
children: parseMathArg(el, "m:e"),
|
|
4334
4546
|
subScript: parseMathArg(el, "m:sub"),
|
|
4335
|
-
superScript: parseMathArg(el, "m:sup")
|
|
4547
|
+
superScript: parseMathArg(el, "m:sup"),
|
|
4548
|
+
...alignScript !== void 0 ? { alignScript } : {}
|
|
4336
4549
|
} };
|
|
4337
4550
|
}
|
|
4338
4551
|
function parseMathNAry(el) {
|
|
@@ -4342,10 +4555,21 @@ function parseMathNAry(el) {
|
|
|
4342
4555
|
const baseChildren = parseMathArg(el, "m:e");
|
|
4343
4556
|
const sub = parseMathArg(el, "m:sub");
|
|
4344
4557
|
const sup = parseMathArg(el, "m:sup");
|
|
4558
|
+
const properties = {};
|
|
4559
|
+
if (naryPr) {
|
|
4560
|
+
const limLocEl = findChild(naryPr, "m:limLoc");
|
|
4561
|
+
if (limLocEl) {
|
|
4562
|
+
const limLoc = attr(limLocEl, "m:val");
|
|
4563
|
+
if (limLoc === "subSup" || limLoc === "undOvr") properties.limitLocation = limLoc;
|
|
4564
|
+
}
|
|
4565
|
+
const grow = readOnOff$1(findChild(naryPr, "m:grow"));
|
|
4566
|
+
if (grow !== void 0) properties.grow = grow;
|
|
4567
|
+
}
|
|
4345
4568
|
const common = {
|
|
4346
4569
|
children: baseChildren,
|
|
4347
4570
|
...sub.length > 0 ? { subScript: sub } : {},
|
|
4348
|
-
...sup.length > 0 ? { superScript: sup } : {}
|
|
4571
|
+
...sup.length > 0 ? { superScript: sup } : {},
|
|
4572
|
+
...Object.keys(properties).length > 0 ? { properties } : {}
|
|
4349
4573
|
};
|
|
4350
4574
|
if (chrVal === "∑") return { sum: common };
|
|
4351
4575
|
return { integral: common };
|
|
@@ -4361,12 +4585,31 @@ function parseMathDelimiter(el) {
|
|
|
4361
4585
|
const begChrEl = dPr ? findChild(dPr, "m:begChr") : void 0;
|
|
4362
4586
|
const begChr = begChrEl ? attr(begChrEl, "m:val") : "(";
|
|
4363
4587
|
const mathChildren = parseMathArg(el, "m:e");
|
|
4588
|
+
const properties = {};
|
|
4589
|
+
if (dPr) {
|
|
4590
|
+
if (begChrEl) properties.beginCharacter = begChr;
|
|
4591
|
+
const endChrEl = findChild(dPr, "m:endChr");
|
|
4592
|
+
if (endChrEl) properties.endCharacter = attr(endChrEl, "m:val");
|
|
4593
|
+
const sepChrEl = findChild(dPr, "m:sepChr");
|
|
4594
|
+
if (sepChrEl) properties.separatorCharacter = attr(sepChrEl, "m:val");
|
|
4595
|
+
const grow = readOnOff$1(findChild(dPr, "m:grow"));
|
|
4596
|
+
if (grow !== void 0) properties.grow = grow;
|
|
4597
|
+
const shpEl = findChild(dPr, "m:shp");
|
|
4598
|
+
if (shpEl) {
|
|
4599
|
+
const shp = attr(shpEl, "m:val");
|
|
4600
|
+
if (shp === "centered" || shp === "match") properties.shape = shp;
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
const value = Object.keys(properties).length > 0 ? {
|
|
4604
|
+
children: mathChildren,
|
|
4605
|
+
properties
|
|
4606
|
+
} : mathChildren;
|
|
4364
4607
|
switch (begChr) {
|
|
4365
|
-
case "[": return { squareBrackets:
|
|
4366
|
-
case "{": return { curlyBrackets:
|
|
4608
|
+
case "[": return { squareBrackets: value };
|
|
4609
|
+
case "{": return { curlyBrackets: value };
|
|
4367
4610
|
case "<":
|
|
4368
|
-
case "⟨": return { angledBrackets:
|
|
4369
|
-
default: return { roundBrackets:
|
|
4611
|
+
case "⟨": return { angledBrackets: value };
|
|
4612
|
+
default: return { roundBrackets: value };
|
|
4370
4613
|
}
|
|
4371
4614
|
}
|
|
4372
4615
|
function parseMathMatrix(el) {
|
|
@@ -4486,13 +4729,12 @@ function stringifyRun(opts, ctx) {
|
|
|
4486
4729
|
break;
|
|
4487
4730
|
}
|
|
4488
4731
|
}
|
|
4489
|
-
const
|
|
4732
|
+
const rPr = stringifyRunProperties(commentRefStyle ? {
|
|
4490
4733
|
...opts,
|
|
4491
4734
|
style: "CommentReference"
|
|
4492
|
-
} : opts;
|
|
4493
|
-
const rPr = runOpts.rPrRawXml ?? stringifyRunProperties(runOpts);
|
|
4735
|
+
} : opts);
|
|
4494
4736
|
if (rPr) parts.push(rPr);
|
|
4495
|
-
if (opts.break)
|
|
4737
|
+
if (opts.break) parts.push(breakXml(opts.break));
|
|
4496
4738
|
if (opts.children) {
|
|
4497
4739
|
for (const child of opts.children) if (typeof child === "string") parts.push(`<w:t xml:space="preserve">${escapeXml(child)}</w:t>`);
|
|
4498
4740
|
else if (typeof child === "object" && child !== null) {
|
|
@@ -4508,6 +4750,10 @@ function stringifyRun(opts, ctx) {
|
|
|
4508
4750
|
parts.push("<w:br w:type=\"column\"/>");
|
|
4509
4751
|
continue;
|
|
4510
4752
|
}
|
|
4753
|
+
if ("break" in child) {
|
|
4754
|
+
parts.push(breakXml(child.break));
|
|
4755
|
+
continue;
|
|
4756
|
+
}
|
|
4511
4757
|
if ("commentReference" in child) {
|
|
4512
4758
|
parts.push(`<w:commentReference w:id="${Number(child.commentReference)}"/>`);
|
|
4513
4759
|
continue;
|
|
@@ -4517,6 +4763,10 @@ function stringifyRun(opts, ctx) {
|
|
|
4517
4763
|
parts.push(emptyXml);
|
|
4518
4764
|
continue;
|
|
4519
4765
|
}
|
|
4766
|
+
if ("object" in child) {
|
|
4767
|
+
parts.push(objectDesc.stringify(child.object, ctx) ?? "");
|
|
4768
|
+
continue;
|
|
4769
|
+
}
|
|
4520
4770
|
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
4521
4771
|
if (jsonResult !== void 0) if (Array.isArray(jsonResult)) parts.push(...jsonResult);
|
|
4522
4772
|
else parts.push(jsonResult);
|
|
@@ -4524,8 +4774,9 @@ function stringifyRun(opts, ctx) {
|
|
|
4524
4774
|
}
|
|
4525
4775
|
} else if (opts.text !== void 0) parts.push(`<w:t xml:space="preserve">${escapeXml(String(opts.text))}</w:t>`);
|
|
4526
4776
|
const rsidAttrs = [];
|
|
4527
|
-
if (opts.
|
|
4528
|
-
if (opts.
|
|
4777
|
+
if (opts.rsid) rsidAttrs.push(` w:rsidR="${opts.rsid}"`);
|
|
4778
|
+
if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr="${opts.runPropertiesRsid}"`);
|
|
4779
|
+
if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel="${opts.deletionRsid}"`);
|
|
4529
4780
|
const attr = rsidAttrs.join("");
|
|
4530
4781
|
const body = parts.join("");
|
|
4531
4782
|
return body.length === 0 ? attr ? `<w:r${attr}/>` : "<w:r/>" : `<w:r${attr}>${body}</w:r>`;
|
|
@@ -4554,7 +4805,16 @@ function stringifyParagraph(opts, ctx, sectionPropertiesXml) {
|
|
|
4554
4805
|
}
|
|
4555
4806
|
}
|
|
4556
4807
|
const body = parts.join("");
|
|
4557
|
-
|
|
4808
|
+
const paraAttrs = [];
|
|
4809
|
+
if (resolved.paraId) paraAttrs.push(` w14:paraId="${resolved.paraId}"`);
|
|
4810
|
+
if (resolved.textId) paraAttrs.push(` w14:textId="${resolved.textId}"`);
|
|
4811
|
+
if (resolved.rsid) paraAttrs.push(` w:rsidR="${resolved.rsid}"`);
|
|
4812
|
+
if (resolved.defaultRunRsid) paraAttrs.push(` w:rsidRDefault="${resolved.defaultRunRsid}"`);
|
|
4813
|
+
if (resolved.propertiesRsid) paraAttrs.push(` w:rsidP="${resolved.propertiesRsid}"`);
|
|
4814
|
+
if (resolved.runPropertiesRsid) paraAttrs.push(` w:rsidRPr="${resolved.runPropertiesRsid}"`);
|
|
4815
|
+
if (resolved.deletionRsid) paraAttrs.push(` w:rsidDel="${resolved.deletionRsid}"`);
|
|
4816
|
+
const attr = paraAttrs.join("");
|
|
4817
|
+
return body ? `<w:p${attr}>${body}</w:p>` : `<w:p${attr}/>`;
|
|
4558
4818
|
}
|
|
4559
4819
|
/**
|
|
4560
4820
|
* Stringify a body-level child element.
|
|
@@ -4574,8 +4834,16 @@ function stringifyBodyChild(child, ctx) {
|
|
|
4574
4834
|
if ("altChunk" in child) return altChunkDesc.stringify(child.altChunk, ctx) ?? "";
|
|
4575
4835
|
if ("subDoc" in child) return subDocDesc.stringify(child.subDoc, ctx) ?? "";
|
|
4576
4836
|
if ("customXml" in child) return customXmlBlockDesc.stringify(child.customXml, ctx) ?? "";
|
|
4577
|
-
if ("bookmarkStart" in child)
|
|
4578
|
-
|
|
4837
|
+
if ("bookmarkStart" in child) {
|
|
4838
|
+
const bs = child.bookmarkStart;
|
|
4839
|
+
const bsDisp = bs.displacedByCustomXml ? ` w:displacedByCustomXml="${bs.displacedByCustomXml}"` : "";
|
|
4840
|
+
return `<w:bookmarkStart w:id="${bs.id}" w:name="${bs.name}"${bsDisp}/>`;
|
|
4841
|
+
}
|
|
4842
|
+
if ("bookmarkEnd" in child) {
|
|
4843
|
+
const be = child.bookmarkEnd;
|
|
4844
|
+
const beDisp = be.displacedByCustomXml ? ` w:displacedByCustomXml="${be.displacedByCustomXml}"` : "";
|
|
4845
|
+
return `<w:bookmarkEnd w:id="${be.id}"${beDisp}/>`;
|
|
4846
|
+
}
|
|
4579
4847
|
if ("rawXml" in child) return child.rawXml;
|
|
4580
4848
|
throw new Error("Unknown section child type");
|
|
4581
4849
|
}
|
|
@@ -4656,7 +4924,8 @@ function stringifyDocumentXml(ctx, docCtx) {
|
|
|
4656
4924
|
const sections = ctx._options.sections;
|
|
4657
4925
|
const bodySections = ctx.sectionProperties;
|
|
4658
4926
|
const parts = [];
|
|
4659
|
-
|
|
4927
|
+
const conformanceAttr = ctx._options.conformance ? ` w:conformance="${ctx._options.conformance}"` : "";
|
|
4928
|
+
parts.push(`<w:document ${DOC_NS} mc:Ignorable="w14 w15 wp14"${conformanceAttr}>`);
|
|
4660
4929
|
if (ctx._options.background) parts.push(stringifyDocumentBackground(ctx._options.background, docCtx));
|
|
4661
4930
|
const bodyParts = [];
|
|
4662
4931
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4717,11 +4986,11 @@ function parseParagraphProperties(el, ctx) {
|
|
|
4717
4986
|
const spacing = findChild(el, "w:spacing");
|
|
4718
4987
|
if (spacing) {
|
|
4719
4988
|
const sp = {};
|
|
4720
|
-
const before =
|
|
4989
|
+
const before = attrMeasure(spacing, "w:before");
|
|
4721
4990
|
if (before !== void 0) sp.before = before;
|
|
4722
|
-
const after =
|
|
4991
|
+
const after = attrMeasure(spacing, "w:after");
|
|
4723
4992
|
if (after !== void 0) sp.after = after;
|
|
4724
|
-
const line =
|
|
4993
|
+
const line = attrMeasure(spacing, "w:line");
|
|
4725
4994
|
if (line !== void 0) sp.line = line;
|
|
4726
4995
|
const lineRule = attr(spacing, "w:lineRule");
|
|
4727
4996
|
if (lineRule && LINE_RULES.includes(lineRule)) sp.lineRule = lineRule;
|
|
@@ -4738,27 +5007,27 @@ function parseParagraphProperties(el, ctx) {
|
|
|
4738
5007
|
const ind = findChild(el, "w:ind");
|
|
4739
5008
|
if (ind) {
|
|
4740
5009
|
const indentObj = {};
|
|
4741
|
-
const left =
|
|
5010
|
+
const left = attrMeasure(ind, "w:left");
|
|
4742
5011
|
if (left !== void 0) indentObj.left = left;
|
|
4743
5012
|
const leftChars = attrNum(ind, "w:leftChars");
|
|
4744
5013
|
if (leftChars !== void 0) indentObj.leftChars = leftChars;
|
|
4745
|
-
const right =
|
|
5014
|
+
const right = attrMeasure(ind, "w:right");
|
|
4746
5015
|
if (right !== void 0) indentObj.right = right;
|
|
4747
5016
|
const rightChars = attrNum(ind, "w:rightChars");
|
|
4748
5017
|
if (rightChars !== void 0) indentObj.rightChars = rightChars;
|
|
4749
|
-
const start =
|
|
5018
|
+
const start = attrMeasure(ind, "w:start");
|
|
4750
5019
|
if (start !== void 0) indentObj.start = start;
|
|
4751
5020
|
const startChars = attrNum(ind, "w:startChars");
|
|
4752
5021
|
if (startChars !== void 0) indentObj.startChars = startChars;
|
|
4753
|
-
const end =
|
|
5022
|
+
const end = attrMeasure(ind, "w:end");
|
|
4754
5023
|
if (end !== void 0) indentObj.end = end;
|
|
4755
5024
|
const endChars = attrNum(ind, "w:endChars");
|
|
4756
5025
|
if (endChars !== void 0) indentObj.endChars = endChars;
|
|
4757
|
-
const hanging =
|
|
5026
|
+
const hanging = attrMeasure(ind, "w:hanging");
|
|
4758
5027
|
if (hanging !== void 0) indentObj.hanging = hanging;
|
|
4759
5028
|
const hangingChars = attrNum(ind, "w:hangingChars");
|
|
4760
5029
|
if (hangingChars !== void 0) indentObj.hangingChars = hangingChars;
|
|
4761
|
-
const firstLine =
|
|
5030
|
+
const firstLine = attrMeasure(ind, "w:firstLine");
|
|
4762
5031
|
if (firstLine !== void 0) indentObj.firstLine = firstLine;
|
|
4763
5032
|
const firstLineChars = attrNum(ind, "w:firstLineChars");
|
|
4764
5033
|
if (firstLineChars !== void 0) indentObj.firstLineChars = firstLineChars;
|
|
@@ -5176,7 +5445,7 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5176
5445
|
const drawingChild = parseDrawingRun(drawingEl, ctx);
|
|
5177
5446
|
if (drawingChild) {
|
|
5178
5447
|
const rPrEl = findChild(child, "w:rPr");
|
|
5179
|
-
const
|
|
5448
|
+
const runProperties = rPrEl ? parseRunProperties(rPrEl) : void 0;
|
|
5180
5449
|
if (altFallback) {
|
|
5181
5450
|
if ("wpsShape" in drawingChild) {
|
|
5182
5451
|
drawingChild.wpsShape.vmlFallback = altFallback;
|
|
@@ -5188,10 +5457,10 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5188
5457
|
if (altRequires) drawingChild.wpgGroup.mcChoiceRequires = altRequires;
|
|
5189
5458
|
}
|
|
5190
5459
|
}
|
|
5191
|
-
if (
|
|
5192
|
-
if ("image" in drawingChild) drawingChild.image.
|
|
5193
|
-
else if ("wpsShape" in drawingChild) drawingChild.wpsShape.
|
|
5194
|
-
else if ("wpgGroup" in drawingChild) drawingChild.wpgGroup.
|
|
5460
|
+
if (runProperties) {
|
|
5461
|
+
if ("image" in drawingChild) drawingChild.image.runProperties = runProperties;
|
|
5462
|
+
else if ("wpsShape" in drawingChild) drawingChild.wpsShape.runProperties = runProperties;
|
|
5463
|
+
else if ("wpgGroup" in drawingChild) drawingChild.wpgGroup.runProperties = runProperties;
|
|
5195
5464
|
}
|
|
5196
5465
|
childList.push(drawingChild);
|
|
5197
5466
|
break;
|
|
@@ -5212,6 +5481,12 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5212
5481
|
if (anchor) hl.anchor = anchor;
|
|
5213
5482
|
const tooltip = attr(child, "w:tooltip");
|
|
5214
5483
|
if (tooltip) hl.tooltip = tooltip;
|
|
5484
|
+
const tgtFrame = attr(child, "w:tgtFrame");
|
|
5485
|
+
if (tgtFrame) hl.tgtFrame = tgtFrame;
|
|
5486
|
+
const docLocation = attr(child, "w:docLocation");
|
|
5487
|
+
if (docLocation) hl.docLocation = docLocation;
|
|
5488
|
+
const history = attrBool(child, "w:history");
|
|
5489
|
+
if (history !== void 0) hl.history = history;
|
|
5215
5490
|
const linkRuns = [];
|
|
5216
5491
|
for (const sub of child.elements ?? []) if (sub.name === "w:r") {
|
|
5217
5492
|
const runOpts = parsedRunToOptions(parseRun(sub, ctx));
|
|
@@ -5226,15 +5501,25 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5226
5501
|
case "w:bookmarkStart": {
|
|
5227
5502
|
const id = attrNum(child, "w:id");
|
|
5228
5503
|
const name = attr(child, "w:name");
|
|
5229
|
-
if (id !== void 0 && name)
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5504
|
+
if (id !== void 0 && name) {
|
|
5505
|
+
const bookmarkStart = {
|
|
5506
|
+
id,
|
|
5507
|
+
name
|
|
5508
|
+
};
|
|
5509
|
+
const disp = attr(child, "w:displacedByCustomXml");
|
|
5510
|
+
if (disp === "before" || disp === "after") bookmarkStart.displacedByCustomXml = disp;
|
|
5511
|
+
childList.push({ bookmarkStart });
|
|
5512
|
+
}
|
|
5233
5513
|
break;
|
|
5234
5514
|
}
|
|
5235
5515
|
case "w:bookmarkEnd": {
|
|
5236
5516
|
const id = attrNum(child, "w:id");
|
|
5237
|
-
if (id !== void 0)
|
|
5517
|
+
if (id !== void 0) {
|
|
5518
|
+
const bookmarkEnd = { id };
|
|
5519
|
+
const disp = attr(child, "w:displacedByCustomXml");
|
|
5520
|
+
if (disp === "before" || disp === "after") bookmarkEnd.displacedByCustomXml = disp;
|
|
5521
|
+
childList.push({ bookmarkEnd });
|
|
5522
|
+
}
|
|
5238
5523
|
break;
|
|
5239
5524
|
}
|
|
5240
5525
|
case "w:commentRangeStart": {
|
|
@@ -5317,6 +5602,10 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5317
5602
|
let cachedValue = "";
|
|
5318
5603
|
for (const sub of child.elements ?? []) if (sub.name === "w:r") cachedValue += collectRunText(sub);
|
|
5319
5604
|
if (cachedValue) sf.cachedValue = cachedValue;
|
|
5605
|
+
const sfLock = attrBool(child, "w:fldLock");
|
|
5606
|
+
if (sfLock !== void 0) sf.fldLock = sfLock;
|
|
5607
|
+
const sfDirty = attrBool(child, "w:dirty");
|
|
5608
|
+
if (sfDirty !== void 0) sf.dirty = sfDirty;
|
|
5320
5609
|
childList.push({ simpleField: sf });
|
|
5321
5610
|
}
|
|
5322
5611
|
break;
|
|
@@ -5502,13 +5791,31 @@ function parseRunLevelChildren(elements, ctx) {
|
|
|
5502
5791
|
}
|
|
5503
5792
|
return childList;
|
|
5504
5793
|
}
|
|
5794
|
+
/** True when a child is a single-field `{ text: string }` run (simple text). */
|
|
5795
|
+
function isTextOnlyRun(c) {
|
|
5796
|
+
return typeof c === "object" && c !== null && "text" in c && Object.keys(c).length === 1;
|
|
5797
|
+
}
|
|
5505
5798
|
function parseParagraph(el, ctx) {
|
|
5506
5799
|
const opts = {};
|
|
5800
|
+
const paraId = attr(el, "w14:paraId");
|
|
5801
|
+
if (paraId) opts.paraId = paraId;
|
|
5802
|
+
const textId = attr(el, "w14:textId");
|
|
5803
|
+
if (textId) opts.textId = textId;
|
|
5804
|
+
const rsid = attr(el, "w:rsidR");
|
|
5805
|
+
if (rsid) opts.rsid = rsid;
|
|
5806
|
+
const defaultRunRsid = attr(el, "w:rsidRDefault");
|
|
5807
|
+
if (defaultRunRsid) opts.defaultRunRsid = defaultRunRsid;
|
|
5808
|
+
const propertiesRsid = attr(el, "w:rsidP");
|
|
5809
|
+
if (propertiesRsid) opts.propertiesRsid = propertiesRsid;
|
|
5810
|
+
const runPropertiesRsid = attr(el, "w:rsidRPr");
|
|
5811
|
+
if (runPropertiesRsid) opts.runPropertiesRsid = runPropertiesRsid;
|
|
5812
|
+
const deletionRsid = attr(el, "w:rsidDel");
|
|
5813
|
+
if (deletionRsid) opts.deletionRsid = deletionRsid;
|
|
5507
5814
|
const pPr = findChild(el, "w:pPr");
|
|
5508
5815
|
if (pPr) Object.assign(opts, parseParagraphProperties(pPr, ctx));
|
|
5509
5816
|
const childList = parseRunLevelChildren(el.elements, ctx);
|
|
5510
5817
|
if (childList.length > 0) {
|
|
5511
|
-
if (childList.every(
|
|
5818
|
+
if (childList.every(isTextOnlyRun)) {
|
|
5512
5819
|
const combined = childList.map((c) => c.text).join("");
|
|
5513
5820
|
if (combined && Object.keys(opts).length === 0) return combined;
|
|
5514
5821
|
if (combined) {
|
|
@@ -5858,6 +6165,8 @@ function parseWpsShapeCore(wspEl, ctx) {
|
|
|
5858
6165
|
if (effectLst) result.effects = effectListDesc.parse(effectLst, ctx);
|
|
5859
6166
|
const custGeom = findChild(spPr, "a:custGeom");
|
|
5860
6167
|
if (custGeom) result.customGeometry = customGeometryDesc.parse(custGeom, ctx);
|
|
6168
|
+
const prstGeom = findChild(spPr, "a:prstGeom");
|
|
6169
|
+
if (prstGeom) result.presetGeometry = presetGeometryDesc.parse(prstGeom, ctx);
|
|
5861
6170
|
}
|
|
5862
6171
|
const bodyPr = findChild(wspEl, "wps:bodyPr");
|
|
5863
6172
|
if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr);
|
|
@@ -6522,6 +6831,7 @@ function stringifyWpsShape(opts, ctx) {
|
|
|
6522
6831
|
rotation: transform.rotation
|
|
6523
6832
|
}, NOOP_CTX) ?? "");
|
|
6524
6833
|
if (opts.customGeometry) spPrParts.push(customGeometryDesc$1.stringify(opts.customGeometry, NOOP_CTX) ?? "");
|
|
6834
|
+
else if (opts.presetGeometry) spPrParts.push(presetGeometryDesc$1.stringify(opts.presetGeometry, NOOP_CTX) ?? "");
|
|
6525
6835
|
else spPrParts.push("<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>");
|
|
6526
6836
|
if (opts.fill) spPrParts.push(fillDesc$1.stringify(opts.fill, NOOP_CTX) ?? "");
|
|
6527
6837
|
if (opts.outline) spPrParts.push(outlineDesc$1.stringify(opts.outline, NOOP_CTX) ?? "");
|
|
@@ -6910,7 +7220,7 @@ function stringifyDeletedRun(c) {
|
|
|
6910
7220
|
const parts = [];
|
|
6911
7221
|
const rPr = stringifyRunProperties(opts);
|
|
6912
7222
|
if (rPr) parts.push(rPr);
|
|
6913
|
-
if (opts.break)
|
|
7223
|
+
if (opts.break) parts.push(breakXml(opts.break));
|
|
6914
7224
|
const fieldMap = {
|
|
6915
7225
|
CURRENT: "PAGE",
|
|
6916
7226
|
TOTAL_PAGES: "NUMPAGES",
|
|
@@ -6929,7 +7239,7 @@ function stringifyRunInline(opts, ctx) {
|
|
|
6929
7239
|
const parts = [];
|
|
6930
7240
|
const rPr = stringifyRunProperties(opts);
|
|
6931
7241
|
if (rPr) parts.push(rPr);
|
|
6932
|
-
if (opts.break)
|
|
7242
|
+
if (opts.break) parts.push(breakXml(opts.break));
|
|
6933
7243
|
if (opts.children) for (const child of opts.children) if (typeof child === "string") parts.push(`<w:t xml:space="preserve">${escapeXml(child)}</w:t>`);
|
|
6934
7244
|
else {
|
|
6935
7245
|
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
@@ -6939,8 +7249,9 @@ function stringifyRunInline(opts, ctx) {
|
|
|
6939
7249
|
}
|
|
6940
7250
|
else if (opts.text !== void 0) parts.push(`<w:t xml:space="preserve">${escapeXml(String(opts.text))}</w:t>`);
|
|
6941
7251
|
const rsidAttrs = [];
|
|
6942
|
-
if (opts.
|
|
6943
|
-
if (opts.
|
|
7252
|
+
if (opts.rsid) rsidAttrs.push(` w:rsidR="${opts.rsid}"`);
|
|
7253
|
+
if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr="${opts.runPropertiesRsid}"`);
|
|
7254
|
+
if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel="${opts.deletionRsid}"`);
|
|
6944
7255
|
const attr = rsidAttrs.join("");
|
|
6945
7256
|
const body = parts.join("");
|
|
6946
7257
|
return body.length === 0 ? attr ? `<w:r${attr}/>` : "<w:r/>" : `<w:r${attr}>${body}</w:r>`;
|
|
@@ -6970,7 +7281,7 @@ let nextChartId = 1;
|
|
|
6970
7281
|
*/
|
|
6971
7282
|
function wrapDrawingRun(drawingXml, opts) {
|
|
6972
7283
|
const xml = drawingXml ?? "";
|
|
6973
|
-
const rPr = opts.
|
|
7284
|
+
const rPr = stringifyRunProperties(opts.runProperties) ?? "";
|
|
6974
7285
|
if (opts.vmlFallback) return `<w:r>${rPr}<mc:AlternateContent><mc:Choice Requires="${opts.mcChoiceRequires ?? "wps"}">${xml}</mc:Choice>${opts.vmlFallback}</mc:AlternateContent></w:r>`;
|
|
6975
7286
|
return `<w:r>${rPr}${xml}</w:r>`;
|
|
6976
7287
|
}
|
|
@@ -7010,25 +7321,36 @@ function registerVmlFallbackMedia(opts, ctx) {
|
|
|
7010
7321
|
}
|
|
7011
7322
|
}
|
|
7012
7323
|
/**
|
|
7013
|
-
*
|
|
7014
|
-
* no b/bCs, sz/szCs pairing), else regenerate from the structured fields.
|
|
7324
|
+
* Build the rPr XML for a break/tab run from its structured run properties.
|
|
7015
7325
|
*/
|
|
7016
|
-
function
|
|
7017
|
-
const raw = child.rPrRawXml;
|
|
7018
|
-
if (raw) return raw;
|
|
7326
|
+
function runPropertiesXml(child) {
|
|
7019
7327
|
return stringifyRunProperties(child) ?? "";
|
|
7020
7328
|
}
|
|
7021
7329
|
function stringifyChildDispatch(child, ctx) {
|
|
7022
|
-
if ("pageBreak" in child) return `<w:r>${
|
|
7023
|
-
if ("columnBreak" in child) return `<w:r>${
|
|
7024
|
-
if ("tab" in child) return `<w:r>${
|
|
7025
|
-
if ("footnoteReference" in child)
|
|
7026
|
-
|
|
7330
|
+
if ("pageBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="page"/></w:r>`;
|
|
7331
|
+
if ("columnBreak" in child) return `<w:r>${runPropertiesXml(child)}<w:br w:type="column"/></w:r>`;
|
|
7332
|
+
if ("tab" in child) return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;
|
|
7333
|
+
if ("footnoteReference" in child) {
|
|
7334
|
+
const ref = child.footnoteReference;
|
|
7335
|
+
return `<w:r><w:rPr><w:rStyle w:val="FootnoteReference"/></w:rPr><w:footnoteReference w:id="${typeof ref === "number" ? ref : ref.id}"${typeof ref === "object" && ref.customMarkFollows ? " w:customMarkFollows=\"true\"" : ""}/></w:r>`;
|
|
7336
|
+
}
|
|
7337
|
+
if ("endnoteReference" in child) {
|
|
7338
|
+
const ref = child.endnoteReference;
|
|
7339
|
+
return `<w:r><w:rPr><w:rStyle w:val="EndnoteReference"/></w:rPr><w:endnoteReference w:id="${typeof ref === "number" ? ref : ref.id}"${typeof ref === "object" && ref.customMarkFollows ? " w:customMarkFollows=\"true\"" : ""}/></w:r>`;
|
|
7340
|
+
}
|
|
7027
7341
|
if ("commentRangeStart" in child) return `<w:commentRangeStart w:id="${child.commentRangeStart}"/>`;
|
|
7028
7342
|
if ("commentRangeEnd" in child) return `<w:commentRangeEnd w:id="${child.commentRangeEnd}"/>`;
|
|
7029
7343
|
if ("commentReference" in child) return `<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${child.commentReference}"/></w:r>`;
|
|
7030
|
-
if ("bookmarkStart" in child)
|
|
7031
|
-
|
|
7344
|
+
if ("bookmarkStart" in child) {
|
|
7345
|
+
const bs = child.bookmarkStart;
|
|
7346
|
+
const bsDisp = bs.displacedByCustomXml ? ` w:displacedByCustomXml="${bs.displacedByCustomXml}"` : "";
|
|
7347
|
+
return `<w:bookmarkStart w:id="${bs.id}" w:name="${bs.name}"${bsDisp}/>`;
|
|
7348
|
+
}
|
|
7349
|
+
if ("bookmarkEnd" in child) {
|
|
7350
|
+
const be = child.bookmarkEnd;
|
|
7351
|
+
const beDisp = be.displacedByCustomXml ? ` w:displacedByCustomXml="${be.displacedByCustomXml}"` : "";
|
|
7352
|
+
return `<w:bookmarkEnd w:id="${be.id}"${beDisp}/>`;
|
|
7353
|
+
}
|
|
7032
7354
|
if ("symbolRun" in child) {
|
|
7033
7355
|
const opts = child.symbolRun;
|
|
7034
7356
|
return `<w:r>${stringifyRunProperties(opts) ?? ""}<w:sym w:char="${opts.char}" w:font="${opts.symbolfont ?? "Wingdings"}"/></w:r>`;
|
|
@@ -7226,16 +7548,22 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7226
7548
|
if (hl.children) for (const rc of hl.children) if (typeof rc === "string") childParts.push(stringifyRunInline({ text: rc }, ctx));
|
|
7227
7549
|
else childParts.push(stringifyRunInline(rc, ctx));
|
|
7228
7550
|
const body = childParts.join("");
|
|
7551
|
+
const pushHlAttrs = (attrs) => {
|
|
7552
|
+
if (hl.history !== false) attrs.push("w:history=\"1\"");
|
|
7553
|
+
if (hl.tooltip) attrs.push(`w:tooltip="${escapeXml(hl.tooltip)}"`);
|
|
7554
|
+
if (hl.tgtFrame) attrs.push(`w:tgtFrame="${escapeXml(hl.tgtFrame)}"`);
|
|
7555
|
+
if (hl.docLocation) attrs.push(`w:docLocation="${escapeXml(hl.docLocation)}"`);
|
|
7556
|
+
};
|
|
7229
7557
|
if (hl.link) {
|
|
7230
7558
|
const linkId = uniqueId();
|
|
7231
7559
|
ctx.viewWrapper.relationships.addRelationship(linkId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hl.link, TargetModeType.EXTERNAL);
|
|
7232
|
-
const attrs = [`r:id="rId${linkId}"
|
|
7233
|
-
|
|
7560
|
+
const attrs = [`r:id="rId${linkId}"`];
|
|
7561
|
+
pushHlAttrs(attrs);
|
|
7234
7562
|
return `<w:hyperlink ${attrs.join(" ")}>${body}</w:hyperlink>`;
|
|
7235
7563
|
}
|
|
7236
7564
|
if (hl.anchor) {
|
|
7237
|
-
const attrs = [`w:anchor="${escapeXml(hl.anchor)}"
|
|
7238
|
-
|
|
7565
|
+
const attrs = [`w:anchor="${escapeXml(hl.anchor)}"`];
|
|
7566
|
+
pushHlAttrs(attrs);
|
|
7239
7567
|
return `<w:hyperlink ${attrs.join(" ")}>${body}</w:hyperlink>`;
|
|
7240
7568
|
}
|
|
7241
7569
|
return "";
|
|
@@ -7305,8 +7633,11 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7305
7633
|
if ("customXmlMoveToRangeEnd" in child) return `<w:customXmlMoveToRangeEnd w:id="${child.customXmlMoveToRangeEnd}"/>`;
|
|
7306
7634
|
if ("simpleField" in child) {
|
|
7307
7635
|
const sf = child.simpleField;
|
|
7308
|
-
|
|
7309
|
-
|
|
7636
|
+
const sfAttrs = [`w:instr="${escapeXml(sf.instruction)}"`];
|
|
7637
|
+
if (sf.fldLock !== void 0) sfAttrs.push(`w:fldLock="${sf.fldLock ? 1 : 0}"`);
|
|
7638
|
+
if (sf.dirty !== void 0) sfAttrs.push(`w:dirty="${sf.dirty ? 1 : 0}"`);
|
|
7639
|
+
if (sf.cachedValue !== void 0) return `<w:fldSimple ${sfAttrs.join(" ")}><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;
|
|
7640
|
+
return `<w:fldSimple ${sfAttrs.join(" ")}/>`;
|
|
7310
7641
|
}
|
|
7311
7642
|
if ("complexField" in child) {
|
|
7312
7643
|
const cf = child.complexField;
|
|
@@ -7792,10 +8123,10 @@ function stringifyTableRow(row, ctx, extraCells) {
|
|
|
7792
8123
|
parts.splice(insertIdx, 0, stringifyTableCell(cell, ctx));
|
|
7793
8124
|
}
|
|
7794
8125
|
const rsidAttrs = [];
|
|
7795
|
-
if (row.
|
|
7796
|
-
if (row.
|
|
7797
|
-
if (row.
|
|
7798
|
-
if (row.
|
|
8126
|
+
if (row.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr="${row.runPropertiesRsid}"`);
|
|
8127
|
+
if (row.rsid) rsidAttrs.push(` w:rsidR="${row.rsid}"`);
|
|
8128
|
+
if (row.deletionRsid) rsidAttrs.push(` w:rsidDel="${row.deletionRsid}"`);
|
|
8129
|
+
if (row.tableRowRsid) rsidAttrs.push(` w:rsidTr="${row.tableRowRsid}"`);
|
|
7799
8130
|
const attr = rsidAttrs.join("");
|
|
7800
8131
|
const body = parts.join("");
|
|
7801
8132
|
return body ? `<w:tr${attr}>${body}</w:tr>` : attr ? `<w:tr${attr}/>` : "<w:tr/>";
|
|
@@ -7865,14 +8196,12 @@ function parseCellMargins(marginEl) {
|
|
|
7865
8196
|
]) {
|
|
7866
8197
|
const sideEl = findChild(marginEl, `w:${side}`);
|
|
7867
8198
|
if (sideEl) {
|
|
7868
|
-
const
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
} : { size };
|
|
7875
|
-
}
|
|
8199
|
+
const type = attr(sideEl, "w:type");
|
|
8200
|
+
const size = attrMeasure(sideEl, "w:w", type);
|
|
8201
|
+
if (size !== void 0) margins[side] = type ? {
|
|
8202
|
+
size,
|
|
8203
|
+
type
|
|
8204
|
+
} : { size };
|
|
7876
8205
|
}
|
|
7877
8206
|
}
|
|
7878
8207
|
if (Object.keys(margins).length === 0) return void 0;
|
|
@@ -7948,7 +8277,7 @@ function parseTablePropertyExceptions(el) {
|
|
|
7948
8277
|
if (base.borders !== void 0) opts.borders = base.borders;
|
|
7949
8278
|
if (base.shading !== void 0) opts.shading = base.shading;
|
|
7950
8279
|
if (base.alignment !== void 0) opts.alignment = base.alignment;
|
|
7951
|
-
if (base.
|
|
8280
|
+
if (base.cellMargin !== void 0) opts.cellMargin = base.cellMargin;
|
|
7952
8281
|
if (base.tableLook !== void 0) opts.tableLook = base.tableLook;
|
|
7953
8282
|
if (base.cellSpacing !== void 0) opts.cellSpacing = base.cellSpacing;
|
|
7954
8283
|
const tblPrExChange = findChild(el, "w:tblPrExChange");
|
|
@@ -8047,9 +8376,8 @@ function parseTablePropertiesEl(el) {
|
|
|
8047
8376
|
}
|
|
8048
8377
|
const tblW = findChild(el, "w:tblW");
|
|
8049
8378
|
if (tblW) {
|
|
8050
|
-
const rawSize = attr(tblW, "w:w");
|
|
8051
8379
|
const type = attr(tblW, "w:type");
|
|
8052
|
-
const size =
|
|
8380
|
+
const size = attrMeasure(tblW, "w:w", type);
|
|
8053
8381
|
if (size !== void 0 || type) opts.width = {
|
|
8054
8382
|
size: size ?? 0,
|
|
8055
8383
|
...type ? { type } : {}
|
|
@@ -8105,7 +8433,7 @@ function parseTablePropertiesEl(el) {
|
|
|
8105
8433
|
const tblCellMar = findChild(el, "w:tblCellMar");
|
|
8106
8434
|
if (tblCellMar) {
|
|
8107
8435
|
const margins = parseCellMargins(tblCellMar);
|
|
8108
|
-
if (margins) opts.
|
|
8436
|
+
if (margins) opts.cellMargin = margins;
|
|
8109
8437
|
}
|
|
8110
8438
|
const shd = findChild(el, "w:shd");
|
|
8111
8439
|
if (shd) {
|
|
@@ -8151,8 +8479,8 @@ function parseTablePropertiesEl(el) {
|
|
|
8151
8479
|
}
|
|
8152
8480
|
const tblInd = findChild(el, "w:tblInd");
|
|
8153
8481
|
if (tblInd) {
|
|
8154
|
-
const size = attrNum(tblInd, "w:w");
|
|
8155
8482
|
const type = attr(tblInd, "w:type");
|
|
8483
|
+
const size = attrMeasure(tblInd, "w:w", type);
|
|
8156
8484
|
if (size !== void 0) opts.indent = {
|
|
8157
8485
|
size,
|
|
8158
8486
|
...type ? { type } : {}
|
|
@@ -8178,7 +8506,7 @@ function parseTablePropertiesEl(el) {
|
|
|
8178
8506
|
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
8179
8507
|
if (tblCellSpacing) {
|
|
8180
8508
|
const type = attr(tblCellSpacing, "w:type");
|
|
8181
|
-
const w =
|
|
8509
|
+
const w = attrMeasure(tblCellSpacing, "w:w", type);
|
|
8182
8510
|
if (w !== void 0) opts.cellSpacing = {
|
|
8183
8511
|
size: w,
|
|
8184
8512
|
...type ? { type } : {}
|
|
@@ -8221,7 +8549,7 @@ function parseColumnWidthsEl(el) {
|
|
|
8221
8549
|
const tblGrid = findChild(el, "w:tblGrid");
|
|
8222
8550
|
if (!tblGrid) return { widths };
|
|
8223
8551
|
for (const col of children(tblGrid, "w:gridCol")) {
|
|
8224
|
-
const w =
|
|
8552
|
+
const w = attrMeasure(col, "w:w");
|
|
8225
8553
|
widths.push(w ?? 100);
|
|
8226
8554
|
}
|
|
8227
8555
|
const tblGridChange = findChild(tblGrid, "w:tblGridChange");
|
|
@@ -8230,7 +8558,7 @@ function parseColumnWidthsEl(el) {
|
|
|
8230
8558
|
const innerGrid = findChild(tblGridChange, "w:tblGrid");
|
|
8231
8559
|
const revWidths = [];
|
|
8232
8560
|
if (innerGrid) for (const col of children(innerGrid, "w:gridCol")) {
|
|
8233
|
-
const w =
|
|
8561
|
+
const w = attrMeasure(col, "w:w");
|
|
8234
8562
|
revWidths.push(w ?? 100);
|
|
8235
8563
|
}
|
|
8236
8564
|
if (id !== void 0) return {
|
|
@@ -8247,7 +8575,7 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8247
8575
|
const opts = {};
|
|
8248
8576
|
const trHeight = findChild(el, "w:trHeight");
|
|
8249
8577
|
if (trHeight) {
|
|
8250
|
-
const val =
|
|
8578
|
+
const val = attrMeasure(trHeight, "w:val");
|
|
8251
8579
|
const rule = attr(trHeight, "w:hRule");
|
|
8252
8580
|
if (val !== void 0) opts.height = {
|
|
8253
8581
|
value: val,
|
|
@@ -8276,9 +8604,8 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8276
8604
|
}
|
|
8277
8605
|
const wBefore = findChild(el, "w:wBefore");
|
|
8278
8606
|
if (wBefore) {
|
|
8279
|
-
const rawSize = attr(wBefore, "w:w");
|
|
8280
8607
|
const type = attr(wBefore, "w:type");
|
|
8281
|
-
const size =
|
|
8608
|
+
const size = attrMeasure(wBefore, "w:w", type);
|
|
8282
8609
|
if (size !== void 0) opts.widthBefore = {
|
|
8283
8610
|
size,
|
|
8284
8611
|
...type ? { type } : {}
|
|
@@ -8286,9 +8613,8 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8286
8613
|
}
|
|
8287
8614
|
const wAfter = findChild(el, "w:wAfter");
|
|
8288
8615
|
if (wAfter) {
|
|
8289
|
-
const rawSize = attr(wAfter, "w:w");
|
|
8290
8616
|
const type = attr(wAfter, "w:type");
|
|
8291
|
-
const size =
|
|
8617
|
+
const size = attrMeasure(wAfter, "w:w", type);
|
|
8292
8618
|
if (size !== void 0) opts.widthAfter = {
|
|
8293
8619
|
size,
|
|
8294
8620
|
...type ? { type } : {}
|
|
@@ -8304,7 +8630,7 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8304
8630
|
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
8305
8631
|
if (tblCellSpacing) {
|
|
8306
8632
|
const type = attr(tblCellSpacing, "w:type");
|
|
8307
|
-
const w =
|
|
8633
|
+
const w = attrMeasure(tblCellSpacing, "w:w", type);
|
|
8308
8634
|
if (w !== void 0) opts.cellSpacing = {
|
|
8309
8635
|
size: w,
|
|
8310
8636
|
...type ? { type } : {}
|
|
@@ -8342,8 +8668,8 @@ function parseTableCellPropertiesEl(el) {
|
|
|
8342
8668
|
}
|
|
8343
8669
|
const tcW = findChild(el, "w:tcW");
|
|
8344
8670
|
if (tcW) {
|
|
8345
|
-
const size = attrNum(tcW, "w:w");
|
|
8346
8671
|
const type = attr(tcW, "w:type");
|
|
8672
|
+
const size = attrMeasure(tcW, "w:w", type);
|
|
8347
8673
|
if (size !== void 0) opts.width = {
|
|
8348
8674
|
size,
|
|
8349
8675
|
...type ? { type } : {}
|
|
@@ -8489,10 +8815,10 @@ function parseTableRowEl(el, ctx) {
|
|
|
8489
8815
|
if (Object.keys(exceptions).length > 0) opts.propertyExceptions = exceptions;
|
|
8490
8816
|
}
|
|
8491
8817
|
for (const [attrName, optKey] of [
|
|
8492
|
-
["w:rsidRPr", "
|
|
8493
|
-
["w:rsidR", "
|
|
8494
|
-
["w:rsidDel", "
|
|
8495
|
-
["w:rsidTr", "
|
|
8818
|
+
["w:rsidRPr", "runPropertiesRsid"],
|
|
8819
|
+
["w:rsidR", "rsid"],
|
|
8820
|
+
["w:rsidDel", "deletionRsid"],
|
|
8821
|
+
["w:rsidTr", "tableRowRsid"]
|
|
8496
8822
|
]) {
|
|
8497
8823
|
const val = attr(el, attrName);
|
|
8498
8824
|
if (val) opts[optKey] = val;
|
|
@@ -8533,7 +8859,11 @@ function parseTableRowEl(el, ctx) {
|
|
|
8533
8859
|
function parseTableEl(el, ctx) {
|
|
8534
8860
|
const opts = {};
|
|
8535
8861
|
const tblPr = findChild(el, "w:tblPr");
|
|
8536
|
-
if (tblPr)
|
|
8862
|
+
if (tblPr) {
|
|
8863
|
+
const tblPrParsed = parseTablePropertiesEl(tblPr);
|
|
8864
|
+
Object.assign(opts, tblPrParsed);
|
|
8865
|
+
if (tblPrParsed.cellMargin !== void 0) opts.margins = tblPrParsed.cellMargin;
|
|
8866
|
+
}
|
|
8537
8867
|
const grid = parseColumnWidthsEl(el);
|
|
8538
8868
|
if (grid.widths.length > 0) opts.columnWidths = grid.widths;
|
|
8539
8869
|
if (grid.revision) opts.columnWidthsRevision = grid.revision;
|
|
@@ -8947,10 +9277,15 @@ function stringifyLevel(opts) {
|
|
|
8947
9277
|
if (opts.lvlRestart !== void 0) children.push(`<w:lvlRestart w:val="${decimalNumber(opts.lvlRestart)}"/>`);
|
|
8948
9278
|
if (opts.suffix) children.push(`<w:suff w:val="${opts.suffix}"/>`);
|
|
8949
9279
|
if (opts.isLegalNumberingStyle) children.push("<w:isLgl/>");
|
|
8950
|
-
if (opts.text
|
|
9280
|
+
if (opts.text !== void 0 || opts.textNull) {
|
|
9281
|
+
const lvlTextAttrs = [];
|
|
9282
|
+
if (opts.text !== void 0) lvlTextAttrs.push(`w:val="${opts.text}"`);
|
|
9283
|
+
if (opts.textNull) lvlTextAttrs.push("w:null=\"1\"");
|
|
9284
|
+
children.push(`<w:lvlText ${lvlTextAttrs.join(" ")}/>`);
|
|
9285
|
+
}
|
|
8951
9286
|
if (opts.lvlPicBulletId !== void 0) children.push(`<w:lvlPicBulletId w:val="${decimalNumber(opts.lvlPicBulletId)}"/>`);
|
|
8952
9287
|
if (opts.legacy !== void 0) {
|
|
8953
|
-
const legacyAttrs = [];
|
|
9288
|
+
const legacyAttrs = [`w:legacy="${opts.legacy.enabled ?? true ? 1 : 0}"`];
|
|
8954
9289
|
if (opts.legacy.space !== void 0) legacyAttrs.push(`w:legacySpace="${opts.legacy.space}"`);
|
|
8955
9290
|
if (opts.legacy.indent !== void 0) legacyAttrs.push(`w:legacyIndent="${opts.legacy.indent}"`);
|
|
8956
9291
|
children.push(`<w:legacy ${legacyAttrs.join(" ")}/>`);
|
|
@@ -9052,6 +9387,8 @@ function parseLevelEl(el, parseParagraphProperties, ctx) {
|
|
|
9052
9387
|
if (lvlText) {
|
|
9053
9388
|
const val = attr(lvlText, "w:val");
|
|
9054
9389
|
if (val) opts.text = val;
|
|
9390
|
+
const isNull = attrBool(lvlText, "w:null");
|
|
9391
|
+
if (isNull) opts.textNull = isNull;
|
|
9055
9392
|
}
|
|
9056
9393
|
const lvlPicBulletId = findChild(el, "w:lvlPicBulletId");
|
|
9057
9394
|
if (lvlPicBulletId) {
|
|
@@ -9061,11 +9398,13 @@ function parseLevelEl(el, parseParagraphProperties, ctx) {
|
|
|
9061
9398
|
const legacyEl = findChild(el, "w:legacy");
|
|
9062
9399
|
if (legacyEl) {
|
|
9063
9400
|
const legacy = {};
|
|
9401
|
+
const enabled = attrBool(legacyEl, "w:legacy");
|
|
9402
|
+
if (enabled !== void 0) legacy.enabled = enabled;
|
|
9064
9403
|
const space = attrNum(legacyEl, "w:legacySpace");
|
|
9065
9404
|
if (space !== void 0) legacy.space = space;
|
|
9066
9405
|
const indent = attrNum(legacyEl, "w:legacyIndent");
|
|
9067
9406
|
if (indent !== void 0) legacy.indent = indent;
|
|
9068
|
-
|
|
9407
|
+
opts.legacy = legacy;
|
|
9069
9408
|
}
|
|
9070
9409
|
const lvlJc = findChild(el, "w:lvlJc");
|
|
9071
9410
|
if (lvlJc) {
|
|
@@ -9487,23 +9826,34 @@ const createHeaderFooterReference = (type, options) => `<${type} r:id="rId${opti
|
|
|
9487
9826
|
function esc(s) {
|
|
9488
9827
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
9489
9828
|
}
|
|
9829
|
+
/**
|
|
9830
|
+
* Build CT_Style style-level children (name…rsid), shared by paragraph/character/table styles.
|
|
9831
|
+
* Order follows CT_Style sequence: name, aliases, basedOn, next, link, autoRedefine, hidden,
|
|
9832
|
+
* uiPriority, semiHidden, unhideWhenUsed, qFormat, locked, personal, personalCompose,
|
|
9833
|
+
* personalReply, rsid.
|
|
9834
|
+
*/
|
|
9835
|
+
function stringifyStyleLevelChildren(opts) {
|
|
9836
|
+
const parts = [`<w:name w:val="${esc(opts.name ?? opts.id ?? "")}"/>`];
|
|
9837
|
+
if (opts.aliases) parts.push(`<w:aliases w:val="${esc(opts.aliases)}"/>`);
|
|
9838
|
+
if (opts.basedOn) parts.push(`<w:basedOn w:val="${esc(opts.basedOn)}"/>`);
|
|
9839
|
+
if (opts.next) parts.push(`<w:next w:val="${esc(opts.next)}"/>`);
|
|
9840
|
+
if (opts.link) parts.push(`<w:link w:val="${esc(opts.link)}"/>`);
|
|
9841
|
+
if (opts.autoRedefine) parts.push("<w:autoRedefine/>");
|
|
9842
|
+
if (opts.hidden) parts.push("<w:hidden/>");
|
|
9843
|
+
if (opts.uiPriority !== void 0) parts.push(`<w:uiPriority w:val="${opts.uiPriority}"/>`);
|
|
9844
|
+
if (opts.semiHidden) parts.push("<w:semiHidden/>");
|
|
9845
|
+
if (opts.unhideWhenUsed) parts.push("<w:unhideWhenUsed/>");
|
|
9846
|
+
if (opts.quickFormat) parts.push("<w:qFormat/>");
|
|
9847
|
+
if (opts.locked) parts.push("<w:locked/>");
|
|
9848
|
+
if (opts.personal) parts.push("<w:personal/>");
|
|
9849
|
+
if (opts.personalCompose) parts.push("<w:personalCompose/>");
|
|
9850
|
+
if (opts.personalReply) parts.push("<w:personalReply/>");
|
|
9851
|
+
if (opts.rsid) parts.push(`<w:rsid w:val="${opts.rsid}"/>`);
|
|
9852
|
+
return parts.join("");
|
|
9853
|
+
}
|
|
9490
9854
|
/** Build `<w:style>` XML for a paragraph style. */
|
|
9491
9855
|
function stringifyParagraphStyle(opts) {
|
|
9492
|
-
const children = [];
|
|
9493
|
-
children.push(`<w:name w:val="${esc(opts.name ?? opts.id)}"/>`);
|
|
9494
|
-
if (opts.aliases) children.push(`<w:aliases w:val="${esc(opts.aliases)}"/>`);
|
|
9495
|
-
if (opts.basedOn) children.push(`<w:basedOn w:val="${esc(opts.basedOn)}"/>`);
|
|
9496
|
-
if (opts.next) children.push(`<w:next w:val="${esc(opts.next)}"/>`);
|
|
9497
|
-
if (opts.link) children.push(`<w:link w:val="${esc(opts.link)}"/>`);
|
|
9498
|
-
if (opts.autoRedefine) children.push("<w:autoRedefine/>");
|
|
9499
|
-
if (opts.uiPriority !== void 0) children.push(`<w:uiPriority w:val="${opts.uiPriority}"/>`);
|
|
9500
|
-
if (opts.semiHidden) children.push("<w:semiHidden/>");
|
|
9501
|
-
if (opts.unhideWhenUsed) children.push("<w:unhideWhenUsed/>");
|
|
9502
|
-
if (opts.quickFormat) children.push("<w:qFormat/>");
|
|
9503
|
-
if (opts.locked) children.push("<w:locked/>");
|
|
9504
|
-
if (opts.personal) children.push("<w:personal/>");
|
|
9505
|
-
if (opts.personalCompose) children.push("<w:personalCompose/>");
|
|
9506
|
-
if (opts.personalReply) children.push("<w:personalReply/>");
|
|
9856
|
+
const children = [stringifyStyleLevelChildren(opts)];
|
|
9507
9857
|
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
9508
9858
|
if (pPr) children.push(pPr);
|
|
9509
9859
|
const rPr = stringifyRunProperties(opts.run);
|
|
@@ -9512,23 +9862,54 @@ function stringifyParagraphStyle(opts) {
|
|
|
9512
9862
|
}
|
|
9513
9863
|
/** Build `<w:style>` XML for a character style. */
|
|
9514
9864
|
function stringifyCharacterStyle(opts) {
|
|
9515
|
-
const children = [];
|
|
9516
|
-
children.push(`<w:name w:val="${esc(opts.name ?? opts.id)}"/>`);
|
|
9517
|
-
if (opts.aliases) children.push(`<w:aliases w:val="${esc(opts.aliases)}"/>`);
|
|
9518
|
-
if (opts.basedOn) children.push(`<w:basedOn w:val="${esc(opts.basedOn)}"/>`);
|
|
9519
|
-
if (opts.link) children.push(`<w:link w:val="${esc(opts.link)}"/>`);
|
|
9520
|
-
if (opts.autoRedefine) children.push("<w:autoRedefine/>");
|
|
9521
|
-
if (opts.uiPriority !== void 0) children.push(`<w:uiPriority w:val="${opts.uiPriority}"/>`);
|
|
9522
|
-
if (opts.semiHidden) children.push("<w:semiHidden/>");
|
|
9523
|
-
if (opts.unhideWhenUsed) children.push("<w:unhideWhenUsed/>");
|
|
9524
|
-
if (opts.locked) children.push("<w:locked/>");
|
|
9525
|
-
if (opts.personal) children.push("<w:personal/>");
|
|
9526
|
-
if (opts.personalCompose) children.push("<w:personalCompose/>");
|
|
9527
|
-
if (opts.personalReply) children.push("<w:personalReply/>");
|
|
9865
|
+
const children = [stringifyStyleLevelChildren(opts)];
|
|
9528
9866
|
const rPr = stringifyRunProperties(opts.run);
|
|
9529
9867
|
if (rPr) children.push(rPr);
|
|
9530
9868
|
return `<w:style w:type="character" w:styleId="${esc(opts.id)}">${children.join("")}</w:style>`;
|
|
9531
9869
|
}
|
|
9870
|
+
/** Build `<w:tblStylePr>` XML for a conditional table style format. */
|
|
9871
|
+
function stringifyConditionalTableStyle(opts) {
|
|
9872
|
+
const children = [];
|
|
9873
|
+
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
9874
|
+
if (pPr) children.push(pPr);
|
|
9875
|
+
const rPr = stringifyRunProperties(opts.run);
|
|
9876
|
+
if (rPr) children.push(rPr);
|
|
9877
|
+
if (opts.table) {
|
|
9878
|
+
const tblPr = stringifyTableProperties(opts.table);
|
|
9879
|
+
if (tblPr) children.push(tblPr);
|
|
9880
|
+
}
|
|
9881
|
+
if (opts.row) {
|
|
9882
|
+
const trPr = stringifyTableRowProperties(opts.row);
|
|
9883
|
+
if (trPr) children.push(trPr);
|
|
9884
|
+
}
|
|
9885
|
+
if (opts.cell) {
|
|
9886
|
+
const tcPr = stringifyTableCellProperties(opts.cell);
|
|
9887
|
+
if (tcPr) children.push(tcPr);
|
|
9888
|
+
}
|
|
9889
|
+
return `<w:tblStylePr w:type="${opts.type}">${children.join("")}</w:tblStylePr>`;
|
|
9890
|
+
}
|
|
9891
|
+
/** Build `<w:style type="table">` XML for a table style. */
|
|
9892
|
+
function stringifyTableStyle(opts) {
|
|
9893
|
+
const children = [stringifyStyleLevelChildren(opts)];
|
|
9894
|
+
const pPr = stringifyParagraphProperties(opts.paragraph).xml;
|
|
9895
|
+
if (pPr) children.push(pPr);
|
|
9896
|
+
const rPr = stringifyRunProperties(opts.run);
|
|
9897
|
+
if (rPr) children.push(rPr);
|
|
9898
|
+
if (opts.table) {
|
|
9899
|
+
const tblPr = stringifyTableProperties(opts.table);
|
|
9900
|
+
if (tblPr) children.push(tblPr);
|
|
9901
|
+
}
|
|
9902
|
+
if (opts.row) {
|
|
9903
|
+
const trPr = stringifyTableRowProperties(opts.row);
|
|
9904
|
+
if (trPr) children.push(trPr);
|
|
9905
|
+
}
|
|
9906
|
+
if (opts.cell) {
|
|
9907
|
+
const tcPr = stringifyTableCellProperties(opts.cell);
|
|
9908
|
+
if (tcPr) children.push(tcPr);
|
|
9909
|
+
}
|
|
9910
|
+
for (const cf of opts.conditionalFormats ?? []) children.push(stringifyConditionalTableStyle(cf));
|
|
9911
|
+
return `<w:style w:type="table" w:styleId="${esc(opts.id)}">${children.join("")}</w:style>`;
|
|
9912
|
+
}
|
|
9532
9913
|
/** Resolve a user override for heading level N (1-9) from default styles options. */
|
|
9533
9914
|
function headingOverride(options, level) {
|
|
9534
9915
|
switch (level) {
|
|
@@ -9980,6 +10361,7 @@ var Styles = class {
|
|
|
9980
10361
|
const customStyleIds = /* @__PURE__ */ new Set();
|
|
9981
10362
|
for (const s of options.paragraphStyles ?? []) customStyleIds.add(s.id);
|
|
9982
10363
|
for (const s of options.characterStyles ?? []) customStyleIds.add(s.id);
|
|
10364
|
+
for (const s of options.tableStyles ?? []) customStyleIds.add(s.id);
|
|
9983
10365
|
if (options.importedStyles) for (const style of options.importedStyles) {
|
|
9984
10366
|
if (!style._raw) continue;
|
|
9985
10367
|
if (customStyleIds.size > 0) {
|
|
@@ -10023,6 +10405,7 @@ var Styles = class {
|
|
|
10023
10405
|
personalReply: style.personalReply,
|
|
10024
10406
|
run: style.run
|
|
10025
10407
|
}));
|
|
10408
|
+
if (options.tableStyles) for (const style of options.tableStyles) this.parts.push(stringifyTableStyle(style));
|
|
10026
10409
|
}
|
|
10027
10410
|
/**
|
|
10028
10411
|
* Serialize to word/styles.xml content (with XML declaration).
|
|
@@ -10088,6 +10471,7 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
10088
10471
|
const opts = {};
|
|
10089
10472
|
const paragraphStyles = [];
|
|
10090
10473
|
const characterStyles = [];
|
|
10474
|
+
const tableStyles = [];
|
|
10091
10475
|
for (const child of el.elements ?? []) if (child.name === "w:docDefaults") {
|
|
10092
10476
|
const defOpts = parseDocDefaults(child, parseParagraphProperties, ctx);
|
|
10093
10477
|
if (defOpts) opts.default = defOpts;
|
|
@@ -10096,6 +10480,11 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
10096
10480
|
else if (child.name === "w:style") {
|
|
10097
10481
|
const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);
|
|
10098
10482
|
if (!styleOpts?._type || !styleOpts.id) continue;
|
|
10483
|
+
if (styleOpts._type === "table") {
|
|
10484
|
+
delete styleOpts._type;
|
|
10485
|
+
tableStyles.push(styleOpts);
|
|
10486
|
+
continue;
|
|
10487
|
+
}
|
|
10099
10488
|
(opts.importedStyles ??= []).push({ _raw: stringifyElement(child) });
|
|
10100
10489
|
const defaultField = STYLE_ID_TO_DEFAULT_FIELD[styleOpts.id];
|
|
10101
10490
|
if (defaultField) {
|
|
@@ -10112,6 +10501,7 @@ function parseStyleDefinitions(el, parseParagraphProperties, ctx) {
|
|
|
10112
10501
|
}
|
|
10113
10502
|
if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;
|
|
10114
10503
|
if (characterStyles.length > 0) opts.characterStyles = characterStyles;
|
|
10504
|
+
if (tableStyles.length > 0) opts.tableStyles = tableStyles;
|
|
10115
10505
|
return Object.keys(opts).length > 0 ? opts : void 0;
|
|
10116
10506
|
}
|
|
10117
10507
|
function parseDocDefaults(el, parseParagraphProperties, ctx) {
|
|
@@ -10175,6 +10565,12 @@ function parseStyleElement(el, parseParagraphProperties, ctx) {
|
|
|
10175
10565
|
if (findChild(el, "w:personal")) opts.personal = true;
|
|
10176
10566
|
if (findChild(el, "w:personalCompose")) opts.personalCompose = true;
|
|
10177
10567
|
if (findChild(el, "w:personalReply")) opts.personalReply = true;
|
|
10568
|
+
if (findChild(el, "w:hidden")) opts.hidden = true;
|
|
10569
|
+
const rsidEl = findChild(el, "w:rsid");
|
|
10570
|
+
if (rsidEl) {
|
|
10571
|
+
const val = attr(rsidEl, "w:val");
|
|
10572
|
+
if (val) opts.rsid = val;
|
|
10573
|
+
}
|
|
10178
10574
|
const aliases = findChild(el, "w:aliases");
|
|
10179
10575
|
if (aliases) {
|
|
10180
10576
|
const val = attr(aliases, "w:val");
|
|
@@ -10190,6 +10586,55 @@ function parseStyleElement(el, parseParagraphProperties, ctx) {
|
|
|
10190
10586
|
const runOpts = parseRunProperties(rPr);
|
|
10191
10587
|
if (Object.keys(runOpts).length > 0) opts.run = runOpts;
|
|
10192
10588
|
}
|
|
10589
|
+
const tblPr = findChild(el, "w:tblPr");
|
|
10590
|
+
if (tblPr) {
|
|
10591
|
+
const tableOpts = parseTablePropertiesEl(tblPr);
|
|
10592
|
+
if (Object.keys(tableOpts).length > 0) opts.table = tableOpts;
|
|
10593
|
+
}
|
|
10594
|
+
const trPr = findChild(el, "w:trPr");
|
|
10595
|
+
if (trPr) {
|
|
10596
|
+
const rowOpts = parseTableRowPropertiesEl(trPr);
|
|
10597
|
+
if (Object.keys(rowOpts).length > 0) opts.row = rowOpts;
|
|
10598
|
+
}
|
|
10599
|
+
const tcPr = findChild(el, "w:tcPr");
|
|
10600
|
+
if (tcPr) {
|
|
10601
|
+
const cellOpts = parseTableCellPropertiesEl(tcPr);
|
|
10602
|
+
if (Object.keys(cellOpts).length > 0) opts.cell = cellOpts;
|
|
10603
|
+
}
|
|
10604
|
+
const conditionalFormats = [];
|
|
10605
|
+
for (const child of el.elements ?? []) {
|
|
10606
|
+
if (child.name !== "w:tblStylePr") continue;
|
|
10607
|
+
const type = attr(child, "w:type");
|
|
10608
|
+
if (!type) continue;
|
|
10609
|
+
const cf = { type };
|
|
10610
|
+
const cfPPr = findChild(child, "w:pPr");
|
|
10611
|
+
if (cfPPr) {
|
|
10612
|
+
const paraOpts = parseParagraphProperties(cfPPr, ctx);
|
|
10613
|
+
if (Object.keys(paraOpts).length > 0) cf.paragraph = paraOpts;
|
|
10614
|
+
}
|
|
10615
|
+
const cfRPr = findChild(child, "w:rPr");
|
|
10616
|
+
if (cfRPr) {
|
|
10617
|
+
const runOpts = parseRunProperties(cfRPr);
|
|
10618
|
+
if (Object.keys(runOpts).length > 0) cf.run = runOpts;
|
|
10619
|
+
}
|
|
10620
|
+
const cfTblPr = findChild(child, "w:tblPr");
|
|
10621
|
+
if (cfTblPr) {
|
|
10622
|
+
const tableOpts = parseTablePropertiesEl(cfTblPr);
|
|
10623
|
+
if (Object.keys(tableOpts).length > 0) cf.table = tableOpts;
|
|
10624
|
+
}
|
|
10625
|
+
const cfTrPr = findChild(child, "w:trPr");
|
|
10626
|
+
if (cfTrPr) {
|
|
10627
|
+
const rowOpts = parseTableRowPropertiesEl(cfTrPr);
|
|
10628
|
+
if (Object.keys(rowOpts).length > 0) cf.row = rowOpts;
|
|
10629
|
+
}
|
|
10630
|
+
const cfTcPr = findChild(child, "w:tcPr");
|
|
10631
|
+
if (cfTcPr) {
|
|
10632
|
+
const cellOpts = parseTableCellPropertiesEl(cfTcPr);
|
|
10633
|
+
if (Object.keys(cellOpts).length > 0) cf.cell = cellOpts;
|
|
10634
|
+
}
|
|
10635
|
+
conditionalFormats.push(cf);
|
|
10636
|
+
}
|
|
10637
|
+
if (conditionalFormats.length > 0) opts.conditionalFormats = conditionalFormats;
|
|
10193
10638
|
return opts;
|
|
10194
10639
|
}
|
|
10195
10640
|
//#endregion
|
|
@@ -10230,8 +10675,443 @@ function attrEl(tag, attrs) {
|
|
|
10230
10675
|
const a = attrStr(attrs);
|
|
10231
10676
|
return a ? `<${tag} ${a}/>` : `<${tag}/>`;
|
|
10232
10677
|
}
|
|
10233
|
-
function compatSetting(name, val) {
|
|
10234
|
-
|
|
10678
|
+
function compatSetting(name, val, uri) {
|
|
10679
|
+
const u = uri ?? "http://schemas.microsoft.com/office/word";
|
|
10680
|
+
return `<w:compatSetting w:name="${escapeAttr$1(name)}" w:uri="${u}" w:val="${val}"/>`;
|
|
10681
|
+
}
|
|
10682
|
+
/** Read a CT_OnOff child as boolean (presence true unless val is explicitly false). */
|
|
10683
|
+
function readOnOff(el) {
|
|
10684
|
+
if (!el || !el.name) return void 0;
|
|
10685
|
+
const v = attr(el, valAttr(el.name));
|
|
10686
|
+
return v !== "false" && v !== "0" && v !== "off";
|
|
10687
|
+
}
|
|
10688
|
+
/** Read an attribute as a number, or undefined if absent/unparseable. */
|
|
10689
|
+
function readNum(el, name) {
|
|
10690
|
+
if (!el) return void 0;
|
|
10691
|
+
const v = attr(el, name);
|
|
10692
|
+
if (v === void 0 || v === "") return void 0;
|
|
10693
|
+
const n = parseInt(v, 10);
|
|
10694
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
10695
|
+
}
|
|
10696
|
+
/** Read an attribute as a string, or undefined if absent. */
|
|
10697
|
+
function readStr(el, name) {
|
|
10698
|
+
if (!el) return void 0;
|
|
10699
|
+
const v = attr(el, name);
|
|
10700
|
+
return v === void 0 || v === "" ? void 0 : v;
|
|
10701
|
+
}
|
|
10702
|
+
/** Read an attribute constrained to an enum; undefined if absent or not allowed. */
|
|
10703
|
+
function readEnum(el, name, allowed) {
|
|
10704
|
+
const v = readStr(el, name);
|
|
10705
|
+
return v !== void 0 && allowed.includes(v) ? v : void 0;
|
|
10706
|
+
}
|
|
10707
|
+
/** Shared password/crypto attributes (AG_TransitionalPassword) → options keys. */
|
|
10708
|
+
const PASSWORD_ATTR_MAP = [
|
|
10709
|
+
[
|
|
10710
|
+
"hashValue",
|
|
10711
|
+
"w:hashValue",
|
|
10712
|
+
false
|
|
10713
|
+
],
|
|
10714
|
+
[
|
|
10715
|
+
"saltValue",
|
|
10716
|
+
"w:saltValue",
|
|
10717
|
+
false
|
|
10718
|
+
],
|
|
10719
|
+
[
|
|
10720
|
+
"hash",
|
|
10721
|
+
"w:hash",
|
|
10722
|
+
false
|
|
10723
|
+
],
|
|
10724
|
+
[
|
|
10725
|
+
"salt",
|
|
10726
|
+
"w:salt",
|
|
10727
|
+
false
|
|
10728
|
+
],
|
|
10729
|
+
[
|
|
10730
|
+
"spinCount",
|
|
10731
|
+
"w:spinCount",
|
|
10732
|
+
true
|
|
10733
|
+
],
|
|
10734
|
+
[
|
|
10735
|
+
"algorithmName",
|
|
10736
|
+
"w:algorithmName",
|
|
10737
|
+
false
|
|
10738
|
+
],
|
|
10739
|
+
[
|
|
10740
|
+
"cryptoAlgorithmClass",
|
|
10741
|
+
"w:cryptAlgorithmClass",
|
|
10742
|
+
false
|
|
10743
|
+
],
|
|
10744
|
+
[
|
|
10745
|
+
"cryptoAlgorithmSid",
|
|
10746
|
+
"w:cryptAlgorithmSid",
|
|
10747
|
+
true
|
|
10748
|
+
],
|
|
10749
|
+
[
|
|
10750
|
+
"cryptoAlgorithmType",
|
|
10751
|
+
"w:cryptAlgorithmType",
|
|
10752
|
+
false
|
|
10753
|
+
],
|
|
10754
|
+
[
|
|
10755
|
+
"cryptoProvider",
|
|
10756
|
+
"w:cryptProvider",
|
|
10757
|
+
false
|
|
10758
|
+
],
|
|
10759
|
+
[
|
|
10760
|
+
"cryptoProviderType",
|
|
10761
|
+
"w:cryptProviderType",
|
|
10762
|
+
false
|
|
10763
|
+
],
|
|
10764
|
+
[
|
|
10765
|
+
"cryptoProviderTypeExtension",
|
|
10766
|
+
"w:cryptProviderTypeExt",
|
|
10767
|
+
true
|
|
10768
|
+
],
|
|
10769
|
+
[
|
|
10770
|
+
"cryptoProviderTypeExtensionSource",
|
|
10771
|
+
"w:cryptProviderTypeExtSource",
|
|
10772
|
+
false
|
|
10773
|
+
],
|
|
10774
|
+
[
|
|
10775
|
+
"algorithmExtensionId",
|
|
10776
|
+
"w:algIdExt",
|
|
10777
|
+
true
|
|
10778
|
+
],
|
|
10779
|
+
[
|
|
10780
|
+
"algorithmExtensionSource",
|
|
10781
|
+
"w:algIdExtSource",
|
|
10782
|
+
false
|
|
10783
|
+
],
|
|
10784
|
+
[
|
|
10785
|
+
"cryptoSpinCount",
|
|
10786
|
+
"w:cryptSpinCount",
|
|
10787
|
+
true
|
|
10788
|
+
]
|
|
10789
|
+
];
|
|
10790
|
+
/** Read shared password/crypto attributes into an options object. */
|
|
10791
|
+
function readPasswordAttrs(el) {
|
|
10792
|
+
const out = {};
|
|
10793
|
+
for (const [key, xmlAttr, isNum] of PASSWORD_ATTR_MAP) {
|
|
10794
|
+
const v = attr(el, xmlAttr);
|
|
10795
|
+
if (v === void 0 || v === "") continue;
|
|
10796
|
+
out[key] = isNum ? parseInt(v, 10) : v;
|
|
10797
|
+
}
|
|
10798
|
+
return out;
|
|
10799
|
+
}
|
|
10800
|
+
/**
|
|
10801
|
+
* CT_OnOff compat flag elements → CompatibilityOptions keys. The XML tag often
|
|
10802
|
+
* differs from the option key (e.g. wordPerfectJustification → w:wpJustification).
|
|
10803
|
+
* Order mirrors stringifyCompatibility so round-trip preserves element order.
|
|
10804
|
+
*/
|
|
10805
|
+
const COMPAT_FLAG_MAP = [
|
|
10806
|
+
["useSingleBorderforContiguousCells", "w:useSingleBorderforContiguousCells"],
|
|
10807
|
+
["wordPerfectJustification", "w:wpJustification"],
|
|
10808
|
+
["noTabStopForHangingIndent", "w:noTabHangInd"],
|
|
10809
|
+
["noLeading", "w:noLeading"],
|
|
10810
|
+
["spaceForUnderline", "w:spaceForUL"],
|
|
10811
|
+
["noColumnBalance", "w:noColumnBalance"],
|
|
10812
|
+
["balanceSingleByteDoubleByteWidth", "w:balanceSingleByteDoubleByteWidth"],
|
|
10813
|
+
["noExtraLineSpacing", "w:noExtraLineSpacing"],
|
|
10814
|
+
["doNotLeaveBackslashAlone", "w:doNotLeaveBackslashAlone"],
|
|
10815
|
+
["underlineTrailingSpaces", "w:ulTrailSpace"],
|
|
10816
|
+
["doNotExpandShiftReturn", "w:doNotExpandShiftReturn"],
|
|
10817
|
+
["spacingInWholePoints", "w:spacingInWholePoints"],
|
|
10818
|
+
["lineWrapLikeWord6", "w:lineWrapLikeWord6"],
|
|
10819
|
+
["printBodyTextBeforeHeader", "w:printBodyTextBeforeHeader"],
|
|
10820
|
+
["printColorsBlack", "w:printColBlack"],
|
|
10821
|
+
["spaceWidth", "w:wpSpaceWidth"],
|
|
10822
|
+
["showBreaksInFrames", "w:showBreaksInFrames"],
|
|
10823
|
+
["subFontBySize", "w:subFontBySize"],
|
|
10824
|
+
["suppressBottomSpacing", "w:suppressBottomSpacing"],
|
|
10825
|
+
["suppressTopSpacing", "w:suppressTopSpacing"],
|
|
10826
|
+
["suppressSpacingAtTopOfPage", "w:suppressSpacingAtTopOfPage"],
|
|
10827
|
+
["suppressTopSpacingWP", "w:suppressTopSpacingWP"],
|
|
10828
|
+
["suppressSpBfAfterPgBrk", "w:suppressSpBfAfterPgBrk"],
|
|
10829
|
+
["swapBordersFacingPages", "w:swapBordersFacingPages"],
|
|
10830
|
+
["convertMailMergeEsc", "w:convMailMergeEsc"],
|
|
10831
|
+
["truncateFontHeightsLikeWP6", "w:truncateFontHeightsLikeWP6"],
|
|
10832
|
+
["macWordSmallCaps", "w:mwSmallCaps"],
|
|
10833
|
+
["usePrinterMetrics", "w:usePrinterMetrics"],
|
|
10834
|
+
["doNotSuppressParagraphBorders", "w:doNotSuppressParagraphBorders"],
|
|
10835
|
+
["wrapTrailSpaces", "w:wrapTrailSpaces"],
|
|
10836
|
+
["footnoteLayoutLikeWW8", "w:footnoteLayoutLikeWW8"],
|
|
10837
|
+
["shapeLayoutLikeWW8", "w:shapeLayoutLikeWW8"],
|
|
10838
|
+
["alignTablesRowByRow", "w:alignTablesRowByRow"],
|
|
10839
|
+
["forgetLastTabAlignment", "w:forgetLastTabAlignment"],
|
|
10840
|
+
["adjustLineHeightInTable", "w:adjustLineHeightInTable"],
|
|
10841
|
+
["autoSpaceLikeWord95", "w:autoSpaceLikeWord95"],
|
|
10842
|
+
["noSpaceRaiseLower", "w:noSpaceRaiseLower"],
|
|
10843
|
+
["doNotUseHTMLParagraphAutoSpacing", "w:doNotUseHTMLParagraphAutoSpacing"],
|
|
10844
|
+
["layoutRawTableWidth", "w:layoutRawTableWidth"],
|
|
10845
|
+
["layoutTableRowsApart", "w:layoutTableRowsApart"],
|
|
10846
|
+
["useWord97LineBreakRules", "w:useWord97LineBreakRules"],
|
|
10847
|
+
["doNotBreakWrappedTables", "w:doNotBreakWrappedTables"],
|
|
10848
|
+
["doNotSnapToGridInCell", "w:doNotSnapToGridInCell"],
|
|
10849
|
+
["selectFieldWithFirstOrLastCharacter", "w:selectFldWithFirstOrLastChar"],
|
|
10850
|
+
["applyBreakingRules", "w:applyBreakingRules"],
|
|
10851
|
+
["doNotWrapTextWithPunctuation", "w:doNotWrapTextWithPunct"],
|
|
10852
|
+
["doNotUseEastAsianBreakRules", "w:doNotUseEastAsianBreakRules"],
|
|
10853
|
+
["useWord2002TableStyleRules", "w:useWord2002TableStyleRules"],
|
|
10854
|
+
["growAutofit", "w:growAutofit"],
|
|
10855
|
+
["useFELayout", "w:useFELayout"],
|
|
10856
|
+
["useNormalStyleForList", "w:useNormalStyleForList"],
|
|
10857
|
+
["doNotUseIndentAsNumberingTabStop", "w:doNotUseIndentAsNumberingTabStop"],
|
|
10858
|
+
["useAlternateEastAsianLineBreakRules", "w:useAltKinsokuLineBreakRules"],
|
|
10859
|
+
["allowSpaceOfSameStyleInTable", "w:allowSpaceOfSameStyleInTable"],
|
|
10860
|
+
["doNotSuppressIndentation", "w:doNotSuppressIndentation"],
|
|
10861
|
+
["doNotAutofitConstrainedTables", "w:doNotAutofitConstrainedTables"],
|
|
10862
|
+
["autofitToFirstFixedWidthCell", "w:autofitToFirstFixedWidthCell"],
|
|
10863
|
+
["underlineTabInNumberingList", "w:underlineTabInNumList"],
|
|
10864
|
+
["displayHangulFixedWidth", "w:displayHangulFixedWidth"],
|
|
10865
|
+
["splitPgBreakAndParaMark", "w:splitPgBreakAndParaMark"],
|
|
10866
|
+
["doNotVerticallyAlignCellWithSp", "w:doNotVertAlignCellWithSp"],
|
|
10867
|
+
["doNotBreakConstrainedForcedTable", "w:doNotBreakConstrainedForcedTable"],
|
|
10868
|
+
["ignoreVerticalAlignmentInTextboxes", "w:doNotVertAlignInTxbx"],
|
|
10869
|
+
["useAnsiKerningPairs", "w:useAnsiKerningPairs"],
|
|
10870
|
+
["cachedColumnBalance", "w:cachedColBalance"]
|
|
10871
|
+
];
|
|
10872
|
+
/** compatSetting names that map to dedicated sugar fields (not into compatSettings[]). */
|
|
10873
|
+
const COMPAT_SETTING_SUGAR = {
|
|
10874
|
+
compatibilityMode: "version",
|
|
10875
|
+
overrideTableStyleFontSizeAndJustification: "overrideTableStyleFontSizeAndJustification",
|
|
10876
|
+
enableOpenTypeFeatures: "enableOpenTypeFeatures",
|
|
10877
|
+
doNotFlipMirrorIndents: "doNotFlipMirrorIndents"
|
|
10878
|
+
};
|
|
10879
|
+
/** Parse w:footnotePr / w:endnotePr (CT_FtnDocProps / CT_EdnDocProps). */
|
|
10880
|
+
function parseFtnEdnPr(el) {
|
|
10881
|
+
const o = {};
|
|
10882
|
+
const pos = readStr(findChild(el, "w:pos"), "w:val");
|
|
10883
|
+
if (pos) o.pos = pos;
|
|
10884
|
+
const numFmtEl = findChild(el, "w:numFmt");
|
|
10885
|
+
if (numFmtEl) {
|
|
10886
|
+
const v = readStr(numFmtEl, "w:val");
|
|
10887
|
+
if (v) o.numFmt = v;
|
|
10888
|
+
const format = readStr(numFmtEl, "w:format");
|
|
10889
|
+
if (format) o.format = format;
|
|
10890
|
+
}
|
|
10891
|
+
const numStart = readNum(findChild(el, "w:numStart"), "w:val");
|
|
10892
|
+
if (numStart !== void 0) o.numStart = numStart;
|
|
10893
|
+
const numRestart = readStr(findChild(el, "w:numRestart"), "w:val");
|
|
10894
|
+
if (numRestart) o.numRestart = numRestart;
|
|
10895
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
10896
|
+
}
|
|
10897
|
+
/** Parse w:compat (CT_Compat): on/off flag elements + w:compatSetting entries. */
|
|
10898
|
+
function parseCompatibility(el) {
|
|
10899
|
+
const o = {};
|
|
10900
|
+
const flagMap = Object.fromEntries(COMPAT_FLAG_MAP.map(([key, tag]) => [tag, key]));
|
|
10901
|
+
const extras = [];
|
|
10902
|
+
for (const child of el.elements ?? []) {
|
|
10903
|
+
if (child.type !== "element" || !child.name) continue;
|
|
10904
|
+
const key = flagMap[child.name];
|
|
10905
|
+
if (key !== void 0) {
|
|
10906
|
+
o[key] = true;
|
|
10907
|
+
continue;
|
|
10908
|
+
}
|
|
10909
|
+
if (child.name === "w:compatSetting") {
|
|
10910
|
+
const name = attr(child, "w:name");
|
|
10911
|
+
const val = attr(child, "w:val");
|
|
10912
|
+
if (name === void 0 || val === void 0) continue;
|
|
10913
|
+
const sugar = COMPAT_SETTING_SUGAR[name];
|
|
10914
|
+
if (sugar === "version") {
|
|
10915
|
+
const n = parseInt(val, 10);
|
|
10916
|
+
if (!Number.isNaN(n)) o.version = n;
|
|
10917
|
+
} else if (sugar !== void 0) o[sugar] = val !== "0" && val !== "false";
|
|
10918
|
+
else extras.push({
|
|
10919
|
+
name,
|
|
10920
|
+
val,
|
|
10921
|
+
uri: attr(child, "w:uri")
|
|
10922
|
+
});
|
|
10923
|
+
}
|
|
10924
|
+
}
|
|
10925
|
+
if (extras.length > 0) o.compatSettings = extras;
|
|
10926
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
10927
|
+
}
|
|
10928
|
+
/** Parse m:mathPr (CT_MathPr). */
|
|
10929
|
+
function parseMathPr(el) {
|
|
10930
|
+
const o = {};
|
|
10931
|
+
const mathFont = readStr(findChild(el, "m:mathFont"), "m:val");
|
|
10932
|
+
if (mathFont) o.mathFont = mathFont;
|
|
10933
|
+
const binaryOperatorBreak = readEnum(findChild(el, "m:brkBin"), "m:val", [
|
|
10934
|
+
"before",
|
|
10935
|
+
"after",
|
|
10936
|
+
"repeat"
|
|
10937
|
+
]);
|
|
10938
|
+
if (binaryOperatorBreak) o.binaryOperatorBreak = binaryOperatorBreak;
|
|
10939
|
+
const binaryOperatorBreakSubtraction = readEnum(findChild(el, "m:brkBinSub"), "m:val", [
|
|
10940
|
+
"--",
|
|
10941
|
+
"-+",
|
|
10942
|
+
"+-"
|
|
10943
|
+
]);
|
|
10944
|
+
if (binaryOperatorBreakSubtraction) o.binaryOperatorBreakSubtraction = binaryOperatorBreakSubtraction;
|
|
10945
|
+
const smallFractions = readOnOff(findChild(el, "m:smallFrac"));
|
|
10946
|
+
if (smallFractions !== void 0) o.smallFractions = smallFractions;
|
|
10947
|
+
const displayDefaults = readOnOff(findChild(el, "m:dispDef"));
|
|
10948
|
+
if (displayDefaults !== void 0) o.displayDefaults = displayDefaults;
|
|
10949
|
+
const leftMargin = readNum(findChild(el, "m:lMargin"), "m:val");
|
|
10950
|
+
if (leftMargin !== void 0) o.leftMargin = leftMargin;
|
|
10951
|
+
const rightMargin = readNum(findChild(el, "m:rMargin"), "m:val");
|
|
10952
|
+
if (rightMargin !== void 0) o.rightMargin = rightMargin;
|
|
10953
|
+
const defaultJustification = readEnum(findChild(el, "m:defJc"), "m:val", [
|
|
10954
|
+
"left",
|
|
10955
|
+
"right",
|
|
10956
|
+
"center",
|
|
10957
|
+
"centerGroup"
|
|
10958
|
+
]);
|
|
10959
|
+
if (defaultJustification) o.defaultJustification = defaultJustification;
|
|
10960
|
+
const preSpacing = readNum(findChild(el, "m:preSp"), "m:val");
|
|
10961
|
+
if (preSpacing !== void 0) o.preSpacing = preSpacing;
|
|
10962
|
+
const postSpacing = readNum(findChild(el, "m:postSp"), "m:val");
|
|
10963
|
+
if (postSpacing !== void 0) o.postSpacing = postSpacing;
|
|
10964
|
+
const interSpacing = readNum(findChild(el, "m:interSp"), "m:val");
|
|
10965
|
+
if (interSpacing !== void 0) o.interSpacing = interSpacing;
|
|
10966
|
+
const intraSpacing = readNum(findChild(el, "m:intraSp"), "m:val");
|
|
10967
|
+
if (intraSpacing !== void 0) o.intraSpacing = intraSpacing;
|
|
10968
|
+
const wrapIndent = readNum(findChild(el, "m:wrapIndent"), "m:val");
|
|
10969
|
+
if (wrapIndent !== void 0) o.wrapIndent = wrapIndent;
|
|
10970
|
+
const wrapRight = readOnOff(findChild(el, "m:wrapRight"));
|
|
10971
|
+
if (wrapRight !== void 0) o.wrapRight = wrapRight;
|
|
10972
|
+
const integralLimitLocation = readEnum(findChild(el, "m:intLim"), "m:val", ["subSup", "undOvr"]);
|
|
10973
|
+
if (integralLimitLocation) o.integralLimitLocation = integralLimitLocation;
|
|
10974
|
+
const naryLimitLocation = readEnum(findChild(el, "m:naryLim"), "m:val", ["subSup", "undOvr"]);
|
|
10975
|
+
if (naryLimitLocation) o.naryLimitLocation = naryLimitLocation;
|
|
10976
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
10977
|
+
}
|
|
10978
|
+
/** Parse w:captions (CT_Captions). */
|
|
10979
|
+
function parseCaptions(el) {
|
|
10980
|
+
const captions = [];
|
|
10981
|
+
const autoCaptions = [];
|
|
10982
|
+
for (const child of el.elements ?? []) {
|
|
10983
|
+
if (child.type !== "element") continue;
|
|
10984
|
+
if (child.name === "w:caption") {
|
|
10985
|
+
const c = { name: attr(child, "w:name") ?? "" };
|
|
10986
|
+
const pos = attr(child, "w:pos");
|
|
10987
|
+
if (pos) c.pos = pos;
|
|
10988
|
+
const chapNum = attr(child, "w:chapNum");
|
|
10989
|
+
if (chapNum !== void 0) c.chapNum = chapNum === "1";
|
|
10990
|
+
const heading = attr(child, "w:heading");
|
|
10991
|
+
if (heading !== void 0) c.heading = parseInt(heading, 10);
|
|
10992
|
+
const noLabel = attr(child, "w:noLabel");
|
|
10993
|
+
if (noLabel !== void 0) c.noLabel = noLabel === "1";
|
|
10994
|
+
const numFmt = attr(child, "w:numFmt");
|
|
10995
|
+
if (numFmt) c.numFmt = numFmt;
|
|
10996
|
+
const sep = attr(child, "w:sep");
|
|
10997
|
+
if (sep) c.sep = sep;
|
|
10998
|
+
captions.push(c);
|
|
10999
|
+
} else if (child.name === "w:autoCaptions") for (const ac of child.elements ?? []) {
|
|
11000
|
+
if (ac.name !== "w:autoCaption") continue;
|
|
11001
|
+
const name = attr(ac, "w:name");
|
|
11002
|
+
const caption = attr(ac, "w:caption");
|
|
11003
|
+
if (name && caption) autoCaptions.push({
|
|
11004
|
+
name,
|
|
11005
|
+
caption
|
|
11006
|
+
});
|
|
11007
|
+
}
|
|
11008
|
+
}
|
|
11009
|
+
if (captions.length === 0) return void 0;
|
|
11010
|
+
const o = { captions };
|
|
11011
|
+
if (autoCaptions.length > 0) o.autoCaptions = autoCaptions;
|
|
11012
|
+
return o;
|
|
11013
|
+
}
|
|
11014
|
+
/** Parse w:odso (CT_Odso). */
|
|
11015
|
+
function parseOdso(el) {
|
|
11016
|
+
const o = {};
|
|
11017
|
+
const udl = readStr(findChild(el, "w:udl"), "w:val");
|
|
11018
|
+
if (udl) o.udl = udl;
|
|
11019
|
+
const table = readStr(findChild(el, "w:table"), "w:val");
|
|
11020
|
+
if (table) o.table = table;
|
|
11021
|
+
const srcEl = findChild(el, "w:src");
|
|
11022
|
+
if (srcEl) {
|
|
11023
|
+
const rid = attr(srcEl, "r:id");
|
|
11024
|
+
if (rid) o.src = rid;
|
|
11025
|
+
}
|
|
11026
|
+
const colDelim = readNum(findChild(el, "w:colDelim"), "w:val");
|
|
11027
|
+
if (colDelim !== void 0) o.colDelim = colDelim;
|
|
11028
|
+
const type = readStr(findChild(el, "w:type"), "w:val");
|
|
11029
|
+
if (type) o.type = type;
|
|
11030
|
+
const fHdr = readOnOff(findChild(el, "w:fHdr"));
|
|
11031
|
+
if (fHdr !== void 0) o.fHdr = fHdr;
|
|
11032
|
+
const fieldMapData = [];
|
|
11033
|
+
for (const child of el.elements ?? []) {
|
|
11034
|
+
if (child.name !== "w:fieldMapData") continue;
|
|
11035
|
+
const fm = {};
|
|
11036
|
+
const t = readStr(findChild(child, "w:type"), "w:val");
|
|
11037
|
+
if (t) fm.type = t;
|
|
11038
|
+
const n = readStr(findChild(child, "w:name"), "w:val");
|
|
11039
|
+
if (n) fm.name = n;
|
|
11040
|
+
const mn = readStr(findChild(child, "w:mappedName"), "w:val");
|
|
11041
|
+
if (mn) fm.mappedName = mn;
|
|
11042
|
+
const col = readNum(findChild(child, "w:column"), "w:val");
|
|
11043
|
+
if (col !== void 0) fm.column = col;
|
|
11044
|
+
const lid = readStr(findChild(child, "w:lid"), "w:val");
|
|
11045
|
+
if (lid) fm.lid = lid;
|
|
11046
|
+
const dyn = readOnOff(findChild(child, "w:dynamicAddress"));
|
|
11047
|
+
if (dyn !== void 0) fm.dynamicAddress = dyn;
|
|
11048
|
+
if (Object.keys(fm).length > 0) fieldMapData.push(fm);
|
|
11049
|
+
}
|
|
11050
|
+
if (fieldMapData.length > 0) o.fieldMapData = fieldMapData;
|
|
11051
|
+
const recipientData = [];
|
|
11052
|
+
for (const child of el.elements ?? []) {
|
|
11053
|
+
if (child.name !== "w:recipientData") continue;
|
|
11054
|
+
const rid = attr(child, "r:id");
|
|
11055
|
+
if (rid) recipientData.push(rid);
|
|
11056
|
+
}
|
|
11057
|
+
if (recipientData.length > 0) o.recipientData = recipientData;
|
|
11058
|
+
const uniqueTag = readStr(findChild(el, "w:uniqueTag"), "w:val");
|
|
11059
|
+
if (uniqueTag) o.uniqueTag = uniqueTag;
|
|
11060
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
11061
|
+
}
|
|
11062
|
+
/** Parse w:mailMerge (CT_MailMerge). */
|
|
11063
|
+
function parseMailMerge(el) {
|
|
11064
|
+
const o = {};
|
|
11065
|
+
const mdt = readStr(findChild(el, "w:mainDocumentType"), "w:val");
|
|
11066
|
+
if (mdt) o.mainDocumentType = mdt;
|
|
11067
|
+
const dataType = readStr(findChild(el, "w:dataType"), "w:val");
|
|
11068
|
+
if (dataType) o.dataType = dataType;
|
|
11069
|
+
const dest = readStr(findChild(el, "w:destination"), "w:val");
|
|
11070
|
+
if (dest) o.destination = dest;
|
|
11071
|
+
const connectString = readStr(findChild(el, "w:connectString"), "w:val");
|
|
11072
|
+
if (connectString) o.connectString = connectString;
|
|
11073
|
+
const query = readStr(findChild(el, "w:query"), "w:val");
|
|
11074
|
+
if (query) o.query = query;
|
|
11075
|
+
const dsEl = findChild(el, "w:dataSource");
|
|
11076
|
+
if (dsEl) {
|
|
11077
|
+
const rid = attr(dsEl, "r:id");
|
|
11078
|
+
if (rid) o.dataSource = rid;
|
|
11079
|
+
}
|
|
11080
|
+
const hsEl = findChild(el, "w:headerSource");
|
|
11081
|
+
if (hsEl) {
|
|
11082
|
+
const rid = attr(hsEl, "r:id");
|
|
11083
|
+
if (rid) o.headerSource = rid;
|
|
11084
|
+
}
|
|
11085
|
+
const linkToQuery = readOnOff(findChild(el, "w:linkToQuery"));
|
|
11086
|
+
if (linkToQuery !== void 0) o.linkToQuery = linkToQuery;
|
|
11087
|
+
const doNotSuppress = readOnOff(findChild(el, "w:doNotSuppressBlankLines"));
|
|
11088
|
+
if (doNotSuppress !== void 0) o.doNotSuppressBlankLines = doNotSuppress;
|
|
11089
|
+
const addressFieldName = readStr(findChild(el, "w:addressFieldName"), "w:val");
|
|
11090
|
+
if (addressFieldName) o.addressFieldName = addressFieldName;
|
|
11091
|
+
const mailSubject = readStr(findChild(el, "w:mailSubject"), "w:val");
|
|
11092
|
+
if (mailSubject) o.mailSubject = mailSubject;
|
|
11093
|
+
const mailAsAttachment = readOnOff(findChild(el, "w:mailAsAttachment"));
|
|
11094
|
+
if (mailAsAttachment !== void 0) o.mailAsAttachment = mailAsAttachment;
|
|
11095
|
+
const viewMergedData = readOnOff(findChild(el, "w:viewMergedData"));
|
|
11096
|
+
if (viewMergedData !== void 0) o.viewMergedData = viewMergedData;
|
|
11097
|
+
const activeRecord = readNum(findChild(el, "w:activeRecord"), "w:val");
|
|
11098
|
+
if (activeRecord !== void 0) o.activeRecord = activeRecord;
|
|
11099
|
+
const checkErrors = readNum(findChild(el, "w:checkErrors"), "w:val");
|
|
11100
|
+
if (checkErrors !== void 0) o.checkErrors = checkErrors;
|
|
11101
|
+
const active = readOnOff(findChild(el, "w:active"));
|
|
11102
|
+
if (active !== void 0) o.active = active;
|
|
11103
|
+
const recipientsEl = findChild(el, "w:recipients");
|
|
11104
|
+
if (recipientsEl) {
|
|
11105
|
+
const rid = attr(recipientsEl, "r:id");
|
|
11106
|
+
if (rid) o.recipients = rid;
|
|
11107
|
+
}
|
|
11108
|
+
const odsoEl = findChild(el, "w:odso");
|
|
11109
|
+
if (odsoEl) {
|
|
11110
|
+
const odso = parseOdso(odsoEl);
|
|
11111
|
+
if (odso) o.odso = odso;
|
|
11112
|
+
}
|
|
11113
|
+
if (Object.keys(o).length === 0) return void 0;
|
|
11114
|
+
return o;
|
|
10235
11115
|
}
|
|
10236
11116
|
function maybeDerive(password, hashValue) {
|
|
10237
11117
|
return password !== void 0 && hashValue === void 0 ? derivePasswordHash(password) : void 0;
|
|
@@ -10407,16 +11287,21 @@ function stringifyCaptions(opts) {
|
|
|
10407
11287
|
function stringifyMathPr(opts) {
|
|
10408
11288
|
const p = [];
|
|
10409
11289
|
if (opts.mathFont !== void 0) p.push(attrEl("m:mathFont", { "m:val": opts.mathFont }));
|
|
10410
|
-
if (opts.
|
|
10411
|
-
if (opts.
|
|
10412
|
-
p.push(onOff("m:smallFrac", opts.
|
|
10413
|
-
p.push(onOff("m:dispDef", opts.
|
|
10414
|
-
p.push(numVal("m:lMargin", opts.
|
|
10415
|
-
p.push(numVal("m:rMargin", opts.
|
|
10416
|
-
if (opts.
|
|
11290
|
+
if (opts.binaryOperatorBreak !== void 0) p.push(attrEl("m:brkBin", { "m:val": opts.binaryOperatorBreak }));
|
|
11291
|
+
if (opts.binaryOperatorBreakSubtraction !== void 0) p.push(attrEl("m:brkBinSub", { "m:val": opts.binaryOperatorBreakSubtraction }));
|
|
11292
|
+
p.push(onOff("m:smallFrac", opts.smallFractions));
|
|
11293
|
+
p.push(onOff("m:dispDef", opts.displayDefaults));
|
|
11294
|
+
p.push(numVal("m:lMargin", opts.leftMargin));
|
|
11295
|
+
p.push(numVal("m:rMargin", opts.rightMargin));
|
|
11296
|
+
if (opts.defaultJustification !== void 0) p.push(attrEl("m:defJc", { "m:val": opts.defaultJustification }));
|
|
11297
|
+
p.push(numVal("m:preSp", opts.preSpacing));
|
|
11298
|
+
p.push(numVal("m:postSp", opts.postSpacing));
|
|
11299
|
+
p.push(numVal("m:interSp", opts.interSpacing));
|
|
11300
|
+
p.push(numVal("m:intraSp", opts.intraSpacing));
|
|
10417
11301
|
p.push(numVal("m:wrapIndent", opts.wrapIndent));
|
|
10418
|
-
|
|
10419
|
-
if (opts.
|
|
11302
|
+
p.push(onOff("m:wrapRight", opts.wrapRight));
|
|
11303
|
+
if (opts.integralLimitLocation !== void 0) p.push(attrEl("m:intLim", { "m:val": opts.integralLimitLocation }));
|
|
11304
|
+
if (opts.naryLimitLocation !== void 0) p.push(attrEl("m:naryLim", { "m:val": opts.naryLimitLocation }));
|
|
10420
11305
|
return `<m:mathPr>${p.join("")}</m:mathPr>`;
|
|
10421
11306
|
}
|
|
10422
11307
|
function stringifyColorSchemeMapping(opts) {
|
|
@@ -10506,6 +11391,18 @@ function stringifyCompatibility(opts) {
|
|
|
10506
11391
|
if (opts.overrideTableStyleFontSizeAndJustification) p.push(compatSetting("overrideTableStyleFontSizeAndJustification", 1));
|
|
10507
11392
|
if (opts.enableOpenTypeFeatures) p.push(compatSetting("enableOpenTypeFeatures", 1));
|
|
10508
11393
|
if (opts.doNotFlipMirrorIndents) p.push(compatSetting("doNotFlipMirrorIndents", 1));
|
|
11394
|
+
if (opts.compatSettings) {
|
|
11395
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
11396
|
+
if (opts.version) emitted.add("compatibilityMode");
|
|
11397
|
+
if (opts.overrideTableStyleFontSizeAndJustification) emitted.add("overrideTableStyleFontSizeAndJustification");
|
|
11398
|
+
if (opts.enableOpenTypeFeatures) emitted.add("enableOpenTypeFeatures");
|
|
11399
|
+
if (opts.doNotFlipMirrorIndents) emitted.add("doNotFlipMirrorIndents");
|
|
11400
|
+
for (const cs of opts.compatSettings) {
|
|
11401
|
+
if (emitted.has(cs.name)) continue;
|
|
11402
|
+
p.push(compatSetting(cs.name, cs.val, cs.uri));
|
|
11403
|
+
emitted.add(cs.name);
|
|
11404
|
+
}
|
|
11405
|
+
}
|
|
10509
11406
|
return p.length ? `<w:compat>${p.join("")}</w:compat>` : "";
|
|
10510
11407
|
}
|
|
10511
11408
|
const SETTINGS_NS = "xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\"";
|
|
@@ -10575,7 +11472,8 @@ const settingsDesc = {
|
|
|
10575
11472
|
["clearFormatting", "w:clearFormatting"],
|
|
10576
11473
|
["top3HeadingStyles", "w:top3HeadingStyles"],
|
|
10577
11474
|
["visibleStyles", "w:visibleStyles"],
|
|
10578
|
-
["alternateStyleNames", "w:alternateStyleNames"]
|
|
11475
|
+
["alternateStyleNames", "w:alternateStyleNames"],
|
|
11476
|
+
["latentStyles", "w:latentStyles"]
|
|
10579
11477
|
]) if (f[prop] !== void 0) attrs[xmlKey] = f[prop] ? "1" : "0";
|
|
10580
11478
|
p.push(attrEl("w:stylePaneFormatFilter", attrs));
|
|
10581
11479
|
}
|
|
@@ -10645,7 +11543,7 @@ const settingsDesc = {
|
|
|
10645
11543
|
p.push(onOff("w:showXMLTags", opts.showXMLTags));
|
|
10646
11544
|
p.push(onOff("w:alwaysMergeEmptyNamespace", opts.alwaysMergeEmptyNamespace));
|
|
10647
11545
|
p.push(onOff("w:updateFields", opts.updateFields));
|
|
10648
|
-
if (opts.hdrShapeDefaults !== void 0) p.push(
|
|
11546
|
+
if (opts.hdrShapeDefaults !== void 0) p.push(`<w:hdrShapeDefaults>${opts.hdrShapeDefaults}</w:hdrShapeDefaults>`);
|
|
10649
11547
|
if (opts.footnotePr !== void 0) p.push(stringifyFootnotePr(opts.footnotePr));
|
|
10650
11548
|
if (opts.endnotePr !== void 0) p.push(stringifyEndnotePr(opts.endnotePr));
|
|
10651
11549
|
const compatXml = stringifyCompatibility({
|
|
@@ -10664,7 +11562,13 @@ const settingsDesc = {
|
|
|
10664
11562
|
if (opts.mathPr !== void 0) p.push(stringifyMathPr(opts.mathPr));
|
|
10665
11563
|
if (opts.attachedSchema !== void 0) for (const schema of opts.attachedSchema) p.push(strVal("w:attachedSchema", schema));
|
|
10666
11564
|
if (opts.colorSchemeMapping !== void 0) p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));
|
|
10667
|
-
if (opts.themeFontLang !== void 0)
|
|
11565
|
+
if (opts.themeFontLang !== void 0) {
|
|
11566
|
+
const a = {};
|
|
11567
|
+
if (opts.themeFontLang.val !== void 0) a["w:val"] = opts.themeFontLang.val;
|
|
11568
|
+
if (opts.themeFontLang.eastAsia !== void 0) a["w:eastAsia"] = opts.themeFontLang.eastAsia;
|
|
11569
|
+
if (opts.themeFontLang.bidi !== void 0) a["w:bidi"] = opts.themeFontLang.bidi;
|
|
11570
|
+
p.push(attrEl("w:themeFontLang", a));
|
|
11571
|
+
}
|
|
10668
11572
|
p.push(onOff("w:doNotIncludeSubdocsInStats", opts.doNotIncludeSubdocsInStats));
|
|
10669
11573
|
p.push(onOff("w:doNotAutoCompressPictures", opts.doNotAutoCompressPictures));
|
|
10670
11574
|
if (opts.forceUpgrade !== void 0) p.push("<w:forceUpgrade/>");
|
|
@@ -10679,160 +11583,84 @@ const settingsDesc = {
|
|
|
10679
11583
|
p.push(attrEl("w:smartTagType", attrs));
|
|
10680
11584
|
}
|
|
10681
11585
|
p.push(onOff("w:doNotEmbedSmartTags", opts.doNotEmbedSmartTags));
|
|
10682
|
-
if (opts.shapeDefaults !== void 0) p.push(
|
|
11586
|
+
if (opts.shapeDefaults !== void 0) p.push(`<w:shapeDefaults>${opts.shapeDefaults}</w:shapeDefaults>`);
|
|
10683
11587
|
p.push(strVal("w:decimalSymbol", opts.decimalSymbol));
|
|
10684
11588
|
p.push(strVal("w:listSeparator", opts.listSeparator));
|
|
10685
11589
|
return `<w:settings ${SETTINGS_NS}>${p.join("")}</w:settings>`;
|
|
10686
11590
|
},
|
|
10687
11591
|
parse(el, _ctx) {
|
|
10688
11592
|
const opts = {};
|
|
10689
|
-
const
|
|
10690
|
-
if (
|
|
10691
|
-
const
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
}
|
|
11593
|
+
const wpEl = findChild(el, "w:writeProtection");
|
|
11594
|
+
if (wpEl) {
|
|
11595
|
+
const wp = readPasswordAttrs(wpEl);
|
|
11596
|
+
const recommended = attr(wpEl, "w:recommended");
|
|
11597
|
+
if (recommended !== void 0) wp.recommended = recommended === "1" || recommended === "true";
|
|
11598
|
+
if (Object.keys(wp).length > 0) opts.writeProtection = wp;
|
|
11599
|
+
}
|
|
11600
|
+
const viewVal = readStr(findChild(el, "w:view"), "w:val");
|
|
11601
|
+
if (viewVal) opts.view = viewVal;
|
|
10699
11602
|
const zoomEl = findChild(el, "w:zoom");
|
|
10700
11603
|
if (zoomEl) {
|
|
10701
11604
|
const zoom = {};
|
|
10702
11605
|
const percent = attr(zoomEl, "w:percent");
|
|
10703
11606
|
if (percent) zoom.percent = parseInt(percent, 10);
|
|
10704
|
-
const
|
|
10705
|
-
if (
|
|
11607
|
+
const zval = attr(zoomEl, "w:val");
|
|
11608
|
+
if (zval) zoom.val = zval;
|
|
10706
11609
|
if (Object.keys(zoom).length > 0) opts.zoom = zoom;
|
|
10707
11610
|
}
|
|
10708
|
-
const
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
const hyphenation = opts.hyphenation ?? {};
|
|
10762
|
-
hyphenation.autoHyphenation = true;
|
|
10763
|
-
opts.hyphenation = hyphenation;
|
|
10764
|
-
}
|
|
10765
|
-
if (findChild(el, "w:doNotHyphenateCaps")) {
|
|
10766
|
-
const hyphenation = opts.hyphenation ?? {};
|
|
10767
|
-
hyphenation.doNotHyphenateCaps = true;
|
|
10768
|
-
opts.hyphenation = hyphenation;
|
|
10769
|
-
}
|
|
10770
|
-
const consHyphEl = findChild(el, "w:consecutiveHyphenLimit");
|
|
10771
|
-
if (consHyphEl) {
|
|
10772
|
-
const val = attr(consHyphEl, "w:val");
|
|
10773
|
-
if (val) {
|
|
10774
|
-
const hyphenation = opts.hyphenation ?? {};
|
|
10775
|
-
hyphenation.consecutiveHyphenLimit = parseInt(val, 10);
|
|
10776
|
-
opts.hyphenation = hyphenation;
|
|
10777
|
-
}
|
|
10778
|
-
}
|
|
10779
|
-
const hyphZoneEl = findChild(el, "w:hyphenationZone");
|
|
10780
|
-
if (hyphZoneEl) {
|
|
10781
|
-
const val = attr(hyphZoneEl, "w:val");
|
|
10782
|
-
if (val) {
|
|
10783
|
-
const hyphenation = opts.hyphenation ?? {};
|
|
10784
|
-
hyphenation.hyphenationZone = parseInt(val, 10);
|
|
10785
|
-
opts.hyphenation = hyphenation;
|
|
10786
|
-
}
|
|
10787
|
-
}
|
|
10788
|
-
const attachedTplEl = findChild(el, "w:attachedTemplate");
|
|
10789
|
-
if (attachedTplEl) {
|
|
10790
|
-
const val = attr(attachedTplEl, "r:id");
|
|
10791
|
-
if (val) opts.attachedTemplate = val;
|
|
10792
|
-
}
|
|
10793
|
-
const spsmEl = findChild(el, "w:stylePaneSortMethod");
|
|
10794
|
-
if (spsmEl) {
|
|
10795
|
-
const val = attr(spsmEl, "w:val");
|
|
10796
|
-
if (val) opts.stylePaneSortMethod = val;
|
|
10797
|
-
}
|
|
10798
|
-
const docTypeEl = findChild(el, "w:documentType");
|
|
10799
|
-
if (docTypeEl) {
|
|
10800
|
-
const val = attr(docTypeEl, "w:val");
|
|
10801
|
-
if (val) opts.documentType = val;
|
|
10802
|
-
}
|
|
10803
|
-
const defTblStyleEl = findChild(el, "w:defaultTableStyle");
|
|
10804
|
-
if (defTblStyleEl) {
|
|
10805
|
-
const val = attr(defTblStyleEl, "w:val");
|
|
10806
|
-
if (val) opts.defaultTableStyle = val;
|
|
10807
|
-
}
|
|
10808
|
-
const spffEl = findChild(el, "w:stylePaneFormatFilter");
|
|
10809
|
-
if (spffEl) {
|
|
10810
|
-
const filter = {};
|
|
10811
|
-
for (const [prop, xmlKey] of [
|
|
10812
|
-
["allStyles", "w:allStyles"],
|
|
10813
|
-
["customStyles", "w:customStyles"],
|
|
10814
|
-
["stylesInUse", "w:stylesInUse"],
|
|
10815
|
-
["headingStyles", "w:headingStyles"],
|
|
10816
|
-
["numberingStyles", "w:numberingStyles"],
|
|
10817
|
-
["tableStyles", "w:tableStyles"],
|
|
10818
|
-
["directFormattingOnRuns", "w:directFormattingOnRuns"],
|
|
10819
|
-
["directFormattingOnParagraphs", "w:directFormattingOnParagraphs"],
|
|
10820
|
-
["directFormattingOnNumbering", "w:directFormattingOnNumbering"],
|
|
10821
|
-
["directFormattingOnTables", "w:directFormattingOnTables"],
|
|
10822
|
-
["clearFormatting", "w:clearFormatting"],
|
|
10823
|
-
["top3HeadingStyles", "w:top3HeadingStyles"],
|
|
10824
|
-
["visibleStyles", "w:visibleStyles"],
|
|
10825
|
-
["alternateStyleNames", "w:alternateStyleNames"]
|
|
10826
|
-
]) {
|
|
10827
|
-
const v = attr(spffEl, xmlKey);
|
|
10828
|
-
if (v !== void 0) filter[prop] = v !== "0" && v !== "false" && v !== "off";
|
|
10829
|
-
}
|
|
10830
|
-
if (Object.keys(filter).length > 0) opts.stylePaneFormatFilter = filter;
|
|
10831
|
-
}
|
|
10832
|
-
const catEl = findChild(el, "w:clickAndTypeStyle");
|
|
10833
|
-
if (catEl) {
|
|
10834
|
-
const val = attr(catEl, "w:val");
|
|
10835
|
-
if (val) opts.clickAndTypeStyle = val;
|
|
11611
|
+
for (const [key, tag] of [
|
|
11612
|
+
["removePersonalInformation", "w:removePersonalInformation"],
|
|
11613
|
+
["removeDateAndTime", "w:removeDateAndTime"],
|
|
11614
|
+
["doNotDisplayPageBoundaries", "w:doNotDisplayPageBoundaries"],
|
|
11615
|
+
["displayBackgroundShape", "w:displayBackgroundShape"],
|
|
11616
|
+
["printPostScriptOverText", "w:printPostScriptOverText"],
|
|
11617
|
+
["printFractionalCharacterWidth", "w:printFractionalCharacterWidth"],
|
|
11618
|
+
["printFormsData", "w:printFormsData"],
|
|
11619
|
+
["embedTrueTypeFonts", "w:embedTrueTypeFonts"],
|
|
11620
|
+
["embedSystemFonts", "w:embedSystemFonts"],
|
|
11621
|
+
["saveSubsetFonts", "w:saveSubsetFonts"],
|
|
11622
|
+
["saveFormsData", "w:saveFormsData"],
|
|
11623
|
+
["mirrorMargins", "w:mirrorMargins"],
|
|
11624
|
+
["alignBordersAndEdges", "w:alignBordersAndEdges"],
|
|
11625
|
+
["bordersDoNotSurroundHeader", "w:bordersDoNotSurroundHeader"],
|
|
11626
|
+
["bordersDoNotSurroundFooter", "w:bordersDoNotSurroundFooter"],
|
|
11627
|
+
["gutterAtTop", "w:gutterAtTop"],
|
|
11628
|
+
["hideSpellingErrors", "w:hideSpellingErrors"],
|
|
11629
|
+
["hideGrammaticalErrors", "w:hideGrammaticalErrors"],
|
|
11630
|
+
["formsDesign", "w:formsDesign"],
|
|
11631
|
+
["linkStyles", "w:linkStyles"],
|
|
11632
|
+
["trackRevisions", "w:trackRevisions"],
|
|
11633
|
+
["doNotTrackMoves", "w:doNotTrackMoves"],
|
|
11634
|
+
["doNotTrackFormatting", "w:doNotTrackFormatting"],
|
|
11635
|
+
["autoFormatOverride", "w:autoFormatOverride"],
|
|
11636
|
+
["styleLockTheme", "w:styleLockTheme"],
|
|
11637
|
+
["styleLockQFSet", "w:styleLockQFSet"],
|
|
11638
|
+
["showEnvelope", "w:showEnvelope"],
|
|
11639
|
+
["evenAndOddHeaders", "w:evenAndOddHeaders"],
|
|
11640
|
+
["bookFoldRevPrinting", "w:bookFoldRevPrinting"],
|
|
11641
|
+
["bookFoldPrinting", "w:bookFoldPrinting"],
|
|
11642
|
+
["doNotUseMarginsForDrawingGridOrigin", "w:doNotUseMarginsForDrawingGridOrigin"],
|
|
11643
|
+
["doNotShadeFormData", "w:doNotShadeFormData"],
|
|
11644
|
+
["noPunctuationKerning", "w:noPunctuationKerning"],
|
|
11645
|
+
["printTwoOnOne", "w:printTwoOnOne"],
|
|
11646
|
+
["strictFirstAndLastChars", "w:strictFirstAndLastChars"],
|
|
11647
|
+
["savePreviewPicture", "w:savePreviewPicture"],
|
|
11648
|
+
["doNotValidateAgainstSchema", "w:doNotValidateAgainstSchema"],
|
|
11649
|
+
["saveInvalidXml", "w:saveInvalidXml"],
|
|
11650
|
+
["ignoreMixedContent", "w:ignoreMixedContent"],
|
|
11651
|
+
["alwaysShowPlaceholderText", "w:alwaysShowPlaceholderText"],
|
|
11652
|
+
["doNotDemarcateInvalidXml", "w:doNotDemarcateInvalidXml"],
|
|
11653
|
+
["saveXmlDataOnly", "w:saveXmlDataOnly"],
|
|
11654
|
+
["useXSLTWhenSaving", "w:useXSLTWhenSaving"],
|
|
11655
|
+
["showXMLTags", "w:showXMLTags"],
|
|
11656
|
+
["alwaysMergeEmptyNamespace", "w:alwaysMergeEmptyNamespace"],
|
|
11657
|
+
["updateFields", "w:updateFields"],
|
|
11658
|
+
["doNotIncludeSubdocsInStats", "w:doNotIncludeSubdocsInStats"],
|
|
11659
|
+
["doNotAutoCompressPictures", "w:doNotAutoCompressPictures"],
|
|
11660
|
+
["doNotEmbedSmartTags", "w:doNotEmbedSmartTags"]
|
|
11661
|
+
]) {
|
|
11662
|
+
const v = readOnOff(findChild(el, tag));
|
|
11663
|
+
if (v !== void 0) opts[key] = v;
|
|
10836
11664
|
}
|
|
10837
11665
|
const awsList = [];
|
|
10838
11666
|
for (const child of el.elements ?? []) {
|
|
@@ -10864,45 +11692,252 @@ const settingsDesc = {
|
|
|
10864
11692
|
if (grammar) proof.grammar = grammar;
|
|
10865
11693
|
if (Object.keys(proof).length > 0) opts.proofState = proof;
|
|
10866
11694
|
}
|
|
11695
|
+
const attachedTplEl = findChild(el, "w:attachedTemplate");
|
|
11696
|
+
if (attachedTplEl) {
|
|
11697
|
+
const rid = attr(attachedTplEl, "r:id");
|
|
11698
|
+
if (rid) opts.attachedTemplate = rid;
|
|
11699
|
+
}
|
|
11700
|
+
const spffEl = findChild(el, "w:stylePaneFormatFilter");
|
|
11701
|
+
if (spffEl) {
|
|
11702
|
+
const filter = {};
|
|
11703
|
+
for (const [prop, xmlKey] of [
|
|
11704
|
+
["allStyles", "w:allStyles"],
|
|
11705
|
+
["customStyles", "w:customStyles"],
|
|
11706
|
+
["stylesInUse", "w:stylesInUse"],
|
|
11707
|
+
["headingStyles", "w:headingStyles"],
|
|
11708
|
+
["numberingStyles", "w:numberingStyles"],
|
|
11709
|
+
["tableStyles", "w:tableStyles"],
|
|
11710
|
+
["directFormattingOnRuns", "w:directFormattingOnRuns"],
|
|
11711
|
+
["directFormattingOnParagraphs", "w:directFormattingOnParagraphs"],
|
|
11712
|
+
["directFormattingOnNumbering", "w:directFormattingOnNumbering"],
|
|
11713
|
+
["directFormattingOnTables", "w:directFormattingOnTables"],
|
|
11714
|
+
["clearFormatting", "w:clearFormatting"],
|
|
11715
|
+
["top3HeadingStyles", "w:top3HeadingStyles"],
|
|
11716
|
+
["visibleStyles", "w:visibleStyles"],
|
|
11717
|
+
["alternateStyleNames", "w:alternateStyleNames"],
|
|
11718
|
+
["latentStyles", "w:latentStyles"]
|
|
11719
|
+
]) {
|
|
11720
|
+
const v = attr(spffEl, xmlKey);
|
|
11721
|
+
if (v !== void 0) filter[prop] = v !== "0" && v !== "false" && v !== "off";
|
|
11722
|
+
}
|
|
11723
|
+
if (Object.keys(filter).length > 0) opts.stylePaneFormatFilter = filter;
|
|
11724
|
+
}
|
|
11725
|
+
const stylePaneSortMethod = readStr(findChild(el, "w:stylePaneSortMethod"), "w:val");
|
|
11726
|
+
if (stylePaneSortMethod) opts.stylePaneSortMethod = stylePaneSortMethod;
|
|
11727
|
+
const documentType = readStr(findChild(el, "w:documentType"), "w:val");
|
|
11728
|
+
if (documentType) opts.documentType = documentType;
|
|
11729
|
+
const clickAndTypeStyle = readStr(findChild(el, "w:clickAndTypeStyle"), "w:val");
|
|
11730
|
+
if (clickAndTypeStyle) opts.clickAndTypeStyle = clickAndTypeStyle;
|
|
11731
|
+
const defaultTableStyle = readStr(findChild(el, "w:defaultTableStyle"), "w:val");
|
|
11732
|
+
if (defaultTableStyle) opts.defaultTableStyle = defaultTableStyle;
|
|
11733
|
+
const mailMergeEl = findChild(el, "w:mailMerge");
|
|
11734
|
+
if (mailMergeEl) {
|
|
11735
|
+
const mm = parseMailMerge(mailMergeEl);
|
|
11736
|
+
if (mm) opts.mailMerge = mm;
|
|
11737
|
+
}
|
|
11738
|
+
const revViewEl = findChild(el, "w:revisionView");
|
|
11739
|
+
if (revViewEl) {
|
|
11740
|
+
const rv = {};
|
|
11741
|
+
for (const [k, a] of [
|
|
11742
|
+
["markup", "w:markup"],
|
|
11743
|
+
["comments", "w:comments"],
|
|
11744
|
+
["insDel", "w:insDel"],
|
|
11745
|
+
["formatting", "w:formatting"],
|
|
11746
|
+
["inkAnnotations", "w:inkAnnotations"]
|
|
11747
|
+
]) {
|
|
11748
|
+
const v = attr(revViewEl, a);
|
|
11749
|
+
if (v !== void 0) rv[k] = v !== "false" && v !== "0";
|
|
11750
|
+
}
|
|
11751
|
+
if (Object.keys(rv).length > 0) opts.revisionView = rv;
|
|
11752
|
+
}
|
|
10867
11753
|
const docProtEl = findChild(el, "w:documentProtection");
|
|
10868
11754
|
if (docProtEl) {
|
|
10869
11755
|
const prot = {};
|
|
10870
11756
|
const edit = attr(docProtEl, "w:edit");
|
|
10871
11757
|
if (edit && DOC_PROTECT_EDITS.includes(edit)) prot.edit = edit;
|
|
10872
11758
|
if (attr(docProtEl, "w:enforcement") !== void 0) {
|
|
10873
|
-
|
|
10874
|
-
if (hash) prot.hash = hash;
|
|
10875
|
-
const salt = attr(docProtEl, "w:salt");
|
|
10876
|
-
if (salt) prot.salt = salt;
|
|
10877
|
-
const cryptProviderType = attr(docProtEl, "w:cryptProviderType");
|
|
10878
|
-
if (cryptProviderType) prot.cryptoProviderType = cryptProviderType;
|
|
10879
|
-
const cryptAlgorithmClass = attr(docProtEl, "w:cryptAlgorithmClass");
|
|
10880
|
-
if (cryptAlgorithmClass) prot.cryptoAlgorithmClass = cryptAlgorithmClass;
|
|
10881
|
-
const cryptAlgorithmType = attr(docProtEl, "w:cryptAlgorithmType");
|
|
10882
|
-
if (cryptAlgorithmType) prot.cryptoAlgorithmType = cryptAlgorithmType;
|
|
10883
|
-
const cryptAlgorithmSid = attr(docProtEl, "w:cryptAlgorithmSid");
|
|
10884
|
-
if (cryptAlgorithmSid) prot.cryptoAlgorithmSid = parseInt(cryptAlgorithmSid, 10);
|
|
10885
|
-
const cryptSpinCount = attr(docProtEl, "w:cryptSpinCount");
|
|
10886
|
-
if (cryptSpinCount) prot.cryptoSpinCount = parseInt(cryptSpinCount, 10);
|
|
10887
|
-
const hashValue = attr(docProtEl, "w:hashValue");
|
|
10888
|
-
if (hashValue) prot.hashValue = hashValue;
|
|
10889
|
-
const saltValue = attr(docProtEl, "w:saltValue");
|
|
10890
|
-
if (saltValue) prot.saltValue = saltValue;
|
|
10891
|
-
const spinCount = attr(docProtEl, "w:spinCount");
|
|
10892
|
-
if (spinCount) prot.spinCount = parseInt(spinCount, 10);
|
|
10893
|
-
const algorithmName = attr(docProtEl, "w:algorithmName");
|
|
10894
|
-
if (algorithmName) prot.algorithmName = algorithmName;
|
|
11759
|
+
Object.assign(prot, readPasswordAttrs(docProtEl));
|
|
10895
11760
|
const formatting = attr(docProtEl, "w:formatting");
|
|
10896
11761
|
if (formatting !== void 0) prot.formatting = formatting === "1" || formatting === "true";
|
|
10897
11762
|
}
|
|
10898
11763
|
if (Object.keys(prot).length > 0) opts.documentProtection = prot;
|
|
10899
11764
|
}
|
|
10900
|
-
const
|
|
10901
|
-
if (
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
11765
|
+
const defaultTabStop = readNum(findChild(el, "w:defaultTabStop"), "w:val");
|
|
11766
|
+
if (defaultTabStop !== void 0) opts.defaultTabStop = defaultTabStop;
|
|
11767
|
+
if (findChild(el, "w:autoHyphenation") || findChild(el, "w:doNotHyphenateCaps") || findChild(el, "w:consecutiveHyphenLimit") || findChild(el, "w:hyphenationZone")) {
|
|
11768
|
+
const hyphenation = {};
|
|
11769
|
+
const autoHyph = readOnOff(findChild(el, "w:autoHyphenation"));
|
|
11770
|
+
if (autoHyph !== void 0) hyphenation.autoHyphenation = autoHyph;
|
|
11771
|
+
const noHyphCaps = readOnOff(findChild(el, "w:doNotHyphenateCaps"));
|
|
11772
|
+
if (noHyphCaps !== void 0) hyphenation.doNotHyphenateCaps = noHyphCaps;
|
|
11773
|
+
const consLimit = readNum(findChild(el, "w:consecutiveHyphenLimit"), "w:val");
|
|
11774
|
+
if (consLimit !== void 0) hyphenation.consecutiveHyphenLimit = consLimit;
|
|
11775
|
+
const zone = readNum(findChild(el, "w:hyphenationZone"), "w:val");
|
|
11776
|
+
if (zone !== void 0) hyphenation.hyphenationZone = zone;
|
|
11777
|
+
if (Object.keys(hyphenation).length > 0) opts.hyphenation = hyphenation;
|
|
11778
|
+
}
|
|
11779
|
+
const summaryLength = readNum(findChild(el, "w:summaryLength"), "w:val");
|
|
11780
|
+
if (summaryLength !== void 0) opts.summaryLength = summaryLength;
|
|
11781
|
+
const bookFoldSheets = readNum(findChild(el, "w:bookFoldPrintingSheets"), "w:val");
|
|
11782
|
+
if (bookFoldSheets !== void 0) opts.bookFoldPrintingSheets = bookFoldSheets;
|
|
11783
|
+
for (const [key, tag] of [
|
|
11784
|
+
["drawingGridHorizontalSpacing", "w:drawingGridHorizontalSpacing"],
|
|
11785
|
+
["drawingGridVerticalSpacing", "w:drawingGridVerticalSpacing"],
|
|
11786
|
+
["displayHorizontalDrawingGridEvery", "w:displayHorizontalDrawingGridEvery"],
|
|
11787
|
+
["displayVerticalDrawingGridEvery", "w:displayVerticalDrawingGridEvery"],
|
|
11788
|
+
["drawingGridHorizontalOrigin", "w:drawingGridHorizontalOrigin"],
|
|
11789
|
+
["drawingGridVerticalOrigin", "w:drawingGridVerticalOrigin"]
|
|
11790
|
+
]) {
|
|
11791
|
+
const v = readNum(findChild(el, tag), "w:val");
|
|
11792
|
+
if (v !== void 0) opts[key] = v;
|
|
11793
|
+
}
|
|
11794
|
+
const characterSpacingControl = readStr(findChild(el, "w:characterSpacingControl"), "w:val");
|
|
11795
|
+
if (characterSpacingControl) opts.characterSpacingControl = characterSpacingControl;
|
|
11796
|
+
for (const [key, tag] of [["noLineBreaksAfter", "w:noLineBreaksAfter"], ["noLineBreaksBefore", "w:noLineBreaksBefore"]]) {
|
|
11797
|
+
const lbEl = findChild(el, tag);
|
|
11798
|
+
if (!lbEl) continue;
|
|
11799
|
+
const entry = {};
|
|
11800
|
+
const lang = attr(lbEl, "w:lang");
|
|
11801
|
+
if (lang) entry.lang = lang;
|
|
11802
|
+
const val = attr(lbEl, "w:val");
|
|
11803
|
+
if (val) entry.val = val;
|
|
11804
|
+
if (Object.keys(entry).length > 0) opts[key] = entry;
|
|
11805
|
+
}
|
|
11806
|
+
const stxEl = findChild(el, "w:saveThroughXslt");
|
|
11807
|
+
if (stxEl) {
|
|
11808
|
+
const stx = {};
|
|
11809
|
+
const id = attr(stxEl, "r:id");
|
|
11810
|
+
if (id) stx.id = id;
|
|
11811
|
+
const val = attr(stxEl, "w:val");
|
|
11812
|
+
if (val) stx.val = val;
|
|
11813
|
+
const solutionID = attr(stxEl, "w:solutionID");
|
|
11814
|
+
if (solutionID) stx.solutionID = solutionID;
|
|
11815
|
+
if (Object.keys(stx).length > 0) opts.saveThroughXslt = stx;
|
|
11816
|
+
}
|
|
11817
|
+
const hdrSdEl = findChild(el, "w:hdrShapeDefaults");
|
|
11818
|
+
if (hdrSdEl) opts.hdrShapeDefaults = stringify(hdrSdEl);
|
|
11819
|
+
const sdEl = findChild(el, "w:shapeDefaults");
|
|
11820
|
+
if (sdEl) opts.shapeDefaults = stringify(sdEl);
|
|
11821
|
+
const fnPrEl = findChild(el, "w:footnotePr");
|
|
11822
|
+
if (fnPrEl) {
|
|
11823
|
+
const fn = parseFtnEdnPr(fnPrEl);
|
|
11824
|
+
if (fn) opts.footnotePr = fn;
|
|
11825
|
+
}
|
|
11826
|
+
const enPrEl = findChild(el, "w:endnotePr");
|
|
11827
|
+
if (enPrEl) {
|
|
11828
|
+
const en = parseFtnEdnPr(enPrEl);
|
|
11829
|
+
if (en) opts.endnotePr = en;
|
|
11830
|
+
}
|
|
11831
|
+
const compatEl = findChild(el, "w:compat");
|
|
11832
|
+
if (compatEl) {
|
|
11833
|
+
const compat = parseCompatibility(compatEl);
|
|
11834
|
+
if (compat) opts.compatibility = compat;
|
|
11835
|
+
}
|
|
11836
|
+
const docVarsEl = findChild(el, "w:docVars");
|
|
11837
|
+
if (docVarsEl) {
|
|
11838
|
+
const vars = [];
|
|
11839
|
+
for (const child of docVarsEl.elements ?? []) {
|
|
11840
|
+
if (child.name !== "w:docVar") continue;
|
|
11841
|
+
const name = attr(child, "w:name");
|
|
11842
|
+
const val = attr(child, "w:val");
|
|
11843
|
+
if (name !== void 0 && val !== void 0) vars.push({
|
|
11844
|
+
name,
|
|
11845
|
+
val
|
|
11846
|
+
});
|
|
11847
|
+
}
|
|
11848
|
+
if (vars.length > 0) opts.docVars = vars;
|
|
11849
|
+
}
|
|
11850
|
+
const rsidsEl = findChild(el, "w:rsids");
|
|
11851
|
+
if (rsidsEl) {
|
|
11852
|
+
const rsids = {};
|
|
11853
|
+
const root = readStr(findChild(rsidsEl, "w:rsidRoot"), "w:val");
|
|
11854
|
+
if (root) rsids.rsidRoot = root;
|
|
11855
|
+
const list = [];
|
|
11856
|
+
for (const child of rsidsEl.elements ?? []) {
|
|
11857
|
+
if (child.name !== "w:rsid") continue;
|
|
11858
|
+
const val = attr(child, "w:val");
|
|
11859
|
+
if (val) list.push(val);
|
|
11860
|
+
}
|
|
11861
|
+
if (list.length > 0) rsids.rsids = list;
|
|
11862
|
+
if (Object.keys(rsids).length > 0) opts.rsids = rsids;
|
|
11863
|
+
}
|
|
11864
|
+
const mathPrEl = findChild(el, "m:mathPr");
|
|
11865
|
+
if (mathPrEl) {
|
|
11866
|
+
const mp = parseMathPr(mathPrEl);
|
|
11867
|
+
if (mp) opts.mathPr = mp;
|
|
11868
|
+
}
|
|
11869
|
+
const attachedSchemas = [];
|
|
11870
|
+
for (const child of el.elements ?? []) {
|
|
11871
|
+
if (child.name !== "w:attachedSchema") continue;
|
|
11872
|
+
const val = attr(child, "w:val");
|
|
11873
|
+
if (val) attachedSchemas.push(val);
|
|
11874
|
+
}
|
|
11875
|
+
if (attachedSchemas.length > 0) opts.attachedSchema = attachedSchemas;
|
|
11876
|
+
const tflEl = findChild(el, "w:themeFontLang");
|
|
11877
|
+
if (tflEl) {
|
|
11878
|
+
const tfl = {};
|
|
11879
|
+
const val = attr(tflEl, "w:val");
|
|
11880
|
+
if (val) tfl.val = val;
|
|
11881
|
+
const eastAsia = attr(tflEl, "w:eastAsia");
|
|
11882
|
+
if (eastAsia) tfl.eastAsia = eastAsia;
|
|
11883
|
+
const bidi = attr(tflEl, "w:bidi");
|
|
11884
|
+
if (bidi) tfl.bidi = bidi;
|
|
11885
|
+
if (Object.keys(tfl).length > 0) opts.themeFontLang = tfl;
|
|
11886
|
+
}
|
|
11887
|
+
const csmEl = findChild(el, "w:clrSchemeMapping");
|
|
11888
|
+
if (csmEl) {
|
|
11889
|
+
const csm = {};
|
|
11890
|
+
for (const [key, xmlAttr] of [
|
|
11891
|
+
["bg1", "w:bg1"],
|
|
11892
|
+
["t1", "w:t1"],
|
|
11893
|
+
["bg2", "w:bg2"],
|
|
11894
|
+
["t2", "w:t2"],
|
|
11895
|
+
["accent1", "w:accent1"],
|
|
11896
|
+
["accent2", "w:accent2"],
|
|
11897
|
+
["accent3", "w:accent3"],
|
|
11898
|
+
["accent4", "w:accent4"],
|
|
11899
|
+
["accent5", "w:accent5"],
|
|
11900
|
+
["accent6", "w:accent6"],
|
|
11901
|
+
["hyperlink", "w:hyperlink"],
|
|
11902
|
+
["followedHyperlink", "w:followedHyperlink"]
|
|
11903
|
+
]) {
|
|
11904
|
+
const v = attr(csmEl, xmlAttr);
|
|
11905
|
+
if (v) csm[key] = v;
|
|
11906
|
+
}
|
|
11907
|
+
if (Object.keys(csm).length > 0) opts.colorSchemeMapping = csm;
|
|
11908
|
+
}
|
|
11909
|
+
if (findChild(el, "w:forceUpgrade")) opts.forceUpgrade = true;
|
|
11910
|
+
const captionsEl = findChild(el, "w:captions");
|
|
11911
|
+
if (captionsEl) {
|
|
11912
|
+
const captions = parseCaptions(captionsEl);
|
|
11913
|
+
if (captions) opts.captions = captions;
|
|
11914
|
+
}
|
|
11915
|
+
const rmilEl = findChild(el, "w:readModeInkLockDown");
|
|
11916
|
+
if (rmilEl) opts.readModeInkLockDown = {
|
|
11917
|
+
actualPg: attr(rmilEl, "w:actualPg") !== "0",
|
|
11918
|
+
w: parseInt(attr(rmilEl, "w:w") ?? "0", 10),
|
|
11919
|
+
h: parseInt(attr(rmilEl, "w:h") ?? "0", 10),
|
|
11920
|
+
fontSz: parseInt(attr(rmilEl, "w:fontSz") ?? "0", 10)
|
|
11921
|
+
};
|
|
11922
|
+
const smartTags = [];
|
|
11923
|
+
for (const child of el.elements ?? []) {
|
|
11924
|
+
if (child.name !== "w:smartTagType") continue;
|
|
11925
|
+
const entry = {};
|
|
11926
|
+
const ns = attr(child, "w:namespace");
|
|
11927
|
+
if (ns) entry.namespace = ns;
|
|
11928
|
+
const nsuri = attr(child, "w:namespaceuri");
|
|
11929
|
+
if (nsuri) entry.namespaceuri = nsuri;
|
|
11930
|
+
const name = attr(child, "w:name");
|
|
11931
|
+
if (name) entry.name = name;
|
|
11932
|
+
const url = attr(child, "w:url");
|
|
11933
|
+
if (url) entry.url = url;
|
|
11934
|
+
if (Object.keys(entry).length > 0) smartTags.push(entry);
|
|
11935
|
+
}
|
|
11936
|
+
if (smartTags.length > 0) opts.smartTagType = smartTags;
|
|
11937
|
+
const decimalSymbol = readStr(findChild(el, "w:decimalSymbol"), "w:val");
|
|
11938
|
+
if (decimalSymbol) opts.decimalSymbol = decimalSymbol;
|
|
11939
|
+
const listSeparator = readStr(findChild(el, "w:listSeparator"), "w:val");
|
|
11940
|
+
if (listSeparator) opts.listSeparator = listSeparator;
|
|
10906
11941
|
return opts;
|
|
10907
11942
|
}
|
|
10908
11943
|
};
|
|
@@ -11059,6 +12094,25 @@ function parseTocFieldInstruction(instruction, opts) {
|
|
|
11059
12094
|
if ("z" in switches) opts.hideTabAndPageNumbersInWebView = true;
|
|
11060
12095
|
}
|
|
11061
12096
|
/**
|
|
12097
|
+
* Extract TOC options from the elements of a captured TOC field (SDT content or
|
|
12098
|
+
* a bare cross-paragraph field). Feeds every w:instrText to the instruction
|
|
12099
|
+
* parser; non-TOC fields (HYPERLINK/PAGEREF inside the rendered entries) are
|
|
12100
|
+
* ignored — parseTocFieldInstruction only acts on instructions starting "TOC".
|
|
12101
|
+
*/
|
|
12102
|
+
function parseTocFieldFromElements(els) {
|
|
12103
|
+
const opts = {};
|
|
12104
|
+
for (const el of els) collectTocInstructions(el, opts);
|
|
12105
|
+
return opts;
|
|
12106
|
+
}
|
|
12107
|
+
/** Recursively feed every w:instrText to the TOC instruction parser. */
|
|
12108
|
+
function collectTocInstructions(el, opts) {
|
|
12109
|
+
if (el.name === "w:instrText") {
|
|
12110
|
+
const instruction = textOf(el)?.trim();
|
|
12111
|
+
if (instruction) parseTocFieldInstruction(instruction, opts);
|
|
12112
|
+
}
|
|
12113
|
+
for (const c of el.elements ?? []) if (c.type === "element") collectTocInstructions(c, opts);
|
|
12114
|
+
}
|
|
12115
|
+
/**
|
|
11062
12116
|
* Parse field switches like \o "1-3" \h \z into a map.
|
|
11063
12117
|
*/
|
|
11064
12118
|
function parseFieldSwitches(text) {
|
|
@@ -11293,14 +12347,22 @@ function fontXml(font) {
|
|
|
11293
12347
|
const parts = [`<w:font w:name="${escapeXml(font.name)}">`];
|
|
11294
12348
|
if (font.altName) parts.push(`<w:altName w:val="${escapeXml(font.altName)}"/>`);
|
|
11295
12349
|
if (font.panose1) parts.push(`<w:panose1 w:val="${escapeXml(font.panose1)}"/>`);
|
|
11296
|
-
if (font.characterSet
|
|
12350
|
+
if (font.characterSet || font.characterSetName) {
|
|
12351
|
+
const valAttr = font.characterSet ? ` w:val="${escapeXml(font.characterSet)}"` : "";
|
|
12352
|
+
const csAttr = font.characterSetName ? ` w:characterSet="${escapeXml(font.characterSetName)}"` : "";
|
|
12353
|
+
parts.push(`<w:charset${valAttr}${csAttr}/>`);
|
|
12354
|
+
}
|
|
11297
12355
|
const family = font.family ?? (font.embedRid ? "auto" : void 0);
|
|
11298
12356
|
if (family) parts.push(`<w:family w:val="${escapeXml(family)}"/>`);
|
|
11299
12357
|
const pitch = font.pitch ?? (font.embedRid ? "variable" : void 0);
|
|
11300
12358
|
if (pitch) parts.push(`<w:pitch w:val="${escapeXml(pitch)}"/>`);
|
|
11301
12359
|
const sig = font.sig ?? (font.embedRid ? DEFAULT_SIG : void 0);
|
|
11302
12360
|
if (sig) parts.push(`<w:sig w:usb0="${sig.usb0}" w:usb1="${sig.usb1}" w:usb2="${sig.usb2}" w:usb3="${sig.usb3}" w:csb0="${sig.csb0}" w:csb1="${sig.csb1}"/>`);
|
|
11303
|
-
if (font.embedRid)
|
|
12361
|
+
if (font.embedRid) {
|
|
12362
|
+
const embedAttrs = [`r:id="${font.embedRid}"`, `w:fontKey="{${font.fontKey}}"`];
|
|
12363
|
+
if (font.subsetted !== void 0) embedAttrs.push(`w:subsetted="${font.subsetted ? 1 : 0}"`);
|
|
12364
|
+
parts.push(`<w:embedRegular ${embedAttrs.join(" ")}/>`);
|
|
12365
|
+
}
|
|
11304
12366
|
parts.push("</w:font>");
|
|
11305
12367
|
return parts.join("");
|
|
11306
12368
|
}
|
|
@@ -11333,6 +12395,8 @@ const fontTableDesc = {
|
|
|
11333
12395
|
if (charsetEl) {
|
|
11334
12396
|
const val = attr(charsetEl, "w:val");
|
|
11335
12397
|
if (val) font.characterSet = val;
|
|
12398
|
+
const csName = attr(charsetEl, "w:characterSet");
|
|
12399
|
+
if (csName) font.characterSetName = csName;
|
|
11336
12400
|
}
|
|
11337
12401
|
const familyEl = findChild(child, "w:family");
|
|
11338
12402
|
if (familyEl) {
|
|
@@ -11373,6 +12437,8 @@ const fontTableDesc = {
|
|
|
11373
12437
|
if (rawKey) font.fontKey = rawKey.replace(/^\{\{|\}\}$/g, "").replace(/^\{|\}$/g, "");
|
|
11374
12438
|
const rid = attr(embedEl, "r:id");
|
|
11375
12439
|
if (rid) font.embedRid = rid;
|
|
12440
|
+
const subsetted = attrBool(embedEl, "w:subsetted");
|
|
12441
|
+
if (subsetted !== void 0) font.subsetted = subsetted;
|
|
11376
12442
|
}
|
|
11377
12443
|
fonts.push(font);
|
|
11378
12444
|
}
|
|
@@ -11747,6 +12813,10 @@ const STANDARD_DEFAULTS = [
|
|
|
11747
12813
|
{
|
|
11748
12814
|
extension: "odttf",
|
|
11749
12815
|
contentType: "application/vnd.openxmlformats-officedocument.obfuscatedFont"
|
|
12816
|
+
},
|
|
12817
|
+
{
|
|
12818
|
+
extension: "bin",
|
|
12819
|
+
contentType: "application/vnd.openxmlformats-officedocument.oleObject"
|
|
11750
12820
|
}
|
|
11751
12821
|
];
|
|
11752
12822
|
/**
|
|
@@ -12069,22 +13139,22 @@ function parseDivEl(el) {
|
|
|
12069
13139
|
const opts = { id: attrNum(el, "w:id") ?? 0 };
|
|
12070
13140
|
const marLeft = findChild(el, "w:marLeft");
|
|
12071
13141
|
if (marLeft) {
|
|
12072
|
-
const val =
|
|
13142
|
+
const val = attrMeasure(marLeft, "w:val");
|
|
12073
13143
|
if (val !== void 0) opts.marginLeft = val;
|
|
12074
13144
|
}
|
|
12075
13145
|
const marRight = findChild(el, "w:marRight");
|
|
12076
13146
|
if (marRight) {
|
|
12077
|
-
const val =
|
|
13147
|
+
const val = attrMeasure(marRight, "w:val");
|
|
12078
13148
|
if (val !== void 0) opts.marginRight = val;
|
|
12079
13149
|
}
|
|
12080
13150
|
const marTop = findChild(el, "w:marTop");
|
|
12081
13151
|
if (marTop) {
|
|
12082
|
-
const val =
|
|
13152
|
+
const val = attrMeasure(marTop, "w:val");
|
|
12083
13153
|
if (val !== void 0) opts.marginTop = val;
|
|
12084
13154
|
}
|
|
12085
13155
|
const marBottom = findChild(el, "w:marBottom");
|
|
12086
13156
|
if (marBottom) {
|
|
12087
|
-
const val =
|
|
13157
|
+
const val = attrMeasure(marBottom, "w:val");
|
|
12088
13158
|
if (val !== void 0) opts.marginBottom = val;
|
|
12089
13159
|
}
|
|
12090
13160
|
const blockQuote = findChild(el, "w:blockQuote");
|
|
@@ -12201,7 +13271,15 @@ const webSettingsDesc = {
|
|
|
12201
13271
|
p.push("</w:divs>");
|
|
12202
13272
|
}
|
|
12203
13273
|
if (opts.encoding !== void 0) p.push(wsStringVal("w:encoding", opts.encoding));
|
|
12204
|
-
if (opts.optimizeForBrowser !== void 0)
|
|
13274
|
+
if (opts.optimizeForBrowser !== void 0) {
|
|
13275
|
+
const ob = opts.optimizeForBrowser;
|
|
13276
|
+
if (typeof ob === "boolean") p.push(wsOnOff("w:optimizeForBrowser", ob));
|
|
13277
|
+
else {
|
|
13278
|
+
const valAttr = ob.value === false ? " w:val=\"false\"" : "";
|
|
13279
|
+
const targetAttr = ob.target ? ` w:target="${wsEscapeAttr(ob.target)}"` : "";
|
|
13280
|
+
p.push(`<w:optimizeForBrowser${valAttr}${targetAttr}/>`);
|
|
13281
|
+
}
|
|
13282
|
+
}
|
|
12205
13283
|
if (opts.relyOnVML !== void 0) p.push(wsOnOff("w:relyOnVML", opts.relyOnVML));
|
|
12206
13284
|
if (opts.allowPNG !== void 0) p.push(wsOnOff("w:allowPNG", opts.allowPNG));
|
|
12207
13285
|
if (opts.doNotRelyOnCSS !== void 0) p.push(wsOnOff("w:doNotRelyOnCSS", opts.doNotRelyOnCSS));
|
|
@@ -12229,7 +13307,6 @@ const webSettingsDesc = {
|
|
|
12229
13307
|
if (val) opts.encoding = val;
|
|
12230
13308
|
}
|
|
12231
13309
|
for (const [name, optKey] of [
|
|
12232
|
-
["w:optimizeForBrowser", "optimizeForBrowser"],
|
|
12233
13310
|
["w:relyOnVML", "relyOnVML"],
|
|
12234
13311
|
["w:allowPNG", "allowPNG"],
|
|
12235
13312
|
["w:doNotRelyOnCSS", "doNotRelyOnCSS"],
|
|
@@ -12241,6 +13318,15 @@ const webSettingsDesc = {
|
|
|
12241
13318
|
const child = findChild(el, name);
|
|
12242
13319
|
if (child) opts[optKey] = attrBool(child, "w:val") ?? true;
|
|
12243
13320
|
}
|
|
13321
|
+
const obEl = findChild(el, "w:optimizeForBrowser");
|
|
13322
|
+
if (obEl) {
|
|
13323
|
+
const target = attr(obEl, "w:target");
|
|
13324
|
+
if (target) opts.optimizeForBrowser = {
|
|
13325
|
+
value: attrBool(obEl, "w:val") ?? true,
|
|
13326
|
+
target
|
|
13327
|
+
};
|
|
13328
|
+
else opts.optimizeForBrowser = attrBool(obEl, "w:val") ?? true;
|
|
13329
|
+
}
|
|
12244
13330
|
const ppi = findChild(el, "w:pixelsPerInch");
|
|
12245
13331
|
if (ppi) {
|
|
12246
13332
|
const val = attrNum(ppi, "w:val");
|
|
@@ -12255,6 +13341,6 @@ const webSettingsDesc = {
|
|
|
12255
13341
|
}
|
|
12256
13342
|
};
|
|
12257
13343
|
//#endregion
|
|
12258
|
-
export {
|
|
13344
|
+
export { PageBorderZOrder as $, stringifyCustomXmlShell as $t, settingsDesc as A, createBodyProperties as An, sectionPageSizeDefaults as At, stringifyConditionalTableStyle as B, TextAlignmentType as Bn, NumberFormat as Bt, footnotesDesc as C, EmphasisMarkType as Cn, parseSdtBlock as Ct, SdtDateMappingType as D, TextVertOverflowType as Dn, sectionPropertiesDesc as Dt, parseTocFieldInstruction as E, TextHorzOverflowType as En, parseSectionPropertiesEl as Et, parseStyleDefinitions as F, createTransformation as Fn, createVerticalPosition as Ft, createHeaderFooterReference as G, TextWrappingSide as Gt, stringifyTableStyle as H, HeadingLevel as Hn, VerticalPositionAlign as Ht, DefaultStylesFactory as I, HighlightColor as In, createHorizontalPosition as It, LineNumberRestartFormat as J, checkboxSymbolRunInner as Jt, SectionType as K, TextWrappingType as Kt, STYLE_ID_TO_DEFAULT_FIELD as L, TextEffect as Ln, HorizontalPositionRelativeFrom as Lt, buildNumberingCache as M, createImageData$1 as Mn, PageOrientation as Mt, buildStyleCache as N, WORKAROUND2 as Nn, PageNumberSeparator as Nt, SdtLock as O, TextVerticalType as On, stringifySectionPropertiesXml as Ot, extractStyleId as P, Media as Pn, createPageNumberType as Pt, PageBorderOffsetFrom as Q, setBodyParseChild as Qt, collectDefaultOverrideIds as R, PageNumber as Rn, VerticalPositionRelativeFrom as Rt, endnotesDesc as S, PositionalTabRelativeTo as Sn, stringifyTableOfContents as St, parseTocFieldFromElements as T, TextBodyWrappingType as Tn, FontWrapper as Tt, HeaderFooterReferenceType as U, LineRuleType as Un, createWrapThrough as Ut, stringifyParagraphStyle as V, TextboxTightWrapType as Vn, SpaceType as Vt, HeaderFooterType as W, AlignmentType as Wn, createWrapTight as Wt, createPageMargin as X, parseCustomXmlProperties as Xt, createLineNumberType as Y, customXmlBlockDesc as Yt, PageBorderDisplay as Z, sdtBlockDesc as Zt, glossaryDesc as _, createFormFieldData as _n, parseParagraph as _t, appPropertiesDesc as a, WidthType as an, LevelFormat as at, CharacterSet as b, PositionalTabAlignment as bn, stringifyDocumentXml as bt, relationshipsDesc as c, TableLayoutType as cn, parseTablePropertiesEl as ct, withAltChunkOverrides as d, RelativeVerticalPosition as dn, tableDesc as dt, stringifySdtPr as en, DocumentGridType as et, withMediaDefaults as f, TableAnchorType as fn, stringifyChildDispatch as ft, DocPartType as g, FormFieldTextType as gn, resetDrawingIdGen as gt, DocPartGallery as h, ProofErrorType as hn, drawingDesc as ht, webSettingsDesc as i, objectDesc as in, parseNumberingDefinitions as it, Styles as j, parseBodyProperties as jn, PageTextDirectionType as jt, StyleLevel as k, VerticalAnchor as kn, sectionMarginDefaults as kt, buildContentTypesFromRegistry as l, OverlapType as ln, parseTableRowPropertiesEl as lt, DocPartBehavior as m, VerticalMergeType as mn, stringifyRunInline as mt, frameXml as n, subDocDesc as nn, DocumentAttributeNamespaces as nt, customPropertiesDesc as o, TABLE_BORDERS_NONE as on, LevelSuffix as ot, commentsDesc as p, TextDirection as pn, stringifyParagraphInline as pt, createSectionType as q, altChunkDesc as qt, framesetXml as r, stringifyElement as rn, Numbering as rt, corePropertiesDesc as s, BorderStyle as sn, parseTableCellPropertiesEl as st, TargetScreenSize as t, stringifySdtShell as tn, createDocumentGrid as tt, contentTypesDesc as u, RelativeHorizontalPosition as un, setTableParseChild as ut, bibliographyDesc as v, parseFormFieldData as vn, parseParagraphProperties as vt, parseToc as w, UnderlineType as wn, parseSdtProperties as wt, EditGroupType as x, PositionalTabLeader as xn, replaceRelsWithPlaceholders as xt, fontTableDesc as y, RubyAlign as yn, stringifyBodyChild as yt, stringifyCharacterStyle as z, breakXml as zn, HorizontalPositionAlign as zt };
|
|
12259
13345
|
|
|
12260
|
-
//# sourceMappingURL=parts-
|
|
13346
|
+
//# sourceMappingURL=parts-DvRRYUug.mjs.map
|