odf.js 6.1.2 → 6.2.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.
@@ -0,0 +1,405 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/ooo1/properties.ts
3
+ const PROPERTIES_ELEMENT_TAG = {
4
+ graphic: "style:graphic-properties",
5
+ "drawing-page": "style:drawing-page-properties",
6
+ "page-layout": "style:page-layout-properties",
7
+ "header-footer": "style:header-footer-properties",
8
+ text: "style:text-properties",
9
+ paragraph: "style:paragraph-properties",
10
+ ruby: "style:ruby-properties",
11
+ section: "style:section-properties",
12
+ table: "style:table-properties",
13
+ "table-column": "style:table-column-properties",
14
+ "table-row": "style:table-row-properties",
15
+ "table-cell": "style:table-cell-properties",
16
+ "list-level": "style:list-level-properties",
17
+ chart: "style:chart-properties"
18
+ };
19
+ const PROPERTY_TYPES_BY_FAMILY = /* @__PURE__ */ new Map([
20
+ ["graphic", [
21
+ "graphic",
22
+ "paragraph",
23
+ "text"
24
+ ]],
25
+ ["presentation", [
26
+ "graphic",
27
+ "paragraph",
28
+ "text"
29
+ ]],
30
+ ["drawing-page", ["drawing-page"]],
31
+ ["text", ["text"]],
32
+ ["paragraph", ["paragraph", "text"]],
33
+ ["ruby", ["ruby"]],
34
+ ["section", ["section"]],
35
+ ["table", ["table"]],
36
+ ["table-column", ["table-column"]],
37
+ ["table-row", ["table-row"]],
38
+ ["table-cell", [
39
+ "table-cell",
40
+ "paragraph",
41
+ "text"
42
+ ]],
43
+ ["chart", [
44
+ "chart",
45
+ "graphic",
46
+ "paragraph",
47
+ "text"
48
+ ]]
49
+ ]);
50
+ const PROPERTY_TYPES_BY_CONTAINER_TAG = /* @__PURE__ */ new Map([
51
+ ["style:page-master", ["page-layout"]],
52
+ ["style:header-style", ["header-footer"]],
53
+ ["style:footer-style", ["header-footer"]],
54
+ ["text:list-level-style-number", ["list-level"]],
55
+ ["text:list-level-style-bullet", ["list-level"]],
56
+ ["text:list-level-style-image", ["list-level"]],
57
+ ["text:outline-level-style", ["list-level"]],
58
+ ["number:number-style", ["text"]],
59
+ ["number:currency-style", ["text"]],
60
+ ["number:percentage-style", ["text"]],
61
+ ["number:date-style", ["text"]],
62
+ ["number:time-style", ["text"]],
63
+ ["number:boolean-style", ["text"]],
64
+ ["number:text-style", ["text"]]
65
+ ]);
66
+ const ATTRIBUTES_BY_PROPERTY_TYPE = /* @__PURE__ */ new Map([
67
+ ["text", /* @__PURE__ */ new Set([
68
+ "fo:color",
69
+ "fo:country",
70
+ "fo:font-family",
71
+ "fo:font-size",
72
+ "fo:font-style",
73
+ "fo:font-variant",
74
+ "fo:font-weight",
75
+ "fo:hyphenate",
76
+ "fo:hyphenation-push-char-count",
77
+ "fo:hyphenation-remain-char-count",
78
+ "fo:language",
79
+ "fo:letter-spacing",
80
+ "fo:script",
81
+ "fo:text-shadow",
82
+ "fo:text-transform",
83
+ "style:country-asian",
84
+ "style:country-complex",
85
+ "style:font-charset",
86
+ "style:font-charset-asian",
87
+ "style:font-charset-complex",
88
+ "style:font-family-asian",
89
+ "style:font-family-complex",
90
+ "style:font-family-generic",
91
+ "style:font-family-generic-asian",
92
+ "style:font-family-generic-complex",
93
+ "style:font-name",
94
+ "style:font-name-asian",
95
+ "style:font-name-complex",
96
+ "style:font-pitch",
97
+ "style:font-pitch-asian",
98
+ "style:font-pitch-complex",
99
+ "style:font-relief",
100
+ "style:font-size-asian",
101
+ "style:font-size-complex",
102
+ "style:font-size-rel",
103
+ "style:font-size-rel-asian",
104
+ "style:font-size-rel-complex",
105
+ "style:font-style-asian",
106
+ "style:font-style-complex",
107
+ "style:font-style-name",
108
+ "style:font-style-name-asian",
109
+ "style:font-style-name-complex",
110
+ "style:font-weight-asian",
111
+ "style:font-weight-complex",
112
+ "style:language-asian",
113
+ "style:language-complex",
114
+ "style:letter-kerning",
115
+ "style:script-type",
116
+ "style:text-background-color",
117
+ "style:text-blinking",
118
+ "style:text-combine",
119
+ "style:text-combine-end-char",
120
+ "style:text-combine-start-char",
121
+ "style:text-emphasize",
122
+ "style:text-line-through-color",
123
+ "style:text-line-through-mode",
124
+ "style:text-line-through-style",
125
+ "style:text-line-through-text",
126
+ "style:text-line-through-text-style",
127
+ "style:text-line-through-type",
128
+ "style:text-line-through-width",
129
+ "style:text-outline",
130
+ "style:text-position",
131
+ "style:text-rotation-angle",
132
+ "style:text-rotation-scale",
133
+ "style:text-scale",
134
+ "style:text-underline-color",
135
+ "style:text-underline-mode",
136
+ "style:text-underline-style",
137
+ "style:text-underline-type",
138
+ "style:text-underline-width",
139
+ "style:use-window-font-color",
140
+ "text:condition",
141
+ "text:display",
142
+ "style:text-underline",
143
+ "style:text-crossing-out"
144
+ ])],
145
+ ["paragraph", /* @__PURE__ */ new Set([
146
+ "fo:background-color",
147
+ "fo:border",
148
+ "fo:border-bottom",
149
+ "fo:border-left",
150
+ "fo:border-right",
151
+ "fo:border-top",
152
+ "fo:break-after",
153
+ "fo:break-before",
154
+ "fo:hyphenation-keep",
155
+ "fo:hyphenation-ladder-count",
156
+ "fo:keep-together",
157
+ "fo:keep-with-next",
158
+ "fo:line-height",
159
+ "fo:margin",
160
+ "fo:margin-bottom",
161
+ "fo:margin-left",
162
+ "fo:margin-right",
163
+ "fo:margin-top",
164
+ "fo:orphans",
165
+ "fo:padding",
166
+ "fo:padding-bottom",
167
+ "fo:padding-left",
168
+ "fo:padding-right",
169
+ "fo:padding-top",
170
+ "fo:text-align",
171
+ "fo:text-align-last",
172
+ "fo:text-indent",
173
+ "fo:widows",
174
+ "style:auto-text-indent",
175
+ "style:background-transparency",
176
+ "style:border-line-width",
177
+ "style:border-line-width-bottom",
178
+ "style:border-line-width-left",
179
+ "style:border-line-width-right",
180
+ "style:border-line-width-top",
181
+ "style:contextual-spacing",
182
+ "style:font-independent-line-spacing",
183
+ "style:justify-single-word",
184
+ "style:line-break",
185
+ "style:line-height-at-least",
186
+ "style:line-spacing",
187
+ "style:master-page-name",
188
+ "style:page-number",
189
+ "style:punctuation-wrap",
190
+ "style:register-true",
191
+ "style:shadow",
192
+ "style:snap-to-layout-grid",
193
+ "style:tab-stop-distance",
194
+ "style:text-autospace",
195
+ "style:vertical-align",
196
+ "style:writing-mode",
197
+ "style:writing-mode-automatic",
198
+ "text:line-number",
199
+ "text:number-lines"
200
+ ])],
201
+ ["table-cell", /* @__PURE__ */ new Set([
202
+ "fo:background-color",
203
+ "fo:border",
204
+ "fo:border-bottom",
205
+ "fo:border-left",
206
+ "fo:border-right",
207
+ "fo:border-top",
208
+ "fo:padding",
209
+ "fo:padding-bottom",
210
+ "fo:padding-left",
211
+ "fo:padding-right",
212
+ "fo:padding-top",
213
+ "style:border-line-width",
214
+ "style:border-line-width-bottom",
215
+ "style:border-line-width-left",
216
+ "style:border-line-width-right",
217
+ "style:border-line-width-top",
218
+ "style:shadow",
219
+ "style:vertical-align",
220
+ "style:writing-mode"
221
+ ])],
222
+ ["graphic", /* @__PURE__ */ new Set([
223
+ "fo:background-color",
224
+ "fo:border",
225
+ "fo:border-bottom",
226
+ "fo:border-left",
227
+ "fo:border-right",
228
+ "fo:border-top",
229
+ "fo:margin",
230
+ "fo:margin-bottom",
231
+ "fo:margin-left",
232
+ "fo:margin-right",
233
+ "fo:margin-top",
234
+ "fo:padding",
235
+ "fo:padding-bottom",
236
+ "fo:padding-left",
237
+ "fo:padding-right",
238
+ "fo:padding-top",
239
+ "style:background-transparency",
240
+ "style:border-line-width",
241
+ "style:border-line-width-bottom",
242
+ "style:border-line-width-left",
243
+ "style:border-line-width-right",
244
+ "style:border-line-width-top",
245
+ "style:shadow",
246
+ "style:vertical-align",
247
+ "style:writing-mode"
248
+ ])]
249
+ ]);
250
+ const ELEMENTS_BY_PROPERTY_TYPE = /* @__PURE__ */ new Map([
251
+ ["paragraph", /* @__PURE__ */ new Set([
252
+ "style:tab-stops",
253
+ "style:drop-cap",
254
+ "style:background-image"
255
+ ])],
256
+ ["table-cell", /* @__PURE__ */ new Set(["style:background-image"])],
257
+ ["graphic", /* @__PURE__ */ new Set(["style:background-image"])]
258
+ ]);
259
+ function propertyTypesForContainer(container) {
260
+ const byTag = PROPERTY_TYPES_BY_CONTAINER_TAG.get(container.tag);
261
+ if (byTag !== void 0) return byTag;
262
+ if (container.tag !== "style:style" && container.tag !== "style:default-style") return;
263
+ const family = container.attributes.find((attribute) => attribute.name === "style:family")?.value;
264
+ return family === void 0 ? void 0 : PROPERTY_TYPES_BY_FAMILY.get(family);
265
+ }
266
+ function routeTo(name, candidates, membership) {
267
+ for (const candidate of candidates) if (membership.get(candidate)?.has(name) === true) return candidate;
268
+ const first = candidates[0];
269
+ if (first === void 0) throw new Error("a style family must have at least one property type");
270
+ return first;
271
+ }
272
+ const UNDERLINE_EXPANSIONS = /* @__PURE__ */ new Map([
273
+ ["single", { style: "solid" }],
274
+ ["double", {
275
+ style: "solid",
276
+ type: "double"
277
+ }],
278
+ ["bold", {
279
+ style: "solid",
280
+ width: "bold"
281
+ }],
282
+ ["bold-dotted", {
283
+ style: "dotted",
284
+ width: "bold"
285
+ }],
286
+ ["bold-dash", {
287
+ style: "dash",
288
+ width: "bold"
289
+ }],
290
+ ["bold-long-dash", {
291
+ style: "long-dash",
292
+ width: "bold"
293
+ }],
294
+ ["bold-dot-dash", {
295
+ style: "dot-dash",
296
+ width: "bold"
297
+ }],
298
+ ["bold-dot-dot-dash", {
299
+ style: "dot-dot-dash",
300
+ width: "bold"
301
+ }],
302
+ ["bold-wave", {
303
+ style: "wave",
304
+ width: "bold"
305
+ }],
306
+ ["double-wave", {
307
+ style: "wave",
308
+ type: "double"
309
+ }]
310
+ ]);
311
+ const LINE_THROUGH_EXPANSIONS = /* @__PURE__ */ new Map([
312
+ ["single-line", { style: "solid" }],
313
+ ["double-line", {
314
+ style: "solid",
315
+ type: "double"
316
+ }],
317
+ ["thick-line", {
318
+ style: "solid",
319
+ width: "bold"
320
+ }],
321
+ ["slash", {
322
+ style: "solid",
323
+ text: "/"
324
+ }],
325
+ ["X", {
326
+ style: "solid",
327
+ text: "X"
328
+ }]
329
+ ]);
330
+ function expandPropertyAttribute(attribute) {
331
+ if (attribute.name === "style:text-underline") {
332
+ const expansion = UNDERLINE_EXPANSIONS.get(attribute.value);
333
+ const out = [{
334
+ name: "style:text-underline-style",
335
+ value: expansion?.style ?? attribute.value
336
+ }];
337
+ if (expansion?.width !== void 0) out.push({
338
+ name: "style:text-underline-width",
339
+ value: expansion.width
340
+ });
341
+ if (expansion?.type !== void 0) out.push({
342
+ name: "style:text-underline-type",
343
+ value: expansion.type
344
+ });
345
+ return out;
346
+ }
347
+ if (attribute.name === "style:text-crossing-out") {
348
+ const expansion = LINE_THROUGH_EXPANSIONS.get(attribute.value);
349
+ const out = [{
350
+ name: "style:text-line-through-style",
351
+ value: expansion?.style ?? attribute.value
352
+ }];
353
+ if (expansion?.width !== void 0) out.push({
354
+ name: "style:text-line-through-width",
355
+ value: expansion.width
356
+ });
357
+ if (expansion?.type !== void 0) out.push({
358
+ name: "style:text-line-through-type",
359
+ value: expansion.type
360
+ });
361
+ if (expansion?.text !== void 0) out.push({
362
+ name: "style:text-line-through-text",
363
+ value: expansion.text
364
+ });
365
+ return out;
366
+ }
367
+ if (attribute.name === "fo:keep-with-next") return [{
368
+ name: "fo:keep-with-next",
369
+ value: attribute.value === "true" ? "always" : "auto"
370
+ }];
371
+ return [attribute];
372
+ }
373
+ function splitStyleProperties(properties, candidates) {
374
+ const attributesByType = /* @__PURE__ */ new Map();
375
+ const childrenByType = /* @__PURE__ */ new Map();
376
+ for (const attribute of properties.attributes) {
377
+ const target = routeTo(attribute.name, candidates, ATTRIBUTES_BY_PROPERTY_TYPE);
378
+ const bucket = attributesByType.get(target) ?? [];
379
+ bucket.push(...expandPropertyAttribute(attribute));
380
+ attributesByType.set(target, bucket);
381
+ }
382
+ for (const child of properties.children) {
383
+ if (child.type !== "element") continue;
384
+ const target = routeTo(child.tag, candidates, ELEMENTS_BY_PROPERTY_TYPE);
385
+ const bucket = childrenByType.get(target) ?? [];
386
+ bucket.push(child);
387
+ childrenByType.set(target, bucket);
388
+ }
389
+ const out = [];
390
+ for (const type of candidates) {
391
+ const attributes = attributesByType.get(type) ?? [];
392
+ const children = childrenByType.get(type) ?? [];
393
+ if (attributes.length === 0 && children.length === 0) continue;
394
+ out.push({
395
+ type: "element",
396
+ tag: PROPERTIES_ELEMENT_TAG[type],
397
+ attributes,
398
+ children
399
+ });
400
+ }
401
+ return out;
402
+ }
403
+ //#endregion
404
+ exports.propertyTypesForContainer = propertyTypesForContainer;
405
+ exports.splitStyleProperties = splitStyleProperties;
@@ -0,0 +1,7 @@
1
+ import { l as XmlElement } from "../node-B6JX5CRX.cjs";
2
+ //#region src/ooo1/properties.d.ts
3
+ type Ooo1PropertyType = "graphic" | "drawing-page" | "page-layout" | "header-footer" | "text" | "paragraph" | "ruby" | "section" | "table" | "table-column" | "table-row" | "table-cell" | "list-level" | "chart";
4
+ declare function propertyTypesForContainer(container: XmlElement): readonly Ooo1PropertyType[] | undefined;
5
+ declare function splitStyleProperties(properties: XmlElement, candidates: readonly Ooo1PropertyType[]): XmlElement[];
6
+ //#endregion
7
+ export { Ooo1PropertyType, propertyTypesForContainer, splitStyleProperties };
@@ -0,0 +1,7 @@
1
+ import { l as XmlElement } from "../node-B6JX5CRX.js";
2
+ //#region src/ooo1/properties.d.ts
3
+ type Ooo1PropertyType = "graphic" | "drawing-page" | "page-layout" | "header-footer" | "text" | "paragraph" | "ruby" | "section" | "table" | "table-column" | "table-row" | "table-cell" | "list-level" | "chart";
4
+ declare function propertyTypesForContainer(container: XmlElement): readonly Ooo1PropertyType[] | undefined;
5
+ declare function splitStyleProperties(properties: XmlElement, candidates: readonly Ooo1PropertyType[]): XmlElement[];
6
+ //#endregion
7
+ export { Ooo1PropertyType, propertyTypesForContainer, splitStyleProperties };