odf.js 5.1.2 → 5.3.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.
Files changed (92) hide show
  1. package/README.md +5 -3
  2. package/dist/{cascade-rhqUQrUa.d.ts → cascade-BZ7zqXhL.d.ts} +2 -2
  3. package/dist/{cascade-BmvsXcAz.d.cts → cascade-DWQfTwaM.d.cts} +2 -2
  4. package/dist/{codec-BAz7YIru.d.cts → codec-LgpdP32n.d.cts} +13 -13
  5. package/dist/{codec-BxxFEqvT.d.ts → codec-sFSMk-if.d.ts} +13 -13
  6. package/dist/codec.d.cts +1 -1
  7. package/dist/codec.d.ts +1 -1
  8. package/dist/{constructs-CJpDDQV0.d.ts → constructs-B1yajQJB.d.ts} +8 -1
  9. package/dist/{constructs-Dy_DMFs3.d.cts → constructs-BSC_5kfU.d.cts} +8 -1
  10. package/dist/embedded-BSSdoKcK.js +904 -0
  11. package/dist/{embedded-BPhuSEEI.d.ts → embedded-ClsebpWi.d.ts} +7 -2
  12. package/dist/embedded-DbLrCGPi.cjs +945 -0
  13. package/dist/{embedded-J3M3kDvY.d.cts → embedded-rKOsAsjg.d.cts} +7 -2
  14. package/dist/{form-D3H5H2NL.d.ts → form-CsOrcORr.d.ts} +2 -2
  15. package/dist/{form-BGCT81ss.d.cts → form-D8wh-xhJ.d.cts} +2 -2
  16. package/dist/{forms-cIjw-Jf-.d.cts → forms-BydLKkI0.d.cts} +1 -1
  17. package/dist/{forms-D1-0spCe.d.ts → forms-iwRSwhOn.d.ts} +1 -1
  18. package/dist/index.cjs +7 -9
  19. package/dist/index.d.cts +15 -15
  20. package/dist/index.d.ts +15 -15
  21. package/dist/index.js +2 -4
  22. package/dist/{masterpage-XJ2v2khe.d.cts → masterpage-Bt6gxuoL.d.cts} +2 -1
  23. package/dist/{masterpage-C1McDhMv.d.ts → masterpage-By_F05W4.d.ts} +2 -1
  24. package/dist/{paragraph-6hzAZpmi.d.ts → paragraph-BE71DZ0t.d.ts} +4 -3
  25. package/dist/{paragraph-BBmSl_sK.d.cts → paragraph-CuEMXbDg.d.cts} +4 -3
  26. package/dist/{properties-BF_Fv6B3.d.cts → properties-C-JKQZUD.d.cts} +2 -0
  27. package/dist/{properties-DjAIdPry.d.ts → properties-Rral02h1.d.ts} +2 -0
  28. package/dist/read-24g5eZw6.d.ts +25 -0
  29. package/dist/{read-lc0t0UHK.d.ts → read-BLoaDxr_.d.ts} +2 -1
  30. package/dist/{read-B4238IGr.d.cts → read-C3Ei_MYc.d.cts} +2 -1
  31. package/dist/{read-CTfeWaWq.d.cts → read-CDSmR3qt.d.cts} +2 -1
  32. package/dist/{read-CdvX2qnz.d.ts → read-DJqvINGW.d.ts} +2 -1
  33. package/dist/{read-Db_GZ0ZH.d.ts → read-DfEHXwgn.d.ts} +2 -1
  34. package/dist/{read-DOYWO6BM.d.cts → read-IOYq80AA.d.cts} +2 -1
  35. package/dist/read-rwDsgR0d.d.cts +25 -0
  36. package/dist/{registry-CaJpWDke.d.cts → registry-CphRYjDD.d.cts} +1 -1
  37. package/dist/{registry-BVeEpUMI.d.ts → registry-D5RGBteE.d.ts} +1 -1
  38. package/dist/{serialize-DvaE_t5D.d.ts → serialize-B-lq0LiG.d.ts} +1 -1
  39. package/dist/{serialize-9xvti0FF.d.cts → serialize-D1fti8C5.d.cts} +1 -1
  40. package/dist/styles/properties.cjs +25 -3
  41. package/dist/styles/properties.d.cts +1 -1
  42. package/dist/styles/properties.d.ts +1 -1
  43. package/dist/styles/properties.js +25 -3
  44. package/dist/styles/registry.d.cts +1 -1
  45. package/dist/styles/registry.d.ts +1 -1
  46. package/dist/styles/serialize.d.cts +1 -1
  47. package/dist/styles/serialize.d.ts +1 -1
  48. package/dist/typed/draw/embedded.cjs +4 -85
  49. package/dist/typed/draw/embedded.d.cts +2 -2
  50. package/dist/typed/draw/embedded.d.ts +2 -2
  51. package/dist/typed/draw/embedded.js +2 -84
  52. package/dist/typed/draw/shapes.cjs +4 -1
  53. package/dist/typed/draw/shapes.js +4 -1
  54. package/dist/typed/odb/form.cjs +2 -2
  55. package/dist/typed/odb/form.d.cts +1 -1
  56. package/dist/typed/odb/form.d.ts +1 -1
  57. package/dist/typed/odb/form.js +1 -1
  58. package/dist/typed/odg/read.cjs +14 -4
  59. package/dist/typed/odg/read.d.cts +1 -1
  60. package/dist/typed/odg/read.d.ts +1 -1
  61. package/dist/typed/odg/read.js +14 -4
  62. package/dist/typed/odp/read.cjs +51 -4
  63. package/dist/typed/odp/read.d.cts +1 -1
  64. package/dist/typed/odp/read.d.ts +1 -1
  65. package/dist/typed/odp/read.js +52 -5
  66. package/dist/typed/ods/read.cjs +3 -446
  67. package/dist/typed/ods/read.d.cts +1 -1
  68. package/dist/typed/ods/read.d.ts +1 -1
  69. package/dist/typed/ods/read.js +1 -444
  70. package/dist/typed/odt/read.cjs +3 -310
  71. package/dist/typed/odt/read.d.cts +2 -2
  72. package/dist/typed/odt/read.d.ts +2 -2
  73. package/dist/typed/odt/read.js +1 -308
  74. package/dist/typed/shared/cascade.d.cts +1 -1
  75. package/dist/typed/shared/cascade.d.ts +1 -1
  76. package/dist/typed/shared/constructs.cjs +73 -0
  77. package/dist/typed/shared/constructs.d.cts +2 -2
  78. package/dist/typed/shared/constructs.d.ts +2 -2
  79. package/dist/typed/shared/constructs.js +67 -1
  80. package/dist/typed/shared/forms.d.cts +1 -1
  81. package/dist/typed/shared/forms.d.ts +1 -1
  82. package/dist/typed/shared/masterpage.cjs +7 -0
  83. package/dist/typed/shared/masterpage.d.cts +2 -2
  84. package/dist/typed/shared/masterpage.d.ts +2 -2
  85. package/dist/typed/shared/masterpage.js +7 -1
  86. package/dist/typed/shared/paragraph.cjs +17 -6
  87. package/dist/typed/shared/paragraph.d.cts +2 -2
  88. package/dist/typed/shared/paragraph.d.ts +2 -2
  89. package/dist/typed/shared/paragraph.js +18 -8
  90. package/package.json +2 -2
  91. package/dist/read-Cs1ktkWB.d.cts +0 -15
  92. package/dist/read-DHuiGh_y.d.ts +0 -15
@@ -1,445 +1,2 @@
1
- import { parseOdfLength } from "../shared/units.js";
2
- import { attrValue, childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
3
- import { TableCursor, parseCellReference as parseCellReference$1 } from "../shared/a1.js";
4
- import { parseMargins, parsePageSize } from "../shared/geometry.js";
5
- import { findStyleElement, resolveStyleElementChain } from "../shared/cascade.js";
6
- import { readOdfMetadata } from "../shared/metadata.js";
7
- import { collectOdfNamedExpressions } from "../shared/constructs.js";
8
- import { readOdfParagraph } from "../shared/paragraph.js";
9
- import { readCellStyleDecoration } from "../shared/table.js";
10
- import { parseOdfTransform } from "../shared/transform.js";
11
- import { resolvePageLayoutProperties } from "../shared/masterpage.js";
12
- import { readDrawFrame } from "../draw/shapes.js";
13
- import { readOdfFormulaContent } from "../formula/read.js";
14
- import { readDrawObjectReference, readOdfChartContent } from "../draw/embedded.js";
15
- import { readOdpContent } from "../odp/read.js";
16
- import { readOdgContent } from "../odg/read.js";
17
- import { readOdtContent } from "../odt/read.js";
18
- import { PAGE_SIZE_A4, assemblePackage } from "document-schema.js";
19
- //#region src/typed/ods/read.ts
20
- const CONTENT_PART = "content.xml";
21
- function parseKnownOdfLength(value) {
22
- const parsed = parseOdfLength(value);
23
- if (parsed === void 0) throw new Error(`readOdsContent: internal error -- "${value}" is not a valid ODF length literal`);
24
- return parsed;
25
- }
26
- const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
27
- const DEFAULT_MARGINS = {
28
- topPt: DEFAULT_MARGIN_PT,
29
- rightPt: DEFAULT_MARGIN_PT,
30
- bottomPt: DEFAULT_MARGIN_PT,
31
- leftPt: DEFAULT_MARGIN_PT
32
- };
33
- function readRepeatCount(element, attrName) {
34
- const raw = attrValue(element, attrName);
35
- if (raw === void 0) return 1;
36
- const parsed = Number.parseInt(raw, 10);
37
- return Number.isInteger(parsed) && parsed > 0 ? parsed : 1;
38
- }
39
- function isHidden(element) {
40
- return attrValue(element, "table:visibility") === "collapse";
41
- }
42
- const DEFAULT_COLUMN_WIDTH_PT = 64;
43
- const DEFAULT_ROW_HEIGHT_PT = 15;
44
- function readColumnLayout(columnElement, pkg) {
45
- const styleName = attrValue(columnElement, "table:style-name");
46
- const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, "table-column", pkg);
47
- const properties = styleElement === void 0 ? void 0 : childrenWithTag(styleElement, "style:table-column-properties")[0];
48
- const widthValue = properties === void 0 ? void 0 : attrValue(properties, "style:column-width");
49
- return {
50
- widthPt: widthValue === void 0 ? DEFAULT_COLUMN_WIDTH_PT : parseOdfLength(widthValue) ?? DEFAULT_COLUMN_WIDTH_PT,
51
- manualBreak: (properties === void 0 ? void 0 : attrValue(properties, "fo:break-before")) === "page"
52
- };
53
- }
54
- function readRowLayout(rowElement, pkg) {
55
- const styleName = attrValue(rowElement, "table:style-name");
56
- const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, "table-row", pkg);
57
- const properties = styleElement === void 0 ? void 0 : childrenWithTag(styleElement, "style:table-row-properties")[0];
58
- const heightValue = properties === void 0 ? void 0 : attrValue(properties, "style:row-height");
59
- return {
60
- heightPt: heightValue === void 0 ? DEFAULT_ROW_HEIGHT_PT : parseOdfLength(heightValue) ?? DEFAULT_ROW_HEIGHT_PT,
61
- manualBreak: (properties === void 0 ? void 0 : attrValue(properties, "fo:break-before")) === "page"
62
- };
63
- }
64
- function readCellText(cellElement, pkg) {
65
- const paragraphs = childrenWithTag(cellElement, "text:p");
66
- const runs = [];
67
- paragraphs.forEach((paragraph, index) => {
68
- if (index > 0) runs.push({ text: "\n" });
69
- runs.push(...readOdfParagraph(paragraph, pkg).runs);
70
- });
71
- return {
72
- runs,
73
- displayText: runs.map((run) => run.text).join("")
74
- };
75
- }
76
- function readCellValue(cellElement, displayText) {
77
- const valueType = attrValue(cellElement, "office:value-type");
78
- const stringFallback = {
79
- kind: "string",
80
- value: displayText
81
- };
82
- switch (valueType) {
83
- case "float": {
84
- const value = parseRequiredNumber(attrValue(cellElement, "office:value"));
85
- return value === void 0 ? stringFallback : {
86
- kind: "number",
87
- value
88
- };
89
- }
90
- case "percentage": {
91
- const value = parseRequiredNumber(attrValue(cellElement, "office:value"));
92
- return value === void 0 ? stringFallback : {
93
- kind: "percentage",
94
- value
95
- };
96
- }
97
- case "currency": {
98
- const value = parseRequiredNumber(attrValue(cellElement, "office:value"));
99
- if (value === void 0) return stringFallback;
100
- const currency = attrValue(cellElement, "office:currency");
101
- return currency === void 0 ? {
102
- kind: "currency",
103
- value
104
- } : {
105
- kind: "currency",
106
- value,
107
- currency
108
- };
109
- }
110
- case "boolean": {
111
- const raw = attrValue(cellElement, "office:boolean-value");
112
- return raw === void 0 ? stringFallback : {
113
- kind: "boolean",
114
- value: raw === "true"
115
- };
116
- }
117
- case "date": return {
118
- kind: "date",
119
- value: attrValue(cellElement, "office:date-value") ?? displayText
120
- };
121
- case "time": return {
122
- kind: "time",
123
- value: attrValue(cellElement, "office:time-value") ?? displayText
124
- };
125
- case "string": return {
126
- kind: "string",
127
- value: attrValue(cellElement, "office:string-value") ?? displayText
128
- };
129
- default: return { kind: "empty" };
130
- }
131
- }
132
- function parseRequiredNumber(raw) {
133
- if (raw === void 0) return;
134
- const value = Number(raw);
135
- return Number.isNaN(value) ? void 0 : value;
136
- }
137
- function parsePrintRanges(value) {
138
- const first = value.split(" ").find((part) => part.length > 0);
139
- if (first === void 0) return;
140
- const separatorIndex = first.indexOf(":");
141
- if (separatorIndex === -1) return;
142
- const start = parseA1WithOptionalSheetPrefix(first.slice(0, separatorIndex));
143
- const end = parseA1WithOptionalSheetPrefix(first.slice(separatorIndex + 1));
144
- if (start === void 0 || end === void 0) return;
145
- return {
146
- startRow: start.row,
147
- startColumn: start.column,
148
- endRow: end.row,
149
- endColumn: end.column
150
- };
151
- }
152
- function parseA1WithOptionalSheetPrefix(cellPart) {
153
- const dotIndex = cellPart.lastIndexOf(".");
154
- const bareReference = dotIndex === -1 ? cellPart : cellPart.slice(dotIndex + 1);
155
- return parseCellReference$1(bareReference);
156
- }
157
- function parseScalePercentage(value) {
158
- const match = /^(\d+(?:\.\d+)?)%$/.exec(value);
159
- if (match === null) return;
160
- const numeric = match[1];
161
- return numeric === void 0 ? void 0 : Number(numeric);
162
- }
163
- function parseNonNegativeInteger(value) {
164
- if (value === void 0) return;
165
- const parsed = Number.parseInt(value, 10);
166
- return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
167
- }
168
- function readEmbeddedObjectDocument(reference, frame) {
169
- switch (reference.objectKind) {
170
- case "wordprocessing": {
171
- const { metadata, sections } = readOdtContent(reference.package);
172
- return {
173
- kind: "wordprocessing",
174
- metadata,
175
- sections
176
- };
177
- }
178
- case "presentation": {
179
- const { metadata, slides } = readOdpContent(reference.package);
180
- return {
181
- kind: "presentation",
182
- metadata,
183
- slides
184
- };
185
- }
186
- case "drawing": {
187
- const { metadata, pages } = readOdgContent(reference.package);
188
- return {
189
- kind: "drawing",
190
- metadata,
191
- pages
192
- };
193
- }
194
- case "spreadsheet": {
195
- const { metadata, sheets } = readOdsContent(reference.package);
196
- return {
197
- kind: "spreadsheet",
198
- metadata,
199
- sheets
200
- };
201
- }
202
- case "formula": return readOdfFormulaContent(reference.package);
203
- case "chart": return readOdfChartContent(reference.package, frame, "ods").document;
204
- }
205
- }
206
- function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
207
- const shape = readDrawFrame(frameElement, groupFunctions, pkg);
208
- if (shape === void 0) return;
209
- const reference = readDrawObjectReference(frameElement, pkg);
210
- if (reference?.objectKind === "chart") {
211
- const { document, residue } = readOdfChartContent(reference.package, shape.frame, "ods");
212
- const chartObject = {
213
- objectKind: "chart",
214
- document,
215
- frame: shape.frame,
216
- anchorRow,
217
- anchorColumn,
218
- offsetXPt: shape.frame.xPt,
219
- offsetYPt: shape.frame.yPt
220
- };
221
- if (residue !== void 0) chartObject.source = residue;
222
- embeddedObjects.push(chartObject);
223
- return;
224
- }
225
- if (reference !== void 0) {
226
- embeddedObjects.push({
227
- objectKind: reference.objectKind,
228
- document: readEmbeddedObjectDocument(reference, shape.frame),
229
- frame: shape.frame,
230
- anchorRow,
231
- anchorColumn,
232
- offsetXPt: shape.frame.xPt,
233
- offsetYPt: shape.frame.yPt
234
- });
235
- return;
236
- }
237
- for (const block of shape.blocks) if (block.kind === "image") images.push({
238
- ...block,
239
- anchorRow,
240
- anchorColumn,
241
- offsetXPt: shape.frame.xPt,
242
- offsetYPt: shape.frame.yPt
243
- });
244
- }
245
- function collectAnchoredFrames(children, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
246
- for (const child of children) {
247
- if (child.type !== "element") continue;
248
- if (child.tag === "draw:frame") collectAnchoredFrame(child, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects);
249
- else if (child.tag === "draw:g") {
250
- const ownValue = attrValue(child, "draw:transform");
251
- const ownFunctions = ownValue === void 0 ? [] : parseOdfTransform(ownValue);
252
- const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
253
- collectAnchoredFrames(child.children, nested, pkg, anchorRow, anchorColumn, images, embeddedObjects);
254
- }
255
- }
256
- }
257
- function readTable(tableElement, pkg) {
258
- const columns = [];
259
- const rows = [];
260
- const cells = [];
261
- const images = [];
262
- const embeddedObjects = [];
263
- const manualBreakRows = [];
264
- const manualBreakColumns = [];
265
- let repeatColumns;
266
- let repeatRows;
267
- let columnCursor = 0;
268
- const cursor = new TableCursor();
269
- function processColumn(columnElement) {
270
- const { widthPt, manualBreak } = readColumnLayout(columnElement, pkg);
271
- columns.push({
272
- index: columnCursor,
273
- widthPt,
274
- hidden: isHidden(columnElement) ? true : void 0
275
- });
276
- if (manualBreak) manualBreakColumns.push(columnCursor);
277
- columnCursor += readRepeatCount(columnElement, "table:number-columns-repeated");
278
- }
279
- function processRowCells(rowElement) {
280
- for (const child of rowElement.children) {
281
- if (child.type !== "element") continue;
282
- if (child.tag === "table:covered-table-cell") cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
283
- else if (child.tag === "table:table-cell") {
284
- const columnIndex = cursor.columnIndex;
285
- const rowIndex = cursor.rowIndex;
286
- cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
287
- collectAnchoredFrames(child.children, [], pkg, rowIndex, columnIndex, images, embeddedObjects);
288
- const formula = attrValue(child, "table:formula");
289
- const { runs, displayText } = readCellText(child, pkg);
290
- if (!(attrValue(child, "office:value-type") !== void 0) && formula === void 0 && displayText.length === 0) continue;
291
- const value = readCellValue(child, displayText);
292
- const colSpan = parseNonNegativeInteger(attrValue(child, "table:number-columns-spanned"));
293
- const rowSpan = parseNonNegativeInteger(attrValue(child, "table:number-rows-spanned"));
294
- const cell = {
295
- row: rowIndex,
296
- column: columnIndex,
297
- value,
298
- displayText
299
- };
300
- if (formula !== void 0) cell.formula = formula;
301
- if (runs.length > 0) cell.runs = runs;
302
- if (colSpan !== void 0) cell.colSpan = colSpan;
303
- if (rowSpan !== void 0) cell.rowSpan = rowSpan;
304
- const cellStyleName = attrValue(child, "table:style-name");
305
- const { elements: cellStyleChain } = resolveStyleElementChain(cellStyleName, "table-cell", pkg);
306
- const decoration = readCellStyleDecoration(cellStyleChain);
307
- if (decoration.background !== void 0) cell.background = decoration.background;
308
- if (decoration.borders !== void 0) cell.borders = decoration.borders;
309
- if (decoration.alignment !== void 0) cell.alignment = decoration.alignment;
310
- if (decoration.verticalAlignment !== void 0) cell.verticalAlignment = decoration.verticalAlignment;
311
- cells.push(cell);
312
- }
313
- }
314
- }
315
- function processRow(rowElement) {
316
- const startIndex = cursor.rowIndex;
317
- processRowCells(rowElement);
318
- const { heightPt, manualBreak } = readRowLayout(rowElement, pkg);
319
- rows.push({
320
- index: startIndex,
321
- heightPt,
322
- hidden: isHidden(rowElement) ? true : void 0
323
- });
324
- if (manualBreak) manualBreakRows.push(startIndex);
325
- cursor.nextRow(readRepeatCount(rowElement, "table:number-rows-repeated"));
326
- }
327
- for (const child of tableElement.children) {
328
- if (child.type !== "element") continue;
329
- if (child.tag === "table:shapes") collectAnchoredFrames(child.children, [], pkg, 0, 0, images, embeddedObjects);
330
- else if (child.tag === "table:table-column") processColumn(child);
331
- else if (child.tag === "table:table-header-columns") {
332
- const startIndex = columnCursor;
333
- for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
334
- if (columnCursor > startIndex) repeatColumns = {
335
- start: startIndex,
336
- end: columnCursor - 1
337
- };
338
- } else if (child.tag === "table:table-row") processRow(child);
339
- else if (child.tag === "table:table-header-rows") {
340
- const startIndex = cursor.rowIndex;
341
- for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-row") processRow(headerChild);
342
- if (cursor.rowIndex > startIndex) repeatRows = {
343
- start: startIndex,
344
- end: cursor.rowIndex - 1
345
- };
346
- }
347
- }
348
- return {
349
- columns,
350
- rows,
351
- cells,
352
- images,
353
- embeddedObjects,
354
- repeatColumns,
355
- repeatRows,
356
- manualBreakRows,
357
- manualBreakColumns
358
- };
359
- }
360
- function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns) {
361
- const tableStyleName = attrValue(tableElement, "table:style-name");
362
- const tableStyleElement = tableStyleName === void 0 ? void 0 : findStyleElement(tableStyleName, "table", pkg);
363
- const masterPageName = tableStyleElement === void 0 ? void 0 : attrValue(tableStyleElement, "style:master-page-name");
364
- const layoutProperties = resolvePageLayoutProperties(pkg, masterPageName);
365
- const pageSize = layoutProperties === void 0 ? void 0 : parsePageSize(layoutProperties);
366
- const margins = layoutProperties === void 0 ? void 0 : parseMargins(layoutProperties);
367
- const printTokens = new Set((layoutProperties === void 0 ? void 0 : attrValue(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0));
368
- const pageOrder = (layoutProperties === void 0 ? void 0 : attrValue(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
369
- const scaleToRaw = layoutProperties === void 0 ? void 0 : attrValue(layoutProperties, "style:scale-to");
370
- const scale = scaleToRaw === void 0 ? void 0 : parseScalePercentage(scaleToRaw);
371
- const scaleToXRaw = layoutProperties === void 0 ? void 0 : attrValue(layoutProperties, "style:scale-to-X");
372
- const scaleToYRaw = layoutProperties === void 0 ? void 0 : attrValue(layoutProperties, "style:scale-to-Y");
373
- const fitWidth = parseNonNegativeInteger(scaleToXRaw);
374
- const fitHeight = parseNonNegativeInteger(scaleToYRaw);
375
- const fitToPages = fitWidth === void 0 || fitHeight === void 0 ? void 0 : {
376
- width: fitWidth,
377
- height: fitHeight
378
- };
379
- const printRangesRaw = attrValue(tableElement, "table:print-ranges");
380
- const printRange = printRangesRaw === void 0 ? void 0 : parsePrintRanges(printRangesRaw);
381
- const manualBreaks = manualBreakRows.length > 0 || manualBreakColumns.length > 0 ? {
382
- rows: manualBreakRows,
383
- columns: manualBreakColumns
384
- } : void 0;
385
- const settings = {
386
- pageSize: pageSize ?? PAGE_SIZE_A4,
387
- margins: margins ?? DEFAULT_MARGINS,
388
- gridlines: printTokens.has("grid"),
389
- headers: printTokens.has("headers"),
390
- pageOrder
391
- };
392
- if (printRange !== void 0) settings.printRange = printRange;
393
- if (scale !== void 0) settings.scalePercent = scale;
394
- if (fitToPages !== void 0) settings.fitToPages = fitToPages;
395
- if (repeatRows !== void 0) settings.repeatRows = repeatRows;
396
- if (repeatColumns !== void 0) settings.repeatColumns = repeatColumns;
397
- if (manualBreaks !== void 0) settings.manualBreaks = manualBreaks;
398
- return settings;
399
- }
400
- function readSheet(tableElement, pkg) {
401
- const name = attrValue(tableElement, "table:name");
402
- if (name === void 0) return;
403
- const { columns, rows, cells, images, embeddedObjects, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
404
- const sheet = {
405
- name,
406
- cells,
407
- columns,
408
- rows,
409
- images,
410
- printSettings: readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns)
411
- };
412
- if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
413
- return sheet;
414
- }
415
- function readOdsContent(pkg) {
416
- const contentPart = pkg.parts[CONTENT_PART];
417
- const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
418
- const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
419
- const spreadsheet = body === void 0 ? void 0 : findChildElement(body.children, "office:spreadsheet");
420
- const tables = spreadsheet === void 0 ? [] : childrenWithTag(spreadsheet, "table:table");
421
- const sheets = [];
422
- for (const table of tables) {
423
- const sheet = readSheet(table, pkg);
424
- if (sheet !== void 0) sheets.push(sheet);
425
- }
426
- const definitions = {};
427
- if (spreadsheet !== void 0) collectOdfNamedExpressions(spreadsheet.children, definitions);
428
- return {
429
- metadata: readOdfMetadata(pkg),
430
- sheets,
431
- ...Object.keys(definitions).length > 0 ? { definitions } : {}
432
- };
433
- }
434
- function readOds(pkg) {
435
- const { metadata, sheets, definitions } = readOdsContent(pkg);
436
- const assembled = assemblePackage({
437
- kind: "spreadsheet",
438
- metadata,
439
- sheets
440
- });
441
- if (definitions !== void 0) assembled.definitions = definitions;
442
- return assembled;
443
- }
444
- //#endregion
1
+ import { o as readOds, s as readOdsContent } from "../../embedded-BSSdoKcK.js";
445
2
  export { readOds, readOdsContent };