documents.js 1.62.0 → 1.64.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 (196) hide show
  1. package/README.md +150 -24
  2. package/dist/convert/convert.cjs +72 -20
  3. package/dist/convert/convert.d.cts +6 -2
  4. package/dist/convert/convert.d.ts +6 -2
  5. package/dist/convert/convert.js +73 -21
  6. package/dist/convert/local.cjs +15 -2
  7. package/dist/convert/local.js +15 -2
  8. package/dist/convert/port.d.cts +8 -4
  9. package/dist/convert/port.d.ts +8 -4
  10. package/dist/edit/docx/content.d.cts +1 -1
  11. package/dist/edit/docx/content.d.ts +1 -1
  12. package/dist/edit/docx/paragraph.d.cts +3 -3
  13. package/dist/edit/docx/paragraph.d.ts +3 -3
  14. package/dist/edit/ods/address.cjs +42 -24
  15. package/dist/edit/ods/address.d.cts +12 -2
  16. package/dist/edit/ods/address.d.ts +12 -2
  17. package/dist/edit/ods/address.js +39 -25
  18. package/dist/edit/ods/column-row.cjs +68 -6
  19. package/dist/edit/ods/column-row.d.cts +5 -1
  20. package/dist/edit/ods/column-row.d.ts +5 -1
  21. package/dist/edit/ods/column-row.js +68 -10
  22. package/dist/edit/ods/content.cjs +10 -2
  23. package/dist/edit/ods/content.js +10 -2
  24. package/dist/edit/ods/floating.cjs +90 -0
  25. package/dist/edit/ods/floating.d.cts +7 -0
  26. package/dist/edit/ods/floating.d.ts +7 -0
  27. package/dist/edit/ods/floating.js +88 -0
  28. package/dist/edit/ods/print-settings.cjs +158 -2
  29. package/dist/edit/ods/print-settings.js +159 -3
  30. package/dist/edit/ods/sheet.cjs +13 -0
  31. package/dist/edit/ods/sheet.d.cts +5 -1
  32. package/dist/edit/ods/sheet.d.ts +5 -1
  33. package/dist/edit/ods/sheet.js +14 -1
  34. package/dist/edit/odt/content.cjs +8 -4
  35. package/dist/edit/odt/content.js +8 -4
  36. package/dist/edit/odt/editor.cjs +7 -0
  37. package/dist/edit/odt/editor.d.cts +3 -0
  38. package/dist/edit/odt/editor.d.ts +3 -0
  39. package/dist/edit/odt/editor.js +7 -0
  40. package/dist/edit/odt/formula.cjs +19 -0
  41. package/dist/edit/odt/formula.d.cts +8 -0
  42. package/dist/edit/odt/formula.d.ts +8 -0
  43. package/dist/edit/odt/formula.js +17 -0
  44. package/dist/evaluate-BU5N1Jk1.d.ts +11 -0
  45. package/dist/evaluate-BhMXY6DM.d.cts +11 -0
  46. package/dist/firebird/backup.d.cts +1 -1
  47. package/dist/firebird/backup.d.ts +1 -1
  48. package/dist/firebird/data.cjs +30 -16
  49. package/dist/firebird/data.d.cts +3 -2
  50. package/dist/firebird/data.d.ts +3 -2
  51. package/dist/firebird/data.js +30 -17
  52. package/dist/fonts/obfuscation.cjs +50 -0
  53. package/dist/fonts/obfuscation.d.cts +9 -0
  54. package/dist/fonts/obfuscation.d.ts +9 -0
  55. package/dist/fonts/obfuscation.js +46 -0
  56. package/dist/fonts/odf.cjs +86 -0
  57. package/dist/fonts/odf.d.cts +9 -0
  58. package/dist/fonts/odf.d.ts +9 -0
  59. package/dist/fonts/odf.js +84 -0
  60. package/dist/fonts/ooxml.cjs +129 -0
  61. package/dist/fonts/ooxml.d.cts +9 -0
  62. package/dist/fonts/ooxml.d.ts +9 -0
  63. package/dist/fonts/ooxml.js +127 -0
  64. package/dist/fonts/registry.cjs +18 -0
  65. package/dist/fonts/registry.d.cts +2 -0
  66. package/dist/fonts/registry.d.ts +2 -0
  67. package/dist/fonts/registry.js +16 -0
  68. package/dist/formula-CgydMiTt.d.ts +10 -0
  69. package/dist/formula-CiwPw8nY.d.cts +10 -0
  70. package/dist/hsqldb/binary-script.d.cts +1 -1
  71. package/dist/hsqldb/binary-script.d.ts +1 -1
  72. package/dist/hsqldb/cache.d.cts +1 -1
  73. package/dist/hsqldb/cache.d.ts +1 -1
  74. package/dist/hsqldb/rowformat.cjs +22 -13
  75. package/dist/hsqldb/rowformat.js +22 -13
  76. package/dist/hsqldb/script.d.cts +1 -18
  77. package/dist/hsqldb/script.d.ts +1 -18
  78. package/dist/index.cjs +88 -0
  79. package/dist/index.d.cts +27 -9
  80. package/dist/index.d.ts +27 -9
  81. package/dist/index.js +20 -3
  82. package/dist/layout/sheets.cjs +30 -24
  83. package/dist/layout/sheets.js +31 -25
  84. package/dist/layout/slides.cjs +6 -4
  85. package/dist/layout/slides.js +7 -5
  86. package/dist/lexer-DGPWx_f2.d.cts +42 -0
  87. package/dist/lexer-DGPWx_f2.d.ts +42 -0
  88. package/dist/mathml/layout.d.cts +1 -1
  89. package/dist/mathml/layout.d.ts +1 -1
  90. package/dist/mathml/variant.d.cts +1 -6
  91. package/dist/mathml/variant.d.ts +1 -6
  92. package/dist/odb/csv.d.cts +1 -1
  93. package/dist/odb/csv.d.ts +1 -1
  94. package/dist/odb/formula/definition.cjs +49 -0
  95. package/dist/odb/formula/definition.d.cts +8 -0
  96. package/dist/odb/formula/definition.d.ts +8 -0
  97. package/dist/odb/formula/definition.js +46 -0
  98. package/dist/odb/formula/errors.cjs +47 -0
  99. package/dist/odb/formula/errors.d.cts +21 -0
  100. package/dist/odb/formula/errors.d.ts +21 -0
  101. package/dist/odb/formula/errors.js +43 -0
  102. package/dist/odb/formula/evaluate.cjs +283 -0
  103. package/dist/odb/formula/evaluate.d.cts +43 -0
  104. package/dist/odb/formula/evaluate.d.ts +43 -0
  105. package/dist/odb/formula/evaluate.js +281 -0
  106. package/dist/odb/formula/parser.cjs +198 -0
  107. package/dist/odb/formula/parser.d.cts +29 -0
  108. package/dist/odb/formula/parser.d.ts +29 -0
  109. package/dist/odb/formula/parser.js +197 -0
  110. package/dist/odb/read.d.cts +1 -1
  111. package/dist/odb/read.d.ts +1 -1
  112. package/dist/odb/report/content.cjs +27 -0
  113. package/dist/odb/report/content.d.cts +14 -0
  114. package/dist/odb/report/content.d.ts +14 -0
  115. package/dist/odb/report/content.js +25 -0
  116. package/dist/odb/report/render.cjs +106 -0
  117. package/dist/odb/report/render.d.cts +7 -0
  118. package/dist/odb/report/render.d.ts +7 -0
  119. package/dist/odb/report/render.js +106 -0
  120. package/dist/odb/report/source.cjs +45 -0
  121. package/dist/odb/report/source.d.cts +14 -0
  122. package/dist/odb/report/source.d.ts +14 -0
  123. package/dist/odb/report/source.js +42 -0
  124. package/dist/odb/spreadsheet.d.cts +1 -1
  125. package/dist/odb/spreadsheet.d.ts +1 -1
  126. package/dist/odb/sql/errors.cjs +38 -0
  127. package/dist/odb/sql/errors.d.cts +17 -0
  128. package/dist/odb/sql/errors.d.ts +17 -0
  129. package/dist/odb/sql/errors.js +35 -0
  130. package/dist/odb/sql/evaluate.cjs +312 -0
  131. package/dist/odb/sql/evaluate.d.cts +2 -0
  132. package/dist/odb/sql/evaluate.d.ts +2 -0
  133. package/dist/odb/sql/evaluate.js +311 -0
  134. package/dist/odb/sql/lexer.cjs +282 -0
  135. package/dist/odb/sql/lexer.d.cts +2 -0
  136. package/dist/odb/sql/lexer.d.ts +2 -0
  137. package/dist/odb/sql/lexer.js +281 -0
  138. package/dist/odb/sql/parser.cjs +479 -0
  139. package/dist/odb/sql/parser.d.cts +2 -0
  140. package/dist/odb/sql/parser.d.ts +2 -0
  141. package/dist/odb/sql/parser.js +478 -0
  142. package/dist/odb/values.cjs +75 -0
  143. package/dist/odb/values.d.cts +2 -0
  144. package/dist/odb/values.d.ts +2 -0
  145. package/dist/odb/values.js +69 -0
  146. package/dist/odf/odt/read.cjs +43 -21
  147. package/dist/odf/odt/read.js +43 -21
  148. package/dist/odf-package/formula.cjs +59 -0
  149. package/dist/odf-package/formula.d.cts +11 -0
  150. package/dist/odf-package/formula.d.ts +11 -0
  151. package/dist/odf-package/formula.js +58 -0
  152. package/dist/odf-package/manifest.cjs +29 -0
  153. package/dist/odf-package/manifest.d.cts +5 -2
  154. package/dist/odf-package/manifest.d.ts +5 -2
  155. package/dist/odf-package/manifest.js +30 -2
  156. package/dist/odf-package/media.cjs +2 -1
  157. package/dist/odf-package/media.js +2 -2
  158. package/dist/omml/read.cjs +265 -0
  159. package/dist/omml/read.d.cts +12 -0
  160. package/dist/omml/read.d.ts +12 -0
  161. package/dist/omml/read.js +263 -0
  162. package/dist/omml/shared.cjs +67 -0
  163. package/dist/omml/shared.d.cts +2 -0
  164. package/dist/omml/shared.d.ts +2 -0
  165. package/dist/omml/shared.js +64 -0
  166. package/dist/omml/write.cjs +3 -51
  167. package/dist/omml/write.d.cts +2 -2
  168. package/dist/omml/write.d.ts +2 -2
  169. package/dist/omml/write.js +1 -49
  170. package/dist/ooxml/docx/extras.cjs +15 -0
  171. package/dist/ooxml/docx/extras.d.cts +12 -0
  172. package/dist/ooxml/docx/extras.d.ts +12 -0
  173. package/dist/ooxml/docx/extras.js +14 -0
  174. package/dist/ooxml/docx/formula.cjs +109 -0
  175. package/dist/ooxml/docx/formula.d.cts +2 -0
  176. package/dist/ooxml/docx/formula.d.ts +2 -0
  177. package/dist/ooxml/docx/formula.js +108 -0
  178. package/dist/ooxml/docx/read.cjs +10 -2
  179. package/dist/ooxml/docx/read.d.cts +6 -2
  180. package/dist/ooxml/docx/read.d.ts +6 -2
  181. package/dist/ooxml/docx/read.js +11 -3
  182. package/dist/parser-B9vC1T6T.d.cts +101 -0
  183. package/dist/parser-DQSgYJzQ.d.ts +101 -0
  184. package/dist/registry-CrSqLIcn.d.ts +19 -0
  185. package/dist/registry-lqJej0Jr.d.cts +19 -0
  186. package/dist/script-DsGGIzGU.d.cts +19 -0
  187. package/dist/script-DsGGIzGU.d.ts +19 -0
  188. package/dist/shared-DLZ3IQUl.d.cts +15 -0
  189. package/dist/shared-DUOzjwcL.d.ts +15 -0
  190. package/dist/values-BetetbaH.d.cts +23 -0
  191. package/dist/values-BetetbaH.d.ts +23 -0
  192. package/dist/variant-BMrebjMw.d.cts +7 -0
  193. package/dist/variant-BMrebjMw.d.ts +7 -0
  194. package/dist/{write-DuyfnbL_.d.cts → write-BQ6SK8r8.d.cts} +2 -6
  195. package/dist/{write-Zqwx6pka.d.ts → write-THs7ipBq.d.ts} +2 -6
  196. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_fragment = require("../../xml/fragment.cjs");
3
+ const require_xml_edit = require("../../xml/edit.cjs");
4
+ const require_odf_package_formula = require("../../odf-package/formula.cjs");
5
+ const require_odf_package_media = require("../../odf-package/media.cjs");
6
+ const require_edit_ods_address = require("./address.cjs");
7
+ let ooxml_js = require("ooxml.js");
8
+ let odf_js = require("odf.js");
9
+ //#region src/edit/ods/floating.ts
10
+ const SHAPES_TAG = "table:shapes";
11
+ const DEFAULT_COLUMN_WIDTH_PT = 64;
12
+ const DEFAULT_ROW_HEIGHT_PT = 15;
13
+ function ensureTableShapes(tableElement) {
14
+ const existing = tableElement.children.find((child) => child.type === "element" && child.tag === SHAPES_TAG);
15
+ if (existing !== void 0) return existing;
16
+ const shapes = require_xml_fragment.el(SHAPES_TAG);
17
+ tableElement.children.unshift(shapes);
18
+ return shapes;
19
+ }
20
+ function isHiddenElement(node) {
21
+ return (0, ooxml_js.attr)(node, "table:visibility") === "collapse";
22
+ }
23
+ function resolvedColumnWidthPt(pkg, columnElement) {
24
+ if (isHiddenElement(columnElement)) return 0;
25
+ const styleName = (0, ooxml_js.attr)(columnElement, "table:style-name");
26
+ const styleElement = styleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(styleName, "table-column", pkg);
27
+ const properties = styleElement === void 0 ? void 0 : require_xml_edit.directChildElement(styleElement, "style:table-column-properties");
28
+ const widthValue = properties === void 0 ? void 0 : (0, ooxml_js.attr)(properties, "style:column-width");
29
+ return widthValue === void 0 ? 0 : (0, odf_js.parseOdfLength)(widthValue) ?? 0;
30
+ }
31
+ function resolvedRowHeightPt(pkg, rowElement) {
32
+ if (isHiddenElement(rowElement)) return 0;
33
+ const styleName = (0, ooxml_js.attr)(rowElement, "table:style-name");
34
+ const styleElement = styleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(styleName, "table-row", pkg);
35
+ const properties = styleElement === void 0 ? void 0 : require_xml_edit.directChildElement(styleElement, "style:table-row-properties");
36
+ const heightValue = properties === void 0 ? void 0 : (0, ooxml_js.attr)(properties, "style:row-height");
37
+ return heightValue === void 0 ? 0 : (0, odf_js.parseOdfLength)(heightValue) ?? 0;
38
+ }
39
+ function cumulativeColumnOffsetPt(pkg, tableElement, anchorColumn) {
40
+ let cursor = 0;
41
+ let offsetPt = 0;
42
+ for (const member of require_edit_ods_address.collectRunMembers(tableElement.children, require_edit_ods_address.isElementWithTag(require_edit_ods_address.COLUMN_TAG), require_edit_ods_address.HEADER_COLUMNS_TAG)) {
43
+ if (cursor >= anchorColumn) break;
44
+ const count = require_edit_ods_address.readRunRepeatCount(member.node, require_edit_ods_address.COLUMN_REPEAT_ATTR);
45
+ const overlap = Math.min(count, anchorColumn - cursor);
46
+ offsetPt += overlap * resolvedColumnWidthPt(pkg, member.node);
47
+ cursor += count;
48
+ }
49
+ if (cursor < anchorColumn) offsetPt += (anchorColumn - cursor) * DEFAULT_COLUMN_WIDTH_PT;
50
+ return offsetPt;
51
+ }
52
+ function cumulativeRowOffsetPt(pkg, tableElement, anchorRow) {
53
+ let cursor = 0;
54
+ let offsetPt = 0;
55
+ for (const member of require_edit_ods_address.collectRunMembers(tableElement.children, require_edit_ods_address.isElementWithTag(require_edit_ods_address.ROW_TAG), require_edit_ods_address.HEADER_ROWS_TAG)) {
56
+ if (cursor >= anchorRow) break;
57
+ const count = require_edit_ods_address.readRunRepeatCount(member.node, require_edit_ods_address.ROW_REPEAT_ATTR);
58
+ const overlap = Math.min(count, anchorRow - cursor);
59
+ offsetPt += overlap * resolvedRowHeightPt(pkg, member.node);
60
+ cursor += count;
61
+ }
62
+ if (cursor < anchorRow) offsetPt += (anchorRow - cursor) * DEFAULT_ROW_HEIGHT_PT;
63
+ return offsetPt;
64
+ }
65
+ function buildAbsoluteFrame(xPt, yPt, widthPt, heightPt, content) {
66
+ return require_xml_fragment.el("draw:frame", {
67
+ "svg:x": (0, odf_js.formatOdfLength)(xPt),
68
+ "svg:y": (0, odf_js.formatOdfLength)(yPt),
69
+ "svg:width": (0, odf_js.formatOdfLength)(widthPt),
70
+ "svg:height": (0, odf_js.formatOdfLength)(heightPt)
71
+ }, [content]);
72
+ }
73
+ function insertSheetImage(pkg, tableElement, image) {
74
+ const { partPath } = require_odf_package_media.addImageMedia(pkg, (0, odf_js.base64ToBytes)(image.base64), image.format);
75
+ const xPt = cumulativeColumnOffsetPt(pkg, tableElement, image.anchorColumn) + image.offsetXPt;
76
+ const yPt = cumulativeRowOffsetPt(pkg, tableElement, image.anchorRow) + image.offsetYPt;
77
+ const imageElement = require_xml_fragment.el("draw:image", { "xlink:href": partPath });
78
+ const frame = buildAbsoluteFrame(xPt, yPt, image.widthPt, image.heightPt, imageElement);
79
+ ensureTableShapes(tableElement).children.push(frame);
80
+ }
81
+ function insertSheetEmbeddedObject(pkg, tableElement, object) {
82
+ if (object.document.kind !== "formula") return;
83
+ const { href } = require_odf_package_formula.addFormulaObject(pkg, object.document.formula);
84
+ const objectElement = require_xml_fragment.el("draw:object", { "xlink:href": href });
85
+ const frame = buildAbsoluteFrame(object.frame.xPt, object.frame.yPt, object.frame.widthPt, object.frame.heightPt, objectElement);
86
+ ensureTableShapes(tableElement).children.push(frame);
87
+ }
88
+ //#endregion
89
+ exports.insertSheetEmbeddedObject = insertSheetEmbeddedObject;
90
+ exports.insertSheetImage = insertSheetImage;
@@ -0,0 +1,7 @@
1
+ import { ContentEmbeddedObject, ContentSheetImage } from "document-schema.js";
2
+ import { Package, XmlElement } from "odf.js";
3
+ //#region src/edit/ods/floating.d.ts
4
+ declare function insertSheetImage(pkg: Package, tableElement: XmlElement, image: ContentSheetImage): void;
5
+ declare function insertSheetEmbeddedObject(pkg: Package, tableElement: XmlElement, object: ContentEmbeddedObject): void;
6
+ //#endregion
7
+ export { insertSheetEmbeddedObject, insertSheetImage };
@@ -0,0 +1,7 @@
1
+ import { ContentEmbeddedObject, ContentSheetImage } from "document-schema.js";
2
+ import { Package, XmlElement } from "odf.js";
3
+ //#region src/edit/ods/floating.d.ts
4
+ declare function insertSheetImage(pkg: Package, tableElement: XmlElement, image: ContentSheetImage): void;
5
+ declare function insertSheetEmbeddedObject(pkg: Package, tableElement: XmlElement, object: ContentEmbeddedObject): void;
6
+ //#endregion
7
+ export { insertSheetEmbeddedObject, insertSheetImage };
@@ -0,0 +1,88 @@
1
+ import { el } from "../../xml/fragment.js";
2
+ import { directChildElement } from "../../xml/edit.js";
3
+ import { addFormulaObject } from "../../odf-package/formula.js";
4
+ import { addImageMedia } from "../../odf-package/media.js";
5
+ import { COLUMN_REPEAT_ATTR, COLUMN_TAG, HEADER_COLUMNS_TAG, HEADER_ROWS_TAG, ROW_REPEAT_ATTR, ROW_TAG, collectRunMembers, isElementWithTag, readRunRepeatCount } from "./address.js";
6
+ import { attr } from "ooxml.js";
7
+ import { base64ToBytes as base64ToBytes$1, findStyleElement, formatOdfLength, parseOdfLength } from "odf.js";
8
+ //#region src/edit/ods/floating.ts
9
+ const SHAPES_TAG = "table:shapes";
10
+ const DEFAULT_COLUMN_WIDTH_PT = 64;
11
+ const DEFAULT_ROW_HEIGHT_PT = 15;
12
+ function ensureTableShapes(tableElement) {
13
+ const existing = tableElement.children.find((child) => child.type === "element" && child.tag === SHAPES_TAG);
14
+ if (existing !== void 0) return existing;
15
+ const shapes = el(SHAPES_TAG);
16
+ tableElement.children.unshift(shapes);
17
+ return shapes;
18
+ }
19
+ function isHiddenElement(node) {
20
+ return attr(node, "table:visibility") === "collapse";
21
+ }
22
+ function resolvedColumnWidthPt(pkg, columnElement) {
23
+ if (isHiddenElement(columnElement)) return 0;
24
+ const styleName = attr(columnElement, "table:style-name");
25
+ const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, "table-column", pkg);
26
+ const properties = styleElement === void 0 ? void 0 : directChildElement(styleElement, "style:table-column-properties");
27
+ const widthValue = properties === void 0 ? void 0 : attr(properties, "style:column-width");
28
+ return widthValue === void 0 ? 0 : parseOdfLength(widthValue) ?? 0;
29
+ }
30
+ function resolvedRowHeightPt(pkg, rowElement) {
31
+ if (isHiddenElement(rowElement)) return 0;
32
+ const styleName = attr(rowElement, "table:style-name");
33
+ const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, "table-row", pkg);
34
+ const properties = styleElement === void 0 ? void 0 : directChildElement(styleElement, "style:table-row-properties");
35
+ const heightValue = properties === void 0 ? void 0 : attr(properties, "style:row-height");
36
+ return heightValue === void 0 ? 0 : parseOdfLength(heightValue) ?? 0;
37
+ }
38
+ function cumulativeColumnOffsetPt(pkg, tableElement, anchorColumn) {
39
+ let cursor = 0;
40
+ let offsetPt = 0;
41
+ for (const member of collectRunMembers(tableElement.children, isElementWithTag(COLUMN_TAG), HEADER_COLUMNS_TAG)) {
42
+ if (cursor >= anchorColumn) break;
43
+ const count = readRunRepeatCount(member.node, COLUMN_REPEAT_ATTR);
44
+ const overlap = Math.min(count, anchorColumn - cursor);
45
+ offsetPt += overlap * resolvedColumnWidthPt(pkg, member.node);
46
+ cursor += count;
47
+ }
48
+ if (cursor < anchorColumn) offsetPt += (anchorColumn - cursor) * DEFAULT_COLUMN_WIDTH_PT;
49
+ return offsetPt;
50
+ }
51
+ function cumulativeRowOffsetPt(pkg, tableElement, anchorRow) {
52
+ let cursor = 0;
53
+ let offsetPt = 0;
54
+ for (const member of collectRunMembers(tableElement.children, isElementWithTag(ROW_TAG), HEADER_ROWS_TAG)) {
55
+ if (cursor >= anchorRow) break;
56
+ const count = readRunRepeatCount(member.node, ROW_REPEAT_ATTR);
57
+ const overlap = Math.min(count, anchorRow - cursor);
58
+ offsetPt += overlap * resolvedRowHeightPt(pkg, member.node);
59
+ cursor += count;
60
+ }
61
+ if (cursor < anchorRow) offsetPt += (anchorRow - cursor) * DEFAULT_ROW_HEIGHT_PT;
62
+ return offsetPt;
63
+ }
64
+ function buildAbsoluteFrame(xPt, yPt, widthPt, heightPt, content) {
65
+ return el("draw:frame", {
66
+ "svg:x": formatOdfLength(xPt),
67
+ "svg:y": formatOdfLength(yPt),
68
+ "svg:width": formatOdfLength(widthPt),
69
+ "svg:height": formatOdfLength(heightPt)
70
+ }, [content]);
71
+ }
72
+ function insertSheetImage(pkg, tableElement, image) {
73
+ const { partPath } = addImageMedia(pkg, base64ToBytes$1(image.base64), image.format);
74
+ const xPt = cumulativeColumnOffsetPt(pkg, tableElement, image.anchorColumn) + image.offsetXPt;
75
+ const yPt = cumulativeRowOffsetPt(pkg, tableElement, image.anchorRow) + image.offsetYPt;
76
+ const imageElement = el("draw:image", { "xlink:href": partPath });
77
+ const frame = buildAbsoluteFrame(xPt, yPt, image.widthPt, image.heightPt, imageElement);
78
+ ensureTableShapes(tableElement).children.push(frame);
79
+ }
80
+ function insertSheetEmbeddedObject(pkg, tableElement, object) {
81
+ if (object.document.kind !== "formula") return;
82
+ const { href } = addFormulaObject(pkg, object.document.formula);
83
+ const objectElement = el("draw:object", { "xlink:href": href });
84
+ const frame = buildAbsoluteFrame(object.frame.xPt, object.frame.yPt, object.frame.widthPt, object.frame.heightPt, objectElement);
85
+ ensureTableShapes(tableElement).children.push(frame);
86
+ }
87
+ //#endregion
88
+ export { insertSheetEmbeddedObject, insertSheetImage };
@@ -2,6 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xml_fragment = require("../../xml/fragment.cjs");
3
3
  const require_xml_edit = require("../../xml/edit.cjs");
4
4
  const require_edit_odt_automatic_styles = require("../odt/automatic-styles.cjs");
5
+ const require_edit_ods_address = require("./address.cjs");
6
+ const require_edit_ods_column_row = require("./column-row.cjs");
5
7
  let ooxml_js = require("ooxml.js");
6
8
  let odf_js = require("odf.js");
7
9
  let document_schema_js = require("document-schema.js");
@@ -39,6 +41,89 @@ const DEFAULT_MARGINS = {
39
41
  bottomPt: DEFAULT_MARGIN_PT,
40
42
  leftPt: DEFAULT_MARGIN_PT
41
43
  };
44
+ function hasManualBreak(pkg, element, family, propertiesTag) {
45
+ const styleName = (0, ooxml_js.attr)(element, "table:style-name");
46
+ const styleElement = styleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(styleName, family, pkg);
47
+ const properties = styleElement === void 0 ? void 0 : directChild(styleElement, propertiesTag);
48
+ return properties !== void 0 && (0, ooxml_js.attr)(properties, "fo:break-before") === "page";
49
+ }
50
+ function scanTableStructure(pkg, tableElement) {
51
+ let columnCursor = 0;
52
+ let rowCursor = 0;
53
+ let repeatColumns;
54
+ let repeatRows;
55
+ const manualBreakColumns = [];
56
+ const manualBreakRows = [];
57
+ function processColumn(columnElement) {
58
+ if (hasManualBreak(pkg, columnElement, "table-column", "style:table-column-properties")) manualBreakColumns.push(columnCursor);
59
+ columnCursor += require_edit_ods_address.readRunRepeatCount(columnElement, require_edit_ods_address.COLUMN_REPEAT_ATTR);
60
+ }
61
+ function processRow(rowElement) {
62
+ const startIndex = rowCursor;
63
+ if (hasManualBreak(pkg, rowElement, "table-row", "style:table-row-properties")) manualBreakRows.push(startIndex);
64
+ rowCursor += require_edit_ods_address.readRunRepeatCount(rowElement, require_edit_ods_address.ROW_REPEAT_ATTR);
65
+ }
66
+ for (const child of tableElement.children) {
67
+ if (child.type !== "element") continue;
68
+ if (child.tag === "table:table-column") processColumn(child);
69
+ else if (child.tag === "table:table-header-columns") {
70
+ const startIndex = columnCursor;
71
+ for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
72
+ if (columnCursor > startIndex) repeatColumns = {
73
+ start: startIndex,
74
+ end: columnCursor - 1
75
+ };
76
+ } else if (child.tag === "table:table-row") processRow(child);
77
+ else if (child.tag === "table:table-header-rows") {
78
+ const startIndex = rowCursor;
79
+ for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-row") processRow(headerChild);
80
+ if (rowCursor > startIndex) repeatRows = {
81
+ start: startIndex,
82
+ end: rowCursor - 1
83
+ };
84
+ }
85
+ }
86
+ return {
87
+ repeatColumns,
88
+ repeatRows,
89
+ manualBreakColumns,
90
+ manualBreakRows
91
+ };
92
+ }
93
+ function parseA1WithOptionalSheetPrefix(cellPart) {
94
+ const dotIndex = cellPart.lastIndexOf(".");
95
+ const bareReference = dotIndex === -1 ? cellPart : cellPart.slice(dotIndex + 1);
96
+ return (0, odf_js.parseCellReference)(bareReference);
97
+ }
98
+ function parsePrintRanges(value) {
99
+ const first = value.split(" ").find((part) => part.length > 0);
100
+ if (first === void 0) return;
101
+ const separatorIndex = first.indexOf(":");
102
+ if (separatorIndex === -1) return;
103
+ const start = parseA1WithOptionalSheetPrefix(first.slice(0, separatorIndex));
104
+ const end = parseA1WithOptionalSheetPrefix(first.slice(separatorIndex + 1));
105
+ if (start === void 0 || end === void 0) return;
106
+ return {
107
+ startRow: start.row,
108
+ startColumn: start.column,
109
+ endRow: end.row,
110
+ endColumn: end.column
111
+ };
112
+ }
113
+ function formatPrintRange(sheetName, range) {
114
+ return `${`${sheetName}.${(0, odf_js.cellReference)(range.startColumn, range.startRow)}`}:${`${sheetName}.${(0, odf_js.cellReference)(range.endColumn, range.endRow)}`}`;
115
+ }
116
+ function parseScalePercentage(value) {
117
+ const match = /^(\d+(?:\.\d+)?)%$/.exec(value);
118
+ if (match === null) return;
119
+ const numeric = match[1];
120
+ return numeric === void 0 ? void 0 : Number(numeric);
121
+ }
122
+ function parseNonNegativeInteger(value) {
123
+ if (value === void 0) return;
124
+ const parsed = Number.parseInt(value, 10);
125
+ return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
126
+ }
42
127
  function readSheetPrintSettings(pkg, tableElement) {
43
128
  const tableStyleName = (0, ooxml_js.attr)(tableElement, "table:style-name");
44
129
  const tableStyleElement = tableStyleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(tableStyleName, "table", pkg);
@@ -48,14 +133,67 @@ function readSheetPrintSettings(pkg, tableElement) {
48
133
  const margins = layoutProperties === void 0 ? void 0 : (0, odf_js.parseMargins)(layoutProperties);
49
134
  const printTokens = new Set((layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0) ?? []);
50
135
  const pageOrder = (layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
136
+ const scaleToRaw = layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:scale-to");
137
+ const scalePercent = scaleToRaw === void 0 ? void 0 : parseScalePercentage(scaleToRaw);
138
+ const fitWidth = parseNonNegativeInteger(layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:scale-to-X"));
139
+ const fitHeight = parseNonNegativeInteger(layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:scale-to-Y"));
140
+ const fitToPages = fitWidth === void 0 || fitHeight === void 0 ? void 0 : {
141
+ width: fitWidth,
142
+ height: fitHeight
143
+ };
144
+ const printRangesRaw = (0, ooxml_js.attr)(tableElement, "table:print-ranges");
145
+ const printRange = printRangesRaw === void 0 ? void 0 : parsePrintRanges(printRangesRaw);
146
+ const { repeatColumns, repeatRows, manualBreakColumns, manualBreakRows } = scanTableStructure(pkg, tableElement);
147
+ const manualBreaks = manualBreakRows.length > 0 || manualBreakColumns.length > 0 ? {
148
+ rows: manualBreakRows,
149
+ columns: manualBreakColumns
150
+ } : void 0;
51
151
  return {
52
152
  pageSize: pageSize ?? document_schema_js.PAGE_SIZE_A4,
53
153
  margins: margins ?? DEFAULT_MARGINS,
54
154
  gridlines: printTokens.has("grid"),
55
155
  headers: printTokens.has("headers"),
56
- pageOrder
156
+ pageOrder,
157
+ ...printRange !== void 0 ? { printRange } : {},
158
+ ...scalePercent !== void 0 ? { scalePercent } : {},
159
+ ...fitToPages !== void 0 ? { fitToPages } : {},
160
+ ...repeatRows !== void 0 ? { repeatRows } : {},
161
+ ...repeatColumns !== void 0 ? { repeatColumns } : {},
162
+ ...manualBreaks !== void 0 ? { manualBreaks } : {}
57
163
  };
58
164
  }
165
+ function unwrapHeaderGroup(tableElement, wrapperTag) {
166
+ const index = tableElement.children.findIndex((child) => child.type === "element" && child.tag === wrapperTag);
167
+ if (index === -1) return;
168
+ const wrapper = tableElement.children[index];
169
+ if (wrapper?.type !== "element") return;
170
+ tableElement.children.splice(index, 1, ...wrapper.children);
171
+ }
172
+ function collectRangeElements(children, tag, repeatAttr, start, end) {
173
+ let cursor = 0;
174
+ const found = [];
175
+ children.forEach((node, position) => {
176
+ if (node.type !== "element" || node.tag !== tag) return;
177
+ const count = require_edit_ods_address.readRunRepeatCount(node, repeatAttr);
178
+ if (cursor >= start && cursor + count - 1 <= end) found.push({
179
+ position,
180
+ element: node
181
+ });
182
+ cursor += count;
183
+ });
184
+ return found;
185
+ }
186
+ function wrapRepeatRange(tableElement, memberTag, repeatAttr, wrapperTag, range, buildEmpty) {
187
+ require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(memberTag), range.start, repeatAttr, buildEmpty);
188
+ require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(memberTag), range.end, repeatAttr, buildEmpty);
189
+ const found = collectRangeElements(tableElement.children, memberTag, repeatAttr, range.start, range.end);
190
+ if (found.length === 0) return;
191
+ const firstPosition = found[0].position;
192
+ const elements = found.map((entry) => entry.element);
193
+ const positions = found.map((entry) => entry.position);
194
+ for (let i = positions.length - 1; i >= 0; i--) tableElement.children.splice(positions[i], 1);
195
+ tableElement.children.splice(firstPosition, 0, require_xml_fragment.el(wrapperTag, {}, elements));
196
+ }
59
197
  function writeSheetPrintSettings(pkg, tableElement, settings) {
60
198
  const stylesAutomaticStyles = findStylesAutomaticStyles(pkg);
61
199
  const masterStyles = findMasterStyles(pkg);
@@ -70,7 +208,12 @@ function writeSheetPrintSettings(pkg, tableElement, settings) {
70
208
  "fo:margin-bottom": (0, odf_js.formatOdfLength)(settings.margins.bottomPt),
71
209
  "fo:margin-left": (0, odf_js.formatOdfLength)(settings.margins.leftPt),
72
210
  ...printTokens.length > 0 ? { "style:print": printTokens.join(" ") } : {},
73
- "style:print-page-order": settings.pageOrder === "overThenDown" ? "ltr" : "ttb"
211
+ "style:print-page-order": settings.pageOrder === "overThenDown" ? "ltr" : "ttb",
212
+ ...settings.scalePercent !== void 0 ? { "style:scale-to": `${settings.scalePercent}%` } : {},
213
+ ...settings.fitToPages !== void 0 ? {
214
+ "style:scale-to-X": String(settings.fitToPages.width),
215
+ "style:scale-to-Y": String(settings.fitToPages.height)
216
+ } : {}
74
217
  })]));
75
218
  const masterPageName = require_edit_odt_automatic_styles.nextStyleName(masterStyles, "style:master-page", "OdsMasterPage");
76
219
  masterStyles.children.push(require_xml_fragment.el("style:master-page", {
@@ -84,6 +227,19 @@ function writeSheetPrintSettings(pkg, tableElement, settings) {
84
227
  "style:master-page-name": masterPageName
85
228
  }));
86
229
  require_xml_edit.setAttr(tableElement, "table:style-name", tableStyleName);
230
+ if (settings.printRange !== void 0) {
231
+ const sheetName = (0, ooxml_js.attr)(tableElement, "table:name");
232
+ if (sheetName === void 0) throw new Error("writeSheetPrintSettings: printRange requires tableElement to already carry a table:name");
233
+ require_xml_edit.setAttr(tableElement, "table:print-ranges", formatPrintRange(sheetName, settings.printRange));
234
+ }
235
+ unwrapHeaderGroup(tableElement, require_edit_ods_address.HEADER_COLUMNS_TAG);
236
+ if (settings.repeatColumns !== void 0) wrapRepeatRange(tableElement, require_edit_ods_address.COLUMN_TAG, require_edit_ods_address.COLUMN_REPEAT_ATTR, require_edit_ods_address.HEADER_COLUMNS_TAG, settings.repeatColumns, () => require_xml_fragment.el(require_edit_ods_address.COLUMN_TAG));
237
+ unwrapHeaderGroup(tableElement, require_edit_ods_address.HEADER_ROWS_TAG);
238
+ if (settings.repeatRows !== void 0) wrapRepeatRange(tableElement, require_edit_ods_address.ROW_TAG, require_edit_ods_address.ROW_REPEAT_ATTR, require_edit_ods_address.HEADER_ROWS_TAG, settings.repeatRows, () => require_xml_fragment.el(require_edit_ods_address.ROW_TAG));
239
+ if (settings.manualBreaks !== void 0) {
240
+ for (const columnIndex of settings.manualBreaks.columns) require_edit_ods_column_row.writeColumnManualBreak(pkg, tableElement, columnIndex);
241
+ for (const rowIndex of settings.manualBreaks.rows) require_edit_ods_column_row.writeRowManualBreak(pkg, tableElement, rowIndex);
242
+ }
87
243
  }
88
244
  //#endregion
89
245
  exports.readSheetPrintSettings = readSheetPrintSettings;
@@ -2,8 +2,10 @@ import { PAGE_SIZE_A4 } from "../../model/geometry.js";
2
2
  import { el } from "../../xml/fragment.js";
3
3
  import { setAttr } from "../../xml/edit.js";
4
4
  import { nextStyleName } from "../odt/automatic-styles.js";
5
+ import { COLUMN_REPEAT_ATTR, COLUMN_TAG, HEADER_COLUMNS_TAG, HEADER_ROWS_TAG, ROW_REPEAT_ATTR, ROW_TAG, isElementWithTag, readRunRepeatCount, replaceRun } from "./address.js";
6
+ import { writeColumnManualBreak, writeRowManualBreak } from "./column-row.js";
5
7
  import { attr } from "ooxml.js";
6
- import { findStyleElement, formatOdfLength, parseMargins, parsePageSize, resolvePageLayoutProperties } from "odf.js";
8
+ import { cellReference, findStyleElement, formatOdfLength, parseCellReference, parseMargins, parsePageSize, resolvePageLayoutProperties } from "odf.js";
7
9
  //#region src/edit/ods/print-settings.ts
8
10
  const STYLES_PART_PATH = "styles.xml";
9
11
  const CONTENT_PART_PATH = "content.xml";
@@ -38,6 +40,89 @@ const DEFAULT_MARGINS = {
38
40
  bottomPt: DEFAULT_MARGIN_PT,
39
41
  leftPt: DEFAULT_MARGIN_PT
40
42
  };
43
+ function hasManualBreak(pkg, element, family, propertiesTag) {
44
+ const styleName = attr(element, "table:style-name");
45
+ const styleElement = styleName === void 0 ? void 0 : findStyleElement(styleName, family, pkg);
46
+ const properties = styleElement === void 0 ? void 0 : directChild(styleElement, propertiesTag);
47
+ return properties !== void 0 && attr(properties, "fo:break-before") === "page";
48
+ }
49
+ function scanTableStructure(pkg, tableElement) {
50
+ let columnCursor = 0;
51
+ let rowCursor = 0;
52
+ let repeatColumns;
53
+ let repeatRows;
54
+ const manualBreakColumns = [];
55
+ const manualBreakRows = [];
56
+ function processColumn(columnElement) {
57
+ if (hasManualBreak(pkg, columnElement, "table-column", "style:table-column-properties")) manualBreakColumns.push(columnCursor);
58
+ columnCursor += readRunRepeatCount(columnElement, COLUMN_REPEAT_ATTR);
59
+ }
60
+ function processRow(rowElement) {
61
+ const startIndex = rowCursor;
62
+ if (hasManualBreak(pkg, rowElement, "table-row", "style:table-row-properties")) manualBreakRows.push(startIndex);
63
+ rowCursor += readRunRepeatCount(rowElement, ROW_REPEAT_ATTR);
64
+ }
65
+ for (const child of tableElement.children) {
66
+ if (child.type !== "element") continue;
67
+ if (child.tag === "table:table-column") processColumn(child);
68
+ else if (child.tag === "table:table-header-columns") {
69
+ const startIndex = columnCursor;
70
+ for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
71
+ if (columnCursor > startIndex) repeatColumns = {
72
+ start: startIndex,
73
+ end: columnCursor - 1
74
+ };
75
+ } else if (child.tag === "table:table-row") processRow(child);
76
+ else if (child.tag === "table:table-header-rows") {
77
+ const startIndex = rowCursor;
78
+ for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-row") processRow(headerChild);
79
+ if (rowCursor > startIndex) repeatRows = {
80
+ start: startIndex,
81
+ end: rowCursor - 1
82
+ };
83
+ }
84
+ }
85
+ return {
86
+ repeatColumns,
87
+ repeatRows,
88
+ manualBreakColumns,
89
+ manualBreakRows
90
+ };
91
+ }
92
+ function parseA1WithOptionalSheetPrefix(cellPart) {
93
+ const dotIndex = cellPart.lastIndexOf(".");
94
+ const bareReference = dotIndex === -1 ? cellPart : cellPart.slice(dotIndex + 1);
95
+ return parseCellReference(bareReference);
96
+ }
97
+ function parsePrintRanges(value) {
98
+ const first = value.split(" ").find((part) => part.length > 0);
99
+ if (first === void 0) return;
100
+ const separatorIndex = first.indexOf(":");
101
+ if (separatorIndex === -1) return;
102
+ const start = parseA1WithOptionalSheetPrefix(first.slice(0, separatorIndex));
103
+ const end = parseA1WithOptionalSheetPrefix(first.slice(separatorIndex + 1));
104
+ if (start === void 0 || end === void 0) return;
105
+ return {
106
+ startRow: start.row,
107
+ startColumn: start.column,
108
+ endRow: end.row,
109
+ endColumn: end.column
110
+ };
111
+ }
112
+ function formatPrintRange(sheetName, range) {
113
+ return `${`${sheetName}.${cellReference(range.startColumn, range.startRow)}`}:${`${sheetName}.${cellReference(range.endColumn, range.endRow)}`}`;
114
+ }
115
+ function parseScalePercentage(value) {
116
+ const match = /^(\d+(?:\.\d+)?)%$/.exec(value);
117
+ if (match === null) return;
118
+ const numeric = match[1];
119
+ return numeric === void 0 ? void 0 : Number(numeric);
120
+ }
121
+ function parseNonNegativeInteger(value) {
122
+ if (value === void 0) return;
123
+ const parsed = Number.parseInt(value, 10);
124
+ return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
125
+ }
41
126
  function readSheetPrintSettings(pkg, tableElement) {
42
127
  const tableStyleName = attr(tableElement, "table:style-name");
43
128
  const tableStyleElement = tableStyleName === void 0 ? void 0 : findStyleElement(tableStyleName, "table", pkg);
@@ -47,14 +132,67 @@ function readSheetPrintSettings(pkg, tableElement) {
47
132
  const margins = layoutProperties === void 0 ? void 0 : parseMargins(layoutProperties);
48
133
  const printTokens = new Set((layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0) ?? []);
49
134
  const pageOrder = (layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
135
+ const scaleToRaw = layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:scale-to");
136
+ const scalePercent = scaleToRaw === void 0 ? void 0 : parseScalePercentage(scaleToRaw);
137
+ const fitWidth = parseNonNegativeInteger(layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:scale-to-X"));
138
+ const fitHeight = parseNonNegativeInteger(layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:scale-to-Y"));
139
+ const fitToPages = fitWidth === void 0 || fitHeight === void 0 ? void 0 : {
140
+ width: fitWidth,
141
+ height: fitHeight
142
+ };
143
+ const printRangesRaw = attr(tableElement, "table:print-ranges");
144
+ const printRange = printRangesRaw === void 0 ? void 0 : parsePrintRanges(printRangesRaw);
145
+ const { repeatColumns, repeatRows, manualBreakColumns, manualBreakRows } = scanTableStructure(pkg, tableElement);
146
+ const manualBreaks = manualBreakRows.length > 0 || manualBreakColumns.length > 0 ? {
147
+ rows: manualBreakRows,
148
+ columns: manualBreakColumns
149
+ } : void 0;
50
150
  return {
51
151
  pageSize: pageSize ?? PAGE_SIZE_A4,
52
152
  margins: margins ?? DEFAULT_MARGINS,
53
153
  gridlines: printTokens.has("grid"),
54
154
  headers: printTokens.has("headers"),
55
- pageOrder
155
+ pageOrder,
156
+ ...printRange !== void 0 ? { printRange } : {},
157
+ ...scalePercent !== void 0 ? { scalePercent } : {},
158
+ ...fitToPages !== void 0 ? { fitToPages } : {},
159
+ ...repeatRows !== void 0 ? { repeatRows } : {},
160
+ ...repeatColumns !== void 0 ? { repeatColumns } : {},
161
+ ...manualBreaks !== void 0 ? { manualBreaks } : {}
56
162
  };
57
163
  }
164
+ function unwrapHeaderGroup(tableElement, wrapperTag) {
165
+ const index = tableElement.children.findIndex((child) => child.type === "element" && child.tag === wrapperTag);
166
+ if (index === -1) return;
167
+ const wrapper = tableElement.children[index];
168
+ if (wrapper?.type !== "element") return;
169
+ tableElement.children.splice(index, 1, ...wrapper.children);
170
+ }
171
+ function collectRangeElements(children, tag, repeatAttr, start, end) {
172
+ let cursor = 0;
173
+ const found = [];
174
+ children.forEach((node, position) => {
175
+ if (node.type !== "element" || node.tag !== tag) return;
176
+ const count = readRunRepeatCount(node, repeatAttr);
177
+ if (cursor >= start && cursor + count - 1 <= end) found.push({
178
+ position,
179
+ element: node
180
+ });
181
+ cursor += count;
182
+ });
183
+ return found;
184
+ }
185
+ function wrapRepeatRange(tableElement, memberTag, repeatAttr, wrapperTag, range, buildEmpty) {
186
+ replaceRun(tableElement.children, isElementWithTag(memberTag), range.start, repeatAttr, buildEmpty);
187
+ replaceRun(tableElement.children, isElementWithTag(memberTag), range.end, repeatAttr, buildEmpty);
188
+ const found = collectRangeElements(tableElement.children, memberTag, repeatAttr, range.start, range.end);
189
+ if (found.length === 0) return;
190
+ const firstPosition = found[0].position;
191
+ const elements = found.map((entry) => entry.element);
192
+ const positions = found.map((entry) => entry.position);
193
+ for (let i = positions.length - 1; i >= 0; i--) tableElement.children.splice(positions[i], 1);
194
+ tableElement.children.splice(firstPosition, 0, el(wrapperTag, {}, elements));
195
+ }
58
196
  function writeSheetPrintSettings(pkg, tableElement, settings) {
59
197
  const stylesAutomaticStyles = findStylesAutomaticStyles(pkg);
60
198
  const masterStyles = findMasterStyles(pkg);
@@ -69,7 +207,12 @@ function writeSheetPrintSettings(pkg, tableElement, settings) {
69
207
  "fo:margin-bottom": formatOdfLength(settings.margins.bottomPt),
70
208
  "fo:margin-left": formatOdfLength(settings.margins.leftPt),
71
209
  ...printTokens.length > 0 ? { "style:print": printTokens.join(" ") } : {},
72
- "style:print-page-order": settings.pageOrder === "overThenDown" ? "ltr" : "ttb"
210
+ "style:print-page-order": settings.pageOrder === "overThenDown" ? "ltr" : "ttb",
211
+ ...settings.scalePercent !== void 0 ? { "style:scale-to": `${settings.scalePercent}%` } : {},
212
+ ...settings.fitToPages !== void 0 ? {
213
+ "style:scale-to-X": String(settings.fitToPages.width),
214
+ "style:scale-to-Y": String(settings.fitToPages.height)
215
+ } : {}
73
216
  })]));
74
217
  const masterPageName = nextStyleName(masterStyles, "style:master-page", "OdsMasterPage");
75
218
  masterStyles.children.push(el("style:master-page", {
@@ -83,6 +226,19 @@ function writeSheetPrintSettings(pkg, tableElement, settings) {
83
226
  "style:master-page-name": masterPageName
84
227
  }));
85
228
  setAttr(tableElement, "table:style-name", tableStyleName);
229
+ if (settings.printRange !== void 0) {
230
+ const sheetName = attr(tableElement, "table:name");
231
+ if (sheetName === void 0) throw new Error("writeSheetPrintSettings: printRange requires tableElement to already carry a table:name");
232
+ setAttr(tableElement, "table:print-ranges", formatPrintRange(sheetName, settings.printRange));
233
+ }
234
+ unwrapHeaderGroup(tableElement, HEADER_COLUMNS_TAG);
235
+ if (settings.repeatColumns !== void 0) wrapRepeatRange(tableElement, COLUMN_TAG, COLUMN_REPEAT_ATTR, HEADER_COLUMNS_TAG, settings.repeatColumns, () => el(COLUMN_TAG));
236
+ unwrapHeaderGroup(tableElement, HEADER_ROWS_TAG);
237
+ if (settings.repeatRows !== void 0) wrapRepeatRange(tableElement, ROW_TAG, ROW_REPEAT_ATTR, HEADER_ROWS_TAG, settings.repeatRows, () => el(ROW_TAG));
238
+ if (settings.manualBreaks !== void 0) {
239
+ for (const columnIndex of settings.manualBreaks.columns) writeColumnManualBreak(pkg, tableElement, columnIndex);
240
+ for (const rowIndex of settings.manualBreaks.rows) writeRowManualBreak(pkg, tableElement, rowIndex);
241
+ }
86
242
  }
87
243
  //#endregion
88
244
  export { readSheetPrintSettings, writeSheetPrintSettings };
@@ -3,6 +3,7 @@ const require_xml_edit = require("../../xml/edit.cjs");
3
3
  const require_edit_ods_address = require("./address.cjs");
4
4
  const require_edit_ods_cell = require("./cell.cjs");
5
5
  const require_edit_ods_column_row = require("./column-row.cjs");
6
+ const require_edit_ods_floating = require("./floating.cjs");
6
7
  const require_edit_ods_print_settings = require("./print-settings.cjs");
7
8
  let ooxml_js = require("ooxml.js");
8
9
  let odf_js = require("odf.js");
@@ -42,6 +43,18 @@ var OdsSheet = class {
42
43
  setRowHeight(index, heightPt) {
43
44
  require_edit_ods_column_row.writeRowHeight(this.pkg, this.live(), index, heightPt);
44
45
  }
46
+ setColumnHidden(index, hidden) {
47
+ require_edit_ods_column_row.writeColumnHidden(this.live(), index, hidden);
48
+ }
49
+ setRowHidden(index, hidden) {
50
+ require_edit_ods_column_row.writeRowHidden(this.live(), index, hidden);
51
+ }
52
+ addImage(image) {
53
+ require_edit_ods_floating.insertSheetImage(this.pkg, this.live(), image);
54
+ }
55
+ addEmbeddedObject(object) {
56
+ require_edit_ods_floating.insertSheetEmbeddedObject(this.pkg, this.live(), object);
57
+ }
45
58
  cell(row, column) {
46
59
  const node = require_edit_ods_address.resolveCellNode(this.live(), row, column);
47
60
  if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range -- address the merge's own anchor cell instead`);
@@ -1,5 +1,5 @@
1
1
  import { t as OdsCell } from "../../cell-CNHPsDEk.cjs";
2
- import { ContentSheetPrintSettings } from "document-schema.js";
2
+ import { ContentEmbeddedObject, ContentSheetImage, ContentSheetPrintSettings } from "document-schema.js";
3
3
  import { Package, XmlElement, XmlNode } from "odf.js";
4
4
  //#region src/edit/ods/sheet.d.ts
5
5
  declare class OdsSheet {
@@ -15,6 +15,10 @@ declare class OdsSheet {
15
15
  set printSettings(value: ContentSheetPrintSettings);
16
16
  setColumnWidth(index: number, widthPt: number): void;
17
17
  setRowHeight(index: number, heightPt: number): void;
18
+ setColumnHidden(index: number, hidden: boolean): void;
19
+ setRowHidden(index: number, hidden: boolean): void;
20
+ addImage(image: ContentSheetImage): void;
21
+ addEmbeddedObject(object: ContentEmbeddedObject): void;
18
22
  cell(row: number, column: number): OdsCell;
19
23
  cellAt(reference: string): OdsCell;
20
24
  mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): OdsCell;