ppt-codec 1.3.0 → 1.4.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 +37 -15
- package/dist/content-write.cjs +6 -3
- package/dist/content-write.js +6 -3
- package/dist/content.cjs +24 -14
- package/dist/content.d.cts +3 -2
- package/dist/content.d.ts +3 -2
- package/dist/content.js +24 -14
- package/dist/document/color-scheme.cjs +37 -0
- package/dist/document/color-scheme.d.cts +8 -0
- package/dist/document/color-scheme.d.ts +8 -0
- package/dist/document/color-scheme.js +35 -0
- package/dist/document/master.cjs +82 -0
- package/dist/document/master.d.cts +2 -0
- package/dist/document/master.d.ts +2 -0
- package/dist/document/master.js +78 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/master-Cs_sDM1-.d.ts +25 -0
- package/dist/master-zlMRXyPU.d.cts +25 -0
- package/dist/read.cjs +56 -9
- package/dist/read.js +59 -12
- package/dist/text/style-write.cjs +10 -4
- package/dist/text/style-write.js +10 -4
- package/dist/text/style.cjs +43 -5
- package/dist/text/style.d.cts +20 -2
- package/dist/text/style.d.ts +20 -2
- package/dist/text/style.js +42 -7
- package/package.json +1 -1
package/dist/text/style.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PptFormatError } from "../errors.js";
|
|
2
|
-
import { RT_StyleTextPropAtom } from "../record/types.js";
|
|
2
|
+
import { RT_StyleTextPropAtom, RT_TextMasterStyleAtom } from "../record/types.js";
|
|
3
3
|
//#region src/text/style.ts
|
|
4
4
|
const ALIGN_LEFT = 0;
|
|
5
5
|
const ALIGN_CENTER = 1;
|
|
@@ -50,6 +50,8 @@ const STYLE_UNDERLINE = 4;
|
|
|
50
50
|
const STYLE_SHADOW = 16;
|
|
51
51
|
const STYLE_EMBOSS = 512;
|
|
52
52
|
const COLOR_INDEX_SRGB = 254;
|
|
53
|
+
const COLOR_INDEX_UNDEFINED = 255;
|
|
54
|
+
const COLOR_SCHEME_SLOT_COUNT = 8;
|
|
53
55
|
var FieldCursor = class {
|
|
54
56
|
data;
|
|
55
57
|
describe;
|
|
@@ -90,11 +92,20 @@ var FieldCursor = class {
|
|
|
90
92
|
function readColorIndexStruct(cursor) {
|
|
91
93
|
const [red, green, blue, index] = cursor.bytes(4);
|
|
92
94
|
if (red === void 0 || green === void 0 || blue === void 0 || index === void 0) throw new PptFormatError("ColorIndexStruct read returned fewer than its four bytes");
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (index === 254) return {
|
|
96
|
+
kind: "rgb",
|
|
97
|
+
rgb: {
|
|
98
|
+
red,
|
|
99
|
+
green,
|
|
100
|
+
blue
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
if (index === 255) return;
|
|
104
|
+
if (index < 8) return {
|
|
105
|
+
kind: "scheme",
|
|
106
|
+
schemeIndex: index
|
|
107
|
+
};
|
|
108
|
+
throw new PptFormatError(`ColorIndexStruct index 0x${index.toString(16)} is none of a colour-scheme slot (0x00-0x07), the literal-colour sentinel (0x${254 .toString(16)}), or the undefined-colour sentinel (0x${255 .toString(16)})`);
|
|
98
109
|
}
|
|
99
110
|
function readTextPFException(cursor, indentLevel) {
|
|
100
111
|
const masks = cursor.u32();
|
|
@@ -174,5 +185,29 @@ function readStyleTextPropAtom(record, characterCount) {
|
|
|
174
185
|
characterRuns: readRuns(cursor, characterCount, "StyleTextPropAtom character runs", readTextCFException)
|
|
175
186
|
};
|
|
176
187
|
}
|
|
188
|
+
const MASTER_STYLE_MAX_LEVELS = 5;
|
|
189
|
+
const MASTER_STYLE_TYPES_WITH_EXPLICIT_LEVEL = 5;
|
|
190
|
+
function readTextMasterStyleAtom(record) {
|
|
191
|
+
if (record.header.recType !== 4003) throw new PptFormatError(`expected RT_TextMasterStyleAtom (0x${RT_TextMasterStyleAtom.toString(16)}) at offset ${record.offset}, found record type 0x${record.header.recType.toString(16)}`);
|
|
192
|
+
const textType = record.header.recInstance;
|
|
193
|
+
const cursor = new FieldCursor(record.data, 0, "TextMasterStyleAtom");
|
|
194
|
+
const cLevels = cursor.u16();
|
|
195
|
+
if (cLevels > MASTER_STYLE_MAX_LEVELS) throw new PptFormatError(`TextMasterStyleAtom at offset ${record.offset} declares cLevels ${cLevels}, more than the mandated maximum of ${MASTER_STYLE_MAX_LEVELS}`);
|
|
196
|
+
const hasExplicitLevel = textType >= MASTER_STYLE_TYPES_WITH_EXPLICIT_LEVEL;
|
|
197
|
+
const levels = [];
|
|
198
|
+
for (let i = 0; i < cLevels; i += 1) {
|
|
199
|
+
if (hasExplicitLevel) cursor.u16();
|
|
200
|
+
const paragraph = readTextPFException(cursor, i);
|
|
201
|
+
const character = readTextCFException(cursor);
|
|
202
|
+
levels.push({
|
|
203
|
+
paragraph,
|
|
204
|
+
character
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
textType,
|
|
209
|
+
levels
|
|
210
|
+
};
|
|
211
|
+
}
|
|
177
212
|
//#endregion
|
|
178
|
-
export { ALIGN_CENTER, ALIGN_DISTRIBUTED, ALIGN_JUSTIFY, ALIGN_JUSTIFY_LOW, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_THAI_DISTRIBUTED, CF_ANSI_TYPEFACE, CF_BOLD, CF_COLOR, CF_EMBOSS, CF_FEHINT, CF_HAS_STYLE, CF_ITALIC, CF_KUMI, CF_OLD_EA_TYPEFACE, CF_POSITION, CF_SHADOW, CF_SIZE, CF_SYMBOL_TYPEFACE, CF_TYPEFACE, CF_UNDERLINE, COLOR_INDEX_SRGB, PF_ALIGN, PF_BULLET_CHAR, PF_BULLET_COLOR, PF_BULLET_FONT, PF_BULLET_HAS_COLOR, PF_BULLET_HAS_FONT, PF_BULLET_HAS_SIZE, PF_BULLET_SIZE, PF_CHAR_WRAP, PF_DEFAULT_TAB_SIZE, PF_FONT_ALIGN, PF_HAS_BULLET, PF_INDENT, PF_LEFT_MARGIN, PF_LINE_SPACING, PF_OVERFLOW, PF_SPACE_AFTER, PF_SPACE_BEFORE, PF_TAB_STOPS, PF_TEXT_DIRECTION, PF_WORD_WRAP, STYLE_BOLD, STYLE_EMBOSS, STYLE_ITALIC, STYLE_SHADOW, STYLE_UNDERLINE, readStyleTextPropAtom };
|
|
213
|
+
export { ALIGN_CENTER, ALIGN_DISTRIBUTED, ALIGN_JUSTIFY, ALIGN_JUSTIFY_LOW, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_THAI_DISTRIBUTED, CF_ANSI_TYPEFACE, CF_BOLD, CF_COLOR, CF_EMBOSS, CF_FEHINT, CF_HAS_STYLE, CF_ITALIC, CF_KUMI, CF_OLD_EA_TYPEFACE, CF_POSITION, CF_SHADOW, CF_SIZE, CF_SYMBOL_TYPEFACE, CF_TYPEFACE, CF_UNDERLINE, COLOR_INDEX_SRGB, COLOR_INDEX_UNDEFINED, COLOR_SCHEME_SLOT_COUNT, PF_ALIGN, PF_BULLET_CHAR, PF_BULLET_COLOR, PF_BULLET_FONT, PF_BULLET_HAS_COLOR, PF_BULLET_HAS_FONT, PF_BULLET_HAS_SIZE, PF_BULLET_SIZE, PF_CHAR_WRAP, PF_DEFAULT_TAB_SIZE, PF_FONT_ALIGN, PF_HAS_BULLET, PF_INDENT, PF_LEFT_MARGIN, PF_LINE_SPACING, PF_OVERFLOW, PF_SPACE_AFTER, PF_SPACE_BEFORE, PF_TAB_STOPS, PF_TEXT_DIRECTION, PF_WORD_WRAP, STYLE_BOLD, STYLE_EMBOSS, STYLE_ITALIC, STYLE_SHADOW, STYLE_UNDERLINE, readStyleTextPropAtom, readTextMasterStyleAtom };
|
package/package.json
CHANGED