odf.js 5.0.8 → 5.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 +16 -2
- package/dist/{cascade-qYa3mgnE.d.cts → cascade-BmvsXcAz.d.cts} +2 -2
- package/dist/{cascade-8u4q16_U.d.ts → cascade-rhqUQrUa.d.ts} +2 -2
- package/dist/{codec-jKlS0rWl.d.cts → codec-BAz7YIru.d.cts} +26 -25
- package/dist/{codec-DqldvlN5.d.ts → codec-BxxFEqvT.d.ts} +26 -25
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/constructs-CJpDDQV0.d.ts +63 -0
- package/dist/constructs-Dy_DMFs3.d.cts +63 -0
- package/dist/embedded-BPhuSEEI.d.ts +18 -0
- package/dist/embedded-J3M3kDvY.d.cts +18 -0
- package/dist/form-BGCT81ss.d.cts +13 -0
- package/dist/form-D3H5H2NL.d.ts +13 -0
- package/dist/forms-D1-0spCe.d.ts +27 -0
- package/dist/forms-cIjw-Jf-.d.cts +27 -0
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +28 -27
- package/dist/index.d.ts +28 -27
- package/dist/index.js +4 -3
- package/dist/{list-C35tiDYU.d.cts → list-KZeXA0mR.d.cts} +1 -1
- package/dist/{list-acGU0xLo.d.ts → list-Qeuawtew.d.ts} +1 -1
- package/dist/{manifest-xxJ4FpSe.d.ts → manifest-BALwu2JR.d.cts} +1 -1
- package/dist/{manifest-CmsCOCEi.d.cts → manifest-CP1sqyGU.d.ts} +1 -1
- package/dist/manifest.d.cts +1 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/{masterpage-7nBnqFj-.d.ts → masterpage-C1McDhMv.d.ts} +1 -1
- package/dist/{masterpage-EmefIRgy.d.cts → masterpage-XJ2v2khe.d.cts} +1 -1
- package/dist/{metadata-32LoP2TK.d.ts → metadata-1j1zm9Cx.d.cts} +1 -1
- package/dist/{metadata-frJqeeSB.d.cts → metadata-BXpjrAS-.d.ts} +1 -1
- package/dist/{mimetype-uF-RHNpR.d.ts → mimetype-BfkwTeaW.d.ts} +1 -1
- package/dist/{mimetype-BcLX0N-N.d.cts → mimetype-CPNMj04s.d.cts} +1 -1
- package/dist/mimetype.d.cts +1 -1
- package/dist/mimetype.d.ts +1 -1
- package/dist/model/package.d.cts +1 -113
- package/dist/model/package.d.ts +1 -113
- package/dist/package-BUojjTXf.d.ts +114 -0
- package/dist/package-L24lkba-.d.cts +114 -0
- package/dist/package-io/read.d.cts +1 -1
- package/dist/package-io/read.d.ts +1 -1
- package/dist/package-io/write.d.cts +1 -1
- package/dist/package-io/write.d.ts +1 -1
- package/dist/paragraph-6hzAZpmi.d.ts +16 -0
- package/dist/paragraph-BBmSl_sK.d.cts +16 -0
- package/dist/read-B4238IGr.d.cts +12 -0
- package/dist/{read-DrdmKX0x.d.cts → read-BV2an1ok.d.cts} +1 -1
- package/dist/{read-DOuXgPhP.d.ts → read-BnN7u9Y2.d.ts} +1 -1
- package/dist/{read-DhLNXgiM.d.ts → read-CMDEXqGw.d.ts} +1 -1
- package/dist/{read-YSIwlhrk.d.ts → read-CTfeWaWq.d.cts} +1 -1
- package/dist/read-CdvX2qnz.d.ts +12 -0
- package/dist/read-Cs1ktkWB.d.cts +15 -0
- package/dist/{read-BoIUENWq.d.ts → read-CvjbdgH3.d.ts} +1 -1
- package/dist/read-DHuiGh_y.d.ts +15 -0
- package/dist/{read-BM8KaFQS.d.cts → read-DOYWO6BM.d.cts} +1 -1
- package/dist/{read-xCmo7cec.d.cts → read-DUCm1nUv.d.cts} +1 -1
- package/dist/{read-BkFbEves.d.ts → read-DYYxbvfo.d.ts} +1 -1
- package/dist/{read-KpU38maT.d.cts → read-Db_GZ0ZH.d.ts} +1 -1
- package/dist/{read-CFMsXSl7.d.cts → read-DzmMJPHd.d.cts} +1 -1
- package/dist/{read-B9zz_ax1.d.ts → read-lc0t0UHK.d.ts} +1 -1
- package/dist/{read-DNNf5_6n.d.cts → read-ydLJ8bid.d.cts} +1 -1
- package/dist/{registry-R43n1hcL.d.ts → registry-BVeEpUMI.d.ts} +1 -1
- package/dist/{registry-Dy6pjoh3.d.cts → registry-CaJpWDke.d.cts} +1 -1
- package/dist/{report-MpwUgXbA.d.ts → report-D6WNYaVn.d.cts} +1 -1
- package/dist/{report-BuCJ7_YU.d.cts → report-DbslT2OR.d.ts} +1 -1
- package/dist/{shapes-BqcccDK8.d.cts → shapes-8o3NjBLU.d.cts} +3 -3
- package/dist/{shapes-BB59aIC8.d.ts → shapes-CCB8ydqD.d.ts} +3 -3
- package/dist/styles/registry.d.cts +1 -1
- package/dist/styles/registry.d.ts +1 -1
- package/dist/{subdocument-CIxH3a5V.d.cts → subdocument-BwW3FZC_.d.ts} +1 -1
- package/dist/{subdocument-DQNQF7wV.d.ts → subdocument-yY8ASE4N.d.cts} +1 -1
- package/dist/{table-sweV3r9n.d.cts → table-BH_Q2n_N.d.cts} +1 -1
- package/dist/{table-D81TZyBn.d.ts → table-ByOoGcq_.d.ts} +1 -1
- package/dist/{text-Cal14ZaX.d.cts → text-BAi1tapc.d.cts} +3 -1
- package/dist/{text-CkNojpZm.d.ts → text-gJ5R0q3u.d.ts} +3 -1
- package/dist/typed/draw/embedded.cjs +38 -0
- package/dist/typed/draw/embedded.d.cts +2 -2
- package/dist/typed/draw/embedded.d.ts +2 -2
- package/dist/typed/draw/embedded.js +39 -2
- package/dist/typed/draw/shapes.cjs +20 -3
- package/dist/typed/draw/shapes.d.cts +1 -1
- package/dist/typed/draw/shapes.d.ts +1 -1
- package/dist/typed/draw/shapes.js +20 -3
- package/dist/typed/formula/read.d.cts +1 -1
- package/dist/typed/formula/read.d.ts +1 -1
- package/dist/typed/odb/form.cjs +2 -59
- package/dist/typed/odb/form.d.cts +2 -2
- package/dist/typed/odb/form.d.ts +2 -2
- package/dist/typed/odb/form.js +3 -60
- package/dist/typed/odb/read.d.cts +1 -1
- package/dist/typed/odb/read.d.ts +1 -1
- package/dist/typed/odb/report.d.cts +1 -1
- package/dist/typed/odb/report.d.ts +1 -1
- package/dist/typed/odb/subdocument.d.cts +1 -1
- package/dist/typed/odb/subdocument.d.ts +1 -1
- package/dist/typed/odg/read.d.cts +1 -1
- package/dist/typed/odg/read.d.ts +1 -1
- package/dist/typed/odm/read.d.cts +1 -1
- package/dist/typed/odm/read.d.ts +1 -1
- package/dist/typed/odp/read.d.cts +1 -1
- package/dist/typed/odp/read.d.ts +1 -1
- package/dist/typed/ods/read.cjs +28 -6
- package/dist/typed/ods/read.d.cts +1 -1
- package/dist/typed/ods/read.d.ts +1 -1
- package/dist/typed/ods/read.js +29 -7
- package/dist/typed/odt/read.cjs +215 -15
- package/dist/typed/odt/read.d.cts +2 -2
- package/dist/typed/odt/read.d.ts +2 -2
- package/dist/typed/odt/read.js +215 -15
- package/dist/typed/shared/cascade.d.cts +1 -1
- package/dist/typed/shared/cascade.d.ts +1 -1
- package/dist/typed/shared/constructs.cjs +392 -0
- package/dist/typed/shared/constructs.d.cts +2 -0
- package/dist/typed/shared/constructs.d.ts +2 -0
- package/dist/typed/shared/constructs.js +374 -0
- package/dist/typed/shared/forms.cjs +128 -0
- package/dist/typed/shared/forms.d.cts +2 -0
- package/dist/typed/shared/forms.d.ts +2 -0
- package/dist/typed/shared/forms.js +126 -0
- package/dist/typed/shared/list.d.cts +1 -1
- package/dist/typed/shared/list.d.ts +1 -1
- package/dist/typed/shared/masterpage.d.cts +1 -1
- package/dist/typed/shared/masterpage.d.ts +1 -1
- package/dist/typed/shared/metadata.d.cts +1 -1
- package/dist/typed/shared/metadata.d.ts +1 -1
- package/dist/typed/shared/paragraph.cjs +189 -10
- package/dist/typed/shared/paragraph.d.cts +2 -2
- package/dist/typed/shared/paragraph.d.ts +2 -2
- package/dist/typed/shared/paragraph.js +192 -13
- package/dist/typed/shared/table.d.cts +1 -1
- package/dist/typed/shared/table.d.ts +1 -1
- package/dist/typed/shared/text.cjs +57 -2
- package/dist/typed/shared/text.d.cts +2 -2
- package/dist/typed/shared/text.d.ts +2 -2
- package/dist/typed/shared/text.js +56 -3
- package/dist/{write-C0nwVuPI.d.ts → write-BxVkPZID.d.ts} +1 -1
- package/dist/{write-Dfb2tirK.d.cts → write-D3kyj1Xw.d.cts} +1 -1
- package/package.json +2 -2
- package/dist/embedded-CNMqOrnt.d.ts +0 -13
- package/dist/embedded-D7Kr1Sce.d.cts +0 -13
- package/dist/form-BsAAx5-p.d.ts +0 -31
- package/dist/form-DSIbHxog.d.cts +0 -31
- package/dist/paragraph-9ii2naJC.d.cts +0 -7
- package/dist/paragraph-DWNnedIE.d.ts +0 -7
- package/dist/read-B4zS8bGb.d.ts +0 -11
- package/dist/read-BHpPvhzR.d.cts +0 -11
- package/dist/read-C6MhadqG.d.ts +0 -11
- package/dist/read-CszvDMMt.d.cts +0 -11
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_build = require("../../xml/build.cjs");
|
|
3
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
4
|
+
const require_typed_shared_text = require("./text.cjs");
|
|
5
|
+
//#region src/typed/shared/constructs.ts
|
|
6
|
+
function odfFieldDescriptor(element) {
|
|
7
|
+
const cachedResult = require_typed_shared_text.decodeOdfText(element);
|
|
8
|
+
const descriptor = {
|
|
9
|
+
kind: "field",
|
|
10
|
+
instruction: require_xml_build.buildXml([{
|
|
11
|
+
...element,
|
|
12
|
+
children: []
|
|
13
|
+
}])
|
|
14
|
+
};
|
|
15
|
+
if (cachedResult.length > 0) descriptor.cachedResult = cachedResult;
|
|
16
|
+
return descriptor;
|
|
17
|
+
}
|
|
18
|
+
function odfBookmarkAnchorDescriptor(name) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "anchor",
|
|
21
|
+
anchorType: "bookmark",
|
|
22
|
+
name
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function odfResidue(format, ...elements) {
|
|
26
|
+
return {
|
|
27
|
+
format,
|
|
28
|
+
xml: require_xml_build.buildXml(elements)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function readOdfBooleanAttribute(element, name) {
|
|
32
|
+
const raw = require_xml_query.attrValue(element, name);
|
|
33
|
+
if (raw === "true") return true;
|
|
34
|
+
return raw === "false" ? false : void 0;
|
|
35
|
+
}
|
|
36
|
+
function findSectionStyleElement(styleName, pkg) {
|
|
37
|
+
for (const partPath of ["content.xml", "styles.xml"]) {
|
|
38
|
+
const part = pkg.parts[partPath];
|
|
39
|
+
if (part?.kind !== "xml") continue;
|
|
40
|
+
const root = require_xml_query.rootElement(part.nodes);
|
|
41
|
+
if (root === void 0) continue;
|
|
42
|
+
for (const containerTag of ["office:automatic-styles", "office:styles"]) {
|
|
43
|
+
const container = require_xml_query.findChildElement(root.children, containerTag);
|
|
44
|
+
if (container === void 0) continue;
|
|
45
|
+
for (const style of require_xml_query.childrenWithTag(container, "style:style")) if (require_xml_query.attrValue(style, "style:family") === "section" && require_xml_query.attrValue(style, "style:name") === styleName) return style;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function readDivisionColumnCount(sectionElement, pkg) {
|
|
50
|
+
const styleName = require_xml_query.attrValue(sectionElement, "text:style-name");
|
|
51
|
+
if (styleName === void 0) return;
|
|
52
|
+
const style = findSectionStyleElement(styleName, pkg);
|
|
53
|
+
if (style === void 0) return;
|
|
54
|
+
const properties = require_xml_query.findChildElement(style.children, "style:section-properties");
|
|
55
|
+
const columns = properties === void 0 ? void 0 : require_xml_query.findChildElement(properties.children, "style:columns");
|
|
56
|
+
const raw = columns === void 0 ? void 0 : require_xml_query.attrValue(columns, "fo:column-count");
|
|
57
|
+
if (raw === void 0) return;
|
|
58
|
+
const parsed = Number.parseInt(raw, 10);
|
|
59
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
60
|
+
}
|
|
61
|
+
function odfDivisionDescriptor(sectionElement, pkg) {
|
|
62
|
+
const descriptor = { kind: "division" };
|
|
63
|
+
const name = require_xml_query.attrValue(sectionElement, "text:name");
|
|
64
|
+
if (name !== void 0) descriptor.name = name;
|
|
65
|
+
const protectedFlag = readOdfBooleanAttribute(sectionElement, "text:protected");
|
|
66
|
+
if (protectedFlag !== void 0) descriptor.protected = protectedFlag;
|
|
67
|
+
const columnCount = readDivisionColumnCount(sectionElement, pkg);
|
|
68
|
+
if (columnCount !== void 0) descriptor.columnCount = columnCount;
|
|
69
|
+
const sourceElement = require_xml_query.findChildElement(sectionElement.children, "text:section-source");
|
|
70
|
+
if (sourceElement !== void 0) {
|
|
71
|
+
const href = require_xml_query.attrValue(sourceElement, "xlink:href");
|
|
72
|
+
if (href !== void 0) {
|
|
73
|
+
const source = { href };
|
|
74
|
+
const sectionName = require_xml_query.attrValue(sourceElement, "text:section-name");
|
|
75
|
+
if (sectionName !== void 0) source.sectionName = sectionName;
|
|
76
|
+
descriptor.source = source;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return descriptor;
|
|
80
|
+
}
|
|
81
|
+
const ODF_INDEX_WRAPPER_TAGS = /* @__PURE__ */ new Set([
|
|
82
|
+
"text:table-of-content",
|
|
83
|
+
"text:alphabetical-index",
|
|
84
|
+
"text:bibliography",
|
|
85
|
+
"text:illustration-index",
|
|
86
|
+
"text:table-index",
|
|
87
|
+
"text:user-index",
|
|
88
|
+
"text:object-index"
|
|
89
|
+
]);
|
|
90
|
+
function isOdfIndexWrapper(element) {
|
|
91
|
+
return ODF_INDEX_WRAPPER_TAGS.has(element.tag);
|
|
92
|
+
}
|
|
93
|
+
function odfIndexControlDescriptor(wrapper) {
|
|
94
|
+
const descriptor = {
|
|
95
|
+
kind: "contentControl",
|
|
96
|
+
controlType: "index"
|
|
97
|
+
};
|
|
98
|
+
const name = require_xml_query.attrValue(wrapper, "text:name");
|
|
99
|
+
if (name !== void 0) descriptor.tag = name;
|
|
100
|
+
for (const child of wrapper.children) if (child.type === "element" && child.tag.endsWith("-source")) {
|
|
101
|
+
descriptor.source = odfResidue("odt", child);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
return descriptor;
|
|
105
|
+
}
|
|
106
|
+
function isContentBearingNode(node) {
|
|
107
|
+
if (node.type === "text") return node.value.length > 0;
|
|
108
|
+
if (node.type !== "element") return false;
|
|
109
|
+
return require_typed_shared_text.isOdfFieldElement(node) || node.tag === "text:s" || node.tag === "text:tab" || node.tag === "text:line-break" || node.tag === "text:span" || node.tag === "text:a" || node.tag === "text:note" || node.tag === "office:annotation";
|
|
110
|
+
}
|
|
111
|
+
function edgePosition(siblings, index) {
|
|
112
|
+
let leading = true;
|
|
113
|
+
for (let before = 0; before < index; before += 1) if (isContentBearingNode(siblings[before])) {
|
|
114
|
+
leading = false;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (leading) return "leading";
|
|
118
|
+
for (let after = index + 1; after < siblings.length; after += 1) if (isContentBearingNode(siblings[after])) return;
|
|
119
|
+
return "trailing";
|
|
120
|
+
}
|
|
121
|
+
function odfMarkerHalfEventIndex(half, paragraphElement, paragraphStartIndex, liftedBlocksBeforeHalf = 0) {
|
|
122
|
+
if (half.parent !== paragraphElement) return;
|
|
123
|
+
const index = half.parent.children.indexOf(half.element);
|
|
124
|
+
if (index === -1) return;
|
|
125
|
+
const edge = edgePosition(half.parent.children, index);
|
|
126
|
+
if (edge === "leading") return paragraphStartIndex;
|
|
127
|
+
return edge === "trailing" ? paragraphStartIndex + 1 + liftedBlocksBeforeHalf : void 0;
|
|
128
|
+
}
|
|
129
|
+
function isOdfBlockScopedHalf(half, paragraphElement) {
|
|
130
|
+
return odfMarkerHalfEventIndex(half, paragraphElement, 0) !== void 0;
|
|
131
|
+
}
|
|
132
|
+
function pairOdfMarkerHalves(halves, paragraphElement) {
|
|
133
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
134
|
+
for (const half of halves) {
|
|
135
|
+
const existing = byKey.get(half.key);
|
|
136
|
+
if (existing === void 0) byKey.set(half.key, [half]);
|
|
137
|
+
else existing.push(half);
|
|
138
|
+
}
|
|
139
|
+
const extents = [];
|
|
140
|
+
const paired = /* @__PURE__ */ new Set();
|
|
141
|
+
for (const pair of byKey.values()) {
|
|
142
|
+
const starts = pair.filter((half) => half.side === "start");
|
|
143
|
+
const ends = pair.filter((half) => half.side === "end");
|
|
144
|
+
const open = starts[0];
|
|
145
|
+
const close = ends[0];
|
|
146
|
+
if (starts.length !== 1 || ends.length !== 1 || open === void 0 || close === void 0) continue;
|
|
147
|
+
if (close.runPosition < open.runPosition) continue;
|
|
148
|
+
if (isOdfBlockScopedHalf(open, paragraphElement) && isOdfBlockScopedHalf(close, paragraphElement)) continue;
|
|
149
|
+
const descriptor = open.descriptor();
|
|
150
|
+
if (descriptor === void 0) continue;
|
|
151
|
+
extents.push({
|
|
152
|
+
descriptor,
|
|
153
|
+
startRun: open.runPosition,
|
|
154
|
+
endRun: close.runPosition
|
|
155
|
+
});
|
|
156
|
+
paired.add(open.element);
|
|
157
|
+
paired.add(close.element);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
extents,
|
|
161
|
+
paired
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function compareOdfExtents(a, b) {
|
|
165
|
+
return a.startIndex - b.startIndex || b.endIndex - a.endIndex || a.order - b.order;
|
|
166
|
+
}
|
|
167
|
+
function acceptProperlyNestedOdfExtents(extents) {
|
|
168
|
+
const sorted = [...extents].sort(compareOdfExtents);
|
|
169
|
+
const accepted = [];
|
|
170
|
+
const open = [];
|
|
171
|
+
for (const extent of sorted) {
|
|
172
|
+
while (open.length > 0 && open[open.length - 1].endIndex <= extent.startIndex) open.pop();
|
|
173
|
+
const enclosing = open[open.length - 1];
|
|
174
|
+
if (enclosing !== void 0 && enclosing.endIndex < extent.endIndex) continue;
|
|
175
|
+
accepted.push(extent);
|
|
176
|
+
open.push(extent);
|
|
177
|
+
}
|
|
178
|
+
return accepted;
|
|
179
|
+
}
|
|
180
|
+
function insertOdfConstructMarkers(blocks, extents) {
|
|
181
|
+
if (extents.length === 0) return [...blocks];
|
|
182
|
+
const nested = acceptProperlyNestedOdfExtents(extents);
|
|
183
|
+
const openingAt = /* @__PURE__ */ new Map();
|
|
184
|
+
for (const extent of nested) {
|
|
185
|
+
const existing = openingAt.get(extent.startIndex);
|
|
186
|
+
if (existing === void 0) openingAt.set(extent.startIndex, [extent]);
|
|
187
|
+
else existing.push(extent);
|
|
188
|
+
}
|
|
189
|
+
const out = [];
|
|
190
|
+
const open = [];
|
|
191
|
+
for (let index = 0; index <= blocks.length; index += 1) {
|
|
192
|
+
while (open.length > 0 && open[open.length - 1].endIndex === index) {
|
|
193
|
+
open.pop();
|
|
194
|
+
out.push({ kind: "constructEnd" });
|
|
195
|
+
}
|
|
196
|
+
for (const extent of openingAt.get(index) ?? []) {
|
|
197
|
+
out.push({
|
|
198
|
+
kind: "constructStart",
|
|
199
|
+
descriptor: extent.descriptor
|
|
200
|
+
});
|
|
201
|
+
if (extent.endIndex === index) out.push({ kind: "constructEnd" });
|
|
202
|
+
else open.push(extent);
|
|
203
|
+
}
|
|
204
|
+
const block = blocks[index];
|
|
205
|
+
if (block !== void 0) out.push(block);
|
|
206
|
+
}
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
function resolveOdfMarkerEvents(events) {
|
|
210
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const event of events) {
|
|
212
|
+
const mapKey = `${event.kind} ${event.key}`;
|
|
213
|
+
const existing = byKey.get(mapKey);
|
|
214
|
+
if (existing === void 0) byKey.set(mapKey, [event]);
|
|
215
|
+
else existing.push(event);
|
|
216
|
+
}
|
|
217
|
+
const extents = [];
|
|
218
|
+
const paired = /* @__PURE__ */ new Set();
|
|
219
|
+
for (const pair of byKey.values()) {
|
|
220
|
+
const starts = pair.filter((event) => event.side === "start" && event.qualified);
|
|
221
|
+
const ends = pair.filter((event) => event.side === "end" && event.qualified);
|
|
222
|
+
const open = starts[0];
|
|
223
|
+
const close = ends[0];
|
|
224
|
+
if (starts.length !== 1 || ends.length !== 1 || open === void 0 || close === void 0) continue;
|
|
225
|
+
if (close.index < open.index) continue;
|
|
226
|
+
const descriptor = open.descriptor();
|
|
227
|
+
if (descriptor === void 0) continue;
|
|
228
|
+
extents.push({
|
|
229
|
+
startIndex: open.index,
|
|
230
|
+
endIndex: close.index,
|
|
231
|
+
order: open.order,
|
|
232
|
+
descriptor
|
|
233
|
+
});
|
|
234
|
+
paired.add(open.element);
|
|
235
|
+
paired.add(close.element);
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
extents,
|
|
239
|
+
paired
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const ODF_PROVENANCE_CHANGE_BY_TAG = /* @__PURE__ */ new Map([
|
|
243
|
+
["text:insertion", "insertion"],
|
|
244
|
+
["text:deletion", "deletion"],
|
|
245
|
+
["text:format-change", "formatChange"]
|
|
246
|
+
]);
|
|
247
|
+
function odfChangedRegionId(region) {
|
|
248
|
+
return require_xml_query.attrValue(region, "xml:id") ?? require_xml_query.attrValue(region, "text:id");
|
|
249
|
+
}
|
|
250
|
+
function collectOdfProvenanceRegions(nodes, out) {
|
|
251
|
+
for (const region of require_xml_query.elementsWithTag(nodes, "text:changed-region")) {
|
|
252
|
+
const id = odfChangedRegionId(region);
|
|
253
|
+
if (id === void 0) continue;
|
|
254
|
+
const changeChild = region.children.find((child) => child.type === "element" && ODF_PROVENANCE_CHANGE_BY_TAG.has(child.tag));
|
|
255
|
+
if (changeChild === void 0) continue;
|
|
256
|
+
const descriptor = {
|
|
257
|
+
kind: "provenance",
|
|
258
|
+
change: ODF_PROVENANCE_CHANGE_BY_TAG.get(changeChild.tag)
|
|
259
|
+
};
|
|
260
|
+
const changeInfo = changeChild.children.find((child) => child.type === "element" && child.tag === "office:change-info");
|
|
261
|
+
if (changeInfo !== void 0) {
|
|
262
|
+
const creator = changeInfo.children.find((child) => child.type === "element" && child.tag === "dc:creator");
|
|
263
|
+
if (creator !== void 0) descriptor.author = require_typed_shared_text.decodeOdfText(creator);
|
|
264
|
+
const date = changeInfo.children.find((child) => child.type === "element" && child.tag === "dc:date");
|
|
265
|
+
if (date !== void 0) descriptor.dateIso = require_typed_shared_text.decodeOdfText(date);
|
|
266
|
+
}
|
|
267
|
+
out.set(id, descriptor);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const ODF_FIELD_MASTER_CONTAINERS = /* @__PURE__ */ new Map([
|
|
271
|
+
["text:variable-decls", "variable"],
|
|
272
|
+
["text:user-field-decls", "user-field"],
|
|
273
|
+
["text:sequence-decls", "sequence"]
|
|
274
|
+
]);
|
|
275
|
+
function readOdfFieldMasterEntry(family, decl) {
|
|
276
|
+
const name = require_xml_query.attrValue(decl, "text:name");
|
|
277
|
+
if (name === void 0) return;
|
|
278
|
+
const entry = {
|
|
279
|
+
kind: "fieldMaster",
|
|
280
|
+
family,
|
|
281
|
+
name
|
|
282
|
+
};
|
|
283
|
+
const valueType = require_xml_query.attrValue(decl, "office:value-type");
|
|
284
|
+
if (valueType !== void 0) entry.valueType = valueType;
|
|
285
|
+
const value = require_xml_query.attrValue(decl, "office:value");
|
|
286
|
+
if (value !== void 0) entry.value = value;
|
|
287
|
+
const stringValue = require_xml_query.attrValue(decl, "office:string-value");
|
|
288
|
+
if (stringValue !== void 0) entry.stringValue = stringValue;
|
|
289
|
+
const formula = require_xml_query.attrValue(decl, "text:formula");
|
|
290
|
+
if (formula !== void 0) entry.formula = formula;
|
|
291
|
+
const displayOutlineLevel = require_xml_query.attrValue(decl, "text:display-outline-level");
|
|
292
|
+
if (displayOutlineLevel !== void 0) {
|
|
293
|
+
const parsed = Number.parseInt(displayOutlineLevel, 10);
|
|
294
|
+
if (Number.isInteger(parsed) && parsed >= 0) entry.displayOutlineLevel = parsed;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
key: `${family}:${name}`,
|
|
298
|
+
entry
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function collectOdfFieldMasterDefinitions(nodes, out) {
|
|
302
|
+
for (const [containerTag, family] of ODF_FIELD_MASTER_CONTAINERS) for (const container of require_xml_query.elementsWithTag(nodes, containerTag)) for (const decl of container.children) {
|
|
303
|
+
if (decl.type !== "element") continue;
|
|
304
|
+
const read = readOdfFieldMasterEntry(family, decl);
|
|
305
|
+
if (read !== void 0) out[read.key] = read.entry;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const ODF_DATA_STYLE_TAGS = /* @__PURE__ */ new Set([
|
|
309
|
+
"number:boolean-style",
|
|
310
|
+
"number:currency-style",
|
|
311
|
+
"number:date-style",
|
|
312
|
+
"number:number-style",
|
|
313
|
+
"number:percentage-style",
|
|
314
|
+
"number:text-style",
|
|
315
|
+
"number:time-style"
|
|
316
|
+
]);
|
|
317
|
+
function collectOdfDataStyleDefinitions(nodes, out) {
|
|
318
|
+
for (const tag of ODF_DATA_STYLE_TAGS) for (const element of require_xml_query.elementsWithTag(nodes, tag)) {
|
|
319
|
+
const name = require_xml_query.attrValue(element, "style:name");
|
|
320
|
+
if (name === void 0) continue;
|
|
321
|
+
out[`dataStyle:${name}`] = {
|
|
322
|
+
kind: "dataStyle",
|
|
323
|
+
name,
|
|
324
|
+
xml: require_xml_build.buildXml([element])
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function collectOdfFontFaceDefinitions(nodes, out) {
|
|
329
|
+
for (const face of require_xml_query.elementsWithTag(nodes, "style:font-face")) {
|
|
330
|
+
const name = require_xml_query.attrValue(face, "style:name");
|
|
331
|
+
const family = require_xml_query.attrValue(face, "svg:font-family");
|
|
332
|
+
if (name === void 0 || family === void 0) continue;
|
|
333
|
+
const entry = {
|
|
334
|
+
kind: "fontFace",
|
|
335
|
+
name,
|
|
336
|
+
fontFamily: family
|
|
337
|
+
};
|
|
338
|
+
const generic = require_xml_query.attrValue(face, "style:font-family-generic");
|
|
339
|
+
if (generic !== void 0) entry.familyGeneric = generic;
|
|
340
|
+
const pitch = require_xml_query.attrValue(face, "style:font-pitch");
|
|
341
|
+
if (pitch !== void 0) entry.pitch = pitch;
|
|
342
|
+
out[`fontFace:${name}`] = entry;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function collectOdfNamedExpressions(nodes, out) {
|
|
346
|
+
for (const container of require_xml_query.elementsWithTag(nodes, "table:named-expressions")) for (const child of container.children) {
|
|
347
|
+
if (child.type !== "element") continue;
|
|
348
|
+
const name = require_xml_query.attrValue(child, "table:name");
|
|
349
|
+
if (name === void 0) continue;
|
|
350
|
+
const baseCellAddress = require_xml_query.attrValue(child, "table:base-cell-address");
|
|
351
|
+
if (child.tag === "table:named-range") {
|
|
352
|
+
const cellRangeAddress = require_xml_query.attrValue(child, "table:cell-range-address");
|
|
353
|
+
if (cellRangeAddress === void 0) continue;
|
|
354
|
+
const entry = {
|
|
355
|
+
kind: "namedRange",
|
|
356
|
+
name,
|
|
357
|
+
cellRangeAddress
|
|
358
|
+
};
|
|
359
|
+
if (baseCellAddress !== void 0) entry.baseCellAddress = baseCellAddress;
|
|
360
|
+
out[`named-range:${name}`] = entry;
|
|
361
|
+
} else if (child.tag === "table:named-expression") {
|
|
362
|
+
const expression = require_xml_query.attrValue(child, "table:expression");
|
|
363
|
+
if (expression === void 0) continue;
|
|
364
|
+
const entry = {
|
|
365
|
+
kind: "namedExpression",
|
|
366
|
+
name,
|
|
367
|
+
expression
|
|
368
|
+
};
|
|
369
|
+
if (baseCellAddress !== void 0) entry.baseCellAddress = baseCellAddress;
|
|
370
|
+
out[`named-expression:${name}`] = entry;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
exports.ODF_INDEX_WRAPPER_TAGS = ODF_INDEX_WRAPPER_TAGS;
|
|
376
|
+
exports.collectOdfDataStyleDefinitions = collectOdfDataStyleDefinitions;
|
|
377
|
+
exports.collectOdfFieldMasterDefinitions = collectOdfFieldMasterDefinitions;
|
|
378
|
+
exports.collectOdfFontFaceDefinitions = collectOdfFontFaceDefinitions;
|
|
379
|
+
exports.collectOdfNamedExpressions = collectOdfNamedExpressions;
|
|
380
|
+
exports.collectOdfProvenanceRegions = collectOdfProvenanceRegions;
|
|
381
|
+
exports.insertOdfConstructMarkers = insertOdfConstructMarkers;
|
|
382
|
+
exports.isOdfBlockScopedHalf = isOdfBlockScopedHalf;
|
|
383
|
+
exports.isOdfIndexWrapper = isOdfIndexWrapper;
|
|
384
|
+
exports.odfBookmarkAnchorDescriptor = odfBookmarkAnchorDescriptor;
|
|
385
|
+
exports.odfChangedRegionId = odfChangedRegionId;
|
|
386
|
+
exports.odfDivisionDescriptor = odfDivisionDescriptor;
|
|
387
|
+
exports.odfFieldDescriptor = odfFieldDescriptor;
|
|
388
|
+
exports.odfIndexControlDescriptor = odfIndexControlDescriptor;
|
|
389
|
+
exports.odfMarkerHalfEventIndex = odfMarkerHalfEventIndex;
|
|
390
|
+
exports.odfResidue = odfResidue;
|
|
391
|
+
exports.pairOdfMarkerHalves = pairOdfMarkerHalves;
|
|
392
|
+
exports.resolveOdfMarkerEvents = resolveOdfMarkerEvents;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as pairOdfMarkerHalves, S as odfResidue, _ as odfChangedRegionId, a as OdfMarkerHalf, b as odfIndexControlDescriptor, c as collectOdfDataStyleDefinitions, d as collectOdfNamedExpressions, f as collectOdfProvenanceRegions, g as odfBookmarkAnchorDescriptor, h as isOdfIndexWrapper, i as OdfMarkerEvent, l as collectOdfFieldMasterDefinitions, m as isOdfBlockScopedHalf, n as OdfConstructExtent, o as OdfMarkerKind, p as insertOdfConstructMarkers, r as OdfDefinitionsSink, s as OdfResidueFormat, t as ODF_INDEX_WRAPPER_TAGS, u as collectOdfFontFaceDefinitions, v as odfDivisionDescriptor, w as resolveOdfMarkerEvents, x as odfMarkerHalfEventIndex, y as odfFieldDescriptor } from "../../constructs-Dy_DMFs3.cjs";
|
|
2
|
+
export { ODF_INDEX_WRAPPER_TAGS, OdfConstructExtent, OdfDefinitionsSink, OdfMarkerEvent, OdfMarkerHalf, OdfMarkerKind, OdfResidueFormat, collectOdfDataStyleDefinitions, collectOdfFieldMasterDefinitions, collectOdfFontFaceDefinitions, collectOdfNamedExpressions, collectOdfProvenanceRegions, insertOdfConstructMarkers, isOdfBlockScopedHalf, isOdfIndexWrapper, odfBookmarkAnchorDescriptor, odfChangedRegionId, odfDivisionDescriptor, odfFieldDescriptor, odfIndexControlDescriptor, odfMarkerHalfEventIndex, odfResidue, pairOdfMarkerHalves, resolveOdfMarkerEvents };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as pairOdfMarkerHalves, S as odfResidue, _ as odfChangedRegionId, a as OdfMarkerHalf, b as odfIndexControlDescriptor, c as collectOdfDataStyleDefinitions, d as collectOdfNamedExpressions, f as collectOdfProvenanceRegions, g as odfBookmarkAnchorDescriptor, h as isOdfIndexWrapper, i as OdfMarkerEvent, l as collectOdfFieldMasterDefinitions, m as isOdfBlockScopedHalf, n as OdfConstructExtent, o as OdfMarkerKind, p as insertOdfConstructMarkers, r as OdfDefinitionsSink, s as OdfResidueFormat, t as ODF_INDEX_WRAPPER_TAGS, u as collectOdfFontFaceDefinitions, v as odfDivisionDescriptor, w as resolveOdfMarkerEvents, x as odfMarkerHalfEventIndex, y as odfFieldDescriptor } from "../../constructs-CJpDDQV0.js";
|
|
2
|
+
export { ODF_INDEX_WRAPPER_TAGS, OdfConstructExtent, OdfDefinitionsSink, OdfMarkerEvent, OdfMarkerHalf, OdfMarkerKind, OdfResidueFormat, collectOdfDataStyleDefinitions, collectOdfFieldMasterDefinitions, collectOdfFontFaceDefinitions, collectOdfNamedExpressions, collectOdfProvenanceRegions, insertOdfConstructMarkers, isOdfBlockScopedHalf, isOdfIndexWrapper, odfBookmarkAnchorDescriptor, odfChangedRegionId, odfDivisionDescriptor, odfFieldDescriptor, odfIndexControlDescriptor, odfMarkerHalfEventIndex, odfResidue, pairOdfMarkerHalves, resolveOdfMarkerEvents };
|