odf.js 5.0.9 → 5.1.1

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