ooxml-core 1.32.1 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PptxHandler-TESZUH66.cjs → PptxHandler-MGKMIK22.cjs} +3 -3
- package/dist/PptxHandler-Q7CFNKOU.mjs +7 -0
- package/dist/PptxHandler-TEC7SWBU.mjs +4 -0
- package/dist/{PresentationBuilder-3CH5TR4W.mjs → PresentationBuilder-PJMQRZI6.mjs} +2 -2
- package/dist/{PresentationBuilder-S6HXHKEJ.mjs → PresentationBuilder-SADKXDWC.mjs} +4 -4
- package/dist/{PresentationBuilder-5NFBUP7Y.cjs → PresentationBuilder-VP2637RH.cjs} +5 -5
- package/dist/automation/index.cjs +4398 -2262
- package/dist/automation/index.mjs +4398 -2262
- package/dist/chart/funnel-geometry.d.ts +1 -1
- package/dist/chart/funnel-geometry.d.ts.map +1 -1
- package/dist/chart/index.cjs +5743 -3820
- package/dist/chart/index.mjs +5736 -3821
- package/dist/chart/region-map/alias.d.ts +12 -0
- package/dist/chart/region-map/alias.d.ts.map +1 -0
- package/dist/chart/region-map/cache.d.ts +20 -0
- package/dist/chart/region-map/cache.d.ts.map +1 -0
- package/dist/chart/region-map/colors.d.ts +4 -0
- package/dist/chart/region-map/colors.d.ts.map +1 -0
- package/dist/chart/region-map/data.d.ts +45 -0
- package/dist/chart/region-map/data.d.ts.map +1 -0
- package/dist/chart/region-map/geographic-projection.d.ts +4 -0
- package/dist/chart/region-map/geographic-projection.d.ts.map +1 -0
- package/dist/chart/region-map/geometry.d.ts +10 -0
- package/dist/chart/region-map/geometry.d.ts.map +1 -0
- package/dist/chart/region-map/index.cjs +892 -0
- package/dist/chart/region-map/index.d.ts +12 -0
- package/dist/chart/region-map/index.d.ts.map +1 -0
- package/dist/chart/region-map/index.mjs +870 -0
- package/dist/chart/region-map/projection.d.ts +19 -0
- package/dist/chart/region-map/projection.d.ts.map +1 -0
- package/dist/chart/region-map/types.d.ts +39 -0
- package/dist/chart/region-map/types.d.ts.map +1 -0
- package/dist/chart/region-map/value-color-positions.d.ts +4 -0
- package/dist/chart/region-map/value-color-positions.d.ts.map +1 -0
- package/dist/chart/region-map/value-colors.d.ts +4 -0
- package/dist/chart/region-map/value-colors.d.ts.map +1 -0
- package/dist/chart/region-map/world-regions.d.ts +22 -0
- package/dist/chart/region-map/world-regions.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-camera.d.ts +26 -0
- package/dist/chart/render/chart-3d-camera.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-layout.d.ts +27 -0
- package/dist/chart/render/chart-3d-layout.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-marks.d.ts +10 -0
- package/dist/chart/render/chart-3d-marks.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-mesh.d.ts +32 -0
- package/dist/chart/render/chart-3d-mesh.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-pie.d.ts +16 -0
- package/dist/chart/render/chart-3d-pie.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-projection.d.ts +37 -0
- package/dist/chart/render/chart-3d-projection.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-scene.d.ts +9 -0
- package/dist/chart/render/chart-3d-scene.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-shading.d.ts +10 -0
- package/dist/chart/render/chart-3d-shading.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-surface.d.ts +5 -0
- package/dist/chart/render/chart-3d-surface.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-svg.d.ts +7 -0
- package/dist/chart/render/chart-3d-svg.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-walls.d.ts +13 -0
- package/dist/chart/render/chart-3d-walls.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-region-map.d.ts +4 -0
- package/dist/chart/render/chart-svg-region-map.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-text-metrics.d.ts +2 -0
- package/dist/chart/render/chart-svg-text-metrics.d.ts.map +1 -1
- package/dist/chart/render/chart-svg.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +5 -1
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/index.d.ts +5 -0
- package/dist/chart/render/index.d.ts.map +1 -1
- package/dist/chart/render/render-space.d.ts.map +1 -1
- package/dist/chart/render/summary-ex-formatting.d.ts +5 -0
- package/dist/chart/render/summary-ex-formatting.d.ts.map +1 -0
- package/dist/chart/render/summary-ex-series.d.ts.map +1 -1
- package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary.d.ts +5 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-Q6NM64J2.cjs → chunk-2LTIDUXH.cjs} +4791 -950
- package/dist/chunk-2N7RZQLC.mjs +8 -0
- package/dist/{chunk-NAWLWKOJ.mjs → chunk-3LMHYL4W.mjs} +2 -2
- package/dist/{chunk-O7SVHLD7.mjs → chunk-6LJW76BZ.mjs} +4756 -951
- package/dist/{chunk-X6VNUBES.cjs → chunk-BDZR4DZ6.cjs} +2058 -1748
- package/dist/{chunk-IOTGRLJH.mjs → chunk-BQGLWC6N.mjs} +867 -557
- package/dist/{chunk-N6424WKA.mjs → chunk-EBBWRRSB.mjs} +1 -1
- package/dist/{chunk-UYMSFJQZ.mjs → chunk-JQVOUS6B.mjs} +5 -5
- package/dist/{chunk-3H5UAJB3.mjs → chunk-QRXMYOVN.mjs} +870 -525
- package/dist/{chunk-54S5A5PZ.mjs → chunk-VDUNZTJC.mjs} +36 -1
- package/dist/{chunk-4R65YYAD.mjs → chunk-Y2RH4QWG.mjs} +4228 -1070
- package/dist/diagram/drawing-resolve.d.ts.map +1 -1
- package/dist/diagram/drawing-view.d.ts +6 -0
- package/dist/diagram/drawing-view.d.ts.map +1 -1
- package/dist/diagram/engine/engine-to-result.d.ts.map +1 -1
- package/dist/diagram/index.cjs +786 -145
- package/dist/diagram/index.d.ts +1 -0
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.mjs +783 -147
- package/dist/diagram/layout/smartart-layout-types.d.ts +7 -0
- package/dist/diagram/layout/smartart-layout-types.d.ts.map +1 -1
- package/dist/diagram/layout-preview.d.ts +4 -0
- package/dist/diagram/layout-preview.d.ts.map +1 -1
- package/dist/diagram/layout-role-style.d.ts +4 -0
- package/dist/diagram/layout-role-style.d.ts.map +1 -0
- package/dist/diagram/load.d.ts.map +1 -1
- package/dist/diagram/picture-layout.d.ts +23 -0
- package/dist/diagram/picture-layout.d.ts.map +1 -0
- package/dist/diagram/types.d.ts +6 -0
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/diagram/write/cache.d.ts +1 -0
- package/dist/diagram/write/cache.d.ts.map +1 -1
- package/dist/digest/crc32.d.ts +2 -0
- package/dist/digest/crc32.d.ts.map +1 -0
- package/dist/digest/index.cjs +11 -0
- package/dist/digest/index.d.ts +1 -0
- package/dist/digest/index.d.ts.map +1 -1
- package/dist/digest/index.mjs +11 -1
- package/dist/docx/diagram-cache.d.ts.map +1 -1
- package/dist/docx/diagram-save.d.ts.map +1 -1
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +882 -212
- package/dist/docx/embedded.mjs +882 -212
- package/dist/docx/index.cjs +3082 -866
- package/dist/docx/index.mjs +3082 -866
- package/dist/docx/inline-model.d.ts +4 -0
- package/dist/docx/inline-model.d.ts.map +1 -1
- package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/floats.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +2200 -438
- package/dist/docx/layout/index.mjs +2200 -438
- package/dist/docx/layout/input.d.ts +3 -0
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +3 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1311 -641
- package/dist/docx/load/index.mjs +1311 -641
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +2832 -842
- package/dist/docx/ui/index.mjs +2832 -842
- package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
- package/dist/docx/ui/run-adapter.d.ts.map +1 -1
- package/dist/docx/write-drawing.d.ts.map +1 -1
- package/dist/drawingml/index.cjs +707 -111
- package/dist/drawingml/index.d.ts +7 -0
- package/dist/drawingml/index.d.ts.map +1 -1
- package/dist/drawingml/index.mjs +697 -113
- package/dist/drawingml/picture-artistic.d.ts +14 -0
- package/dist/drawingml/picture-artistic.d.ts.map +1 -0
- package/dist/drawingml/picture-effects.d.ts +4 -1
- package/dist/drawingml/picture-effects.d.ts.map +1 -1
- package/dist/drawingml/picture-fill.d.ts.map +1 -1
- package/dist/drawingml/picture-hsl-pixels.d.ts +4 -0
- package/dist/drawingml/picture-hsl-pixels.d.ts.map +1 -0
- package/dist/drawingml/picture-layout.d.ts +25 -0
- package/dist/drawingml/picture-layout.d.ts.map +1 -0
- package/dist/drawingml/picture-standard-effects.d.ts +15 -0
- package/dist/drawingml/picture-standard-effects.d.ts.map +1 -0
- package/dist/drawingml/picture-transfer.d.ts +11 -0
- package/dist/drawingml/picture-transfer.d.ts.map +1 -0
- package/dist/drawingml/raster-image.d.ts +29 -0
- package/dist/drawingml/raster-image.d.ts.map +1 -0
- package/dist/drawingml/types.d.ts +1 -0
- package/dist/drawingml/types.d.ts.map +1 -1
- package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
- package/dist/geometry/index.cjs +38 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +36 -1
- package/dist/geometry/picture-tile.d.ts +29 -0
- package/dist/geometry/picture-tile.d.ts.map +1 -0
- package/dist/index.cjs +15164 -12669
- package/dist/index.mjs +15164 -12669
- package/dist/pptx/automation/index.cjs +7431 -2967
- package/dist/pptx/automation/index.d.ts +5 -5
- package/dist/pptx/automation/index.mjs +7 -7
- package/dist/pptx/chunks/{elements-mSCZ84Tc.d.ts → elements-f3UbFph-.d.ts} +7 -2
- package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DnWlmYCy.d.ts → index-BnH2QjYm.d.ts} +4 -4
- package/dist/pptx/chunks/{index-DnWlmYCy.d.ts.map → index-BnH2QjYm.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-D-FdgqrP.d.ts → index-Bp-1pGo1.d.ts} +4 -4
- package/dist/pptx/chunks/{index-D-FdgqrP.d.ts.map → index-Bp-1pGo1.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-DKybuHPT.d.ts → index-BuMPQDQb.d.ts} +27 -16
- package/dist/pptx/chunks/index-BuMPQDQb.d.ts.map +1 -0
- package/dist/pptx/chunks/{smart-art-DLumQo90.d.ts → smart-art-CmOrPLLQ.d.ts} +86 -2
- package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts → text-operations-D5sgspO6.d.ts} +2 -2
- package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts.map → text-operations-D5sgspO6.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +7196 -2732
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +6 -6
- package/dist/pptx/converter/index.cjs +3895 -503
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +3 -3
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
- package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
- package/dist/pptx/index.cjs +6828 -2969
- package/dist/pptx/index.d.ts +7 -7
- package/dist/pptx/index.mjs +7 -7
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.mjs +2 -2
- package/dist/teams/index.cjs +1964 -726
- package/dist/teams/index.mjs +1964 -726
- package/dist/visio/cell-formula.d.ts +5 -1
- package/dist/visio/cell-formula.d.ts.map +1 -1
- package/dist/visio/collab/index.cjs +3 -1
- package/dist/visio/collab/index.mjs +3 -1
- package/dist/visio/container-relationships.d.ts +19 -0
- package/dist/visio/container-relationships.d.ts.map +1 -0
- package/dist/visio/edit-container-fit.d.ts +19 -0
- package/dist/visio/edit-container-fit.d.ts.map +1 -0
- package/dist/visio/edit-container-members.d.ts +21 -0
- package/dist/visio/edit-container-members.d.ts.map +1 -0
- package/dist/visio/edit-delete.d.ts.map +1 -1
- package/dist/visio/edit-diagram-parts-commands.d.ts +23 -1
- package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -1
- package/dist/visio/edit-diagram-parts.d.ts +3 -2
- package/dist/visio/edit-diagram-parts.d.ts.map +1 -1
- package/dist/visio/edit-geometry.d.ts +4 -1
- package/dist/visio/edit-geometry.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts +13 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
- package/dist/visio/edit-recalculate.d.ts.map +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/formula-analyze.d.ts +2 -0
- package/dist/visio/formula-analyze.d.ts.map +1 -1
- package/dist/visio/formula-evaluate.d.ts.map +1 -1
- package/dist/visio/formula-master.d.ts +1 -0
- package/dist/visio/formula-master.d.ts.map +1 -1
- package/dist/visio/index.cjs +2771 -1312
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +2771 -1312
- package/dist/visio/media.d.ts +4 -23
- package/dist/visio/media.d.ts.map +1 -1
- package/dist/visio/package-common.d.ts +1 -1
- package/dist/visio/package-common.d.ts.map +1 -1
- package/dist/visio/shape-structure.d.ts +6 -3
- package/dist/visio/shape-structure.d.ts.map +1 -1
- package/dist/visio/ui/diagram-parts.d.ts +12 -1
- package/dist/visio/ui/diagram-parts.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +2679 -1201
- package/dist/visio/ui/index.mjs +2679 -1202
- package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-ex.d.ts +1 -0
- package/dist/xlsx/edit/chart-ex.d.ts.map +1 -1
- package/dist/xlsx/edit/filter.d.ts +5 -1
- package/dist/xlsx/edit/filter.d.ts.map +1 -1
- package/dist/xlsx/edit/index.d.ts +1 -0
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/session-calc.d.ts +5 -0
- package/dist/xlsx/edit/session-calc.d.ts.map +1 -1
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/text-columns.d.ts +21 -0
- package/dist/xlsx/edit/text-columns.d.ts.map +1 -0
- package/dist/xlsx/edit/types.d.ts +5 -1
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/embedded-chart-ex-space.d.ts +18 -0
- package/dist/xlsx/embedded-chart-ex-space.d.ts.map +1 -0
- package/dist/xlsx/filter-criteria.d.ts +22 -0
- package/dist/xlsx/filter-criteria.d.ts.map +1 -0
- package/dist/xlsx/filter-dynamic.d.ts +8 -0
- package/dist/xlsx/filter-dynamic.d.ts.map +1 -0
- package/dist/xlsx/filter-menu.d.ts +49 -0
- package/dist/xlsx/filter-menu.d.ts.map +1 -0
- package/dist/xlsx/filter-rows.d.ts +4 -4
- package/dist/xlsx/filter-rows.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +5856 -2934
- package/dist/xlsx/index.d.ts +4 -0
- package/dist/xlsx/index.d.ts.map +1 -1
- package/dist/xlsx/index.mjs +5839 -2934
- package/dist/xlsx/load/index.cjs +1871 -585
- package/dist/xlsx/load/index.mjs +1871 -585
- package/dist/xlsx/model-filter.d.ts +54 -0
- package/dist/xlsx/model-filter.d.ts.map +1 -0
- package/dist/xlsx/model.d.ts +42 -3
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/read/drawing.d.ts.map +1 -1
- package/dist/xlsx/read/filter-columns.d.ts +5 -0
- package/dist/xlsx/read/filter-columns.d.ts.map +1 -0
- package/dist/xlsx/read/shared-strings.d.ts +5 -3
- package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-props.d.ts +2 -2
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/filters.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/filters.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -1
- package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +7177 -4234
- package/dist/xlsx/ui/index.mjs +7177 -4234
- package/dist/xlsx/write/drawing.d.ts.map +1 -1
- package/dist/xlsx/write/filter-columns.d.ts +39 -0
- package/dist/xlsx/write/filter-columns.d.ts.map +1 -0
- package/dist/xlsx/write/shared-strings.d.ts +4 -4
- package/dist/xlsx/write/shared-strings.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-props.d.ts +2 -1
- package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/write/smart-art-cache.d.ts.map +1 -1
- package/dist/xlsx/write/smart-art.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +6 -1
- package/dist/PptxHandler-QY5VL3CY.mjs +0 -7
- package/dist/PptxHandler-SJ5ZUIUX.mjs +0 -4
- package/dist/chunk-3GXV5MPC.mjs +0 -41
- package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DKybuHPT.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +0 -1
package/dist/docx/load/index.mjs
CHANGED
|
@@ -8455,359 +8455,133 @@ function setExtendedRunProperties(doc, props, run2, base) {
|
|
|
8455
8455
|
}
|
|
8456
8456
|
}
|
|
8457
8457
|
|
|
8458
|
-
// drawingml/
|
|
8459
|
-
function
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
emf: "image/x-emf",
|
|
8471
|
-
wmf: "image/x-wmf"
|
|
8458
|
+
// drawingml/dom.ts
|
|
8459
|
+
function attributeReader(element4) {
|
|
8460
|
+
return (name) => {
|
|
8461
|
+
if (!element4) return void 0;
|
|
8462
|
+
const direct = element4.getAttribute(name);
|
|
8463
|
+
if (direct !== null) return direct;
|
|
8464
|
+
const attributes2 = element4.attributes;
|
|
8465
|
+
for (let index = 0; index < attributes2.length; index++) {
|
|
8466
|
+
const candidate = attributes2.item(index);
|
|
8467
|
+
if (candidate && candidate.localName === name) return candidate.value;
|
|
8468
|
+
}
|
|
8469
|
+
return void 0;
|
|
8472
8470
|
};
|
|
8473
|
-
return extension && known[extension] || "application/octet-stream";
|
|
8474
8471
|
}
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
if (target.startsWith("/")) return target.replace(/^\//, "");
|
|
8479
|
-
return `word/${target.replace(/^\.\//, "")}`;
|
|
8472
|
+
function stringAttribute(element4, name) {
|
|
8473
|
+
const value = attributeReader(element4)(name)?.trim();
|
|
8474
|
+
return value ? value : void 0;
|
|
8480
8475
|
}
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
return Object.fromEntries(Object.entries(source2).filter(([, value]) => value !== void 0));
|
|
8476
|
+
function integerAttribute(element4, name) {
|
|
8477
|
+
const parsed = Number.parseInt(attributeReader(element4)(name) ?? "", 10);
|
|
8478
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
8485
8479
|
}
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
var NAMED = {
|
|
8492
|
-
silver: "#c0c0c0",
|
|
8493
|
-
gray: "#808080",
|
|
8494
|
-
grey: "#808080",
|
|
8495
|
-
black: "#000000",
|
|
8496
|
-
white: "#ffffff",
|
|
8497
|
-
red: "#ff0000",
|
|
8498
|
-
blue: "#0000ff",
|
|
8499
|
-
green: "#008000",
|
|
8500
|
-
yellow: "#ffff00"
|
|
8501
|
-
};
|
|
8502
|
-
var POINT_TO_PX = 96 / 72;
|
|
8503
|
-
var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
|
|
8504
|
-
var DEFAULT_WATERMARK_COLOR = "#c0c0c0";
|
|
8505
|
-
function colorOf(value) {
|
|
8506
|
-
const text = (value ?? "").trim().toLowerCase().split(/\s/)[0] ?? "";
|
|
8507
|
-
if (NAMED[text]) return NAMED[text];
|
|
8508
|
-
const hex = /^#?([0-9a-f]{6})$/.exec(text);
|
|
8509
|
-
return hex ? `#${hex[1]}` : DEFAULT_WATERMARK_COLOR;
|
|
8480
|
+
function booleanAttribute(element4, name) {
|
|
8481
|
+
const value = attributeReader(element4)(name)?.trim().toLowerCase();
|
|
8482
|
+
if (value === "1" || value === "true") return true;
|
|
8483
|
+
if (value === "0" || value === "false") return false;
|
|
8484
|
+
return void 0;
|
|
8510
8485
|
}
|
|
8511
|
-
function
|
|
8512
|
-
|
|
8513
|
-
const
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
path3.getAttribute("style") ?? ""
|
|
8520
|
-
)?.[1];
|
|
8521
|
-
const width = /width:\s*([\d.]+)pt/i.exec(style);
|
|
8522
|
-
const height = /height:\s*([\d.]+)pt/i.exec(style);
|
|
8523
|
-
const rotation2 = /rotation:\s*(-?[\d.]+)/i.exec(style);
|
|
8524
|
-
const spec = {
|
|
8525
|
-
text: path3.getAttribute("string") ?? "",
|
|
8526
|
-
color: colorOf(shape.getAttribute("fillcolor")),
|
|
8527
|
-
semitransparent: opacity !== null && opacity !== "" && opacity !== "1",
|
|
8528
|
-
layout: rotation2 && Math.abs(Number(rotation2[1]) % 360) > 1 ? "diagonal" : "horizontal",
|
|
8529
|
-
...family ? { fontFamily: family.trim() } : {}
|
|
8530
|
-
};
|
|
8531
|
-
return {
|
|
8532
|
-
relId: "",
|
|
8533
|
-
partName: "",
|
|
8534
|
-
contentType: "application/octet-stream",
|
|
8535
|
-
widthPx: width ? Math.round(Number(width[1]) * POINT_TO_PX) : 0,
|
|
8536
|
-
heightPx: height ? Math.round(Number(height[1]) * POINT_TO_PX) : 0,
|
|
8537
|
-
unsupported: "Watermark",
|
|
8538
|
-
watermark: spec
|
|
8486
|
+
function descendants(root, local) {
|
|
8487
|
+
const result = [];
|
|
8488
|
+
const visit = (node) => {
|
|
8489
|
+
for (const child8 of Array.from(node.childNodes)) {
|
|
8490
|
+
if (!isElement(child8)) continue;
|
|
8491
|
+
if (child8.localName === local) result.push(child8);
|
|
8492
|
+
visit(child8);
|
|
8493
|
+
}
|
|
8539
8494
|
};
|
|
8495
|
+
visit(root);
|
|
8496
|
+
return result;
|
|
8540
8497
|
}
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8498
|
+
|
|
8499
|
+
// drawingml/picture-crop.ts
|
|
8500
|
+
var SIDES5 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
|
|
8501
|
+
function parsePictureCrop(blipFill) {
|
|
8502
|
+
const rect2 = first(blipFill, "srcRect", NS.a);
|
|
8503
|
+
if (!rect2) return void 0;
|
|
8504
|
+
const result = {};
|
|
8505
|
+
for (const [attr3, key] of Object.entries(SIDES5)) {
|
|
8506
|
+
const raw2 = rect2.getAttribute(attr3);
|
|
8507
|
+
if (raw2 === null || !raw2.trim()) continue;
|
|
8508
|
+
const percent = raw2.endsWith("%");
|
|
8509
|
+
const value = Number(percent ? raw2.slice(0, -1) : raw2) / (percent ? 100 : 1e5);
|
|
8510
|
+
if (Number.isFinite(value)) result[key] = value;
|
|
8511
|
+
}
|
|
8512
|
+
return result;
|
|
8545
8513
|
}
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
];
|
|
8562
|
-
function buildWatermarkRun(doc, spec, uniqueId) {
|
|
8563
|
-
const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
|
|
8564
|
-
const run2 = makeW(doc, "r");
|
|
8565
|
-
const props = makeW(doc, "rPr");
|
|
8566
|
-
props.appendChild(makeW(doc, "noProof"));
|
|
8567
|
-
run2.appendChild(props);
|
|
8568
|
-
const pict = makeW(doc, "pict");
|
|
8569
|
-
const type = v("shapetype");
|
|
8570
|
-
type.setAttribute("id", "_x0000_t136");
|
|
8571
|
-
type.setAttribute("coordsize", "21600,21600");
|
|
8572
|
-
type.setAttributeNS(OFFICE_NS, "o:spt", "136");
|
|
8573
|
-
type.setAttribute("adj", "10800");
|
|
8574
|
-
type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
|
|
8575
|
-
const formulas = v("formulas");
|
|
8576
|
-
for (const eqn of FORMULAS) {
|
|
8577
|
-
const f6 = v("f");
|
|
8578
|
-
f6.setAttribute("eqn", eqn);
|
|
8579
|
-
formulas.appendChild(f6);
|
|
8514
|
+
function applyPictureCrop(blipFill, crop) {
|
|
8515
|
+
let rect2 = first(blipFill, "srcRect", NS.a);
|
|
8516
|
+
if (!rect2 && crop && Object.values(crop).some((value) => value !== void 0)) {
|
|
8517
|
+
rect2 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
|
|
8518
|
+
const blip = first(blipFill, "blip", NS.a);
|
|
8519
|
+
blipFill.insertBefore(rect2, blip?.nextSibling ?? blipFill.firstChild);
|
|
8520
|
+
}
|
|
8521
|
+
if (!rect2) return;
|
|
8522
|
+
for (const [attr3, key] of Object.entries(SIDES5)) {
|
|
8523
|
+
const value = crop?.[key];
|
|
8524
|
+
if (value === void 0) rect2.removeAttribute(attr3);
|
|
8525
|
+
else {
|
|
8526
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
|
|
8527
|
+
rect2.setAttribute(attr3, String(Math.round(value * 1e5)));
|
|
8528
|
+
}
|
|
8580
8529
|
}
|
|
8581
|
-
const path3 = v("path");
|
|
8582
|
-
path3.setAttribute("textpathok", "t");
|
|
8583
|
-
path3.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
|
|
8584
|
-
path3.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
|
|
8585
|
-
path3.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
|
|
8586
|
-
const typePath = v("textpath");
|
|
8587
|
-
typePath.setAttribute("on", "t");
|
|
8588
|
-
typePath.setAttribute("fitshape", "t");
|
|
8589
|
-
const handles = v("handles");
|
|
8590
|
-
const handle = v("h");
|
|
8591
|
-
handle.setAttribute("position", "#0,bottomRight");
|
|
8592
|
-
handle.setAttribute("xrange", "6629,14971");
|
|
8593
|
-
handles.appendChild(handle);
|
|
8594
|
-
const lock = makeNS(doc, OFFICE_NS, "o:lock");
|
|
8595
|
-
lock.setAttributeNS(VML_NS, "v:ext", "edit");
|
|
8596
|
-
lock.setAttribute("text", "t");
|
|
8597
|
-
lock.setAttribute("shapetype", "t");
|
|
8598
|
-
for (const child8 of [formulas, path3, typePath, handles, lock]) type.appendChild(child8);
|
|
8599
|
-
const size = watermarkSizePt(spec);
|
|
8600
|
-
const shape = v("shape");
|
|
8601
|
-
shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
|
|
8602
|
-
shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
|
|
8603
|
-
shape.setAttribute("type", "#_x0000_t136");
|
|
8604
|
-
shape.setAttribute(
|
|
8605
|
-
"style",
|
|
8606
|
-
`position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
|
|
8607
|
-
);
|
|
8608
|
-
shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
|
|
8609
|
-
shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
|
|
8610
|
-
shape.setAttribute("stroked", "f");
|
|
8611
|
-
const fill = v("fill");
|
|
8612
|
-
fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
|
|
8613
|
-
const text = v("textpath");
|
|
8614
|
-
text.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
|
|
8615
|
-
text.setAttribute("string", spec.text);
|
|
8616
|
-
const wrap2 = makeNS(doc, WORD10_NS, "w10:wrap");
|
|
8617
|
-
wrap2.setAttribute("anchorx", "margin");
|
|
8618
|
-
wrap2.setAttribute("anchory", "margin");
|
|
8619
|
-
for (const child8 of [fill, text, wrap2]) shape.appendChild(child8);
|
|
8620
|
-
pict.appendChild(type);
|
|
8621
|
-
pict.appendChild(shape);
|
|
8622
|
-
run2.appendChild(pict);
|
|
8623
|
-
return run2;
|
|
8624
8530
|
}
|
|
8625
8531
|
|
|
8626
|
-
//
|
|
8627
|
-
var
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
const
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
const
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
const
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
const off = el(doc, A_NS, "a:off");
|
|
8680
|
-
off.setAttribute("x", "0");
|
|
8681
|
-
off.setAttribute("y", "0");
|
|
8682
|
-
const ext = el(doc, A_NS, "a:ext");
|
|
8683
|
-
ext.setAttribute("cx", emu(image.widthPx));
|
|
8684
|
-
ext.setAttribute("cy", emu(image.heightPx));
|
|
8685
|
-
const geometry2 = el(doc, A_NS, "a:prstGeom");
|
|
8686
|
-
geometry2.setAttribute("prst", "rect");
|
|
8687
|
-
add(geometry2, el(doc, A_NS, "a:avLst"));
|
|
8688
|
-
const fillColor = el(doc, A_NS, "a:srgbClr");
|
|
8689
|
-
fillColor.setAttribute("val", "FFFFFF");
|
|
8690
|
-
const spPr = add(
|
|
8691
|
-
el(doc, WPS_NS, "wps:spPr"),
|
|
8692
|
-
add(xfrm, off, ext),
|
|
8693
|
-
geometry2,
|
|
8694
|
-
add(el(doc, A_NS, "a:solidFill"), fillColor),
|
|
8695
|
-
outline(doc, image.textBoxBorder !== false)
|
|
8696
|
-
);
|
|
8697
|
-
const content = add(
|
|
8698
|
-
el(doc, W_NS, "w:txbxContent"),
|
|
8699
|
-
...paragraphsFor(doc, image.textBoxText ?? [])
|
|
8700
|
-
);
|
|
8701
|
-
const body = el(doc, WPS_NS, "wps:bodyPr");
|
|
8702
|
-
for (const [name, value] of [
|
|
8703
|
-
["rot", "0"],
|
|
8704
|
-
["vert", "horz"],
|
|
8705
|
-
["wrap", "square"],
|
|
8706
|
-
["lIns", "91440"],
|
|
8707
|
-
["tIns", "45720"],
|
|
8708
|
-
["rIns", "91440"],
|
|
8709
|
-
["bIns", "45720"],
|
|
8710
|
-
["anchor", "t"],
|
|
8711
|
-
["anchorCtr", "0"]
|
|
8712
|
-
])
|
|
8713
|
-
body.setAttribute(name, value);
|
|
8714
|
-
add(body, el(doc, A_NS, "a:noAutofit"));
|
|
8715
|
-
add(wsp, cNvSpPr, spPr, add(el(doc, WPS_NS, "wps:txbx"), content), body);
|
|
8716
|
-
const graphicData = el(doc, A_NS, "a:graphicData");
|
|
8717
|
-
graphicData.setAttribute("uri", SHAPE_GRAPHIC_URI);
|
|
8718
|
-
add(
|
|
8719
|
-
inline,
|
|
8720
|
-
extent,
|
|
8721
|
-
effect,
|
|
8722
|
-
docPr,
|
|
8723
|
-
el(doc, WP_NS, "wp:cNvGraphicFramePr"),
|
|
8724
|
-
add(el(doc, A_NS, "a:graphic"), add(graphicData, wsp))
|
|
8725
|
-
);
|
|
8726
|
-
return add(drawing, inline);
|
|
8727
|
-
}
|
|
8728
|
-
function isSimpleTextBox(graphicData, anchored) {
|
|
8729
|
-
if (!graphicData || anchored) return false;
|
|
8730
|
-
const content = descendants(graphicData, W_NS, "txbxContent")[0];
|
|
8731
|
-
if (!content) return false;
|
|
8732
|
-
const plain = (node, allowed) => Array.from(node.childNodes).filter(isElement).every((child8) => child8.namespaceURI === W_NS && allowed.includes(child8.localName));
|
|
8733
|
-
return plain(content, ["p"]) && descendants(content, W_NS, "p").every(
|
|
8734
|
-
(paragraph2) => plain(paragraph2, ["r"]) && descendants(paragraph2, W_NS, "r").every((run2) => plain(run2, ["t"]))
|
|
8735
|
-
);
|
|
8736
|
-
}
|
|
8737
|
-
function textBoxHasBorder(graphicData) {
|
|
8738
|
-
const spPr = graphicData && descendants(graphicData, WPS_NS, "spPr")[0];
|
|
8739
|
-
const ln = spPr && Array.from(spPr.getElementsByTagNameNS(A_NS, "ln"))[0];
|
|
8740
|
-
return Boolean(ln && !ln.getElementsByTagNameNS(A_NS, "noFill").length);
|
|
8741
|
-
}
|
|
8742
|
-
function patchTextBox(doc, drawing, image, base) {
|
|
8743
|
-
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
8744
|
-
for (const node of [
|
|
8745
|
-
...descendants(drawing, WP_NS, "extent"),
|
|
8746
|
-
...descendants(drawing, A_NS, "ext").filter(
|
|
8747
|
-
(ext) => ext.parentNode?.localName === "xfrm"
|
|
8748
|
-
)
|
|
8749
|
-
]) {
|
|
8750
|
-
node.setAttribute("cx", emu(image.widthPx));
|
|
8751
|
-
node.setAttribute("cy", emu(image.heightPx));
|
|
8752
|
-
}
|
|
8753
|
-
if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
|
|
8754
|
-
const content = descendants(drawing, W_NS, "txbxContent")[0];
|
|
8755
|
-
if (content) {
|
|
8756
|
-
for (const child8 of Array.from(content.childNodes)) content.removeChild(child8);
|
|
8757
|
-
add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
|
|
8758
|
-
}
|
|
8759
|
-
}
|
|
8760
|
-
if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
|
|
8761
|
-
const spPr = descendants(drawing, WPS_NS, "spPr")[0];
|
|
8762
|
-
if (spPr) {
|
|
8763
|
-
for (const old of Array.from(spPr.childNodes).filter(
|
|
8764
|
-
(node) => isElement(node) && node.localName === "ln"
|
|
8765
|
-
))
|
|
8766
|
-
spPr.removeChild(old);
|
|
8767
|
-
spPr.appendChild(outline(doc, image.textBoxBorder !== false));
|
|
8768
|
-
}
|
|
8769
|
-
}
|
|
8770
|
-
}
|
|
8771
|
-
|
|
8772
|
-
// drawingml/dom.ts
|
|
8773
|
-
function attributeReader(element4) {
|
|
8774
|
-
return (name) => {
|
|
8775
|
-
if (!element4) return void 0;
|
|
8776
|
-
const direct = element4.getAttribute(name);
|
|
8777
|
-
if (direct !== null) return direct;
|
|
8778
|
-
const attributes2 = element4.attributes;
|
|
8779
|
-
for (let index = 0; index < attributes2.length; index++) {
|
|
8780
|
-
const candidate = attributes2.item(index);
|
|
8781
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
8782
|
-
}
|
|
8783
|
-
return void 0;
|
|
8784
|
-
};
|
|
8785
|
-
}
|
|
8786
|
-
function stringAttribute(element4, name) {
|
|
8787
|
-
const value = attributeReader(element4)(name)?.trim();
|
|
8788
|
-
return value ? value : void 0;
|
|
8789
|
-
}
|
|
8790
|
-
function integerAttribute(element4, name) {
|
|
8791
|
-
const parsed = Number.parseInt(attributeReader(element4)(name) ?? "", 10);
|
|
8792
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
8793
|
-
}
|
|
8794
|
-
function booleanAttribute(element4, name) {
|
|
8795
|
-
const value = attributeReader(element4)(name)?.trim().toLowerCase();
|
|
8796
|
-
if (value === "1" || value === "true") return true;
|
|
8797
|
-
if (value === "0" || value === "false") return false;
|
|
8798
|
-
return void 0;
|
|
8799
|
-
}
|
|
8800
|
-
function descendants2(root, local) {
|
|
8801
|
-
const result = [];
|
|
8802
|
-
const visit = (node) => {
|
|
8803
|
-
for (const child8 of Array.from(node.childNodes)) {
|
|
8804
|
-
if (!isElement(child8)) continue;
|
|
8805
|
-
if (child8.localName === local) result.push(child8);
|
|
8806
|
-
visit(child8);
|
|
8807
|
-
}
|
|
8808
|
-
};
|
|
8809
|
-
visit(root);
|
|
8810
|
-
return result;
|
|
8532
|
+
// drawingml/picture-artistic.ts
|
|
8533
|
+
var ARTISTIC_PRIMARY_ATTRIBUTE = {
|
|
8534
|
+
artisticBlur: "radius",
|
|
8535
|
+
artisticCement: "crackSpacing",
|
|
8536
|
+
artisticChalkSketch: "pressure",
|
|
8537
|
+
artisticCrisscrossEtching: "pressure",
|
|
8538
|
+
artisticCutout: "numberOfShades",
|
|
8539
|
+
artisticFilmGrain: "grainSize",
|
|
8540
|
+
artisticGlass: "scaling",
|
|
8541
|
+
artisticGlowDiffused: "intensity",
|
|
8542
|
+
artisticGlowEdges: "smoothness",
|
|
8543
|
+
artisticLightScreen: "gridSize",
|
|
8544
|
+
artisticLineDrawing: "pencilSize",
|
|
8545
|
+
artisticMarker: "size",
|
|
8546
|
+
// Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
|
|
8547
|
+
artisticMosiaicBubbles: "pressure",
|
|
8548
|
+
artisticPaintBrush: "brushSize",
|
|
8549
|
+
artisticPaintStrokes: "intensity",
|
|
8550
|
+
artisticPastelsSmooth: "scaling",
|
|
8551
|
+
artisticPencilGrayscale: "pencilSize",
|
|
8552
|
+
artisticPencilSketch: "pressure",
|
|
8553
|
+
artisticPhotocopy: "detail",
|
|
8554
|
+
artisticPlasticWrap: "smoothness",
|
|
8555
|
+
artisticTexturizer: "scaling",
|
|
8556
|
+
artisticWatercolorSponge: "brushSize"
|
|
8557
|
+
};
|
|
8558
|
+
function parseArtisticPictureExtension(node) {
|
|
8559
|
+
if (node.namespaceURI !== NS.a || node.localName !== "extLst") return void 0;
|
|
8560
|
+
const found = [];
|
|
8561
|
+
const unhandled = [];
|
|
8562
|
+
const pending = [node];
|
|
8563
|
+
while (pending.length) {
|
|
8564
|
+
const item2 = pending.pop();
|
|
8565
|
+
if (item2 !== node && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
|
|
8566
|
+
unhandled.push(item2.localName);
|
|
8567
|
+
if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
|
|
8568
|
+
found.push(item2);
|
|
8569
|
+
pending.push(...elements(item2));
|
|
8570
|
+
}
|
|
8571
|
+
if (found.length !== 1) return void 0;
|
|
8572
|
+
const effect = found[0];
|
|
8573
|
+
const key = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
|
|
8574
|
+
if (!key) return void 0;
|
|
8575
|
+
const raw2 = key ? effect.getAttribute(key) : null;
|
|
8576
|
+
const n = raw2 === null ? 0 : Number(raw2);
|
|
8577
|
+
if (!Number.isFinite(n)) return void 0;
|
|
8578
|
+
return {
|
|
8579
|
+
kind: "artistic",
|
|
8580
|
+
name: effect.localName,
|
|
8581
|
+
radius: effect.localName === "artisticBlur" ? n : n / 1e3,
|
|
8582
|
+
baked: true,
|
|
8583
|
+
...unhandled.length ? { unhandled } : {}
|
|
8584
|
+
};
|
|
8811
8585
|
}
|
|
8812
8586
|
|
|
8813
8587
|
// drawingml/ordered-color-transforms.ts
|
|
@@ -9033,58 +8807,237 @@ function resolveDrawingColor(color, theme, options) {
|
|
|
9033
8807
|
};
|
|
9034
8808
|
}
|
|
9035
8809
|
|
|
9036
|
-
// drawingml/
|
|
9037
|
-
var
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
8810
|
+
// drawingml/write-color.ts
|
|
8811
|
+
var ELEMENTS = {
|
|
8812
|
+
srgb: "srgbClr",
|
|
8813
|
+
scheme: "schemeClr",
|
|
8814
|
+
system: "sysClr",
|
|
8815
|
+
preset: "prstClr",
|
|
8816
|
+
scrgb: "scrgbClr",
|
|
8817
|
+
hsl: "hslClr"
|
|
8818
|
+
};
|
|
8819
|
+
function drawingColorXml(color) {
|
|
8820
|
+
const local = ELEMENTS[color.kind];
|
|
8821
|
+
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
8822
|
+
const root = doc.documentElement;
|
|
8823
|
+
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
8824
|
+
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
8825
|
+
const values = color.value.split(",");
|
|
8826
|
+
keys.forEach((key, i2) => root.setAttribute(key, values[i2] ?? "0"));
|
|
8827
|
+
} else root.setAttribute("val", color.value);
|
|
8828
|
+
if (color.fallback !== void 0 && color.kind === "system")
|
|
8829
|
+
root.setAttribute("lastClr", color.fallback);
|
|
8830
|
+
for (const transform7 of color.transforms) {
|
|
8831
|
+
if (!/^[A-Za-z_][\w.-]*$/.test(transform7.name))
|
|
8832
|
+
throw new Error(`Invalid DrawingML transform ${transform7.name}`);
|
|
8833
|
+
const node = doc.createElementNS(NS.a, `a:${transform7.name}`);
|
|
8834
|
+
if (transform7.value !== "") node.setAttribute("val", transform7.value);
|
|
8835
|
+
root.appendChild(node);
|
|
9048
8836
|
}
|
|
9049
|
-
return
|
|
8837
|
+
return buildXml(doc);
|
|
9050
8838
|
}
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
8839
|
+
|
|
8840
|
+
// drawingml/patch-color.ts
|
|
8841
|
+
function patchDrawingColorIn(container2, color) {
|
|
8842
|
+
const old = elements(container2).find((node) => parseDrawingColor(node));
|
|
8843
|
+
const before = parseDrawingColorIn(container2);
|
|
8844
|
+
if (!old || !before || before.kind !== color.kind) {
|
|
8845
|
+
const next = container2.ownerDocument.importNode(
|
|
8846
|
+
parseXml(drawingColorXml(color)).documentElement,
|
|
8847
|
+
true
|
|
8848
|
+
);
|
|
8849
|
+
if (old) container2.replaceChild(next, old);
|
|
8850
|
+
else container2.insertBefore(next, container2.firstChild);
|
|
8851
|
+
return;
|
|
9057
8852
|
}
|
|
9058
|
-
if (
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
8853
|
+
if (before.value !== color.value) {
|
|
8854
|
+
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
8855
|
+
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
8856
|
+
const values = color.value.split(",");
|
|
8857
|
+
keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
|
|
8858
|
+
} else old.setAttribute("val", color.value);
|
|
8859
|
+
}
|
|
8860
|
+
if (before.fallback !== color.fallback && color.kind === "system") {
|
|
8861
|
+
if (color.fallback === void 0) old.removeAttribute("lastClr");
|
|
8862
|
+
else old.setAttribute("lastClr", color.fallback);
|
|
9066
8863
|
}
|
|
8864
|
+
const originals = elements(old);
|
|
8865
|
+
color.transforms.forEach((transform7, index) => {
|
|
8866
|
+
const source2 = originals[index];
|
|
8867
|
+
if (source2?.localName === transform7.name) {
|
|
8868
|
+
if (before.transforms[index]?.value !== transform7.value) {
|
|
8869
|
+
if (transform7.value === "") source2.removeAttribute("val");
|
|
8870
|
+
else source2.setAttribute("val", transform7.value);
|
|
8871
|
+
}
|
|
8872
|
+
return;
|
|
8873
|
+
}
|
|
8874
|
+
if (!/^[A-Za-z_][\w.-]*$/u.test(transform7.name))
|
|
8875
|
+
throw new Error("Invalid DrawingML colour transform");
|
|
8876
|
+
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform7.name}`);
|
|
8877
|
+
if (transform7.value !== "") next.setAttribute("val", transform7.value);
|
|
8878
|
+
if (source2) old.replaceChild(next, source2);
|
|
8879
|
+
else old.appendChild(next);
|
|
8880
|
+
});
|
|
8881
|
+
for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
|
|
9067
8882
|
}
|
|
9068
8883
|
|
|
9069
|
-
// drawingml/picture-effects.ts
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
}
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
8884
|
+
// drawingml/picture-standard-effects.ts
|
|
8885
|
+
var attrs = {
|
|
8886
|
+
biLevel: { threshold: "thresh" },
|
|
8887
|
+
alphaRepl: { amount: "a" },
|
|
8888
|
+
alphaBiLevel: { threshold: "thresh" },
|
|
8889
|
+
hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
|
|
8890
|
+
tint: { hue: "hue", amount: "amt" },
|
|
8891
|
+
blur: { radiusEmu: "rad" }
|
|
8892
|
+
};
|
|
8893
|
+
function parseStandardPictureEffect(node) {
|
|
8894
|
+
const name = node.localName;
|
|
8895
|
+
if (![
|
|
8896
|
+
"biLevel",
|
|
8897
|
+
"alphaInv",
|
|
8898
|
+
"alphaCeiling",
|
|
8899
|
+
"alphaFloor",
|
|
8900
|
+
"alphaRepl",
|
|
8901
|
+
"alphaBiLevel",
|
|
8902
|
+
"alphaMod",
|
|
8903
|
+
"duotone",
|
|
8904
|
+
"clrRepl",
|
|
8905
|
+
"clrChange",
|
|
8906
|
+
"hsl",
|
|
8907
|
+
"tint",
|
|
8908
|
+
"blur"
|
|
8909
|
+
].includes(name))
|
|
8910
|
+
return void 0;
|
|
8911
|
+
const values = {};
|
|
8912
|
+
for (const [key, attribute2] of Object.entries(attrs[name] ?? {})) {
|
|
8913
|
+
const raw2 = node.getAttribute(attribute2);
|
|
8914
|
+
if (raw2 === null) continue;
|
|
8915
|
+
const percent = raw2.endsWith("%");
|
|
8916
|
+
const n = Number(percent ? raw2.slice(0, -1) : raw2) / (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : percent ? 100 : 1e5);
|
|
8917
|
+
if (!Number.isFinite(n) || key === "hue" && (n < 0 || n >= 360) || key === "threshold" && (n < 0 || n > 1) || key === "radiusEmu" && (!Number.isSafeInteger(n) || n < 0) || ["saturation", "luminance", "amount"].includes(key) && name !== "alphaMod" && (n < (name === "alphaRepl" ? 0 : -1) || n > 1))
|
|
8918
|
+
return void 0;
|
|
8919
|
+
values[key] = n;
|
|
8920
|
+
}
|
|
8921
|
+
if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
|
|
8922
|
+
return void 0;
|
|
8923
|
+
if (name === "alphaRepl" && values.amount === void 0) return void 0;
|
|
8924
|
+
if (name === "alphaMod") {
|
|
8925
|
+
const cont = first(node, "cont", NS.a);
|
|
8926
|
+
const nested = cont ? elements(cont) : [];
|
|
8927
|
+
if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
|
|
8928
|
+
const raw2 = nested[0].getAttribute("amt") ?? "100000";
|
|
8929
|
+
const n = Number(raw2.endsWith("%") ? raw2.slice(0, -1) : raw2) / (raw2.endsWith("%") ? 100 : 1e5);
|
|
8930
|
+
if (!Number.isFinite(n) || n < 0) return void 0;
|
|
8931
|
+
values.amount = n;
|
|
8932
|
+
}
|
|
8933
|
+
let colors = [];
|
|
8934
|
+
if (name === "duotone") {
|
|
8935
|
+
const candidates = elements(node).filter(
|
|
8936
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
8937
|
+
);
|
|
8938
|
+
colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
|
|
8939
|
+
if (colors.length !== 2) return void 0;
|
|
8940
|
+
}
|
|
8941
|
+
if (name === "clrRepl") {
|
|
8942
|
+
const color = parseDrawingColorIn(node);
|
|
8943
|
+
if (!color) return void 0;
|
|
8944
|
+
colors = [color];
|
|
8945
|
+
}
|
|
8946
|
+
if (name === "clrChange") {
|
|
8947
|
+
const from = parseDrawingColorIn(first(node, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node, "clrTo", NS.a));
|
|
8948
|
+
if (!from || !to) return void 0;
|
|
8949
|
+
colors = [from, to];
|
|
8950
|
+
}
|
|
8951
|
+
if (name === "alphaInv") {
|
|
8952
|
+
const color = parseDrawingColorIn(node);
|
|
8953
|
+
if (color) colors = [color];
|
|
8954
|
+
}
|
|
8955
|
+
return {
|
|
8956
|
+
kind: "standard",
|
|
8957
|
+
name,
|
|
8958
|
+
...Object.keys(values).length ? { values } : {},
|
|
8959
|
+
...colors.length ? { colors } : {},
|
|
8960
|
+
...name === "clrChange" && node.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node.getAttribute("useA") ?? "") } : {},
|
|
8961
|
+
...name === "blur" && node.hasAttribute("grow") ? { grow: !["0", "false"].includes(node.getAttribute("grow") ?? "") } : {}
|
|
8962
|
+
};
|
|
8963
|
+
}
|
|
8964
|
+
function applyStandardPictureEffect(node, effect) {
|
|
8965
|
+
const doc = node.ownerDocument, before = parseStandardPictureEffect(node);
|
|
8966
|
+
for (const [key, value] of Object.entries(effect.values ?? {})) {
|
|
8967
|
+
if (!Number.isFinite(value) || key === "hue" && (value < 0 || value >= 360) || key === "threshold" && (value < 0 || value > 1) || key === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
|
|
8968
|
+
throw new RangeError("Invalid picture effect values");
|
|
8969
|
+
}
|
|
8970
|
+
const count = effect.colors?.length ?? 0;
|
|
8971
|
+
if (["duotone", "clrChange"].includes(effect.name) && count !== 2 || effect.name === "clrRepl" && count !== 1 || effect.name === "alphaInv" && count > 1)
|
|
8972
|
+
throw new RangeError("Invalid picture effect colours");
|
|
8973
|
+
for (const [key, attribute2] of Object.entries(attrs[effect.name] ?? {})) {
|
|
8974
|
+
const value = effect.values?.[key];
|
|
8975
|
+
if (value === before?.values?.[key]) continue;
|
|
8976
|
+
if (value === void 0) node.removeAttribute(attribute2);
|
|
8977
|
+
else
|
|
8978
|
+
node.setAttribute(
|
|
8979
|
+
attribute2,
|
|
8980
|
+
String(Math.round(value * (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : 1e5)))
|
|
8981
|
+
);
|
|
8982
|
+
}
|
|
8983
|
+
if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
|
|
8984
|
+
const cont = first(node, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
|
|
8985
|
+
const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
|
|
8986
|
+
fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
|
|
8987
|
+
if (!fix.parentNode) cont.appendChild(fix);
|
|
8988
|
+
if (!cont.parentNode) node.appendChild(cont);
|
|
8989
|
+
}
|
|
8990
|
+
if (effect.useAlpha !== before?.useAlpha) {
|
|
8991
|
+
if (effect.useAlpha === void 0) node.removeAttribute("useA");
|
|
8992
|
+
else node.setAttribute("useA", effect.useAlpha ? "1" : "0");
|
|
8993
|
+
}
|
|
8994
|
+
if (effect.grow !== before?.grow) {
|
|
8995
|
+
if (effect.grow === void 0) node.removeAttribute("grow");
|
|
8996
|
+
else node.setAttribute("grow", effect.grow ? "1" : "0");
|
|
8997
|
+
}
|
|
8998
|
+
if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
|
|
8999
|
+
if (effect.name === "duotone") {
|
|
9000
|
+
const old = elements(node).filter(
|
|
9001
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
9002
|
+
);
|
|
9003
|
+
for (let i2 = 0; i2 < (effect.colors?.length ?? 0); i2++) {
|
|
9004
|
+
const holder = doc.createElementNS(NS.a, "a:holder");
|
|
9005
|
+
if (old[i2]) holder.appendChild(doc.importNode(old[i2], true));
|
|
9006
|
+
patchDrawingColorIn(holder, effect.colors[i2]);
|
|
9007
|
+
const next = elements(holder)[0];
|
|
9008
|
+
if (old[i2]) node.replaceChild(next, old[i2]);
|
|
9009
|
+
else node.insertBefore(next, first(node, "extLst", NS.a) ?? null);
|
|
9010
|
+
}
|
|
9011
|
+
} else if (effect.name === "clrChange") {
|
|
9012
|
+
for (const [i2, name] of ["clrFrom", "clrTo"].entries()) {
|
|
9013
|
+
const holder = first(node, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
|
|
9014
|
+
if (effect.colors?.[i2]) patchDrawingColorIn(holder, effect.colors[i2]);
|
|
9015
|
+
if (!holder.parentNode) node.insertBefore(holder, first(node, "extLst", NS.a) ?? null);
|
|
9016
|
+
}
|
|
9017
|
+
} else if (effect.colors?.[0]) patchDrawingColorIn(node, effect.colors[0]);
|
|
9018
|
+
}
|
|
9019
|
+
if (!parseStandardPictureEffect(node)) throw new RangeError("Invalid picture effect values");
|
|
9020
|
+
}
|
|
9021
|
+
|
|
9022
|
+
// drawingml/picture-effects.ts
|
|
9023
|
+
function picturePercentage(value) {
|
|
9024
|
+
const text = String(value ?? "").trim();
|
|
9025
|
+
if (!text) return void 0;
|
|
9026
|
+
const percent = text.endsWith("%");
|
|
9027
|
+
const n = Number(percent ? text.slice(0, -1) : text) / (percent ? 100 : 1e5);
|
|
9028
|
+
return Number.isFinite(n) ? n : void 0;
|
|
9029
|
+
}
|
|
9030
|
+
function readPictureEffect(name, attribute2) {
|
|
9031
|
+
if (name === "grayscl") return { kind: "grayscale" };
|
|
9032
|
+
if (name === "lum") {
|
|
9033
|
+
const brightness = picturePercentage(attribute2("bright"));
|
|
9034
|
+
const contrast = picturePercentage(attribute2("contrast"));
|
|
9035
|
+
for (const [name2, value] of [
|
|
9036
|
+
["bright", brightness],
|
|
9037
|
+
["contrast", contrast]
|
|
9038
|
+
]) {
|
|
9039
|
+
const raw2 = attribute2(name2);
|
|
9040
|
+
if (raw2 !== void 0 && raw2 !== null && (value === void 0 || Math.abs(value) > 1))
|
|
9088
9041
|
return void 0;
|
|
9089
9042
|
}
|
|
9090
9043
|
return {
|
|
@@ -9098,74 +9051,525 @@ function readPictureEffect(name, attribute2) {
|
|
|
9098
9051
|
const amount = raw2 === void 0 || raw2 === null ? 1 : picturePercentage(raw2);
|
|
9099
9052
|
if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
|
|
9100
9053
|
}
|
|
9101
|
-
return void 0;
|
|
9102
|
-
}
|
|
9103
|
-
function parsePictureEffects(blip) {
|
|
9104
|
-
if (!blip) return [];
|
|
9105
|
-
return elements(blip).map((node) => ({
|
|
9106
|
-
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
9107
|
-
sourceXml: buildXml(node)
|
|
9108
|
-
}));
|
|
9109
|
-
}
|
|
9110
|
-
function applyPictureEffects(blip, effects) {
|
|
9111
|
-
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
|
|
9112
|
-
const nodes = effects.map((effect) => {
|
|
9113
|
-
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
(
|
|
9054
|
+
return void 0;
|
|
9055
|
+
}
|
|
9056
|
+
function parsePictureEffects(blip) {
|
|
9057
|
+
if (!blip) return [];
|
|
9058
|
+
return elements(blip).map((node) => ({
|
|
9059
|
+
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) ?? parseStandardPictureEffect(node) ?? parseArtisticPictureExtension(node) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
9060
|
+
sourceXml: buildXml(node)
|
|
9061
|
+
}));
|
|
9062
|
+
}
|
|
9063
|
+
function applyPictureEffects(blip, effects) {
|
|
9064
|
+
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
|
|
9065
|
+
const nodes = effects.map((effect) => {
|
|
9066
|
+
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
|
|
9067
|
+
if (effect.kind === "artistic") {
|
|
9068
|
+
const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
|
|
9069
|
+
if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
|
|
9070
|
+
throw new Error("Artistic authoring requires a host-generated baked picture cache");
|
|
9071
|
+
}
|
|
9072
|
+
const source2 = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
|
|
9073
|
+
if (effect.kind === "unsupported" && !source2)
|
|
9074
|
+
throw new Error("An unsupported picture effect needs source XML");
|
|
9075
|
+
const node = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
9076
|
+
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
9077
|
+
throw new Error("Picture effect source does not match its kind");
|
|
9078
|
+
const set2 = (name2, value) => {
|
|
9079
|
+
const original = picturePercentage(node.getAttribute(name2));
|
|
9080
|
+
if (value === void 0) node.removeAttribute(name2);
|
|
9081
|
+
else if (value !== original) {
|
|
9082
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture effect must be finite");
|
|
9083
|
+
node.setAttribute(name2, String(Math.round(value * 1e5)));
|
|
9084
|
+
}
|
|
9085
|
+
};
|
|
9086
|
+
if (effect.kind === "luminance") {
|
|
9087
|
+
if ([effect.brightness, effect.contrast].some(
|
|
9088
|
+
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
9089
|
+
))
|
|
9090
|
+
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
9091
|
+
set2("bright", effect.brightness);
|
|
9092
|
+
set2("contrast", effect.contrast);
|
|
9093
|
+
}
|
|
9094
|
+
if (effect.kind === "alphaModFix") {
|
|
9095
|
+
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
9096
|
+
set2("amt", effect.amount);
|
|
9097
|
+
}
|
|
9098
|
+
if (effect.kind === "standard") applyStandardPictureEffect(node, effect);
|
|
9099
|
+
return node;
|
|
9100
|
+
});
|
|
9101
|
+
for (const node of elements(blip)) blip.removeChild(node);
|
|
9102
|
+
for (const node of nodes) blip.appendChild(node);
|
|
9103
|
+
}
|
|
9104
|
+
|
|
9105
|
+
// drawingml/picture-layout.ts
|
|
9106
|
+
function parsePictureLayout(fill) {
|
|
9107
|
+
const out = {};
|
|
9108
|
+
const rot = fill.getAttribute("rotWithShape");
|
|
9109
|
+
if (rot !== null) out.rotWithShape = rot !== "0" && rot !== "false";
|
|
9110
|
+
const dpi = Number(fill.getAttribute("dpi"));
|
|
9111
|
+
if (fill.hasAttribute("dpi") && Number.isFinite(dpi) && dpi > 0) out.dpi = dpi;
|
|
9112
|
+
const tile = first(fill, "tile", NS.a);
|
|
9113
|
+
if (tile) {
|
|
9114
|
+
const value = {};
|
|
9115
|
+
for (const [key, attr3] of [
|
|
9116
|
+
["scaleX", "sx"],
|
|
9117
|
+
["scaleY", "sy"]
|
|
9118
|
+
]) {
|
|
9119
|
+
const n = picturePercentage(tile.getAttribute(attr3));
|
|
9120
|
+
if (n !== void 0) value[key] = n;
|
|
9121
|
+
}
|
|
9122
|
+
for (const [key, attr3] of [
|
|
9123
|
+
["offsetXEmu", "tx"],
|
|
9124
|
+
["offsetYEmu", "ty"]
|
|
9125
|
+
]) {
|
|
9126
|
+
const raw2 = tile.getAttribute(attr3);
|
|
9127
|
+
const n = raw2 === null ? NaN : Number(raw2);
|
|
9128
|
+
if (Number.isSafeInteger(n)) value[key] = n;
|
|
9129
|
+
}
|
|
9130
|
+
const alignment = tile.getAttribute("algn");
|
|
9131
|
+
if (alignment) value.alignment = alignment;
|
|
9132
|
+
const flip = tile.getAttribute("flip");
|
|
9133
|
+
if (flip && ["none", "x", "y", "xy"].includes(flip))
|
|
9134
|
+
value.flip = flip;
|
|
9135
|
+
out.tile = value;
|
|
9136
|
+
}
|
|
9137
|
+
const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
|
|
9138
|
+
if (rect2)
|
|
9139
|
+
out.fillRect = {
|
|
9140
|
+
l: picturePercentage(rect2.getAttribute("l")) ?? 0,
|
|
9141
|
+
t: picturePercentage(rect2.getAttribute("t")) ?? 0,
|
|
9142
|
+
r: picturePercentage(rect2.getAttribute("r")) ?? 0,
|
|
9143
|
+
b: picturePercentage(rect2.getAttribute("b")) ?? 0
|
|
9144
|
+
};
|
|
9145
|
+
return out;
|
|
9146
|
+
}
|
|
9147
|
+
function applyPictureLayout(fill, layout2) {
|
|
9148
|
+
const before = parsePictureLayout(fill);
|
|
9149
|
+
const attr3 = (node, name, value, old) => {
|
|
9150
|
+
if (value === old) return;
|
|
9151
|
+
if (value === void 0) node.removeAttribute(name);
|
|
9152
|
+
else node.setAttribute(name, String(value));
|
|
9153
|
+
};
|
|
9154
|
+
if (layout2.rotWithShape !== before.rotWithShape)
|
|
9155
|
+
attr3(
|
|
9156
|
+
fill,
|
|
9157
|
+
"rotWithShape",
|
|
9158
|
+
layout2.rotWithShape === void 0 ? void 0 : layout2.rotWithShape ? "1" : "0",
|
|
9159
|
+
void 0
|
|
9160
|
+
);
|
|
9161
|
+
if (layout2.dpi !== before.dpi) {
|
|
9162
|
+
if (layout2.dpi !== void 0 && (!Number.isSafeInteger(layout2.dpi) || layout2.dpi <= 0))
|
|
9163
|
+
throw new RangeError("Invalid picture DPI");
|
|
9164
|
+
attr3(fill, "dpi", layout2.dpi, void 0);
|
|
9165
|
+
}
|
|
9166
|
+
const make = (parent, name) => {
|
|
9167
|
+
const old = first(parent, name, NS.a);
|
|
9168
|
+
if (old) return old;
|
|
9169
|
+
const node = fill.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
9170
|
+
parent.insertBefore(node, first(parent, "extLst", NS.a) ?? null);
|
|
9171
|
+
return node;
|
|
9172
|
+
};
|
|
9173
|
+
if (layout2.tile) {
|
|
9174
|
+
const stretch = first(fill, "stretch", NS.a);
|
|
9175
|
+
if (stretch) fill.removeChild(stretch);
|
|
9176
|
+
const tile = make(fill, "tile");
|
|
9177
|
+
for (const [key, name] of [
|
|
9178
|
+
["scaleX", "sx"],
|
|
9179
|
+
["scaleY", "sy"],
|
|
9180
|
+
["offsetXEmu", "tx"],
|
|
9181
|
+
["offsetYEmu", "ty"]
|
|
9182
|
+
]) {
|
|
9183
|
+
const n = layout2.tile[key];
|
|
9184
|
+
if (n !== void 0 && (!Number.isFinite(n) || (name === "sx" || name === "sy" ? n <= 0 : !Number.isSafeInteger(n))))
|
|
9185
|
+
throw new RangeError("Invalid picture tile");
|
|
9186
|
+
if (n !== before.tile?.[key])
|
|
9187
|
+
attr3(
|
|
9188
|
+
tile,
|
|
9189
|
+
name,
|
|
9190
|
+
n === void 0 ? void 0 : Math.round(n * (name === "sx" || name === "sy" ? 1e5 : 1)),
|
|
9191
|
+
void 0
|
|
9192
|
+
);
|
|
9193
|
+
}
|
|
9194
|
+
if (layout2.tile.alignment !== before.tile?.alignment) {
|
|
9195
|
+
if (layout2.tile.alignment && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(layout2.tile.alignment))
|
|
9196
|
+
throw new RangeError("Invalid picture tile alignment");
|
|
9197
|
+
attr3(tile, "algn", layout2.tile.alignment, void 0);
|
|
9198
|
+
}
|
|
9199
|
+
if (layout2.tile.flip !== void 0 && !["none", "x", "y", "xy"].includes(layout2.tile.flip))
|
|
9200
|
+
throw new RangeError("Invalid picture tile flip");
|
|
9201
|
+
if (layout2.tile.flip !== before.tile?.flip) attr3(tile, "flip", layout2.tile.flip, void 0);
|
|
9202
|
+
} else if (before.tile || layout2.fillRect) {
|
|
9203
|
+
const tile = first(fill, "tile", NS.a);
|
|
9204
|
+
if (tile) fill.removeChild(tile);
|
|
9205
|
+
const rect2 = make(make(fill, "stretch"), "fillRect");
|
|
9206
|
+
for (const key of ["l", "t", "r", "b"]) {
|
|
9207
|
+
const n = layout2.fillRect?.[key];
|
|
9208
|
+
if (n !== void 0 && !Number.isFinite(n))
|
|
9209
|
+
throw new RangeError("Invalid picture fill rectangle");
|
|
9210
|
+
if (n !== before.fillRect?.[key])
|
|
9211
|
+
attr3(rect2, key, n === void 0 ? void 0 : Math.round(n * 1e5), void 0);
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
9215
|
+
|
|
9216
|
+
// drawingml/picture-fill.ts
|
|
9217
|
+
function parseDrawingPictureFill(fill) {
|
|
9218
|
+
const blip = first(fill, "blip", NS.a);
|
|
9219
|
+
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
9220
|
+
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
9221
|
+
const crop = parsePictureCrop(fill);
|
|
9222
|
+
const effects = parsePictureEffects(blip);
|
|
9223
|
+
const layout2 = parsePictureLayout(fill);
|
|
9224
|
+
const unsupported2 = [];
|
|
9225
|
+
const tile = first(fill, "tile", NS.a), stretch = first(fill, "stretch", NS.a);
|
|
9226
|
+
if (tile && stretch) unsupported2.push("tile/stretch-choice");
|
|
9227
|
+
if (tile) {
|
|
9228
|
+
for (const [attr3, key] of [
|
|
9229
|
+
["sx", "scaleX"],
|
|
9230
|
+
["sy", "scaleY"],
|
|
9231
|
+
["tx", "offsetXEmu"],
|
|
9232
|
+
["ty", "offsetYEmu"]
|
|
9233
|
+
])
|
|
9234
|
+
if (tile.hasAttribute(attr3) && (layout2.tile?.[key] === void 0 || (attr3 === "sx" || attr3 === "sy") && layout2.tile[key] <= 0))
|
|
9235
|
+
unsupported2.push(`tile:${attr3}`);
|
|
9236
|
+
if (tile.hasAttribute("algn") && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(tile.getAttribute("algn") ?? ""))
|
|
9237
|
+
unsupported2.push("tile:algn");
|
|
9238
|
+
if (tile.hasAttribute("flip") && !layout2.tile?.flip) unsupported2.push("tile:flip");
|
|
9239
|
+
}
|
|
9240
|
+
const rect2 = first(stretch, "fillRect", NS.a);
|
|
9241
|
+
if (rect2)
|
|
9242
|
+
for (const key of ["l", "t", "r", "b"]) {
|
|
9243
|
+
const raw2 = rect2.getAttribute(key);
|
|
9244
|
+
if (raw2 !== null && !/^[-+]?(?:\d+\.?\d*|\.\d+)%?$/.test(raw2))
|
|
9245
|
+
unsupported2.push(`fillRect:${key}`);
|
|
9246
|
+
}
|
|
9247
|
+
if (fill.hasAttribute("rotWithShape") && !["0", "1", "true", "false"].includes(fill.getAttribute("rotWithShape") ?? ""))
|
|
9248
|
+
unsupported2.push("rotWithShape");
|
|
9249
|
+
return {
|
|
9250
|
+
kind: "picture",
|
|
9251
|
+
sourceXml: buildXml(fill),
|
|
9252
|
+
...relId ? { relId } : {},
|
|
9253
|
+
...linkRelId ? { linkRelId } : {},
|
|
9254
|
+
...crop ? { crop } : {},
|
|
9255
|
+
...effects.length ? { effects } : {},
|
|
9256
|
+
...Object.keys(layout2).length ? { layout: layout2 } : {},
|
|
9257
|
+
...unsupported2.length ? { unsupportedPicture: unsupported2 } : {}
|
|
9258
|
+
};
|
|
9259
|
+
}
|
|
9260
|
+
|
|
9261
|
+
// drawingml/image-content-type.ts
|
|
9262
|
+
function imageContentType(partName) {
|
|
9263
|
+
const extension = partName.split(".").pop()?.toLowerCase();
|
|
9264
|
+
const known = {
|
|
9265
|
+
png: "image/png",
|
|
9266
|
+
jpg: "image/jpeg",
|
|
9267
|
+
jpeg: "image/jpeg",
|
|
9268
|
+
gif: "image/gif",
|
|
9269
|
+
bmp: "image/bmp",
|
|
9270
|
+
svg: "image/svg+xml",
|
|
9271
|
+
tif: "image/tiff",
|
|
9272
|
+
tiff: "image/tiff",
|
|
9273
|
+
emf: "image/x-emf",
|
|
9274
|
+
wmf: "image/x-wmf"
|
|
9275
|
+
};
|
|
9276
|
+
return extension && known[extension] || "application/octet-stream";
|
|
9277
|
+
}
|
|
9278
|
+
|
|
9279
|
+
// docx/package-parts.ts
|
|
9280
|
+
function resolveInternalTarget(target) {
|
|
9281
|
+
if (target.startsWith("/")) return target.replace(/^\//, "");
|
|
9282
|
+
return `word/${target.replace(/^\.\//, "")}`;
|
|
9283
|
+
}
|
|
9284
|
+
|
|
9285
|
+
// docx/defined-props.ts
|
|
9286
|
+
function definedProps(source2) {
|
|
9287
|
+
return Object.fromEntries(Object.entries(source2).filter(([, value]) => value !== void 0));
|
|
9288
|
+
}
|
|
9289
|
+
|
|
9290
|
+
// docx/watermark.ts
|
|
9291
|
+
var VML_NS = "urn:schemas-microsoft-com:vml";
|
|
9292
|
+
var OFFICE_NS = "urn:schemas-microsoft-com:office:office";
|
|
9293
|
+
var WORD10_NS = "urn:schemas-microsoft-com:office:word";
|
|
9294
|
+
var NAMED = {
|
|
9295
|
+
silver: "#c0c0c0",
|
|
9296
|
+
gray: "#808080",
|
|
9297
|
+
grey: "#808080",
|
|
9298
|
+
black: "#000000",
|
|
9299
|
+
white: "#ffffff",
|
|
9300
|
+
red: "#ff0000",
|
|
9301
|
+
blue: "#0000ff",
|
|
9302
|
+
green: "#008000",
|
|
9303
|
+
yellow: "#ffff00"
|
|
9304
|
+
};
|
|
9305
|
+
var POINT_TO_PX = 96 / 72;
|
|
9306
|
+
var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
|
|
9307
|
+
var DEFAULT_WATERMARK_COLOR = "#c0c0c0";
|
|
9308
|
+
function colorOf(value) {
|
|
9309
|
+
const text = (value ?? "").trim().toLowerCase().split(/\s/)[0] ?? "";
|
|
9310
|
+
if (NAMED[text]) return NAMED[text];
|
|
9311
|
+
const hex = /^#?([0-9a-f]{6})$/.exec(text);
|
|
9312
|
+
return hex ? `#${hex[1]}` : DEFAULT_WATERMARK_COLOR;
|
|
9313
|
+
}
|
|
9314
|
+
function parseWatermarkShape(shape) {
|
|
9315
|
+
if (!shape || !(shape.getAttribute("id") ?? "").startsWith(WATERMARK_PREFIX)) return void 0;
|
|
9316
|
+
const path3 = Array.from(shape.getElementsByTagNameNS(VML_NS, "textpath"))[0];
|
|
9317
|
+
if (!path3) return void 0;
|
|
9318
|
+
const style = shape.getAttribute("style") ?? "";
|
|
9319
|
+
const fill = Array.from(shape.getElementsByTagNameNS(VML_NS, "fill"))[0];
|
|
9320
|
+
const opacity = fill?.getAttribute("opacity");
|
|
9321
|
+
const family = /font-family:\s*(?:"|"|')?([^;"'&]+)/i.exec(
|
|
9322
|
+
path3.getAttribute("style") ?? ""
|
|
9323
|
+
)?.[1];
|
|
9324
|
+
const width = /width:\s*([\d.]+)pt/i.exec(style);
|
|
9325
|
+
const height = /height:\s*([\d.]+)pt/i.exec(style);
|
|
9326
|
+
const rotation2 = /rotation:\s*(-?[\d.]+)/i.exec(style);
|
|
9327
|
+
const spec = {
|
|
9328
|
+
text: path3.getAttribute("string") ?? "",
|
|
9329
|
+
color: colorOf(shape.getAttribute("fillcolor")),
|
|
9330
|
+
semitransparent: opacity !== null && opacity !== "" && opacity !== "1",
|
|
9331
|
+
layout: rotation2 && Math.abs(Number(rotation2[1]) % 360) > 1 ? "diagonal" : "horizontal",
|
|
9332
|
+
...family ? { fontFamily: family.trim() } : {}
|
|
9333
|
+
};
|
|
9334
|
+
return {
|
|
9335
|
+
relId: "",
|
|
9336
|
+
partName: "",
|
|
9337
|
+
contentType: "application/octet-stream",
|
|
9338
|
+
widthPx: width ? Math.round(Number(width[1]) * POINT_TO_PX) : 0,
|
|
9339
|
+
heightPx: height ? Math.round(Number(height[1]) * POINT_TO_PX) : 0,
|
|
9340
|
+
unsupported: "Watermark",
|
|
9341
|
+
watermark: spec
|
|
9342
|
+
};
|
|
9343
|
+
}
|
|
9344
|
+
function watermarkSizePt(spec) {
|
|
9345
|
+
const chars = Math.max(1, [...spec.text].length);
|
|
9346
|
+
const width = Math.min(spec.layout === "diagonal" ? 527 : 468, Math.max(150, chars * 44));
|
|
9347
|
+
return { width, height: Math.round(width / (chars * 0.55) * 100) / 100 };
|
|
9348
|
+
}
|
|
9349
|
+
var FORMULAS = [
|
|
9350
|
+
"sum #0 0 10800",
|
|
9351
|
+
"prod #0 2 1",
|
|
9352
|
+
"sum 21600 0 @1",
|
|
9353
|
+
"sum 0 0 @2",
|
|
9354
|
+
"sum 21600 0 @3",
|
|
9355
|
+
"if @0 @3 0",
|
|
9356
|
+
"if @0 21600 @1",
|
|
9357
|
+
"if @0 0 @2",
|
|
9358
|
+
"if @0 @4 21600",
|
|
9359
|
+
"mid @5 @6",
|
|
9360
|
+
"mid @8 @5",
|
|
9361
|
+
"mid @7 @8",
|
|
9362
|
+
"mid @6 @7",
|
|
9363
|
+
"sum @6 0 @5"
|
|
9364
|
+
];
|
|
9365
|
+
function buildWatermarkRun(doc, spec, uniqueId) {
|
|
9366
|
+
const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
|
|
9367
|
+
const run2 = makeW(doc, "r");
|
|
9368
|
+
const props = makeW(doc, "rPr");
|
|
9369
|
+
props.appendChild(makeW(doc, "noProof"));
|
|
9370
|
+
run2.appendChild(props);
|
|
9371
|
+
const pict = makeW(doc, "pict");
|
|
9372
|
+
const type = v("shapetype");
|
|
9373
|
+
type.setAttribute("id", "_x0000_t136");
|
|
9374
|
+
type.setAttribute("coordsize", "21600,21600");
|
|
9375
|
+
type.setAttributeNS(OFFICE_NS, "o:spt", "136");
|
|
9376
|
+
type.setAttribute("adj", "10800");
|
|
9377
|
+
type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
|
|
9378
|
+
const formulas = v("formulas");
|
|
9379
|
+
for (const eqn of FORMULAS) {
|
|
9380
|
+
const f6 = v("f");
|
|
9381
|
+
f6.setAttribute("eqn", eqn);
|
|
9382
|
+
formulas.appendChild(f6);
|
|
9383
|
+
}
|
|
9384
|
+
const path3 = v("path");
|
|
9385
|
+
path3.setAttribute("textpathok", "t");
|
|
9386
|
+
path3.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
|
|
9387
|
+
path3.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
|
|
9388
|
+
path3.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
|
|
9389
|
+
const typePath = v("textpath");
|
|
9390
|
+
typePath.setAttribute("on", "t");
|
|
9391
|
+
typePath.setAttribute("fitshape", "t");
|
|
9392
|
+
const handles = v("handles");
|
|
9393
|
+
const handle = v("h");
|
|
9394
|
+
handle.setAttribute("position", "#0,bottomRight");
|
|
9395
|
+
handle.setAttribute("xrange", "6629,14971");
|
|
9396
|
+
handles.appendChild(handle);
|
|
9397
|
+
const lock = makeNS(doc, OFFICE_NS, "o:lock");
|
|
9398
|
+
lock.setAttributeNS(VML_NS, "v:ext", "edit");
|
|
9399
|
+
lock.setAttribute("text", "t");
|
|
9400
|
+
lock.setAttribute("shapetype", "t");
|
|
9401
|
+
for (const child8 of [formulas, path3, typePath, handles, lock]) type.appendChild(child8);
|
|
9402
|
+
const size = watermarkSizePt(spec);
|
|
9403
|
+
const shape = v("shape");
|
|
9404
|
+
shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
|
|
9405
|
+
shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
|
|
9406
|
+
shape.setAttribute("type", "#_x0000_t136");
|
|
9407
|
+
shape.setAttribute(
|
|
9408
|
+
"style",
|
|
9409
|
+
`position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
|
|
9410
|
+
);
|
|
9411
|
+
shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
|
|
9412
|
+
shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
|
|
9413
|
+
shape.setAttribute("stroked", "f");
|
|
9414
|
+
const fill = v("fill");
|
|
9415
|
+
fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
|
|
9416
|
+
const text = v("textpath");
|
|
9417
|
+
text.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
|
|
9418
|
+
text.setAttribute("string", spec.text);
|
|
9419
|
+
const wrap2 = makeNS(doc, WORD10_NS, "w10:wrap");
|
|
9420
|
+
wrap2.setAttribute("anchorx", "margin");
|
|
9421
|
+
wrap2.setAttribute("anchory", "margin");
|
|
9422
|
+
for (const child8 of [fill, text, wrap2]) shape.appendChild(child8);
|
|
9423
|
+
pict.appendChild(type);
|
|
9424
|
+
pict.appendChild(shape);
|
|
9425
|
+
run2.appendChild(pict);
|
|
9426
|
+
return run2;
|
|
9427
|
+
}
|
|
9428
|
+
|
|
9429
|
+
// docx/write-text-box.ts
|
|
9430
|
+
var A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
9431
|
+
var WP_NS = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
9432
|
+
var WPS_NS = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
9433
|
+
var W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
9434
|
+
var SHAPE_GRAPHIC_URI = WPS_NS;
|
|
9435
|
+
var el = (doc, ns, name) => makeNS(doc, ns, name);
|
|
9436
|
+
var add = (parent, ...items) => {
|
|
9437
|
+
for (const item2 of items) parent.appendChild(item2);
|
|
9438
|
+
return parent;
|
|
9439
|
+
};
|
|
9440
|
+
var emu = (px2) => String(Math.max(1, Math.round(px2 * EMU_PER_PIXEL)));
|
|
9441
|
+
var descendants2 = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
|
|
9442
|
+
function paragraphsFor(doc, lines2) {
|
|
9443
|
+
return (lines2.length ? lines2 : [""]).map((line2) => {
|
|
9444
|
+
const paragraph2 = makeW(doc, "p");
|
|
9445
|
+
if (line2) {
|
|
9446
|
+
const run2 = makeW(doc, "r");
|
|
9447
|
+
const text = makeW(doc, "t");
|
|
9448
|
+
if (/^\s|\s$/.test(line2))
|
|
9449
|
+
text.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
|
|
9450
|
+
text.textContent = line2;
|
|
9451
|
+
add(run2, text);
|
|
9452
|
+
add(paragraph2, run2);
|
|
9453
|
+
}
|
|
9454
|
+
return paragraph2;
|
|
9455
|
+
});
|
|
9456
|
+
}
|
|
9457
|
+
function outline(doc, border) {
|
|
9458
|
+
const ln = el(doc, A_NS, "a:ln");
|
|
9459
|
+
if (!border) return add(ln, el(doc, A_NS, "a:noFill"));
|
|
9460
|
+
ln.setAttribute("w", "9525");
|
|
9461
|
+
const color = el(doc, A_NS, "a:srgbClr");
|
|
9462
|
+
color.setAttribute("val", "000000");
|
|
9463
|
+
return add(ln, add(el(doc, A_NS, "a:solidFill"), color));
|
|
9464
|
+
}
|
|
9465
|
+
function buildTextBoxDrawing(doc, image, docPrId) {
|
|
9466
|
+
const drawing = makeW(doc, "drawing");
|
|
9467
|
+
const inline = el(doc, WP_NS, "wp:inline");
|
|
9468
|
+
for (const side of ["distT", "distB", "distL", "distR"]) inline.setAttribute(side, "0");
|
|
9469
|
+
const extent = el(doc, WP_NS, "wp:extent");
|
|
9470
|
+
extent.setAttribute("cx", emu(image.widthPx));
|
|
9471
|
+
extent.setAttribute("cy", emu(image.heightPx));
|
|
9472
|
+
const effect = el(doc, WP_NS, "wp:effectExtent");
|
|
9473
|
+
for (const side of ["l", "t", "r", "b"]) effect.setAttribute(side, "0");
|
|
9474
|
+
const docPr = el(doc, WP_NS, "wp:docPr");
|
|
9475
|
+
docPr.setAttribute("id", docPrId);
|
|
9476
|
+
docPr.setAttribute("name", `Text Box ${docPrId}`);
|
|
9477
|
+
if (image.altText) docPr.setAttribute("descr", image.altText);
|
|
9478
|
+
const wsp = el(doc, WPS_NS, "wps:wsp");
|
|
9479
|
+
const cNvSpPr = el(doc, WPS_NS, "wps:cNvSpPr");
|
|
9480
|
+
cNvSpPr.setAttribute("txBox", "1");
|
|
9481
|
+
const xfrm = el(doc, A_NS, "a:xfrm");
|
|
9482
|
+
const off = el(doc, A_NS, "a:off");
|
|
9483
|
+
off.setAttribute("x", "0");
|
|
9484
|
+
off.setAttribute("y", "0");
|
|
9485
|
+
const ext = el(doc, A_NS, "a:ext");
|
|
9486
|
+
ext.setAttribute("cx", emu(image.widthPx));
|
|
9487
|
+
ext.setAttribute("cy", emu(image.heightPx));
|
|
9488
|
+
const geometry2 = el(doc, A_NS, "a:prstGeom");
|
|
9489
|
+
geometry2.setAttribute("prst", "rect");
|
|
9490
|
+
add(geometry2, el(doc, A_NS, "a:avLst"));
|
|
9491
|
+
const fillColor = el(doc, A_NS, "a:srgbClr");
|
|
9492
|
+
fillColor.setAttribute("val", "FFFFFF");
|
|
9493
|
+
const spPr = add(
|
|
9494
|
+
el(doc, WPS_NS, "wps:spPr"),
|
|
9495
|
+
add(xfrm, off, ext),
|
|
9496
|
+
geometry2,
|
|
9497
|
+
add(el(doc, A_NS, "a:solidFill"), fillColor),
|
|
9498
|
+
outline(doc, image.textBoxBorder !== false)
|
|
9499
|
+
);
|
|
9500
|
+
const content = add(
|
|
9501
|
+
el(doc, W_NS, "w:txbxContent"),
|
|
9502
|
+
...paragraphsFor(doc, image.textBoxText ?? [])
|
|
9503
|
+
);
|
|
9504
|
+
const body = el(doc, WPS_NS, "wps:bodyPr");
|
|
9505
|
+
for (const [name, value] of [
|
|
9506
|
+
["rot", "0"],
|
|
9507
|
+
["vert", "horz"],
|
|
9508
|
+
["wrap", "square"],
|
|
9509
|
+
["lIns", "91440"],
|
|
9510
|
+
["tIns", "45720"],
|
|
9511
|
+
["rIns", "91440"],
|
|
9512
|
+
["bIns", "45720"],
|
|
9513
|
+
["anchor", "t"],
|
|
9514
|
+
["anchorCtr", "0"]
|
|
9515
|
+
])
|
|
9516
|
+
body.setAttribute(name, value);
|
|
9517
|
+
add(body, el(doc, A_NS, "a:noAutofit"));
|
|
9518
|
+
add(wsp, cNvSpPr, spPr, add(el(doc, WPS_NS, "wps:txbx"), content), body);
|
|
9519
|
+
const graphicData = el(doc, A_NS, "a:graphicData");
|
|
9520
|
+
graphicData.setAttribute("uri", SHAPE_GRAPHIC_URI);
|
|
9521
|
+
add(
|
|
9522
|
+
inline,
|
|
9523
|
+
extent,
|
|
9524
|
+
effect,
|
|
9525
|
+
docPr,
|
|
9526
|
+
el(doc, WP_NS, "wp:cNvGraphicFramePr"),
|
|
9527
|
+
add(el(doc, A_NS, "a:graphic"), add(graphicData, wsp))
|
|
9528
|
+
);
|
|
9529
|
+
return add(drawing, inline);
|
|
9530
|
+
}
|
|
9531
|
+
function isSimpleTextBox(graphicData, anchored) {
|
|
9532
|
+
if (!graphicData || anchored) return false;
|
|
9533
|
+
const content = descendants2(graphicData, W_NS, "txbxContent")[0];
|
|
9534
|
+
if (!content) return false;
|
|
9535
|
+
const plain = (node, allowed) => Array.from(node.childNodes).filter(isElement).every((child8) => child8.namespaceURI === W_NS && allowed.includes(child8.localName));
|
|
9536
|
+
return plain(content, ["p"]) && descendants2(content, W_NS, "p").every(
|
|
9537
|
+
(paragraph2) => plain(paragraph2, ["r"]) && descendants2(paragraph2, W_NS, "r").every((run2) => plain(run2, ["t"]))
|
|
9538
|
+
);
|
|
9539
|
+
}
|
|
9540
|
+
function textBoxHasBorder(graphicData) {
|
|
9541
|
+
const spPr = graphicData && descendants2(graphicData, WPS_NS, "spPr")[0];
|
|
9542
|
+
const ln = spPr && Array.from(spPr.getElementsByTagNameNS(A_NS, "ln"))[0];
|
|
9543
|
+
return Boolean(ln && !ln.getElementsByTagNameNS(A_NS, "noFill").length);
|
|
9544
|
+
}
|
|
9545
|
+
function patchTextBox(doc, drawing, image, base) {
|
|
9546
|
+
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
9547
|
+
for (const node of [
|
|
9548
|
+
...descendants2(drawing, WP_NS, "extent"),
|
|
9549
|
+
...descendants2(drawing, A_NS, "ext").filter(
|
|
9550
|
+
(ext) => ext.parentNode?.localName === "xfrm"
|
|
9551
|
+
)
|
|
9552
|
+
]) {
|
|
9553
|
+
node.setAttribute("cx", emu(image.widthPx));
|
|
9554
|
+
node.setAttribute("cy", emu(image.heightPx));
|
|
9555
|
+
}
|
|
9556
|
+
if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
|
|
9557
|
+
const content = descendants2(drawing, W_NS, "txbxContent")[0];
|
|
9558
|
+
if (content) {
|
|
9559
|
+
for (const child8 of Array.from(content.childNodes)) content.removeChild(child8);
|
|
9560
|
+
add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
|
|
9561
|
+
}
|
|
9562
|
+
}
|
|
9563
|
+
if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
|
|
9564
|
+
const spPr = descendants2(drawing, WPS_NS, "spPr")[0];
|
|
9565
|
+
if (spPr) {
|
|
9566
|
+
for (const old of Array.from(spPr.childNodes).filter(
|
|
9567
|
+
(node) => isElement(node) && node.localName === "ln"
|
|
9131
9568
|
))
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
set2("contrast", effect.contrast);
|
|
9135
|
-
}
|
|
9136
|
-
if (effect.kind === "alphaModFix") {
|
|
9137
|
-
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
9138
|
-
set2("amt", effect.amount);
|
|
9569
|
+
spPr.removeChild(old);
|
|
9570
|
+
spPr.appendChild(outline(doc, image.textBoxBorder !== false));
|
|
9139
9571
|
}
|
|
9140
|
-
|
|
9141
|
-
});
|
|
9142
|
-
for (const node of elements(blip)) blip.removeChild(node);
|
|
9143
|
-
for (const node of nodes) blip.appendChild(node);
|
|
9144
|
-
}
|
|
9145
|
-
|
|
9146
|
-
// drawingml/picture-fill.ts
|
|
9147
|
-
function parseDrawingPictureFill(fill) {
|
|
9148
|
-
const blip = first(fill, "blip", NS.a);
|
|
9149
|
-
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
9150
|
-
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
9151
|
-
const crop = parsePictureCrop(fill);
|
|
9152
|
-
const effects = parsePictureEffects(blip);
|
|
9153
|
-
const tile = first(fill, "tile", NS.a);
|
|
9154
|
-
const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
|
|
9155
|
-
const unsupported2 = [
|
|
9156
|
-
...tile ? ["tile"] : [],
|
|
9157
|
-
...rect2 && ["l", "t", "r", "b"].some((key) => Number(rect2.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
|
|
9158
|
-
...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
|
|
9159
|
-
];
|
|
9160
|
-
return {
|
|
9161
|
-
kind: "picture",
|
|
9162
|
-
sourceXml: buildXml(fill),
|
|
9163
|
-
...relId ? { relId } : {},
|
|
9164
|
-
...linkRelId ? { linkRelId } : {},
|
|
9165
|
-
...crop ? { crop } : {},
|
|
9166
|
-
...effects.length ? { effects } : {},
|
|
9167
|
-
...unsupported2.length ? { unsupportedPicture: unsupported2 } : {}
|
|
9168
|
-
};
|
|
9572
|
+
}
|
|
9169
9573
|
}
|
|
9170
9574
|
|
|
9171
9575
|
// drawingml/drawing-fill.ts
|
|
@@ -9708,80 +10112,6 @@ function parseDrawingGeometry(spPr) {
|
|
|
9708
10112
|
return { geometry: geometry2, ...Object.keys(adjustments).length > 0 ? { adjustments } : {} };
|
|
9709
10113
|
}
|
|
9710
10114
|
|
|
9711
|
-
// drawingml/write-color.ts
|
|
9712
|
-
var ELEMENTS = {
|
|
9713
|
-
srgb: "srgbClr",
|
|
9714
|
-
scheme: "schemeClr",
|
|
9715
|
-
system: "sysClr",
|
|
9716
|
-
preset: "prstClr",
|
|
9717
|
-
scrgb: "scrgbClr",
|
|
9718
|
-
hsl: "hslClr"
|
|
9719
|
-
};
|
|
9720
|
-
function drawingColorXml(color) {
|
|
9721
|
-
const local = ELEMENTS[color.kind];
|
|
9722
|
-
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
9723
|
-
const root = doc.documentElement;
|
|
9724
|
-
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
9725
|
-
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
9726
|
-
const values = color.value.split(",");
|
|
9727
|
-
keys.forEach((key, i2) => root.setAttribute(key, values[i2] ?? "0"));
|
|
9728
|
-
} else root.setAttribute("val", color.value);
|
|
9729
|
-
if (color.fallback !== void 0 && color.kind === "system")
|
|
9730
|
-
root.setAttribute("lastClr", color.fallback);
|
|
9731
|
-
for (const transform7 of color.transforms) {
|
|
9732
|
-
if (!/^[A-Za-z_][\w.-]*$/.test(transform7.name))
|
|
9733
|
-
throw new Error(`Invalid DrawingML transform ${transform7.name}`);
|
|
9734
|
-
const node = doc.createElementNS(NS.a, `a:${transform7.name}`);
|
|
9735
|
-
if (transform7.value !== "") node.setAttribute("val", transform7.value);
|
|
9736
|
-
root.appendChild(node);
|
|
9737
|
-
}
|
|
9738
|
-
return buildXml(doc);
|
|
9739
|
-
}
|
|
9740
|
-
|
|
9741
|
-
// drawingml/patch-color.ts
|
|
9742
|
-
function patchDrawingColorIn(container2, color) {
|
|
9743
|
-
const old = elements(container2).find((node) => parseDrawingColor(node));
|
|
9744
|
-
const before = parseDrawingColorIn(container2);
|
|
9745
|
-
if (!old || !before || before.kind !== color.kind) {
|
|
9746
|
-
const next = container2.ownerDocument.importNode(
|
|
9747
|
-
parseXml(drawingColorXml(color)).documentElement,
|
|
9748
|
-
true
|
|
9749
|
-
);
|
|
9750
|
-
if (old) container2.replaceChild(next, old);
|
|
9751
|
-
else container2.insertBefore(next, container2.firstChild);
|
|
9752
|
-
return;
|
|
9753
|
-
}
|
|
9754
|
-
if (before.value !== color.value) {
|
|
9755
|
-
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
9756
|
-
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
9757
|
-
const values = color.value.split(",");
|
|
9758
|
-
keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
|
|
9759
|
-
} else old.setAttribute("val", color.value);
|
|
9760
|
-
}
|
|
9761
|
-
if (before.fallback !== color.fallback && color.kind === "system") {
|
|
9762
|
-
if (color.fallback === void 0) old.removeAttribute("lastClr");
|
|
9763
|
-
else old.setAttribute("lastClr", color.fallback);
|
|
9764
|
-
}
|
|
9765
|
-
const originals = elements(old);
|
|
9766
|
-
color.transforms.forEach((transform7, index) => {
|
|
9767
|
-
const source2 = originals[index];
|
|
9768
|
-
if (source2?.localName === transform7.name) {
|
|
9769
|
-
if (before.transforms[index]?.value !== transform7.value) {
|
|
9770
|
-
if (transform7.value === "") source2.removeAttribute("val");
|
|
9771
|
-
else source2.setAttribute("val", transform7.value);
|
|
9772
|
-
}
|
|
9773
|
-
return;
|
|
9774
|
-
}
|
|
9775
|
-
if (!/^[A-Za-z_][\w.-]*$/u.test(transform7.name))
|
|
9776
|
-
throw new Error("Invalid DrawingML colour transform");
|
|
9777
|
-
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform7.name}`);
|
|
9778
|
-
if (transform7.value !== "") next.setAttribute("val", transform7.value);
|
|
9779
|
-
if (source2) old.replaceChild(next, source2);
|
|
9780
|
-
else old.appendChild(next);
|
|
9781
|
-
});
|
|
9782
|
-
for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
|
|
9783
|
-
}
|
|
9784
|
-
|
|
9785
10115
|
// drawingml/write-pattern-picture.ts
|
|
9786
10116
|
function drawingPatternPictureXml(fill) {
|
|
9787
10117
|
const name = fill.kind === "pattern" ? "pattFill" : "blipFill";
|
|
@@ -9843,7 +10173,8 @@ function drawingPatternPictureXml(fill) {
|
|
|
9843
10173
|
applyPictureCrop(root, fill.crop);
|
|
9844
10174
|
if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
|
|
9845
10175
|
applyPictureEffects(blip, fill.effects ?? []);
|
|
9846
|
-
if (
|
|
10176
|
+
if (fill.layout !== void 0) applyPictureLayout(root, fill.layout);
|
|
10177
|
+
if (!fill.sourceXml && !fill.layout?.tile && !first(root, "stretch", NS.a)) {
|
|
9847
10178
|
const stretch = doc.createElementNS(NS.a, "a:stretch");
|
|
9848
10179
|
stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
|
|
9849
10180
|
root.appendChild(stretch);
|
|
@@ -21103,7 +21434,7 @@ function isSpace(ch) {
|
|
|
21103
21434
|
return ch === " " || ch === " " || ch === "\n" || ch === "\r";
|
|
21104
21435
|
}
|
|
21105
21436
|
function parseAttributes(source2) {
|
|
21106
|
-
const
|
|
21437
|
+
const attrs3 = {};
|
|
21107
21438
|
let i2 = 0;
|
|
21108
21439
|
const n = source2.length;
|
|
21109
21440
|
while (i2 < n) {
|
|
@@ -21138,9 +21469,9 @@ function parseAttributes(source2) {
|
|
|
21138
21469
|
if (name === "xmlns" || name.startsWith("xmlns:")) {
|
|
21139
21470
|
continue;
|
|
21140
21471
|
}
|
|
21141
|
-
|
|
21472
|
+
attrs3[localName(name)] = decodeEntities(value);
|
|
21142
21473
|
}
|
|
21143
|
-
return
|
|
21474
|
+
return attrs3;
|
|
21144
21475
|
}
|
|
21145
21476
|
function tagEnd2(xml, from) {
|
|
21146
21477
|
let quote = "";
|
|
@@ -21266,14 +21597,14 @@ function numOrNaN(value) {
|
|
|
21266
21597
|
function relation(value) {
|
|
21267
21598
|
return value === "ch" || value === "des" ? value : "self";
|
|
21268
21599
|
}
|
|
21269
|
-
function parseIterator(
|
|
21600
|
+
function parseIterator(attrs3) {
|
|
21270
21601
|
return {
|
|
21271
|
-
axis: list(
|
|
21272
|
-
ptType: list(
|
|
21273
|
-
hideLastTrans: list(
|
|
21274
|
-
st: numberList(
|
|
21275
|
-
cnt: numberList(
|
|
21276
|
-
step: numberList(
|
|
21602
|
+
axis: list(attrs3.axis),
|
|
21603
|
+
ptType: list(attrs3.ptType),
|
|
21604
|
+
hideLastTrans: list(attrs3.hideLastTrans).map((v) => v === "1" || v === "true"),
|
|
21605
|
+
st: numberList(attrs3.st),
|
|
21606
|
+
cnt: numberList(attrs3.cnt),
|
|
21607
|
+
step: numberList(attrs3.step)
|
|
21277
21608
|
};
|
|
21278
21609
|
}
|
|
21279
21610
|
function parseAlgorithm(element4) {
|
|
@@ -21304,41 +21635,41 @@ function parseShape2(element4) {
|
|
|
21304
21635
|
adj
|
|
21305
21636
|
};
|
|
21306
21637
|
}
|
|
21307
|
-
function parseConstraint(
|
|
21308
|
-
const op2 =
|
|
21638
|
+
function parseConstraint(attrs3) {
|
|
21639
|
+
const op2 = attrs3.op;
|
|
21309
21640
|
return {
|
|
21310
|
-
type:
|
|
21311
|
-
for: relation(
|
|
21312
|
-
forName:
|
|
21313
|
-
ptType:
|
|
21314
|
-
refType:
|
|
21315
|
-
refFor: relation(
|
|
21316
|
-
refForName:
|
|
21317
|
-
refPtType:
|
|
21641
|
+
type: attrs3.type ?? "none",
|
|
21642
|
+
for: relation(attrs3.for),
|
|
21643
|
+
forName: attrs3.forName || void 0,
|
|
21644
|
+
ptType: attrs3.ptType ?? "all",
|
|
21645
|
+
refType: attrs3.refType ?? "none",
|
|
21646
|
+
refFor: relation(attrs3.refFor),
|
|
21647
|
+
refForName: attrs3.refForName || void 0,
|
|
21648
|
+
refPtType: attrs3.refPtType ?? "all",
|
|
21318
21649
|
op: op2 === "equ" || op2 === "gte" || op2 === "lte" ? op2 : "none",
|
|
21319
|
-
val: num(
|
|
21320
|
-
hasVal:
|
|
21321
|
-
fact: num(
|
|
21650
|
+
val: num(attrs3.val, 0),
|
|
21651
|
+
hasVal: attrs3.val !== void 0,
|
|
21652
|
+
fact: num(attrs3.fact, 1)
|
|
21322
21653
|
};
|
|
21323
21654
|
}
|
|
21324
|
-
function parseRule(
|
|
21655
|
+
function parseRule(attrs3) {
|
|
21325
21656
|
return {
|
|
21326
|
-
type:
|
|
21327
|
-
for: relation(
|
|
21328
|
-
forName:
|
|
21329
|
-
ptType:
|
|
21330
|
-
val: numOrNaN(
|
|
21331
|
-
fact: numOrNaN(
|
|
21332
|
-
max: numOrNaN(
|
|
21657
|
+
type: attrs3.type ?? "none",
|
|
21658
|
+
for: relation(attrs3.for),
|
|
21659
|
+
forName: attrs3.forName || void 0,
|
|
21660
|
+
ptType: attrs3.ptType ?? "all",
|
|
21661
|
+
val: numOrNaN(attrs3.val),
|
|
21662
|
+
fact: numOrNaN(attrs3.fact),
|
|
21663
|
+
max: numOrNaN(attrs3.max)
|
|
21333
21664
|
};
|
|
21334
21665
|
}
|
|
21335
|
-
function parseCondition(
|
|
21666
|
+
function parseCondition(attrs3) {
|
|
21336
21667
|
return {
|
|
21337
|
-
...parseIterator(
|
|
21338
|
-
func:
|
|
21339
|
-
arg:
|
|
21340
|
-
op:
|
|
21341
|
-
val:
|
|
21668
|
+
...parseIterator(attrs3),
|
|
21669
|
+
func: attrs3.func ?? "cnt",
|
|
21670
|
+
arg: attrs3.arg,
|
|
21671
|
+
op: attrs3.op ?? "equ",
|
|
21672
|
+
val: attrs3.val ?? ""
|
|
21342
21673
|
};
|
|
21343
21674
|
}
|
|
21344
21675
|
function parseBody(element4, state) {
|
|
@@ -25439,7 +25770,13 @@ function buildRenderedNode(node, index, nodeById, palette, style, mergedSourceId
|
|
|
25439
25770
|
fontSize: 0,
|
|
25440
25771
|
textX: x + width / 2,
|
|
25441
25772
|
textY: y + height / 2,
|
|
25442
|
-
|
|
25773
|
+
// Picture roles often omit presOf: they present the current point's image, not its text.
|
|
25774
|
+
nodeId: primary?.id ?? (node.shape?.blipPhldr ? node.point.source?.id : void 0),
|
|
25775
|
+
picturePlaceholder: node.shape?.blipPhldr,
|
|
25776
|
+
layoutRole: node.name,
|
|
25777
|
+
contextNodeId: node.point.source?.id,
|
|
25778
|
+
textAlign: ["l", "ctr", "r"].includes(node.alg.params.parTxLTRAlign ?? "") ? node.alg.params.parTxLTRAlign : void 0,
|
|
25779
|
+
textVerticalAnchor: ["t", "ctr", "b"].includes(node.alg.params.txAnchorVert ?? "") ? node.alg.params.txAnchorVert : void 0,
|
|
25443
25780
|
rotation: transform7.rotation === 0 ? void 0 : transform7.rotation,
|
|
25444
25781
|
presetOverride: node.shape?.type ?? "roundRect",
|
|
25445
25782
|
foldedNodeIds: foldedNodeIds.length > 0 ? foldedNodeIds : void 0,
|
|
@@ -27213,7 +27550,7 @@ function connectionLabel(connection, transitionText) {
|
|
|
27213
27550
|
function textBodyParagraphs(body) {
|
|
27214
27551
|
if (!body) return [];
|
|
27215
27552
|
return children(body, "p", NS.a).map(
|
|
27216
|
-
(paragraph2) =>
|
|
27553
|
+
(paragraph2) => descendants(paragraph2, "t").map((run2) => run2.textContent ?? "").join("")
|
|
27217
27554
|
);
|
|
27218
27555
|
}
|
|
27219
27556
|
function parsePoint(element4) {
|
|
@@ -27301,15 +27638,15 @@ function parseDiagramDataModel(source2, part) {
|
|
|
27301
27638
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
27302
27639
|
parentById.set(connection.destId, connection.sourceId);
|
|
27303
27640
|
}
|
|
27304
|
-
const ext =
|
|
27641
|
+
const ext = descendants(root, "dataModelExt")[0];
|
|
27305
27642
|
const drawingRelId = stringAttribute(ext, "relId");
|
|
27306
|
-
const generated2 =
|
|
27643
|
+
const generated2 = descendants(root, "generatedCache").find(
|
|
27307
27644
|
(node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
27308
27645
|
);
|
|
27309
27646
|
const generatedCacheDigest = generated2?.getAttribute("drawingSha256");
|
|
27310
27647
|
return {
|
|
27311
27648
|
points,
|
|
27312
|
-
...
|
|
27649
|
+
...descendants(root, "generatedCache").some(
|
|
27313
27650
|
(node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
27314
27651
|
) ? { generatedCache: true } : {},
|
|
27315
27652
|
...generatedCacheDigest ? { generatedCacheDigest } : {},
|
|
@@ -27453,7 +27790,7 @@ function parseDiagramLayoutSummary(source2) {
|
|
|
27453
27790
|
...header,
|
|
27454
27791
|
...family ? { family } : {},
|
|
27455
27792
|
...rootAlgorithm ? { rootAlgorithm } : {},
|
|
27456
|
-
layoutNodeCount:
|
|
27793
|
+
layoutNodeCount: descendants(root, "layoutNode").length
|
|
27457
27794
|
};
|
|
27458
27795
|
}
|
|
27459
27796
|
|
|
@@ -27572,6 +27909,203 @@ function approximateDiagramDrawingFromNodes(input) {
|
|
|
27572
27909
|
});
|
|
27573
27910
|
}
|
|
27574
27911
|
|
|
27912
|
+
// diagram/picture-layout.ts
|
|
27913
|
+
var DIAGRAM_PICTURE_SOURCE_NS = "urn:ooxml-core:diagram-picture-sources:1";
|
|
27914
|
+
function remapFill(fill, id) {
|
|
27915
|
+
if (!fill.sourceXml) return { ...fill, relId: id };
|
|
27916
|
+
const node = parseXml(fill.sourceXml).documentElement;
|
|
27917
|
+
const blip = first(node, "blip", NS.a);
|
|
27918
|
+
if (blip) {
|
|
27919
|
+
blip.setAttributeNS(NS.r, "r:embed", id);
|
|
27920
|
+
blip.removeAttributeNS(NS.r, "link");
|
|
27921
|
+
}
|
|
27922
|
+
return { ...fill, relId: id, sourceXml: buildXml(node) };
|
|
27923
|
+
}
|
|
27924
|
+
function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
|
|
27925
|
+
const pictures = [];
|
|
27926
|
+
const parts = { ...dataParts };
|
|
27927
|
+
const add4 = (source2, owner) => {
|
|
27928
|
+
const part = source2.fill.relId ? owner[source2.fill.relId] : void 0;
|
|
27929
|
+
if (!part) return;
|
|
27930
|
+
let id = Object.keys(parts).find((key) => parts[key] === part);
|
|
27931
|
+
if (!id) {
|
|
27932
|
+
let index = 1;
|
|
27933
|
+
while (Object.hasOwn(parts, `ooxmlDiagramPicture${index}`)) index++;
|
|
27934
|
+
id = `ooxmlDiagramPicture${index}`;
|
|
27935
|
+
parts[id] = part;
|
|
27936
|
+
}
|
|
27937
|
+
const entry2 = { ...source2, fill: remapFill(source2.fill, id) };
|
|
27938
|
+
const existing = pictures.findIndex(
|
|
27939
|
+
(item2) => item2.nodeId === entry2.nodeId && (item2.role === entry2.role && item2.styleLabel === entry2.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry2.fill.relId)
|
|
27940
|
+
);
|
|
27941
|
+
if (existing < 0) pictures.push(entry2);
|
|
27942
|
+
else pictures[existing] = entry2;
|
|
27943
|
+
};
|
|
27944
|
+
const root = parseXml(dataXml2).documentElement;
|
|
27945
|
+
const saved = root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "picture");
|
|
27946
|
+
for (const element4 of saved) {
|
|
27947
|
+
const nodeId = element4.getAttribute("nodeId");
|
|
27948
|
+
const fill = first(element4, "blipFill", NS.a);
|
|
27949
|
+
if (nodeId && fill && model.nodes.some((node) => node.modelId === nodeId))
|
|
27950
|
+
add4(
|
|
27951
|
+
{
|
|
27952
|
+
nodeId,
|
|
27953
|
+
fill: parseDrawingPictureFill(fill),
|
|
27954
|
+
...element4.getAttribute("role") ? { role: element4.getAttribute("role") } : {},
|
|
27955
|
+
...element4.getAttribute("styleLabel") ? { styleLabel: element4.getAttribute("styleLabel") } : {}
|
|
27956
|
+
},
|
|
27957
|
+
dataParts
|
|
27958
|
+
);
|
|
27959
|
+
}
|
|
27960
|
+
for (const point of model.points) {
|
|
27961
|
+
if (point.fill?.kind !== "picture") continue;
|
|
27962
|
+
const nodeId = point.type === "pres" ? point.presAssocId : point.modelId;
|
|
27963
|
+
if (nodeId && model.nodes.some((node) => node.modelId === nodeId) && !pictures.some((item2) => item2.nodeId === nodeId))
|
|
27964
|
+
add4(
|
|
27965
|
+
{
|
|
27966
|
+
nodeId,
|
|
27967
|
+
fill: point.fill,
|
|
27968
|
+
...point.presName ? { role: point.presName } : {},
|
|
27969
|
+
...point.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
|
|
27970
|
+
},
|
|
27971
|
+
dataParts
|
|
27972
|
+
);
|
|
27973
|
+
}
|
|
27974
|
+
for (const shape of drawing?.shapes ?? []) {
|
|
27975
|
+
if (shape.fill?.kind !== "picture") continue;
|
|
27976
|
+
const point = model.points.find((point2) => point2.modelId === shape.modelId);
|
|
27977
|
+
const nodeId = shape.sourceNodeId ?? (point?.type === "pres" ? point.presAssocId : point?.modelId);
|
|
27978
|
+
const part = shape.fill.relId ? drawing?.pictureParts?.[shape.fill.relId] : void 0;
|
|
27979
|
+
if (saved.length && pictures.some(
|
|
27980
|
+
(item2) => item2.nodeId === nodeId && item2.fill.relId && parts[item2.fill.relId] === part && item2.role !== point?.presName && item2.styleLabel !== point?.presStyleLabel
|
|
27981
|
+
))
|
|
27982
|
+
continue;
|
|
27983
|
+
if (nodeId && model.nodes.some((node) => node.modelId === nodeId))
|
|
27984
|
+
add4(
|
|
27985
|
+
{
|
|
27986
|
+
nodeId,
|
|
27987
|
+
fill: shape.fill,
|
|
27988
|
+
...point?.presName ? { role: point.presName } : {},
|
|
27989
|
+
...point?.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
|
|
27990
|
+
},
|
|
27991
|
+
drawing?.pictureParts ?? {}
|
|
27992
|
+
);
|
|
27993
|
+
}
|
|
27994
|
+
return pictures.length ? { pictures, pictureParts: parts } : {};
|
|
27995
|
+
}
|
|
27996
|
+
function applyDiagramPictureSources(drawing, nodes, source2, issues, liveNodeIds) {
|
|
27997
|
+
if (!source2?.pictures?.length) return;
|
|
27998
|
+
if (source2.pictureParts) drawing.pictureParts = { ...source2.pictureParts };
|
|
27999
|
+
const used = /* @__PURE__ */ new Set();
|
|
28000
|
+
nodes.forEach((node, index) => {
|
|
28001
|
+
if (!node.picturePlaceholder || !node.nodeId) return;
|
|
28002
|
+
const shape = drawing.shapes[index];
|
|
28003
|
+
if (!shape) return;
|
|
28004
|
+
const candidates = source2.pictures.filter((picture2) => picture2.nodeId === node.nodeId);
|
|
28005
|
+
const matching = candidates.filter(
|
|
28006
|
+
(picture2) => picture2.role === node.layoutRole || !!picture2.styleLabel && picture2.styleLabel === node.styleLabel
|
|
28007
|
+
);
|
|
28008
|
+
const picture = matching.length === 1 ? matching[0] : candidates.length === 1 ? candidates[0] : void 0;
|
|
28009
|
+
if (picture) {
|
|
28010
|
+
shape.fill = structuredClone(picture.fill);
|
|
28011
|
+
delete shape.text;
|
|
28012
|
+
delete shape.body;
|
|
28013
|
+
used.add(picture);
|
|
28014
|
+
} else if (candidates.length)
|
|
28015
|
+
issues.push({
|
|
28016
|
+
code: "DIAGRAM_PICTURE_AMBIGUOUS",
|
|
28017
|
+
message: `Picture role ${node.layoutRole ?? node.key} has multiple source pictures; no arbitrary assignment was made.`
|
|
28018
|
+
});
|
|
28019
|
+
});
|
|
28020
|
+
if (source2.pictures.some(
|
|
28021
|
+
(picture) => (!liveNodeIds || liveNodeIds.has(picture.nodeId)) && !used.has(picture)
|
|
28022
|
+
))
|
|
28023
|
+
issues.push({
|
|
28024
|
+
code: "DIAGRAM_PICTURE_LAYOUT_UNSUPPORTED",
|
|
28025
|
+
message: "Some retained pictures have no matching image placeholder in this layout. Their source associations are preserved for a compatible layout."
|
|
28026
|
+
});
|
|
28027
|
+
}
|
|
28028
|
+
function withDiagramPictureSources(dataXml2, source2) {
|
|
28029
|
+
if (!source2?.pictures?.length) return dataXml2;
|
|
28030
|
+
const doc = parseXml(dataXml2);
|
|
28031
|
+
const root = doc.documentElement;
|
|
28032
|
+
const points = first(root, "ptLst", NS.dgm);
|
|
28033
|
+
const live = children(points ?? root, "pt", NS.dgm).filter(
|
|
28034
|
+
(point) => !["doc", "pres", "parTrans", "sibTrans"].includes(point.getAttribute("type") ?? "node")
|
|
28035
|
+
);
|
|
28036
|
+
for (const element4 of [...root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "pictures")]) {
|
|
28037
|
+
const extension2 = element4.parentNode;
|
|
28038
|
+
if (extension2?.parentNode) extension2.parentNode.removeChild(extension2);
|
|
28039
|
+
}
|
|
28040
|
+
const retained = source2.pictures.filter(
|
|
28041
|
+
(picture) => live.some((point) => point.getAttribute("modelId") === picture.nodeId)
|
|
28042
|
+
);
|
|
28043
|
+
if (!retained.length) return buildXml(doc);
|
|
28044
|
+
const list2 = first(root, "extLst", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:extLst");
|
|
28045
|
+
if (!list2.parentNode) root.appendChild(list2);
|
|
28046
|
+
const extension = doc.createElementNS(NS.a, "a:ext");
|
|
28047
|
+
extension.setAttribute("uri", DIAGRAM_PICTURE_SOURCE_NS);
|
|
28048
|
+
const payload = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:pictures");
|
|
28049
|
+
extension.appendChild(payload);
|
|
28050
|
+
list2.appendChild(extension);
|
|
28051
|
+
for (const picture of retained) {
|
|
28052
|
+
if (!picture.fill.sourceXml)
|
|
28053
|
+
throw new Error("A retained SmartArt picture needs source fill XML");
|
|
28054
|
+
const element4 = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:picture");
|
|
28055
|
+
element4.setAttribute("nodeId", picture.nodeId);
|
|
28056
|
+
if (picture.role) element4.setAttribute("role", picture.role);
|
|
28057
|
+
if (picture.styleLabel) element4.setAttribute("styleLabel", picture.styleLabel);
|
|
28058
|
+
const fill = parseXml(picture.fill.sourceXml).documentElement;
|
|
28059
|
+
element4.appendChild(doc.importNode(fill, true));
|
|
28060
|
+
payload.appendChild(element4);
|
|
28061
|
+
const presentations = children(points ?? root, "pt", NS.dgm).filter((point) => {
|
|
28062
|
+
const props = first(point, "prSet", NS.dgm);
|
|
28063
|
+
return point.getAttribute("type") === "pres" && props?.getAttribute("presAssocID") === picture.nodeId && (picture.role && props.getAttribute("presName") === picture.role || picture.styleLabel && props.getAttribute("presStyleLbl") === picture.styleLabel);
|
|
28064
|
+
});
|
|
28065
|
+
if (presentations.length === 1) {
|
|
28066
|
+
const point = presentations[0];
|
|
28067
|
+
const props = first(point, "spPr", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:spPr");
|
|
28068
|
+
if (!props.parentNode) point.appendChild(props);
|
|
28069
|
+
for (const old of [...props.childNodes].filter((node) => node.nodeType === 1).filter(
|
|
28070
|
+
(node) => node.namespaceURI === NS.a && ["blipFill", "solidFill", "gradFill", "pattFill", "noFill", "grpFill"].includes(
|
|
28071
|
+
node.localName
|
|
28072
|
+
)
|
|
28073
|
+
))
|
|
28074
|
+
props.removeChild(old);
|
|
28075
|
+
props.insertBefore(doc.importNode(fill, true), props.firstChild);
|
|
28076
|
+
}
|
|
28077
|
+
}
|
|
28078
|
+
return buildXml(doc);
|
|
28079
|
+
}
|
|
28080
|
+
function diagramPictureRelationships(owner, source2, existing) {
|
|
28081
|
+
if (!source2?.pictures?.length || !source2.pictureParts) return existing;
|
|
28082
|
+
const rels = parseRelationships(existing);
|
|
28083
|
+
for (const [id, part] of Object.entries(source2.pictureParts)) {
|
|
28084
|
+
const previous = rels.get(id);
|
|
28085
|
+
if (previous && (previous.mode === "External" || resolvePartPath(owner, previous.target) !== part))
|
|
28086
|
+
throw new Error(`Conflicting SmartArt picture relationship: ${id}`);
|
|
28087
|
+
rels.set(id, { id, type: RELATIONSHIP_TYPES.image, target: `/${part}`, mode: "Internal" });
|
|
28088
|
+
}
|
|
28089
|
+
return buildRelationshipsXml(rels);
|
|
28090
|
+
}
|
|
28091
|
+
|
|
28092
|
+
// diagram/layout-role-style.ts
|
|
28093
|
+
function applyDiagramRoleColors(shape, role, index, minorFont) {
|
|
28094
|
+
const at = (colors) => colors[index % colors.length];
|
|
28095
|
+
const fill = role && at(role.fill.colors);
|
|
28096
|
+
if (fill && shape.fill?.kind !== "none" && shape.fill?.kind !== "picture")
|
|
28097
|
+
shape.fill = { kind: "solid", color: structuredClone(fill) };
|
|
28098
|
+
const line2 = role && at(role.line.colors);
|
|
28099
|
+
if (line2 && shape.line) shape.line.fill = { kind: "solid", color: structuredClone(line2) };
|
|
28100
|
+
const text = role && at(role.textFill.colors);
|
|
28101
|
+
for (const paragraph2 of shape.text?.paragraphs ?? []) {
|
|
28102
|
+
for (const run2 of paragraph2.runs) {
|
|
28103
|
+
if (!run2.color && text) run2.color = structuredClone(text);
|
|
28104
|
+
if (!run2.typeface && minorFont) run2.typeface = minorFont;
|
|
28105
|
+
}
|
|
28106
|
+
}
|
|
28107
|
+
}
|
|
28108
|
+
|
|
27575
28109
|
// diagram/layout-preview.ts
|
|
27576
28110
|
function diagramLayoutData(input) {
|
|
27577
28111
|
const original = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
|
|
@@ -27617,7 +28151,7 @@ function diagramLayoutData(input) {
|
|
|
27617
28151
|
data.layoutDefinition = { rootNode: {}, rawXmlText: input.source.layoutXml };
|
|
27618
28152
|
if (input.source?.dataXml) {
|
|
27619
28153
|
const root = parseXml(input.source.dataXml).documentElement;
|
|
27620
|
-
const vars =
|
|
28154
|
+
const vars = descendants(root, "presLayoutVars")[0];
|
|
27621
28155
|
const direction = first(vars, "dir", NS.dgm)?.getAttribute("val");
|
|
27622
28156
|
const values = {};
|
|
27623
28157
|
if (direction === "norm" || direction === "rev") values.direction = direction;
|
|
@@ -27675,7 +28209,7 @@ function previewDiagramLayout(input) {
|
|
|
27675
28209
|
const computed = runEngineLayout(data, box, data.nodes, palette, intensity);
|
|
27676
28210
|
if (computed) {
|
|
27677
28211
|
const result = applyCustomLayoutOverrides(computed, data.nodes, box);
|
|
27678
|
-
const declaresConnectors = input.source?.layoutXml &&
|
|
28212
|
+
const declaresConnectors = input.source?.layoutXml && descendants(parseXml(input.source.layoutXml).documentElement, "alg").some(
|
|
27679
28213
|
(algorithm) => algorithm.getAttribute("type") === "conn"
|
|
27680
28214
|
);
|
|
27681
28215
|
if (declaresConnectors && data.nodes.some((node) => node.parentId) && !result.nodes.some((node) => /connector|^line(?:Inv)?$/i.test(node.presetOverride ?? "")))
|
|
@@ -27717,6 +28251,8 @@ function previewDiagramLayout(input) {
|
|
|
27717
28251
|
];
|
|
27718
28252
|
});
|
|
27719
28253
|
const drawing2 = diagramDrawingFromViews(views);
|
|
28254
|
+
drawing2.extentEmu = { ...input.extentEmu };
|
|
28255
|
+
const colors = input.source?.colorsXml ? parseDiagramColors(input.source.colorsXml) : void 0;
|
|
27720
28256
|
const quickStyle = input.source?.quickStyleXml ? parseDiagramQuickStyle(input.source.quickStyleXml) : void 0;
|
|
27721
28257
|
const originalModel = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
|
|
27722
28258
|
result.nodes.forEach((node, index) => {
|
|
@@ -27727,7 +28263,9 @@ function previewDiagramLayout(input) {
|
|
|
27727
28263
|
shape.style = label;
|
|
27728
28264
|
shape.has3d = label.requires3d ?? label.hasShape3d;
|
|
27729
28265
|
}
|
|
27730
|
-
|
|
28266
|
+
const contextNodeId = node.nodeId ?? node.contextNodeId;
|
|
28267
|
+
if (contextNodeId) shape.sourceNodeId = contextNodeId;
|
|
28268
|
+
if (node.layoutRole) shape.sourceLayoutRole = node.layoutRole;
|
|
27731
28269
|
if (node.styleLabel) shape.sourceStyleLabel = node.styleLabel;
|
|
27732
28270
|
if (node.foldedNodeIds?.length) shape.foldedNodeIds = node.foldedNodeIds;
|
|
27733
28271
|
const sourceNode = data.nodes.find((entry2) => entry2.id === node.nodeId);
|
|
@@ -27740,15 +28278,36 @@ function previewDiagramLayout(input) {
|
|
|
27740
28278
|
if (fill) shape.fill = fill;
|
|
27741
28279
|
}
|
|
27742
28280
|
const direct = originalModel?.nodes.find((entry2) => entry2.modelId === node.nodeId);
|
|
27743
|
-
if (direct?.fill) shape.fill = direct.fill;
|
|
27744
|
-
if (direct?.line) shape.line = { ...shape.line, ...direct.line };
|
|
27745
28281
|
const sourceIds = [node.nodeId, ...node.foldedNodeIds ?? []];
|
|
27746
28282
|
const textNodes = sourceIds.flatMap((id) => {
|
|
27747
28283
|
const source2 = input.nodes.find((entry2) => entry2.id === id);
|
|
27748
28284
|
return source2 ? [source2] : [];
|
|
27749
28285
|
});
|
|
27750
28286
|
if (textNodes.length) shape.text = diagramPreviewText(textNodes, node.fontSize);
|
|
28287
|
+
if (shape.text) {
|
|
28288
|
+
if (node.textVerticalAnchor) shape.text.anchor = node.textVerticalAnchor;
|
|
28289
|
+
for (const paragraph2 of shape.text.paragraphs)
|
|
28290
|
+
if (!paragraph2.align && node.textAlign) paragraph2.align = node.textAlign;
|
|
28291
|
+
}
|
|
28292
|
+
applyDiagramRoleColors(
|
|
28293
|
+
shape,
|
|
28294
|
+
colors?.labels.find((label2) => label2.name === node.styleLabel),
|
|
28295
|
+
Math.max(
|
|
28296
|
+
0,
|
|
28297
|
+
input.nodes.findIndex((entry2) => entry2.id === contextNodeId)
|
|
28298
|
+
),
|
|
28299
|
+
input.minorFont
|
|
28300
|
+
);
|
|
28301
|
+
if (direct?.fill && direct.fill.kind !== "picture") shape.fill = direct.fill;
|
|
28302
|
+
if (direct?.line) shape.line = { ...shape.line, ...direct.line };
|
|
27751
28303
|
});
|
|
28304
|
+
applyDiagramPictureSources(
|
|
28305
|
+
drawing2,
|
|
28306
|
+
result.nodes,
|
|
28307
|
+
input.source,
|
|
28308
|
+
issues,
|
|
28309
|
+
new Set(input.nodes.map((node) => node.id))
|
|
28310
|
+
);
|
|
27752
28311
|
return { drawing: drawing2, mode: "interpreted", issues };
|
|
27753
28312
|
}
|
|
27754
28313
|
} catch (error) {
|
|
@@ -27789,16 +28348,16 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
|
|
|
27789
28348
|
|
|
27790
28349
|
// diagram/write/cache.ts
|
|
27791
28350
|
var DSP2 = "http://schemas.microsoft.com/office/drawing/2008/diagram";
|
|
27792
|
-
function add2(parent, namespace, name,
|
|
28351
|
+
function add2(parent, namespace, name, attrs3 = {}) {
|
|
27793
28352
|
const child8 = parent.ownerDocument.createElementNS(namespace, name);
|
|
27794
|
-
for (const [key, value] of Object.entries(
|
|
28353
|
+
for (const [key, value] of Object.entries(attrs3)) child8.setAttribute(key, value);
|
|
27795
28354
|
parent.appendChild(child8);
|
|
27796
28355
|
return child8;
|
|
27797
28356
|
}
|
|
27798
28357
|
function withDiagramDrawingRelationship(xml, relationshipId) {
|
|
27799
28358
|
const doc = parseXml(xml);
|
|
27800
28359
|
const model = doc.documentElement;
|
|
27801
|
-
let extension =
|
|
28360
|
+
let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
|
|
27802
28361
|
if (!extension) {
|
|
27803
28362
|
const extLst = first(model, "extLst", NS.dgm) ?? add2(model, NS.dgm, "dgm:extLst");
|
|
27804
28363
|
extension = add2(add2(extLst, NS.a, "a:ext", { uri: DSP2 }), DSP2, "dsp:dataModelExt", {
|
|
@@ -27809,6 +28368,7 @@ function withDiagramDrawingRelationship(xml, relationshipId) {
|
|
|
27809
28368
|
return buildXml(doc);
|
|
27810
28369
|
}
|
|
27811
28370
|
function buildGeneratedDiagramCache(dataXml2, input) {
|
|
28371
|
+
dataXml2 = withDiagramPictureSources(dataXml2, input.source);
|
|
27812
28372
|
const source2 = { ...input.source, dataXml: dataXml2 };
|
|
27813
28373
|
const model = parseDiagramDataModel(dataXml2);
|
|
27814
28374
|
const scheme2 = { ...DEFAULT_GENERATED_DIAGRAM_SCHEME, ...input.scheme };
|
|
@@ -27835,7 +28395,10 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
27835
28395
|
}
|
|
27836
28396
|
for (const shape of drawing.shapes) {
|
|
27837
28397
|
if (shape.has3d || shape.foldedNodeIds?.length) return void 0;
|
|
27838
|
-
if (shape.fill && !["none", "solid", "gradient"].includes(shape.fill.kind))
|
|
28398
|
+
if (shape.fill && !["none", "solid", "gradient", "picture"].includes(shape.fill.kind))
|
|
28399
|
+
return void 0;
|
|
28400
|
+
if (shape.fill?.kind === "picture" && (!shape.fill.relId || !drawing.pictureParts?.[shape.fill.relId]))
|
|
28401
|
+
return void 0;
|
|
27839
28402
|
if (shape.fill?.kind === "gradient" && shape.fill.path && !["circle", "rect"].includes(shape.fill.path))
|
|
27840
28403
|
return void 0;
|
|
27841
28404
|
if (shape.effects?.effects.some(
|
|
@@ -27908,12 +28471,12 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
27908
28471
|
} catch {
|
|
27909
28472
|
return void 0;
|
|
27910
28473
|
}
|
|
27911
|
-
const oldMarkers =
|
|
28474
|
+
const oldMarkers = descendants(root, "generatedCache").filter(
|
|
27912
28475
|
(node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
27913
28476
|
);
|
|
27914
28477
|
const oldIds = new Set(
|
|
27915
28478
|
oldMarkers.flatMap(
|
|
27916
|
-
(marker2) =>
|
|
28479
|
+
(marker2) => descendants(marker2, "shape").map((node) => node.getAttribute("id"))
|
|
27917
28480
|
)
|
|
27918
28481
|
);
|
|
27919
28482
|
for (const point of children(points, "pt", NS.dgm))
|
|
@@ -27942,12 +28505,15 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
27942
28505
|
const point = add2(points, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
|
|
27943
28506
|
add2(point, NS.dgm, "dgm:prSet", {
|
|
27944
28507
|
...shape.sourceNodeId ? { presAssocID: shape.sourceNodeId } : {},
|
|
27945
|
-
presName: "node",
|
|
28508
|
+
presName: shape.sourceLayoutRole ?? "node",
|
|
27946
28509
|
presStyleLbl: shape.sourceStyleLabel ?? "node1",
|
|
27947
28510
|
presStyleIdx: String(index),
|
|
27948
28511
|
presStyleCnt: String(drawing.shapes.length)
|
|
27949
28512
|
});
|
|
27950
|
-
add2(point, NS.dgm, "dgm:spPr");
|
|
28513
|
+
const properties = add2(point, NS.dgm, "dgm:spPr");
|
|
28514
|
+
if (shape.fill?.kind === "picture" && shape.fill.sourceXml) {
|
|
28515
|
+
properties.appendChild(doc.importNode(parseXml(shape.fill.sourceXml).documentElement, true));
|
|
28516
|
+
}
|
|
27951
28517
|
if (shape.sourceNodeId)
|
|
27952
28518
|
add2(connections, NS.dgm, "dgm:cxn", {
|
|
27953
28519
|
modelId: createOfficeGuid(),
|
|
@@ -27960,7 +28526,11 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
27960
28526
|
});
|
|
27961
28527
|
add2(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
|
|
27962
28528
|
});
|
|
27963
|
-
return {
|
|
28529
|
+
return {
|
|
28530
|
+
dataXml: buildXml(doc),
|
|
28531
|
+
drawingXml: serialized.xml,
|
|
28532
|
+
...drawing.pictureParts ? { pictureParts: drawing.pictureParts } : {}
|
|
28533
|
+
};
|
|
27964
28534
|
}
|
|
27965
28535
|
|
|
27966
28536
|
// diagram/relationships.ts
|
|
@@ -28225,6 +28795,29 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
28225
28795
|
code: "DIAGRAM_DRAWING_ABSENT",
|
|
28226
28796
|
message: "The package has no cached drawing for this diagram; its layout can only be recomputed from the layout definition."
|
|
28227
28797
|
});
|
|
28798
|
+
if (data && layoutSource.dataXml) {
|
|
28799
|
+
let pictureParts = {};
|
|
28800
|
+
if (paths.data) {
|
|
28801
|
+
const owner = paths.data;
|
|
28802
|
+
try {
|
|
28803
|
+
const entries = await host.readRelationshipEntries(diagramRelationshipsPart(owner));
|
|
28804
|
+
pictureParts = Object.fromEntries(
|
|
28805
|
+
(entries ?? []).filter(
|
|
28806
|
+
(entry2) => entry2.type.endsWith("/image") && entry2.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry2.target)
|
|
28807
|
+
).map((entry2) => [entry2.id, host.resolvePath(owner, entry2.target)])
|
|
28808
|
+
);
|
|
28809
|
+
} catch {
|
|
28810
|
+
issues.push({
|
|
28811
|
+
code: "DIAGRAM_PICTURE_RELATIONSHIPS_UNREADABLE",
|
|
28812
|
+
message: "Picture relationships in the diagram data could not be read."
|
|
28813
|
+
});
|
|
28814
|
+
}
|
|
28815
|
+
}
|
|
28816
|
+
Object.assign(
|
|
28817
|
+
layoutSource,
|
|
28818
|
+
captureDiagramPictures(data, layoutSource.dataXml, pictureParts, drawing)
|
|
28819
|
+
);
|
|
28820
|
+
}
|
|
28228
28821
|
return {
|
|
28229
28822
|
layoutSource,
|
|
28230
28823
|
...generatedCache ? { generatedCache: true } : {},
|
|
@@ -30596,8 +31189,8 @@ function attributes(entries) {
|
|
|
30596
31189
|
return ` ${name}="${text}"`;
|
|
30597
31190
|
}).join("");
|
|
30598
31191
|
}
|
|
30599
|
-
var cxElement = (local, content = "",
|
|
30600
|
-
var cxText = (local, text,
|
|
31192
|
+
var cxElement = (local, content = "", attrs3 = "") => content ? `<cx:${local}${attrs3}>${content}</cx:${local}>` : `<cx:${local}${attrs3}/>`;
|
|
31193
|
+
var cxText = (local, text, attrs3 = "") => text === void 0 ? "" : `<cx:${local}${attrs3}>${escapeText2(text)}</cx:${local}>`;
|
|
30601
31194
|
var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
|
|
30602
31195
|
var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
|
|
30603
31196
|
var shapeXml = (context, shape) => shape ? cxElement("spPr", shapePropertiesInnerXml(context, shape)) : "";
|
|
@@ -31648,6 +32241,54 @@ async function appendChartExWorkbookData(bytes, before, after) {
|
|
|
31648
32241
|
return { bytes: result.bytes, space: layout2.space };
|
|
31649
32242
|
}
|
|
31650
32243
|
|
|
32244
|
+
// chart/render/chart-title-text.ts
|
|
32245
|
+
function chartRunStyle(run2) {
|
|
32246
|
+
return {
|
|
32247
|
+
...run2.sizePt === void 0 ? {} : { fontSize: run2.sizePt },
|
|
32248
|
+
...run2.bold === void 0 ? {} : { bold: run2.bold },
|
|
32249
|
+
...run2.italic === void 0 ? {} : { italic: run2.italic },
|
|
32250
|
+
...run2.underline === void 0 ? {} : { underline: run2.underline },
|
|
32251
|
+
...run2.typeface === void 0 ? {} : { typeface: run2.typeface },
|
|
32252
|
+
...run2.color === void 0 ? {} : { textColor: run2.color }
|
|
32253
|
+
};
|
|
32254
|
+
}
|
|
32255
|
+
|
|
32256
|
+
// chart/render/summary-ex-formatting.ts
|
|
32257
|
+
function textStyle(body) {
|
|
32258
|
+
const paragraph2 = body?.paragraphs[0];
|
|
32259
|
+
return {
|
|
32260
|
+
...chartRunStyle(paragraph2?.defaultProperties ?? {}),
|
|
32261
|
+
...chartRunStyle(paragraph2?.runs[0] ?? {})
|
|
32262
|
+
};
|
|
32263
|
+
}
|
|
32264
|
+
function chartExFormatting(space) {
|
|
32265
|
+
return {
|
|
32266
|
+
builtInStyle: 2,
|
|
32267
|
+
sourceXml: "",
|
|
32268
|
+
entries: {
|
|
32269
|
+
title: {
|
|
32270
|
+
fontSize: 18,
|
|
32271
|
+
bold: false,
|
|
32272
|
+
textColor: {
|
|
32273
|
+
kind: "scheme",
|
|
32274
|
+
value: "tx1",
|
|
32275
|
+
transforms: []
|
|
32276
|
+
},
|
|
32277
|
+
...textStyle(space.title?.txPr),
|
|
32278
|
+
...textStyle(space.title?.tx?.rich),
|
|
32279
|
+
...space.title?.tx?.rich ? { textBody: space.title.tx.rich } : {},
|
|
32280
|
+
sourceXml: ""
|
|
32281
|
+
},
|
|
32282
|
+
legend: { fontSize: 12, ...textStyle(space.legend?.txPr), sourceXml: "" },
|
|
32283
|
+
categoryAxis: {
|
|
32284
|
+
fontSize: 10,
|
|
32285
|
+
...textStyle(space.plotArea.axes.find((a2) => a2.scaling?.kind === "cat")?.txPr),
|
|
32286
|
+
sourceXml: ""
|
|
32287
|
+
}
|
|
32288
|
+
}
|
|
32289
|
+
};
|
|
32290
|
+
}
|
|
32291
|
+
|
|
31651
32292
|
// chart/render/summary-ex-series.ts
|
|
31652
32293
|
var level2 = (source2) => ({
|
|
31653
32294
|
...source2.visibility?.value === void 0 ? {} : { showValue: source2.visibility.value },
|
|
@@ -31660,6 +32301,7 @@ var level2 = (source2) => ({
|
|
|
31660
32301
|
function chartExSeriesPaint(source2, series, defaultValues = false) {
|
|
31661
32302
|
const fill = source2.spPr?.fill;
|
|
31662
32303
|
if (fill) series.fill = fill;
|
|
32304
|
+
if (source2.spPr?.line) series.line = source2.spPr.line;
|
|
31663
32305
|
const points = {};
|
|
31664
32306
|
const fills = {};
|
|
31665
32307
|
for (const point of source2.dataPoints) {
|
|
@@ -31743,34 +32385,13 @@ function chartExSummary(source2) {
|
|
|
31743
32385
|
if (!isChartExRoot(root)) return void 0;
|
|
31744
32386
|
return chartExSummaryFromModel(parseChartExSpace(root).chartExSpace);
|
|
31745
32387
|
}
|
|
31746
|
-
function chartExFormatting() {
|
|
31747
|
-
return {
|
|
31748
|
-
builtInStyle: 2,
|
|
31749
|
-
sourceXml: "",
|
|
31750
|
-
entries: {
|
|
31751
|
-
title: {
|
|
31752
|
-
fontSize: 14,
|
|
31753
|
-
bold: false,
|
|
31754
|
-
textColor: {
|
|
31755
|
-
kind: "scheme",
|
|
31756
|
-
value: "tx1",
|
|
31757
|
-
transforms: [
|
|
31758
|
-
{ name: "lumMod", value: "65000" },
|
|
31759
|
-
{ name: "lumOff", value: "35000" }
|
|
31760
|
-
]
|
|
31761
|
-
},
|
|
31762
|
-
sourceXml: ""
|
|
31763
|
-
}
|
|
31764
|
-
}
|
|
31765
|
-
};
|
|
31766
|
-
}
|
|
31767
32388
|
function summarySeries(space, source2, chartType) {
|
|
31768
32389
|
const data = seriesData(space, source2);
|
|
31769
32390
|
const categories = dimension(data, "strDim", "cat");
|
|
31770
32391
|
const values = dimension(
|
|
31771
32392
|
data,
|
|
31772
32393
|
"numDim",
|
|
31773
|
-
chartType === "treemap" || chartType === "sunburst" ? "size" : "val"
|
|
32394
|
+
chartType === "treemap" || chartType === "sunburst" ? "size" : chartType === "regionMap" ? "colorVal" : "val"
|
|
31774
32395
|
);
|
|
31775
32396
|
const series = {
|
|
31776
32397
|
categories: categories?.points ?? [],
|
|
@@ -31779,11 +32400,24 @@ function summarySeries(space, source2, chartType) {
|
|
|
31779
32400
|
),
|
|
31780
32401
|
...seriesFill(source2)
|
|
31781
32402
|
};
|
|
31782
|
-
if (chartType === "funnel" || chartType === "boxWhisker") {
|
|
32403
|
+
if (chartType === "funnel" || chartType === "boxWhisker" || chartType === "regionMap") {
|
|
31783
32404
|
chartExSeriesPaint(source2, series, chartType === "funnel" && source2.dataLabels !== void 0);
|
|
31784
32405
|
if (source2.hidden !== void 0) series.hidden = source2.hidden;
|
|
31785
32406
|
}
|
|
31786
32407
|
if (chartType === "boxWhisker") series.boxWhisker = source2.layoutProperties ?? {};
|
|
32408
|
+
if (chartType === "regionMap") {
|
|
32409
|
+
const geo = source2.layoutProperties?.geography;
|
|
32410
|
+
series.regionMap = {
|
|
32411
|
+
...geo,
|
|
32412
|
+
...geo?.geoCacheXml ? { geographyCacheXml: geo.geoCacheXml } : {},
|
|
32413
|
+
...dimension(data, "strDim", "entityId") ? { entityIds: dimension(data, "strDim", "entityId").points } : {},
|
|
32414
|
+
...source2.layoutProperties?.regionLabelLayout ? {
|
|
32415
|
+
regionLabelLayout: source2.layoutProperties.regionLabelLayout
|
|
32416
|
+
} : {},
|
|
32417
|
+
...source2.valueColorsXml ? { valueColorsXml: source2.valueColorsXml } : {},
|
|
32418
|
+
...source2.valueColorPositionsXml ? { valueColorPositionsXml: source2.valueColorPositionsXml } : {}
|
|
32419
|
+
};
|
|
32420
|
+
}
|
|
31787
32421
|
const name = source2.tx?.value?.trim();
|
|
31788
32422
|
if (name) series.name = name;
|
|
31789
32423
|
const nameRef = source2.tx?.formula?.formula.trim();
|
|
@@ -31796,7 +32430,7 @@ function chartExSummaryFromModel(space) {
|
|
|
31796
32430
|
const all = space.plotArea.series;
|
|
31797
32431
|
const primary = all.find((s) => s.layoutId !== "paretoLine") ?? all[0];
|
|
31798
32432
|
const layoutId = primary?.layoutId ?? "";
|
|
31799
|
-
const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" ? layoutId : void 0;
|
|
32433
|
+
const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" || layoutId === "regionMap" ? layoutId : void 0;
|
|
31800
32434
|
if (!primary || !chartType) return { layoutId };
|
|
31801
32435
|
const series = summarySeries(space, primary, chartType);
|
|
31802
32436
|
const layout2 = primary.layoutProperties;
|
|
@@ -31834,7 +32468,12 @@ function chartExSummaryFromModel(space) {
|
|
|
31834
32468
|
];
|
|
31835
32469
|
});
|
|
31836
32470
|
}
|
|
31837
|
-
|
|
32471
|
+
if (chartType === "funnel") {
|
|
32472
|
+
const cat = space.plotArea.axes.find((axis) => axis.scaling?.kind === "cat")?.scaling;
|
|
32473
|
+
if (cat?.kind === "cat" && typeof cat.gapWidth === "number")
|
|
32474
|
+
summary.funnelGapWidth = cat.gapWidth;
|
|
32475
|
+
}
|
|
32476
|
+
summary.formatting = chartExFormatting(space);
|
|
31838
32477
|
const title = titleOf(space);
|
|
31839
32478
|
if (title) summary.title = title;
|
|
31840
32479
|
const position2 = legend?.position;
|
|
@@ -32031,11 +32670,11 @@ function warningsFor(document) {
|
|
|
32031
32670
|
],
|
|
32032
32671
|
[
|
|
32033
32672
|
["rPrChange"],
|
|
32034
|
-
"Formatting-change revisions retain their prior run-properties snapshots and support acceptance and
|
|
32673
|
+
"Formatting-change revisions retain their prior run-properties snapshots and support acceptance, rejection and Original display; supported run-formatting changes are recorded as new revisions, other formatting edits are not."
|
|
32035
32674
|
],
|
|
32036
32675
|
[
|
|
32037
32676
|
["pPrChange"],
|
|
32038
|
-
"Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance and
|
|
32677
|
+
"Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance, rejection and Original display; pure paragraph-formatting changes are recorded as new revisions, and revised paragraph-mark merging is not shown yet."
|
|
32039
32678
|
],
|
|
32040
32679
|
[
|
|
32041
32680
|
["ffData"],
|
|
@@ -32330,6 +32969,7 @@ function parseModernDrawing(node, context) {
|
|
|
32330
32969
|
if (picture)
|
|
32331
32970
|
return {
|
|
32332
32971
|
...picture,
|
|
32972
|
+
...blip?.parentNode ? { pictureFill: parseDrawingPictureFill(blip.parentNode) } : {},
|
|
32333
32973
|
widthPx,
|
|
32334
32974
|
heightPx,
|
|
32335
32975
|
...definedProps({ altText, title, anchored }),
|
|
@@ -32433,7 +33073,7 @@ var add3 = (parent, ...items) => {
|
|
|
32433
33073
|
};
|
|
32434
33074
|
var emu3 = (px2) => String(Math.max(1, Math.round(px2 * EMU_PER_PIXEL)));
|
|
32435
33075
|
var emuOffset = (px2) => String(Math.round(px2 * EMU_PER_PIXEL));
|
|
32436
|
-
var
|
|
33076
|
+
var attrs2 = (element4, values) => {
|
|
32437
33077
|
for (const [name, value] of Object.entries(values)) element4.setAttribute(name, value);
|
|
32438
33078
|
return element4;
|
|
32439
33079
|
};
|
|
@@ -32486,9 +33126,9 @@ function textParagraphs(doc, lines2, color) {
|
|
|
32486
33126
|
}
|
|
32487
33127
|
function shapeStyle(doc) {
|
|
32488
33128
|
const ref = (name, idx, scheme2, shade) => {
|
|
32489
|
-
const node =
|
|
32490
|
-
const color =
|
|
32491
|
-
if (shade) add3(color,
|
|
33129
|
+
const node = attrs2(el2(doc, A_NS2, `a:${name}`), { idx });
|
|
33130
|
+
const color = attrs2(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
|
|
33131
|
+
if (shade) add3(color, attrs2(el2(doc, A_NS2, "a:shade"), { val: shade }));
|
|
32492
33132
|
return add3(node, color);
|
|
32493
33133
|
};
|
|
32494
33134
|
return add3(
|
|
@@ -32502,17 +33142,17 @@ function shapeStyle(doc) {
|
|
|
32502
33142
|
function wrapElement(doc, placement) {
|
|
32503
33143
|
switch (placement.wrap) {
|
|
32504
33144
|
case "square":
|
|
32505
|
-
return
|
|
33145
|
+
return attrs2(el2(doc, WP_NS3, "wp:wrapSquare"), { wrapText: "bothSides" });
|
|
32506
33146
|
case "tight":
|
|
32507
33147
|
case "through": {
|
|
32508
|
-
const wrap2 =
|
|
33148
|
+
const wrap2 = attrs2(
|
|
32509
33149
|
el2(doc, WP_NS3, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
|
|
32510
33150
|
{
|
|
32511
33151
|
wrapText: "bothSides"
|
|
32512
33152
|
}
|
|
32513
33153
|
);
|
|
32514
|
-
const polygon =
|
|
32515
|
-
const point = (name, x, y) =>
|
|
33154
|
+
const polygon = attrs2(el2(doc, WP_NS3, "wp:wrapPolygon"), { edited: "0" });
|
|
33155
|
+
const point = (name, x, y) => attrs2(el2(doc, WP_NS3, `wp:${name}`), { x, y });
|
|
32516
33156
|
return add3(
|
|
32517
33157
|
wrap2,
|
|
32518
33158
|
add3(
|
|
@@ -32532,7 +33172,7 @@ function wrapElement(doc, placement) {
|
|
|
32532
33172
|
}
|
|
32533
33173
|
}
|
|
32534
33174
|
function position(doc, axis, relativeFrom, align, offsetPx) {
|
|
32535
|
-
const node =
|
|
33175
|
+
const node = attrs2(el2(doc, WP_NS3, `wp:position${axis}`), { relativeFrom });
|
|
32536
33176
|
if (align) {
|
|
32537
33177
|
const a2 = el2(doc, WP_NS3, "wp:align");
|
|
32538
33178
|
a2.textContent = align;
|
|
@@ -32543,10 +33183,10 @@ function position(doc, axis, relativeFrom, align, offsetPx) {
|
|
|
32543
33183
|
return add3(node, offset);
|
|
32544
33184
|
}
|
|
32545
33185
|
function geometry(doc, spec) {
|
|
32546
|
-
const prst =
|
|
33186
|
+
const prst = attrs2(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
|
|
32547
33187
|
const avLst = el2(doc, A_NS2, "a:avLst");
|
|
32548
33188
|
for (const [name, value] of Object.entries(spec.adjustments ?? {}))
|
|
32549
|
-
add3(avLst,
|
|
33189
|
+
add3(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
|
|
32550
33190
|
const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add3(prst, avLst)];
|
|
32551
33191
|
if (spec.fill) {
|
|
32552
33192
|
const xml = drawingFillXml(spec.fill);
|
|
@@ -32562,7 +33202,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
32562
33202
|
const anchored = Boolean(image.anchored);
|
|
32563
33203
|
const holder = el2(doc, WP_NS3, anchored ? "wp:anchor" : "wp:inline");
|
|
32564
33204
|
if (anchored) {
|
|
32565
|
-
|
|
33205
|
+
attrs2(holder, {
|
|
32566
33206
|
distT: "0",
|
|
32567
33207
|
distB: "0",
|
|
32568
33208
|
distL: "114300",
|
|
@@ -32576,7 +33216,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
32576
33216
|
});
|
|
32577
33217
|
add3(
|
|
32578
33218
|
holder,
|
|
32579
|
-
|
|
33219
|
+
attrs2(el2(doc, WP_NS3, "wp:simplePos"), { x: "0", y: "0" }),
|
|
32580
33220
|
position(
|
|
32581
33221
|
doc,
|
|
32582
33222
|
"H",
|
|
@@ -32595,24 +33235,24 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
32595
33235
|
} else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
|
|
32596
33236
|
add3(
|
|
32597
33237
|
holder,
|
|
32598
|
-
|
|
32599
|
-
|
|
33238
|
+
attrs2(el2(doc, WP_NS3, "wp:extent"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) }),
|
|
33239
|
+
attrs2(el2(doc, WP_NS3, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
|
|
32600
33240
|
);
|
|
32601
33241
|
if (anchored) add3(holder, wrapElement(doc, placement ?? { wrap: "none" }));
|
|
32602
|
-
const docPr =
|
|
33242
|
+
const docPr = attrs2(el2(doc, WP_NS3, "wp:docPr"), {
|
|
32603
33243
|
id: identity.id,
|
|
32604
33244
|
name: identity.name ?? `Shape ${identity.id}`
|
|
32605
33245
|
});
|
|
32606
33246
|
if (identity.descr) docPr.setAttribute("descr", identity.descr);
|
|
32607
33247
|
if (identity.title) docPr.setAttribute("title", identity.title);
|
|
32608
|
-
const xfrm =
|
|
33248
|
+
const xfrm = attrs2(el2(doc, A_NS2, "a:xfrm"), {});
|
|
32609
33249
|
if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
|
|
32610
33250
|
if (spec.flipH) xfrm.setAttribute("flipH", "1");
|
|
32611
33251
|
if (spec.flipV) xfrm.setAttribute("flipV", "1");
|
|
32612
33252
|
add3(
|
|
32613
33253
|
xfrm,
|
|
32614
|
-
|
|
32615
|
-
|
|
33254
|
+
attrs2(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
|
|
33255
|
+
attrs2(el2(doc, A_NS2, "a:ext"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) })
|
|
32616
33256
|
);
|
|
32617
33257
|
const spPr = add3(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
|
|
32618
33258
|
const wsp = add3(
|
|
@@ -32628,7 +33268,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
32628
33268
|
);
|
|
32629
33269
|
add3(wsp, add3(el2(doc, WPS_NS2, "wps:txbx"), content));
|
|
32630
33270
|
}
|
|
32631
|
-
const body =
|
|
33271
|
+
const body = attrs2(el2(doc, WPS_NS2, "wps:bodyPr"), {
|
|
32632
33272
|
rot: "0",
|
|
32633
33273
|
vert: "horz",
|
|
32634
33274
|
wrap: "square",
|
|
@@ -32640,7 +33280,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
32640
33280
|
anchorCtr: "0"
|
|
32641
33281
|
});
|
|
32642
33282
|
add3(wsp, add3(body, el2(doc, A_NS2, "a:noAutofit")));
|
|
32643
|
-
const graphicData =
|
|
33283
|
+
const graphicData = attrs2(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
|
|
32644
33284
|
add3(
|
|
32645
33285
|
holder,
|
|
32646
33286
|
docPr,
|
|
@@ -32756,9 +33396,9 @@ function clearNonProperties(node, keep) {
|
|
|
32756
33396
|
var A_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
32757
33397
|
var WP_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
32758
33398
|
var C_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
32759
|
-
function child7(parent, ns, name,
|
|
33399
|
+
function child7(parent, ns, name, attrs3 = {}) {
|
|
32760
33400
|
const node = makeNS(parent.ownerDocument, ns, name);
|
|
32761
|
-
for (const [key, value] of Object.entries(
|
|
33401
|
+
for (const [key, value] of Object.entries(attrs3)) node.setAttribute(key, value);
|
|
32762
33402
|
parent.appendChild(node);
|
|
32763
33403
|
return node;
|
|
32764
33404
|
}
|
|
@@ -33242,6 +33882,19 @@ async function applyDiagramEdits(zip, blocks, baseBlocks, pendingMedia) {
|
|
|
33242
33882
|
...relaid && layoutId ? { layout: { uniqueId: layoutId, category: diagram.layout?.family } } : {}
|
|
33243
33883
|
})
|
|
33244
33884
|
);
|
|
33885
|
+
if (diagram.layoutSource?.pictures?.length) {
|
|
33886
|
+
zip.file(
|
|
33887
|
+
partName,
|
|
33888
|
+
withDiagramPictureSources(await zip.file(partName).async("string"), diagram.layoutSource)
|
|
33889
|
+
);
|
|
33890
|
+
const relsName = relationshipsPartFor2(partName);
|
|
33891
|
+
const rels = diagramPictureRelationships(
|
|
33892
|
+
partName,
|
|
33893
|
+
diagram.layoutSource,
|
|
33894
|
+
await zip.file(relsName)?.async("string")
|
|
33895
|
+
);
|
|
33896
|
+
if (rels) zip.file(relsName, rels);
|
|
33897
|
+
}
|
|
33245
33898
|
if (drawing) await dropDrawingPart(zip, drawing.relId, drawing.partName, drawing.ownerPart);
|
|
33246
33899
|
}
|
|
33247
33900
|
}
|
|
@@ -33254,9 +33907,9 @@ var EMU_PER_PIXEL2 = 9525;
|
|
|
33254
33907
|
function isSameDiagram(base, next) {
|
|
33255
33908
|
return Boolean(base?.parts.data?.partName) && base?.parts.data?.partName === next.parts.data?.partName && !next.inserted;
|
|
33256
33909
|
}
|
|
33257
|
-
function el3(doc, ns, qualified,
|
|
33910
|
+
function el3(doc, ns, qualified, attrs3 = {}) {
|
|
33258
33911
|
const node = makeNS(doc, ns, qualified);
|
|
33259
|
-
for (const [name, value] of Object.entries(
|
|
33912
|
+
for (const [name, value] of Object.entries(attrs3)) node.setAttribute(name, value);
|
|
33260
33913
|
return node;
|
|
33261
33914
|
}
|
|
33262
33915
|
function buildInsertedDiagramDrawing(doc, diagram, widthPx, heightPx, allocator) {
|
|
@@ -33406,6 +34059,9 @@ function buildInlineDrawing(doc, image, relId, docPrId, svgRelId) {
|
|
|
33406
34059
|
stretch.appendChild(el4(doc, A_NS7, "a:fillRect"));
|
|
33407
34060
|
const blipFill = el4(doc, PIC_NS, "pic:blipFill");
|
|
33408
34061
|
appendAll(blipFill, blip, stretch);
|
|
34062
|
+
if (image.pictureFill?.crop) applyPictureCrop(blipFill, image.pictureFill.crop);
|
|
34063
|
+
if (image.pictureFill?.effects) applyPictureEffects(blip, image.pictureFill.effects);
|
|
34064
|
+
if (image.pictureFill?.layout) applyPictureLayout(blipFill, image.pictureFill.layout);
|
|
33409
34065
|
const xfrm = el4(doc, A_NS7, "a:xfrm");
|
|
33410
34066
|
const off = el4(doc, A_NS7, "a:off");
|
|
33411
34067
|
off.setAttribute("x", "0");
|
|
@@ -33492,6 +34148,16 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
33492
34148
|
return node;
|
|
33493
34149
|
}
|
|
33494
34150
|
if (base && oldDrawing && sameUnderlyingImage(base, image)) {
|
|
34151
|
+
if (image.pictureFill && JSON.stringify(image.pictureFill) !== JSON.stringify(base.pictureFill)) {
|
|
34152
|
+
const fill = oldDrawing.getElementsByTagNameNS(PIC_NS, "blipFill")[0];
|
|
34153
|
+
const blip = fill?.getElementsByTagNameNS(A_NS7, "blip")[0];
|
|
34154
|
+
if (fill && image.pictureFill.crop !== void 0)
|
|
34155
|
+
applyPictureCrop(fill, image.pictureFill.crop);
|
|
34156
|
+
if (blip && image.pictureFill.effects !== void 0)
|
|
34157
|
+
applyPictureEffects(blip, image.pictureFill.effects);
|
|
34158
|
+
if (fill && image.pictureFill.layout !== void 0)
|
|
34159
|
+
applyPictureLayout(fill, image.pictureFill.layout);
|
|
34160
|
+
}
|
|
33495
34161
|
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
33496
34162
|
updateExtent(oldDrawing, image.widthPx, image.heightPx);
|
|
33497
34163
|
if (image.altText !== base.altText || image.title !== base.title)
|
|
@@ -37580,6 +38246,7 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
|
|
|
37580
38246
|
const colorsXml = await read("colors");
|
|
37581
38247
|
const quickStyleXml = await read("quickStyle");
|
|
37582
38248
|
const source2 = {
|
|
38249
|
+
...diagram.layoutSource,
|
|
37583
38250
|
...layoutXml3 ? { layoutXml: layoutXml3 } : {},
|
|
37584
38251
|
...colorsXml ? { colorsXml } : {},
|
|
37585
38252
|
...quickStyleXml ? { quickStyleXml } : {}
|
|
@@ -37604,6 +38271,8 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
|
|
|
37604
38271
|
);
|
|
37605
38272
|
zip.file(name, withDiagramDrawingRelationship(cache.dataXml, relationship2));
|
|
37606
38273
|
zip.file(drawingName, cache.drawingXml);
|
|
38274
|
+
const pictureRels = diagramPictureRelationships(drawingName, diagram.layoutSource);
|
|
38275
|
+
if (pictureRels) zip.file(drawingName.replace(/([^/]+)$/, "_rels/$1.rels"), pictureRels);
|
|
37607
38276
|
await ensureContentTypeOverride(zip, drawingName, DIAGRAM_CONTENT_TYPES.drawing);
|
|
37608
38277
|
}
|
|
37609
38278
|
}
|
|
@@ -39003,7 +39672,8 @@ async function readPackage(input) {
|
|
|
39003
39672
|
for (const part of [
|
|
39004
39673
|
run2.image?.partName,
|
|
39005
39674
|
run2.image?.svgPartName,
|
|
39006
|
-
...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {})
|
|
39675
|
+
...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {}),
|
|
39676
|
+
...Object.values(run2.image?.diagram?.layoutSource?.pictureParts ?? {})
|
|
39007
39677
|
])
|
|
39008
39678
|
if (part) imagePartNames.add(part);
|
|
39009
39679
|
});
|