ppt-codec 1.0.2 → 1.1.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 +142 -38
- package/dist/content-write.cjs +114 -0
- package/dist/content-write.d.cts +11 -0
- package/dist/content-write.d.ts +11 -0
- package/dist/content-write.js +112 -0
- package/dist/content.cjs +22 -2
- package/dist/content.js +22 -2
- package/dist/document/color-scheme-write.cjs +57 -0
- package/dist/document/color-scheme-write.d.cts +4 -0
- package/dist/document/color-scheme-write.d.ts +4 -0
- package/dist/document/color-scheme-write.js +56 -0
- package/dist/document/document-atom-write.cjs +12 -0
- package/dist/document/document-atom-write.d.cts +5 -0
- package/dist/document/document-atom-write.d.ts +5 -0
- package/dist/document/document-atom-write.js +11 -0
- package/dist/document/fonts-write.cjs +17 -0
- package/dist/document/fonts-write.d.cts +4 -0
- package/dist/document/fonts-write.d.ts +4 -0
- package/dist/document/fonts-write.js +16 -0
- package/dist/document/master-write.cjs +128 -0
- package/dist/document/master-write.d.cts +15 -0
- package/dist/document/master-write.d.ts +15 -0
- package/dist/document/master-write.js +123 -0
- package/dist/document/notes-list-write.cjs +12 -0
- package/dist/document/notes-list-write.d.cts +5 -0
- package/dist/document/notes-list-write.d.ts +5 -0
- package/dist/document/notes-list-write.js +11 -0
- package/dist/document/notes-list.cjs +22 -0
- package/dist/document/notes-list.d.cts +9 -0
- package/dist/document/notes-list.d.ts +9 -0
- package/dist/document/notes-list.js +21 -0
- package/dist/document/notes-write.cjs +43 -0
- package/dist/document/notes-write.d.cts +6 -0
- package/dist/document/notes-write.d.ts +6 -0
- package/dist/document/notes-write.js +41 -0
- package/dist/document/notes.cjs +41 -0
- package/dist/document/notes.d.cts +12 -0
- package/dist/document/notes.d.ts +12 -0
- package/dist/document/notes.js +37 -0
- package/dist/document/slide-list-write.cjs +12 -0
- package/dist/document/slide-list-write.d.cts +8 -0
- package/dist/document/slide-list-write.d.ts +8 -0
- package/dist/document/slide-list-write.js +11 -0
- package/dist/drawing/shapes-write.cjs +60 -0
- package/dist/drawing/shapes-write.d.cts +10 -0
- package/dist/drawing/shapes-write.d.ts +10 -0
- package/dist/drawing/shapes-write.js +58 -0
- package/dist/errors.cjs +7 -0
- package/dist/errors.d.cts +4 -1
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +7 -1
- package/dist/index.cjs +112 -3
- package/dist/index.d.cts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +25 -8
- package/dist/metadata.cjs +14 -0
- package/dist/metadata.d.cts +6 -0
- package/dist/metadata.d.ts +6 -0
- package/dist/metadata.js +13 -0
- package/dist/read.cjs +33 -8
- package/dist/read.d.cts +5 -1
- package/dist/read.d.ts +5 -1
- package/dist/read.js +32 -10
- package/dist/record/types.cjs +8 -0
- package/dist/record/types.d.cts +5 -1
- package/dist/record/types.d.ts +5 -1
- package/dist/record/types.js +5 -1
- package/dist/record/write.cjs +75 -0
- package/dist/record/write.d.cts +17 -0
- package/dist/record/write.d.ts +17 -0
- package/dist/record/write.js +65 -0
- package/dist/stream/current-user-write.cjs +13 -0
- package/dist/stream/current-user-write.d.cts +4 -0
- package/dist/stream/current-user-write.d.ts +4 -0
- package/dist/stream/current-user-write.js +12 -0
- package/dist/stream/current-user.cjs +7 -5
- package/dist/stream/current-user.d.cts +3 -1
- package/dist/stream/current-user.d.ts +3 -1
- package/dist/stream/current-user.js +6 -6
- package/dist/stream/persist-write.cjs +14 -0
- package/dist/stream/persist-write.d.cts +16 -0
- package/dist/stream/persist-write.d.ts +16 -0
- package/dist/stream/persist-write.js +12 -0
- package/dist/text/style-write.cjs +79 -0
- package/dist/text/style-write.d.cts +5 -0
- package/dist/text/style-write.d.ts +5 -0
- package/dist/text/style-write.js +78 -0
- package/dist/text/style.cjs +85 -30
- package/dist/text/style.d.cts +50 -1
- package/dist/text/style.d.ts +50 -1
- package/dist/text/style.js +44 -31
- package/dist/units.cjs +4 -0
- package/dist/units.d.cts +2 -1
- package/dist/units.d.ts +2 -1
- package/dist/units.js +4 -1
- package/dist/write.cjs +145 -0
- package/dist/write.d.cts +11 -0
- package/dist/write.d.ts +11 -0
- package/dist/write.js +142 -0
- package/package.json +4 -4
package/dist/content.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_text_atoms = require("./text/atoms.cjs");
|
|
3
2
|
require("./text/style.cjs");
|
|
3
|
+
const require_text_atoms = require("./text/atoms.cjs");
|
|
4
|
+
const require_units = require("./units.cjs");
|
|
4
5
|
//#region src/content.ts
|
|
5
6
|
const BYTE_MAX = 255;
|
|
6
7
|
function mapAlignment(alignment) {
|
|
@@ -12,6 +13,20 @@ function mapAlignment(alignment) {
|
|
|
12
13
|
default: return;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
16
|
+
/** ParaSpacing's own percentage form (0-13200, value/100 = percent of line height) is the only one document-schema.js's lineSpacing (a plain multiple of single line height) can express -- the negative, absolute-master-units form has no multiplier to convert to without knowing the paragraph's actual rendered line height, so it maps to nothing rather than a guess. */
|
|
17
|
+
function paraSpacingToLineSpacing(raw) {
|
|
18
|
+
if (raw === void 0 || raw < 0) return;
|
|
19
|
+
return raw / 100;
|
|
20
|
+
}
|
|
21
|
+
/** ParaSpacing's own negative (absolute master-units) form is the only one document-schema.js's spacingBeforePt/spacingAfterPt (plain points) can express -- the positive percentage-of-line-height form has no point value to convert to without knowing the actual rendered line height, so it maps to nothing rather than a guess. */
|
|
22
|
+
function paraSpacingToPoints(raw) {
|
|
23
|
+
if (raw === void 0 || raw >= 0) return;
|
|
24
|
+
return require_units.masterUnitsToPoints(-raw);
|
|
25
|
+
}
|
|
26
|
+
/** MarginOrIndent is always an absolute signed master-unit offset, with no percentage form to disambiguate -- unlike ParaSpacing, every value converts cleanly. */
|
|
27
|
+
function marginOrIndentToPoints(raw) {
|
|
28
|
+
return raw === void 0 ? void 0 : require_units.masterUnitsToPoints(raw);
|
|
29
|
+
}
|
|
15
30
|
function mapColor(color) {
|
|
16
31
|
if (color === void 0) return;
|
|
17
32
|
return {
|
|
@@ -64,7 +79,12 @@ function buildParagraphs(text, style, fontNames) {
|
|
|
64
79
|
kind: "paragraph",
|
|
65
80
|
runs,
|
|
66
81
|
alignment,
|
|
67
|
-
list: indentLevel > 0 ? { level: indentLevel } : void 0
|
|
82
|
+
list: indentLevel > 0 ? { level: indentLevel } : void 0,
|
|
83
|
+
spacingBeforePt: paraSpacingToPoints(paragraphProperties?.spaceBefore),
|
|
84
|
+
spacingAfterPt: paraSpacingToPoints(paragraphProperties?.spaceAfter),
|
|
85
|
+
lineSpacing: paraSpacingToLineSpacing(paragraphProperties?.lineSpacing),
|
|
86
|
+
indentLeftPt: marginOrIndentToPoints(paragraphProperties?.leftMargin),
|
|
87
|
+
indentFirstLinePt: marginOrIndentToPoints(paragraphProperties?.indent)
|
|
68
88
|
};
|
|
69
89
|
});
|
|
70
90
|
}
|
package/dist/content.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { splitParagraphs } from "./text/atoms.js";
|
|
2
1
|
import "./text/style.js";
|
|
2
|
+
import { splitParagraphs } from "./text/atoms.js";
|
|
3
|
+
import { masterUnitsToPoints } from "./units.js";
|
|
3
4
|
//#region src/content.ts
|
|
4
5
|
const BYTE_MAX = 255;
|
|
5
6
|
function mapAlignment(alignment) {
|
|
@@ -11,6 +12,20 @@ function mapAlignment(alignment) {
|
|
|
11
12
|
default: return;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
/** ParaSpacing's own percentage form (0-13200, value/100 = percent of line height) is the only one document-schema.js's lineSpacing (a plain multiple of single line height) can express -- the negative, absolute-master-units form has no multiplier to convert to without knowing the paragraph's actual rendered line height, so it maps to nothing rather than a guess. */
|
|
16
|
+
function paraSpacingToLineSpacing(raw) {
|
|
17
|
+
if (raw === void 0 || raw < 0) return;
|
|
18
|
+
return raw / 100;
|
|
19
|
+
}
|
|
20
|
+
/** ParaSpacing's own negative (absolute master-units) form is the only one document-schema.js's spacingBeforePt/spacingAfterPt (plain points) can express -- the positive percentage-of-line-height form has no point value to convert to without knowing the actual rendered line height, so it maps to nothing rather than a guess. */
|
|
21
|
+
function paraSpacingToPoints(raw) {
|
|
22
|
+
if (raw === void 0 || raw >= 0) return;
|
|
23
|
+
return masterUnitsToPoints(-raw);
|
|
24
|
+
}
|
|
25
|
+
/** MarginOrIndent is always an absolute signed master-unit offset, with no percentage form to disambiguate -- unlike ParaSpacing, every value converts cleanly. */
|
|
26
|
+
function marginOrIndentToPoints(raw) {
|
|
27
|
+
return raw === void 0 ? void 0 : masterUnitsToPoints(raw);
|
|
28
|
+
}
|
|
14
29
|
function mapColor(color) {
|
|
15
30
|
if (color === void 0) return;
|
|
16
31
|
return {
|
|
@@ -63,7 +78,12 @@ function buildParagraphs(text, style, fontNames) {
|
|
|
63
78
|
kind: "paragraph",
|
|
64
79
|
runs,
|
|
65
80
|
alignment,
|
|
66
|
-
list: indentLevel > 0 ? { level: indentLevel } : void 0
|
|
81
|
+
list: indentLevel > 0 ? { level: indentLevel } : void 0,
|
|
82
|
+
spacingBeforePt: paraSpacingToPoints(paragraphProperties?.spaceBefore),
|
|
83
|
+
spacingAfterPt: paraSpacingToPoints(paragraphProperties?.spaceAfter),
|
|
84
|
+
lineSpacing: paraSpacingToLineSpacing(paragraphProperties?.lineSpacing),
|
|
85
|
+
indentLeftPt: marginOrIndentToPoints(paragraphProperties?.leftMargin),
|
|
86
|
+
indentFirstLinePt: marginOrIndentToPoints(paragraphProperties?.indent)
|
|
67
87
|
};
|
|
68
88
|
});
|
|
69
89
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record_types = require("../record/types.cjs");
|
|
3
|
+
const require_record_write = require("../record/write.cjs");
|
|
4
|
+
//#region src/document/color-scheme-write.ts
|
|
5
|
+
const DEFAULT_SCHEME_COLORS = [
|
|
6
|
+
[
|
|
7
|
+
255,
|
|
8
|
+
255,
|
|
9
|
+
255
|
|
10
|
+
],
|
|
11
|
+
[
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
0
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
128,
|
|
18
|
+
128,
|
|
19
|
+
128
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
0,
|
|
23
|
+
0,
|
|
24
|
+
0
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
187,
|
|
28
|
+
224,
|
|
29
|
+
227
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
51,
|
|
33
|
+
51,
|
|
34
|
+
153
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
0,
|
|
38
|
+
0,
|
|
39
|
+
204
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
128,
|
|
43
|
+
0,
|
|
44
|
+
128
|
|
45
|
+
]
|
|
46
|
+
];
|
|
47
|
+
const SLIDE_SCHEME_REC_INSTANCE = 1;
|
|
48
|
+
function writeSlideSchemeColorSchemeAtom() {
|
|
49
|
+
return require_record_write.writeAtom(require_record_types.RT_ColorSchemeAtom, require_record_write.concatBytes(...DEFAULT_SCHEME_COLORS.map(([red, green, blue]) => new Uint8Array([
|
|
50
|
+
red,
|
|
51
|
+
green,
|
|
52
|
+
blue,
|
|
53
|
+
0
|
|
54
|
+
]))), { recInstance: SLIDE_SCHEME_REC_INSTANCE });
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.writeSlideSchemeColorSchemeAtom = writeSlideSchemeColorSchemeAtom;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RT_ColorSchemeAtom } from "../record/types.js";
|
|
2
|
+
import { concatBytes, writeAtom } from "../record/write.js";
|
|
3
|
+
//#region src/document/color-scheme-write.ts
|
|
4
|
+
const DEFAULT_SCHEME_COLORS = [
|
|
5
|
+
[
|
|
6
|
+
255,
|
|
7
|
+
255,
|
|
8
|
+
255
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
0,
|
|
12
|
+
0,
|
|
13
|
+
0
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
128,
|
|
17
|
+
128,
|
|
18
|
+
128
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
187,
|
|
27
|
+
224,
|
|
28
|
+
227
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
51,
|
|
32
|
+
51,
|
|
33
|
+
153
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
204
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
128,
|
|
42
|
+
0,
|
|
43
|
+
128
|
|
44
|
+
]
|
|
45
|
+
];
|
|
46
|
+
const SLIDE_SCHEME_REC_INSTANCE = 1;
|
|
47
|
+
function writeSlideSchemeColorSchemeAtom() {
|
|
48
|
+
return writeAtom(RT_ColorSchemeAtom, concatBytes(...DEFAULT_SCHEME_COLORS.map(([red, green, blue]) => new Uint8Array([
|
|
49
|
+
red,
|
|
50
|
+
green,
|
|
51
|
+
blue,
|
|
52
|
+
0
|
|
53
|
+
]))), { recInstance: SLIDE_SCHEME_REC_INSTANCE });
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { writeSlideSchemeColorSchemeAtom };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record_types = require("../record/types.cjs");
|
|
3
|
+
const require_units = require("../units.cjs");
|
|
4
|
+
const require_record_write = require("../record/write.cjs");
|
|
5
|
+
//#region src/document/document-atom-write.ts
|
|
6
|
+
function writeDocumentAtom(size) {
|
|
7
|
+
const width = require_units.pointsToMasterUnits(size.widthPt);
|
|
8
|
+
const height = require_units.pointsToMasterUnits(size.heightPt);
|
|
9
|
+
return require_record_write.writeAtom(require_record_types.RT_DocumentAtom, require_record_write.concatBytes(require_record_write.i32le(width), require_record_write.i32le(height), require_record_write.i32le(width), require_record_write.i32le(height), require_record_write.i32le(1), require_record_write.i32le(2), require_record_write.u32le(0), require_record_write.u32le(0), require_record_write.u16le(1), require_record_write.u16le(0), /* @__PURE__ */ new Uint8Array(4)), { recVer: 1 });
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.writeDocumentAtom = writeDocumentAtom;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RT_DocumentAtom } from "../record/types.js";
|
|
2
|
+
import { pointsToMasterUnits } from "../units.js";
|
|
3
|
+
import { concatBytes, i32le, u16le, u32le, writeAtom } from "../record/write.js";
|
|
4
|
+
//#region src/document/document-atom-write.ts
|
|
5
|
+
function writeDocumentAtom(size) {
|
|
6
|
+
const width = pointsToMasterUnits(size.widthPt);
|
|
7
|
+
const height = pointsToMasterUnits(size.heightPt);
|
|
8
|
+
return writeAtom(RT_DocumentAtom, concatBytes(i32le(width), i32le(height), i32le(width), i32le(height), i32le(1), i32le(2), u32le(0), u32le(0), u16le(1), u16le(0), /* @__PURE__ */ new Uint8Array(4)), { recVer: 1 });
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { writeDocumentAtom };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record_types = require("../record/types.cjs");
|
|
3
|
+
const require_record_write = require("../record/write.cjs");
|
|
4
|
+
//#region src/document/fonts-write.ts
|
|
5
|
+
const FACE_NAME_FIELD_BYTES = 64;
|
|
6
|
+
function writeFontEntityAtom(faceName) {
|
|
7
|
+
const nameField = new Uint8Array(FACE_NAME_FIELD_BYTES);
|
|
8
|
+
const encoded = require_record_write.utf16le(faceName);
|
|
9
|
+
nameField.set(encoded.subarray(0, 62));
|
|
10
|
+
return require_record_write.writeAtom(require_record_types.RT_FontEntityAtom, require_record_write.concatBytes(nameField, /* @__PURE__ */ new Uint8Array(4)));
|
|
11
|
+
}
|
|
12
|
+
function writeEnvironment(fontNames) {
|
|
13
|
+
if (fontNames.length === 0) return;
|
|
14
|
+
return require_record_write.writeContainer(require_record_types.RT_Environment, [require_record_write.writeContainer(require_record_types.RT_FontCollection, fontNames.map(writeFontEntityAtom))]);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.writeEnvironment = writeEnvironment;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RT_Environment, RT_FontCollection, RT_FontEntityAtom } from "../record/types.js";
|
|
2
|
+
import { concatBytes, utf16le, writeAtom, writeContainer } from "../record/write.js";
|
|
3
|
+
//#region src/document/fonts-write.ts
|
|
4
|
+
const FACE_NAME_FIELD_BYTES = 64;
|
|
5
|
+
function writeFontEntityAtom(faceName) {
|
|
6
|
+
const nameField = new Uint8Array(FACE_NAME_FIELD_BYTES);
|
|
7
|
+
const encoded = utf16le(faceName);
|
|
8
|
+
nameField.set(encoded.subarray(0, 62));
|
|
9
|
+
return writeAtom(RT_FontEntityAtom, concatBytes(nameField, /* @__PURE__ */ new Uint8Array(4)));
|
|
10
|
+
}
|
|
11
|
+
function writeEnvironment(fontNames) {
|
|
12
|
+
if (fontNames.length === 0) return;
|
|
13
|
+
return writeContainer(RT_Environment, [writeContainer(RT_FontCollection, fontNames.map(writeFontEntityAtom))]);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { writeEnvironment };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record_types = require("../record/types.cjs");
|
|
3
|
+
require("../text/atoms.cjs");
|
|
4
|
+
const require_record_write = require("../record/write.cjs");
|
|
5
|
+
const require_document_color_scheme_write = require("./color-scheme-write.cjs");
|
|
6
|
+
const require_drawing_shapes_write = require("../drawing/shapes-write.cjs");
|
|
7
|
+
const require_read = require("../read.cjs");
|
|
8
|
+
//#region src/document/master-write.ts
|
|
9
|
+
const SL_TITLE_BODY = 1;
|
|
10
|
+
const SL_BLANK = 16;
|
|
11
|
+
const PT_NONE = 0;
|
|
12
|
+
const MASTER_PLACEHOLDER_TYPES = [
|
|
13
|
+
1,
|
|
14
|
+
2,
|
|
15
|
+
7,
|
|
16
|
+
9,
|
|
17
|
+
8
|
|
18
|
+
];
|
|
19
|
+
const PLACEHOLDER_TYPE_COUNT = 8;
|
|
20
|
+
const PS_FULL = 0;
|
|
21
|
+
const SLIDE_FOLLOWS_MASTER = 7;
|
|
22
|
+
const MASTER_SLIDE_ID = 2147483648;
|
|
23
|
+
const TITLE_TOP = .06;
|
|
24
|
+
const TITLE_HEIGHT = .16;
|
|
25
|
+
const BODY_TOP = .26;
|
|
26
|
+
const BODY_HEIGHT = .6;
|
|
27
|
+
const FOOTER_TOP = .92;
|
|
28
|
+
const FOOTER_HEIGHT = .05;
|
|
29
|
+
const SIDE_MARGIN = .05;
|
|
30
|
+
const FOOTER_COLUMN_WIDTH = .28;
|
|
31
|
+
function placeholderFrames(size) {
|
|
32
|
+
const { widthPt: w, heightPt: h } = size;
|
|
33
|
+
const margin = w * SIDE_MARGIN;
|
|
34
|
+
const contentWidth = w - margin * 2;
|
|
35
|
+
const footerColumn = w * FOOTER_COLUMN_WIDTH;
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
xPt: margin,
|
|
39
|
+
yPt: h * TITLE_TOP,
|
|
40
|
+
widthPt: contentWidth,
|
|
41
|
+
heightPt: h * TITLE_HEIGHT
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
xPt: margin,
|
|
45
|
+
yPt: h * BODY_TOP,
|
|
46
|
+
widthPt: contentWidth,
|
|
47
|
+
heightPt: h * BODY_HEIGHT
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
xPt: margin,
|
|
51
|
+
yPt: h * FOOTER_TOP,
|
|
52
|
+
widthPt: footerColumn,
|
|
53
|
+
heightPt: h * FOOTER_HEIGHT
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
xPt: (w - footerColumn) / 2,
|
|
57
|
+
yPt: h * FOOTER_TOP,
|
|
58
|
+
widthPt: footerColumn,
|
|
59
|
+
heightPt: h * FOOTER_HEIGHT
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
xPt: w - margin - footerColumn,
|
|
63
|
+
yPt: h * FOOTER_TOP,
|
|
64
|
+
widthPt: footerColumn,
|
|
65
|
+
heightPt: h * FOOTER_HEIGHT
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
function placeholderClientData(position, placementId) {
|
|
70
|
+
return require_record_write.writeContainer(require_record_types.OfficeArtClientData, [require_record_write.writeAtom(require_record_types.RT_PlaceholderAtom, require_record_write.concatBytes(require_record_write.i32le(position), require_record_write.u8(placementId), require_record_write.u8(PS_FULL), require_record_write.u16le(0)))]);
|
|
71
|
+
}
|
|
72
|
+
function writeSlideAtom(options) {
|
|
73
|
+
const types = new Uint8Array(PLACEHOLDER_TYPE_COUNT);
|
|
74
|
+
types.set(options.placeholderTypes.slice(0, PLACEHOLDER_TYPE_COUNT));
|
|
75
|
+
return require_record_write.writeAtom(require_record_types.RT_SlideAtom, require_record_write.concatBytes(require_record_write.i32le(options.geom), types, require_record_write.u32le(options.masterIdRef), require_record_write.u32le(options.notesIdRef), require_record_write.u16le(options.slideFlags), require_record_write.u16le(0)), { recVer: 2 });
|
|
76
|
+
}
|
|
77
|
+
function writeSlideAtomForSlide(notesIdRef) {
|
|
78
|
+
return writeSlideAtom({
|
|
79
|
+
geom: SL_BLANK,
|
|
80
|
+
placeholderTypes: [PT_NONE],
|
|
81
|
+
masterIdRef: MASTER_SLIDE_ID,
|
|
82
|
+
notesIdRef,
|
|
83
|
+
slideFlags: SLIDE_FOLLOWS_MASTER
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function writeTextMasterStyleAtom(textType) {
|
|
87
|
+
return require_record_write.writeAtom(require_record_types.RT_TextMasterStyleAtom, require_record_write.u16le(0), { recInstance: textType });
|
|
88
|
+
}
|
|
89
|
+
function writeMainMaster(size, fontIndexOf) {
|
|
90
|
+
const placeholders = MASTER_PLACEHOLDER_TYPES.map((placementId, index) => {
|
|
91
|
+
const frame = placeholderFrames(size)[index];
|
|
92
|
+
if (frame === void 0) throw new Error("internal error: the main master states more placeholder types than it has rectangles for");
|
|
93
|
+
return {
|
|
94
|
+
shape: {
|
|
95
|
+
frame,
|
|
96
|
+
insetLeftPt: require_read.DEFAULT_INSET_LEFT_RIGHT_PT,
|
|
97
|
+
insetTopPt: require_read.DEFAULT_INSET_TOP_BOTTOM_PT,
|
|
98
|
+
insetRightPt: require_read.DEFAULT_INSET_LEFT_RIGHT_PT,
|
|
99
|
+
insetBottomPt: require_read.DEFAULT_INSET_TOP_BOTTOM_PT,
|
|
100
|
+
blocks: []
|
|
101
|
+
},
|
|
102
|
+
clientData: placeholderClientData(index, placementId)
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
return require_record_write.writeContainer(require_record_types.RT_MainMaster, [
|
|
106
|
+
writeSlideAtom({
|
|
107
|
+
geom: SL_TITLE_BODY,
|
|
108
|
+
placeholderTypes: MASTER_PLACEHOLDER_TYPES,
|
|
109
|
+
masterIdRef: 0,
|
|
110
|
+
notesIdRef: 0,
|
|
111
|
+
slideFlags: 0
|
|
112
|
+
}),
|
|
113
|
+
writeTextMasterStyleAtom(0),
|
|
114
|
+
writeTextMasterStyleAtom(1),
|
|
115
|
+
writeTextMasterStyleAtom(2),
|
|
116
|
+
require_drawing_shapes_write.writeDrawingWithClientData(placeholders, fontIndexOf),
|
|
117
|
+
require_document_color_scheme_write.writeSlideSchemeColorSchemeAtom()
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
function writeMasterListWithText(persistIdRef) {
|
|
121
|
+
return require_record_write.writeContainer(require_record_types.RT_SlideListWithText, [require_record_write.writeAtom(require_record_types.RT_SlidePersistAtom, require_record_write.concatBytes(require_record_write.u32le(persistIdRef), require_record_write.u32le(0), require_record_write.i32le(0), require_record_write.u32le(MASTER_SLIDE_ID), require_record_write.u32le(0)))], { recInstance: 1 });
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
exports.MASTER_SLIDE_ID = MASTER_SLIDE_ID;
|
|
125
|
+
exports.writeMainMaster = writeMainMaster;
|
|
126
|
+
exports.writeMasterListWithText = writeMasterListWithText;
|
|
127
|
+
exports.writeSlideAtom = writeSlideAtom;
|
|
128
|
+
exports.writeSlideAtomForSlide = writeSlideAtomForSlide;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PageSize } from "document-schema.js";
|
|
2
|
+
//#region src/document/master-write.d.ts
|
|
3
|
+
declare const MASTER_SLIDE_ID = 2147483648;
|
|
4
|
+
declare function writeSlideAtom(options: {
|
|
5
|
+
readonly geom: number;
|
|
6
|
+
readonly placeholderTypes: readonly number[];
|
|
7
|
+
readonly masterIdRef: number;
|
|
8
|
+
readonly notesIdRef: number;
|
|
9
|
+
readonly slideFlags: number;
|
|
10
|
+
}): Uint8Array<ArrayBuffer>;
|
|
11
|
+
declare function writeSlideAtomForSlide(notesIdRef: number): Uint8Array<ArrayBuffer>;
|
|
12
|
+
declare function writeMainMaster(size: PageSize, fontIndexOf: (family: string) => number): Uint8Array<ArrayBuffer>;
|
|
13
|
+
declare function writeMasterListWithText(persistIdRef: number): Uint8Array<ArrayBuffer>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { MASTER_SLIDE_ID, writeMainMaster, writeMasterListWithText, writeSlideAtom, writeSlideAtomForSlide };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PageSize } from "document-schema.js";
|
|
2
|
+
//#region src/document/master-write.d.ts
|
|
3
|
+
declare const MASTER_SLIDE_ID = 2147483648;
|
|
4
|
+
declare function writeSlideAtom(options: {
|
|
5
|
+
readonly geom: number;
|
|
6
|
+
readonly placeholderTypes: readonly number[];
|
|
7
|
+
readonly masterIdRef: number;
|
|
8
|
+
readonly notesIdRef: number;
|
|
9
|
+
readonly slideFlags: number;
|
|
10
|
+
}): Uint8Array<ArrayBuffer>;
|
|
11
|
+
declare function writeSlideAtomForSlide(notesIdRef: number): Uint8Array<ArrayBuffer>;
|
|
12
|
+
declare function writeMainMaster(size: PageSize, fontIndexOf: (family: string) => number): Uint8Array<ArrayBuffer>;
|
|
13
|
+
declare function writeMasterListWithText(persistIdRef: number): Uint8Array<ArrayBuffer>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { MASTER_SLIDE_ID, writeMainMaster, writeMasterListWithText, writeSlideAtom, writeSlideAtomForSlide };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { OfficeArtClientData, RT_MainMaster, RT_PlaceholderAtom, RT_SlideAtom, RT_SlideListWithText, RT_SlidePersistAtom, RT_TextMasterStyleAtom } from "../record/types.js";
|
|
2
|
+
import "../text/atoms.js";
|
|
3
|
+
import { concatBytes, i32le, u16le, u32le, u8, writeAtom, writeContainer } from "../record/write.js";
|
|
4
|
+
import { writeSlideSchemeColorSchemeAtom } from "./color-scheme-write.js";
|
|
5
|
+
import { writeDrawingWithClientData } from "../drawing/shapes-write.js";
|
|
6
|
+
import { DEFAULT_INSET_LEFT_RIGHT_PT, DEFAULT_INSET_TOP_BOTTOM_PT } from "../read.js";
|
|
7
|
+
//#region src/document/master-write.ts
|
|
8
|
+
const SL_TITLE_BODY = 1;
|
|
9
|
+
const SL_BLANK = 16;
|
|
10
|
+
const PT_NONE = 0;
|
|
11
|
+
const MASTER_PLACEHOLDER_TYPES = [
|
|
12
|
+
1,
|
|
13
|
+
2,
|
|
14
|
+
7,
|
|
15
|
+
9,
|
|
16
|
+
8
|
|
17
|
+
];
|
|
18
|
+
const PLACEHOLDER_TYPE_COUNT = 8;
|
|
19
|
+
const PS_FULL = 0;
|
|
20
|
+
const SLIDE_FOLLOWS_MASTER = 7;
|
|
21
|
+
const MASTER_SLIDE_ID = 2147483648;
|
|
22
|
+
const TITLE_TOP = .06;
|
|
23
|
+
const TITLE_HEIGHT = .16;
|
|
24
|
+
const BODY_TOP = .26;
|
|
25
|
+
const BODY_HEIGHT = .6;
|
|
26
|
+
const FOOTER_TOP = .92;
|
|
27
|
+
const FOOTER_HEIGHT = .05;
|
|
28
|
+
const SIDE_MARGIN = .05;
|
|
29
|
+
const FOOTER_COLUMN_WIDTH = .28;
|
|
30
|
+
function placeholderFrames(size) {
|
|
31
|
+
const { widthPt: w, heightPt: h } = size;
|
|
32
|
+
const margin = w * SIDE_MARGIN;
|
|
33
|
+
const contentWidth = w - margin * 2;
|
|
34
|
+
const footerColumn = w * FOOTER_COLUMN_WIDTH;
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
xPt: margin,
|
|
38
|
+
yPt: h * TITLE_TOP,
|
|
39
|
+
widthPt: contentWidth,
|
|
40
|
+
heightPt: h * TITLE_HEIGHT
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
xPt: margin,
|
|
44
|
+
yPt: h * BODY_TOP,
|
|
45
|
+
widthPt: contentWidth,
|
|
46
|
+
heightPt: h * BODY_HEIGHT
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
xPt: margin,
|
|
50
|
+
yPt: h * FOOTER_TOP,
|
|
51
|
+
widthPt: footerColumn,
|
|
52
|
+
heightPt: h * FOOTER_HEIGHT
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
xPt: (w - footerColumn) / 2,
|
|
56
|
+
yPt: h * FOOTER_TOP,
|
|
57
|
+
widthPt: footerColumn,
|
|
58
|
+
heightPt: h * FOOTER_HEIGHT
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
xPt: w - margin - footerColumn,
|
|
62
|
+
yPt: h * FOOTER_TOP,
|
|
63
|
+
widthPt: footerColumn,
|
|
64
|
+
heightPt: h * FOOTER_HEIGHT
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function placeholderClientData(position, placementId) {
|
|
69
|
+
return writeContainer(OfficeArtClientData, [writeAtom(RT_PlaceholderAtom, concatBytes(i32le(position), u8(placementId), u8(PS_FULL), u16le(0)))]);
|
|
70
|
+
}
|
|
71
|
+
function writeSlideAtom(options) {
|
|
72
|
+
const types = new Uint8Array(PLACEHOLDER_TYPE_COUNT);
|
|
73
|
+
types.set(options.placeholderTypes.slice(0, PLACEHOLDER_TYPE_COUNT));
|
|
74
|
+
return writeAtom(RT_SlideAtom, concatBytes(i32le(options.geom), types, u32le(options.masterIdRef), u32le(options.notesIdRef), u16le(options.slideFlags), u16le(0)), { recVer: 2 });
|
|
75
|
+
}
|
|
76
|
+
function writeSlideAtomForSlide(notesIdRef) {
|
|
77
|
+
return writeSlideAtom({
|
|
78
|
+
geom: SL_BLANK,
|
|
79
|
+
placeholderTypes: [PT_NONE],
|
|
80
|
+
masterIdRef: MASTER_SLIDE_ID,
|
|
81
|
+
notesIdRef,
|
|
82
|
+
slideFlags: SLIDE_FOLLOWS_MASTER
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function writeTextMasterStyleAtom(textType) {
|
|
86
|
+
return writeAtom(RT_TextMasterStyleAtom, u16le(0), { recInstance: textType });
|
|
87
|
+
}
|
|
88
|
+
function writeMainMaster(size, fontIndexOf) {
|
|
89
|
+
const placeholders = MASTER_PLACEHOLDER_TYPES.map((placementId, index) => {
|
|
90
|
+
const frame = placeholderFrames(size)[index];
|
|
91
|
+
if (frame === void 0) throw new Error("internal error: the main master states more placeholder types than it has rectangles for");
|
|
92
|
+
return {
|
|
93
|
+
shape: {
|
|
94
|
+
frame,
|
|
95
|
+
insetLeftPt: DEFAULT_INSET_LEFT_RIGHT_PT,
|
|
96
|
+
insetTopPt: DEFAULT_INSET_TOP_BOTTOM_PT,
|
|
97
|
+
insetRightPt: DEFAULT_INSET_LEFT_RIGHT_PT,
|
|
98
|
+
insetBottomPt: DEFAULT_INSET_TOP_BOTTOM_PT,
|
|
99
|
+
blocks: []
|
|
100
|
+
},
|
|
101
|
+
clientData: placeholderClientData(index, placementId)
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
return writeContainer(RT_MainMaster, [
|
|
105
|
+
writeSlideAtom({
|
|
106
|
+
geom: SL_TITLE_BODY,
|
|
107
|
+
placeholderTypes: MASTER_PLACEHOLDER_TYPES,
|
|
108
|
+
masterIdRef: 0,
|
|
109
|
+
notesIdRef: 0,
|
|
110
|
+
slideFlags: 0
|
|
111
|
+
}),
|
|
112
|
+
writeTextMasterStyleAtom(0),
|
|
113
|
+
writeTextMasterStyleAtom(1),
|
|
114
|
+
writeTextMasterStyleAtom(2),
|
|
115
|
+
writeDrawingWithClientData(placeholders, fontIndexOf),
|
|
116
|
+
writeSlideSchemeColorSchemeAtom()
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
function writeMasterListWithText(persistIdRef) {
|
|
120
|
+
return writeContainer(RT_SlideListWithText, [writeAtom(RT_SlidePersistAtom, concatBytes(u32le(persistIdRef), u32le(0), i32le(0), u32le(MASTER_SLIDE_ID), u32le(0)))], { recInstance: 1 });
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { MASTER_SLIDE_ID, writeMainMaster, writeMasterListWithText, writeSlideAtom, writeSlideAtomForSlide };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record_types = require("../record/types.cjs");
|
|
3
|
+
const require_record_write = require("../record/write.cjs");
|
|
4
|
+
//#region src/document/notes-list-write.ts
|
|
5
|
+
function writeNotesPersistAtom(persist) {
|
|
6
|
+
return require_record_write.writeAtom(require_record_types.RT_SlidePersistAtom, require_record_write.concatBytes(require_record_write.u32le(persist.persistIdRef), require_record_write.u32le(0), require_record_write.i32le(0), require_record_write.u32le(persist.notesId), require_record_write.u32le(0)));
|
|
7
|
+
}
|
|
8
|
+
function writeNotesListWithText(persists) {
|
|
9
|
+
return require_record_write.writeContainer(require_record_types.RT_SlideListWithText, persists.map(writeNotesPersistAtom), { recInstance: 2 });
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.writeNotesListWithText = writeNotesListWithText;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RT_SlideListWithText, RT_SlidePersistAtom } from "../record/types.js";
|
|
2
|
+
import { concatBytes, i32le, u32le, writeAtom, writeContainer } from "../record/write.js";
|
|
3
|
+
//#region src/document/notes-list-write.ts
|
|
4
|
+
function writeNotesPersistAtom(persist) {
|
|
5
|
+
return writeAtom(RT_SlidePersistAtom, concatBytes(u32le(persist.persistIdRef), u32le(0), i32le(0), u32le(persist.notesId), u32le(0)));
|
|
6
|
+
}
|
|
7
|
+
function writeNotesListWithText(persists) {
|
|
8
|
+
return writeContainer(RT_SlideListWithText, persists.map(writeNotesPersistAtom), { recInstance: 2 });
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { writeNotesListWithText };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_errors = require("../errors.cjs");
|
|
3
|
+
const require_record_tree = require("../record/tree.cjs");
|
|
4
|
+
const require_record_types = require("../record/types.cjs");
|
|
5
|
+
//#region src/document/notes-list.ts
|
|
6
|
+
const NOTES_PERSIST_ATOM_LEN = 20;
|
|
7
|
+
function readNotesListWithText(listContainer) {
|
|
8
|
+
if (listContainer.header.recType !== 4080) throw new require_errors.PptFormatError(`expected RT_SlideListWithText (0x${require_record_types.RT_SlideListWithText.toString(16)}), found record type 0x${listContainer.header.recType.toString(16)}`);
|
|
9
|
+
const persists = [];
|
|
10
|
+
for (const record of require_record_tree.childRecords(listContainer)) {
|
|
11
|
+
if (record.header.recType !== 1011) continue;
|
|
12
|
+
if (record.data.length < NOTES_PERSIST_ATOM_LEN) throw new require_errors.PptFormatError(`NotesPersistAtom at offset ${record.offset} carries ${record.data.length} bytes, fewer than the mandated 0x${NOTES_PERSIST_ATOM_LEN.toString(16)}`);
|
|
13
|
+
const view = new DataView(record.data.buffer, record.data.byteOffset, record.data.byteLength);
|
|
14
|
+
persists.push({
|
|
15
|
+
persistIdRef: view.getUint32(0, true),
|
|
16
|
+
notesId: view.getUint32(12, true)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return persists;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.readNotesListWithText = readNotesListWithText;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as PptRecord } from "../tree-Du_LXAF0.cjs";
|
|
2
|
+
//#region src/document/notes-list.d.ts
|
|
3
|
+
interface NotesPersist {
|
|
4
|
+
readonly persistIdRef: number;
|
|
5
|
+
readonly notesId: number;
|
|
6
|
+
}
|
|
7
|
+
declare function readNotesListWithText(listContainer: PptRecord): NotesPersist[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NotesPersist, readNotesListWithText };
|