js.documents 1.63.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -25
- package/dist/convert/convert.cjs +3 -3
- package/dist/convert/convert.d.cts +5 -2
- package/dist/convert/convert.d.ts +4 -1
- package/dist/convert/convert.js +3 -3
- package/dist/edit/docx/content.d.cts +1 -1
- package/dist/edit/docx/content.d.ts +1 -1
- package/dist/edit/docx/paragraph.d.cts +3 -3
- package/dist/edit/docx/paragraph.d.ts +3 -3
- package/dist/edit/ods/address.cjs +42 -24
- package/dist/edit/ods/address.d.cts +12 -2
- package/dist/edit/ods/address.d.ts +12 -2
- package/dist/edit/ods/address.js +39 -25
- package/dist/edit/ods/column-row.cjs +68 -6
- package/dist/edit/ods/column-row.d.cts +5 -1
- package/dist/edit/ods/column-row.d.ts +5 -1
- package/dist/edit/ods/column-row.js +68 -10
- package/dist/edit/ods/content.cjs +10 -2
- package/dist/edit/ods/content.js +10 -2
- package/dist/edit/ods/floating.cjs +90 -0
- package/dist/edit/ods/floating.d.cts +7 -0
- package/dist/edit/ods/floating.d.ts +7 -0
- package/dist/edit/ods/floating.js +88 -0
- package/dist/edit/ods/print-settings.cjs +158 -2
- package/dist/edit/ods/print-settings.js +159 -3
- package/dist/edit/ods/sheet.cjs +13 -0
- package/dist/edit/ods/sheet.d.cts +5 -1
- package/dist/edit/ods/sheet.d.ts +5 -1
- package/dist/edit/ods/sheet.js +14 -1
- package/dist/edit/odt/content.cjs +8 -4
- package/dist/edit/odt/content.js +8 -4
- package/dist/edit/odt/editor.cjs +7 -0
- package/dist/edit/odt/editor.d.cts +3 -0
- package/dist/edit/odt/editor.d.ts +3 -0
- package/dist/edit/odt/editor.js +7 -0
- package/dist/edit/odt/formula.cjs +19 -0
- package/dist/edit/odt/formula.d.cts +8 -0
- package/dist/edit/odt/formula.d.ts +8 -0
- package/dist/edit/odt/formula.js +17 -0
- package/dist/evaluate-BU5N1Jk1.d.ts +11 -0
- package/dist/evaluate-BhMXY6DM.d.cts +11 -0
- package/dist/firebird/backup.d.cts +1 -1
- package/dist/firebird/backup.d.ts +1 -1
- package/dist/firebird/data.cjs +30 -16
- package/dist/firebird/data.d.cts +3 -2
- package/dist/firebird/data.d.ts +3 -2
- package/dist/firebird/data.js +30 -17
- package/dist/fonts/ooxml.d.cts +1 -1
- package/dist/fonts/registry.d.cts +1 -1
- package/dist/formula-CgydMiTt.d.ts +10 -0
- package/dist/formula-CiwPw8nY.d.cts +10 -0
- package/dist/hsqldb/binary-script.d.cts +1 -1
- package/dist/hsqldb/binary-script.d.ts +1 -1
- package/dist/hsqldb/cache.d.cts +1 -1
- package/dist/hsqldb/cache.d.ts +1 -1
- package/dist/hsqldb/rowformat.cjs +22 -13
- package/dist/hsqldb/rowformat.js +22 -13
- package/dist/hsqldb/script.d.cts +1 -18
- package/dist/hsqldb/script.d.ts +1 -18
- package/dist/index.cjs +56 -0
- package/dist/index.d.cts +24 -10
- package/dist/index.d.ts +23 -9
- package/dist/index.js +15 -2
- package/dist/layout/sheets.cjs +30 -24
- package/dist/layout/sheets.js +31 -25
- package/dist/layout/slides.cjs +6 -4
- package/dist/layout/slides.js +7 -5
- package/dist/lexer-DGPWx_f2.d.cts +42 -0
- package/dist/lexer-DGPWx_f2.d.ts +42 -0
- package/dist/mathml/compose.cjs +8 -0
- package/dist/mathml/compose.js +8 -0
- package/dist/mathml/layout-types.d.cts +14 -2
- package/dist/mathml/layout-types.d.ts +14 -2
- package/dist/mathml/layout.cjs +62 -3
- package/dist/mathml/layout.d.cts +1 -1
- package/dist/mathml/layout.d.ts +1 -1
- package/dist/mathml/layout.js +62 -3
- package/dist/mathml/metrics.d.cts +17 -1
- package/dist/mathml/metrics.d.ts +17 -1
- package/dist/mathml/operators.cjs +1 -1
- package/dist/mathml/operators.js +1 -1
- package/dist/mathml/variant.d.cts +1 -6
- package/dist/mathml/variant.d.ts +1 -6
- package/dist/odb/csv.d.cts +1 -1
- package/dist/odb/csv.d.ts +1 -1
- package/dist/odb/formula/definition.cjs +49 -0
- package/dist/odb/formula/definition.d.cts +8 -0
- package/dist/odb/formula/definition.d.ts +8 -0
- package/dist/odb/formula/definition.js +46 -0
- package/dist/odb/formula/errors.cjs +47 -0
- package/dist/odb/formula/errors.d.cts +21 -0
- package/dist/odb/formula/errors.d.ts +21 -0
- package/dist/odb/formula/errors.js +43 -0
- package/dist/odb/formula/evaluate.cjs +283 -0
- package/dist/odb/formula/evaluate.d.cts +43 -0
- package/dist/odb/formula/evaluate.d.ts +43 -0
- package/dist/odb/formula/evaluate.js +281 -0
- package/dist/odb/formula/parser.cjs +198 -0
- package/dist/odb/formula/parser.d.cts +29 -0
- package/dist/odb/formula/parser.d.ts +29 -0
- package/dist/odb/formula/parser.js +197 -0
- package/dist/odb/read.d.cts +1 -1
- package/dist/odb/read.d.ts +1 -1
- package/dist/odb/report/content.cjs +27 -0
- package/dist/odb/report/content.d.cts +14 -0
- package/dist/odb/report/content.d.ts +14 -0
- package/dist/odb/report/content.js +25 -0
- package/dist/odb/report/render.cjs +106 -0
- package/dist/odb/report/render.d.cts +7 -0
- package/dist/odb/report/render.d.ts +7 -0
- package/dist/odb/report/render.js +106 -0
- package/dist/odb/report/source.cjs +45 -0
- package/dist/odb/report/source.d.cts +14 -0
- package/dist/odb/report/source.d.ts +14 -0
- package/dist/odb/report/source.js +42 -0
- package/dist/odb/spreadsheet.d.cts +1 -1
- package/dist/odb/spreadsheet.d.ts +1 -1
- package/dist/odb/sql/errors.cjs +38 -0
- package/dist/odb/sql/errors.d.cts +17 -0
- package/dist/odb/sql/errors.d.ts +17 -0
- package/dist/odb/sql/errors.js +35 -0
- package/dist/odb/sql/evaluate.cjs +312 -0
- package/dist/odb/sql/evaluate.d.cts +2 -0
- package/dist/odb/sql/evaluate.d.ts +2 -0
- package/dist/odb/sql/evaluate.js +311 -0
- package/dist/odb/sql/lexer.cjs +282 -0
- package/dist/odb/sql/lexer.d.cts +2 -0
- package/dist/odb/sql/lexer.d.ts +2 -0
- package/dist/odb/sql/lexer.js +281 -0
- package/dist/odb/sql/parser.cjs +479 -0
- package/dist/odb/sql/parser.d.cts +2 -0
- package/dist/odb/sql/parser.d.ts +2 -0
- package/dist/odb/sql/parser.js +478 -0
- package/dist/odb/values.cjs +75 -0
- package/dist/odb/values.d.cts +2 -0
- package/dist/odb/values.d.ts +2 -0
- package/dist/odb/values.js +69 -0
- package/dist/odf/odt/read.cjs +43 -21
- package/dist/odf/odt/read.js +43 -21
- package/dist/odf-package/formula.cjs +59 -0
- package/dist/odf-package/formula.d.cts +11 -0
- package/dist/odf-package/formula.d.ts +11 -0
- package/dist/odf-package/formula.js +58 -0
- package/dist/odf-package/manifest.cjs +29 -0
- package/dist/odf-package/manifest.d.cts +5 -2
- package/dist/odf-package/manifest.d.ts +5 -2
- package/dist/odf-package/manifest.js +30 -2
- package/dist/odf-package/media.cjs +2 -1
- package/dist/odf-package/media.js +2 -2
- package/dist/omml/read.cjs +265 -0
- package/dist/omml/read.d.cts +12 -0
- package/dist/omml/read.d.ts +12 -0
- package/dist/omml/read.js +263 -0
- package/dist/omml/shared.cjs +67 -0
- package/dist/omml/shared.d.cts +2 -0
- package/dist/omml/shared.d.ts +2 -0
- package/dist/omml/shared.js +64 -0
- package/dist/omml/write.cjs +3 -51
- package/dist/omml/write.d.cts +2 -2
- package/dist/omml/write.d.ts +2 -2
- package/dist/omml/write.js +1 -49
- package/dist/ooxml/docx/extras.cjs +15 -0
- package/dist/ooxml/docx/extras.d.cts +12 -0
- package/dist/ooxml/docx/extras.d.ts +12 -0
- package/dist/ooxml/docx/extras.js +14 -0
- package/dist/ooxml/docx/formula.cjs +109 -0
- package/dist/ooxml/docx/formula.d.cts +2 -0
- package/dist/ooxml/docx/formula.d.ts +2 -0
- package/dist/ooxml/docx/formula.js +108 -0
- package/dist/ooxml/docx/read.cjs +10 -2
- package/dist/ooxml/docx/read.d.cts +6 -2
- package/dist/ooxml/docx/read.d.ts +6 -2
- package/dist/ooxml/docx/read.js +11 -3
- package/dist/parser-B9vC1T6T.d.cts +101 -0
- package/dist/parser-DQSgYJzQ.d.ts +101 -0
- package/dist/{registry-CtPhMD0f.d.cts → registry-lqJej0Jr.d.cts} +1 -1
- package/dist/script-DsGGIzGU.d.cts +19 -0
- package/dist/script-DsGGIzGU.d.ts +19 -0
- package/dist/shared-DLZ3IQUl.d.cts +15 -0
- package/dist/shared-DUOzjwcL.d.ts +15 -0
- package/dist/values-BetetbaH.d.cts +23 -0
- package/dist/values-BetetbaH.d.ts +23 -0
- package/dist/variant-BMrebjMw.d.cts +7 -0
- package/dist/variant-BMrebjMw.d.ts +7 -0
- package/dist/{write-DuyfnbL_.d.cts → write-BQ6SK8r8.d.cts} +2 -6
- package/dist/{write-Zqwx6pka.d.ts → write-THs7ipBq.d.ts} +2 -6
- package/package.json +2 -2
|
@@ -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 };
|
package/dist/edit/ods/sheet.cjs
CHANGED
|
@@ -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;
|
package/dist/edit/ods/sheet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as OdsCell } from "../../cell-CNHPsDEk.js";
|
|
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;
|
package/dist/edit/ods/sheet.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { removeChild, setAttr } from "../../xml/edit.js";
|
|
2
2
|
import { COVERED_CELL_TAG, resolveCellNode } from "./address.js";
|
|
3
3
|
import { OdsCell } from "./cell.js";
|
|
4
|
-
import { writeColumnWidth, writeRowHeight } from "./column-row.js";
|
|
4
|
+
import { writeColumnHidden, writeColumnWidth, writeRowHeight, writeRowHidden } from "./column-row.js";
|
|
5
|
+
import { insertSheetEmbeddedObject, insertSheetImage } from "./floating.js";
|
|
5
6
|
import { readSheetPrintSettings, writeSheetPrintSettings } from "./print-settings.js";
|
|
6
7
|
import { attr } from "ooxml.js";
|
|
7
8
|
import { parseCellReference } from "odf.js";
|
|
@@ -41,6 +42,18 @@ var OdsSheet = class {
|
|
|
41
42
|
setRowHeight(index, heightPt) {
|
|
42
43
|
writeRowHeight(this.pkg, this.live(), index, heightPt);
|
|
43
44
|
}
|
|
45
|
+
setColumnHidden(index, hidden) {
|
|
46
|
+
writeColumnHidden(this.live(), index, hidden);
|
|
47
|
+
}
|
|
48
|
+
setRowHidden(index, hidden) {
|
|
49
|
+
writeRowHidden(this.live(), index, hidden);
|
|
50
|
+
}
|
|
51
|
+
addImage(image) {
|
|
52
|
+
insertSheetImage(this.pkg, this.live(), image);
|
|
53
|
+
}
|
|
54
|
+
addEmbeddedObject(object) {
|
|
55
|
+
insertSheetEmbeddedObject(this.pkg, this.live(), object);
|
|
56
|
+
}
|
|
44
57
|
cell(row, column) {
|
|
45
58
|
const node = resolveCellNode(this.live(), row, column);
|
|
46
59
|
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`);
|
|
@@ -139,10 +139,14 @@ function appendBlock(body, block) {
|
|
|
139
139
|
function appendEmbeddedObject(body, block) {
|
|
140
140
|
const formula = require_model_formula.formulaOfBlock(block);
|
|
141
141
|
if (formula === void 0) return;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
if (formula.mathml.length === 0) {
|
|
143
|
+
populateParagraph(body.appendParagraph(), {
|
|
144
|
+
kind: "paragraph",
|
|
145
|
+
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
body.appendFormula(formula, block.frame);
|
|
146
150
|
}
|
|
147
151
|
//#endregion
|
|
148
152
|
exports.buildOdtPackage = buildOdtPackage;
|
package/dist/edit/odt/content.js
CHANGED
|
@@ -138,10 +138,14 @@ function appendBlock(body, block) {
|
|
|
138
138
|
function appendEmbeddedObject(body, block) {
|
|
139
139
|
const formula = formulaOfBlock(block);
|
|
140
140
|
if (formula === void 0) return;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
if (formula.mathml.length === 0) {
|
|
142
|
+
populateParagraph(body.appendParagraph(), {
|
|
143
|
+
kind: "paragraph",
|
|
144
|
+
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
body.appendFormula(formula, block.frame);
|
|
145
149
|
}
|
|
146
150
|
//#endregion
|
|
147
151
|
export { buildOdtPackage, populateOdtTable, populateParagraph };
|
package/dist/edit/odt/editor.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_edit_odt_automatic_styles = require("./automatic-styles.cjs");
|
|
3
|
+
const require_edit_odt_formula = require("./formula.cjs");
|
|
3
4
|
const require_edit_odt_paragraph = require("./paragraph.cjs");
|
|
4
5
|
const require_edit_odt_list = require("./list.cjs");
|
|
5
6
|
const require_edit_odt_scaffold = require("./scaffold.cjs");
|
|
@@ -44,6 +45,12 @@ var OdtBodyImpl = class {
|
|
|
44
45
|
this.officeText.children.push(listElement);
|
|
45
46
|
return new require_edit_odt_list.OdtList(this.officeText.children, listElement, this.pkg);
|
|
46
47
|
}
|
|
48
|
+
appendFormula(formula, frame) {
|
|
49
|
+
const paragraphElement = require_edit_odt_paragraph.buildParagraph(this.pkg);
|
|
50
|
+
paragraphElement.children.push(require_edit_odt_formula.insertFormulaFrameMedia(this.pkg, frame, formula));
|
|
51
|
+
this.officeText.children.push(paragraphElement);
|
|
52
|
+
return new require_edit_odt_paragraph.OdtParagraph(this.officeText.children, paragraphElement, this.pkg);
|
|
53
|
+
}
|
|
47
54
|
appendPageBreak() {
|
|
48
55
|
const paragraphElement = require_edit_odt_paragraph.buildParagraph(this.pkg);
|
|
49
56
|
paragraphElement.attributes.push({
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
1
2
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BXbXKPy3.cjs";
|
|
2
3
|
import { t as OdtList } from "../../list-BuBM9rwQ.cjs";
|
|
3
4
|
import { i as TableInit, t as OdtTable } from "../../table-DjYcNOFm.cjs";
|
|
5
|
+
import { ContentFormula } from "document-schema.js";
|
|
4
6
|
import { Package } from "odf.js";
|
|
5
7
|
//#region src/edit/odt/editor.d.ts
|
|
6
8
|
interface OdtBody {
|
|
@@ -8,6 +10,7 @@ interface OdtBody {
|
|
|
8
10
|
appendTable(init: TableInit): OdtTable;
|
|
9
11
|
appendList(): OdtList;
|
|
10
12
|
appendPageBreak(): void;
|
|
13
|
+
appendFormula(formula: ContentFormula, frame: Box$1): OdtParagraph;
|
|
11
14
|
}
|
|
12
15
|
declare class OdtEditor {
|
|
13
16
|
readonly body: OdtBody;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
1
2
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CoUi_88j.js";
|
|
2
3
|
import { t as OdtList } from "../../list-CvKxhy3y.js";
|
|
3
4
|
import { i as TableInit, t as OdtTable } from "../../table-DqfqMkVq.js";
|
|
5
|
+
import { ContentFormula } from "document-schema.js";
|
|
4
6
|
import { Package } from "odf.js";
|
|
5
7
|
//#region src/edit/odt/editor.d.ts
|
|
6
8
|
interface OdtBody {
|
|
@@ -8,6 +10,7 @@ interface OdtBody {
|
|
|
8
10
|
appendTable(init: TableInit): OdtTable;
|
|
9
11
|
appendList(): OdtList;
|
|
10
12
|
appendPageBreak(): void;
|
|
13
|
+
appendFormula(formula: ContentFormula, frame: Box$1): OdtParagraph;
|
|
11
14
|
}
|
|
12
15
|
declare class OdtEditor {
|
|
13
16
|
readonly body: OdtBody;
|
package/dist/edit/odt/editor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ensurePageBreakStyleName } from "./automatic-styles.js";
|
|
2
|
+
import { insertFormulaFrameMedia } from "./formula.js";
|
|
2
3
|
import { OdtParagraph, buildParagraph } from "./paragraph.js";
|
|
3
4
|
import { OdtList, buildList } from "./list.js";
|
|
4
5
|
import { createEmptyOdtPackage } from "./scaffold.js";
|
|
@@ -43,6 +44,12 @@ var OdtBodyImpl = class {
|
|
|
43
44
|
this.officeText.children.push(listElement);
|
|
44
45
|
return new OdtList(this.officeText.children, listElement, this.pkg);
|
|
45
46
|
}
|
|
47
|
+
appendFormula(formula, frame) {
|
|
48
|
+
const paragraphElement = buildParagraph(this.pkg);
|
|
49
|
+
paragraphElement.children.push(insertFormulaFrameMedia(this.pkg, frame, formula));
|
|
50
|
+
this.officeText.children.push(paragraphElement);
|
|
51
|
+
return new OdtParagraph(this.officeText.children, paragraphElement, this.pkg);
|
|
52
|
+
}
|
|
46
53
|
appendPageBreak() {
|
|
47
54
|
const paragraphElement = buildParagraph(this.pkg);
|
|
48
55
|
paragraphElement.attributes.push({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_odf_package_formula = require("../../odf-package/formula.cjs");
|
|
4
|
+
let odf_js = require("odf.js");
|
|
5
|
+
//#region src/edit/odt/formula.ts
|
|
6
|
+
function buildFormulaFrame(href, frame) {
|
|
7
|
+
return require_xml_fragment.el("draw:frame", {
|
|
8
|
+
"text:anchor-type": "as-char",
|
|
9
|
+
"svg:width": (0, odf_js.formatOdfLength)(frame.widthPt),
|
|
10
|
+
"svg:height": (0, odf_js.formatOdfLength)(frame.heightPt)
|
|
11
|
+
}, [require_xml_fragment.el("draw:object", { "xlink:href": href })]);
|
|
12
|
+
}
|
|
13
|
+
function insertFormulaFrameMedia(pkg, frame, formula) {
|
|
14
|
+
const { href } = require_odf_package_formula.addFormulaObject(pkg, formula);
|
|
15
|
+
return buildFormulaFrame(href, frame);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.buildFormulaFrame = buildFormulaFrame;
|
|
19
|
+
exports.insertFormulaFrameMedia = insertFormulaFrameMedia;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
2
|
+
import { ContentFormula } from "document-schema.js";
|
|
3
|
+
import { Package, XmlElement } from "odf.js";
|
|
4
|
+
//#region src/edit/odt/formula.d.ts
|
|
5
|
+
declare function buildFormulaFrame(href: string, frame: Box$1): XmlElement;
|
|
6
|
+
declare function insertFormulaFrameMedia(pkg: Package, frame: Box$1, formula: ContentFormula): XmlElement;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buildFormulaFrame, insertFormulaFrameMedia };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
2
|
+
import { ContentFormula } from "document-schema.js";
|
|
3
|
+
import { Package, XmlElement } from "odf.js";
|
|
4
|
+
//#region src/edit/odt/formula.d.ts
|
|
5
|
+
declare function buildFormulaFrame(href: string, frame: Box$1): XmlElement;
|
|
6
|
+
declare function insertFormulaFrameMedia(pkg: Package, frame: Box$1, formula: ContentFormula): XmlElement;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buildFormulaFrame, insertFormulaFrameMedia };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { addFormulaObject } from "../../odf-package/formula.js";
|
|
3
|
+
import { formatOdfLength } from "odf.js";
|
|
4
|
+
//#region src/edit/odt/formula.ts
|
|
5
|
+
function buildFormulaFrame(href, frame) {
|
|
6
|
+
return el("draw:frame", {
|
|
7
|
+
"text:anchor-type": "as-char",
|
|
8
|
+
"svg:width": formatOdfLength(frame.widthPt),
|
|
9
|
+
"svg:height": formatOdfLength(frame.heightPt)
|
|
10
|
+
}, [el("draw:object", { "xlink:href": href })]);
|
|
11
|
+
}
|
|
12
|
+
function insertFormulaFrameMedia(pkg, frame, formula) {
|
|
13
|
+
const { href } = addFormulaObject(pkg, formula);
|
|
14
|
+
return buildFormulaFrame(href, frame);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { buildFormulaFrame, insertFormulaFrameMedia };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { r as HsqldbTable } from "./script-DsGGIzGU.js";
|
|
2
|
+
import { u as SqlSelectStatement } from "./parser-DQSgYJzQ.js";
|
|
3
|
+
import { ContentCellValue } from "document-schema.js";
|
|
4
|
+
//#region src/odb/sql/evaluate.d.ts
|
|
5
|
+
interface SqlResultSet {
|
|
6
|
+
readonly columns: readonly string[];
|
|
7
|
+
readonly rows: readonly (readonly ContentCellValue[])[];
|
|
8
|
+
}
|
|
9
|
+
declare function evaluateSelect(statement: SqlSelectStatement, tables: readonly HsqldbTable[]): SqlResultSet;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { evaluateSelect as n, SqlResultSet as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { r as HsqldbTable } from "./script-DsGGIzGU.cjs";
|
|
2
|
+
import { u as SqlSelectStatement } from "./parser-B9vC1T6T.cjs";
|
|
3
|
+
import { ContentCellValue } from "document-schema.js";
|
|
4
|
+
//#region src/odb/sql/evaluate.d.ts
|
|
5
|
+
interface SqlResultSet {
|
|
6
|
+
readonly columns: readonly string[];
|
|
7
|
+
readonly rows: readonly (readonly ContentCellValue[])[];
|
|
8
|
+
}
|
|
9
|
+
declare function evaluateSelect(statement: SqlSelectStatement, tables: readonly HsqldbTable[]): SqlResultSet;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { evaluateSelect as n, SqlResultSet as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HsqldbTable } from "../
|
|
1
|
+
import { r as HsqldbTable } from "../script-DsGGIzGU.cjs";
|
|
2
2
|
import { r as FirebirdSchemaParseError } from "../schema-BeR_KJ0X.cjs";
|
|
3
3
|
import { FirebirdCompositeRecordUnsupportedError } from "./data.cjs";
|
|
4
4
|
//#region src/firebird/backup.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HsqldbTable } from "../
|
|
1
|
+
import { r as HsqldbTable } from "../script-DsGGIzGU.js";
|
|
2
2
|
import { r as FirebirdSchemaParseError } from "../schema-CSKwSb_v.js";
|
|
3
3
|
import { FirebirdCompositeRecordUnsupportedError } from "./data.js";
|
|
4
4
|
//#region src/firebird/backup.d.ts
|
package/dist/firebird/data.cjs
CHANGED
|
@@ -89,32 +89,45 @@ function blobCellValue(field, bytes) {
|
|
|
89
89
|
function storedFieldsOf(fields) {
|
|
90
90
|
return fields.filter((field) => !field.computed);
|
|
91
91
|
}
|
|
92
|
+
function exactDecimalDigits(unscaled, decimalScale) {
|
|
93
|
+
const isNegative = unscaled < 0n;
|
|
94
|
+
const magnitudeDigits = (isNegative ? -unscaled : unscaled).toString();
|
|
95
|
+
const sign = isNegative ? "-" : "";
|
|
96
|
+
if (decimalScale <= 0) return `${sign}${magnitudeDigits}${"0".repeat(-decimalScale)}`;
|
|
97
|
+
const padded = magnitudeDigits.padStart(decimalScale + 1, "0");
|
|
98
|
+
return `${sign}${padded.slice(0, padded.length - decimalScale)}.${padded.slice(padded.length - decimalScale)}`;
|
|
99
|
+
}
|
|
100
|
+
function trimTrailingFractionZeros(digits) {
|
|
101
|
+
if (!digits.includes(".")) return digits;
|
|
102
|
+
const trimmed = digits.replace(/0+$/, "");
|
|
103
|
+
return trimmed.endsWith(".") ? trimmed.slice(0, -1) : trimmed;
|
|
104
|
+
}
|
|
105
|
+
function numericCellValue(unscaled, decimalScale) {
|
|
106
|
+
const exact = trimTrailingFractionZeros(exactDecimalDigits(unscaled, decimalScale));
|
|
107
|
+
const value = Number(exact);
|
|
108
|
+
return String(value) === exact ? {
|
|
109
|
+
kind: "number",
|
|
110
|
+
value
|
|
111
|
+
} : {
|
|
112
|
+
kind: "number",
|
|
113
|
+
value,
|
|
114
|
+
exactValue: exact
|
|
115
|
+
};
|
|
116
|
+
}
|
|
92
117
|
function decodeRowValues(fields, payload) {
|
|
93
118
|
const storedFields = storedFieldsOf(fields);
|
|
94
119
|
const xdr = new require_firebird_reader.XdrReader(payload);
|
|
95
120
|
const rawValues = [];
|
|
96
121
|
for (const field of storedFields) switch (field.physicalType) {
|
|
97
122
|
case "short":
|
|
98
|
-
rawValues.push(
|
|
99
|
-
kind: "number",
|
|
100
|
-
value: field.scale === 0 ? xdr.readInt16() : xdr.readInt16() * 10 ** field.scale
|
|
101
|
-
});
|
|
123
|
+
rawValues.push(numericCellValue(BigInt(xdr.readInt16()), -field.scale));
|
|
102
124
|
break;
|
|
103
125
|
case "long":
|
|
104
|
-
rawValues.push(
|
|
105
|
-
kind: "number",
|
|
106
|
-
value: field.scale === 0 ? xdr.readInt32() : xdr.readInt32() * 10 ** field.scale
|
|
107
|
-
});
|
|
126
|
+
rawValues.push(numericCellValue(BigInt(xdr.readInt32()), -field.scale));
|
|
108
127
|
break;
|
|
109
|
-
case "int64":
|
|
110
|
-
|
|
111
|
-
const scaled = field.scale === 0 ? Number(raw) : Number(raw) * 10 ** field.scale;
|
|
112
|
-
rawValues.push({
|
|
113
|
-
kind: "number",
|
|
114
|
-
value: scaled
|
|
115
|
-
});
|
|
128
|
+
case "int64":
|
|
129
|
+
rawValues.push(numericCellValue(xdr.readInt64(), -field.scale));
|
|
116
130
|
break;
|
|
117
|
-
}
|
|
118
131
|
case "real":
|
|
119
132
|
rawValues.push({
|
|
120
133
|
kind: "number",
|
|
@@ -282,4 +295,5 @@ function readRelationData(reader, schema, compressed) {
|
|
|
282
295
|
//#endregion
|
|
283
296
|
exports.FirebirdCompositeRecordUnsupportedError = FirebirdCompositeRecordUnsupportedError;
|
|
284
297
|
exports.FirebirdDataParseError = FirebirdDataParseError;
|
|
298
|
+
exports.decodeRowValues = decodeRowValues;
|
|
285
299
|
exports.readRelationData = readRelationData;
|
package/dist/firebird/data.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as FirebirdBackupReader } from "../reader-DP0Mbaj4.cjs";
|
|
2
|
-
import { n as FirebirdRelation } from "../schema-BeR_KJ0X.cjs";
|
|
2
|
+
import { n as FirebirdRelation, t as FirebirdField } from "../schema-BeR_KJ0X.cjs";
|
|
3
3
|
import { ContentCellValue } from "document-schema.js";
|
|
4
4
|
//#region src/firebird/data.d.ts
|
|
5
5
|
declare class FirebirdDataParseError extends Error {
|
|
@@ -9,9 +9,10 @@ declare class FirebirdCompositeRecordUnsupportedError extends Error {
|
|
|
9
9
|
readonly recordType: number;
|
|
10
10
|
constructor(recordType: number, context: string);
|
|
11
11
|
}
|
|
12
|
+
declare function decodeRowValues(fields: readonly FirebirdField[], payload: Uint8Array<ArrayBuffer>): ContentCellValue[];
|
|
12
13
|
declare function readRelationData(reader: FirebirdBackupReader, schema: ReadonlyMap<string, FirebirdRelation>, compressed: boolean): {
|
|
13
14
|
relationName: string;
|
|
14
15
|
rows: ContentCellValue[][];
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
|
17
|
-
export { FirebirdCompositeRecordUnsupportedError, FirebirdDataParseError, readRelationData };
|
|
18
|
+
export { FirebirdCompositeRecordUnsupportedError, FirebirdDataParseError, decodeRowValues, readRelationData };
|
package/dist/firebird/data.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as FirebirdBackupReader } from "../reader-DP0Mbaj4.js";
|
|
2
|
-
import { n as FirebirdRelation } from "../schema-CSKwSb_v.js";
|
|
2
|
+
import { n as FirebirdRelation, t as FirebirdField } from "../schema-CSKwSb_v.js";
|
|
3
3
|
import { ContentCellValue } from "document-schema.js";
|
|
4
4
|
//#region src/firebird/data.d.ts
|
|
5
5
|
declare class FirebirdDataParseError extends Error {
|
|
@@ -9,9 +9,10 @@ declare class FirebirdCompositeRecordUnsupportedError extends Error {
|
|
|
9
9
|
readonly recordType: number;
|
|
10
10
|
constructor(recordType: number, context: string);
|
|
11
11
|
}
|
|
12
|
+
declare function decodeRowValues(fields: readonly FirebirdField[], payload: Uint8Array<ArrayBuffer>): ContentCellValue[];
|
|
12
13
|
declare function readRelationData(reader: FirebirdBackupReader, schema: ReadonlyMap<string, FirebirdRelation>, compressed: boolean): {
|
|
13
14
|
relationName: string;
|
|
14
15
|
rows: ContentCellValue[][];
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
|
17
|
-
export { FirebirdCompositeRecordUnsupportedError, FirebirdDataParseError, readRelationData };
|
|
18
|
+
export { FirebirdCompositeRecordUnsupportedError, FirebirdDataParseError, decodeRowValues, readRelationData };
|