@web-ppt/edit-core 0.5.0-beta.1 → 0.5.0-beta.7
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/CHANGELOG.md +188 -0
- package/README.md +165 -22
- package/dist/alt-text.d.ts +5 -0
- package/dist/appearance/index.d.ts +12 -0
- package/dist/appearance/materialize.d.ts +4 -0
- package/dist/appearance/types.d.ts +26 -0
- package/dist/appearance/values.d.ts +9 -0
- package/dist/appearance.js +301 -0
- package/dist/cfb/index.d.ts +5 -0
- package/dist/cfb/read.d.ts +16 -0
- package/dist/cfb/write.d.ts +3 -0
- package/dist/cfb.js +208 -0
- package/dist/change-classification.d.ts +3 -3
- package/dist/chart/category-binding.d.ts +4 -0
- package/dist/chart/category-commands.d.ts +23 -0
- package/dist/chart/category-levels.d.ts +14 -0
- package/dist/chart/category-matrix.d.ts +2 -0
- package/dist/chart/category-value.d.ts +2 -0
- package/dist/chart/category-workbook.d.ts +13 -0
- package/dist/chart/commands.d.ts +28 -0
- package/dist/chart/context.d.ts +12 -0
- package/dist/chart/dataset-merge.d.ts +5 -0
- package/dist/chart/formula.d.ts +13 -0
- package/dist/chart/identity-frames.d.ts +4 -0
- package/dist/chart/identity-scopes.d.ts +6 -0
- package/dist/chart/identity.d.ts +24 -0
- package/dist/chart/index.d.ts +8 -0
- package/dist/chart/limits.d.ts +6 -0
- package/dist/chart/locator.d.ts +4 -0
- package/dist/chart/materialize.d.ts +7 -0
- package/dist/chart/ordering.d.ts +9 -0
- package/dist/chart/part-graph.d.ts +5 -0
- package/dist/chart/patch-validation.d.ts +3 -0
- package/dist/chart/plot-kinds.d.ts +2 -0
- package/dist/chart/projection.d.ts +8 -0
- package/dist/chart/save.d.ts +4 -0
- package/dist/chart/shared-added-plan.d.ts +19 -0
- package/dist/chart/shared-added-records.d.ts +8 -0
- package/dist/chart/shared-address.d.ts +5 -0
- package/dist/chart/shared-allocate.d.ts +7 -0
- package/dist/chart/shared-cache-codec.d.ts +5 -0
- package/dist/chart/shared-cache-identities.d.ts +3 -0
- package/dist/chart/shared-cache-migration.d.ts +7 -0
- package/dist/chart/shared-cache-save.d.ts +3 -0
- package/dist/chart/shared-cache-scopes.d.ts +13 -0
- package/dist/chart/shared-cache.d.ts +11 -0
- package/dist/chart/shared-category.d.ts +4 -0
- package/dist/chart/shared-cell.d.ts +9 -0
- package/dist/chart/shared-family.d.ts +26 -0
- package/dist/chart/shared-fields.d.ts +18 -0
- package/dist/chart/shared-graph.d.ts +19 -0
- package/dist/chart/shared-growth-space.d.ts +5 -0
- package/dist/chart/shared-inserted-cells.d.ts +14 -0
- package/dist/chart/shared-inserted-command.d.ts +7 -0
- package/dist/chart/shared-inserted-layout.d.ts +16 -0
- package/dist/chart/shared-inserted-project.d.ts +14 -0
- package/dist/chart/shared-inserted-records.d.ts +16 -0
- package/dist/chart/shared-inserted-save.d.ts +6 -0
- package/dist/chart/shared-joint-command.d.ts +9 -0
- package/dist/chart/shared-joint-records.d.ts +9 -0
- package/dist/chart/shared-record-axis.d.ts +25 -0
- package/dist/chart/shared-record-remove.d.ts +13 -0
- package/dist/chart/shared-record-stage.d.ts +2 -0
- package/dist/chart/shared-records.d.ts +2 -0
- package/dist/chart/shared-rows.d.ts +17 -0
- package/dist/chart/shared-runtime.d.ts +19 -0
- package/dist/chart/shared-save-plan.d.ts +4 -0
- package/dist/chart/shared-save.d.ts +3 -0
- package/dist/chart/shared-series.d.ts +6 -0
- package/dist/chart/shared-source-cache.d.ts +4 -0
- package/dist/chart/shared-topology.d.ts +9 -0
- package/dist/chart/shared-unresolved.d.ts +3 -0
- package/dist/chart/shared-validation.d.ts +6 -0
- package/dist/chart/shared-workbook-source.d.ts +6 -0
- package/dist/chart/shared-xy-command.d.ts +7 -0
- package/dist/chart/shared-xy-family.d.ts +16 -0
- package/dist/chart/shared-xy-project.d.ts +6 -0
- package/dist/chart/shared-xy-records.d.ts +23 -0
- package/dist/chart/shared-xy-save.d.ts +5 -0
- package/dist/chart/shared-xy-source.d.ts +39 -0
- package/dist/chart/shared.d.ts +13 -0
- package/dist/chart/source.d.ts +11 -0
- package/dist/chart/types.d.ts +86 -0
- package/dist/chart/validation.d.ts +24 -0
- package/dist/chart/workbook-range.d.ts +16 -0
- package/dist/chart/workbook-read.d.ts +7 -0
- package/dist/chart/workbook-write.d.ts +9 -0
- package/dist/chart/workbook.d.ts +25 -0
- package/dist/chart/xml-data.d.ts +14 -0
- package/dist/chart/xml-namespaces.d.ts +16 -0
- package/dist/chart-design/index.d.ts +10 -0
- package/dist/chart-design/types.d.ts +11 -0
- package/dist/chart-design/xml.d.ts +2 -0
- package/dist/chart-design.js +361 -0
- package/dist/chart-ex/index.d.ts +15 -0
- package/dist/chart-ex/workbook.d.ts +6 -0
- package/dist/chart-ex/xml.d.ts +14 -0
- package/dist/chart-ex.js +457 -0
- package/dist/chart-shared/index.d.ts +12 -0
- package/dist/chart-shared.js +1 -0
- package/dist/chart.js +1 -0
- package/dist/clipboard-links-GuPtqr1z.js +778 -0
- package/dist/clipboard-package.d.ts +4 -0
- package/dist/clipboard-source.d.ts +6 -2
- package/dist/clipboard-trees.d.ts +9 -0
- package/dist/collaboration-identity.d.ts +3 -0
- package/dist/commands/add-slide-identity.d.ts +4 -0
- package/dist/commands/bullet-image-resource.d.ts +11 -0
- package/dist/commands/clear-format.d.ts +4 -0
- package/dist/commands/common-object-slide-patch.d.ts +4 -0
- package/dist/commands/common-object-slide-types.d.ts +68 -0
- package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
- package/dist/commands/direct-format-patches.d.ts +11 -5
- package/dist/commands/distribute-elements.d.ts +4 -0
- package/dist/commands/edit-table-grid.d.ts +10 -0
- package/dist/commands/element-alt-text.d.ts +8 -0
- package/dist/commands/element-arrangement.d.ts +17 -0
- package/dist/commands/element-effects.d.ts +1 -1
- package/dist/commands/element-fill.d.ts +1 -1
- package/dist/commands/element-geometry.d.ts +9 -0
- package/dist/commands/element-hierarchy.d.ts +6 -0
- package/dist/commands/element-image-content.d.ts +2 -2
- package/dist/commands/element-link.d.ts +1 -1
- package/dist/commands/element-name.d.ts +1 -1
- package/dist/commands/element-stroke.d.ts +1 -1
- package/dist/commands/element-table-style.d.ts +5 -0
- package/dist/commands/element-text.d.ts +1 -1
- package/dist/commands/element-transform.d.ts +2 -2
- package/dist/commands/frame-decomposition.d.ts +10 -0
- package/dist/commands/generated-creation-defaults.d.ts +4 -0
- package/dist/commands/geometry-types.d.ts +44 -0
- package/dist/commands/group-types.d.ts +24 -0
- package/dist/commands/group.d.ts +4 -0
- package/dist/commands/hierarchy-record.d.ts +5 -0
- package/dist/commands/image-resource.d.ts +8 -1
- package/dist/commands/insertion-host.d.ts +16 -0
- package/dist/commands/insertion-rect.d.ts +2 -0
- package/dist/commands/layout-property.d.ts +7 -0
- package/dist/commands/master-property.d.ts +5 -0
- package/dist/commands/master-text-style-types.d.ts +27 -0
- package/dist/commands/master-text-style.d.ts +7 -0
- package/dist/commands/paste-resources.d.ts +9 -5
- package/dist/commands/patch-apply.d.ts +3 -0
- package/dist/commands/patch-count.d.ts +1 -0
- package/dist/commands/patch-invalidation.d.ts +4 -0
- package/dist/commands/patch-stage.d.ts +4 -0
- package/dist/commands/patch.d.ts +4 -0
- package/dist/commands/record-clone.d.ts +3 -0
- package/dist/commands/record-override.d.ts +5 -0
- package/dist/commands/replace-image.d.ts +6 -1
- package/dist/commands/sections.d.ts +10 -0
- package/dist/commands/set-geometry.d.ts +4 -0
- package/dist/commands/set-preset.d.ts +5 -0
- package/dist/commands/set-table-style.d.ts +3 -0
- package/dist/commands/slide-property-types.d.ts +55 -5
- package/dist/commands/slide-size.d.ts +7 -0
- package/dist/commands/spid.d.ts +2 -1
- package/dist/commands/table-grid-patch.d.ts +12 -0
- package/dist/commands/table-style-types.d.ts +28 -0
- package/dist/commands/text-target.d.ts +3 -2
- package/dist/commands/theme-types.d.ts +47 -0
- package/dist/commands/theme.d.ts +9 -0
- package/dist/commands/types.d.ts +219 -17
- package/dist/commands/ungroup-source.d.ts +3 -0
- package/dist/commands/ungroup.d.ts +4 -0
- package/dist/comments/index.d.ts +35 -0
- package/dist/comments/save.d.ts +3 -0
- package/dist/comments/state.d.ts +10 -0
- package/dist/comments/xml.d.ts +12 -0
- package/dist/comments.js +782 -0
- package/dist/common-object-slide-types.d.ts +34 -0
- package/dist/custom-geometry-path.d.ts +3 -0
- package/dist/custom-geometry.d.ts +12 -0
- package/dist/data-validation.d.ts +1 -1
- package/dist/describe/budget.d.ts +3 -0
- package/dist/describe/index.d.ts +5 -0
- package/dist/describe/read.d.ts +4 -0
- package/dist/describe/types.d.ts +103 -0
- package/dist/describe.js +192 -0
- package/dist/design-dependencies.d.ts +8 -0
- package/dist/design-projection-package.d.ts +10 -0
- package/dist/design-target.d.ts +10 -0
- package/dist/design.d.ts +3 -0
- package/dist/document-extensions.d.ts +9 -0
- package/dist/document.d.ts +1 -1
- package/dist/dynamic-projection.d.ts +6 -0
- package/dist/edit-core.js +5680 -3413
- package/dist/editor.d.ts +19 -2
- package/dist/element-source.d.ts +11 -0
- package/dist/element-spids.d.ts +4 -0
- package/dist/extension-address-journal.d.ts +9 -0
- package/dist/extension-address-remap.d.ts +14 -0
- package/dist/extension-addresses.d.ts +20 -0
- package/dist/extension-copy-history.d.ts +7 -0
- package/dist/extension-copy.d.ts +16 -0
- package/dist/extension-migration-receipt.d.ts +34 -0
- package/dist/extension-recovery-context.d.ts +5 -0
- package/dist/extension-runtime.d.ts +64 -0
- package/dist/generate/comments.d.ts +3 -0
- package/dist/generate/compatibility-parts.d.ts +14 -0
- package/dist/generate/compatibility-references.d.ts +3 -0
- package/dist/generate/compatibility.d.ts +4 -0
- package/dist/generate/custom-geometry.d.ts +2 -0
- package/dist/generate/index.d.ts +13 -0
- package/dist/generate/links.d.ts +3 -0
- package/dist/generate/master-defaults.d.ts +4 -0
- package/dist/generate/materialize.d.ts +2 -0
- package/dist/generate/math.d.ts +3 -0
- package/dist/generate/media.d.ts +13 -0
- package/dist/generate/portable-clipboard.d.ts +4 -0
- package/dist/generate/projection-tree.d.ts +8 -0
- package/dist/generate/table.d.ts +4 -0
- package/dist/generate/template.d.ts +70 -0
- package/dist/generate/text-body.d.ts +2 -0
- package/dist/generate/text-effects.d.ts +5 -0
- package/dist/generate/text-override.d.ts +8 -0
- package/dist/generate/validation.d.ts +3 -0
- package/dist/generate/warp.d.ts +2 -0
- package/dist/generate.js +1464 -0
- package/dist/history.d.ts +11 -1
- package/dist/hyperlink.d.ts +2 -0
- package/dist/identities.d.ts +4 -0
- package/dist/identity-allocation.d.ts +12 -0
- package/dist/identity-watermark.d.ts +4 -0
- package/dist/image-content.d.ts +5 -2
- package/dist/image-resource-history.d.ts +2 -0
- package/dist/index-C2r7c6G6.js +714 -0
- package/dist/index-CYDvbiwF.js +1 -0
- package/dist/index.d.ts +43 -7
- package/dist/ink/index.d.ts +27 -0
- package/dist/ink/model.d.ts +4 -0
- package/dist/ink/save.d.ts +3 -0
- package/dist/ink/source.d.ts +7 -0
- package/dist/ink.js +324 -0
- package/dist/layout-assets.d.ts +3 -1
- package/dist/layout-projection.d.ts +19 -5
- package/dist/layout-state.d.ts +2 -0
- package/dist/layout-types.d.ts +42 -0
- package/dist/layout.d.ts +5 -0
- package/dist/lint/color.d.ts +5 -0
- package/dist/lint/index.d.ts +7 -0
- package/dist/lint/prompts.d.ts +3 -0
- package/dist/lint/report.d.ts +21 -0
- package/dist/lint/sampler-batch.d.ts +4 -0
- package/dist/lint/sampler-images.d.ts +2 -0
- package/dist/lint/sampler.d.ts +9 -0
- package/dist/lint/snapshot.d.ts +34 -0
- package/dist/lint/types.d.ts +67 -0
- package/dist/lint-sampler.js +187 -0
- package/dist/lint.js +659 -0
- package/dist/master-state.d.ts +3 -0
- package/dist/master-text-style-state.d.ts +3 -0
- package/dist/master-types.d.ts +55 -0
- package/dist/master.d.ts +5 -0
- package/dist/media/audio-icon.d.ts +2 -0
- package/dist/media/commands.d.ts +3 -0
- package/dist/media/index.d.ts +10 -0
- package/dist/media/markup.d.ts +10 -0
- package/dist/media/mp4-boxes.d.ts +12 -0
- package/dist/media/mp4-fragments.d.ts +8 -0
- package/dist/media/mp4-samples.d.ts +4 -0
- package/dist/media/mp4.d.ts +2 -0
- package/dist/media/poster.d.ts +2 -0
- package/dist/media/replace-poster.d.ts +3 -0
- package/dist/media/resource.d.ts +4 -0
- package/dist/media/source.d.ts +14 -0
- package/dist/media/types.d.ts +33 -0
- package/dist/media-properties.d.ts +4 -0
- package/dist/media.js +1630 -0
- package/dist/model-invariants-BM19JVxy.js +8980 -0
- package/dist/object-source.d.ts +11 -0
- package/dist/ole/container.d.ts +14 -0
- package/dist/ole/content.d.ts +94 -0
- package/dist/ole/index.d.ts +20 -0
- package/dist/ole/preview.d.ts +3 -0
- package/dist/ole/save.d.ts +2 -0
- package/dist/ole/state.d.ts +16 -0
- package/dist/ole.js +870 -0
- package/dist/opc/patch.d.ts +2 -0
- package/dist/opc.js +1 -1
- package/dist/paragraph-level.d.ts +11 -0
- package/dist/paragraph-property-schema.d.ts +5 -2
- package/dist/{patch-DO8497wO.js → patch-BwhfBbYE.js} +112 -95
- package/dist/patch-change.d.ts +4 -0
- package/dist/patch-events.d.ts +16 -0
- package/dist/ppt/appearance.d.ts +11 -0
- package/dist/ppt/binary.d.ts +20 -0
- package/dist/ppt/drawing.d.ts +18 -0
- package/dist/ppt/geometry.d.ts +4 -0
- package/dist/ppt/index.d.ts +12 -0
- package/dist/ppt/pictures.d.ts +11 -0
- package/dist/ppt/text.d.ts +9 -0
- package/dist/ppt.js +774 -0
- package/dist/preset-geometry.d.ts +6 -0
- package/dist/projection.d.ts +2 -0
- package/dist/query-BHLjWjnu.js +903 -0
- package/dist/recovery-identity.d.ts +3 -1
- package/dist/recovery-migrations.d.ts +3 -0
- package/dist/recovery.d.ts +3 -0
- package/dist/resize/index.d.ts +6 -0
- package/dist/resize/text.d.ts +4 -0
- package/dist/resize.js +5090 -0
- package/dist/retained-element-origins.d.ts +6 -0
- package/dist/run-property-fields.d.ts +12 -0
- package/dist/run-property-schema.d.ts +3 -1
- package/dist/run-style.d.ts +15 -0
- package/dist/save/alt-text.d.ts +4 -0
- package/dist/save/comments.d.ts +3 -0
- package/dist/save/effects.d.ts +2 -1
- package/dist/save/extension-availability.d.ts +3 -0
- package/dist/save/extension-elements.d.ts +26 -0
- package/dist/save/geometry.d.ts +5 -0
- package/dist/save/index.d.ts +6 -1
- package/dist/save/insertion.d.ts +7 -3
- package/dist/save/layout-properties.d.ts +4 -0
- package/dist/save/master-properties.d.ts +5 -0
- package/dist/save/notes.d.ts +2 -0
- package/dist/save/paragraph-overrides.d.ts +3 -0
- package/dist/save/run-overrides.d.ts +10 -0
- package/dist/save/shape-format.d.ts +3 -0
- package/dist/save/slide-parts.d.ts +1 -0
- package/dist/save/table-style-part.d.ts +11 -0
- package/dist/save/table.d.ts +5 -0
- package/dist/save/text-source-less.d.ts +6 -0
- package/dist/save/xfrm.d.ts +8 -2
- package/dist/save.js +502 -1480
- package/dist/sections.d.ts +8 -0
- package/dist/session-assets.d.ts +4 -0
- package/dist/slide-parts-D0o_DDhi.js +1331 -0
- package/dist/slide-size.d.ts +6 -0
- package/dist/smartart/drawing.d.ts +3 -0
- package/dist/smartart/index.d.ts +16 -0
- package/dist/smartart/model.d.ts +18 -0
- package/dist/smartart/save.d.ts +3 -0
- package/dist/smartart.js +604 -0
- package/dist/source-retention.d.ts +7 -0
- package/dist/space.d.ts +37 -0
- package/dist/table-cell.d.ts +7 -1
- package/dist/table-direct-markup.d.ts +7 -1
- package/dist/table-grid-projection.d.ts +6 -0
- package/dist/table-grid.d.ts +45 -0
- package/dist/table-invariants.d.ts +4 -0
- package/dist/table-rows.d.ts +2 -1
- package/dist/table-scale.d.ts +4 -0
- package/dist/table-style.d.ts +21 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/recipes.d.ts +5 -0
- package/dist/templates/types.d.ts +17 -0
- package/dist/templates.js +543 -0
- package/dist/text-flatten.d.ts +6 -0
- package/dist/text-fragment.d.ts +5 -0
- package/dist/text-model.d.ts +8 -8
- package/dist/text-override-validation.d.ts +6 -2
- package/dist/text-selection.d.ts +4 -0
- package/dist/theme-projection.d.ts +8 -0
- package/dist/theme-xml.d.ts +3 -0
- package/dist/theme.d.ts +14 -0
- package/dist/types.d.ts +217 -8
- package/dist/xml/index.d.ts +1 -1
- package/dist/xml/nodes.d.ts +2 -2
- package/dist/xml/shape-ids.d.ts +3 -0
- package/dist/xml.js +19 -16
- package/package.json +77 -5
- package/schemas/describe.schema.json +479 -0
- package/schemas/lint.schema.json +145 -0
- package/dist/index-D4ZTaYOa.js +0 -706
- package/dist/insertion-DabLme_U.js +0 -5471
package/dist/ppt.js
ADDED
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { sourceAsset as mt, toSlide as wt } from "@web-ppt/edit-core";
|
|
2
|
+
import { createCompoundFile as gt } from "@web-ppt/edit-core/cfb";
|
|
3
|
+
const k = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
4
|
+
function d(e) {
|
|
5
|
+
const t = e.reduce((s, i) => s + i.length, 0);
|
|
6
|
+
if (t > 256 * 1024 * 1024) throw new Error("PPT 文件超过浏览器保存大小限制");
|
|
7
|
+
const n = new Uint8Array(t);
|
|
8
|
+
let r = 0;
|
|
9
|
+
for (const s of e)
|
|
10
|
+
n.set(s, r), r += s.length;
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
function m(e) {
|
|
14
|
+
const t = new Uint8Array(2);
|
|
15
|
+
return k(t).setUint16(0, e, !0), t;
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
const t = new Uint8Array(4);
|
|
19
|
+
return k(t).setUint32(0, e, !0), t;
|
|
20
|
+
}
|
|
21
|
+
function W(e, t = !1) {
|
|
22
|
+
if (e.length > 1e6) throw new Error("PPT 文字长度超限");
|
|
23
|
+
const n = new Uint8Array((e.length + Number(t)) * 2), r = k(n);
|
|
24
|
+
for (let s = 0; s < e.length; s++) r.setUint16(s * 2, e.charCodeAt(s), !0);
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
function w(e, t = new Uint8Array(), n = 0, r = 0) {
|
|
28
|
+
if (!Number.isInteger(r) || r < 0 || r > 4095) throw new Error("PPT 记录实例超限");
|
|
29
|
+
const s = new Uint8Array(8), i = k(s);
|
|
30
|
+
return i.setUint16(0, r << 4 | n, !0), i.setUint16(2, e, !0), i.setUint32(4, t.length, !0), d([s, t]);
|
|
31
|
+
}
|
|
32
|
+
function y(e, t, n = 0) {
|
|
33
|
+
return w(e, d(t), 15, n);
|
|
34
|
+
}
|
|
35
|
+
function G(e) {
|
|
36
|
+
const t = [...e].sort((i, c) => i.id - c.id);
|
|
37
|
+
if (new Set(t.map((i) => i.id)).size !== t.length) throw new Error("PPT 形状属性重复");
|
|
38
|
+
const n = new Uint8Array(t.length * 6), r = k(n), s = [];
|
|
39
|
+
return t.forEach((i, c) => {
|
|
40
|
+
const o = i.value instanceof Uint8Array;
|
|
41
|
+
r.setUint16(c * 6, i.id | (o ? 32768 : 0) | (i.blip ? 16384 : 0), !0), r.setUint32(c * 6 + 2, o ? i.value.length : i.value, !0), o && s.push(i.value);
|
|
42
|
+
}), w(61451, d([n, ...s]), 3, t.length);
|
|
43
|
+
}
|
|
44
|
+
function J(e, t) {
|
|
45
|
+
if (!Number.isFinite(e) || e < -2147483648 || e > 2147483647) throw new Error(`PPT ${t} 超出坐标范围`);
|
|
46
|
+
return Math.round(e);
|
|
47
|
+
}
|
|
48
|
+
function Pt(e) {
|
|
49
|
+
const { rgb: t } = X(e);
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
function X(e) {
|
|
53
|
+
e = e.replace(/^#([0-9a-f]{3})$/i, (r, s) => "#" + s.split("").map((i) => i + i).join(""));
|
|
54
|
+
const t = /^#?([0-9a-f]{6})$/i.exec(e);
|
|
55
|
+
if (t) {
|
|
56
|
+
const r = parseInt(t[1], 16);
|
|
57
|
+
return { rgb: (r & 255) << 16 | r & 65280 | r >>> 16 & 255, alpha: 1 };
|
|
58
|
+
}
|
|
59
|
+
const n = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(0(?:\.\d+)?|1(?:\.0+)?))?\s*\)$/i.exec(e);
|
|
60
|
+
if (!n || n.slice(1, 4).some((r) => Number(r) > 255)) throw new Error(`PPT 不支持此颜色:${e}`);
|
|
61
|
+
return { rgb: Number(n[1]) | Number(n[2]) << 8 | Number(n[3]) << 16, alpha: Number(n[4] ?? 1) };
|
|
62
|
+
}
|
|
63
|
+
const bt = [
|
|
64
|
+
{ id: 1, pattern: [4, 3] },
|
|
65
|
+
{ id: 2, pattern: [1, 3] },
|
|
66
|
+
{ id: 3, pattern: [4, 3, 1, 3] },
|
|
67
|
+
{ id: 4, pattern: [4, 3, 1, 3, 1, 3] },
|
|
68
|
+
{ id: 5, pattern: [8, 3] },
|
|
69
|
+
{ id: 6, pattern: [8, 3, 1, 3] },
|
|
70
|
+
{ id: 7, pattern: [8, 3, 1, 3, 1, 3] },
|
|
71
|
+
{ id: 8, pattern: [1, 1] },
|
|
72
|
+
{ id: 9, pattern: [3, 3] },
|
|
73
|
+
{ id: 10, pattern: [3, 3, 1, 3] }
|
|
74
|
+
];
|
|
75
|
+
function xt(e, t) {
|
|
76
|
+
const n = Math.max(t, 1);
|
|
77
|
+
for (const { id: r, pattern: s } of bt) {
|
|
78
|
+
const i = s.map((c) => c * n);
|
|
79
|
+
if (i.length === e.length && i.every((c, o) => Math.abs(c - e[o]) < 0.51)) return r;
|
|
80
|
+
}
|
|
81
|
+
throw new Error("PPT 写入暂不支持自定义虚线");
|
|
82
|
+
}
|
|
83
|
+
function Mt(e) {
|
|
84
|
+
if (!Number.isFinite(e)) throw new Error("PPT 渐变角度无效");
|
|
85
|
+
let t = 90 - e;
|
|
86
|
+
for (; t >= 0; ) t -= 360;
|
|
87
|
+
for (; t < -360; ) t += 360;
|
|
88
|
+
return Math.round(t * 65536) >>> 0;
|
|
89
|
+
}
|
|
90
|
+
function Q(e) {
|
|
91
|
+
if (!e || e.type === "none") return [{ id: 447, value: 1048576 }];
|
|
92
|
+
if (e.type === "solid") {
|
|
93
|
+
const t = X(e.color);
|
|
94
|
+
return [
|
|
95
|
+
{ id: 384, value: 0 },
|
|
96
|
+
{ id: 385, value: t.rgb },
|
|
97
|
+
{ id: 386, value: Math.round(t.alpha * 65536) },
|
|
98
|
+
{ id: 447, value: 1048592 }
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
if (e.type === "gradient") {
|
|
102
|
+
if (e.radial || e.stops.length !== 2 || e.stops[0].pos !== 0 || e.stops[1].pos !== 1)
|
|
103
|
+
throw new Error("PPT 写入暂不支持多色标、非端点色标或径向渐变");
|
|
104
|
+
const t = X(e.stops[0].color), n = X(e.stops[1].color);
|
|
105
|
+
return [
|
|
106
|
+
// 7 = msofillShadeScale,与 LibreOffice 线性渐变导出一致;两端透明度分别是 fillOpacity / fillBackOpacity。
|
|
107
|
+
{ id: 384, value: 7 },
|
|
108
|
+
{ id: 385, value: t.rgb },
|
|
109
|
+
{ id: 387, value: n.rgb },
|
|
110
|
+
{ id: 386, value: Math.round(t.alpha * 65536) },
|
|
111
|
+
{ id: 388, value: Math.round(n.alpha * 65536) },
|
|
112
|
+
{ id: 395, value: Mt(e.angle) },
|
|
113
|
+
{ id: 447, value: 1048592 }
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
throw new Error("PPT 写入暂不支持图案或图片形状填充");
|
|
117
|
+
}
|
|
118
|
+
function Y(e) {
|
|
119
|
+
var r;
|
|
120
|
+
if (!e) return [{ id: 511, value: 524288 }];
|
|
121
|
+
if (e.compound && e.compound !== "sng") throw new Error("PPT 写入暂不支持复合线型");
|
|
122
|
+
if (!Number.isFinite(e.width) || e.width < 0) throw new Error("PPT 线宽无效");
|
|
123
|
+
const t = X(e.color), n = [
|
|
124
|
+
{ id: 448, value: t.rgb },
|
|
125
|
+
{ id: 449, value: Math.round(t.alpha * 65536) },
|
|
126
|
+
{ id: 459, value: Math.round(e.width * 9525) },
|
|
127
|
+
{ id: 511, value: 524296 }
|
|
128
|
+
];
|
|
129
|
+
(r = e.dash) != null && r.length && n.push({ id: 462, value: xt(e.dash, e.width) }), e.cap && n.push({ id: 471, value: { round: 0, square: 1, butt: 2 }[e.cap] }), e.join && n.push({ id: 470, value: { round: 1, bevel: 0, miter: 2 }[e.join] });
|
|
130
|
+
for (const [s, i] of [[e.head, 464], [e.tail, 465]])
|
|
131
|
+
if (s && s.type !== "none") {
|
|
132
|
+
if (s.w !== 3 || s.h !== 3) throw new Error("PPT 写入暂不支持自定义箭头尺寸");
|
|
133
|
+
n.push({ id: i, value: { triangle: 1, stealth: 2, diamond: 3, oval: 4, arrow: 5 }[s.type] });
|
|
134
|
+
}
|
|
135
|
+
return n;
|
|
136
|
+
}
|
|
137
|
+
function Et(e) {
|
|
138
|
+
for (const t of [e.l, e.t, e.r, e.b])
|
|
139
|
+
if (!Number.isFinite(t) || t < 0 || t > 1) throw new Error("PPT 图片裁剪无效");
|
|
140
|
+
if (e.l + e.r >= 1 || e.t + e.b >= 1) throw new Error("PPT 图片裁剪无效");
|
|
141
|
+
return [
|
|
142
|
+
{ id: 256, value: Math.round(e.t * 65536) },
|
|
143
|
+
{ id: 257, value: Math.round(e.b * 65536) },
|
|
144
|
+
{ id: 258, value: Math.round(e.l * 65536) },
|
|
145
|
+
{ id: 259, value: Math.round(e.r * 65536) }
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
const yt = /[A-Za-z]|[-+]?(?:\d*\.?\d+)(?:e[-+]?\d+)?/gi;
|
|
149
|
+
function L(e, t) {
|
|
150
|
+
const n = Math.round(e * 9525);
|
|
151
|
+
if (!Number.isSafeInteger(n)) throw new Error(`自定义几何 ${t} 超出 OOXML 安全整数范围`);
|
|
152
|
+
return String(n);
|
|
153
|
+
}
|
|
154
|
+
function C(e, t, n) {
|
|
155
|
+
const r = Number(e[t]), s = Number(e[t + 1]);
|
|
156
|
+
if (!Number.isFinite(r) || !Number.isFinite(s)) throw new Error(`自定义几何 ${n} 坐标无效`);
|
|
157
|
+
return [r, s];
|
|
158
|
+
}
|
|
159
|
+
const B = ([e, t], n) => `<a:pt x="${L(e, `${n}.x`)}" y="${L(t, `${n}.y`)}"/>`;
|
|
160
|
+
function rt(e, t) {
|
|
161
|
+
const n = Math.round(e * 180 * 6e4 / Math.PI);
|
|
162
|
+
if (!Number.isSafeInteger(n)) throw new Error(`自定义几何 ${t} 角度无效`);
|
|
163
|
+
return String(n);
|
|
164
|
+
}
|
|
165
|
+
function Tt(e, t, n) {
|
|
166
|
+
if (!n) throw new Error("生成保存的自定义圆弧缺少起点");
|
|
167
|
+
let r = Math.abs(Number(e[t])), s = Math.abs(Number(e[t + 1]));
|
|
168
|
+
const i = Number(e[t + 2]), c = Number(e[t + 3]), o = Number(e[t + 4]), l = C(e, t + 5, "A");
|
|
169
|
+
if (![r, s, i, c, o].every(Number.isFinite) || c !== 0 && c !== 1 || o !== 0 && o !== 1)
|
|
170
|
+
throw new Error("自定义几何 A 参数无效");
|
|
171
|
+
if (Math.abs(i) > 1e-9) throw new Error("生成保存不支持旋转椭圆的自定义圆弧");
|
|
172
|
+
if (r === 0 || s === 0)
|
|
173
|
+
return { markup: `<a:lnTo>${B(l, "A")}</a:lnTo>`, target: l };
|
|
174
|
+
const [p, f] = n, [h, u] = l;
|
|
175
|
+
if (p === h && f === u) return { markup: "", target: l };
|
|
176
|
+
const g = (p - h) / 2, P = (f - u) / 2, x = g * g / (r * r) + P * P / (s * s);
|
|
177
|
+
if (x > 1) {
|
|
178
|
+
const z = Math.sqrt(x);
|
|
179
|
+
r *= z, s *= z;
|
|
180
|
+
}
|
|
181
|
+
const T = r * r, b = s * s, E = T * P * P + b * g * g, v = Math.max(0, T * b - E), N = E === 0 ? 0 : (c === o ? -1 : 1) * Math.sqrt(v / E), A = (p + h) / 2 + N * (r * P / s), q = (f + u) / 2 - N * (s * g / r), M = Math.atan2((f - q) / s, (p - A) / r);
|
|
182
|
+
let U = Math.atan2((u - q) / s, (h - A) / r) - M;
|
|
183
|
+
return o === 1 && U < 0 && (U += Math.PI * 2), o === 0 && U > 0 && (U -= Math.PI * 2), {
|
|
184
|
+
markup: `<a:arcTo wR="${L(r, "A.rx")}" hR="${L(s, "A.ry")}" stAng="${rt(M, "A.start")}" swAng="${rt(U, "A.sweep")}"/>`,
|
|
185
|
+
target: l
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function vt(e, t, n, r) {
|
|
189
|
+
const s = e.match(yt) ?? [], i = [];
|
|
190
|
+
let c = 0, o = null, l = null;
|
|
191
|
+
for (; c < s.length; ) {
|
|
192
|
+
const h = s[c++];
|
|
193
|
+
if (h === "Z" || h === "z") {
|
|
194
|
+
i.push("<a:close/>"), o = l;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (h === "M" || h === "L") {
|
|
198
|
+
const u = C(s, c, h);
|
|
199
|
+
c += 2;
|
|
200
|
+
const g = h === "M" ? "moveTo" : "lnTo";
|
|
201
|
+
i.push(`<a:${g}>${B(u, h)}</a:${g}>`), o = u, h === "M" && (l = u);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (h === "C") {
|
|
205
|
+
const u = [
|
|
206
|
+
C(s, c, "C1"),
|
|
207
|
+
C(s, c + 2, "C2"),
|
|
208
|
+
C(s, c + 4, "C3")
|
|
209
|
+
];
|
|
210
|
+
c += 6, i.push(`<a:cubicBezTo>${u.map((g, P) => B(g, `C${P + 1}`)).join("")}</a:cubicBezTo>`), o = u[2];
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (h === "Q") {
|
|
214
|
+
const u = [C(s, c, "Q1"), C(s, c + 2, "Q2")];
|
|
215
|
+
c += 4, i.push(`<a:quadBezTo>${u.map((g, P) => B(g, `Q${P + 1}`)).join("")}</a:quadBezTo>`), o = u[1];
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (h === "A") {
|
|
219
|
+
const u = Tt(s, c, o);
|
|
220
|
+
c += 7, u.markup && i.push(u.markup), o = u.target;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
throw new Error(`生成保存不支持自定义路径命令:${h}`);
|
|
224
|
+
}
|
|
225
|
+
if (!i.length) throw new Error("生成保存的自定义路径为空");
|
|
226
|
+
const p = L(t, "width"), f = L(n, "height");
|
|
227
|
+
return `<a:custGeom><a:avLst/><a:gdLst/><a:ahLst/><a:cxnLst/><a:rect l="0" t="0" r="r" b="b"/>
|
|
228
|
+
<a:pathLst><a:path w="${p}" h="${f}" fill="${r ? "none" : "norm"}" stroke="1">${i.join("")}</a:path></a:pathLst></a:custGeom>`;
|
|
229
|
+
}
|
|
230
|
+
const I = /* @__PURE__ */ new WeakMap(), Nt = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), lt = "http://www.w3.org/XML/1998/namespace", $t = "http://www.w3.org/2000/xmlns/", St = /^[A-Za-z_][A-Za-z0-9_.-]*$/, Ut = /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{N}\p{M}\p{Pc}_.\-\u00B7\u203F-\u2040]*$/u, Z = (e) => St.test(e) || Ut.test(e);
|
|
231
|
+
function nt(e) {
|
|
232
|
+
const t = e.indexOf(":");
|
|
233
|
+
return t < 0 ? Z(e) : t === e.lastIndexOf(":") && Z(e.slice(0, t)) && Z(e.slice(t + 1));
|
|
234
|
+
}
|
|
235
|
+
const K = (e) => {
|
|
236
|
+
const t = e.indexOf(":");
|
|
237
|
+
return t < 0 ? { prefix: null, localName: e } : { prefix: e.slice(0, t), localName: e.slice(t + 1) };
|
|
238
|
+
};
|
|
239
|
+
function st(e, t, n) {
|
|
240
|
+
const r = K(e);
|
|
241
|
+
return n && (e === "xmlns" || r.prefix === "xmlns") ? $t : r.prefix === "xml" ? lt : r.prefix ? t.get(r.prefix) || null : n ? null : t.get("") || null;
|
|
242
|
+
}
|
|
243
|
+
const It = /* @__PURE__ */ new WeakMap(), Ct = {
|
|
244
|
+
amp: "&",
|
|
245
|
+
lt: "<",
|
|
246
|
+
gt: ">",
|
|
247
|
+
quot: '"',
|
|
248
|
+
apos: "'"
|
|
249
|
+
}, j = (e) => e === " " || e === " " || e === "\r" || e === `
|
|
250
|
+
`, it = (e) => j(e) || e === "=" || e === "/" || e === ">";
|
|
251
|
+
function Ot(e) {
|
|
252
|
+
let t = e.length - 2;
|
|
253
|
+
for (; j(e[t]); ) t--;
|
|
254
|
+
return e[t] === "/";
|
|
255
|
+
}
|
|
256
|
+
function D(e) {
|
|
257
|
+
return e.includes("&") ? e.replace(/&(#x[0-9a-f]+|#[0-9]+|[A-Za-z][\w.-]*);/gi, (t, n) => {
|
|
258
|
+
if (n[0] !== "#") return Ct[n] ?? t;
|
|
259
|
+
const r = n[1].toLowerCase() === "x", s = Number.parseInt(n.slice(r ? 2 : 1), r ? 16 : 10);
|
|
260
|
+
return Number.isFinite(s) && s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : t;
|
|
261
|
+
}) : e;
|
|
262
|
+
}
|
|
263
|
+
function Ft(e) {
|
|
264
|
+
let t = "utf-8", n = !1, r = 0;
|
|
265
|
+
return e[0] === 239 && e[1] === 187 && e[2] === 191 ? (n = !0, r = 3) : e[0] === 255 && e[1] === 254 ? (t = "utf-16le", n = !0, r = 2) : e[0] === 254 && e[1] === 255 ? (t = "utf-16be", n = !0, r = 2) : e[0] === 60 && e[1] === 0 ? t = "utf-16le" : e[0] === 0 && e[1] === 60 && (t = "utf-16be"), { text: new TextDecoder(t, { fatal: !0 }).decode(e.subarray(r)), encoding: t, bom: n };
|
|
266
|
+
}
|
|
267
|
+
class ot {
|
|
268
|
+
constructor(t) {
|
|
269
|
+
this.source = t, this.offset = 0;
|
|
270
|
+
}
|
|
271
|
+
parse() {
|
|
272
|
+
const t = [], n = { type: "document", children: t, root: null };
|
|
273
|
+
let r = null;
|
|
274
|
+
for (; this.offset < this.source.length; ) {
|
|
275
|
+
const s = this.source[this.offset] === "<" ? this.parseMarkup(n, /* @__PURE__ */ new Map()) : this.parseText(n);
|
|
276
|
+
t.push(s), s.type === "element" ? (r && this.fail("XML 只能有一个根元素"), r = s) : s.type === "text" && s.value.replace(/^\uFEFF/, "").trim() && this.fail("根元素外不能出现文本");
|
|
277
|
+
}
|
|
278
|
+
return r || this.fail("未找到根元素"), Object.defineProperty(n, "root", { value: r, enumerable: !0 }), I.set(n, { raw: this.source, parent: null, dirty: !1 }), n;
|
|
279
|
+
}
|
|
280
|
+
parseText(t) {
|
|
281
|
+
const n = this.offset, r = this.source.indexOf("<", n);
|
|
282
|
+
this.offset = r < 0 ? this.source.length : r;
|
|
283
|
+
const s = this.source.slice(n, this.offset), i = { type: "text", value: D(s) };
|
|
284
|
+
return I.set(i, { raw: s, parent: t, dirty: !1 }), i;
|
|
285
|
+
}
|
|
286
|
+
parseMarkup(t, n) {
|
|
287
|
+
const r = this.offset;
|
|
288
|
+
if (this.source.startsWith("<!--", r)) {
|
|
289
|
+
const s = this.source.indexOf("-->", r + 4);
|
|
290
|
+
s < 0 && this.fail("注释未闭合"), this.offset = s + 3;
|
|
291
|
+
const i = this.source.slice(r, this.offset), c = { type: "comment", value: i.slice(4, -3) };
|
|
292
|
+
return I.set(c, { raw: i, parent: t, dirty: !1 }), c;
|
|
293
|
+
}
|
|
294
|
+
if (this.source.startsWith("<![CDATA[", r)) {
|
|
295
|
+
const s = this.source.indexOf("]]>", r + 9);
|
|
296
|
+
s < 0 && this.fail("CDATA 未闭合"), this.offset = s + 3;
|
|
297
|
+
const i = this.source.slice(r, this.offset), c = { type: "cdata", value: i.slice(9, -3) };
|
|
298
|
+
return I.set(c, { raw: i, parent: t, dirty: !1 }), c;
|
|
299
|
+
}
|
|
300
|
+
return this.source.startsWith("<?", r) ? this.parseInstruction(t) : this.source.startsWith("<!", r) ? this.parseDeclaration(t) : (this.source.startsWith("</", r) && this.fail("遇到意外的闭合标签"), this.parseElement(t, n));
|
|
301
|
+
}
|
|
302
|
+
parseInstruction(t) {
|
|
303
|
+
const n = this.offset, r = this.source.indexOf("?>", n + 2);
|
|
304
|
+
r < 0 && this.fail("处理指令未闭合"), this.offset = r + 2;
|
|
305
|
+
const s = this.source.slice(n, this.offset), i = s.slice(2, -2), c = i.search(/\s/), o = {
|
|
306
|
+
type: "processing-instruction",
|
|
307
|
+
target: c < 0 ? i : i.slice(0, c),
|
|
308
|
+
value: c < 0 ? "" : i.slice(c).trimStart()
|
|
309
|
+
};
|
|
310
|
+
return I.set(o, { raw: s, parent: t, dirty: !1 }), o;
|
|
311
|
+
}
|
|
312
|
+
parseDeclaration(t) {
|
|
313
|
+
const n = this.offset;
|
|
314
|
+
let r = "", s = 0;
|
|
315
|
+
for (this.offset += 2; this.offset < this.source.length; ) {
|
|
316
|
+
const o = this.source[this.offset++];
|
|
317
|
+
if (r)
|
|
318
|
+
o === r && (r = "");
|
|
319
|
+
else if (o === '"' || o === "'") r = o;
|
|
320
|
+
else if (o === "[") s++;
|
|
321
|
+
else if (o === "]") s = Math.max(0, s - 1);
|
|
322
|
+
else if (o === ">" && s === 0) break;
|
|
323
|
+
}
|
|
324
|
+
this.source[this.offset - 1] !== ">" && this.fail("声明未闭合");
|
|
325
|
+
const i = this.source.slice(n, this.offset), c = { type: "declaration", value: i.slice(2, -1) };
|
|
326
|
+
return I.set(c, { raw: i, parent: t, dirty: !1 }), c;
|
|
327
|
+
}
|
|
328
|
+
parseElement(t, n) {
|
|
329
|
+
const r = this.offset, s = this.scanOpenEnd(r), i = this.source.slice(r, s + 1), c = this.scanNameEnd(r + 1, s), o = this.source.slice(r + 1, c);
|
|
330
|
+
nt(o) || this.fail(`非法元素名 ${o || "(空)"}`);
|
|
331
|
+
const l = this.parseAttributes(i, o.length + 1), p = new Map(n);
|
|
332
|
+
p.set("xml", lt);
|
|
333
|
+
for (const b of l)
|
|
334
|
+
b.name === "xmlns" ? p.set("", D(b.value)) : b.name.startsWith("xmlns:") && p.set(b.name.slice(6), D(b.value));
|
|
335
|
+
const f = l.map((b) => {
|
|
336
|
+
const E = K(b.name), v = {
|
|
337
|
+
name: b.name,
|
|
338
|
+
prefix: E.prefix,
|
|
339
|
+
localName: E.localName,
|
|
340
|
+
namespaceUri: st(b.name, p, !0),
|
|
341
|
+
value: D(b.value),
|
|
342
|
+
quote: b.quote
|
|
343
|
+
};
|
|
344
|
+
return At.set(v, b.state), v;
|
|
345
|
+
}), h = K(o), u = Ot(i), g = [], P = {
|
|
346
|
+
type: "element",
|
|
347
|
+
name: o,
|
|
348
|
+
prefix: h.prefix,
|
|
349
|
+
localName: h.localName,
|
|
350
|
+
namespaceUri: st(o, p, !1),
|
|
351
|
+
attributes: f,
|
|
352
|
+
children: g,
|
|
353
|
+
selfClosing: u
|
|
354
|
+
};
|
|
355
|
+
this.offset = s + 1;
|
|
356
|
+
let x = "";
|
|
357
|
+
if (!u) {
|
|
358
|
+
for (; this.offset < this.source.length && !this.source.startsWith("</", this.offset); ) {
|
|
359
|
+
const $ = this.source[this.offset] === "<" ? this.parseMarkup(P, p) : this.parseText(P);
|
|
360
|
+
g.push($);
|
|
361
|
+
}
|
|
362
|
+
this.source.startsWith("</", this.offset) || this.fail(`元素 <${o}> 未闭合`);
|
|
363
|
+
const b = this.offset, E = this.source.indexOf(">", b + 2);
|
|
364
|
+
E < 0 && this.fail(`元素 <${o}> 未闭合`);
|
|
365
|
+
const v = this.source.slice(b + 2, E).trim();
|
|
366
|
+
v !== o && this.fail(`闭合标签 </${v}> 与 <${o}> 不匹配`), this.offset = E + 1, x = this.source.slice(b, this.offset);
|
|
367
|
+
}
|
|
368
|
+
const T = {
|
|
369
|
+
raw: this.source.slice(r, this.offset),
|
|
370
|
+
parent: t,
|
|
371
|
+
dirty: !1,
|
|
372
|
+
openRaw: i,
|
|
373
|
+
closeRaw: x,
|
|
374
|
+
sourceSelfClosing: u,
|
|
375
|
+
// 源属性表必须与公开的当前属性表分离;删除/新增只改当前表,序列化仍靠源表定位原始字节。
|
|
376
|
+
sourceAttributes: [...f],
|
|
377
|
+
namespaces: p
|
|
378
|
+
};
|
|
379
|
+
return I.set(P, T), Nt.set(P, T), P;
|
|
380
|
+
}
|
|
381
|
+
scanOpenEnd(t) {
|
|
382
|
+
let n = "";
|
|
383
|
+
for (let r = t + 1; r < this.source.length; r++) {
|
|
384
|
+
const s = this.source[r];
|
|
385
|
+
if (n)
|
|
386
|
+
s === n && (n = "");
|
|
387
|
+
else if (s === '"' || s === "'") n = s;
|
|
388
|
+
else if (s === ">") return r;
|
|
389
|
+
}
|
|
390
|
+
this.fail("开始标签未闭合");
|
|
391
|
+
}
|
|
392
|
+
scanNameEnd(t, n) {
|
|
393
|
+
let r = t;
|
|
394
|
+
for (; r < n && !it(this.source[r]); ) r++;
|
|
395
|
+
return r;
|
|
396
|
+
}
|
|
397
|
+
parseAttributes(t, n) {
|
|
398
|
+
const r = [], s = /* @__PURE__ */ new Set();
|
|
399
|
+
let i = n;
|
|
400
|
+
for (; i < t.length - 1; ) {
|
|
401
|
+
const c = i;
|
|
402
|
+
for (; j(t[i]); ) i++;
|
|
403
|
+
if (t[i] === "/" || t[i] === ">" || i >= t.length - 1) break;
|
|
404
|
+
i === c && this.fail("属性前缺少空白");
|
|
405
|
+
const o = i;
|
|
406
|
+
for (; i < t.length && !it(t[i]); ) i++;
|
|
407
|
+
const l = t.slice(o, i);
|
|
408
|
+
for (nt(l) || this.fail(`非法属性名 ${l || "(空)"}`), s.has(l) && this.fail(`属性 ${l} 重复`), s.add(l); j(t[i]); ) i++;
|
|
409
|
+
for (t[i++] !== "=" && this.fail(`属性 ${l} 缺少等号`); j(t[i]); ) i++;
|
|
410
|
+
const p = t[i++];
|
|
411
|
+
p !== '"' && p !== "'" && this.fail(`属性 ${l} 必须使用引号`);
|
|
412
|
+
const f = i, h = t.indexOf(p, f);
|
|
413
|
+
h < 0 && this.fail(`属性 ${l} 未闭合`), i = h + 1, r.push({
|
|
414
|
+
name: l,
|
|
415
|
+
value: t.slice(f, h),
|
|
416
|
+
quote: p,
|
|
417
|
+
state: {
|
|
418
|
+
source: !0,
|
|
419
|
+
present: !0,
|
|
420
|
+
changed: !1,
|
|
421
|
+
start: c,
|
|
422
|
+
nameStart: o,
|
|
423
|
+
valueStart: f,
|
|
424
|
+
valueEnd: h,
|
|
425
|
+
end: i
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return r;
|
|
430
|
+
}
|
|
431
|
+
fail(t) {
|
|
432
|
+
throw new Error(`XML 解析失败(偏移 ${this.offset}):${t}`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function Xt(e) {
|
|
436
|
+
if (typeof e == "string") return new ot(e).parse();
|
|
437
|
+
const t = Ft(e), n = new ot(t.text).parse();
|
|
438
|
+
return It.set(n, { encoding: t.encoding, bom: t.bom, source: e }), n;
|
|
439
|
+
}
|
|
440
|
+
const et = (e, t) => e.localName === t.localName && (!Object.prototype.hasOwnProperty.call(t, "namespaceUri") || e.namespaceUri === t.namespaceUri);
|
|
441
|
+
function R(e, t) {
|
|
442
|
+
const n = e.children.filter((r) => r.type === "element");
|
|
443
|
+
return t ? n.filter((r) => et(r, t)) : n;
|
|
444
|
+
}
|
|
445
|
+
function ft(e, t) {
|
|
446
|
+
for (const n of R(e)) {
|
|
447
|
+
if (et(n, t)) return n;
|
|
448
|
+
const r = ft(n, t);
|
|
449
|
+
if (r) return r;
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
function Lt(e, t) {
|
|
454
|
+
return e.attributes.find((n) => et(n, t)) ?? null;
|
|
455
|
+
}
|
|
456
|
+
const F = (e, t) => {
|
|
457
|
+
var n;
|
|
458
|
+
return Number(((n = Lt(e, { localName: t })) == null ? void 0 : n.value) ?? 0);
|
|
459
|
+
}, kt = (e) => [F(e, "x") / 9525, F(e, "y") / 9525];
|
|
460
|
+
function zt(e) {
|
|
461
|
+
if (e.path === null) return [];
|
|
462
|
+
const t = Xt(vt(e.path, e.w, e.h, !!e.openGeom)), n = ft(t.root, { localName: "path" });
|
|
463
|
+
if (!n) throw new Error("PPT 几何没有路径");
|
|
464
|
+
const r = [], s = [];
|
|
465
|
+
let i = [0, 0], c = [0, 0];
|
|
466
|
+
const o = (f, h, u) => {
|
|
467
|
+
s.push(8193), r.push(f, h, u), i = u;
|
|
468
|
+
};
|
|
469
|
+
for (const f of R(n)) {
|
|
470
|
+
const h = R(f).map(kt);
|
|
471
|
+
if (f.localName === "moveTo")
|
|
472
|
+
s.push(16384), r.push(h[0]), i = h[0], c = i;
|
|
473
|
+
else if (f.localName === "lnTo")
|
|
474
|
+
s.push(1), r.push(h[0]), i = h[0];
|
|
475
|
+
else if (f.localName === "cubicBezTo") o(h[0], h[1], h[2]);
|
|
476
|
+
else if (f.localName === "quadBezTo") {
|
|
477
|
+
const [u, g] = h;
|
|
478
|
+
o([i[0] + 2 * (u[0] - i[0]) / 3, i[1] + 2 * (u[1] - i[1]) / 3], [g[0] + 2 * (u[0] - g[0]) / 3, g[1] + 2 * (u[1] - g[1]) / 3], g);
|
|
479
|
+
} else if (f.localName === "close")
|
|
480
|
+
s.push(24577), i = c;
|
|
481
|
+
else if (f.localName === "arcTo") {
|
|
482
|
+
const u = F(f, "wR") / 9525, g = F(f, "hR") / 9525, P = F(f, "stAng") / 6e4 * Math.PI / 180, x = F(f, "swAng") / 6e4 * Math.PI / 180, T = i[0] - u * Math.cos(P), b = i[1] - g * Math.sin(P), E = Math.max(1, Math.ceil(Math.abs(x) / (Math.PI / 2)));
|
|
483
|
+
if (E > 64) throw new Error("PPT 圆弧圈数超限");
|
|
484
|
+
for (let v = 0; v < E; v++) {
|
|
485
|
+
const $ = P + x * v / E, N = P + x * (v + 1) / E, A = 4 / 3 * Math.tan((N - $) / 4);
|
|
486
|
+
o([T + u * (Math.cos($) - A * Math.sin($)), b + g * (Math.sin($) + A * Math.cos($))], [T + u * (Math.cos(N) + A * Math.sin(N)), b + g * (Math.sin(N) - A * Math.cos(N))], [T + u * Math.cos(N), b + g * Math.sin(N)]);
|
|
487
|
+
}
|
|
488
|
+
} else throw new Error(`PPT 几何不能表示 ${f.localName}`);
|
|
489
|
+
if (r.length > 6e4 || s.length > 6e4) throw new Error("PPT 几何点数超限");
|
|
490
|
+
}
|
|
491
|
+
s.push(32768);
|
|
492
|
+
const l = d([m(r.length), m(r.length), m(8), ...r.flatMap(([f, h]) => [a(J(f * 21600 / e.w, "几何 X")), a(J(h * 21600 / e.h, "几何 Y"))])]), p = d([m(s.length), m(s.length), m(2), ...s.map(m)]);
|
|
493
|
+
return [{ id: 320, value: 0 }, { id: 321, value: 0 }, { id: 322, value: 21600 }, { id: 323, value: 21600 }, { id: 324, value: 4 }, { id: 325, value: l }, { id: 326, value: p }];
|
|
494
|
+
}
|
|
495
|
+
class jt {
|
|
496
|
+
constructor() {
|
|
497
|
+
this.names = ["Arial"];
|
|
498
|
+
}
|
|
499
|
+
index(t) {
|
|
500
|
+
if (!t || t.length > 31 || /[\0-\x1f]/.test(t)) throw new Error("PPT 字体名称必须为 1–31 个字符");
|
|
501
|
+
let n = this.names.indexOf(t);
|
|
502
|
+
if (n < 0) {
|
|
503
|
+
if (this.names.length >= 512) throw new Error("PPT 字体数量超限");
|
|
504
|
+
n = this.names.length, this.names.push(t);
|
|
505
|
+
}
|
|
506
|
+
return n;
|
|
507
|
+
}
|
|
508
|
+
records() {
|
|
509
|
+
return this.names.map((t, n) => {
|
|
510
|
+
const r = new Uint8Array(68);
|
|
511
|
+
return r.set(W(t)), r[64] = 1, r[66] = 1, r[67] = 0, w(4023, r, 0, n);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function Wt(e, t) {
|
|
516
|
+
if (e.math || e.gradient || e.outline || e.shadow || e.underlineColor || e.field || e.highlight || e.spacing || e.caps && e.caps !== "none" || e.strike || e.strikeType && e.strikeType !== "noStrike" || e.link) throw new Error("此 PPT 写入器不能表示公式、链接或高级字符效果");
|
|
517
|
+
if (X(e.color).alpha !== 1) throw new Error("PPT 写入暂不支持半透明文字");
|
|
518
|
+
if (e.underline && e.underline !== "sng" && e.underline !== "none") throw new Error("PPT 写入暂不支持此下划线样式");
|
|
519
|
+
const n = Math.round(e.size * 0.75);
|
|
520
|
+
if (!Number.isFinite(n) || n < 1 || n > 4e3) throw new Error("PPT 字号超限");
|
|
521
|
+
const r = Number(e.b) | Number(e.i) << 1 | Number(e.u) << 2;
|
|
522
|
+
return d([a(3080199), m(r), m(t.index(e.fonts[0] || "Arial")), m(t.index(e.fonts[1] || e.fonts[0] || "Arial")), m(n), a(Pt(e.color) | 4261412864), m(Math.round(e.baseline ?? 0))]);
|
|
523
|
+
}
|
|
524
|
+
function qt(e, t, n = 4) {
|
|
525
|
+
var c;
|
|
526
|
+
if (e.warp || e.vert && e.vert !== "horz" || (e.columns ?? 1) !== 1) throw new Error("PPT 写入暂不支持艺术字、竖排或多栏文字");
|
|
527
|
+
if (e.fontScale !== 1 || e.autoFitCompute || e.autoFitNormal || e.autoFitShape || e.lnSpcReduction || e.anchorCtr) throw new Error("PPT 写入暂不支持自动适应或文字框居中语义");
|
|
528
|
+
const r = e.paragraphs.map((o) => o.runs.map((l) => l.text).join("")).join("\r");
|
|
529
|
+
if (/[\0]/.test(r)) throw new Error("PPT 文字不能包含 NUL");
|
|
530
|
+
const s = [], i = [];
|
|
531
|
+
for (const o of e.paragraphs) {
|
|
532
|
+
if (o.rtl || o.bulletColor || o.bulletFont || o.bulletSize && o.bulletSize !== 1 || (c = o.editInfo) != null && c.autoNumbering) throw new Error("PPT 写入暂不支持段落方向或独立项目符号样式");
|
|
533
|
+
if (!Number.isInteger(o.lvl) || o.lvl < 0 || o.lvl > 4) throw new Error("PPT 段落级别必须在 0–4 之间");
|
|
534
|
+
if ([o.marL, o.indent, o.spaceBefore, o.spaceAfter].some((P) => !Number.isFinite(P) || Math.abs(P * 6) > 32767) || o.lineHeight !== null && (!Number.isFinite(o.lineHeight) || Math.abs(o.lineHeight * (o.lineHeight < 0 ? 6 : 100)) > 32767)) throw new Error("PPT 段落间距超限");
|
|
535
|
+
const l = o.runs.reduce((P, x) => P + x.text.length, 0) + 1, p = o.bullet, f = p !== null && p !== "";
|
|
536
|
+
if (f && p.length !== 1 || o.bulletImage) throw new Error("PPT 写入暂不支持此项目符号");
|
|
537
|
+
const h = 32015 | (f ? 128 : 0), u = o.lineHeight === null || o.lineHeight === void 0 ? 100 : o.lineHeight < 0 ? Math.round(o.lineHeight * 6) : Math.round(o.lineHeight * 100), g = [a(l), m(o.lvl ?? 0), a(h), m(f ? 1 : 0), ...f ? [m(p.charCodeAt(0))] : [], m({ left: 0, center: 1, right: 2, justify: 3, dist: 4 }[o.align] ?? 0), m(u), m(-Math.round((o.spaceBefore ?? 0) * 6)), m(-Math.round((o.spaceAfter ?? 0) * 6)), m(Math.round((o.marL ?? 0) * 6)), m(Math.round((o.indent ?? 0) * 6))];
|
|
538
|
+
s.push(d(g));
|
|
539
|
+
for (let P = 0; P < o.runs.length; P++) {
|
|
540
|
+
const x = o.runs[P], T = x.text.length + (P === o.runs.length - 1 ? 1 : 0);
|
|
541
|
+
T && i.push(d([a(T), Wt(x, t)]));
|
|
542
|
+
}
|
|
543
|
+
o.runs.length || i.push(d([a(1), a(0)]));
|
|
544
|
+
}
|
|
545
|
+
return e.paragraphs.length || (s.push(d([a(1), m(0), a(0)])), i.push(d([a(1), a(0)]))), d([w(3999, a(n)), w(4e3, W(r)), w(4001, d([...s, ...i]))]);
|
|
546
|
+
}
|
|
547
|
+
function at(e) {
|
|
548
|
+
return w(4003, d([m(1), ...e >= 5 ? [m(0)] : [], a(0), a(196608), m(0), m(18)]), 0, e);
|
|
549
|
+
}
|
|
550
|
+
const dt = (e) => d(e.map((t) => a(J(t * 6, "组内坐标"))));
|
|
551
|
+
function ct(e, t) {
|
|
552
|
+
return t ? w(61455, dt([e.x, e.y, e.x + e.w, e.y + e.h])) : w(61456, d([e.y, e.x, e.x + e.w, e.y + e.h].map((n) => {
|
|
553
|
+
const r = Math.round(n * 6);
|
|
554
|
+
if (!Number.isFinite(r) || r < -32768 || r > 32767) throw new Error("PPT 顶层坐标超过 16 位范围");
|
|
555
|
+
return m(r);
|
|
556
|
+
})));
|
|
557
|
+
}
|
|
558
|
+
class Dt {
|
|
559
|
+
constructor(t, n) {
|
|
560
|
+
this.fonts = t, this.pictures = n, this.clusters = [], this.next = 1024, this.count = 0;
|
|
561
|
+
}
|
|
562
|
+
identity(t) {
|
|
563
|
+
let n = this.clusters[this.clusters.length - 1];
|
|
564
|
+
return (!n || n.id !== t || n.used === 1024) && (this.next = (this.clusters.length + 1) * 1024, n = { id: t, used: 0 }, this.clusters.push(n)), n.used++, this.count++, this.next++;
|
|
565
|
+
}
|
|
566
|
+
element(t, n, r = !1, s = 0, i = 0) {
|
|
567
|
+
var f, h, u, g, P;
|
|
568
|
+
if (s > 7) throw new Error("PPT 组合嵌套超过 8 层");
|
|
569
|
+
if (![t.x, t.y, t.w, t.h, t.rot].every(Number.isFinite) || t.w <= 0 || t.h <= 0) throw new Error("PPT 元素尺寸无效");
|
|
570
|
+
if (t.link || (f = t.editInfo) != null && f.readonlyLink) throw new Error("PPT 写入暂不支持超链接");
|
|
571
|
+
if (t.effects && Object.keys(t.effects).length || t.scene3d) throw new Error("PPT 写入暂不支持形状特效或三维");
|
|
572
|
+
if ((h = t.editInfo) != null && h.requiresOriginal || ((u = t.editInfo) == null ? void 0 : u.editable) === "frame") throw new Error("此原生对象必须保留原格式,请保存为 PPTX");
|
|
573
|
+
if (t.kind === "unsupported" || t.kind === "table") throw new Error("PPT 写入暂不支持表格或未知对象");
|
|
574
|
+
const c = this.identity(n), o = 2560 | (r ? 2 : 0) | (t.flipH ? 64 : 0) | (t.flipV ? 128 : 0), l = [{ id: 4, value: Math.round((t.rot % 360 + 360) % 360 * 65536) }];
|
|
575
|
+
if (t.name && l.push({ id: 896, value: W(t.name, !0) }), (P = (g = t.editInfo) == null ? void 0 : g.altText) != null && P.descr && l.push({ id: 897, value: W(t.editInfo.altText.descr, !0) }), t.kind === "group") {
|
|
576
|
+
if (!Number.isFinite(t.scaleX) || !Number.isFinite(t.scaleY) || t.scaleX <= 0 || t.scaleY <= 0) throw new Error("PPT 组合缩放无效");
|
|
577
|
+
return y(61443, [
|
|
578
|
+
y(61444, [
|
|
579
|
+
w(61449, dt([t.childX, t.childY, t.childX + t.w / t.scaleX, t.childY + t.h / t.scaleY]), 1),
|
|
580
|
+
w(61450, d([a(c), a(o | 1)]), 2),
|
|
581
|
+
G(l),
|
|
582
|
+
ct(t, r)
|
|
583
|
+
]),
|
|
584
|
+
...t.children.map((x) => this.element(x, n, !0, s + 1, i))
|
|
585
|
+
]);
|
|
586
|
+
}
|
|
587
|
+
let p;
|
|
588
|
+
if (t.kind === "image") {
|
|
589
|
+
if (t.clipPath || t.filter || t.duotone || t.alpha !== void 0 && t.alpha !== 1 || t.media) throw new Error("PPT 写入暂不支持异形裁剪、图片效果或音视频");
|
|
590
|
+
t.crop && Object.values(t.crop).some(Boolean) && l.push(...Et(t.crop)), l.push({ id: 260, value: this.pictures.add(t.src), blip: !0 }, ...Q(null), ...Y(t.stroke));
|
|
591
|
+
} else if (l.push(...zt(t), ...Q(t.openGeom ? null : t.fill), ...Y(t.stroke)), t.text) {
|
|
592
|
+
const x = t.text;
|
|
593
|
+
l.push(
|
|
594
|
+
{ id: 128, value: c << 16 },
|
|
595
|
+
{ id: 129, value: Math.round(x.insets[3] * 9525) },
|
|
596
|
+
{ id: 130, value: Math.round(x.insets[0] * 9525) },
|
|
597
|
+
{ id: 131, value: Math.round(x.insets[1] * 9525) },
|
|
598
|
+
{ id: 132, value: Math.round(x.insets[2] * 9525) },
|
|
599
|
+
{ id: 133, value: x.wrap ? 0 : 2 },
|
|
600
|
+
{ id: 135, value: { top: 0, middle: 1, bottom: 2 }[x.anchor] }
|
|
601
|
+
), p = w(61453, qt(x, this.fonts, i ? 2 : 4));
|
|
602
|
+
}
|
|
603
|
+
return y(61444, [
|
|
604
|
+
w(61450, d([a(c), a(o)]), 2, t.kind === "image" ? 75 : t.path === null ? 202 : 0),
|
|
605
|
+
G(l),
|
|
606
|
+
ct(t, r),
|
|
607
|
+
...p ? [p] : [],
|
|
608
|
+
...i ? [w(61457, w(3011, d([a(0), new Uint8Array([i, 0, 0, 0])])))] : []
|
|
609
|
+
]);
|
|
610
|
+
}
|
|
611
|
+
drawing(t, n, r, s = 0) {
|
|
612
|
+
const i = this.count, c = this.identity(r), o = t.map((p) => this.element(p, r, !1, 0, s)), l = this.identity(r);
|
|
613
|
+
return y(1036, [y(61442, [
|
|
614
|
+
w(61448, d([a(this.count - i), a(this.next - 1)]), 0, r),
|
|
615
|
+
y(61443, [y(61444, [w(61449, new Uint8Array(16), 1), w(61450, d([a(c), a(5)]), 2)]), ...o]),
|
|
616
|
+
y(61444, [w(61450, d([a(l), a(3072)]), 2, 1), G([...Q(n), ...Y(null)])])
|
|
617
|
+
])]);
|
|
618
|
+
}
|
|
619
|
+
group() {
|
|
620
|
+
const t = new Set(this.clusters.map((n) => n.id)).size;
|
|
621
|
+
return y(1035, [y(61440, [
|
|
622
|
+
w(61446, d([
|
|
623
|
+
a(this.next),
|
|
624
|
+
a(this.clusters.length + 1),
|
|
625
|
+
a(this.count),
|
|
626
|
+
a(t),
|
|
627
|
+
...this.clusters.flatMap((n) => [a(n.id), a(n.used)])
|
|
628
|
+
])),
|
|
629
|
+
this.pictures.store(),
|
|
630
|
+
w(61726, d([a(134217741), a(134217740), a(134217751), a(268435703)]))
|
|
631
|
+
])]);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
class Ht {
|
|
635
|
+
constructor(t) {
|
|
636
|
+
this.doc = t, this.items = [], this.indexes = /* @__PURE__ */ new Map();
|
|
637
|
+
}
|
|
638
|
+
add(t) {
|
|
639
|
+
var o;
|
|
640
|
+
const n = this.indexes.get(t);
|
|
641
|
+
if (n)
|
|
642
|
+
return this.items[n - 1].refs++, n;
|
|
643
|
+
let r = (o = mt(this.doc, t)) == null ? void 0 : o.bytes;
|
|
644
|
+
if (!r) {
|
|
645
|
+
const l = /^data:image\/(?:png|jpe?g);base64,([a-zA-Z0-9+/=\r\n]+)$/.exec(t);
|
|
646
|
+
if (!l) throw new Error("PPT 图片必须为可读取的内嵌 PNG/JPEG");
|
|
647
|
+
r = Uint8Array.from(atob(l[1]), (p) => p.charCodeAt(0));
|
|
648
|
+
}
|
|
649
|
+
const s = r[0] === 137 && r[1] === 80 && r[2] === 78 && r[3] === 71;
|
|
650
|
+
if (!s && !(r[0] === 255 && r[1] === 216 && r[2] === 255)) throw new Error("PPT 图片仅支持 PNG/JPEG");
|
|
651
|
+
const i = new Uint8Array(16);
|
|
652
|
+
k(i).setUint32(0, this.items.length + 1, !0);
|
|
653
|
+
const c = w(s ? 61470 : 61469, d([i, new Uint8Array([255]), r]), 0, s ? 1760 : 1130);
|
|
654
|
+
return this.items.push({ record: c, uid: i, type: s ? 6 : 5, refs: 1 }), this.indexes.set(t, this.items.length), this.items.length;
|
|
655
|
+
}
|
|
656
|
+
stream() {
|
|
657
|
+
return d(this.items.map((t) => t.record));
|
|
658
|
+
}
|
|
659
|
+
store() {
|
|
660
|
+
let t = 0;
|
|
661
|
+
const n = this.items.map((r) => {
|
|
662
|
+
const s = d([new Uint8Array([r.type, r.type]), r.uid, m(255), a(r.record.length), a(r.refs), a(t), new Uint8Array(4)]);
|
|
663
|
+
return t += r.record.length, w(61447, s, 2, r.type);
|
|
664
|
+
});
|
|
665
|
+
return w(61441, d(n), 15, n.length);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const Yt = "application/vnd.ms-powerpoint";
|
|
669
|
+
class tt extends Error {
|
|
670
|
+
constructor(t) {
|
|
671
|
+
super(t.map((n) => `${n.slide ? `第 ${n.slide} 页:` : ""}${n.message}`).join(`
|
|
672
|
+
`)), this.issues = t, this.name = "PptSaveError";
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const H = () => w(2032, d([16777215, 0, 8421504, 0, 16764108, 11711154, 13382451, 10066176].map(a)), 0, 1), V = (e, t) => w(1011, d([a(e), a(4), a(0), a(t), a(0)]));
|
|
676
|
+
function ht(e, t = 0) {
|
|
677
|
+
return w(1007, d([a(16), new Uint8Array(8), a(e), a(t), a(0)]), 2);
|
|
678
|
+
}
|
|
679
|
+
function ut(e) {
|
|
680
|
+
return { kind: "shape", x: 48, y: 300, w: 624, h: 500, rot: 0, flipH: !1, flipV: !1, path: null, fill: null, stroke: null, text: { anchor: "top", insets: [4, 4, 4, 4], wrap: !0, fontScale: 1, paragraphs: e.split(/\r?\n/).map((n) => ({
|
|
681
|
+
align: "left",
|
|
682
|
+
lvl: 0,
|
|
683
|
+
marL: 0,
|
|
684
|
+
indent: 0,
|
|
685
|
+
bullet: null,
|
|
686
|
+
lineHeight: null,
|
|
687
|
+
spaceBefore: 0,
|
|
688
|
+
spaceAfter: 0,
|
|
689
|
+
runs: [{ text: n, b: !1, i: !1, u: !1, strike: !1, size: 20, color: "#000000", fonts: ["Arial"] }]
|
|
690
|
+
})) } };
|
|
691
|
+
}
|
|
692
|
+
function Bt(e) {
|
|
693
|
+
if (e.transition) throw new Error("PPT 写入暂不支持页面切换,请保存为 PPTX");
|
|
694
|
+
return w(1017, d([a(0), a(0), m(0), m(e.hidden ? 260 : 256), a(2)]));
|
|
695
|
+
}
|
|
696
|
+
function _t(e) {
|
|
697
|
+
if (e.meta.readonly) throw new Error("只读文档不能保存 PPT");
|
|
698
|
+
if (!e.slideOrder.length || e.slideOrder.length > 1e3) throw new Error("PPT 保存需要 1–1000 页");
|
|
699
|
+
for (const M of [e.meta.width, e.meta.height]) if (!Number.isFinite(M) || M < 96 || M > 5376) throw new Error("PPT 页面尺寸必须在 96–5376 px 范围");
|
|
700
|
+
if (e.sections.order.length) throw new Error("PPT 写入暂不支持节,请保存为 PPTX");
|
|
701
|
+
const t = new jt(), n = new Ht(e), r = new Dt(t, n), s = e.slideOrder.map((M) => wt(e, M)), i = [], c = [], o = 2147483648, l = y(1016, [
|
|
702
|
+
ht(0),
|
|
703
|
+
r.drawing([], { type: "solid", color: "#ffffff" }, 1),
|
|
704
|
+
H(),
|
|
705
|
+
...[0, 1, 2, 4, 5, 6].map(at)
|
|
706
|
+
]), p = [], f = [], h = [];
|
|
707
|
+
let u = 2;
|
|
708
|
+
if (s.forEach((M, S) => {
|
|
709
|
+
var U, z;
|
|
710
|
+
try {
|
|
711
|
+
if ((U = M.animations) != null && U.length) throw new Error("PPT 写入暂不支持元素动画,请保存为 PPTX");
|
|
712
|
+
if ((z = M.comments) != null && z.length) throw new Error("PPT 写入暂不支持批注,请保存为 PPTX");
|
|
713
|
+
const O = 256 + S, _ = M.notes ? 256 + S : 0;
|
|
714
|
+
if (c.push(y(1006, [ht(o, _), Bt(M), r.drawing(M.elements, M.background, u++), H()])), p.push(O), _) {
|
|
715
|
+
const pt = r.drawing([ut(M.notes)], { type: "solid", color: "#ffffff" }, u++, 12);
|
|
716
|
+
h.push(y(1008, [w(1009, d([a(O), a(7)])), pt, H()])), f.push(_);
|
|
717
|
+
}
|
|
718
|
+
} catch (O) {
|
|
719
|
+
i.push({ slide: S + 1, message: O instanceof Error ? O.message : String(O) });
|
|
720
|
+
}
|
|
721
|
+
}), i.length) throw new tt(i);
|
|
722
|
+
const g = h.length ? y(1008, [
|
|
723
|
+
w(1009, new Uint8Array(8)),
|
|
724
|
+
r.drawing([ut("")], { type: "solid", color: "#ffffff" }, u++, 6),
|
|
725
|
+
H()
|
|
726
|
+
]) : void 0, P = w(1001, d([
|
|
727
|
+
a(Math.round(e.meta.width * 6)),
|
|
728
|
+
a(Math.round(e.meta.height * 6)),
|
|
729
|
+
a(4320),
|
|
730
|
+
a(5760),
|
|
731
|
+
a(1),
|
|
732
|
+
a(1),
|
|
733
|
+
a(g ? 3 + s.length + h.length : 0),
|
|
734
|
+
a(0),
|
|
735
|
+
m(1),
|
|
736
|
+
m(6),
|
|
737
|
+
new Uint8Array(4)
|
|
738
|
+
]), 1), T = [y(1e3, [
|
|
739
|
+
P,
|
|
740
|
+
y(1010, [y(2005, t.records()), w(4009, a(0)), at(4)]),
|
|
741
|
+
r.group(),
|
|
742
|
+
y(4080, [V(2, o)], 1),
|
|
743
|
+
y(4080, p.map((M, S) => V(S + 3, M))),
|
|
744
|
+
...f.length ? [y(4080, f.map((M, S) => V(s.length + 3 + S, M)), 2)] : [],
|
|
745
|
+
w(1002)
|
|
746
|
+
]), l, ...c, ...h, ...g ? [g] : []], b = [];
|
|
747
|
+
let E = 0;
|
|
748
|
+
for (const M of T)
|
|
749
|
+
b.push(E), E += M.length;
|
|
750
|
+
const v = w(6002, d([a(b.length << 20 | 1), ...b.map(a)])), $ = E + v.length, N = w(4085, d([a(256), m(0), new Uint8Array([0, 3]), a(0), a(E), a(1), a(T.length + 1), m(1), m(0)])), A = "Web-PPT", q = w(4086, d([
|
|
751
|
+
a(20),
|
|
752
|
+
a(3817979999),
|
|
753
|
+
a($),
|
|
754
|
+
m(A.length),
|
|
755
|
+
m(1012),
|
|
756
|
+
new Uint8Array([3, 0, 0, 0]),
|
|
757
|
+
new TextEncoder().encode(A),
|
|
758
|
+
a(8),
|
|
759
|
+
W(A)
|
|
760
|
+
]));
|
|
761
|
+
return gt({ "PowerPoint Document": d([...T, v, N]), "Current User": q, Pictures: n.stream() });
|
|
762
|
+
}
|
|
763
|
+
function Zt(e) {
|
|
764
|
+
try {
|
|
765
|
+
return _t(e);
|
|
766
|
+
} catch (t) {
|
|
767
|
+
throw t instanceof tt ? t : new tt([{ slide: 0, message: t instanceof Error ? t.message : String(t) }]);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
export {
|
|
771
|
+
Yt as PPT_MIME,
|
|
772
|
+
tt as PptSaveError,
|
|
773
|
+
Zt as savePpt
|
|
774
|
+
};
|