document-cli 1.0.1 → 1.2.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 +50 -8
- package/dist/cli.js +223 -24
- package/dist/index.cjs +520 -20
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +522 -22
- package/dist/odb-structure-CX_0zL8_.js +382 -0
- package/dist/{tui-CucYgqmL.js → tui-DD4bQp39.js} +644 -74
- package/package.json +3 -3
- package/dist/io-Cl3MaB0L.js +0 -81
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import "documents.js";
|
|
3
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
4
|
+
//#region src/format.ts
|
|
5
|
+
const EXTENSION_TO_FORMAT = {
|
|
6
|
+
docx: "docx",
|
|
7
|
+
pptx: "pptx",
|
|
8
|
+
xlsx: "xlsx",
|
|
9
|
+
odt: "odt",
|
|
10
|
+
odp: "odp",
|
|
11
|
+
ods: "ods",
|
|
12
|
+
odg: "odg",
|
|
13
|
+
odf: "odf",
|
|
14
|
+
markdown: "markdown",
|
|
15
|
+
md: "markdown",
|
|
16
|
+
pdf: "pdf"
|
|
17
|
+
};
|
|
18
|
+
const FORMAT_TO_EXTENSION = {
|
|
19
|
+
docx: "docx",
|
|
20
|
+
pptx: "pptx",
|
|
21
|
+
xlsx: "xlsx",
|
|
22
|
+
odt: "odt",
|
|
23
|
+
odp: "odp",
|
|
24
|
+
ods: "ods",
|
|
25
|
+
odg: "odg",
|
|
26
|
+
odf: "odf",
|
|
27
|
+
markdown: "md",
|
|
28
|
+
pdf: "pdf"
|
|
29
|
+
};
|
|
30
|
+
function isDocumentFormat(value) {
|
|
31
|
+
return value in FORMAT_TO_EXTENSION;
|
|
32
|
+
}
|
|
33
|
+
function inferFormatFromExtension(path) {
|
|
34
|
+
if (path === "-") return;
|
|
35
|
+
const lastSegment = path.split(/[/\\]/).pop() ?? path;
|
|
36
|
+
const dotIndex = lastSegment.lastIndexOf(".");
|
|
37
|
+
if (dotIndex <= 0) return;
|
|
38
|
+
const extension = lastSegment.slice(dotIndex + 1).toLowerCase();
|
|
39
|
+
return EXTENSION_TO_FORMAT[extension];
|
|
40
|
+
}
|
|
41
|
+
function formatToExtension(format) {
|
|
42
|
+
return FORMAT_TO_EXTENSION[format];
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/runtime/font-face.ts
|
|
46
|
+
var FontFaceError = class extends Error {
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "FontFaceError";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const SFNT_VERSION_TRUETYPE = 65536;
|
|
53
|
+
const SFNT_VERSION_CFF = 1330926671;
|
|
54
|
+
const SFNT_VERSION_APPLE_TRUE = 1953658213;
|
|
55
|
+
const SFNT_VERSION_APPLE_TYP1 = 1954115633;
|
|
56
|
+
const SFNT_VERSION_COLLECTION = 1953784678;
|
|
57
|
+
const SFNT_VERSIONS = /* @__PURE__ */ new Set([
|
|
58
|
+
SFNT_VERSION_TRUETYPE,
|
|
59
|
+
SFNT_VERSION_CFF,
|
|
60
|
+
SFNT_VERSION_APPLE_TRUE,
|
|
61
|
+
SFNT_VERSION_APPLE_TYP1
|
|
62
|
+
]);
|
|
63
|
+
const TABLE_DIRECTORY_HEADER_SIZE = 12;
|
|
64
|
+
const TABLE_RECORD_SIZE = 16;
|
|
65
|
+
const TABLE_TAG_SIZE = 4;
|
|
66
|
+
const NAME_HEADER_SIZE = 6;
|
|
67
|
+
const NAME_RECORD_SIZE = 12;
|
|
68
|
+
const NAME_ID_FAMILY = 1;
|
|
69
|
+
const NAME_ID_TYPOGRAPHIC_FAMILY = 16;
|
|
70
|
+
const PLATFORM_UNICODE = 0;
|
|
71
|
+
const PLATFORM_MACINTOSH = 1;
|
|
72
|
+
const PLATFORM_WINDOWS = 3;
|
|
73
|
+
const MACINTOSH_ENCODING_ROMAN = 0;
|
|
74
|
+
const OS2_FS_SELECTION_OFFSET = 62;
|
|
75
|
+
const OS2_MINIMUM_SIZE = 64;
|
|
76
|
+
const OS2_FS_SELECTION_ITALIC = 1;
|
|
77
|
+
const OS2_FS_SELECTION_BOLD = 32;
|
|
78
|
+
const HEAD_MAC_STYLE_OFFSET = 44;
|
|
79
|
+
const HEAD_MINIMUM_SIZE = 46;
|
|
80
|
+
const HEAD_MAC_STYLE_BOLD = 1;
|
|
81
|
+
const HEAD_MAC_STYLE_ITALIC = 2;
|
|
82
|
+
function viewOf(bytes) {
|
|
83
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
84
|
+
}
|
|
85
|
+
function decodeTag(view, offset) {
|
|
86
|
+
let tag = "";
|
|
87
|
+
for (let i = 0; i < TABLE_TAG_SIZE; i++) tag += String.fromCharCode(view.getUint8(offset + i));
|
|
88
|
+
return tag;
|
|
89
|
+
}
|
|
90
|
+
function decodeUtf16Be(view, offset, length) {
|
|
91
|
+
let text = "";
|
|
92
|
+
for (let i = 0; i + 1 < length; i += 2) text += String.fromCharCode(view.getUint16(offset + i));
|
|
93
|
+
return text;
|
|
94
|
+
}
|
|
95
|
+
function decodeMacintoshAscii(view, offset, length) {
|
|
96
|
+
let text = "";
|
|
97
|
+
for (let i = 0; i < length; i++) {
|
|
98
|
+
const byte = view.getUint8(offset + i);
|
|
99
|
+
if (byte > 126) return;
|
|
100
|
+
text += String.fromCharCode(byte);
|
|
101
|
+
}
|
|
102
|
+
return text;
|
|
103
|
+
}
|
|
104
|
+
function readTableDirectory(view, source) {
|
|
105
|
+
if (view.byteLength < TABLE_DIRECTORY_HEADER_SIZE) throw new FontFaceError(`${source} is too short to be a font file (${String(view.byteLength)} bytes)`);
|
|
106
|
+
const sfntVersion = view.getUint32(0);
|
|
107
|
+
if (sfntVersion === SFNT_VERSION_COLLECTION) throw new FontFaceError(`${source} is a TrueType Collection (.ttc), which packs several faces into one file; extract the single face you want and pass that instead`);
|
|
108
|
+
if (!SFNT_VERSIONS.has(sfntVersion)) throw new FontFaceError(`${source} is not a TrueType/OpenType font file (no recognised sfnt version); a .woff/.woff2 file must be converted to .ttf/.otf first`);
|
|
109
|
+
const numTables = view.getUint16(4);
|
|
110
|
+
if (view.byteLength < TABLE_DIRECTORY_HEADER_SIZE + numTables * TABLE_RECORD_SIZE) throw new FontFaceError(`${source} declares ${String(numTables)} tables but is too short to hold that many table records`);
|
|
111
|
+
const tables = /* @__PURE__ */ new Map();
|
|
112
|
+
for (let i = 0; i < numTables; i++) {
|
|
113
|
+
const recordOffset = TABLE_DIRECTORY_HEADER_SIZE + i * TABLE_RECORD_SIZE;
|
|
114
|
+
const tag = decodeTag(view, recordOffset);
|
|
115
|
+
const offset = view.getUint32(recordOffset + 8);
|
|
116
|
+
const length = view.getUint32(recordOffset + 12);
|
|
117
|
+
if (offset + length > view.byteLength || tables.has(tag)) continue;
|
|
118
|
+
tables.set(tag, {
|
|
119
|
+
offset,
|
|
120
|
+
length
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return tables;
|
|
124
|
+
}
|
|
125
|
+
function tableView(bytes, table) {
|
|
126
|
+
return new DataView(bytes.buffer, bytes.byteOffset + table.offset, table.length);
|
|
127
|
+
}
|
|
128
|
+
function readNameRecords(name) {
|
|
129
|
+
if (name.byteLength < NAME_HEADER_SIZE) return [];
|
|
130
|
+
const count = name.getUint16(2);
|
|
131
|
+
const storageOffset = name.getUint16(4);
|
|
132
|
+
if (name.byteLength < NAME_HEADER_SIZE + count * NAME_RECORD_SIZE) return [];
|
|
133
|
+
const records = [];
|
|
134
|
+
for (let i = 0; i < count; i++) {
|
|
135
|
+
const recordOffset = NAME_HEADER_SIZE + i * NAME_RECORD_SIZE;
|
|
136
|
+
records.push({
|
|
137
|
+
platformId: name.getUint16(recordOffset),
|
|
138
|
+
encodingId: name.getUint16(recordOffset + 2),
|
|
139
|
+
nameId: name.getUint16(recordOffset + 6),
|
|
140
|
+
length: name.getUint16(recordOffset + 8),
|
|
141
|
+
stringOffset: storageOffset + name.getUint16(recordOffset + 10)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return records;
|
|
145
|
+
}
|
|
146
|
+
function platformPreference(record) {
|
|
147
|
+
if (record.platformId === PLATFORM_WINDOWS) return 0;
|
|
148
|
+
if (record.platformId === PLATFORM_UNICODE) return 1;
|
|
149
|
+
if (record.platformId === PLATFORM_MACINTOSH && record.encodingId === MACINTOSH_ENCODING_ROMAN) return 2;
|
|
150
|
+
return Number.POSITIVE_INFINITY;
|
|
151
|
+
}
|
|
152
|
+
function readNameString(name, records, nameId) {
|
|
153
|
+
const candidates = records.filter((record) => record.nameId === nameId && Number.isFinite(platformPreference(record))).sort((left, right) => platformPreference(left) - platformPreference(right));
|
|
154
|
+
for (const record of candidates) {
|
|
155
|
+
if (record.stringOffset + record.length > name.byteLength) continue;
|
|
156
|
+
const text = record.platformId === PLATFORM_MACINTOSH ? decodeMacintoshAscii(name, record.stringOffset, record.length) : decodeUtf16Be(name, record.stringOffset, record.length);
|
|
157
|
+
if (text !== void 0 && text.length > 0) return text;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function readStyleBits(bytes, tables, source) {
|
|
161
|
+
const os2 = tables.get("OS/2");
|
|
162
|
+
if (os2 !== void 0 && os2.length >= OS2_MINIMUM_SIZE) {
|
|
163
|
+
const fsSelection = tableView(bytes, os2).getUint16(OS2_FS_SELECTION_OFFSET);
|
|
164
|
+
return {
|
|
165
|
+
bold: (fsSelection & OS2_FS_SELECTION_BOLD) !== 0,
|
|
166
|
+
italic: (fsSelection & OS2_FS_SELECTION_ITALIC) !== 0
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const head = tables.get("head");
|
|
170
|
+
if (head !== void 0 && head.length >= HEAD_MINIMUM_SIZE) {
|
|
171
|
+
const macStyle = tableView(bytes, head).getUint16(HEAD_MAC_STYLE_OFFSET);
|
|
172
|
+
return {
|
|
173
|
+
bold: (macStyle & HEAD_MAC_STYLE_BOLD) !== 0,
|
|
174
|
+
italic: (macStyle & HEAD_MAC_STYLE_ITALIC) !== 0
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
throw new FontFaceError(`${source} declares neither a readable 'OS/2' nor a readable 'head' table, so its weight and slope cannot be determined`);
|
|
178
|
+
}
|
|
179
|
+
function describeFontFace(bytes, source) {
|
|
180
|
+
const tables = readTableDirectory(viewOf(bytes), source);
|
|
181
|
+
const nameTable = tables.get("name");
|
|
182
|
+
if (nameTable === void 0) throw new FontFaceError(`${source} declares no 'name' table, so the font family it provides cannot be determined`);
|
|
183
|
+
const name = tableView(bytes, nameTable);
|
|
184
|
+
const records = readNameRecords(name);
|
|
185
|
+
const family = readNameString(name, records, NAME_ID_TYPOGRAPHIC_FAMILY) ?? readNameString(name, records, NAME_ID_FAMILY);
|
|
186
|
+
if (family === void 0) throw new FontFaceError(`${source} declares no family name in its 'name' table, so the font family it provides cannot be determined`);
|
|
187
|
+
const { bold, italic } = readStyleBits(bytes, tables, source);
|
|
188
|
+
return {
|
|
189
|
+
family,
|
|
190
|
+
bold,
|
|
191
|
+
italic
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/runtime/fonts.ts
|
|
196
|
+
async function loadProvidedFonts(paths, options) {
|
|
197
|
+
const fonts = [];
|
|
198
|
+
for (const path of paths) {
|
|
199
|
+
const bytes = new Uint8Array(await readFile(path, { signal: options?.signal }));
|
|
200
|
+
const face = describeFontFace(bytes, path);
|
|
201
|
+
fonts.push({
|
|
202
|
+
family: face.family,
|
|
203
|
+
bold: face.bold,
|
|
204
|
+
italic: face.italic,
|
|
205
|
+
bytes
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return fonts;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/runtime/io.ts
|
|
212
|
+
function isUint8Array(value) {
|
|
213
|
+
return value instanceof Uint8Array;
|
|
214
|
+
}
|
|
215
|
+
async function readStdin(signal) {
|
|
216
|
+
const chunks = [];
|
|
217
|
+
for await (const chunk of process.stdin) {
|
|
218
|
+
if (signal?.aborted === true) throw new Error("Reading from stdin was aborted");
|
|
219
|
+
if (!isUint8Array(chunk)) throw new Error("Unexpected non-buffer chunk read from stdin");
|
|
220
|
+
chunks.push(chunk);
|
|
221
|
+
}
|
|
222
|
+
return new Uint8Array(Buffer.concat(chunks));
|
|
223
|
+
}
|
|
224
|
+
async function readInput(pathOrDash, options) {
|
|
225
|
+
if (pathOrDash === "-") return readStdin(options?.signal);
|
|
226
|
+
const buffer = await readFile(pathOrDash, { signal: options?.signal });
|
|
227
|
+
return new Uint8Array(buffer);
|
|
228
|
+
}
|
|
229
|
+
async function writeOutput(pathOrDash, bytes) {
|
|
230
|
+
if (pathOrDash === "-") {
|
|
231
|
+
await new Promise((resolve, reject) => {
|
|
232
|
+
process.stdout.write(bytes, (error) => {
|
|
233
|
+
if (error) {
|
|
234
|
+
reject(error);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
resolve();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
await writeFile(pathOrDash, bytes);
|
|
243
|
+
}
|
|
244
|
+
function resolveDefaultOutputPath(inputPath, targetFormat) {
|
|
245
|
+
const directory = dirname(inputPath);
|
|
246
|
+
const stem = basename(inputPath, extname(inputPath));
|
|
247
|
+
return join(directory, `${stem}.${formatToExtension(targetFormat)}`);
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/odb-structure.ts
|
|
251
|
+
const INDENT = " ";
|
|
252
|
+
function indent(depth) {
|
|
253
|
+
return INDENT.repeat(depth);
|
|
254
|
+
}
|
|
255
|
+
function quoted(value) {
|
|
256
|
+
return `"${value}"`;
|
|
257
|
+
}
|
|
258
|
+
function describeDataSource(command, commandType) {
|
|
259
|
+
if (command === void 0) return commandType;
|
|
260
|
+
return commandType === void 0 ? quoted(command) : `${commandType} ${quoted(command)}`;
|
|
261
|
+
}
|
|
262
|
+
function countOdbFormControls(controls) {
|
|
263
|
+
return controls.reduce((total, control) => total + 1 + countOdbFormControls(control.controls), 0);
|
|
264
|
+
}
|
|
265
|
+
function countOdbFormDefinitionControls(definition) {
|
|
266
|
+
return countOdbFormControls(definition.controls) + definition.subForms.reduce((total, subForm) => total + countOdbFormDefinitionControls(subForm), 0);
|
|
267
|
+
}
|
|
268
|
+
function countOdbFormBoundControls(controls) {
|
|
269
|
+
return controls.reduce((total, control) => total + (control.dataField === void 0 ? 0 : 1) + countOdbFormBoundControls(control.controls), 0);
|
|
270
|
+
}
|
|
271
|
+
function countOdbFormDefinitionBoundControls(definition) {
|
|
272
|
+
return countOdbFormBoundControls(definition.controls) + definition.subForms.reduce((total, subForm) => total + countOdbFormDefinitionBoundControls(subForm), 0);
|
|
273
|
+
}
|
|
274
|
+
function describeOdbForm(form) {
|
|
275
|
+
const controlCount = form.forms.reduce((total, definition) => total + countOdbFormDefinitionControls(definition), 0);
|
|
276
|
+
const boundCount = form.forms.reduce((total, definition) => total + countOdbFormDefinitionBoundControls(definition), 0);
|
|
277
|
+
return `${form.name} [${form.href}] -- ${form.forms.length} form${form.forms.length === 1 ? "" : "s"}, ${controlCount} control${controlCount === 1 ? "" : "s"} (${boundCount} bound)`;
|
|
278
|
+
}
|
|
279
|
+
function formControlLines(control, depth) {
|
|
280
|
+
const parts = [control.tag];
|
|
281
|
+
if (control.name !== void 0) parts.push(control.name);
|
|
282
|
+
if (control.dataField !== void 0) parts.push(`-> ${control.dataField}`);
|
|
283
|
+
if (control.label !== void 0) parts.push(`label ${quoted(control.label)}`);
|
|
284
|
+
if (control.controlImplementation !== void 0) parts.push(`(${control.controlImplementation})`);
|
|
285
|
+
const nested = control.controls.flatMap((child) => formControlLines(child, depth + 1));
|
|
286
|
+
return [`${indent(depth)}${parts.join(" ")}`, ...nested];
|
|
287
|
+
}
|
|
288
|
+
function formDefinitionLines(definition, depth, kindLabel) {
|
|
289
|
+
const headerParts = [kindLabel];
|
|
290
|
+
if (definition.name !== void 0) headerParts.push(definition.name);
|
|
291
|
+
const dataSource = describeDataSource(definition.command, definition.commandType);
|
|
292
|
+
if (dataSource !== void 0) headerParts.push(`on ${dataSource}`);
|
|
293
|
+
const lines = [`${indent(depth)}${headerParts.join(" ")}`];
|
|
294
|
+
if (definition.datasource !== void 0) lines.push(`${indent(depth + 1)}datasource: ${definition.datasource}`);
|
|
295
|
+
if (definition.filter !== void 0) lines.push(`${indent(depth + 1)}filter: ${definition.filter}`);
|
|
296
|
+
if (definition.order !== void 0) lines.push(`${indent(depth + 1)}order: ${definition.order}`);
|
|
297
|
+
if (definition.controls.length === 0) lines.push(`${indent(depth + 1)}(no controls)`);
|
|
298
|
+
for (const control of definition.controls) lines.push(...formControlLines(control, depth + 1));
|
|
299
|
+
for (const subForm of definition.subForms) lines.push(...formDefinitionLines(subForm, depth + 1, "subform"));
|
|
300
|
+
return lines;
|
|
301
|
+
}
|
|
302
|
+
function formatOdbFormLines(form) {
|
|
303
|
+
if (form.forms.length === 0) return ["(this form document declares no form:form definitions)"];
|
|
304
|
+
return form.forms.flatMap((definition) => formDefinitionLines(definition, 0, "form"));
|
|
305
|
+
}
|
|
306
|
+
function odbFormSummary(form) {
|
|
307
|
+
return {
|
|
308
|
+
name: form.name,
|
|
309
|
+
href: form.href,
|
|
310
|
+
forms: form.forms
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function countReportBandElements(band) {
|
|
314
|
+
return band?.elements.length ?? 0;
|
|
315
|
+
}
|
|
316
|
+
function countReportGroupElements(group) {
|
|
317
|
+
return countReportBandElements(group.header) + countReportBandElements(group.footer) + group.groups.reduce((total, nested) => total + countReportGroupElements(nested), 0);
|
|
318
|
+
}
|
|
319
|
+
function countReportGroups(groups) {
|
|
320
|
+
return groups.reduce((total, group) => total + 1 + countReportGroups(group.groups), 0);
|
|
321
|
+
}
|
|
322
|
+
function describeOdbReport(report) {
|
|
323
|
+
const dataSource = describeDataSource(report.command, report.commandType);
|
|
324
|
+
const groupCount = countReportGroups(report.groups);
|
|
325
|
+
const elementCount = countReportBandElements(report.reportHeader) + countReportBandElements(report.pageHeader) + countReportBandElements(report.detail) + countReportBandElements(report.pageFooter) + countReportBandElements(report.reportFooter) + report.groups.reduce((total, group) => total + countReportGroupElements(group), 0);
|
|
326
|
+
const source = dataSource === void 0 ? "no data source" : `on ${dataSource}`;
|
|
327
|
+
return `${report.name} [${report.href}] -- ${source}, ${groupCount} group${groupCount === 1 ? "" : "s"}, ${elementCount} element${elementCount === 1 ? "" : "s"}`;
|
|
328
|
+
}
|
|
329
|
+
function reportElementLine(element, depth) {
|
|
330
|
+
const parts = [element.tag];
|
|
331
|
+
if (element.name !== void 0) parts.push(quoted(element.name));
|
|
332
|
+
if (element.formula !== void 0) parts.push(`= ${element.formula}`);
|
|
333
|
+
if (element.dataField !== void 0) parts.push(`-> ${element.dataField}`);
|
|
334
|
+
const head = `${indent(depth)}${parts.join(" ")}`;
|
|
335
|
+
return element.text === void 0 ? head : `${head}: ${quoted(element.text)}`;
|
|
336
|
+
}
|
|
337
|
+
function reportBandLines(band, depth) {
|
|
338
|
+
if (band === void 0) return [];
|
|
339
|
+
const header = band.name === void 0 ? band.kind : `${band.kind} ${quoted(band.name)}`;
|
|
340
|
+
const lines = [`${indent(depth)}${header}`];
|
|
341
|
+
if (band.elements.length === 0) lines.push(`${indent(depth + 1)}(no elements)`);
|
|
342
|
+
for (const element of band.elements) lines.push(reportElementLine(element, depth + 1));
|
|
343
|
+
return lines;
|
|
344
|
+
}
|
|
345
|
+
function reportFunctionLines(functions, depth) {
|
|
346
|
+
if (functions.length === 0) return [];
|
|
347
|
+
return [`${indent(depth)}functions`, ...functions.map((fn) => `${indent(depth + 1)}${fn.name} = ${fn.formula}`)];
|
|
348
|
+
}
|
|
349
|
+
function reportGroupLines(group, depth) {
|
|
350
|
+
const headerParts = ["group"];
|
|
351
|
+
if (group.groupExpression !== void 0) headerParts.push(group.groupExpression);
|
|
352
|
+
const attributes = [];
|
|
353
|
+
if (group.sortExpression !== void 0) attributes.push(`sort ${group.sortExpression} ${group.sortAscending === false ? "descending" : "ascending"}`);
|
|
354
|
+
if (group.startNewColumn === true) attributes.push("new column");
|
|
355
|
+
if (group.resetPageNumber === true) attributes.push("reset page number");
|
|
356
|
+
if (group.keepTogether !== void 0) attributes.push(`keep together ${group.keepTogether}`);
|
|
357
|
+
if (attributes.length > 0) headerParts.push(`(${attributes.join(", ")})`);
|
|
358
|
+
return [
|
|
359
|
+
`${indent(depth)}${headerParts.join(" ")}`,
|
|
360
|
+
...reportBandLines(group.header, depth + 1),
|
|
361
|
+
...group.groups.flatMap((nested) => reportGroupLines(nested, depth + 1)),
|
|
362
|
+
...reportFunctionLines(group.functions, depth + 1),
|
|
363
|
+
...reportBandLines(group.footer, depth + 1)
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
function formatOdbReportLines(report) {
|
|
367
|
+
const lines = [];
|
|
368
|
+
const dataSource = describeDataSource(report.command, report.commandType);
|
|
369
|
+
if (dataSource !== void 0) lines.push(`data source: ${dataSource}`);
|
|
370
|
+
if (report.caption !== void 0) lines.push(`caption: ${report.caption}`);
|
|
371
|
+
if (report.mimeType !== void 0) lines.push(`mime type: ${report.mimeType}`);
|
|
372
|
+
lines.push(...reportBandLines(report.reportHeader, 0));
|
|
373
|
+
lines.push(...reportBandLines(report.pageHeader, 0));
|
|
374
|
+
lines.push(...report.groups.flatMap((group) => reportGroupLines(group, 0)));
|
|
375
|
+
lines.push(...reportBandLines(report.detail, 0));
|
|
376
|
+
lines.push(...reportBandLines(report.pageFooter, 0));
|
|
377
|
+
lines.push(...reportBandLines(report.reportFooter, 0));
|
|
378
|
+
lines.push(...reportFunctionLines(report.functions, 0));
|
|
379
|
+
return lines;
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
export { odbFormSummary as a, writeOutput as c, inferFormatFromExtension as d, isDocumentFormat as f, formatOdbReportLines as i, loadProvidedFonts as l, describeOdbReport as n, readInput as o, formatOdbFormLines as r, resolveDefaultOutputPath as s, describeOdbForm as t, formatToExtension as u };
|