reamkit 1.30.0 → 1.32.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 +70 -24
- package/dist/esm/core/bidi/index.d.ts +10 -0
- package/dist/esm/core/bidi/index.js +18 -2
- package/dist/esm/core/converter/facade.js +10 -5
- package/dist/esm/core/converter/project.js +4 -1
- package/dist/esm/core/converter/ream.js +17 -6
- package/dist/esm/core/converter/sheet-images.d.ts +17 -0
- package/dist/esm/core/converter/sheet-images.js +33 -0
- package/dist/esm/core/crypto/offcrypto.js +1 -1
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +175 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +21 -8
- package/dist/esm/core/drawingml/chart-geometry.js +198 -108
- package/dist/esm/core/drawingml/chart-parser.js +73 -2
- package/dist/esm/core/drawingml/colors.d.ts +6 -0
- package/dist/esm/core/drawingml/colors.js +23 -3
- package/dist/esm/core/drawingml/shape-render.d.ts +3 -1
- package/dist/esm/core/drawingml/shape-render.js +4 -2
- package/dist/esm/core/font/index.d.ts +2 -0
- package/dist/esm/core/font/measure.d.ts +9 -0
- package/dist/esm/core/font/measure.js +9 -1
- package/dist/esm/core/font/ttf-build.d.ts +113 -0
- package/dist/esm/core/font/ttf-build.js +1224 -0
- package/dist/esm/core/font/ttf-subset.d.ts +19 -0
- package/dist/esm/core/font/ttf-subset.js +14 -1
- package/dist/esm/core/fonts/families.js +4 -2
- package/dist/esm/core/fonts/provider.d.ts +17 -0
- package/dist/esm/core/fonts/provider.js +27 -2
- package/dist/esm/core/fonts/remote-fonts.js +8 -1
- package/dist/esm/core/fonts/scripts.js +4 -2
- package/dist/esm/core/ir/flow.d.ts +77 -1
- package/dist/esm/core/ir/sheet.d.ts +43 -0
- package/dist/esm/core/number-format.js +16 -11
- package/dist/esm/core/numbering/index.d.ts +1 -1
- package/dist/esm/core/numbering/state.d.ts +11 -1
- package/dist/esm/core/numbering/state.js +10 -1
- package/dist/esm/core/spreadsheet-model/index.d.ts +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +96 -0
- package/dist/esm/core/style-cascade/resolver.js +39 -6
- package/dist/esm/core/style-cascade/types.d.ts +19 -1
- package/dist/esm/core/style-cascade/types.js +3 -0
- package/dist/esm/excel/column-bands.d.ts +39 -6
- package/dist/esm/excel/column-bands.js +41 -17
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +7 -3
- package/dist/esm/excel/conditional-format.js +77 -39
- package/dist/esm/excel/formula/context.d.ts +18 -0
- package/dist/esm/excel/formula/eval.js +51 -0
- package/dist/esm/excel/formula/index.d.ts +2 -2
- package/dist/esm/excel/formula/lexer.d.ts +1 -1
- package/dist/esm/excel/formula/lexer.js +41 -0
- package/dist/esm/excel/formula/parser.d.ts +25 -0
- package/dist/esm/excel/formula/parser.js +95 -0
- package/dist/esm/excel/print-model.d.ts +38 -1
- package/dist/esm/excel/print-model.js +522 -80
- package/dist/esm/excel/shared-strings-parser.d.ts +9 -0
- package/dist/esm/excel/shared-strings-parser.js +11 -1
- package/dist/esm/excel/sheet-drawing.d.ts +38 -2
- package/dist/esm/excel/sheet-drawing.js +47 -13
- package/dist/esm/excel/sheet-shape-parser.d.ts +6 -2
- package/dist/esm/excel/sheet-shape-parser.js +18 -6
- package/dist/esm/excel/sheet-to-flow.d.ts +17 -0
- package/dist/esm/excel/sheet-to-flow.js +434 -47
- package/dist/esm/excel/styles-parser.d.ts +9 -0
- package/dist/esm/excel/styles-parser.js +80 -26
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/table-style-presets.d.ts +26 -0
- package/dist/esm/excel/table-style-presets.js +1555 -0
- package/dist/esm/excel/table-style.d.ts +13 -0
- package/dist/esm/excel/table-style.js +75 -0
- package/dist/esm/excel/tint.d.ts +10 -0
- package/dist/esm/excel/tint.js +75 -0
- package/dist/esm/excel/vml-drawing.d.ts +41 -3
- package/dist/esm/excel/vml-drawing.js +143 -10
- package/dist/esm/excel/worksheet-parser.js +89 -15
- package/dist/esm/excel/xls/biff-reader.js +10 -2
- package/dist/esm/excel/xlsx-reader.js +195 -14
- package/dist/esm/excel/xlsx-writer.js +8 -7
- package/dist/esm/html/html-writer.js +202 -20
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/layout/fit-pages.d.ts +11 -0
- package/dist/esm/layout/fit-pages.js +86 -0
- package/dist/esm/layout/line-paint.d.ts +58 -0
- package/dist/esm/layout/line-paint.js +107 -0
- package/dist/esm/layout/page-doc.d.ts +61 -3
- package/dist/esm/layout/page-doc.js +141 -1
- package/dist/esm/layout/styled-layout.d.ts +55 -7
- package/dist/esm/layout/styled-layout.js +1154 -169
- package/dist/esm/layout/turned-section.d.ts +38 -0
- package/dist/esm/layout/turned-section.js +205 -0
- package/dist/esm/markdown/markdown-writer.js +17 -6
- package/dist/esm/pdf/styled-page-emitter.js +114 -60
- package/dist/esm/pdf/styled-page-renderer.js +1 -1
- package/dist/esm/pdf-reader/cff-outline.d.ts +27 -0
- package/dist/esm/pdf-reader/cff-outline.js +169 -21
- package/dist/esm/pdf-reader/content.d.ts +53 -0
- package/dist/esm/pdf-reader/content.js +9 -1
- package/dist/esm/pdf-reader/display.d.ts +36 -0
- package/dist/esm/pdf-reader/display.js +66 -1
- package/dist/esm/pdf-reader/document.js +5 -1
- package/dist/esm/pdf-reader/embedded-fonts.d.ts +2 -1
- package/dist/esm/pdf-reader/embedded-fonts.js +32 -2
- package/dist/esm/pdf-reader/encodings.d.ts +8 -0
- package/dist/esm/pdf-reader/encodings.js +25 -3
- package/dist/esm/pdf-reader/face-outlines.d.ts +78 -0
- package/dist/esm/pdf-reader/face-outlines.js +362 -0
- package/dist/esm/pdf-reader/figures.d.ts +52 -0
- package/dist/esm/pdf-reader/figures.js +433 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +131 -5
- package/dist/esm/pdf-reader/flow-build.js +345 -26
- package/dist/esm/pdf-reader/font.js +321 -36
- package/dist/esm/pdf-reader/glyf-outline.d.ts +33 -0
- package/dist/esm/pdf-reader/glyf-outline.js +135 -1
- package/dist/esm/pdf-reader/glyph-names.js +154 -1
- package/dist/esm/pdf-reader/layout.d.ts +93 -0
- package/dist/esm/pdf-reader/layout.js +1703 -214
- package/dist/esm/pdf-reader/page-numbers.d.ts +53 -0
- package/dist/esm/pdf-reader/page-numbers.js +167 -0
- package/dist/esm/pdf-reader/tagged.js +182 -23
- package/dist/esm/pdf-reader/text.d.ts +6 -3
- package/dist/esm/pdf-reader/text.js +98 -9
- package/dist/esm/pdf-reader/type1-outline.d.ts +11 -0
- package/dist/esm/pdf-reader/type1-outline.js +63 -8
- package/dist/esm/pdf-reader/vector.js +71 -1
- package/dist/esm/svg/svg-text.d.ts +58 -0
- package/dist/esm/svg/svg-text.js +322 -0
- package/dist/esm/svg/svg-writer.js +135 -71
- package/dist/esm/word/doc/doc-reader.js +6 -2
- package/dist/esm/word/doc/doc-text.d.ts +6 -0
- package/dist/esm/word/doc/doc-text.js +19 -1
- package/dist/esm/word/document-parser.d.ts +2 -2
- package/dist/esm/word/document-parser.js +11 -1
- package/dist/esm/word/docx-reader.js +5 -3
- package/dist/esm/word/docx-writer.js +218 -23
- package/dist/esm/word/drawing-parser.d.ts +5 -3
- package/dist/esm/word/drawing-parser.js +49 -8
- package/dist/esm/word/font-embed.d.ts +30 -0
- package/dist/esm/word/font-embed.js +173 -0
- package/dist/esm/word/font-table.d.ts +10 -0
- package/dist/esm/word/font-table.js +13 -1
- package/dist/esm/word/index.js +1 -1
- package/dist/esm/word/numbering-parser.d.ts +3 -1
- package/dist/esm/word/numbering-parser.js +2 -1
- package/dist/esm/word/paragraph-properties.d.ts +7 -6
- package/dist/esm/word/paragraph-properties.js +14 -2
- package/dist/esm/word/run-properties.js +26 -0
- package/package.json +12 -3
|
@@ -137,7 +137,10 @@ function mergeRun(base, override) {
|
|
|
137
137
|
...lang !== void 0 ? { lang } : {},
|
|
138
138
|
...(override.shadingColorHex ?? base.shadingColorHex) !== void 0 ? { shadingColorHex: override.shadingColorHex ?? base.shadingColorHex } : {},
|
|
139
139
|
...(override.textOutline ?? base.textOutline) !== void 0 ? { textOutline: override.textOutline ?? base.textOutline } : {},
|
|
140
|
-
...(override.letterSpacingPt ?? base.letterSpacingPt) !== void 0 ? { letterSpacingPt: override.letterSpacingPt ?? base.letterSpacingPt } : {}
|
|
140
|
+
...(override.letterSpacingPt ?? base.letterSpacingPt) !== void 0 ? { letterSpacingPt: override.letterSpacingPt ?? base.letterSpacingPt } : {},
|
|
141
|
+
...(override.widthScale ?? base.widthScale) !== void 0 ? { widthScale: override.widthScale ?? base.widthScale } : {},
|
|
142
|
+
...(override.kerningMinPt ?? base.kerningMinPt) !== void 0 ? { kerningMinPt: override.kerningMinPt ?? base.kerningMinPt } : {},
|
|
143
|
+
...(override.ligatures ?? base.ligatures) !== void 0 ? { ligatures: override.ligatures ?? base.ligatures } : {}
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
146
|
function mergePar(base, override) {
|
|
@@ -152,6 +155,7 @@ function mergePar(base, override) {
|
|
|
152
155
|
const sectionBreak = override.sectionBreak ?? base.sectionBreak;
|
|
153
156
|
const textDirection = override.textDirection ?? base.textDirection;
|
|
154
157
|
const snapToGrid = override.snapToGrid ?? base.snapToGrid;
|
|
158
|
+
const beforeAuto = override.spacingBeforeAuto ?? (override.spacingBefore === void 0 ? base.spacingBeforeAuto : void 0);
|
|
155
159
|
return {
|
|
156
160
|
alignment: override.alignment ?? base.alignment,
|
|
157
161
|
spacingBefore: override.spacingBeforeAuto ?? override.spacingBefore ?? base.spacingBefore,
|
|
@@ -162,6 +166,9 @@ function mergePar(base, override) {
|
|
|
162
166
|
indentRight: override.indentRight ?? base.indentRight,
|
|
163
167
|
indentFirstLine: override.indentFirstLine ?? base.indentFirstLine,
|
|
164
168
|
pageBreakBefore: override.pageBreakBefore ?? base.pageBreakBefore,
|
|
169
|
+
keepNext: override.keepNext ?? base.keepNext,
|
|
170
|
+
keepLines: override.keepLines ?? base.keepLines,
|
|
171
|
+
widowControl: override.widowControl ?? base.widowControl,
|
|
165
172
|
contextualSpacing: override.contextualSpacing ?? base.contextualSpacing,
|
|
166
173
|
tabs: override.tabs ?? base.tabs,
|
|
167
174
|
bidi: override.bidi ?? base.bidi,
|
|
@@ -174,7 +181,8 @@ function mergePar(base, override) {
|
|
|
174
181
|
...frame !== void 0 ? { frame } : {},
|
|
175
182
|
...sectionBreak !== void 0 ? { sectionBreak } : {},
|
|
176
183
|
...textDirection !== void 0 ? { textDirection } : {},
|
|
177
|
-
...snapToGrid !== void 0 ? { snapToGrid } : {}
|
|
184
|
+
...snapToGrid !== void 0 ? { snapToGrid } : {},
|
|
185
|
+
...beforeAuto !== void 0 ? { spacingBeforeAuto: beforeAuto } : {}
|
|
178
186
|
};
|
|
179
187
|
}
|
|
180
188
|
function mergeRunPartial(base, override) {
|
|
@@ -222,6 +230,7 @@ function primeParagraphFixpoint(para) {
|
|
|
222
230
|
}
|
|
223
231
|
if (!bySheet.has(para)) bySheet.set(para, para);
|
|
224
232
|
}
|
|
233
|
+
var markCascadeCache = /* @__PURE__ */ new WeakMap();
|
|
225
234
|
/**
|
|
226
235
|
* Resolve the style cascade across an entire body so the tree carries final
|
|
227
236
|
* effective run/paragraph properties (FlowDoc transform, ir-design stage 6).
|
|
@@ -229,22 +238,46 @@ function primeParagraphFixpoint(para) {
|
|
|
229
238
|
* resolving again over {@link EMPTY_STYLE_SHEET} is the identity.
|
|
230
239
|
*/
|
|
231
240
|
function resolveBodyStyles(body, sheet) {
|
|
241
|
+
let bySheet = markCascadeCache.get(sheet);
|
|
242
|
+
if (!bySheet) {
|
|
243
|
+
bySheet = /* @__PURE__ */ new WeakMap();
|
|
244
|
+
markCascadeCache.set(sheet, bySheet);
|
|
245
|
+
}
|
|
246
|
+
const marks = bySheet;
|
|
247
|
+
const withResolvedMark = (pp) => {
|
|
248
|
+
const hit = marks.get(pp);
|
|
249
|
+
if (hit) return hit;
|
|
250
|
+
const resolved = {
|
|
251
|
+
...resolveParagraphProperties(pp, sheet),
|
|
252
|
+
runProperties: resolveRunProperties(pp.runProperties ?? {}, pp, sheet)
|
|
253
|
+
};
|
|
254
|
+
marks.set(pp, resolved);
|
|
255
|
+
return resolved;
|
|
256
|
+
};
|
|
232
257
|
const visitParagraph = (p) => {
|
|
233
258
|
for (const r of p.runs) r.properties = resolveRunProperties(r.properties, p.properties, sheet);
|
|
234
|
-
p.properties =
|
|
259
|
+
p.properties = withResolvedMark(p.properties);
|
|
235
260
|
primeParagraphFixpoint(p.properties);
|
|
236
261
|
for (const r of p.runs) primeResolvedFixpoint(r.properties, p.properties);
|
|
237
262
|
};
|
|
238
263
|
const visit = (el) => {
|
|
239
264
|
if (el.kind === "paragraph") visitParagraph(el.paragraph);
|
|
240
|
-
else if (el.kind === "table")
|
|
241
|
-
|
|
265
|
+
else if (el.kind === "table") {
|
|
266
|
+
for (const row of el.table.rows) for (const cell of row.cells) for (const child of cell.content) visit(child);
|
|
267
|
+
for (const drawing of el.table.overlay?.drawings ?? []) visit(drawing);
|
|
268
|
+
} else if (el.kind === "shape") {
|
|
242
269
|
const shapeText = (sh) => {
|
|
243
270
|
for (const child of sh.text?.content ?? []) visit(child);
|
|
244
271
|
for (const member of sh.children ?? []) shapeText(member.shape);
|
|
245
272
|
};
|
|
246
273
|
shapeText(el.shape);
|
|
247
|
-
|
|
274
|
+
standsOn(el.shape);
|
|
275
|
+
} else if (el.kind === "image") standsOn(el.image);
|
|
276
|
+
else standsOn(el.chart);
|
|
277
|
+
};
|
|
278
|
+
const standsOn = (block) => {
|
|
279
|
+
if (block.float !== void 0) return;
|
|
280
|
+
block.paragraphProperties = withResolvedMark(block.paragraphProperties);
|
|
248
281
|
};
|
|
249
282
|
for (const el of body) visit(el);
|
|
250
283
|
return body;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alignment, CellBorders, CellShading, FontFamilyMap, FrameProperties, NumberingReference, RunProperties, TabStop, TextOutline, UnderlineStyle, VerticalAlign } from '../document-model/index.js';
|
|
1
|
+
import { Alignment, CellBorders, CellShading, FontFamilyMap, FrameProperties, Ligatures, NumberingReference, RunProperties, TabStop, TextOutline, UnderlineStyle, VerticalAlign } from '../document-model/index.js';
|
|
2
2
|
import { Pt } from '../ir/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* A run's fully-resolved properties: every field required because the cascade
|
|
@@ -30,6 +30,12 @@ export interface ResolvedRunProperties {
|
|
|
30
30
|
readonly shadingColorHex?: string;
|
|
31
31
|
/** §17.3.2.35 — extra space between the run's characters, in points. */
|
|
32
32
|
readonly letterSpacingPt?: Pt;
|
|
33
|
+
/** §17.3.2.43 — the share of its own width each character is set at. */
|
|
34
|
+
readonly widthScale?: number;
|
|
35
|
+
/** §17.3.2.19 — the run is kerned at this size and above (0: not at all). */
|
|
36
|
+
readonly kerningMinPt?: Pt;
|
|
37
|
+
/** [MS-DOCX] `w14:ligatures` — the face's ligatures the run is set with. */
|
|
38
|
+
readonly ligatures?: Ligatures;
|
|
33
39
|
/** §21.1.2.3.9 — a line drawn round the glyphs themselves. */
|
|
34
40
|
readonly textOutline?: TextOutline;
|
|
35
41
|
}
|
|
@@ -40,6 +46,12 @@ export interface ResolvedRunProperties {
|
|
|
40
46
|
export interface ResolvedParagraphProperties {
|
|
41
47
|
readonly alignment: Alignment;
|
|
42
48
|
readonly spacingBefore: Pt;
|
|
49
|
+
/**
|
|
50
|
+
* §17.3.1.3 `w:beforeAutospacing` — present, and equal to
|
|
51
|
+
* {@link spacingBefore}, where the space before is the automatic (HTML) one:
|
|
52
|
+
* Word does not give it to the document's first paragraph.
|
|
53
|
+
*/
|
|
54
|
+
readonly spacingBeforeAuto?: Pt;
|
|
43
55
|
readonly spacingAfter: Pt;
|
|
44
56
|
readonly spacingLine: Pt;
|
|
45
57
|
readonly spacingLineRule: 'auto' | 'exact' | 'atLeast';
|
|
@@ -47,6 +59,12 @@ export interface ResolvedParagraphProperties {
|
|
|
47
59
|
readonly indentRight: Pt;
|
|
48
60
|
readonly indentFirstLine: Pt;
|
|
49
61
|
readonly pageBreakBefore: boolean;
|
|
62
|
+
/** §17.3.1.14 — on the same page as the start of the next paragraph. */
|
|
63
|
+
readonly keepNext: boolean;
|
|
64
|
+
/** §17.3.1.15 — every line on one page. */
|
|
65
|
+
readonly keepLines: boolean;
|
|
66
|
+
/** §17.3.1.44 — no first or last line left alone on a page. */
|
|
67
|
+
readonly widowControl: boolean;
|
|
50
68
|
/** §17.3.1.9 — drop the space between this paragraph and a same-styled neighbour. */
|
|
51
69
|
readonly contextualSpacing: boolean;
|
|
52
70
|
/** §17.3.1.37 — the paragraph's tab stops, in ascending position order. */
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { BodyElement, TableProperties, TableRow } from '../core/document-model/index.js';
|
|
2
|
+
/** §18.3.1.70 — the width of the row-number column, in twips. */
|
|
3
|
+
export declare const HEADING_COL_TWIPS = 460;
|
|
4
|
+
/**
|
|
5
|
+
* §18.3.1.70 — how the printed headings stand: the sheet's print scale shrinks
|
|
6
|
+
* them with it, as it shrinks everything else on the page.
|
|
7
|
+
*/
|
|
8
|
+
export interface HeadingBand {
|
|
9
|
+
/** How tall the letters row stands — exactly, so a drawing anchored to the
|
|
10
|
+
* grid can be moved down by just as much. */
|
|
11
|
+
readonly lettersPt?: number;
|
|
12
|
+
/** The row-number column's width, in twips; {@link HEADING_COL_TWIPS} unscaled. */
|
|
13
|
+
readonly colTwips?: number;
|
|
14
|
+
/** The size the letters and numbers are set in; the sheet's default unscaled. */
|
|
15
|
+
readonly fontPt?: number;
|
|
16
|
+
/** The width of the boxes' lines; 0.5pt unscaled. */
|
|
17
|
+
readonly lineWidthPt?: number;
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
20
|
* Wrap a grid in its printed row and column headings (§18.3.1.70 `headings`):
|
|
4
21
|
* the column letters across the top, the row numbers down the left, each in a
|
|
@@ -7,14 +24,23 @@ import { BodyElement, TableProperties, TableRow } from '../core/document-model/i
|
|
|
7
24
|
*
|
|
8
25
|
* @param rows The band's rows.
|
|
9
26
|
* @param widths The band's column widths in twips.
|
|
10
|
-
* @param
|
|
27
|
+
* @param columns The absolute index of each of those columns — a hidden
|
|
28
|
+
* one between them is skipped, and so is its letter.
|
|
11
29
|
* @param rowNumbers The absolute 1-based row number of each row.
|
|
30
|
+
* @param band How the headings stand, at the print scale.
|
|
12
31
|
* @returns The rows and widths with the heading band added.
|
|
13
32
|
*/
|
|
14
|
-
export declare function withHeadingBand(rows: ReadonlyArray<TableRow>, widths: ReadonlyArray<number>,
|
|
33
|
+
export declare function withHeadingBand(rows: ReadonlyArray<TableRow>, widths: ReadonlyArray<number>, columns: ReadonlyArray<number>, rowNumbers: ReadonlyArray<number>, band?: HeadingBand): {
|
|
15
34
|
rows: Array<TableRow>;
|
|
16
35
|
widths: Array<number>;
|
|
17
36
|
};
|
|
37
|
+
/** Where a drawing lies on its sheet, in points from the sheet's top-left corner. */
|
|
38
|
+
export interface DrawingBox {
|
|
39
|
+
readonly xPt: number;
|
|
40
|
+
readonly yPt: number;
|
|
41
|
+
readonly widthPt: number;
|
|
42
|
+
readonly heightPt: number;
|
|
43
|
+
}
|
|
18
44
|
/** A contiguous run of columns that prints together as one band (E-SHEET SE1). */
|
|
19
45
|
export interface ColumnBand {
|
|
20
46
|
/** First local column index (inclusive). */
|
|
@@ -50,12 +76,19 @@ export declare function computeColumnBands(columnWidths: ReadonlyArray<number>,
|
|
|
50
76
|
* @param titleRowIndex The print-title row, or -1.
|
|
51
77
|
* @param drawingReachTwips How far right the sheet's drawings reach (0 if none).
|
|
52
78
|
* @param headings §18.3.1.70 — the printed row/column headings, when the sheet
|
|
53
|
-
* asks for them: the absolute index of
|
|
54
|
-
*
|
|
55
|
-
*
|
|
79
|
+
* asks for them: the absolute index of each column and the sheet row number
|
|
80
|
+
* of each emitted row. Each band gets ITS OWN letters, which is what both
|
|
81
|
+
* references print across the top of a continuation page.
|
|
82
|
+
* @param sheet §20.5 — where the grid's first column stands on the sheet and
|
|
83
|
+
* where its printed drawings lie, at the print scale: each band is framed
|
|
84
|
+
* for the drawings over it (TableOverlay) and keeps the rows they cover.
|
|
56
85
|
* @returns One table body element per band, in band order.
|
|
57
86
|
*/
|
|
58
87
|
export declare function bandedTables(rows: ReadonlyArray<TableRow>, columnWidths: ReadonlyArray<number>, bands: ReadonlyArray<ColumnBand>, properties: TableProperties, titleRowIndex?: number, drawingReachTwips?: number, headings?: {
|
|
59
|
-
readonly
|
|
88
|
+
readonly columns: ReadonlyArray<number>;
|
|
60
89
|
readonly rowNumbers: ReadonlyArray<number>;
|
|
90
|
+
readonly band?: HeadingBand;
|
|
91
|
+
}, sheet?: {
|
|
92
|
+
readonly sheetLeftPt: number;
|
|
93
|
+
readonly drawings: ReadonlyArray<DrawingBox>;
|
|
61
94
|
}): Array<BodyElement>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { twipsToPt } from "../core/ir/units.js";
|
|
2
|
-
//#region src/excel/column-bands.ts
|
|
3
|
-
/** §18.3.1.70 — the width of the row-number column, in twips. */
|
|
4
|
-
var HEADING_COL_TWIPS = 460;
|
|
1
|
+
import { pt, twipsToPt } from "../core/ir/units.js";
|
|
5
2
|
/** The A1-style letters of an absolute column index (0 → A, 26 → AA). */
|
|
6
3
|
function columnLetters(index) {
|
|
7
4
|
let n = index;
|
|
@@ -20,14 +17,17 @@ function columnLetters(index) {
|
|
|
20
17
|
*
|
|
21
18
|
* @param rows The band's rows.
|
|
22
19
|
* @param widths The band's column widths in twips.
|
|
23
|
-
* @param
|
|
20
|
+
* @param columns The absolute index of each of those columns — a hidden
|
|
21
|
+
* one between them is skipped, and so is its letter.
|
|
24
22
|
* @param rowNumbers The absolute 1-based row number of each row.
|
|
23
|
+
* @param band How the headings stand, at the print scale.
|
|
25
24
|
* @returns The rows and widths with the heading band added.
|
|
26
25
|
*/
|
|
27
|
-
function withHeadingBand(rows, widths,
|
|
26
|
+
function withHeadingBand(rows, widths, columns, rowNumbers, band = {}) {
|
|
27
|
+
const { lettersPt, colTwips = 460, fontPt, lineWidthPt = .5 } = band;
|
|
28
28
|
const border = {
|
|
29
29
|
style: "single",
|
|
30
|
-
width:
|
|
30
|
+
width: lineWidthPt,
|
|
31
31
|
colorHex: "808080"
|
|
32
32
|
};
|
|
33
33
|
const borders = {
|
|
@@ -47,15 +47,21 @@ function withHeadingBand(rows, widths, colStart, rowNumbers) {
|
|
|
47
47
|
properties: { alignment: "center" },
|
|
48
48
|
runs: [{
|
|
49
49
|
text,
|
|
50
|
-
properties: {}
|
|
50
|
+
properties: fontPt !== void 0 ? { fontSizePt: pt(fontPt) } : {}
|
|
51
51
|
}]
|
|
52
52
|
}
|
|
53
53
|
}]
|
|
54
54
|
});
|
|
55
55
|
const letters = [head("")];
|
|
56
|
-
for (let i = 0; i < widths.length; i++) letters.push(head(columnLetters(
|
|
56
|
+
for (let i = 0; i < widths.length; i++) letters.push(head(columnLetters(columns[i] ?? i)));
|
|
57
57
|
const out = [{
|
|
58
|
-
properties: {
|
|
58
|
+
properties: {
|
|
59
|
+
isHeader: true,
|
|
60
|
+
...lettersPt !== void 0 ? {
|
|
61
|
+
height: pt(lettersPt),
|
|
62
|
+
heightRule: "exact"
|
|
63
|
+
} : {}
|
|
64
|
+
},
|
|
59
65
|
cells: letters
|
|
60
66
|
}];
|
|
61
67
|
rows.forEach((row, i) => {
|
|
@@ -66,7 +72,7 @@ function withHeadingBand(rows, widths, colStart, rowNumbers) {
|
|
|
66
72
|
});
|
|
67
73
|
return {
|
|
68
74
|
rows: out,
|
|
69
|
-
widths: [
|
|
75
|
+
widths: [colTwips, ...widths]
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
@@ -122,16 +128,33 @@ function computeColumnBands(columnWidths, contentWidthTwips, colBreaks) {
|
|
|
122
128
|
* @param titleRowIndex The print-title row, or -1.
|
|
123
129
|
* @param drawingReachTwips How far right the sheet's drawings reach (0 if none).
|
|
124
130
|
* @param headings §18.3.1.70 — the printed row/column headings, when the sheet
|
|
125
|
-
* asks for them: the absolute index of
|
|
126
|
-
*
|
|
127
|
-
*
|
|
131
|
+
* asks for them: the absolute index of each column and the sheet row number
|
|
132
|
+
* of each emitted row. Each band gets ITS OWN letters, which is what both
|
|
133
|
+
* references print across the top of a continuation page.
|
|
134
|
+
* @param sheet §20.5 — where the grid's first column stands on the sheet and
|
|
135
|
+
* where its printed drawings lie, at the print scale: each band is framed
|
|
136
|
+
* for the drawings over it (TableOverlay) and keeps the rows they cover.
|
|
128
137
|
* @returns One table body element per band, in band order.
|
|
129
138
|
*/
|
|
130
|
-
function bandedTables(rows, columnWidths, bands, properties, titleRowIndex = -1, drawingReachTwips = 0, headings) {
|
|
139
|
+
function bandedTables(rows, columnWidths, bands, properties, titleRowIndex = -1, drawingReachTwips = 0, headings, sheet) {
|
|
131
140
|
return bands.flatMap((band, bandIndex) => {
|
|
132
141
|
const bandLeft = columnWidths.slice(0, band.start).reduce((sum, w) => sum + w, 0);
|
|
133
142
|
const bandTwips = columnWidths.slice(band.start, band.end + 1);
|
|
134
143
|
const grid = bandTwips.map((w) => twipsToPt(w));
|
|
144
|
+
const sheetLeftPt = sheet ? sheet.sheetLeftPt + twipsToPt(bandLeft) : 0;
|
|
145
|
+
const sheetRightPt = sheetLeftPt + grid.reduce((sum, w) => sum + w, 0);
|
|
146
|
+
const overlayAt = (leftPt) => sheet ? { overlay: {
|
|
147
|
+
sheetLeftPt: pt(sheetLeftPt),
|
|
148
|
+
widthPt: pt(sheetRightPt - sheetLeftPt),
|
|
149
|
+
leftPt: pt(leftPt),
|
|
150
|
+
drawings: []
|
|
151
|
+
} } : {};
|
|
152
|
+
const underDrawing = (row) => {
|
|
153
|
+
const top = row.properties.sheetTopPt;
|
|
154
|
+
if (top === void 0 || !sheet) return false;
|
|
155
|
+
const bottom = top + (row.properties.height ?? 0);
|
|
156
|
+
return sheet.drawings.some((d) => d.xPt < sheetRightPt && d.xPt + d.widthPt > sheetLeftPt && d.yPt < bottom && d.yPt + d.heightPt > top);
|
|
157
|
+
};
|
|
135
158
|
const bandRowNumbers = [...headings?.rowNumbers ?? []];
|
|
136
159
|
const bandRows = rows.map((row, rowIndex) => {
|
|
137
160
|
const cells = sliceRowCells(row.cells, band);
|
|
@@ -144,7 +167,7 @@ function bandedTables(rows, columnWidths, bands, properties, titleRowIndex = -1,
|
|
|
144
167
|
};
|
|
145
168
|
});
|
|
146
169
|
if (bandIndex > 0 && !(bandLeft < drawingReachTwips) && !bandRows.some(rowDrawsSomething)) return [];
|
|
147
|
-
while (bandRows.length > 1 && !rowDrawsSomething(bandRows[bandRows.length - 1])) {
|
|
170
|
+
while (bandRows.length > 1 && !rowDrawsSomething(bandRows[bandRows.length - 1]) && !underDrawing(bandRows[bandRows.length - 1])) {
|
|
148
171
|
bandRows.pop();
|
|
149
172
|
bandRowNumbers.pop();
|
|
150
173
|
}
|
|
@@ -158,11 +181,12 @@ function bandedTables(rows, columnWidths, bands, properties, titleRowIndex = -1,
|
|
|
158
181
|
rows: bandRows,
|
|
159
182
|
numbers: bandRowNumbers
|
|
160
183
|
}]).map((part) => {
|
|
161
|
-
const headed = headings ? withHeadingBand(part.rows, bandTwips, headings.
|
|
184
|
+
const headed = headings ? withHeadingBand(part.rows, bandTwips, headings.columns.slice(band.start, band.end + 1), part.numbers, headings.band) : void 0;
|
|
162
185
|
return {
|
|
163
186
|
kind: "table",
|
|
164
187
|
table: {
|
|
165
188
|
properties,
|
|
189
|
+
...overlayAt(headed ? twipsToPt(headings?.band?.colTwips ?? 460) : 0),
|
|
166
190
|
grid: headed ? headed.widths.map((w) => twipsToPt(w)) : grid,
|
|
167
191
|
rows: headed ? leadWithBandBreak(headed.rows) : part.rows
|
|
168
192
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveInternalEntities } from "../core/opc/xml-entities.js";
|
|
2
|
+
import { richRun } from "./shared-strings-parser.js";
|
|
2
3
|
import { XMLParser } from "fast-xml-parser";
|
|
3
4
|
//#region src/excel/comments-parser.ts
|
|
4
5
|
var decoder = new TextDecoder("utf-8");
|
|
@@ -32,10 +33,12 @@ function parseLegacyComments(data) {
|
|
|
32
33
|
const author = Number.isInteger(authorIdx) ? authors[authorIdx] : void 0;
|
|
33
34
|
const text = stripAuthorPrefix(richText(obj["text"]), author);
|
|
34
35
|
if (text.length === 0 && !author) continue;
|
|
36
|
+
const runs = richRuns(obj["text"]);
|
|
35
37
|
out.push({
|
|
36
38
|
ref,
|
|
37
39
|
...author ? { author } : {},
|
|
38
40
|
text,
|
|
41
|
+
...runs.length > 0 ? { runs } : {},
|
|
39
42
|
threaded: false
|
|
40
43
|
});
|
|
41
44
|
}
|
|
@@ -95,6 +98,22 @@ function richText(node) {
|
|
|
95
98
|
if (direct) return direct;
|
|
96
99
|
return toArray(obj["r"]).map((r) => textOf(asObject(r)?.["t"])).join("");
|
|
97
100
|
}
|
|
101
|
+
function richRuns(node) {
|
|
102
|
+
const obj = asObject(node);
|
|
103
|
+
if (!obj) {
|
|
104
|
+
const plain = textOf(node);
|
|
105
|
+
return plain ? [{ text: plain }] : [];
|
|
106
|
+
}
|
|
107
|
+
const direct = textOf(obj["t"]);
|
|
108
|
+
if (direct) return [{ text: direct }];
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const r of toArray(obj["r"])) {
|
|
111
|
+
const run = asObject(r);
|
|
112
|
+
const text = textOf(run?.["t"]);
|
|
113
|
+
if (text.length > 0) out.push(richRun(text, run?.["rPr"]));
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
98
117
|
function stripAuthorPrefix(text, author) {
|
|
99
118
|
if (!author) return text;
|
|
100
119
|
const prefix = `${author}:`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CellIcon } from '../core/document-model/index.js';
|
|
2
|
-
import { ConditionalFormat, DefinedName, WorksheetCell, XlsxBorder, XlsxStyles } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
import { ConditionalFormat, DefinedName, ExcelTable, WorksheetCell, XlsxBorder, XlsxStyles } from '../core/spreadsheet-model/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* A resolved per-cell override the print model layers over a cell's base format: a
|
|
5
5
|
* solid highlight fill, font tweaks, an in-cell data bar (fraction of the cell
|
|
@@ -25,12 +25,14 @@ export interface CfOverride {
|
|
|
25
25
|
readonly colorHex: string;
|
|
26
26
|
readonly startFraction?: number;
|
|
27
27
|
readonly negative?: boolean;
|
|
28
|
+
readonly solid?: boolean;
|
|
28
29
|
};
|
|
29
30
|
readonly icon?: CellIcon;
|
|
30
31
|
/**
|
|
31
32
|
* §18.3.1.28 `<dataBar showValue="0">` — the cell shows its BAR and not its
|
|
32
33
|
* number. Excel's "Show Bar Only": the figure would otherwise sit on top of
|
|
33
|
-
* its own gauge.
|
|
34
|
+
* its own gauge. §18.3.1.49 `<iconSet showValue="0">` is the same for an
|
|
35
|
+
* icon: "Show Icon Only".
|
|
34
36
|
*/
|
|
35
37
|
readonly hideValue?: boolean;
|
|
36
38
|
}
|
|
@@ -69,11 +71,13 @@ blank?: boolean) => CfOverride | undefined;
|
|
|
69
71
|
* driving `TODAY()`/`NOW()` and the `timePeriod` windows;
|
|
70
72
|
* absent ⇒ those constructs no-op (deterministic output).
|
|
71
73
|
* @param sheetGrids The whole workbook, for an `expression` rule that reaches
|
|
72
|
-
* another sheet (`Sheet2!A1`)
|
|
74
|
+
* another sheet (`Sheet2!A1`), a defined name or a table
|
|
75
|
+
* by its columns (`tblIncome[Amount]`); absent ⇒
|
|
73
76
|
* same-sheet references only.
|
|
74
77
|
* @param currentSheet The rule sheet's name, for resolving sheet-local names.
|
|
75
78
|
* @param definedNames The workbook defined names visible to `expression` rules.
|
|
76
79
|
*/
|
|
77
80
|
export declare function buildConditionalFormatter(conditionalFormats: ReadonlyArray<ConditionalFormat> | undefined, styles: XlsxStyles, cells: ReadonlyArray<WorksheetCell>, resolveText?: (cell: WorksheetCell) => string, date1904?: boolean, now?: Date, sheetGrids?: ReadonlyMap<string, {
|
|
78
81
|
readonly cells: ReadonlyArray<WorksheetCell>;
|
|
82
|
+
readonly tables?: ReadonlyArray<ExcelTable>;
|
|
79
83
|
}>, currentSheet?: string, definedNames?: ReadonlyArray<DefinedName>): CellConditionalFormatter | undefined;
|