pptx-ts 0.0.1 → 4.0.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/README.md +116 -269
- package/dist/autopage-odPz7zZO.js +536 -0
- package/dist/autopage-odPz7zZO.js.map +1 -0
- package/dist/binary-string-CKVAYI3M.js +24 -0
- package/dist/binary-string-CKVAYI3M.js.map +1 -0
- package/dist/body-insets-Dw_BeWD_.js +54 -0
- package/dist/body-insets-Dw_BeWD_.js.map +1 -0
- package/dist/browser.d.ts +29 -9
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +41 -14
- package/dist/browser.js.map +1 -1
- package/dist/clip-Bl01BPcN.d.ts +67 -0
- package/dist/clip-Bl01BPcN.d.ts.map +1 -0
- package/dist/diagnostics-D8ot4Ei7.d.ts +244 -0
- package/dist/diagnostics-D8ot4Ei7.d.ts.map +1 -0
- package/dist/embedded-fonts-DarT9aoa.d.ts +20 -0
- package/dist/embedded-fonts-DarT9aoa.d.ts.map +1 -0
- package/dist/entry-compose-DCnvBZz2.d.ts +1046 -0
- package/dist/entry-compose-DCnvBZz2.d.ts.map +1 -0
- package/dist/{enums-CvRYniUA.d.ts → enums-BUKTUB6V.d.ts} +21 -13
- package/dist/{enums-CvRYniUA.d.ts.map → enums-BUKTUB6V.d.ts.map} +1 -1
- package/dist/{errors-Bvln0H-7.js → errors-C4oENPcu.js} +92 -2
- package/dist/errors-C4oENPcu.js.map +1 -0
- package/dist/families.d.ts +260 -0
- package/dist/families.d.ts.map +1 -0
- package/dist/families.js +57 -0
- package/dist/families.js.map +1 -0
- package/dist/{fit-BKs0zxMI.js → fit-Cb7naFj6.js} +249 -167
- package/dist/fit-Cb7naFj6.js.map +1 -0
- package/dist/font-metrics-v5fn7s7e.d.ts +613 -0
- package/dist/font-metrics-v5fn7s7e.d.ts.map +1 -0
- package/dist/grid-DikTjFey.js +187 -0
- package/dist/grid-DikTjFey.js.map +1 -0
- package/dist/{html-dom-B0I0QSbU.js → html-dom-Iuog2wdK.js} +121 -91
- package/dist/html-dom-Iuog2wdK.js.map +1 -0
- package/dist/html.d.ts +6 -6
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +7 -6
- package/dist/html.js.map +1 -1
- package/dist/image-size-CvN2iCA4.js +1611 -0
- package/dist/image-size-CvN2iCA4.js.map +1 -0
- package/dist/index.d.ts +24 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +40 -31
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +40 -48
- package/dist/inspect.js.map +1 -1
- package/dist/math.d.ts +7 -5
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +16 -7
- package/dist/math.js.map +1 -1
- package/dist/measure.d.ts +12 -225
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +3 -3
- package/dist/node.d.ts +22 -8
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +27 -7
- package/dist/node.js.map +1 -1
- package/dist/notes-Dh12JAbn.js +3264 -0
- package/dist/notes-Dh12JAbn.js.map +1 -0
- package/dist/options-internal-WqgMf720.js +43 -0
- package/dist/options-internal-WqgMf720.js.map +1 -0
- package/dist/{package-CaOLXSNi.d.ts → package-J49Ck6S2.d.ts} +27 -12
- package/dist/package-J49Ck6S2.d.ts.map +1 -0
- package/dist/playbtn-CUqQdoDf.js +22 -0
- package/dist/playbtn-CUqQdoDf.js.map +1 -0
- package/dist/{slide-js0QpRV-.d.ts → pres-C6qgOFAa.d.ts} +1021 -1370
- package/dist/pres-C6qgOFAa.d.ts.map +1 -0
- package/dist/{presentation-Cp7vzlAw.js → presentation-DGYlAWhl.js} +3208 -2727
- package/dist/presentation-DGYlAWhl.js.map +1 -0
- package/dist/{presentation-types-DP_8jog7.d.ts → presentation-types-8jLQHI4M.d.ts} +1070 -683
- package/dist/presentation-types-8jLQHI4M.d.ts.map +1 -0
- package/dist/read.d.ts +9 -9
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +4 -4
- package/dist/script.d.ts +80 -66
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +2399 -1139
- package/dist/script.js.map +1 -1
- package/dist/{shapes-BemroU-z.js → shapes-re0KyQk_.js} +2807 -1609
- package/dist/shapes-re0KyQk_.js.map +1 -0
- package/dist/slide-Dx2ZeVZ6.d.ts +1256 -0
- package/dist/slide-Dx2ZeVZ6.d.ts.map +1 -0
- package/dist/slide-size-BalTjFuv.js +88 -0
- package/dist/slide-size-BalTjFuv.js.map +1 -0
- package/dist/{units-internal-Dg95w_YD.js → table-cell-margins-EVg0EwxT.js} +235 -273
- package/dist/table-cell-margins-EVg0EwxT.js.map +1 -0
- package/dist/table-dom-BTDP3lEP.js +21 -0
- package/dist/table-dom-BTDP3lEP.js.map +1 -0
- package/dist/text-KnLOtEEu.js +3980 -0
- package/dist/text-KnLOtEEu.js.map +1 -0
- package/dist/text-anchor-CrYXAfUu.js +176 -0
- package/dist/text-anchor-CrYXAfUu.js.map +1 -0
- package/dist/transition-speed-kUEWDWTx.js +14 -0
- package/dist/transition-speed-kUEWDWTx.js.map +1 -0
- package/dist/units-internal-XJlf-hOl.js +649 -0
- package/dist/units-internal-XJlf-hOl.js.map +1 -0
- package/dist/zip-C0leZZMj.d.ts +67 -0
- package/dist/zip-C0leZZMj.d.ts.map +1 -0
- package/dist/zip-CKd8ihcf.js +177 -0
- package/dist/zip-CKd8ihcf.js.map +1 -0
- package/dist/zip.d.ts +3 -68
- package/dist/zip.js +3 -163
- package/dist/zoom-cX9sllpH.js +8865 -0
- package/dist/zoom-cX9sllpH.js.map +1 -0
- package/package.json +106 -19
- package/skills/ts-pptx-upstream/SKILL.md +58 -57
- package/dist/autopage-DkjYZUFD.js +0 -423
- package/dist/autopage-DkjYZUFD.js.map +0 -1
- package/dist/diagnostics-Du_s75MT.d.ts +0 -829
- package/dist/diagnostics-Du_s75MT.d.ts.map +0 -1
- package/dist/errors-Bvln0H-7.js.map +0 -1
- package/dist/errors-PflMPWBn.d.ts +0 -182
- package/dist/errors-PflMPWBn.d.ts.map +0 -1
- package/dist/fit-BKs0zxMI.js.map +0 -1
- package/dist/html-dom-B0I0QSbU.js.map +0 -1
- package/dist/namespaces-BVnNu7sg.js +0 -666
- package/dist/namespaces-BVnNu7sg.js.map +0 -1
- package/dist/notes-RLCwdlTE.js +0 -1703
- package/dist/notes-RLCwdlTE.js.map +0 -1
- package/dist/package-CaOLXSNi.d.ts.map +0 -1
- package/dist/pres-C5__xkDh.d.ts +0 -202
- package/dist/pres-C5__xkDh.d.ts.map +0 -1
- package/dist/presentation-Cp7vzlAw.js.map +0 -1
- package/dist/presentation-types-DP_8jog7.d.ts.map +0 -1
- package/dist/shapes-BemroU-z.js.map +0 -1
- package/dist/slide-js0QpRV-.d.ts.map +0 -1
- package/dist/text-CyetbF6p.js +0 -11278
- package/dist/text-CyetbF6p.js.map +0 -1
- package/dist/units-1kRzYShk.js +0 -231
- package/dist/units-1kRzYShk.js.map +0 -1
- package/dist/units-internal-Dg95w_YD.js.map +0 -1
- package/dist/zip.d.ts.map +0 -1
- package/dist/zip.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slide-Dx2ZeVZ6.d.ts","names":[],"sources":["../src/types/table.ts","../src/types/animation.ts","../src/types/master.ts","../src/types/model3d.ts","../src/types/zoom.ts","../src/types/slide.ts"],"mappings":";;;;;;;;;;;;UA4BiB;EAChB,eAAe;EACf,gBAAgB;EAChB,mBAAmB;;;;;;UAOH;EAChB,iBAAiB,sBAAsB;;;;;;UAOvB,2BAA2B,KAAK;;;;;;;EAOhD;IAAa,OAAO;IAAiB,SAAS;;;;;EAI9C;IAAa,WAAW;IAAY,SAAS;;;;;EAI7C;IAAa,MAAM;IAAY,SAAS;;;;;EAIxC;IAAY,MAAM;IAAa,SAAS;;;;;;;;;EAQxC;;;;;;;;EAQA;;;;;EAKA;;;;;EAKA;;;;;;;;EAQA,WAAW;;;;;;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BAAkB;;;;;;;;;;;WAYlB,qBAAqB;;;;;EAM9B,aAAa;;;;;;WAOJ;;;;WAIA;;;;;;;;;EAUT,aAAa;;;;;;EAMb,QAAQ;;;;;EAKR;;;;EAIA,cAAc;;UAEE;;EAEhB;EACA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region src/ooxml/slide-size.ts
|
|
2
|
+
/**
|
|
3
|
+
* The slide size a presentation has when `presentation.xml` declares none.
|
|
4
|
+
*
|
|
5
|
+
* `p:sldSz` is optional in `CT_Presentation` (`minOccurs="0"`), and the schema says nothing about
|
|
6
|
+
* what its absence means: `cx` and `cy` are required only when the element is there. So the answer
|
|
7
|
+
* is PowerPoint's. A deck with `p:sldSz` removed opens at 720 × 540 pt, the 10in × 7.5in on-screen
|
|
8
|
+
* 4:3 size (`ppSlideSizeOnScreen`), measured over COM against a control copy that kept its
|
|
9
|
+
* 960 × 540 pt declaration. That is `LAYOUT_4x3`, not the write path's `LAYOUT_16x9` default and
|
|
10
|
+
* not `LAYOUT_WIDE`.
|
|
11
|
+
*
|
|
12
|
+
* Anything that has to name a size for such a deck takes this one. The script converter and
|
|
13
|
+
* `inspect` each had their own, and they disagreed.
|
|
14
|
+
*/
|
|
15
|
+
const ABSENT_SLIDE_SIZE_EMU = Object.freeze({
|
|
16
|
+
widthEmu: 9144e3,
|
|
17
|
+
heightEmu: 6858e3
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The standard slide sizes, each with the label PowerPoint shows for it, as `docProps/app.xml`'s
|
|
21
|
+
* `<PresentationFormat>` spells it, and the `p:sldSz/@type` PowerPoint writes for it.
|
|
22
|
+
*
|
|
23
|
+
* The labels are PowerPoint's own, read back from decks it re-saved, and three of them follow
|
|
24
|
+
* `@type` rather than the dimensions: a deck re-saved from `type="screen16x9"` comes back
|
|
25
|
+
* `On-screen Show (16:9)`, while the same dimensions set through `PageSetup`, which writes no type,
|
|
26
|
+
* come back `Custom`. `LAYOUT_WIDE`'s 13.333in × 7.5in is recognised as `Widescreen` from its
|
|
27
|
+
* dimensions alone, and PowerPoint writes it with no `type` at all. Anything else is `Custom`.
|
|
28
|
+
*
|
|
29
|
+
* One table for both, so the label `app.xml` states and the type `presentation.xml` declares
|
|
30
|
+
* cannot disagree about a deck.
|
|
31
|
+
*
|
|
32
|
+
* Matched on exact EMU rather than on aspect ratio: the ratio of 10in × 7.5in and of
|
|
33
|
+
* 13.333in × 10in is the same, and PowerPoint labels only the first of them 4:3.
|
|
34
|
+
*/
|
|
35
|
+
const STANDARD_SLIDE_SIZES = Object.freeze([
|
|
36
|
+
{
|
|
37
|
+
cx: 9144e3,
|
|
38
|
+
cy: 6858e3,
|
|
39
|
+
label: "On-screen Show (4:3)",
|
|
40
|
+
type: "screen4x3"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
cx: 9144e3,
|
|
44
|
+
cy: 5143500,
|
|
45
|
+
label: "On-screen Show (16:9)",
|
|
46
|
+
type: "screen16x9"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
cx: 9144e3,
|
|
50
|
+
cy: 5715e3,
|
|
51
|
+
label: "On-screen Show (16:10)",
|
|
52
|
+
type: "screen16x10"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
cx: 12192e3,
|
|
56
|
+
cy: 6858e3,
|
|
57
|
+
label: "Widescreen",
|
|
58
|
+
type: void 0
|
|
59
|
+
}
|
|
60
|
+
]);
|
|
61
|
+
function standardSlideSize(widthEmu, heightEmu) {
|
|
62
|
+
return STANDARD_SLIDE_SIZES.find(({ cx, cy }) => cx === widthEmu && cy === heightEmu);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* `<PresentationFormat>` for a deck of this size, or `Custom` for one that matches no standard
|
|
66
|
+
* size. `app.xml` used to say `On-screen Show (16:9)` whatever the deck.
|
|
67
|
+
* @param widthEmu - the deck's slide width in EMU
|
|
68
|
+
* @param heightEmu - the deck's slide height in EMU
|
|
69
|
+
*/
|
|
70
|
+
function presentationFormatLabel(widthEmu, heightEmu) {
|
|
71
|
+
return standardSlideSize(widthEmu, heightEmu)?.label ?? "Custom";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `p:sldSz/@type` for a deck of this size, or `undefined` where PowerPoint writes none: at the
|
|
75
|
+
* widescreen size, and at any size that is not standard.
|
|
76
|
+
*
|
|
77
|
+
* Taken from the dimensions, not from the layout's name, so a `defineLayout` at exactly
|
|
78
|
+
* 10in × 5.625in is typed as the on-screen 16:9 size it is, as its `app.xml` label already says.
|
|
79
|
+
* @param widthEmu - the deck's slide width in EMU
|
|
80
|
+
* @param heightEmu - the deck's slide height in EMU
|
|
81
|
+
*/
|
|
82
|
+
function slideSizeType(widthEmu, heightEmu) {
|
|
83
|
+
return standardSlideSize(widthEmu, heightEmu)?.type;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { presentationFormatLabel as n, slideSizeType as r, ABSENT_SLIDE_SIZE_EMU as t };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=slide-size-BalTjFuv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slide-size-BalTjFuv.js","names":[],"sources":["../src/ooxml/slide-size.ts"],"sourcesContent":["/**\n * The slide size a presentation has when `presentation.xml` declares none.\n *\n * `p:sldSz` is optional in `CT_Presentation` (`minOccurs=\"0\"`), and the schema says nothing about\n * what its absence means: `cx` and `cy` are required only when the element is there. So the answer\n * is PowerPoint's. A deck with `p:sldSz` removed opens at 720 × 540 pt, the 10in × 7.5in on-screen\n * 4:3 size (`ppSlideSizeOnScreen`), measured over COM against a control copy that kept its\n * 960 × 540 pt declaration. That is `LAYOUT_4x3`, not the write path's `LAYOUT_16x9` default and\n * not `LAYOUT_WIDE`.\n *\n * Anything that has to name a size for such a deck takes this one. The script converter and\n * `inspect` each had their own, and they disagreed.\n */\nexport const ABSENT_SLIDE_SIZE_EMU: Readonly<{ widthEmu: number; heightEmu: number }> = Object.freeze({\n\twidthEmu: 9144000,\n\theightEmu: 6858000,\n})\n\n/** The `ST_SlideSizeType` values a written deck can carry; `custom` is the schema default. */\nexport type SlideSizeType = 'screen4x3' | 'screen16x9' | 'screen16x10'\n\n/**\n * The standard slide sizes, each with the label PowerPoint shows for it, as `docProps/app.xml`'s\n * `<PresentationFormat>` spells it, and the `p:sldSz/@type` PowerPoint writes for it.\n *\n * The labels are PowerPoint's own, read back from decks it re-saved, and three of them follow\n * `@type` rather than the dimensions: a deck re-saved from `type=\"screen16x9\"` comes back\n * `On-screen Show (16:9)`, while the same dimensions set through `PageSetup`, which writes no type,\n * come back `Custom`. `LAYOUT_WIDE`'s 13.333in × 7.5in is recognised as `Widescreen` from its\n * dimensions alone, and PowerPoint writes it with no `type` at all. Anything else is `Custom`.\n *\n * One table for both, so the label `app.xml` states and the type `presentation.xml` declares\n * cannot disagree about a deck.\n *\n * Matched on exact EMU rather than on aspect ratio: the ratio of 10in × 7.5in and of\n * 13.333in × 10in is the same, and PowerPoint labels only the first of them 4:3.\n */\nconst STANDARD_SLIDE_SIZES: ReadonlyArray<\n\tReadonly<{ cx: number; cy: number; label: string; type: SlideSizeType | undefined }>\n> = Object.freeze([\n\t{ cx: 9144000, cy: 6858000, label: 'On-screen Show (4:3)', type: 'screen4x3' },\n\t{ cx: 9144000, cy: 5143500, label: 'On-screen Show (16:9)', type: 'screen16x9' },\n\t{ cx: 9144000, cy: 5715000, label: 'On-screen Show (16:10)', type: 'screen16x10' },\n\t{ cx: 12192000, cy: 6858000, label: 'Widescreen', type: undefined },\n])\n\nfunction standardSlideSize(widthEmu: number, heightEmu: number) {\n\treturn STANDARD_SLIDE_SIZES.find(({ cx, cy }) => cx === widthEmu && cy === heightEmu)\n}\n\n/**\n * `<PresentationFormat>` for a deck of this size, or `Custom` for one that matches no standard\n * size. `app.xml` used to say `On-screen Show (16:9)` whatever the deck.\n * @param widthEmu - the deck's slide width in EMU\n * @param heightEmu - the deck's slide height in EMU\n */\nexport function presentationFormatLabel(widthEmu: number, heightEmu: number): string {\n\treturn standardSlideSize(widthEmu, heightEmu)?.label ?? 'Custom'\n}\n\n/**\n * `p:sldSz/@type` for a deck of this size, or `undefined` where PowerPoint writes none: at the\n * widescreen size, and at any size that is not standard.\n *\n * Taken from the dimensions, not from the layout's name, so a `defineLayout` at exactly\n * 10in × 5.625in is typed as the on-screen 16:9 size it is, as its `app.xml` label already says.\n * @param widthEmu - the deck's slide width in EMU\n * @param heightEmu - the deck's slide height in EMU\n */\nexport function slideSizeType(widthEmu: number, heightEmu: number): SlideSizeType | undefined {\n\treturn standardSlideSize(widthEmu, heightEmu)?.type\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,wBAA2E,OAAO,OAAO;CACrG,UAAU;CACV,WAAW;AACZ,CAAC;;;;;;;;;;;;;;;;;AAqBD,MAAM,uBAEF,OAAO,OAAO;CACjB;EAAE,IAAI;EAAS,IAAI;EAAS,OAAO;EAAwB,MAAM;CAAY;CAC7E;EAAE,IAAI;EAAS,IAAI;EAAS,OAAO;EAAyB,MAAM;CAAa;CAC/E;EAAE,IAAI;EAAS,IAAI;EAAS,OAAO;EAA0B,MAAM;CAAc;CACjF;EAAE,IAAI;EAAU,IAAI;EAAS,OAAO;EAAc,MAAM,KAAA;CAAU;AACnE,CAAC;AAED,SAAS,kBAAkB,UAAkB,WAAmB;CAC/D,OAAO,qBAAqB,MAAM,EAAE,IAAI,SAAS,OAAO,YAAY,OAAO,SAAS;AACrF;;;;;;;AAQA,SAAgB,wBAAwB,UAAkB,WAA2B;CACpF,OAAO,kBAAkB,UAAU,SAAS,CAAC,EAAE,SAAS;AACzD;;;;;;;;;;AAWA,SAAgB,cAAc,UAAkB,WAA8C;CAC7F,OAAO,kBAAkB,UAAU,SAAS,CAAC,EAAE;AAChD"}
|
|
@@ -1,5 +1,209 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { l as warn, n as InvalidOptionError } from "./errors-C4oENPcu.js";
|
|
2
|
+
//#region src/ooxml/emu.ts
|
|
3
|
+
/**
|
|
4
|
+
* The fixed ratios between English Metric Units, points and inches.
|
|
5
|
+
*
|
|
6
|
+
* `units.ts` publishes them, but it also holds the unit converters, which warn and throw, so it
|
|
7
|
+
* imports `diagnostics.ts` and `errors.ts` at run time. A schema fact in `ooxml/` that only needs
|
|
8
|
+
* a ratio (`body-insets.ts`) took both along with it. This module imports nothing, and `units.ts`
|
|
9
|
+
* re-exports it, so the public names are unchanged.
|
|
10
|
+
*/
|
|
11
|
+
/** EMU in one inch. */
|
|
12
|
+
const EMU_PER_INCH = 914400;
|
|
13
|
+
/** EMU in one point. */
|
|
14
|
+
const EMU_PER_POINT = 12700;
|
|
15
|
+
/** Points in one inch. */
|
|
16
|
+
const POINTS_PER_INCH = 72;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/units.ts
|
|
19
|
+
/**
|
|
20
|
+
* DrawingML angle unit. `ST_Angle` (`rot`, shadow `dir`, gradient `ang`, …) is measured in
|
|
21
|
+
* sixtieths-of-a-thousandth of a degree, i.e. 60000 units per degree. Multiply a value in
|
|
22
|
+
* degrees by this to get the OOXML integer.
|
|
23
|
+
*/
|
|
24
|
+
const ANGLE_UNITS_PER_DEGREE = 6e4;
|
|
25
|
+
/**
|
|
26
|
+
* DrawingML fixed-point percentage scale. `ST_Percentage` / `ST_PositiveFixedPercentage` and
|
|
27
|
+
* related types (`<a:alpha>`, `<a:spcPct>`, shape adjustment guides, `<p:tav tm>`, …) encode
|
|
28
|
+
* 100% as the integer 100000. Multiply a 0-1 fraction by this to get the OOXML value.
|
|
29
|
+
*/
|
|
30
|
+
const PERCENT_SCALE = 1e5;
|
|
31
|
+
/**
|
|
32
|
+
* Scale for a percentage supplied as 0-100 (rather than a 0-1 fraction) into the same
|
|
33
|
+
* fixed-point percentage integer as {@link PERCENT_SCALE} (1% = 1000 units, i.e. thousandths
|
|
34
|
+
* of a percent). Use for inputs documented as percents: transparency/alpha, image crop insets,
|
|
35
|
+
* gradient stops, bullet size, connector adjust, etc.
|
|
36
|
+
*/
|
|
37
|
+
const FIXED_PCT_PER_PERCENT = PERCENT_SCALE / 100;
|
|
38
|
+
/**
|
|
39
|
+
* DrawingML text measures font size (`sz`), character spacing (`spc`) and point line/paragraph
|
|
40
|
+
* spacing (`<a:spcPts val>`) in hundredths of a point. Multiply a value in points by this to get
|
|
41
|
+
* the OOXML integer.
|
|
42
|
+
*/
|
|
43
|
+
const HUNDREDTHS_PER_POINT = 100;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a value in points to hundredths of a point (rounded), the integer unit DrawingML uses
|
|
46
|
+
* for `sz`, `spc`, and `<a:spcPts val>`. See {@link HUNDREDTHS_PER_POINT}.
|
|
47
|
+
*/
|
|
48
|
+
function ptToHundredths(pt) {
|
|
49
|
+
assertFiniteNumber(pt, "points");
|
|
50
|
+
return Math.round(pt * 100);
|
|
51
|
+
}
|
|
52
|
+
/** A bare number larger than this (in inches) is almost certainly a mistake — likely a raw EMU
|
|
53
|
+
* value passed where inches are expected. We interpret it as inches (the documented contract) but
|
|
54
|
+
* warn, pointing at the explicit `"<n>emu"` form. ~1000in is far beyond any real slide. */
|
|
55
|
+
const IMPLAUSIBLE_INCHES = 1e3;
|
|
56
|
+
/** Default pixel density for the `"<n>px"` coordinate unit: CSS reference pixels, also the
|
|
57
|
+
* density ts-pptx assumes when reading an image header's pixel dimensions. */
|
|
58
|
+
const DEFAULT_PX_PER_INCH = 96;
|
|
59
|
+
/**
|
|
60
|
+
* The largest DrawingML coordinate, in EMU: the `maxInclusive` of `ST_Coordinate`, the type of
|
|
61
|
+
* every shape offset and extent. The range is not symmetric; see {@link MIN_COORDINATE_EMU}.
|
|
62
|
+
*/
|
|
63
|
+
const MAX_COORDINATE_EMU = 27273042316900;
|
|
64
|
+
/** The smallest DrawingML coordinate, in EMU: the `minInclusive` of `ST_Coordinate`. */
|
|
65
|
+
const MIN_COORDINATE_EMU = -27273042329600;
|
|
66
|
+
function inchesToEmu(inches) {
|
|
67
|
+
assertFiniteNumber(inches, "inches");
|
|
68
|
+
return inCoordinateRange(Math.round(inches * EMU_PER_INCH), inches, "inches");
|
|
69
|
+
}
|
|
70
|
+
function pointsToEmu(points) {
|
|
71
|
+
assertFiniteNumber(points, "points");
|
|
72
|
+
return inCoordinateRange(Math.round(points * EMU_PER_POINT), points, "points");
|
|
73
|
+
}
|
|
74
|
+
function pixelsToEmu(pixels, dpi) {
|
|
75
|
+
assertFiniteNumber(pixels, "pixels");
|
|
76
|
+
assertPositiveFiniteNumber(dpi, "dpi");
|
|
77
|
+
return inchesToEmu(pixels / dpi);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve a percentage of an axis length to EMU.
|
|
81
|
+
*
|
|
82
|
+
* **Published for consumers, and reached from one place inside `src/` on purpose.** Internally
|
|
83
|
+
* only `parseCoord` needs it, because every `'50%'` a caller writes comes through there; it is
|
|
84
|
+
* exported because a consumer computing its own geometry against a slide axis needs the same
|
|
85
|
+
* arithmetic, and it belongs with the rest of the conversion set beside it rather than hidden
|
|
86
|
+
* behind the one caller. Left exported deliberately rather than by oversight — this note is the
|
|
87
|
+
* difference between the two, as it is on {@link emuToPixels}.
|
|
88
|
+
* @param percent - percentage value (e.g. `50` for 50%)
|
|
89
|
+
* @param axisEmu - the axis length in EMU (slide width for x/w, height for y/h)
|
|
90
|
+
*/
|
|
91
|
+
function percentToEmu(percent, axisEmu) {
|
|
92
|
+
assertFiniteNumber(percent, "percent");
|
|
93
|
+
assertFiniteNumber(axisEmu, "axisEmu");
|
|
94
|
+
return inCoordinateRange(Math.round(percent / 100 * axisEmu), percent, "percent");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The single user-coordinate → EMU boundary. Convert each user-supplied coordinate exactly once.
|
|
98
|
+
*
|
|
99
|
+
* Accepts (see {@link Coord}):
|
|
100
|
+
* - a bare `number` → **always inches** (the documented unit); no magnitude guessing
|
|
101
|
+
* - `"<n>%"` → percentage of `axisEmu`
|
|
102
|
+
* - `"<n>in"` / `"<n>pt"` / `"<n>px"` / `"<n>emu"` → explicit units (the escape hatch for non-inch
|
|
103
|
+
* values). `px` is resolved at {@link DEFAULT_PX_PER_INCH} (96), for authoring against a known
|
|
104
|
+
* web/source canvas size.
|
|
105
|
+
*
|
|
106
|
+
* Throws on non-finite or unparseable input rather than silently emitting a degenerate 0-size.
|
|
107
|
+
* @param value - user coordinate
|
|
108
|
+
* @param axisEmu - axis length in EMU, used only to resolve percentages
|
|
109
|
+
*/
|
|
110
|
+
function coordToEmu(value, axisEmu) {
|
|
111
|
+
if (typeof value === "number") {
|
|
112
|
+
assertFiniteNumber(value, "coordinate");
|
|
113
|
+
if (Math.abs(value) > IMPLAUSIBLE_INCHES) warn("coord/bare-number-is-inches", `coordinate ${value} interpreted as ${value} inches. A bare number is always inches; if you meant EMU, pass it as a string like "${Math.round(value)}emu".`);
|
|
114
|
+
return inchesToEmu(value);
|
|
115
|
+
}
|
|
116
|
+
const match = /^\s*(-?\d*\.?\d+)\s*(%|in|pt|px|emu)\s*$/.exec(value);
|
|
117
|
+
if (!match) throw new InvalidOptionError("coord/invalid-format", `Invalid coordinate "${value}". Expected a number (inches) or a string like "50%", "5in", "72pt", "96px", or "914400emu".`);
|
|
118
|
+
const n = Number(match[1]);
|
|
119
|
+
switch (match[2]) {
|
|
120
|
+
case "%": return percentToEmu(n, axisEmu);
|
|
121
|
+
case "in": return inchesToEmu(n);
|
|
122
|
+
case "pt": return pointsToEmu(n);
|
|
123
|
+
case "px": return pixelsToEmu(n, 96);
|
|
124
|
+
default:
|
|
125
|
+
assertFiniteNumber(n, "coordinate");
|
|
126
|
+
return inCoordinateRange(Math.round(n), n, "EMU");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function emuToInches(emu) {
|
|
130
|
+
assertFiniteNumber(emu, "emu");
|
|
131
|
+
return emu / EMU_PER_INCH;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* EMU → points, the unit the write API states line widths, font sizes and text insets in.
|
|
135
|
+
*
|
|
136
|
+
* The one conversion, for the library as well as for a consumer: three private forms of
|
|
137
|
+
* `emu / EMU_PER_POINT` had grown around it — the read model's `null`-propagating `ptFromEmu`,
|
|
138
|
+
* the script mapper's `points`, and a dozen inline divisions — while this stayed published and
|
|
139
|
+
* uncalled.
|
|
140
|
+
*
|
|
141
|
+
* **The policy, and its one exception.** Every EMU→points conversion goes through here or through
|
|
142
|
+
* `ptFromEmu` in `src/read/api/coords.ts`, which is this with a `null` passed along. (Named rather
|
|
143
|
+
* than linked: it is internal, so a reference link to it resolves to nothing in the published
|
|
144
|
+
* reference.) The exception is
|
|
145
|
+
* `measure/*` — `fit.ts`, `paragraphs.ts`, `table-fit.ts` — where an inner box is computed as
|
|
146
|
+
* `(extent - inset - inset) / EMU_PER_POINT` and then guarded with `!(x > 0)`. That guard is
|
|
147
|
+
* written NaN-first on purpose: a box that cannot be measured is skipped, not reported. This
|
|
148
|
+
* function asserts a finite input and throws instead, which is the right answer for a caller
|
|
149
|
+
* stating a value and the wrong one for a pass whose whole job is to degrade quietly. Those
|
|
150
|
+
* sites keep the division; nothing else may.
|
|
151
|
+
*/
|
|
152
|
+
function emuToPoints(emu) {
|
|
153
|
+
assertFiniteNumber(emu, "emu");
|
|
154
|
+
return emu / EMU_PER_POINT;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* EMU → whole pixels at a stated DPI.
|
|
158
|
+
*
|
|
159
|
+
* **Published for consumers, and used nowhere in `src/` on purpose.** Nothing inside the
|
|
160
|
+
* library thinks in pixels: it is the unit a caller placing library output on a canvas or in a
|
|
161
|
+
* `<img>` needs, and the DPI is theirs to choose. Left exported deliberately rather than by
|
|
162
|
+
* oversight — this note is the difference between the two.
|
|
163
|
+
*/
|
|
164
|
+
function emuToPixels(emu, dpi) {
|
|
165
|
+
assertFiniteNumber(emu, "emu");
|
|
166
|
+
assertPositiveFiniteNumber(dpi, "dpi");
|
|
167
|
+
return Math.round(emuToInches(emu) * dpi);
|
|
168
|
+
}
|
|
169
|
+
function standardLayout(layout, name, widthIn, heightIn) {
|
|
170
|
+
return Object.freeze({
|
|
171
|
+
layout,
|
|
172
|
+
name,
|
|
173
|
+
widthIn,
|
|
174
|
+
heightIn,
|
|
175
|
+
widthEmu: inchesToEmu(widthIn),
|
|
176
|
+
heightEmu: inchesToEmu(heightIn)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const STANDARD_LAYOUTS = Object.freeze({
|
|
180
|
+
LAYOUT_4x3: standardLayout("LAYOUT_4x3", "screen4x3", 10, 7.5),
|
|
181
|
+
LAYOUT_16x9: standardLayout("LAYOUT_16x9", "screen16x9", 10, 5.625),
|
|
182
|
+
LAYOUT_16x10: standardLayout("LAYOUT_16x10", "screen16x10", 10, 6.25),
|
|
183
|
+
LAYOUT_WIDE: standardLayout("LAYOUT_WIDE", "custom", 40 / 3, 7.5)
|
|
184
|
+
});
|
|
185
|
+
/**
|
|
186
|
+
* `emu` as an `Emu`, or a `coord/out-of-range` throw when it falls outside `ST_Coordinate`.
|
|
187
|
+
*
|
|
188
|
+
* A finite input is not enough on its own. `1e16` inches is finite and converts to `9.144e+21`,
|
|
189
|
+
* which serializes in exponent notation and is not an `xsd:long` at all; `4e7` inches converts to
|
|
190
|
+
* a long, but one past the bound. Neither is a coordinate PowerPoint can hold.
|
|
191
|
+
* @param emu - the converted value
|
|
192
|
+
* @param value - the caller's value, for the message
|
|
193
|
+
* @param unit - the unit `value` was stated in, for the message
|
|
194
|
+
*/
|
|
195
|
+
function inCoordinateRange(emu, value, unit) {
|
|
196
|
+
if (emu < -27273042329600 || emu > 27273042316900) throw new InvalidOptionError("coord/out-of-range", `${value} ${unit} is ${emu} EMU, outside the DrawingML coordinate range ${MIN_COORDINATE_EMU} to ${MAX_COORDINATE_EMU} EMU.`);
|
|
197
|
+
return emu;
|
|
198
|
+
}
|
|
199
|
+
function assertFiniteNumber(value, name) {
|
|
200
|
+
if (!Number.isFinite(value)) throw new InvalidOptionError("coord/non-finite", `${name} must be a finite number`);
|
|
201
|
+
}
|
|
202
|
+
function assertPositiveFiniteNumber(value, name) {
|
|
203
|
+
assertFiniteNumber(value, name);
|
|
204
|
+
if (value <= 0) throw new InvalidOptionError("coord/not-positive", `${name} must be greater than 0`);
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
3
207
|
//#region src/enums.ts
|
|
4
208
|
let TextAnchor = /* @__PURE__ */ function(TextAnchor) {
|
|
5
209
|
TextAnchor["b"] = "b";
|
|
@@ -241,6 +445,13 @@ let AlignH = /* @__PURE__ */ function(AlignH) {
|
|
|
241
445
|
AlignH["justify"] = "justify";
|
|
242
446
|
return AlignH;
|
|
243
447
|
}({});
|
|
448
|
+
/**
|
|
449
|
+
* @deprecated The enum form of `VAlign`, which no option actually takes. Use the `VAlign`
|
|
450
|
+
* string union (`'top' | 'middle' | 'bottom'`) or, for a text body's own anchoring,
|
|
451
|
+
* {@link TextAnchor}. Unlike its sibling {@link AlignH} — which `TextPropsOptions.align`
|
|
452
|
+
* really is typed as — nothing in the library reads this, so it is a third spelling of a
|
|
453
|
+
* two-spelling fact. It will be removed in the next major.
|
|
454
|
+
*/
|
|
244
455
|
let AlignV = /* @__PURE__ */ function(AlignV) {
|
|
245
456
|
AlignV["top"] = "top";
|
|
246
457
|
AlignV["middle"] = "middle";
|
|
@@ -344,6 +555,11 @@ let SlideObjectType = /* @__PURE__ */ function(SlideObjectType) {
|
|
|
344
555
|
* Maps a friendly `ConnectorType` to its OOXML connector preset *family*. `straight`
|
|
345
556
|
* has a single fixed preset; `elbow` and `curved` select a member by bend count
|
|
346
557
|
* (`bentConnector{3,4,5}` / `curvedConnector{3,4,5}`) — see `connectorPresetFor`.
|
|
558
|
+
*
|
|
559
|
+
* Not exported: `connectorPresetFor`, eleven lines below, is its only reader, and
|
|
560
|
+
* `docs/contributing/architecture.md` puts internal OOXML generators off the published surface unless
|
|
561
|
+
* deliberately exposed. Callers name a connector by its `ConnectorType`, or by the
|
|
562
|
+
* {@link CONNECTOR_PRESET_NAME} the function returns.
|
|
347
563
|
*/
|
|
348
564
|
const CONNECTOR_PRESETS = {
|
|
349
565
|
straight: "straightConnector1",
|
|
@@ -474,280 +690,26 @@ let TableStyle = /* @__PURE__ */ function(TableStyle) {
|
|
|
474
690
|
return TableStyle;
|
|
475
691
|
}({});
|
|
476
692
|
//#endregion
|
|
477
|
-
//#region src/
|
|
478
|
-
const LAYOUT_IDX_SERIES_BASE = 2147483649;
|
|
479
|
-
const REGEX_HEX_COLOR = /^[0-9a-fA-F]{6}$/;
|
|
480
|
-
const LINEH_MODIFIER = 1.67;
|
|
481
|
-
const DEF_CELL_BORDER = {
|
|
482
|
-
type: "solid",
|
|
483
|
-
color: "666666",
|
|
484
|
-
width: 1
|
|
485
|
-
};
|
|
486
|
-
const DEF_CELL_MARGIN_IN = [
|
|
487
|
-
.05,
|
|
488
|
-
.1,
|
|
489
|
-
.05,
|
|
490
|
-
.1
|
|
491
|
-
];
|
|
492
|
-
const DEF_CHART_BORDER = {
|
|
493
|
-
type: "solid",
|
|
494
|
-
color: "363636",
|
|
495
|
-
width: 1
|
|
496
|
-
};
|
|
497
|
-
const DEF_CHART_GRIDLINE = {
|
|
498
|
-
color: "888888",
|
|
499
|
-
style: "solid",
|
|
500
|
-
size: 1,
|
|
501
|
-
cap: "flat"
|
|
502
|
-
};
|
|
503
|
-
const DEF_FONT_COLOR = "000000";
|
|
504
|
-
const DEF_PRES_LAYOUT = "LAYOUT_16x9";
|
|
505
|
-
const DEF_PRES_LAYOUT_NAME = "DEFAULT";
|
|
506
|
-
const DEF_SHAPE_LINE_COLOR = "333333";
|
|
507
|
-
const DEF_SHAPE_SHADOW = {
|
|
508
|
-
type: "outer",
|
|
509
|
-
blur: 3,
|
|
510
|
-
offset: 23e3 / 12700,
|
|
511
|
-
angle: 90,
|
|
512
|
-
color: "000000",
|
|
513
|
-
_alpha: .35,
|
|
514
|
-
rotateWithShape: true
|
|
515
|
-
};
|
|
516
|
-
const DEF_SLIDE_MARGIN_IN = [
|
|
517
|
-
.5,
|
|
518
|
-
.5,
|
|
519
|
-
.5,
|
|
520
|
-
.5
|
|
521
|
-
];
|
|
522
|
-
const DEF_TEXT_SHADOW = {
|
|
523
|
-
type: "outer",
|
|
524
|
-
blur: 8,
|
|
525
|
-
offset: 4,
|
|
526
|
-
angle: 270,
|
|
527
|
-
color: "000000",
|
|
528
|
-
_alpha: .75
|
|
529
|
-
};
|
|
530
|
-
const DEF_TEXT_GLOW = {
|
|
531
|
-
size: 8,
|
|
532
|
-
color: "FFFFFF",
|
|
533
|
-
opacity: .75
|
|
534
|
-
};
|
|
535
|
-
const AXIS_ID_VALUE_PRIMARY = "2094734552";
|
|
536
|
-
const AXIS_ID_VALUE_SECONDARY = "2094734553";
|
|
537
|
-
const AXIS_ID_CATEGORY_PRIMARY = "2094734554";
|
|
538
|
-
const AXIS_ID_CATEGORY_SECONDARY = "2094734555";
|
|
539
|
-
const AXIS_ID_SERIES_PRIMARY = "2094734556";
|
|
540
|
-
const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
541
|
-
const BARCHART_COLORS = [
|
|
542
|
-
"C0504D",
|
|
543
|
-
"4F81BD",
|
|
544
|
-
"9BBB59",
|
|
545
|
-
"8064A2",
|
|
546
|
-
"4BACC6",
|
|
547
|
-
"F79646",
|
|
548
|
-
"628FC6",
|
|
549
|
-
"C86360"
|
|
550
|
-
];
|
|
551
|
-
const PIECHART_COLORS = [
|
|
552
|
-
"5DA5DA",
|
|
553
|
-
"FAA43A",
|
|
554
|
-
"60BD68",
|
|
555
|
-
"F17CB0",
|
|
556
|
-
"B2912F",
|
|
557
|
-
"B276B2",
|
|
558
|
-
"DECF3F",
|
|
559
|
-
"F15854",
|
|
560
|
-
"A7A7A7"
|
|
561
|
-
];
|
|
562
|
-
const SLDNUMFLDID = "{F7021451-1387-4CA6-816F-3879F97B5CBC}";
|
|
563
|
-
const SLDNUM_PLACEHOLDER_TEXT = "‹#›";
|
|
564
|
-
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
|
|
565
|
-
//#endregion
|
|
566
|
-
//#region src/units-internal.ts
|
|
693
|
+
//#region src/ooxml/table-cell-margins.ts
|
|
567
694
|
/**
|
|
568
|
-
*
|
|
695
|
+
* A table cell's default text insets in EMU: the schema defaults of `a:tcPr/@marL`, `@marR`
|
|
696
|
+
* (91440, 0.1in) and `@marT`, `@marB` (45720, 0.05in) on `CT_TableCellProperties`.
|
|
569
697
|
*
|
|
570
|
-
* `
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* authoring API has always accepted (numeric strings, `"5in"`, `null`), that clamp to the
|
|
574
|
-
* ranges PowerPoint will load without offering to repair the file, and that warn about legacy
|
|
575
|
-
* inputs instead of failing.
|
|
698
|
+
* Unlike the body insets in `body-insets.ts` these are real XSD defaults, so they are transcribed
|
|
699
|
+
* from the schema rather than derived. A cell that states one side leaves the other three at these
|
|
700
|
+
* values, not at zero.
|
|
576
701
|
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*/
|
|
581
|
-
/**
|
|
582
|
-
* Resolve a user `Coord` (x/y/w/h) to EMU — the single user-coordinate → EMU boundary.
|
|
583
|
-
* - bare `number` → **inches** (no magnitude guessing); `"<n>%"` → percent of the slide axis;
|
|
584
|
-
* `"<n>in"`/`"<n>pt"`/`"<n>emu"` → explicit units (see {@link Coord} / {@link coordToEmu})
|
|
585
|
-
* - `null`/`undefined` → 0 (callers may omit a coordinate)
|
|
586
|
-
* - throws on a non-finite number rather than silently collapsing the object to zero size
|
|
587
|
-
* @param {Coord|null|undefined} size - user coordinate
|
|
588
|
-
* @param {'X' | 'Y'} xyDir - axis (selects slide width vs height for percentages)
|
|
589
|
-
* @param {PresLayout} layout - presentation layout (EMU dimensions)
|
|
590
|
-
* @returns {Emu} resolved EMU value
|
|
591
|
-
*/
|
|
592
|
-
function getSmartParseNumber(size, xyDir, layout) {
|
|
593
|
-
if (size === null || size === void 0) return 0;
|
|
594
|
-
if (typeof size === "number" && !isFinite(size)) throw new InvalidOptionError("coord/non-finite", `Invalid ${xyDir || "coordinate"} value: expected a finite number but received ${String(size)}. This usually means a layout dimension was read from a missing property (e.g. \`layout.width\` returning \`undefined\`). Use \`slide.width\`/\`slide.height\` or \`STANDARD_LAYOUTS.<NAME>.width\`/\`.height\` (inches).`);
|
|
595
|
-
return coordToEmu(size, xyDir === "Y" ? layout.height : layout.width);
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Convert inches into EMU.
|
|
599
|
-
* - accepts a number (inches) or a numeric/`"<n>in"` string
|
|
600
|
-
* - no magnitude guessing: values are always treated as inches (use {@link coordToEmu} for
|
|
601
|
-
* user coordinates that may carry other units)
|
|
602
|
-
* @param {number|string} inches - inches as number or string
|
|
603
|
-
* @returns {Emu} EMU value
|
|
702
|
+
* A module of its own, importing nothing, because `constants-internal.ts` derives the write path's
|
|
703
|
+
* inch defaults from it and is reached by every entry. Taken from `body-insets.ts`, the record
|
|
704
|
+
* brought that module's other exports into the read entry with it.
|
|
604
705
|
*/
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
* inset) to EMU.
|
|
612
|
-
*
|
|
613
|
-
* Margins are INCHES, consistent with the positional API (`x`/`y`/`w`/`h`) and the value
|
|
614
|
-
* PowerPoint's own dialog shows (both the table cell-margin and the text-box internal-margin
|
|
615
|
-
* fields are inches). Historically the library read these as POINTS (table cells used a magnitude
|
|
616
|
-
* heuristic — `>= 1` points, `< 1` inches; text-box margins were straight points), so a legitimate
|
|
617
|
-
* fraction-of-an-inch value entered from the PowerPoint dialog became a tiny points value. Every
|
|
618
|
-
* value is now inches. A `>= 1` value is honored as inches but warns once, because it is almost
|
|
619
|
-
* certainly a legacy points value that should be divided by 72 (e.g. `10` points → `0.139` inches).
|
|
620
|
-
*
|
|
621
|
-
* Shared by every margin site so they stay in lockstep: the cell XML emitter and text-box/slide-
|
|
622
|
-
* number insets (`gen/slide/object.ts`), the autoPage row-height pass (`gen/table/autopage.ts`), and the measured-fit pass
|
|
623
|
-
* (`measure-fit`).
|
|
624
|
-
* @param {number} inches - margin component in inches
|
|
625
|
-
* @returns {Emu} EMU value
|
|
626
|
-
*/
|
|
627
|
-
function marginToEmu(inches) {
|
|
628
|
-
if (inches >= 1) warnOnce("margin/legacy-points", "margins (table cell and text-box) are interpreted as inches (matching the rest of the API and the PowerPoint dialog); a value >= 1 is likely a legacy points value — divide by 72 to convert (e.g. 10pt => 0.139in).");
|
|
629
|
-
return inch2Emu(inches);
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Resolve a table's column widths to EMU, the single source of truth shared by the
|
|
633
|
-
* table XML emitter and the measured-fit pass (so a fitted cell sees the same grid
|
|
634
|
-
* the renderer draws).
|
|
635
|
-
* - an explicit `colW` **array** is per-column inches (`inch2Emu`); a non-finite slot
|
|
636
|
-
* falls back to the even-distribution width
|
|
637
|
-
* - otherwise the table's already-resolved width (`totalWidthEmu`, EMU) is split evenly
|
|
638
|
-
* across `colCount` columns. (A scalar `colW` never reaches here — `addTableDefinition`
|
|
639
|
-
* converts it to `w` and clears `colW`.)
|
|
640
|
-
*
|
|
641
|
-
* IMPORTANT: the even path divides an **EMU** width. Passing the raw inches `options.w`
|
|
642
|
-
* instead (the historical bug) produced ~0-EMU columns (e.g. `w=9` → `gridCol w="3"`),
|
|
643
|
-
* collapsing auto-width tables to a sliver in PowerPoint/LibreOffice.
|
|
644
|
-
* @param {Coord[]|Coord|undefined} colW - explicit per-column inches, or scalar/undefined
|
|
645
|
-
* @param {number} totalWidthEmu - the table's resolved width in EMU
|
|
646
|
-
* @param {number} colCount - number of grid columns (counting colspans)
|
|
647
|
-
* @returns {number[]} per-column widths in EMU (length `colCount`)
|
|
648
|
-
*/
|
|
649
|
-
function resolveTableColWidthsEmu(colW, totalWidthEmu, colCount) {
|
|
650
|
-
if (!(colCount > 0)) return [];
|
|
651
|
-
const even = totalWidthEmu > 0 ? Math.round(totalWidthEmu / colCount) : EMU_PER_INCH;
|
|
652
|
-
if (Array.isArray(colW)) return Array.from({ length: colCount }, (_, i) => {
|
|
653
|
-
const n = colW[i];
|
|
654
|
-
return typeof n === "number" && Number.isFinite(n) ? Math.round(inch2Emu(n)) : even;
|
|
655
|
-
});
|
|
656
|
-
return new Array(colCount).fill(even);
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Convert points to EMU, leniently: anything that does not read as a finite number — a `NaN`,
|
|
660
|
-
* an `Infinity`, a non-numeric string, `null` — becomes `0` rather than throwing.
|
|
661
|
-
*
|
|
662
|
-
* That is the whole difference from {@link pointsToEmu} in `units.ts`, which throws on the same
|
|
663
|
-
* input. Emitters use this one for the many optional size/width/offset options where a missing
|
|
664
|
-
* or malformed value should collapse the feature (a zero-width line, no shadow offset) rather
|
|
665
|
-
* than take the whole deck down.
|
|
666
|
-
*
|
|
667
|
-
* @param pt - points, as a number or a numeric string
|
|
668
|
-
* @returns the value in EMU, or `0` if it does not read as a finite number
|
|
669
|
-
*/
|
|
670
|
-
function ptsToEmuLenient(pt) {
|
|
671
|
-
const points = Number(pt);
|
|
672
|
-
return Number.isFinite(points) ? Math.round(points * EMU_PER_POINT) : 0;
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Convert a transparency percentage (0-100) into a schema-valid `<a:alpha>` value
|
|
676
|
-
* (ST_PositiveFixedPercentage, 0-100000). Out-of-range transparency yields an
|
|
677
|
-
* alpha that PowerPoint rejects as needing repair, so clamp into range and warn.
|
|
678
|
-
*/
|
|
679
|
-
function transparencyToAlpha(transparency) {
|
|
680
|
-
const pct = Math.min(100, Math.max(0, transparency));
|
|
681
|
-
if (pct !== transparency) warn("transparency/out-of-range", `transparency ${transparency} is outside the valid range 0-100; using ${pct}.`);
|
|
682
|
-
return Math.round((100 - pct) * FIXED_PCT_PER_PERCENT);
|
|
683
|
-
}
|
|
684
|
-
/** Convert an opacity (0-1) into a schema-valid `<a:alpha>` value (0-100000); clamps + warns on out-of-range input. */
|
|
685
|
-
function opacityToAlpha(opacity) {
|
|
686
|
-
const o = Math.min(1, Math.max(0, opacity));
|
|
687
|
-
if (o !== opacity) warn("opacity/out-of-range", `opacity ${opacity} is outside the valid range 0-1; using ${o}.`);
|
|
688
|
-
return Math.round(o * PERCENT_SCALE);
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Convert a line width (points) to EMU clamped into ST_LineWidth (0..20116800 EMU,
|
|
692
|
-
* i.e. 0-1584pt). Out-of-range widths make PowerPoint report the package as needing
|
|
693
|
-
* repair, so clamp into range and warn.
|
|
694
|
-
*/
|
|
695
|
-
function lineWidthToEmu(widthPts) {
|
|
696
|
-
const raw = ptsToEmuLenient(widthPts);
|
|
697
|
-
const clamped = Math.min(20116800, Math.max(0, raw));
|
|
698
|
-
if (clamped !== raw) warn("line/width-out-of-range", `line width ${widthPts} is outside the valid range 0-1584pt; using ${clamped / EMU_PER_POINT}.`);
|
|
699
|
-
return clamped;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Convert degrees to a DrawingML angle (60000ths of a degree), **without** wrapping.
|
|
703
|
-
*
|
|
704
|
-
* Most angles in the format are not modular: a connection site at 400 degrees, a polar adjust
|
|
705
|
-
* handle whose range runs to 540, an arc that sweeps 400 degrees — each means something a
|
|
706
|
-
* reduction into 0..360 would destroy. Use this for those, and {@link convertRotationDegrees}
|
|
707
|
-
* for the ones that genuinely are a rotation.
|
|
708
|
-
*
|
|
709
|
-
* Non-finite input throws rather than reaching the attribute: `Math.round(Infinity * 60000)` is
|
|
710
|
-
* `Infinity`, which serializes as `ang="Infinity"` and makes PowerPoint offer to repair the file.
|
|
711
|
-
*
|
|
712
|
-
* @param d - degrees
|
|
713
|
-
* @param what - what is being converted, for the error message
|
|
714
|
-
* @param code - diagnostic code to throw under, where a caller has a more specific one
|
|
715
|
-
*/
|
|
716
|
-
function convertAngleUnits(d, what, code = "coord/non-finite") {
|
|
717
|
-
assertFiniteDegrees(d, what, code);
|
|
718
|
-
return Math.round(d * ANGLE_UNITS_PER_DEGREE);
|
|
719
|
-
}
|
|
720
|
-
function assertFiniteDegrees(d, what, code) {
|
|
721
|
-
if (typeof d !== "number" || !Number.isFinite(d)) throw new InvalidOptionError(code, `${what} must be a finite number of degrees; received ${String(d)}.`);
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Convert a shape or gradient rotation (degrees) to a DrawingML angle (60000ths of a degree).
|
|
725
|
-
*
|
|
726
|
-
* A rotation *is* modular — 800 degrees and 80 degrees point the same way — so the value is
|
|
727
|
-
* reduced with `% 360`. The reduction keeps the sign: `-45` stays `-45` rather than becoming
|
|
728
|
-
* `315`, because both are valid `ST_Angle`, PowerPoint writes negative rotations itself, and
|
|
729
|
-
* the read side reports back what was authored. Only an input outside -360..360 moves.
|
|
730
|
-
*
|
|
731
|
-
* @param d - degrees
|
|
732
|
-
* @returns the `rot` value in 60000ths of a degree
|
|
733
|
-
*/
|
|
734
|
-
function convertRotationDegrees(d) {
|
|
735
|
-
const degrees = d || 0;
|
|
736
|
-
assertFiniteDegrees(degrees, "rotation", "coord/non-finite");
|
|
737
|
-
return Math.round(degrees % 360 * ANGLE_UNITS_PER_DEGREE);
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Convert a freeform arc angle (degrees) to an `<a:arcTo>` ST_AdjAngle value (60000ths).
|
|
741
|
-
* Unlike a shape rotation, a sweep is not modular: a 400 degree swAng draws a different
|
|
742
|
-
* arc than a 40 degree one, so the value is never wrapped into 0..360.
|
|
743
|
-
* @param {number} d degrees
|
|
744
|
-
* @param {'stAng' | 'swAng'} attr - attribute being emitted, for the error message
|
|
745
|
-
* @returns {number} ST_AdjAngle value (60000ths of a degree)
|
|
746
|
-
*/
|
|
747
|
-
function convertArcAngle(d, attr) {
|
|
748
|
-
return convertAngleUnits(d, `Arc ${attr}`, "geometry/arc-angle-non-finite");
|
|
749
|
-
}
|
|
706
|
+
const TABLE_CELL_MARGIN_DEFAULTS_EMU = {
|
|
707
|
+
left: 91440,
|
|
708
|
+
right: 91440,
|
|
709
|
+
top: 45720,
|
|
710
|
+
bottom: 45720
|
|
711
|
+
};
|
|
750
712
|
//#endregion
|
|
751
|
-
export {
|
|
713
|
+
export { inchesToEmu as A, MIN_COORDINATE_EMU as C, emuToInches as D, coordToEmu as E, EMU_PER_INCH as F, EMU_PER_POINT as I, POINTS_PER_INCH as L, pixelsToEmu as M, pointsToEmu as N, emuToPixels as O, ptToHundredths as P, MAX_COORDINATE_EMU as S, STANDARD_LAYOUTS as T, isChartType as _, ChartType as a, FIXED_PCT_PER_PERCENT as b, SchemeColor as c, TableStyle as d, TextAnchor as f, isChartExType as g, connectorPresetFor as h, BulletType as i, percentToEmu as j, emuToPoints as k, ShapeType as l, asChartType as m, AlignH as n, OutputType as o, VALID_SHAPE_PRESETS as p, AlignV as r, PlaceholderType as s, TABLE_CELL_MARGIN_DEFAULTS_EMU as t, SlideObjectType as u, ANGLE_UNITS_PER_DEGREE as v, PERCENT_SCALE as w, HUNDREDTHS_PER_POINT as x, DEFAULT_PX_PER_INCH as y };
|
|
752
714
|
|
|
753
|
-
//# sourceMappingURL=
|
|
715
|
+
//# sourceMappingURL=table-cell-margins-EVg0EwxT.js.map
|