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