@evotecit/officeimo 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1222 -2
- package/bundles/officeimo-canopyx.js +11741 -0
- package/bundles/officeimo-canopyx.mjs +11639 -0
- package/bundles/officeimo-csv.js +1264 -0
- package/bundles/officeimo-csv.mjs +1239 -0
- package/bundles/officeimo-datatables.js +12018 -0
- package/bundles/officeimo-datatables.mjs +11915 -0
- package/bundles/officeimo-execution.js +1513 -0
- package/bundles/officeimo-execution.mjs +1489 -0
- package/bundles/officeimo-pdf.js +7009 -0
- package/bundles/officeimo-pdf.mjs +6946 -0
- package/bundles/officeimo-xlsx.js +5344 -0
- package/bundles/officeimo-xlsx.mjs +5290 -0
- package/bundles/officeimo.js +11468 -0
- package/bundles/officeimo.mjs +11369 -0
- package/dist/core/dates.d.ts +1 -0
- package/dist/core/dates.js +16 -0
- package/dist/core/errors.d.ts +12 -0
- package/dist/core/errors.js +31 -0
- package/dist/core/grouped-report.d.ts +87 -0
- package/dist/core/grouped-report.js +252 -0
- package/dist/core/index.d.ts +74 -0
- package/dist/core/index.js +37 -0
- package/dist/core/iteration.d.ts +7 -0
- package/dist/core/iteration.js +149 -0
- package/dist/core/limits.d.ts +7 -0
- package/dist/core/limits.js +56 -0
- package/dist/core/links.d.ts +5 -0
- package/dist/core/links.js +14 -0
- package/dist/core/presentation.d.ts +29 -0
- package/dist/core/presentation.js +59 -0
- package/dist/core/progress.d.ts +1 -0
- package/dist/core/progress.js +10 -0
- package/dist/core/sinks.d.ts +33 -0
- package/dist/core/sinks.js +102 -0
- package/dist/core/table.d.ts +8 -0
- package/dist/core/table.js +1 -0
- package/dist/core/value-text.d.ts +7 -0
- package/dist/core/value-text.js +13 -0
- package/dist/csv/index.d.ts +44 -0
- package/dist/csv/index.js +133 -0
- package/dist/csv/options.d.ts +1 -0
- package/dist/csv/options.js +8 -0
- package/dist/csv/structured-rows.d.ts +3 -0
- package/dist/csv/structured-rows.js +15 -0
- package/dist/execution/host.d.ts +5 -0
- package/dist/execution/host.js +164 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/protocol.d.ts +48 -0
- package/dist/execution/protocol.js +173 -0
- package/dist/execution/types.d.ts +42 -0
- package/dist/execution/types.js +1 -0
- package/dist/execution/worker.d.ts +3 -0
- package/dist/execution/worker.js +147 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +14 -0
- package/dist/integrations/canopyx/dates.d.ts +1 -0
- package/dist/integrations/canopyx/dates.js +34 -0
- package/dist/integrations/canopyx/index.d.ts +10 -0
- package/dist/integrations/canopyx/index.js +45 -0
- package/dist/integrations/canopyx/source.d.ts +3 -0
- package/dist/integrations/canopyx/source.js +122 -0
- package/dist/integrations/canopyx/types.d.ts +83 -0
- package/dist/integrations/canopyx/types.js +1 -0
- package/dist/integrations/datatables/api.d.ts +1 -0
- package/dist/integrations/datatables/api.js +27 -0
- package/dist/integrations/datatables/headings.d.ts +1 -0
- package/dist/integrations/datatables/headings.js +65 -0
- package/dist/integrations/datatables/index.d.ts +12 -0
- package/dist/integrations/datatables/index.js +167 -0
- package/dist/integrations/datatables/snapshot.d.ts +3 -0
- package/dist/integrations/datatables/snapshot.js +206 -0
- package/dist/integrations/datatables/types.d.ts +98 -0
- package/dist/integrations/datatables/types.js +1 -0
- package/dist/integrations/options.d.ts +13 -0
- package/dist/integrations/options.js +34 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +14 -0
- package/dist/internal/columns.d.ts +27 -0
- package/dist/internal/columns.js +1 -0
- package/dist/internal/crc32.d.ts +6 -0
- package/dist/internal/crc32.js +17 -0
- package/dist/internal/export-values.d.ts +3 -0
- package/dist/internal/export-values.js +14 -0
- package/dist/internal/rows.d.ts +6 -0
- package/dist/internal/rows.js +77 -0
- package/dist/internal/table-spans.d.ts +11 -0
- package/dist/internal/table-spans.js +58 -0
- package/dist/internal/totals.d.ts +15 -0
- package/dist/internal/totals.js +42 -0
- package/dist/opc/index.d.ts +67 -0
- package/dist/opc/index.js +233 -0
- package/dist/opc/properties.d.ts +15 -0
- package/dist/opc/properties.js +18 -0
- package/dist/opc/uri.d.ts +5 -0
- package/dist/opc/uri.js +41 -0
- package/dist/pdf/annotations.d.ts +1 -0
- package/dist/pdf/annotations.js +38 -0
- package/dist/pdf/binary.d.ts +6 -0
- package/dist/pdf/binary.js +24 -0
- package/dist/pdf/document-drawings.d.ts +15 -0
- package/dist/pdf/document-drawings.js +237 -0
- package/dist/pdf/document-grouped.d.ts +1 -0
- package/dist/pdf/document-grouped.js +244 -0
- package/dist/pdf/document-images.d.ts +19 -0
- package/dist/pdf/document-images.js +125 -0
- package/dist/pdf/document-types.d.ts +160 -0
- package/dist/pdf/document-types.js +1 -0
- package/dist/pdf/document-vectors.d.ts +11 -0
- package/dist/pdf/document-vectors.js +77 -0
- package/dist/pdf/document.d.ts +9 -0
- package/dist/pdf/document.js +270 -0
- package/dist/pdf/drawing-types.d.ts +53 -0
- package/dist/pdf/drawing-types.js +1 -0
- package/dist/pdf/font-resources.d.ts +43 -0
- package/dist/pdf/font-resources.js +202 -0
- package/dist/pdf/font-support.d.ts +1 -0
- package/dist/pdf/font-support.js +60 -0
- package/dist/pdf/font.d.ts +17 -0
- package/dist/pdf/font.js +56 -0
- package/dist/pdf/grouped-table.d.ts +6 -0
- package/dist/pdf/grouped-table.js +40 -0
- package/dist/pdf/grouped-types.d.ts +34 -0
- package/dist/pdf/grouped-types.js +1 -0
- package/dist/pdf/grouped.d.ts +10 -0
- package/dist/pdf/grouped.js +37 -0
- package/dist/pdf/index.d.ts +22 -0
- package/dist/pdf/index.js +8 -0
- package/dist/pdf/inline-text.d.ts +30 -0
- package/dist/pdf/inline-text.js +183 -0
- package/dist/pdf/inline-types.d.ts +15 -0
- package/dist/pdf/inline-types.js +1 -0
- package/dist/pdf/list-layout.d.ts +6 -0
- package/dist/pdf/list-layout.js +49 -0
- package/dist/pdf/objects.d.ts +2 -0
- package/dist/pdf/objects.js +320 -0
- package/dist/pdf/outlines.d.ts +1 -0
- package/dist/pdf/outlines.js +55 -0
- package/dist/pdf/page-context.d.ts +1 -0
- package/dist/pdf/page-context.js +12 -0
- package/dist/pdf/pages.d.ts +1 -0
- package/dist/pdf/pages.js +678 -0
- package/dist/pdf/paragraph-layout.d.ts +21 -0
- package/dist/pdf/paragraph-layout.js +71 -0
- package/dist/pdf/paragraph-styles.d.ts +1 -0
- package/dist/pdf/paragraph-styles.js +66 -0
- package/dist/pdf/png.d.ts +9 -0
- package/dist/pdf/png.js +259 -0
- package/dist/pdf/preflight.d.ts +7 -0
- package/dist/pdf/preflight.js +32 -0
- package/dist/pdf/presentation-settings.d.ts +5 -0
- package/dist/pdf/presentation-settings.js +28 -0
- package/dist/pdf/providers/harfbuzz.d.ts +60 -0
- package/dist/pdf/providers/harfbuzz.js +112 -0
- package/dist/pdf/providers/unicode13-profile.d.ts +2 -0
- package/dist/pdf/providers/unicode13-profile.js +115 -0
- package/dist/pdf/section-types.d.ts +15 -0
- package/dist/pdf/section-types.js +40 -0
- package/dist/pdf/session.d.ts +25 -0
- package/dist/pdf/session.js +55 -0
- package/dist/pdf/settings.d.ts +17 -0
- package/dist/pdf/settings.js +196 -0
- package/dist/pdf/shaped-text.d.ts +5 -0
- package/dist/pdf/shaped-text.js +205 -0
- package/dist/pdf/standard-widths.d.ts +1 -0
- package/dist/pdf/standard-widths.js +317 -0
- package/dist/pdf/structure-parent-tree.d.ts +1 -0
- package/dist/pdf/structure-parent-tree.js +57 -0
- package/dist/pdf/structure.d.ts +6 -0
- package/dist/pdf/structure.js +302 -0
- package/dist/pdf/table-band-flow.d.ts +34 -0
- package/dist/pdf/table-band-flow.js +129 -0
- package/dist/pdf/table-band-plan.d.ts +10 -0
- package/dist/pdf/table-band-plan.js +83 -0
- package/dist/pdf/table-layout.d.ts +75 -0
- package/dist/pdf/table-layout.js +217 -0
- package/dist/pdf/table-structure.d.ts +1 -0
- package/dist/pdf/table-structure.js +108 -0
- package/dist/pdf/text-shaping-types.d.ts +39 -0
- package/dist/pdf/text-shaping-types.js +1 -0
- package/dist/pdf/text.d.ts +13 -0
- package/dist/pdf/text.js +101 -0
- package/dist/pdf/truetype-subset.d.ts +5 -0
- package/dist/pdf/truetype-subset.js +217 -0
- package/dist/pdf/truetype.d.ts +1 -0
- package/dist/pdf/truetype.js +235 -0
- package/dist/pdf/types.d.ts +171 -0
- package/dist/pdf/types.js +1 -0
- package/dist/pdf/write.d.ts +6 -0
- package/dist/pdf/write.js +57 -0
- package/dist/pdf/xref.d.ts +1 -0
- package/dist/pdf/xref.js +30 -0
- package/dist/xlsx/attachments.d.ts +30 -0
- package/dist/xlsx/attachments.js +67 -0
- package/dist/xlsx/chart-bindings.d.ts +1 -0
- package/dist/xlsx/chart-bindings.js +122 -0
- package/dist/xlsx/chart-types.d.ts +73 -0
- package/dist/xlsx/chart-types.js +1 -0
- package/dist/xlsx/chart-xml.d.ts +2 -0
- package/dist/xlsx/chart-xml.js +103 -0
- package/dist/xlsx/charts.d.ts +1 -0
- package/dist/xlsx/charts.js +159 -0
- package/dist/xlsx/conditional-formatting.d.ts +1 -0
- package/dist/xlsx/conditional-formatting.js +158 -0
- package/dist/xlsx/conditional-types.d.ts +64 -0
- package/dist/xlsx/conditional-types.js +1 -0
- package/dist/xlsx/data-row-ranges.d.ts +5 -0
- package/dist/xlsx/data-row-ranges.js +39 -0
- package/dist/xlsx/differential-styles.d.ts +1 -0
- package/dist/xlsx/differential-styles.js +102 -0
- package/dist/xlsx/formula.d.ts +8 -0
- package/dist/xlsx/formula.js +104 -0
- package/dist/xlsx/grouped-layout.d.ts +61 -0
- package/dist/xlsx/grouped-layout.js +79 -0
- package/dist/xlsx/grouped.d.ts +16 -0
- package/dist/xlsx/grouped.js +161 -0
- package/dist/xlsx/index.d.ts +24 -0
- package/dist/xlsx/index.js +10 -0
- package/dist/xlsx/layout.d.ts +1 -0
- package/dist/xlsx/layout.js +186 -0
- package/dist/xlsx/options.d.ts +1 -0
- package/dist/xlsx/options.js +16 -0
- package/dist/xlsx/portable.d.ts +27 -0
- package/dist/xlsx/portable.js +44 -0
- package/dist/xlsx/preservation.d.ts +1 -0
- package/dist/xlsx/preservation.js +60 -0
- package/dist/xlsx/ranges.d.ts +1 -0
- package/dist/xlsx/ranges.js +24 -0
- package/dist/xlsx/regions.d.ts +1 -0
- package/dist/xlsx/regions.js +97 -0
- package/dist/xlsx/structured-rows.d.ts +11 -0
- package/dist/xlsx/structured-rows.js +28 -0
- package/dist/xlsx/style-xml.d.ts +1 -0
- package/dist/xlsx/style-xml.js +6 -0
- package/dist/xlsx/styles.d.ts +70 -0
- package/dist/xlsx/styles.js +203 -0
- package/dist/xlsx/table.d.ts +12 -0
- package/dist/xlsx/table.js +35 -0
- package/dist/xlsx/types.d.ts +180 -0
- package/dist/xlsx/types.js +1 -0
- package/dist/xlsx/validation-types.d.ts +18 -0
- package/dist/xlsx/validation-types.js +1 -0
- package/dist/xlsx/validation.d.ts +1 -0
- package/dist/xlsx/validation.js +92 -0
- package/dist/xlsx/values.d.ts +13 -0
- package/dist/xlsx/values.js +87 -0
- package/dist/xlsx/workbook.d.ts +50 -0
- package/dist/xlsx/workbook.js +452 -0
- package/dist/xlsx/worksheet.d.ts +71 -0
- package/dist/xlsx/worksheet.js +700 -0
- package/dist/xlsx/write.d.ts +15 -0
- package/dist/xlsx/write.js +47 -0
- package/dist/xml/index.d.ts +24 -0
- package/dist/xml/index.js +74 -0
- package/dist/zip/entry.d.ts +39 -0
- package/dist/zip/entry.js +122 -0
- package/dist/zip/index.d.ts +44 -0
- package/dist/zip/index.js +248 -0
- package/package.json +104 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @internal Bounded big-endian reader used for caller-provided TrueType programs. */
|
|
2
|
+
export class FontReader {
|
|
3
|
+
bytes;
|
|
4
|
+
view;
|
|
5
|
+
constructor(bytes) {
|
|
6
|
+
this.bytes = bytes;
|
|
7
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
8
|
+
}
|
|
9
|
+
range(offset, length) {
|
|
10
|
+
if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 0 || offset + length > this.bytes.length)
|
|
11
|
+
throw new TypeError("Truncated or invalid TrueType table.");
|
|
12
|
+
}
|
|
13
|
+
u16(offset) { this.range(offset, 2); return this.view.getUint16(offset); }
|
|
14
|
+
i16(offset) { this.range(offset, 2); return this.view.getInt16(offset); }
|
|
15
|
+
u32(offset) { this.range(offset, 4); return this.view.getUint32(offset); }
|
|
16
|
+
tag(offset) { this.range(offset, 4); return String.fromCharCode(...this.bytes.subarray(offset, offset + 4)); }
|
|
17
|
+
}
|
|
18
|
+
export function checksum(bytes) {
|
|
19
|
+
let sum = 0;
|
|
20
|
+
for (let i = 0; i < bytes.length; i += 4)
|
|
21
|
+
sum = (sum + (((bytes[i] ?? 0) * 0x1000000) + ((bytes[i + 1] ?? 0) << 16) + ((bytes[i + 2] ?? 0) << 8) + (bytes[i + 3] ?? 0))) >>> 0;
|
|
22
|
+
return sum;
|
|
23
|
+
}
|
|
24
|
+
export const align4 = (value) => Math.ceil(value / 4) * 4;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PdfDrawing } from "./drawing-types.js";
|
|
2
|
+
import type { PdfFontResources } from "./font-resources.js";
|
|
3
|
+
import type { PdfSettings } from "./settings.js";
|
|
4
|
+
export interface PdfDrawingUsage {
|
|
5
|
+
readonly commands: number;
|
|
6
|
+
readonly elements: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PreparedPdfDrawing extends PdfDrawingUsage {
|
|
9
|
+
readonly width: number;
|
|
10
|
+
readonly height: number;
|
|
11
|
+
readonly content: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function checkDrawingBlock(value: unknown): void;
|
|
14
|
+
/** Preflight and paint owned records. The existing font owner retains glyph maps and subsets. */
|
|
15
|
+
export declare function prepareDrawing(drawing: PdfDrawing, settings: PdfSettings, fonts: PdfFontResources, used: PdfDrawingUsage): Promise<PreparedPdfDrawing>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { NotSupportedError, OfficeIMOError } from "../core/errors.js";
|
|
2
|
+
import { checkAbort, pause, taskYieldDue } from "../core/iteration.js";
|
|
3
|
+
import { color, positive } from "./settings.js";
|
|
4
|
+
import { pdfNumber as n } from "./objects.js";
|
|
5
|
+
/** Portable drawings are an exact schema: unsupported data must never be silently discarded. */
|
|
6
|
+
function record(value, keys, name) {
|
|
7
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Reflect.ownKeys(value).some(key => typeof key !== "string" || !keys.includes(key)))
|
|
8
|
+
throw new TypeError("Unsupported " + name + " properties.");
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
export function checkDrawingBlock(value) {
|
|
12
|
+
record(value, ["kind", "drawing", "alignment", "alternativeText", "decorative", "caption"], "drawing block");
|
|
13
|
+
}
|
|
14
|
+
function coordinate(value) {
|
|
15
|
+
if (typeof value !== "number" || !Number.isFinite(value) || Math.abs(value) > 1000000)
|
|
16
|
+
throw new RangeError("Drawing coordinates must be finite and within -1,000,000 through 1,000,000 points.");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function clipRectangle(value) {
|
|
20
|
+
const clip = record(value, ["x", "y", "width", "height"], "drawing clip");
|
|
21
|
+
return { x: coordinate(clip.x), y: coordinate(clip.y), width: positive(clip.width, "Drawing clip width", 1000000), height: positive(clip.height, "Drawing clip height", 1000000) };
|
|
22
|
+
}
|
|
23
|
+
async function cooperate(settings) {
|
|
24
|
+
if (taskYieldDue())
|
|
25
|
+
await pause();
|
|
26
|
+
checkAbort(settings.options.signal);
|
|
27
|
+
}
|
|
28
|
+
/** Take ownership of one bounded schema before any cooperative or font work can run caller code. */
|
|
29
|
+
function captureDrawing(drawing, settings, used) {
|
|
30
|
+
checkAbort(settings.options.signal);
|
|
31
|
+
const root = record(drawing, ["version", "width", "height", "elements"], "drawing");
|
|
32
|
+
if (root.version !== 1)
|
|
33
|
+
throw new NotSupportedError("Only portable drawing version 1 is supported.");
|
|
34
|
+
const width = positive(root.width, "Drawing width"), height = positive(root.height, "Drawing height");
|
|
35
|
+
let commands = used.commands, elements = used.elements;
|
|
36
|
+
const ancestors = new Set();
|
|
37
|
+
function path(value) {
|
|
38
|
+
record(value, ["kind", "commands", "fill", "stroke", "strokeWidth", "fillRule", "lineCap", "lineJoin"], "drawing path");
|
|
39
|
+
const source = value.commands;
|
|
40
|
+
if (!Array.isArray(source))
|
|
41
|
+
throw new TypeError("Drawing path commands must be an array.");
|
|
42
|
+
if (commands + source.length > settings.limits.maxVectorCommands)
|
|
43
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxVectorCommands exceeded.");
|
|
44
|
+
checkAbort(settings.options.signal);
|
|
45
|
+
const snapshot = source.slice(), copied = [];
|
|
46
|
+
let started = false;
|
|
47
|
+
commands += snapshot.length;
|
|
48
|
+
const fillValue = value.fill, strokeValue = value.stroke;
|
|
49
|
+
const fill = fillValue === undefined ? undefined : color(fillValue), stroke = strokeValue === undefined ? undefined : color(strokeValue);
|
|
50
|
+
if (fill === undefined && stroke === undefined)
|
|
51
|
+
throw new TypeError("A drawing path requires fill or stroke.");
|
|
52
|
+
const strokeWidth = positive(value.strokeWidth ?? 1, "Drawing stroke width");
|
|
53
|
+
const fillRule = value.fillRule, lineCap = value.lineCap, lineJoin = value.lineJoin;
|
|
54
|
+
if (fillRule !== undefined && !["nonzero", "evenodd"].includes(fillRule))
|
|
55
|
+
throw new TypeError("Invalid drawing fillRule.");
|
|
56
|
+
if (lineCap !== undefined && !["butt", "round", "square"].includes(lineCap))
|
|
57
|
+
throw new TypeError("Invalid drawing lineCap.");
|
|
58
|
+
if (lineJoin !== undefined && !["miter", "round", "bevel"].includes(lineJoin))
|
|
59
|
+
throw new TypeError("Invalid drawing lineJoin.");
|
|
60
|
+
for (let i = 0; i < snapshot.length; i++) {
|
|
61
|
+
const c = snapshot[i];
|
|
62
|
+
if (!c || typeof c !== "object")
|
|
63
|
+
throw new TypeError("Invalid drawing path command.");
|
|
64
|
+
const op = c.op;
|
|
65
|
+
if (op === "move" || op === "line") {
|
|
66
|
+
record(c, ["op", "x", "y"], "drawing path command");
|
|
67
|
+
if (op === "line" && !started)
|
|
68
|
+
throw new TypeError("A drawing subpath must begin with move.");
|
|
69
|
+
copied.push({ op, x: coordinate(c.x), y: coordinate(c.y) });
|
|
70
|
+
started = true;
|
|
71
|
+
}
|
|
72
|
+
else if (op === "cubic") {
|
|
73
|
+
record(c, ["op", "x1", "y1", "x2", "y2", "x", "y"], "drawing path command");
|
|
74
|
+
if (!started)
|
|
75
|
+
throw new TypeError("A drawing subpath must begin with move.");
|
|
76
|
+
copied.push({ op: "cubic", x1: coordinate(c.x1), y1: coordinate(c.y1), x2: coordinate(c.x2), y2: coordinate(c.y2), x: coordinate(c.x), y: coordinate(c.y) });
|
|
77
|
+
}
|
|
78
|
+
else if (op === "close") {
|
|
79
|
+
record(c, ["op"], "drawing path command");
|
|
80
|
+
if (!started)
|
|
81
|
+
throw new TypeError("Cannot close an empty drawing path.");
|
|
82
|
+
copied.push({ op: "close" });
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
throw new TypeError("Unsupported drawing path command.");
|
|
86
|
+
if ((i & 1023) === 1023)
|
|
87
|
+
checkAbort(settings.options.signal);
|
|
88
|
+
}
|
|
89
|
+
if (!started)
|
|
90
|
+
throw new TypeError("A drawing path needs at least one command.");
|
|
91
|
+
return { kind: "path", commands: copied, style: (fill === undefined ? "" : fill + " rg\n") + (stroke === undefined ? "" : stroke + " RG\n" + n(strokeWidth) + " w\n") +
|
|
92
|
+
String(["butt", "round", "square"].indexOf(lineCap ?? "butt")) + " J\n" + String(["miter", "round", "bevel"].indexOf(lineJoin ?? "miter")) + " j\n10 M\n",
|
|
93
|
+
paint: (fill !== undefined && stroke !== undefined ? "B" : fill !== undefined ? "f" : "S") + (fill !== undefined && fillRule === "evenodd" ? "*" : "") + "\n" };
|
|
94
|
+
}
|
|
95
|
+
function text(value) {
|
|
96
|
+
record(value, ["kind", "text", "x", "y", "font", "fontSize", "color"], "drawing text");
|
|
97
|
+
const snapshot = value.text, slot = value.font;
|
|
98
|
+
if (typeof snapshot !== "string")
|
|
99
|
+
throw new TypeError("Drawing text must be a string.");
|
|
100
|
+
if (snapshot.length > settings.limits.maxCellCharacters)
|
|
101
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
|
|
102
|
+
if (/[\r\n\u2028\u2029]/.test(snapshot))
|
|
103
|
+
throw new NotSupportedError("Drawing text must be a single baseline without line breaks.");
|
|
104
|
+
if (!["regular", "bold", "italic", "boldItalic"].includes(slot))
|
|
105
|
+
throw new TypeError("Invalid drawing font slot.");
|
|
106
|
+
const x = coordinate(value.x), y = coordinate(value.y), size = positive(value.fontSize, "Drawing font size"), foreground = color(value.color);
|
|
107
|
+
settings.budget.cell(snapshot);
|
|
108
|
+
return { kind: "text", text: snapshot, x, y, size, color: foreground, font: slot };
|
|
109
|
+
}
|
|
110
|
+
function children(input, depth) {
|
|
111
|
+
if (!Array.isArray(input))
|
|
112
|
+
throw new TypeError("Drawing elements must be an array.");
|
|
113
|
+
if (depth > 32 && input.length)
|
|
114
|
+
throw new RangeError("Drawing groups support at most 32 element levels.");
|
|
115
|
+
if (elements + input.length > settings.limits.maxDrawingElements)
|
|
116
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxDrawingElements exceeded.");
|
|
117
|
+
checkAbort(settings.options.signal);
|
|
118
|
+
const snapshot = input.slice(), output = [];
|
|
119
|
+
for (let i = 0; i < snapshot.length; i++) {
|
|
120
|
+
if (++elements > settings.limits.maxDrawingElements)
|
|
121
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxDrawingElements exceeded.");
|
|
122
|
+
const value = snapshot[i];
|
|
123
|
+
if (!value || typeof value !== "object")
|
|
124
|
+
throw new TypeError("Invalid drawing element.");
|
|
125
|
+
if (ancestors.has(value))
|
|
126
|
+
throw new TypeError("Drawing groups cannot contain cycles.");
|
|
127
|
+
const kind = value.kind;
|
|
128
|
+
if (kind === "path")
|
|
129
|
+
output.push(path(value));
|
|
130
|
+
else if (kind === "text")
|
|
131
|
+
output.push(text(value));
|
|
132
|
+
else if (kind === "group") {
|
|
133
|
+
record(value, ["kind", "clip", "elements"], "drawing group");
|
|
134
|
+
const clipValue = value.clip, clip = clipValue === undefined ? undefined : clipRectangle(clipValue);
|
|
135
|
+
ancestors.add(value);
|
|
136
|
+
output.push({ kind: "group", ...(clip ? { clip } : {}), children: children(value.elements, depth + 1) });
|
|
137
|
+
ancestors.delete(value);
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
throw new TypeError("Unsupported drawing element kind.");
|
|
141
|
+
if ((i & 255) === 255)
|
|
142
|
+
checkAbort(settings.options.signal);
|
|
143
|
+
}
|
|
144
|
+
return output;
|
|
145
|
+
}
|
|
146
|
+
const plan = children(root.elements, 1);
|
|
147
|
+
checkAbort(settings.options.signal);
|
|
148
|
+
return { width, height, plan, commands: commands - used.commands, elements: elements - used.elements };
|
|
149
|
+
}
|
|
150
|
+
/** Preflight and paint owned records. The existing font owner retains glyph maps and subsets. */
|
|
151
|
+
export async function prepareDrawing(drawing, settings, fonts, used) {
|
|
152
|
+
// A drawing's bounded capture is synchronous; yielding here would leave later caller records borrowed.
|
|
153
|
+
const captured = captureDrawing(drawing, settings, used), drawingFonts = new Map();
|
|
154
|
+
function fontFor(slot) {
|
|
155
|
+
const existing = drawingFonts.get(slot);
|
|
156
|
+
if (existing)
|
|
157
|
+
return existing;
|
|
158
|
+
const font = fonts.select(slot === "bold" || slot === "boldItalic", slot === "italic" || slot === "boldItalic");
|
|
159
|
+
if (!font.program || font.syntheticBold || font.syntheticItalic)
|
|
160
|
+
throw new NotSupportedError("Drawing text without an exact embedded font face at fonts." + slot);
|
|
161
|
+
drawingFonts.set(slot, font);
|
|
162
|
+
return font;
|
|
163
|
+
}
|
|
164
|
+
// The work budget belongs to the drawing, including short runs in separate sibling groups.
|
|
165
|
+
let preflightCharacters = 0, preflightElements = 0;
|
|
166
|
+
async function preflight(nodes) {
|
|
167
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
168
|
+
const node = nodes[i];
|
|
169
|
+
if (node.kind === "group")
|
|
170
|
+
await preflight(node.children);
|
|
171
|
+
else if (node.kind === "text") {
|
|
172
|
+
const font = fontFor(node.font);
|
|
173
|
+
for (const character of node.text) {
|
|
174
|
+
font.width(character.codePointAt(0));
|
|
175
|
+
if ((++preflightCharacters & 1023) === 0)
|
|
176
|
+
await cooperate(settings);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if ((++preflightElements & 255) === 0)
|
|
180
|
+
await cooperate(settings);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
await preflight(captured.plan);
|
|
184
|
+
const fragments = [];
|
|
185
|
+
let bytes = 0;
|
|
186
|
+
function add(fragment) {
|
|
187
|
+
bytes += fragment.length;
|
|
188
|
+
if (bytes > settings.limits.maxPageBytes - 256)
|
|
189
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxPageBytes exceeded by drawing content.");
|
|
190
|
+
fragments.push(fragment);
|
|
191
|
+
}
|
|
192
|
+
let paintedCharacters = 0, paintedCommands = 0, paintedElements = 0;
|
|
193
|
+
async function paint(nodes) {
|
|
194
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
195
|
+
const node = nodes[i];
|
|
196
|
+
add("q\n");
|
|
197
|
+
if (node.kind === "group") {
|
|
198
|
+
if (node.clip)
|
|
199
|
+
add([node.clip.x, node.clip.y, node.clip.width, node.clip.height].map(n).join(" ") + " re W n\n");
|
|
200
|
+
await paint(node.children);
|
|
201
|
+
}
|
|
202
|
+
else if (node.kind === "path") {
|
|
203
|
+
add(node.style);
|
|
204
|
+
for (let j = 0; j < node.commands.length; j++) {
|
|
205
|
+
const c = node.commands[j];
|
|
206
|
+
add(c.op === "move" || c.op === "line" ? n(c.x) + " " + n(c.y) + (c.op === "move" ? " m\n" : " l\n") :
|
|
207
|
+
c.op === "cubic" ? [c.x1, c.y1, c.x2, c.y2, c.x, c.y].map(n).join(" ") + " c\n" : "h\n");
|
|
208
|
+
if ((++paintedCommands & 1023) === 0)
|
|
209
|
+
await cooperate(settings);
|
|
210
|
+
}
|
|
211
|
+
add(node.paint);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const font = fontFor(node.font);
|
|
215
|
+
add(node.color + " rg\nBT /" + font.name + " " + n(node.size) + " Tf 0 Tr 1 0 0 -1 " + n(node.x) + " " + n(node.y) + " Tm <");
|
|
216
|
+
let chunk = "";
|
|
217
|
+
for (const character of node.text) {
|
|
218
|
+
chunk += character;
|
|
219
|
+
if ((++paintedCharacters & 1023) === 0) {
|
|
220
|
+
add(font.encode(chunk).slice(1, -1));
|
|
221
|
+
chunk = "";
|
|
222
|
+
await cooperate(settings);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (chunk)
|
|
226
|
+
add(font.encode(chunk).slice(1, -1));
|
|
227
|
+
add("> Tj ET\n");
|
|
228
|
+
}
|
|
229
|
+
add("Q\n");
|
|
230
|
+
if ((++paintedElements & 255) === 0)
|
|
231
|
+
await cooperate(settings);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
await paint(captured.plan);
|
|
235
|
+
checkAbort(settings.options.signal);
|
|
236
|
+
return { width: captured.width, height: captured.height, content: fragments.join(""), commands: captured.commands, elements: captured.elements };
|
|
237
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { assertGroupedReportSource, groupedReportOperation } from "../core/grouped-report.js";
|
|
2
|
+
import { consumeRows } from "../core/iteration.js";
|
|
3
|
+
import { ExportCell } from "../core/presentation.js";
|
|
4
|
+
import { captureGroupedPdfTableOptions } from "./grouped-table.js";
|
|
5
|
+
import { settings } from "./settings.js";
|
|
6
|
+
import { PdfTableLayout } from "./table-layout.js";
|
|
7
|
+
import { captureCaption, captureParagraph, prepareParagraph } from "./paragraph-layout.js";
|
|
8
|
+
import { synchronousText } from "./text.js";
|
|
9
|
+
/** @internal Render one analytical source in the existing document session. Retain one detail row and
|
|
10
|
+
* at most four closing subtotals. All captions, rows, pages, bytes and fonts use the document owners. */
|
|
11
|
+
export async function renderGroupedPdfTable(block, context) {
|
|
12
|
+
const { report } = block, { pages, fonts, prepared, controller } = context;
|
|
13
|
+
assertGroupedReportSource(report);
|
|
14
|
+
const semantic = prepared.options.tagged !== undefined;
|
|
15
|
+
const captured = captureGroupedPdfTableOptions(block.options);
|
|
16
|
+
const { labelColumn, subtotalLabel, grandTotalLabel, includeGrandTotal = true, continuationLabel, groupHeadingLevel = 2, ...input } = captured;
|
|
17
|
+
const columns = Object.freeze([Object.freeze({ ...labelColumn }), ...report.columns]);
|
|
18
|
+
let rowIndex = -1;
|
|
19
|
+
const sourceContext = (value) => ({ rowIndex,
|
|
20
|
+
columnIndex: value.columnIndex - 1, column: report.columns[value.columnIndex - 1] });
|
|
21
|
+
const table = settings({ ...pages.settings.options, ...input, columns, includeHeader: input.includeHeader ?? true,
|
|
22
|
+
...(input.formatValue === undefined ? {} : { formatValue: (value, position) => input.formatValue(value, sourceContext(position)) }),
|
|
23
|
+
...(input.formatRuns === undefined ? {} : { formatRuns: (value, position) => input.formatRuns(value, sourceContext(position)) }) });
|
|
24
|
+
const sharedTable = { ...table, budget: prepared.budget }, layout = new PdfTableLayout(sharedTable, fonts);
|
|
25
|
+
context.acceptColumns(columns.length);
|
|
26
|
+
const operation = groupedReportOperation(report, controller.signal), abort = () => controller.abort(operation.signal?.reason);
|
|
27
|
+
operation.signal?.addEventListener("abort", abort, { once: true });
|
|
28
|
+
if (operation.signal?.aborted)
|
|
29
|
+
abort();
|
|
30
|
+
try {
|
|
31
|
+
const headings = await layout.headers(), headingHeight = await layout.blockHeight(headings);
|
|
32
|
+
let path = [], started = false, firstFragment = false, firstBundleOversized = false, semanticDepth = 0;
|
|
33
|
+
const continuationLabels = new WeakMap();
|
|
34
|
+
let pending;
|
|
35
|
+
const closing = [];
|
|
36
|
+
const aggregatePositions = report.columns.flatMap((column, index) => Object.hasOwn(report.totals, column.key) ? [index] : []);
|
|
37
|
+
const summaryValues = (label, values, positions) => Object.freeze([
|
|
38
|
+
new ExportCell(label, { text: label, presentation: table.options.footerPresentation }),
|
|
39
|
+
...(positions ? positions.map(index => values[index]) : values).map(value => new ExportCell(value, { presentation: table.options.footerPresentation }))
|
|
40
|
+
]);
|
|
41
|
+
// Independent summaries have no detail values in non-aggregate columns. Project their
|
|
42
|
+
// declared operations, including zero/null results, rather than emitting label-only bands.
|
|
43
|
+
// Keep callback positions in the original source model after this physical projection.
|
|
44
|
+
const summaryLayouts = new Map();
|
|
45
|
+
const summaryLayout = (grand) => {
|
|
46
|
+
const existing = summaryLayouts.get(grand);
|
|
47
|
+
if (existing)
|
|
48
|
+
return existing;
|
|
49
|
+
const positions = [0, ...aggregatePositions.map(index => index + 1)];
|
|
50
|
+
const projected = positions.map(position => {
|
|
51
|
+
const column = columns[position];
|
|
52
|
+
if (!grand)
|
|
53
|
+
return column;
|
|
54
|
+
const { groups: _groups, ...leaf } = column;
|
|
55
|
+
return leaf;
|
|
56
|
+
});
|
|
57
|
+
const originalPosition = (position) => {
|
|
58
|
+
const columnIndex = positions[position.columnIndex];
|
|
59
|
+
return { ...position, columnIndex, column: columns[columnIndex] };
|
|
60
|
+
};
|
|
61
|
+
const repeatColumns = positions.flatMap((position, index) => position === 0 || table.repeatedColumns.includes(position) ? [index] : []);
|
|
62
|
+
const wideTable = table.options.wideTable;
|
|
63
|
+
const projectedSettings = { ...sharedTable,
|
|
64
|
+
repeatedColumns: Object.freeze(repeatColumns), options: { ...table.options, columns: projected,
|
|
65
|
+
...(table.options.columnWidths === undefined ? {} : { columnWidths: positions.map(position => table.options.columnWidths[position]) }),
|
|
66
|
+
...(typeof wideTable !== "object" ? {} : { wideTable: { ...wideTable, repeatColumns } }),
|
|
67
|
+
...(table.options.formatValue === undefined ? {} : { formatValue: (value, position) => table.options.formatValue(value, originalPosition(position)) }),
|
|
68
|
+
...(table.options.formatRuns === undefined ? {} : { formatRuns: (value, position) => table.options.formatRuns(value, originalPosition(position)) })
|
|
69
|
+
} };
|
|
70
|
+
const projectedLayout = new PdfTableLayout(projectedSettings, fonts);
|
|
71
|
+
summaryLayouts.set(grand, projectedLayout);
|
|
72
|
+
return projectedLayout;
|
|
73
|
+
};
|
|
74
|
+
const prepareGroupContext = async () => {
|
|
75
|
+
const caption = await prepareParagraph(captureCaption({ text: path.map(group => group.label).join("\n"),
|
|
76
|
+
presentation: { bold: true }, spaceAfter: 4 }, pages.settings, fonts), pages.settings, fonts);
|
|
77
|
+
const continuation = await prepareParagraph(captureCaption({ text: path.map(group => {
|
|
78
|
+
if (continuationLabel === undefined)
|
|
79
|
+
return group.label;
|
|
80
|
+
const existing = semantic ? continuationLabels.get(group) : undefined;
|
|
81
|
+
if (existing !== undefined)
|
|
82
|
+
return existing;
|
|
83
|
+
const label = synchronousText(continuationLabel(group), "continuationLabel");
|
|
84
|
+
if (semantic)
|
|
85
|
+
continuationLabels.set(group, label);
|
|
86
|
+
return label;
|
|
87
|
+
}).join("\n"), presentation: { bold: true }, spaceAfter: 4 }, pages.settings, fonts), pages.settings, fonts);
|
|
88
|
+
return { caption, continuation };
|
|
89
|
+
};
|
|
90
|
+
const flushLastDetail = async () => {
|
|
91
|
+
if (pending) {
|
|
92
|
+
if (!started)
|
|
93
|
+
await startLeaf(pending);
|
|
94
|
+
if (closing.length && !firstBundleOversized)
|
|
95
|
+
await pages.keptRows([pending, ...closing], firstFragment);
|
|
96
|
+
else if (closing.length) {
|
|
97
|
+
await pages.row(pending, firstFragment);
|
|
98
|
+
for (const row of closing)
|
|
99
|
+
await pages.row(row);
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
await pages.row(pending, firstFragment);
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
for (const row of closing)
|
|
106
|
+
await pages.row(row);
|
|
107
|
+
pending = undefined;
|
|
108
|
+
closing.length = 0;
|
|
109
|
+
firstFragment = false;
|
|
110
|
+
firstBundleOversized = false;
|
|
111
|
+
};
|
|
112
|
+
const finishLeaf = async () => {
|
|
113
|
+
if (!started && !pending)
|
|
114
|
+
return;
|
|
115
|
+
await flushLastDetail();
|
|
116
|
+
await pages.endTable();
|
|
117
|
+
started = false;
|
|
118
|
+
};
|
|
119
|
+
const startLeaf = async (row) => {
|
|
120
|
+
const { caption, continuation } = await prepareGroupContext();
|
|
121
|
+
const bundleHeight = row.height + closing.reduce((height, summary) => height + summary.height, 0);
|
|
122
|
+
const available = table.page.height - table.margins.top - table.margins.bottom - headingHeight - Math.max(caption?.height ?? 0, continuation.height);
|
|
123
|
+
firstBundleOversized = closing.length > 0 && bundleHeight > available + .001;
|
|
124
|
+
const minimum = closing.length > 0 && !firstBundleOversized ? bundleHeight : layout.minimumRowHeight(row);
|
|
125
|
+
// Defer new group headings until their first real row is known. The complete, at-most-four
|
|
126
|
+
// heading chain stays with a meaningful first table fragment without retaining a group body.
|
|
127
|
+
const groupHeadings = [];
|
|
128
|
+
if (semantic)
|
|
129
|
+
for (const group of path.slice(semanticDepth))
|
|
130
|
+
groupHeadings.push(await prepareParagraph(captureParagraph({
|
|
131
|
+
kind: "paragraph", text: group.label.trim() ? group.label : "", headingLevel: (groupHeadingLevel + group.level),
|
|
132
|
+
presentation: { bold: true }, keepTogether: true, keepWithNext: true, spaceAfter: 4,
|
|
133
|
+
...(group.label.trim() ? { bookmark: { title: group.label, level: (groupHeadingLevel + group.level) } } : {})
|
|
134
|
+
}, pages.settings, fonts), pages.settings, fonts));
|
|
135
|
+
const groupHeight = groupHeadings.reduce((height, heading) => height + heading.height, 0);
|
|
136
|
+
// Newly opened semantic headings already paint the end of this path. Only the open
|
|
137
|
+
// ancestor prefix needs an artifact here; later physical bands still paint the full path.
|
|
138
|
+
const ancestorCaption = semantic && semanticDepth > 0 ? await prepareParagraph(captureCaption({
|
|
139
|
+
text: path.slice(0, semanticDepth).map(group => group.label).join("\n"), presentation: { bold: true }, spaceAfter: 4
|
|
140
|
+
}, pages.settings, fonts), pages.settings, fonts) : undefined;
|
|
141
|
+
const openingHeight = semantic ? (ancestorCaption?.height ?? 0) + groupHeight : caption.height;
|
|
142
|
+
await context.flushParagraphs(openingHeight + headingHeight + minimum);
|
|
143
|
+
if (ancestorCaption)
|
|
144
|
+
await pages.paragraphs([ancestorCaption], groupHeight + headingHeight + minimum, true, { artifact: true });
|
|
145
|
+
let followingHeight = groupHeight + (semantic ? 0 : caption.height) + headingHeight + minimum;
|
|
146
|
+
for (const heading of groupHeadings) {
|
|
147
|
+
followingHeight -= heading.height;
|
|
148
|
+
await pages.beginGroup(semanticDepth++, heading, followingHeight);
|
|
149
|
+
}
|
|
150
|
+
await pages.beginTable(layout, headings, minimum, caption, continuation, false, semantic, semantic);
|
|
151
|
+
started = true;
|
|
152
|
+
firstFragment = (caption?.lines.length ?? 0) > 0 || groupHeadings.some(heading => heading.lines.length > 0);
|
|
153
|
+
};
|
|
154
|
+
const semanticSubtotal = async (row, level, values) => {
|
|
155
|
+
if (level === report.groupBy.length - 1) {
|
|
156
|
+
// A leaf's own subtotal shares its detail table and header identities. Keep the last
|
|
157
|
+
// detail/summary bundle when it fits; the existing flow owns continuation and limits.
|
|
158
|
+
pages.summary(row);
|
|
159
|
+
closing.push(row);
|
|
160
|
+
await finishLeaf();
|
|
161
|
+
await pages.endGroup(level);
|
|
162
|
+
semanticDepth = level;
|
|
163
|
+
path = path.slice(0, level);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await finishLeaf();
|
|
167
|
+
const { caption, continuation } = await prepareGroupContext();
|
|
168
|
+
const projected = summaryLayout(false), summaryHeadings = await projected.headers();
|
|
169
|
+
const summaryRow = await projected.data(values, 0, true), minimum = projected.minimumRowHeight(summaryRow);
|
|
170
|
+
await context.flushParagraphs(caption.height + await projected.blockHeight(summaryHeadings) + minimum);
|
|
171
|
+
// An ancestor subtotal belongs to that ancestor's section, never the final child's table.
|
|
172
|
+
// Its own visible column headings keep the separate logical summary table truthful.
|
|
173
|
+
await pages.beginTable(projected, summaryHeadings, minimum, caption, continuation, false, true);
|
|
174
|
+
pages.summary(summaryRow);
|
|
175
|
+
await pages.row(summaryRow, caption.lines.length > 0 || summaryHeadings.length > 0);
|
|
176
|
+
await pages.endTable();
|
|
177
|
+
await pages.endGroup(level);
|
|
178
|
+
semanticDepth = level;
|
|
179
|
+
path = path.slice(0, level);
|
|
180
|
+
};
|
|
181
|
+
const complete = async (summary) => {
|
|
182
|
+
await finishLeaf();
|
|
183
|
+
if (!includeGrandTotal && summary.rows !== 0)
|
|
184
|
+
return;
|
|
185
|
+
const completeLayout = summary.rows === 0 ? layout : summaryLayout(true);
|
|
186
|
+
const completeHeadings = summary.rows === 0 ? headings : await completeLayout.headers();
|
|
187
|
+
rowIndex = -1;
|
|
188
|
+
let total;
|
|
189
|
+
if (includeGrandTotal) {
|
|
190
|
+
context.acceptRow(false);
|
|
191
|
+
total = await completeLayout.data(summaryValues(synchronousText(grandTotalLabel(summary), "grandTotalLabel"), summary.totals, summary.rows === 0 ? undefined : aggregatePositions), 0, true);
|
|
192
|
+
}
|
|
193
|
+
if (!completeHeadings.length && !total)
|
|
194
|
+
return;
|
|
195
|
+
const minimum = total ? completeLayout.minimumRowHeight(total) : 0;
|
|
196
|
+
await context.flushParagraphs(await completeLayout.blockHeight(completeHeadings) + minimum);
|
|
197
|
+
await pages.beginTable(completeLayout, completeHeadings, minimum);
|
|
198
|
+
if (total) {
|
|
199
|
+
if (semantic)
|
|
200
|
+
pages.summary(total);
|
|
201
|
+
await pages.row(total);
|
|
202
|
+
}
|
|
203
|
+
await pages.endTable();
|
|
204
|
+
};
|
|
205
|
+
await consumeRows(operation.events, operation.signal, async (event) => {
|
|
206
|
+
switch (event.kind) {
|
|
207
|
+
case "groupStart":
|
|
208
|
+
await finishLeaf();
|
|
209
|
+
if (semantic && groupHeadingLevel + event.level > 6)
|
|
210
|
+
throw new RangeError("groupHeadingLevel and the opened group depth exceed heading level 6.");
|
|
211
|
+
path = Object.freeze([...path.slice(0, event.level), event]);
|
|
212
|
+
break;
|
|
213
|
+
case "row": {
|
|
214
|
+
if (pending)
|
|
215
|
+
await flushLastDetail();
|
|
216
|
+
rowIndex = event.rowIndex;
|
|
217
|
+
context.acceptRow(true);
|
|
218
|
+
const row = await layout.data([new ExportCell("", { text: "" }), ...event.values], event.rowIndex);
|
|
219
|
+
pending = row;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case "groupEnd": {
|
|
223
|
+
rowIndex = -1;
|
|
224
|
+
context.acceptRow(false);
|
|
225
|
+
const separate = semantic && event.level !== report.groupBy.length - 1;
|
|
226
|
+
const values = summaryValues(synchronousText(subtotalLabel(event), "subtotalLabel"), event.totals, separate ? aggregatePositions : undefined);
|
|
227
|
+
const row = separate ? undefined : await layout.data(values, 0, true);
|
|
228
|
+
if (semantic)
|
|
229
|
+
await semanticSubtotal(row, event.level, values);
|
|
230
|
+
else
|
|
231
|
+
closing.push(row);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case "complete":
|
|
235
|
+
await complete(event);
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
operation.signal?.removeEventListener("abort", abort);
|
|
242
|
+
operation.dispose();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PdfImageBlock } from "./document-types.js";
|
|
2
|
+
import type { PdfObjects } from "./objects.js";
|
|
3
|
+
import type { PdfSettings } from "./settings.js";
|
|
4
|
+
interface ImageResource {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly id: number;
|
|
7
|
+
readonly width: number;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
}
|
|
10
|
+
/** Shared document image resources; source objects are captured on first consumption. */
|
|
11
|
+
export declare class PdfDocumentImages {
|
|
12
|
+
private readonly objects;
|
|
13
|
+
private readonly settings;
|
|
14
|
+
private readonly images;
|
|
15
|
+
private bytes;
|
|
16
|
+
constructor(objects: PdfObjects, settings: PdfSettings);
|
|
17
|
+
prepare(image: PdfImageBlock["image"]): Promise<ImageResource>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|