odf.js 6.2.1 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +191 -17
  2. package/dist/{cascade-BDkyOmoo.d.cts → cascade-BpMwrjkB.d.cts} +1 -1
  3. package/dist/{cascade-CaVinmvp.d.ts → cascade-PDS3hgrP.d.ts} +1 -1
  4. package/dist/{codec-B72LApRl.d.cts → codec-CFdlbFLJ.d.cts} +21 -13
  5. package/dist/{codec-rbZGlr37.d.ts → codec-DTAgph2r.d.ts} +21 -13
  6. package/dist/codec.d.cts +1 -1
  7. package/dist/codec.d.ts +1 -1
  8. package/dist/{embedded-UQQNFd5U.js → embedded-BnavfkP-.js} +4 -5
  9. package/dist/{embedded-BsO-SvtW.cjs → embedded-Bxyss_ck.cjs} +15 -4
  10. package/dist/index.cjs +53 -1
  11. package/dist/index.d.cts +24 -16
  12. package/dist/index.d.ts +24 -16
  13. package/dist/index.js +19 -11
  14. package/dist/list-7FO0SDqZ.d.ts +32 -0
  15. package/dist/list-BorrTJBY.d.cts +32 -0
  16. package/dist/metadata-BUzwE_-u.d.ts +10 -0
  17. package/dist/metadata-CYXgXL_h.d.cts +10 -0
  18. package/dist/{ns-C14w-Zhf.d.cts → ns-DrleaIZQ.d.cts} +3 -1
  19. package/dist/{ns-CTyKJZeF.d.ts → ns-E0TfX9tZ.d.ts} +3 -1
  20. package/dist/ooo1/ns.cjs +9 -0
  21. package/dist/ooo1/ns.d.cts +2 -2
  22. package/dist/ooo1/ns.d.ts +2 -2
  23. package/dist/ooo1/ns.js +8 -1
  24. package/dist/ooo1/properties.cjs +30 -0
  25. package/dist/ooo1/properties.d.cts +6 -2
  26. package/dist/ooo1/properties.d.ts +6 -2
  27. package/dist/ooo1/properties.js +30 -1
  28. package/dist/ooo1/read.cjs +1 -1
  29. package/dist/ooo1/read.d.cts +1 -1
  30. package/dist/ooo1/read.d.ts +1 -1
  31. package/dist/ooo1/read.js +1 -1
  32. package/dist/ooo1/transform.cjs +290 -0
  33. package/dist/ooo1/transform.d.cts +2 -2
  34. package/dist/ooo1/transform.d.ts +2 -2
  35. package/dist/ooo1/transform.js +293 -4
  36. package/dist/ooo1/write.cjs +40 -0
  37. package/dist/ooo1/write.d.cts +2 -0
  38. package/dist/ooo1/write.d.ts +2 -0
  39. package/dist/ooo1/write.js +32 -0
  40. package/dist/package-io/scaffold.cjs +65 -0
  41. package/dist/package-io/scaffold.d.cts +2 -0
  42. package/dist/package-io/scaffold.d.ts +2 -0
  43. package/dist/package-io/scaffold.js +62 -0
  44. package/dist/paragraph-Bf6Iq5wC.d.cts +28 -0
  45. package/dist/paragraph-DtC86tft.d.ts +28 -0
  46. package/dist/{path-CK0dIPgx.d.cts → path-8HQS-J7y.d.cts} +3 -1
  47. package/dist/{path-CK0dIPgx.d.ts → path-8HQS-J7y.d.ts} +3 -1
  48. package/dist/{read-Bo1GBjSE.d.ts → read-A3CJkqVM.d.ts} +3 -1
  49. package/dist/{read-RFqq4ckj.d.cts → read-BgnLFuSi.d.cts} +1 -1
  50. package/dist/{read-3yy5EFV_.d.ts → read-CqaZ01kU.d.ts} +1 -1
  51. package/dist/{read-tpfiT_n4.d.cts → read-fphkvCpR.d.cts} +3 -1
  52. package/dist/{registry-Dajfxsbz.d.ts → registry-C_16-N6i.d.ts} +2 -0
  53. package/dist/{registry-B-ZkdQv1.d.cts → registry-PoQIRgbY.d.cts} +2 -0
  54. package/dist/scaffold-44EIMGll.d.cts +8 -0
  55. package/dist/scaffold-ehGsIpZ5.d.ts +8 -0
  56. package/dist/{shapes-QkOsc-WT.d.ts → shapes-B6Ms7ibr.d.ts} +1 -1
  57. package/dist/{shapes-BCjeY90t.d.cts → shapes-CbBc9t0y.d.cts} +1 -1
  58. package/dist/styles/properties.cjs +1 -1
  59. package/dist/styles/properties.js +2 -2
  60. package/dist/styles/registry.cjs +9 -6
  61. package/dist/styles/registry.d.cts +1 -1
  62. package/dist/styles/registry.d.ts +1 -1
  63. package/dist/styles/registry.js +9 -6
  64. package/dist/table-CECMtPxZ.d.cts +20 -0
  65. package/dist/table-XuniPr2I.d.ts +20 -0
  66. package/dist/text-B8350HA2.d.ts +17 -0
  67. package/dist/text-pmlTqzgi.d.cts +17 -0
  68. package/dist/{transform-SDysw9wx.d.cts → transform-DFCPKX7e.d.cts} +2 -1
  69. package/dist/{transform-DRr76JEu.d.ts → transform-DPliWQuD.d.ts} +2 -1
  70. package/dist/typed/draw/embedded.cjs +1 -1
  71. package/dist/typed/draw/embedded.js +1 -1
  72. package/dist/typed/draw/shapes.cjs +7 -2
  73. package/dist/typed/draw/shapes.d.cts +1 -1
  74. package/dist/typed/draw/shapes.d.ts +1 -1
  75. package/dist/typed/draw/shapes.js +7 -2
  76. package/dist/typed/draw/write-shapes.cjs +210 -0
  77. package/dist/typed/draw/write-shapes.d.cts +2 -0
  78. package/dist/typed/draw/write-shapes.d.ts +2 -0
  79. package/dist/typed/draw/write-shapes.js +203 -0
  80. package/dist/typed/draw/write-vectors.cjs +132 -0
  81. package/dist/typed/draw/write-vectors.d.cts +2 -0
  82. package/dist/typed/draw/write-vectors.d.ts +2 -0
  83. package/dist/typed/draw/write-vectors.js +129 -0
  84. package/dist/typed/odb/form.cjs +1 -1
  85. package/dist/typed/odb/form.js +1 -1
  86. package/dist/typed/odg/write.cjs +80 -0
  87. package/dist/typed/odg/write.d.cts +2 -0
  88. package/dist/typed/odg/write.d.ts +2 -0
  89. package/dist/typed/odg/write.js +77 -0
  90. package/dist/typed/odp/write.cjs +108 -0
  91. package/dist/typed/odp/write.d.cts +2 -0
  92. package/dist/typed/odp/write.d.ts +2 -0
  93. package/dist/typed/odp/write.js +105 -0
  94. package/dist/typed/ods/read.cjs +3 -1
  95. package/dist/typed/ods/read.d.cts +2 -2
  96. package/dist/typed/ods/read.d.ts +2 -2
  97. package/dist/typed/ods/read.js +2 -2
  98. package/dist/typed/ods/write.cjs +578 -0
  99. package/dist/typed/ods/write.d.cts +2 -0
  100. package/dist/typed/ods/write.d.ts +2 -0
  101. package/dist/typed/ods/write.js +575 -0
  102. package/dist/typed/odt/read.cjs +1 -1
  103. package/dist/typed/odt/read.js +1 -1
  104. package/dist/typed/odt/write.cjs +278 -0
  105. package/dist/typed/odt/write.d.cts +2 -0
  106. package/dist/typed/odt/write.d.ts +2 -0
  107. package/dist/typed/odt/write.js +275 -0
  108. package/dist/typed/shared/canonicalise.cjs +126 -0
  109. package/dist/typed/shared/canonicalise.d.cts +10 -0
  110. package/dist/typed/shared/canonicalise.d.ts +10 -0
  111. package/dist/typed/shared/canonicalise.js +120 -0
  112. package/dist/typed/shared/cascade.d.cts +1 -1
  113. package/dist/typed/shared/cascade.d.ts +1 -1
  114. package/dist/typed/shared/list.cjs +81 -0
  115. package/dist/typed/shared/list.d.cts +2 -2
  116. package/dist/typed/shared/list.d.ts +2 -2
  117. package/dist/typed/shared/list.js +75 -1
  118. package/dist/typed/shared/metadata.cjs +41 -0
  119. package/dist/typed/shared/metadata.d.cts +2 -2
  120. package/dist/typed/shared/metadata.d.ts +2 -2
  121. package/dist/typed/shared/metadata.js +41 -2
  122. package/dist/typed/shared/paragraph.cjs +118 -2
  123. package/dist/typed/shared/paragraph.d.cts +2 -2
  124. package/dist/typed/shared/paragraph.d.ts +2 -2
  125. package/dist/typed/shared/paragraph.js +117 -5
  126. package/dist/typed/shared/path.cjs +19 -0
  127. package/dist/typed/shared/path.d.cts +2 -2
  128. package/dist/typed/shared/path.d.ts +2 -2
  129. package/dist/typed/shared/path.js +18 -1
  130. package/dist/typed/shared/table.cjs +84 -0
  131. package/dist/typed/shared/table.d.cts +2 -2
  132. package/dist/typed/shared/table.d.ts +2 -2
  133. package/dist/typed/shared/table.js +84 -4
  134. package/dist/typed/shared/text.cjs +60 -0
  135. package/dist/typed/shared/text.d.cts +2 -2
  136. package/dist/typed/shared/text.d.ts +2 -2
  137. package/dist/typed/shared/text.js +60 -2
  138. package/dist/typed/shared/units.cjs +16 -1
  139. package/dist/typed/shared/units.d.cts +2 -2
  140. package/dist/typed/shared/units.d.ts +2 -2
  141. package/dist/typed/shared/units.js +16 -2
  142. package/dist/{units-BQSNkTQZ.d.cts → units-DdyaQolR.d.cts} +2 -1
  143. package/dist/{units-BQSNkTQZ.d.ts → units-DdyaQolR.d.ts} +2 -1
  144. package/dist/write-4kMi-asu.d.ts +14 -0
  145. package/dist/write-BZXpT8F6.d.cts +17 -0
  146. package/dist/write-BhG3t3fJ.d.cts +14 -0
  147. package/dist/write-BuLQmwLD.d.cts +14 -0
  148. package/dist/write-C2c4xBXs.d.cts +14 -0
  149. package/dist/write-CPATqG4v.d.cts +14 -0
  150. package/dist/write-CfTE2jY8.d.ts +14 -0
  151. package/dist/write-DttX1rTC.d.ts +14 -0
  152. package/dist/write-JERychL3.d.ts +14 -0
  153. package/dist/write-SKnCTU4C.d.ts +17 -0
  154. package/dist/write-shapes-Co7BrmMZ.d.ts +36 -0
  155. package/dist/write-shapes-D4piGKf4.d.cts +36 -0
  156. package/dist/write-vectors-B-RVHAKI.d.cts +11 -0
  157. package/dist/write-vectors-CYjZoVBW.d.ts +11 -0
  158. package/package.json +2 -2
  159. package/dist/list-DwTyo_B2.d.cts +0 -13
  160. package/dist/list-X_GJY7P3.d.ts +0 -13
  161. package/dist/metadata-01SgHkRR.d.cts +0 -7
  162. package/dist/metadata-D1SOBTh8.d.ts +0 -7
  163. package/dist/paragraph-ByTzS8Li.d.ts +0 -18
  164. package/dist/paragraph-CVULactG.d.cts +0 -18
  165. package/dist/table-CYvFMlP6.d.cts +0 -14
  166. package/dist/table-DclDgC5h.d.ts +0 -14
  167. package/dist/text-Bn3C7lnm.d.ts +0 -10
  168. package/dist/text-CDUCcwje.d.cts +0 -10
@@ -16,6 +16,7 @@ const PROPERTIES_ELEMENT_TAG = {
16
16
  "list-level": "style:list-level-properties",
17
17
  chart: "style:chart-properties"
18
18
  };
19
+ const ALL_PROPERTIES_ELEMENT_TAGS = new Set(Object.values(PROPERTIES_ELEMENT_TAG));
19
20
  const PROPERTY_TYPES_BY_FAMILY = /* @__PURE__ */ new Map([
20
21
  ["graphic", [
21
22
  "graphic",
@@ -400,6 +401,35 @@ function splitStyleProperties(properties, candidates) {
400
401
  }
401
402
  return out;
402
403
  }
404
+ function mergeStyleProperties(children) {
405
+ const attributes = [];
406
+ const propertyChildren = [];
407
+ const rest = [];
408
+ let found = false;
409
+ for (const child of children) {
410
+ if (child.type === "element" && ALL_PROPERTIES_ELEMENT_TAGS.has(child.tag)) {
411
+ found = true;
412
+ attributes.push(...child.attributes);
413
+ propertyChildren.push(...child.children);
414
+ continue;
415
+ }
416
+ rest.push(child);
417
+ }
418
+ if (!found) return {
419
+ merged: void 0,
420
+ rest: [...children]
421
+ };
422
+ return {
423
+ merged: {
424
+ type: "element",
425
+ tag: "style:properties",
426
+ attributes,
427
+ children: propertyChildren
428
+ },
429
+ rest
430
+ };
431
+ }
403
432
  //#endregion
433
+ exports.mergeStyleProperties = mergeStyleProperties;
404
434
  exports.propertyTypesForContainer = propertyTypesForContainer;
405
435
  exports.splitStyleProperties = splitStyleProperties;
@@ -1,7 +1,11 @@
1
- import { l as XmlElement } from "../node-B6JX5CRX.cjs";
1
+ import { d as XmlNode, l as XmlElement } from "../node-B6JX5CRX.cjs";
2
2
  //#region src/ooo1/properties.d.ts
3
3
  type Ooo1PropertyType = "graphic" | "drawing-page" | "page-layout" | "header-footer" | "text" | "paragraph" | "ruby" | "section" | "table" | "table-column" | "table-row" | "table-cell" | "list-level" | "chart";
4
4
  declare function propertyTypesForContainer(container: XmlElement): readonly Ooo1PropertyType[] | undefined;
5
5
  declare function splitStyleProperties(properties: XmlElement, candidates: readonly Ooo1PropertyType[]): XmlElement[];
6
+ declare function mergeStyleProperties(children: readonly XmlNode[]): {
7
+ readonly merged: XmlElement | undefined;
8
+ readonly rest: XmlNode[];
9
+ };
6
10
  //#endregion
7
- export { Ooo1PropertyType, propertyTypesForContainer, splitStyleProperties };
11
+ export { Ooo1PropertyType, mergeStyleProperties, propertyTypesForContainer, splitStyleProperties };
@@ -1,7 +1,11 @@
1
- import { l as XmlElement } from "../node-B6JX5CRX.js";
1
+ import { d as XmlNode, l as XmlElement } from "../node-B6JX5CRX.js";
2
2
  //#region src/ooo1/properties.d.ts
3
3
  type Ooo1PropertyType = "graphic" | "drawing-page" | "page-layout" | "header-footer" | "text" | "paragraph" | "ruby" | "section" | "table" | "table-column" | "table-row" | "table-cell" | "list-level" | "chart";
4
4
  declare function propertyTypesForContainer(container: XmlElement): readonly Ooo1PropertyType[] | undefined;
5
5
  declare function splitStyleProperties(properties: XmlElement, candidates: readonly Ooo1PropertyType[]): XmlElement[];
6
+ declare function mergeStyleProperties(children: readonly XmlNode[]): {
7
+ readonly merged: XmlElement | undefined;
8
+ readonly rest: XmlNode[];
9
+ };
6
10
  //#endregion
7
- export { Ooo1PropertyType, propertyTypesForContainer, splitStyleProperties };
11
+ export { Ooo1PropertyType, mergeStyleProperties, propertyTypesForContainer, splitStyleProperties };
@@ -15,6 +15,7 @@ const PROPERTIES_ELEMENT_TAG = {
15
15
  "list-level": "style:list-level-properties",
16
16
  chart: "style:chart-properties"
17
17
  };
18
+ const ALL_PROPERTIES_ELEMENT_TAGS = new Set(Object.values(PROPERTIES_ELEMENT_TAG));
18
19
  const PROPERTY_TYPES_BY_FAMILY = /* @__PURE__ */ new Map([
19
20
  ["graphic", [
20
21
  "graphic",
@@ -399,5 +400,33 @@ function splitStyleProperties(properties, candidates) {
399
400
  }
400
401
  return out;
401
402
  }
403
+ function mergeStyleProperties(children) {
404
+ const attributes = [];
405
+ const propertyChildren = [];
406
+ const rest = [];
407
+ let found = false;
408
+ for (const child of children) {
409
+ if (child.type === "element" && ALL_PROPERTIES_ELEMENT_TAGS.has(child.tag)) {
410
+ found = true;
411
+ attributes.push(...child.attributes);
412
+ propertyChildren.push(...child.children);
413
+ continue;
414
+ }
415
+ rest.push(child);
416
+ }
417
+ if (!found) return {
418
+ merged: void 0,
419
+ rest: [...children]
420
+ };
421
+ return {
422
+ merged: {
423
+ type: "element",
424
+ tag: "style:properties",
425
+ attributes,
426
+ children: propertyChildren
427
+ },
428
+ rest
429
+ };
430
+ }
402
431
  //#endregion
403
- export { propertyTypesForContainer, splitStyleProperties };
432
+ export { mergeStyleProperties, propertyTypesForContainer, splitStyleProperties };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_typed_odg_read = require("../typed/odg/read.cjs");
3
3
  const require_typed_odp_read = require("../typed/odp/read.cjs");
4
- const require_embedded = require("../embedded-BsO-SvtW.cjs");
4
+ const require_embedded = require("../embedded-Bxyss_ck.cjs");
5
5
  const require_ooo1_transform = require("./transform.cjs");
6
6
  //#region src/ooo1/read.ts
7
7
  function readSxwContent(pkg, options = {}) {
@@ -1,2 +1,2 @@
1
- import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "../read-RFqq4ckj.cjs";
1
+ import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "../read-BgnLFuSi.cjs";
2
2
  export { readSxc, readSxcContent, readSxd, readSxdContent, readSxi, readSxiContent, readSxw, readSxwContent };
@@ -1,2 +1,2 @@
1
- import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "../read-3yy5EFV_.js";
1
+ import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "../read-CqaZ01kU.js";
2
2
  export { readSxc, readSxcContent, readSxd, readSxdContent, readSxi, readSxiContent, readSxw, readSxwContent };
package/dist/ooo1/read.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { readOdg, readOdgContent } from "../typed/odg/read.js";
2
2
  import { readOdp, readOdpContent } from "../typed/odp/read.js";
3
- import { a as readOdtContent, i as readOdt, o as readOds, s as readOdsContent } from "../embedded-UQQNFd5U.js";
3
+ import { a as readOdtContent, c as readOds, i as readOdt, l as readOdsContent } from "../embedded-BnavfkP-.js";
4
4
  import { transformOoo1Package } from "./transform.js";
5
5
  //#region src/ooo1/read.ts
6
6
  function readSxwContent(pkg, options = {}) {
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_util_base64 = require("../util/base64.cjs");
3
3
  const require_ns = require("../ns.cjs");
4
+ const require_mimetype = require("../mimetype.cjs");
4
5
  const require_xml_query = require("../xml/query.cjs");
6
+ const require_typed_shared_list = require("../typed/shared/list.cjs");
5
7
  const require_ooo1_ns = require("./ns.cjs");
6
8
  const require_ooo1_properties = require("./properties.cjs");
7
9
  //#region src/ooo1/transform.ts
@@ -151,7 +153,10 @@ const INCH_TOKEN = /(^|\s)(-?(?:\d+(?:\.\d+)?|\.\d+))inch(?=\s|$)/g;
151
153
  function carriesNoLength(attributeName) {
152
154
  return attributeName.endsWith("name") || attributeName === "xlink:href";
153
155
  }
156
+ const OOO1_GRAPHIC_STYLE_FAMILY = "graphics";
157
+ const ODF_GRAPHIC_STYLE_FAMILY = "graphic";
154
158
  function normaliseAttributeValue(name, value) {
159
+ if (name === "style:family") return value === OOO1_GRAPHIC_STYLE_FAMILY ? ODF_GRAPHIC_STYLE_FAMILY : value;
155
160
  if (carriesNoLength(name)) return value;
156
161
  return value.replace(INCH_TOKEN, "$1$2in");
157
162
  }
@@ -398,5 +403,290 @@ function transformOoo1Package(pkg) {
398
403
  };
399
404
  return { parts };
400
405
  }
406
+ const CLASS_BY_GENRE_ELEMENT = /* @__PURE__ */ new Map([
407
+ ["office:text", "text"],
408
+ ["office:spreadsheet", "spreadsheet"],
409
+ ["office:presentation", "presentation"],
410
+ ["office:drawing", "drawing"],
411
+ ["office:chart", "chart"]
412
+ ]);
413
+ const REVERSE_RENAMED_ELEMENTS = /* @__PURE__ */ new Map([
414
+ ["office:font-face-decls", "office:font-decls"],
415
+ ["office:scripts", "office:script"],
416
+ ["office:script", "office:script-data"],
417
+ ["office:event-listeners", "office:events"],
418
+ ["style:page-layout", "style:page-master"],
419
+ ["text:tab", "text:tab-stop"],
420
+ ["text:database-row-select", "text:database-select"],
421
+ ["text:index-entry-chapter", "text:index-entry-chapter-number"],
422
+ ["table:dependencies", "table:dependences"],
423
+ ["table:dependency", "table:dependence"]
424
+ ]);
425
+ function reverseNoteTag(tag, noteClass) {
426
+ const isEndnote = noteClass === "endnote";
427
+ if (tag === "text:note") return isEndnote ? "text:endnote" : "text:footnote";
428
+ if (tag === "text:note-ref") return isEndnote ? "text:endnote-ref" : "text:footnote-ref";
429
+ if (tag === "text:notes-configuration") return isEndnote ? "text:endnotes-configuration" : "text:footnotes-configuration";
430
+ }
431
+ function reverseNoteBodyOrCitation(tag, noteClass) {
432
+ const isEndnote = noteClass === "endnote";
433
+ if (tag === "text:note-body") return isEndnote ? "text:endnote-body" : "text:footnote-body";
434
+ if (tag === "text:note-citation") return isEndnote ? "text:endnote-citation" : "text:footnote-citation";
435
+ }
436
+ const PT_IN_TOKEN = /(^|\s)(-?(?:\d+(?:\.\d+)?|\.\d+))in(?=\s|$)/g;
437
+ function reverseAttributeValue(name, value) {
438
+ if (name === "style:family") return value === ODF_GRAPHIC_STYLE_FAMILY ? OOO1_GRAPHIC_STYLE_FAMILY : value;
439
+ if (name === "fo:keep-with-next") {
440
+ if (value === "always") return "true";
441
+ if (value === "auto") return "false";
442
+ return value;
443
+ }
444
+ if (carriesNoLength(name)) return value;
445
+ return value.replace(PT_IN_TOKEN, "$1$2inch");
446
+ }
447
+ function reverseRewriteHref(tag, name, value) {
448
+ if (name === "xlink:href" && PACKAGE_HREF_ELEMENTS.has(tag) && !value.startsWith("#") && !value.includes("://")) return `#${value}`;
449
+ return value;
450
+ }
451
+ function reverseRenamedAttributeName(tag, name) {
452
+ switch (name) {
453
+ case "style:page-layout-name": return "style:page-master-name";
454
+ case "style:leader-text": return "style:leader-char";
455
+ case "text:count-in-text-boxes": return "text:count-in-floating-frames";
456
+ case "form:control-implementation": return "form:service-name";
457
+ case "form:text-style-name": return "form:column-style-name";
458
+ case "office:value-type": return tag === "form:property" ? "form:property-type" : void 0;
459
+ default: return;
460
+ }
461
+ }
462
+ function reverseAttributeNameFor(tag, name) {
463
+ if (tag === "text:h" && name === "text:outline-level") return "text:level";
464
+ if (CELL_ELEMENTS.has(tag)) {
465
+ if (name === "table:content-validation-name") return "table:validation-name";
466
+ for (const local of VALUE_ATTRIBUTE_LOCAL_NAMES) if (name === `office:${local}`) return `table:${local}`;
467
+ }
468
+ if (TEXT_VALUE_ELEMENTS.has(tag)) {
469
+ for (const local of VALUE_ATTRIBUTE_LOCAL_NAMES) if (name === `office:${local}`) return `text:${local}`;
470
+ }
471
+ if (tag === "style:column") {
472
+ if (name === "fo:start-indent") return "fo:margin-left";
473
+ if (name === "fo:end-indent") return "fo:margin-right";
474
+ }
475
+ return reverseRenamedAttributeName(tag, name) ?? name;
476
+ }
477
+ function transformNamespaceDeclarationToOoo1(attribute) {
478
+ const canonical = CANONICAL_PREFIX_BY_URI.get(attribute.value);
479
+ if (canonical === void 0 || !require_ooo1_ns.isOoo1NamespacePrefix(canonical)) return attribute;
480
+ return {
481
+ name: attribute.name === "xmlns" ? "xmlns" : `xmlns:${canonical}`,
482
+ value: require_ooo1_ns.OOO1_NAMESPACES[canonical]
483
+ };
484
+ }
485
+ function reverseTransformAttributes(element, tag, prefixes) {
486
+ const out = [];
487
+ for (const attribute of element.attributes) {
488
+ if (attribute.name === "xmlns" || attribute.name.startsWith("xmlns:")) {
489
+ out.push(transformNamespaceDeclarationToOoo1(attribute));
490
+ continue;
491
+ }
492
+ const name = renameQName(attribute.name, prefixes);
493
+ const value = reverseRewriteHref(tag, name, reverseAttributeValue(name, attribute.value));
494
+ out.push({
495
+ name: reverseAttributeNameFor(tag, name),
496
+ value
497
+ });
498
+ }
499
+ return out;
500
+ }
501
+ function unwrapFrame(frameAttributes, frameChildren) {
502
+ let shape;
503
+ const otherChildren = [];
504
+ for (const child of frameChildren) {
505
+ if (shape === void 0 && child.type === "element" && FRAME_SHAPES.has(child.tag)) {
506
+ shape = child;
507
+ continue;
508
+ }
509
+ otherChildren.push(child);
510
+ }
511
+ if (shape === void 0) return;
512
+ return element(shape.tag, [...shape.attributes, ...frameAttributes], [...shape.children, ...otherChildren]);
513
+ }
514
+ function elementRawText(el) {
515
+ let text = "";
516
+ for (const child of el.children) if (child.type === "text") text += child.value;
517
+ return text;
518
+ }
519
+ function reverseMovedChildren(tag, children) {
520
+ const moved = MOVED_TO_CHILD_ELEMENT.get(tag);
521
+ if (moved === void 0) return;
522
+ const childTagToAttribute = new Map([...moved.entries()].map(([attributeName, childTag]) => [childTag, attributeName]));
523
+ const attributes = [];
524
+ const rest = [];
525
+ for (const child of children) {
526
+ const attributeName = child.type === "element" ? childTagToAttribute.get(child.tag) : void 0;
527
+ if (attributeName !== void 0 && child.type === "element") {
528
+ attributes.push({
529
+ name: attributeName,
530
+ value: elementRawText(child)
531
+ });
532
+ continue;
533
+ }
534
+ rest.push(child);
535
+ }
536
+ return {
537
+ attributes,
538
+ rest
539
+ };
540
+ }
541
+ function wrapMetaKeywords(nodes) {
542
+ const keywords = nodes.filter((node) => node.type === "element" && node.tag === "meta:keyword");
543
+ if (keywords.length === 0) return [...nodes];
544
+ const out = [];
545
+ let inserted = false;
546
+ for (const node of nodes) {
547
+ if (node.type === "element" && node.tag === "meta:keyword") {
548
+ if (!inserted) {
549
+ out.push({
550
+ type: "element",
551
+ tag: "meta:keywords",
552
+ attributes: [],
553
+ children: keywords
554
+ });
555
+ inserted = true;
556
+ }
557
+ continue;
558
+ }
559
+ out.push(node);
560
+ }
561
+ return out;
562
+ }
563
+ function finaliseReversedChildren(nodes) {
564
+ const { merged, rest } = require_ooo1_properties.mergeStyleProperties(nodes);
565
+ return wrapMetaKeywords(merged === void 0 ? rest : [merged, ...rest]);
566
+ }
567
+ function reverseTransformNodes(nodes, context) {
568
+ const out = [];
569
+ for (const node of nodes) {
570
+ if (node.type !== "element") {
571
+ out.push(node);
572
+ continue;
573
+ }
574
+ out.push(...reverseTransformElement(node, context));
575
+ }
576
+ return out;
577
+ }
578
+ function reverseListKind(source, context) {
579
+ return require_typed_shared_list.resolveOdfListKind(context.pkg, require_xml_query.attrValue(source, "text:style-name")) ?? context.listKind;
580
+ }
581
+ function reverseTransformElement(source, context) {
582
+ const renamedTag = renameQName(source.tag, context.prefixes);
583
+ const attributes = reverseTransformAttributes(source, renamedTag, context.prefixes);
584
+ const genreChild = renamedTag === "office:body" ? source.children.find((child) => child.type === "element") : void 0;
585
+ const recurseInto = genreChild !== void 0 && CLASS_BY_GENRE_ELEMENT.has(genreChild.tag) ? genreChild.children : source.children;
586
+ let childContext = context;
587
+ if (renamedTag === "text:note") childContext = {
588
+ ...context,
589
+ noteClass: require_xml_query.attrValue(source, "text:note-class") === "endnote" ? "endnote" : "footnote"
590
+ };
591
+ else if (renamedTag === "text:list") childContext = {
592
+ ...context,
593
+ listKind: reverseListKind(source, context)
594
+ };
595
+ const children = finaliseReversedChildren(reverseTransformNodes(recurseInto, childContext));
596
+ if (renamedTag === "office:body") return [element("office:body", attributes, children)];
597
+ if (renamedTag === "draw:frame") return [unwrapFrame(attributes, children) ?? element(renamedTag, attributes, children)];
598
+ if (renamedTag === "text:note" || renamedTag === "text:note-ref" || renamedTag === "text:notes-configuration") {
599
+ const noteClassRaw = require_xml_query.attrValue(source, "text:note-class");
600
+ const withoutClass = attributes.filter((attribute) => attribute.name !== "text:note-class");
601
+ return [element(reverseNoteTag(renamedTag, noteClassRaw) ?? renamedTag, withoutClass, children)];
602
+ }
603
+ if (renamedTag === "text:note-body" || renamedTag === "text:note-citation") return [element(reverseNoteBodyOrCitation(renamedTag, context.noteClass) ?? renamedTag, attributes, children)];
604
+ if (renamedTag === "table:table" && require_xml_query.attrValue(source, "table:is-sub-table") === "true") return [element("table:sub-table", attributes.filter((attribute) => attribute.name !== "table:is-sub-table"), children)];
605
+ if (renamedTag === "style:font-face") return [element("style:font-decl", attributes.map((attribute) => {
606
+ if (attribute.name === "svg:font-family") return {
607
+ name: "fo:font-family",
608
+ value: attribute.value
609
+ };
610
+ if (attribute.name === "style:font-adornments") return {
611
+ name: "style:font-style-name",
612
+ value: attribute.value
613
+ };
614
+ return attribute;
615
+ }), children)];
616
+ const movedBack = reverseMovedChildren(renamedTag, children);
617
+ if (movedBack !== void 0) return [element(renamedTag, [...attributes, ...movedBack.attributes], movedBack.rest)];
618
+ if (renamedTag === "text:list") {
619
+ const kind = reverseListKind(source, context);
620
+ return [element(kind === "ordered" ? "text:ordered-list" : kind === "bullet" ? "text:unordered-list" : renamedTag, attributes, children)];
621
+ }
622
+ const tag = REVERSE_RENAMED_ELEMENTS.get(renamedTag) ?? renamedTag;
623
+ return [element(tag, DOCUMENT_ROOT_ELEMENTS.has(tag) && context.documentClass !== void 0 ? [...attributes, {
624
+ name: "office:class",
625
+ value: context.documentClass
626
+ }] : attributes, children)];
627
+ }
628
+ const CONTENT_XML_PATH = "content.xml";
629
+ function documentClassOf(pkg) {
630
+ const content = pkg.parts[CONTENT_XML_PATH];
631
+ if (content?.kind !== "xml") return;
632
+ const root = require_xml_query.rootElement(content.nodes);
633
+ const genre = (root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body"))?.children.find((child) => child.type === "element");
634
+ return genre === void 0 ? void 0 : CLASS_BY_GENRE_ELEMENT.get(genre.tag);
635
+ }
636
+ function reverseTransformXmlPart(nodes, context) {
637
+ const root = require_xml_query.rootElement(nodes);
638
+ if (root === void 0) return [...nodes];
639
+ return reverseTransformNodes(nodes, {
640
+ prefixes: prefixRenames(root),
641
+ ...context
642
+ });
643
+ }
644
+ function rewriteManifestToOoo1(nodes, ooo1MediaType) {
645
+ return nodes.map((node) => {
646
+ if (node.type !== "element") return node;
647
+ return {
648
+ ...node,
649
+ children: node.children.map((entry) => {
650
+ if (entry.type !== "element" || entry.tag !== "manifest:file-entry") return entry;
651
+ if (entry.attributes.find((attribute) => attribute.name === "manifest:full-path")?.value !== "/") return entry;
652
+ return {
653
+ ...entry,
654
+ attributes: entry.attributes.map((attribute) => attribute.name === "manifest:media-type" ? {
655
+ name: attribute.name,
656
+ value: ooo1MediaType
657
+ } : attribute)
658
+ };
659
+ })
660
+ };
661
+ });
662
+ }
663
+ function transformToOoo1Package(pkg) {
664
+ const odfMediaType = require_mimetype.readMimetype(pkg);
665
+ if (odfMediaType === void 0) return pkg;
666
+ const ooo1MediaType = require_ooo1_ns.ooo1MediaTypeForOdfMediaType(odfMediaType);
667
+ if (ooo1MediaType === void 0) return pkg;
668
+ const documentClass = documentClassOf(pkg);
669
+ const parts = {};
670
+ for (const [path, part] of Object.entries(pkg.parts)) {
671
+ if (path === MIMETYPE_PATH) continue;
672
+ if (part.kind !== "xml") {
673
+ parts[path] = part;
674
+ continue;
675
+ }
676
+ const nodes = reverseTransformXmlPart(part.nodes, {
677
+ pkg,
678
+ documentClass
679
+ });
680
+ parts[path] = path === MANIFEST_PATH ? {
681
+ kind: "xml",
682
+ nodes: rewriteManifestToOoo1(nodes, ooo1MediaType)
683
+ } : {
684
+ kind: "xml",
685
+ nodes
686
+ };
687
+ }
688
+ return { parts };
689
+ }
401
690
  //#endregion
402
691
  exports.transformOoo1Package = transformOoo1Package;
692
+ exports.transformToOoo1Package = transformToOoo1Package;
@@ -1,2 +1,2 @@
1
- import { t as transformOoo1Package } from "../transform-SDysw9wx.cjs";
2
- export { transformOoo1Package };
1
+ import { n as transformToOoo1Package, t as transformOoo1Package } from "../transform-DFCPKX7e.cjs";
2
+ export { transformOoo1Package, transformToOoo1Package };
@@ -1,2 +1,2 @@
1
- import { t as transformOoo1Package } from "../transform-DRr76JEu.js";
2
- export { transformOoo1Package };
1
+ import { n as transformToOoo1Package, t as transformOoo1Package } from "../transform-DPliWQuD.js";
2
+ export { transformOoo1Package, transformToOoo1Package };