reamkit 1.15.1 → 1.15.3
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/dist/esm/core/arc-to-bezier.d.ts +23 -0
- package/dist/esm/core/arc-to-bezier.js +23 -0
- package/dist/esm/core/bidi/algorithm.d.ts +26 -0
- package/dist/esm/core/bidi/algorithm.js +21 -0
- package/dist/esm/core/bidi/char-types.d.ts +17 -0
- package/dist/esm/core/bidi/char-types.js +10 -0
- package/dist/esm/core/bidi/index.d.ts +42 -0
- package/dist/esm/core/bidi/index.js +27 -0
- package/dist/esm/core/bidi/segments.d.ts +22 -0
- package/dist/esm/core/bidi/segments.js +14 -0
- package/dist/esm/core/bytes.d.ts +20 -0
- package/dist/esm/core/bytes.js +24 -1
- package/dist/esm/core/converter/facade.d.ts +38 -1
- package/dist/esm/core/converter/facade.js +25 -0
- package/dist/esm/core/converter/project.d.ts +12 -0
- package/dist/esm/core/converter/project.js +11 -0
- package/dist/esm/core/converter/ream.d.ts +107 -0
- package/dist/esm/core/converter/ream.js +76 -0
- package/dist/esm/core/crypto/asn1.d.ts +77 -0
- package/dist/esm/core/crypto/asn1.js +65 -0
- package/dist/esm/core/crypto/cms.d.ts +25 -0
- package/dist/esm/core/crypto/cms.js +8 -0
- package/dist/esm/core/document-model/index.d.ts +7 -0
- package/dist/esm/core/document-model/types.d.ts +328 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
- package/dist/esm/core/drawingml/chart-geometry.js +96 -0
- package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
- package/dist/esm/core/drawingml/chart-parser.js +34 -0
- package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
- package/dist/esm/core/drawingml/chart-serializer.js +12 -0
- package/dist/esm/core/drawingml/colors.d.ts +53 -0
- package/dist/esm/core/drawingml/colors.js +41 -0
- package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
- package/dist/esm/core/drawingml/preset-geometry.js +30 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
- package/dist/esm/core/drawingml/shape-render.js +54 -0
- package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
- package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
- package/dist/esm/core/drawingml/theme-parser.js +11 -0
- package/dist/esm/core/font/arabic-joining.d.ts +21 -0
- package/dist/esm/core/font/arabic-joining.js +16 -0
- package/dist/esm/core/font/binary-reader.d.ts +17 -0
- package/dist/esm/core/font/binary-reader.js +17 -0
- package/dist/esm/core/font/font-registry.d.ts +37 -0
- package/dist/esm/core/font/font-registry.js +31 -0
- package/dist/esm/core/font/measure.d.ts +20 -0
- package/dist/esm/core/font/measure.js +11 -0
- package/dist/esm/core/font/opentype-layout.d.ts +49 -0
- package/dist/esm/core/font/opentype-layout.js +37 -0
- package/dist/esm/core/font/ttf-parser.d.ts +32 -0
- package/dist/esm/core/font/ttf-parser.js +7 -0
- package/dist/esm/core/font/ttf-subset.d.ts +21 -0
- package/dist/esm/core/font/ttf-subset.js +21 -0
- package/dist/esm/core/fonts/provider.d.ts +8 -1
- package/dist/esm/core/fonts/provider.js +1 -0
- package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
- package/dist/esm/core/fonts/remote-fonts.js +16 -0
- package/dist/esm/core/hyphenation/index.d.ts +25 -0
- package/dist/esm/core/hyphenation/index.js +17 -0
- package/dist/esm/core/hyphenation/liang.d.ts +27 -0
- package/dist/esm/core/hyphenation/liang.js +14 -0
- package/dist/esm/core/images.d.ts +32 -0
- package/dist/esm/core/images.js +12 -0
- package/dist/esm/core/ir/adapters.d.ts +23 -0
- package/dist/esm/core/ir/features.d.ts +8 -0
- package/dist/esm/core/ir/features.js +1 -0
- package/dist/esm/core/ir/flow.d.ts +20 -0
- package/dist/esm/core/ir/index.d.ts +7 -0
- package/dist/esm/core/ir/loss.d.ts +12 -0
- package/dist/esm/core/ir/loss.js +8 -0
- package/dist/esm/core/ir/resources.d.ts +12 -0
- package/dist/esm/core/ir/resources.js +11 -0
- package/dist/esm/core/ir/sheet.d.ts +81 -0
- package/dist/esm/core/ir/units.d.ts +9 -0
- package/dist/esm/core/ir/units.js +2 -0
- package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
- package/dist/esm/core/line-breaker/cjk.js +60 -0
- package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
- package/dist/esm/core/line-breaker/greedy.js +14 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -0
- package/dist/esm/core/line-breaker/index.js +3 -0
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
- package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
- package/dist/esm/core/numbering/apply.d.ts +19 -0
- package/dist/esm/core/numbering/apply.js +19 -0
- package/dist/esm/core/numbering/state.d.ts +15 -0
- package/dist/esm/core/numbering/state.js +15 -0
- package/dist/esm/core/ole/cfb.d.ts +19 -0
- package/dist/esm/core/ole/cfb.js +16 -0
- package/dist/esm/core/opc/core-properties.d.ts +12 -0
- package/dist/esm/core/opc/core-properties.js +5 -0
- package/dist/esm/core/opc/opc-writer.d.ts +24 -4
- package/dist/esm/core/opc/opc-writer.js +12 -0
- package/dist/esm/core/opc/package.d.ts +55 -0
- package/dist/esm/core/opc/package.js +49 -1
- package/dist/esm/core/opc/relationship-types.d.ts +8 -0
- package/dist/esm/core/opc/relationship-types.js +5 -0
- package/dist/esm/core/opc/relationships.d.ts +12 -0
- package/dist/esm/core/opc/relationships.js +7 -0
- package/dist/esm/core/po-helpers.d.ts +38 -0
- package/dist/esm/core/po-helpers.js +33 -0
- package/dist/esm/core/spreadsheet-model/types.d.ts +302 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
- package/dist/esm/core/style-cascade/resolver.js +31 -0
- package/dist/esm/core/style-cascade/table.d.ts +7 -0
- package/dist/esm/core/style-cascade/table.js +7 -0
- package/dist/esm/core/style-cascade/types.d.ts +27 -0
- package/dist/esm/core/style-cascade/types.js +2 -0
- package/dist/esm/core/vector.d.ts +67 -0
- package/dist/esm/core/vector.js +23 -0
- package/dist/esm/excel/activex-parser.d.ts +31 -0
- package/dist/esm/excel/activex-parser.js +24 -0
- package/dist/esm/excel/cell-reference.d.ts +14 -0
- package/dist/esm/excel/cell-reference.js +9 -0
- package/dist/esm/excel/column-bands.d.ts +29 -0
- package/dist/esm/excel/column-bands.js +27 -7
- package/dist/esm/excel/comments-parser.d.ts +19 -0
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +38 -0
- package/dist/esm/excel/conditional-format.js +25 -0
- package/dist/esm/excel/defined-name-ref.d.ts +21 -0
- package/dist/esm/excel/defined-name-ref.js +20 -0
- package/dist/esm/excel/form-control-parser.d.ts +13 -0
- package/dist/esm/excel/form-control-parser.js +5 -0
- package/dist/esm/excel/formula/context.d.ts +37 -0
- package/dist/esm/excel/formula/dates.d.ts +23 -0
- package/dist/esm/excel/formula/dates.js +20 -0
- package/dist/esm/excel/formula/eval.d.ts +21 -0
- package/dist/esm/excel/formula/eval.js +11 -0
- package/dist/esm/excel/formula/functions.d.ts +12 -0
- package/dist/esm/excel/formula/functions.js +12 -0
- package/dist/esm/excel/formula/index.d.ts +21 -0
- package/dist/esm/excel/formula/index.js +16 -0
- package/dist/esm/excel/formula/lexer.d.ts +12 -0
- package/dist/esm/excel/formula/lexer.js +10 -0
- package/dist/esm/excel/formula/parser.d.ts +20 -0
- package/dist/esm/excel/formula/parser.js +53 -0
- package/dist/esm/excel/formula/value.d.ts +53 -0
- package/dist/esm/excel/formula/value.js +30 -0
- package/dist/esm/excel/header-footer.d.ts +9 -0
- package/dist/esm/excel/header-footer.js +9 -0
- package/dist/esm/excel/number-format.d.ts +34 -0
- package/dist/esm/excel/number-format.js +34 -0
- package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
- package/dist/esm/excel/pivot-table-parser.js +8 -0
- package/dist/esm/excel/print-model.d.ts +77 -1
- package/dist/esm/excel/print-model.js +230 -26
- package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
- package/dist/esm/excel/shared-strings-parser.js +5 -0
- package/dist/esm/excel/sheet-drawing.d.ts +34 -0
- package/dist/esm/excel/sheet-drawing.js +21 -0
- package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
- package/dist/esm/excel/sheet-shape-parser.js +12 -0
- package/dist/esm/excel/sheet-to-flow.d.ts +29 -0
- package/dist/esm/excel/sheet-to-flow.js +24 -7
- package/dist/esm/excel/slicer-parser.d.ts +23 -0
- package/dist/esm/excel/slicer-parser.js +10 -0
- package/dist/esm/excel/styles-parser.d.ts +8 -0
- package/dist/esm/excel/styles-parser.js +8 -0
- package/dist/esm/excel/table-parser.d.ts +24 -0
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/workbook-parser.d.ts +17 -0
- package/dist/esm/excel/workbook-parser.js +5 -0
- package/dist/esm/excel/worksheet-parser.d.ts +9 -0
- package/dist/esm/excel/worksheet-parser.js +39 -6
- package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
- package/dist/esm/excel/xls/biff-chart.js +10 -0
- package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
- package/dist/esm/excel/xls/biff-reader.js +44 -0
- package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
- package/dist/esm/excel/xls/biff-styles.js +20 -0
- package/dist/esm/excel/xls/escher.d.ts +27 -0
- package/dist/esm/excel/xls/escher.js +18 -0
- package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
- package/dist/esm/excel/xls/xls-reader.js +6 -0
- package/dist/esm/excel/xlsx-reader.d.ts +30 -0
- package/dist/esm/excel/xlsx-reader.js +38 -4
- package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
- package/dist/esm/excel/xlsx-writer.d.ts +14 -0
- package/dist/esm/excel/xlsx-writer.js +13 -0
- package/dist/esm/html/html-writer.d.ts +18 -0
- package/dist/esm/html/html-writer.js +18 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/layout/math-layout.d.ts +39 -0
- package/dist/esm/layout/math-layout.js +18 -0
- package/dist/esm/layout/page-doc.d.ts +91 -0
- package/dist/esm/layout/styled-layout.d.ts +175 -0
- package/dist/esm/layout/styled-layout.js +136 -4
- package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
- package/dist/esm/pdf/cid-font.d.ts +22 -0
- package/dist/esm/pdf/cid-font.js +10 -0
- package/dist/esm/pdf/embedded-file.d.ts +16 -0
- package/dist/esm/pdf/embedded-file.js +9 -0
- package/dist/esm/pdf/encryption.d.ts +59 -0
- package/dist/esm/pdf/encryption.js +37 -0
- package/dist/esm/pdf/icc-profile.d.ts +8 -0
- package/dist/esm/pdf/icc-profile.js +8 -0
- package/dist/esm/pdf/image-xobject.d.ts +19 -0
- package/dist/esm/pdf/image-xobject.js +9 -0
- package/dist/esm/pdf/objects.d.ts +40 -0
- package/dist/esm/pdf/objects.js +36 -0
- package/dist/esm/pdf/serialize.d.ts +18 -0
- package/dist/esm/pdf/serialize.js +18 -0
- package/dist/esm/pdf/shading.d.ts +16 -0
- package/dist/esm/pdf/shading.js +16 -0
- package/dist/esm/pdf/signature.d.ts +36 -0
- package/dist/esm/pdf/signature.js +22 -0
- package/dist/esm/pdf/struct-tree.d.ts +64 -0
- package/dist/esm/pdf/struct-tree.js +60 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
- package/dist/esm/pdf/styled-page-emitter.js +21 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
- package/dist/esm/pdf/styled-page-renderer.js +18 -0
- package/dist/esm/pdf/text-encoding.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
- package/dist/esm/pdf/vector-graphics.d.ts +12 -0
- package/dist/esm/pdf/vector-graphics.js +12 -0
- package/dist/esm/pdf/writer.d.ts +39 -0
- package/dist/esm/pdf/writer.js +27 -0
- package/dist/esm/pdf/xmp.d.ts +16 -0
- package/dist/esm/pdf/xmp.js +9 -0
- package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
- package/dist/esm/pdf-reader/ccitt.js +15 -0
- package/dist/esm/pdf-reader/cmap.d.ts +12 -0
- package/dist/esm/pdf-reader/cmap.js +9 -0
- package/dist/esm/pdf-reader/content.d.ts +69 -0
- package/dist/esm/pdf-reader/content.js +16 -0
- package/dist/esm/pdf-reader/crypto.d.ts +5 -0
- package/dist/esm/pdf-reader/crypto.js +5 -0
- package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
- package/dist/esm/pdf-reader/decrypt.js +12 -0
- package/dist/esm/pdf-reader/document.d.ts +53 -0
- package/dist/esm/pdf-reader/document.js +50 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +47 -0
- package/dist/esm/pdf-reader/flow-build.js +42 -0
- package/dist/esm/pdf-reader/font.d.ts +12 -0
- package/dist/esm/pdf-reader/font.js +12 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
- package/dist/esm/pdf-reader/image-decode.js +14 -0
- package/dist/esm/pdf-reader/images.d.ts +19 -0
- package/dist/esm/pdf-reader/images.js +9 -0
- package/dist/esm/pdf-reader/layout.d.ts +15 -0
- package/dist/esm/pdf-reader/layout.js +15 -0
- package/dist/esm/pdf-reader/lexer.d.ts +43 -0
- package/dist/esm/pdf-reader/lexer.js +38 -0
- package/dist/esm/pdf-reader/parser.d.ts +15 -0
- package/dist/esm/pdf-reader/parser.js +8 -0
- package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
- package/dist/esm/pdf-reader/png-encode.js +8 -0
- package/dist/esm/pdf-reader/predictor.d.ts +9 -0
- package/dist/esm/pdf-reader/predictor.js +8 -0
- package/dist/esm/pdf-reader/reader.d.ts +16 -0
- package/dist/esm/pdf-reader/reader.js +16 -0
- package/dist/esm/pdf-reader/shading.d.ts +10 -0
- package/dist/esm/pdf-reader/shading.js +10 -0
- package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
- package/dist/esm/pdf-reader/struct-tree.js +12 -0
- package/dist/esm/pdf-reader/tagged.d.ts +13 -0
- package/dist/esm/pdf-reader/tagged.js +13 -0
- package/dist/esm/pdf-reader/text.d.ts +11 -0
- package/dist/esm/pdf-reader/text.js +11 -0
- package/dist/esm/pdf-reader/vector.d.ts +19 -0
- package/dist/esm/pdf-reader/vector.js +9 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
- package/dist/esm/pptx/placeholder-cascade.js +10 -0
- package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
- package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
- package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
- package/dist/esm/pptx/ppt/ppt-text.js +14 -0
- package/dist/esm/pptx/pptx-reader.d.ts +21 -0
- package/dist/esm/pptx/pptx-reader.js +23 -2
- package/dist/esm/pptx/slide-parser.d.ts +102 -0
- package/dist/esm/pptx/slide-parser.js +78 -0
- package/dist/esm/pptx/sp-helpers.d.ts +28 -0
- package/dist/esm/pptx/sp-helpers.js +22 -0
- package/dist/esm/svg/svg-writer.d.ts +17 -0
- package/dist/esm/svg/svg-writer.js +16 -0
- package/dist/esm/word/doc/doc-reader.d.ts +16 -0
- package/dist/esm/word/doc/doc-reader.js +16 -0
- package/dist/esm/word/doc/doc-text.d.ts +77 -0
- package/dist/esm/word/doc/doc-text.js +13 -0
- package/dist/esm/word/document-parser.d.ts +134 -0
- package/dist/esm/word/document-parser.js +86 -0
- package/dist/esm/word/docx-reader.d.ts +16 -0
- package/dist/esm/word/docx-reader.js +18 -2
- package/dist/esm/word/docx-to-pdf.d.ts +52 -0
- package/dist/esm/word/docx-to-pdf.js +21 -0
- package/dist/esm/word/docx-writer.d.ts +17 -0
- package/dist/esm/word/docx-writer.js +17 -0
- package/dist/esm/word/drawing-parser.d.ts +88 -0
- package/dist/esm/word/drawing-parser.js +68 -0
- package/dist/esm/word/font-table.d.ts +24 -0
- package/dist/esm/word/font-table.js +24 -0
- package/dist/esm/word/numbering-parser.d.ts +11 -0
- package/dist/esm/word/numbering-parser.js +11 -0
- package/dist/esm/word/omml-parser.d.ts +15 -0
- package/dist/esm/word/omml-parser.js +15 -0
- package/dist/esm/word/omml-serializer.d.ts +9 -0
- package/dist/esm/word/omml-serializer.js +9 -0
- package/dist/esm/word/paragraph-properties.d.ts +10 -0
- package/dist/esm/word/paragraph-properties.js +10 -0
- package/dist/esm/word/po-to-flat.d.ts +11 -0
- package/dist/esm/word/po-to-flat.js +11 -0
- package/dist/esm/word/run-properties.d.ts +10 -0
- package/dist/esm/word/run-properties.js +10 -0
- package/dist/esm/word/settings-parser.d.ts +13 -0
- package/dist/esm/word/settings-parser.js +8 -0
- package/dist/esm/word/styles-parser.d.ts +10 -0
- package/dist/esm/word/styles-parser.js +10 -0
- package/dist/esm/word/table-parser.d.ts +11 -0
- package/dist/esm/word/table-parser.js +11 -0
- package/dist/esm/word/text-extractor.d.ts +9 -0
- package/dist/esm/word/xml-helpers.d.ts +44 -0
- package/dist/esm/word/xml-helpers.js +38 -0
- package/package.json +5 -2
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { BodyElement, StyleSheet } from '../document-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Apply table styles across a body (ECMA-376 §17.7.6): for each table, fold its
|
|
4
|
+
* `basedOn` chain and apply the base + `tblLook`-gated conditional region layers
|
|
5
|
+
* to every cell's chrome (shading, borders, margins) and run/paragraph text, as
|
|
6
|
+
* a fallback under direct formatting. Recurses into nested tables and shape
|
|
7
|
+
* text. Mutates the tree IN PLACE and returns it.
|
|
8
|
+
*/
|
|
2
9
|
export declare function resolveTableStyles(body: ReadonlyArray<BodyElement>, sheet: StyleSheet): ReadonlyArray<BodyElement>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
//#region src/core/style-cascade/table.ts
|
|
2
|
+
/**
|
|
3
|
+
* Apply table styles across a body (ECMA-376 §17.7.6): for each table, fold its
|
|
4
|
+
* `basedOn` chain and apply the base + `tblLook`-gated conditional region layers
|
|
5
|
+
* to every cell's chrome (shading, borders, margins) and run/paragraph text, as
|
|
6
|
+
* a fallback under direct formatting. Recurses into nested tables and shape
|
|
7
|
+
* text. Mutates the tree IN PLACE and returns it.
|
|
8
|
+
*/
|
|
2
9
|
function resolveTableStyles(body, sheet) {
|
|
3
10
|
const visit = (el) => {
|
|
4
11
|
if (el.kind === "table") {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Alignment, FontFamilyMap, NumberingReference, UnderlineStyle, VerticalAlign } from '../document-model/index.js';
|
|
2
2
|
import { Pt } from '../ir/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* A run's fully-resolved properties: every field required because the cascade
|
|
5
|
+
* has collapsed all inheritance against document defaults and the style chain.
|
|
6
|
+
* Consumed directly by the renderer.
|
|
7
|
+
*/
|
|
3
8
|
export interface ResolvedRunProperties {
|
|
4
9
|
readonly bold: boolean;
|
|
5
10
|
readonly italic: boolean;
|
|
@@ -10,8 +15,16 @@ export interface ResolvedRunProperties {
|
|
|
10
15
|
readonly fontFamily: FontFamilyMap;
|
|
11
16
|
readonly verticalAlign: VerticalAlign;
|
|
12
17
|
readonly rtl: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Natural language (`w:lang @w:val`). Optional — only set when the source
|
|
20
|
+
* specifies one; consumed by the tagged-PDF per-element `/Lang`, never layout.
|
|
21
|
+
*/
|
|
13
22
|
readonly lang?: string;
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A paragraph's fully-resolved properties: every field required, the cascade
|
|
26
|
+
* having collapsed all inheritance. Consumed directly by the renderer.
|
|
27
|
+
*/
|
|
15
28
|
export interface ResolvedParagraphProperties {
|
|
16
29
|
readonly alignment: Alignment;
|
|
17
30
|
readonly spacingBefore: Pt;
|
|
@@ -23,9 +36,23 @@ export interface ResolvedParagraphProperties {
|
|
|
23
36
|
readonly indentFirstLine: Pt;
|
|
24
37
|
readonly pageBreakBefore: boolean;
|
|
25
38
|
readonly bidi: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* ECMA-376 §17.3.1.20 — resolved outline level (0–8). Undefined = body text.
|
|
41
|
+
* Used only by tagged-PDF heading detection.
|
|
42
|
+
*/
|
|
26
43
|
readonly outlineLevel?: number;
|
|
44
|
+
/**
|
|
45
|
+
* The paragraph's style id (e.g. `"Heading2"`), carried through for heading
|
|
46
|
+
* detection when a style lacks an explicit outline level.
|
|
47
|
+
*/
|
|
27
48
|
readonly styleId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* §17.9 list reference, carried through for tagged-PDF list structure
|
|
51
|
+
* (L/LI nesting) — markers themselves are materialized by `applyNumbering`.
|
|
52
|
+
*/
|
|
28
53
|
readonly numbering?: NumberingReference;
|
|
29
54
|
}
|
|
55
|
+
/** Word's empty-document run defaults (used when `docDefaults` is absent). */
|
|
30
56
|
export declare const DEFAULT_RESOLVED_RUN: ResolvedRunProperties;
|
|
57
|
+
/** Word's empty-document paragraph defaults (used when `docDefaults` is absent). */
|
|
31
58
|
export declare const DEFAULT_RESOLVED_PARAGRAPH: ResolvedParagraphProperties;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { halfPtToPt, twipsToPt } from "../ir/units.js";
|
|
2
2
|
//#region src/core/style-cascade/types.ts
|
|
3
|
+
/** Word's empty-document run defaults (used when `docDefaults` is absent). */
|
|
3
4
|
var DEFAULT_RESOLVED_RUN = {
|
|
4
5
|
bold: false,
|
|
5
6
|
italic: false,
|
|
@@ -11,6 +12,7 @@ var DEFAULT_RESOLVED_RUN = {
|
|
|
11
12
|
verticalAlign: "baseline",
|
|
12
13
|
rtl: false
|
|
13
14
|
};
|
|
15
|
+
/** Word's empty-document paragraph defaults (used when `docDefaults` is absent). */
|
|
14
16
|
var DEFAULT_RESOLVED_PARAGRAPH = {
|
|
15
17
|
alignment: "left",
|
|
16
18
|
spacingBefore: twipsToPt(0),
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One drawing operator of a path, in the y-up local frame. The `op` discriminant
|
|
3
|
+
* mirrors the PDF path operators noted on each arm (`m`/`l`/`c`/`h`).
|
|
4
|
+
*/
|
|
1
5
|
export type PathSegment = {
|
|
2
6
|
readonly op: 'move';
|
|
3
7
|
readonly x: number;
|
|
@@ -17,41 +21,104 @@ export type PathSegment = {
|
|
|
17
21
|
} | {
|
|
18
22
|
readonly op: 'close';
|
|
19
23
|
};
|
|
24
|
+
/** A single subpath: a sequence of {@link PathSegment}s plus an optional fill rule. */
|
|
20
25
|
export interface VectorPath {
|
|
21
26
|
readonly segments: ReadonlyArray<PathSegment>;
|
|
27
|
+
/**
|
|
28
|
+
* Winding rule for filling (§8.5.3.3). Defaults to nonzero. `evenodd` selects
|
|
29
|
+
* the `*` painting variants (`f*`/`B*`).
|
|
30
|
+
*/
|
|
22
31
|
readonly fillRule?: 'nonzero' | 'evenodd';
|
|
23
32
|
}
|
|
33
|
+
/** A stroke description: colour, width, line cap/join and dash pattern. */
|
|
24
34
|
export interface StrokeStyle {
|
|
35
|
+
/** Stroke colour as 6-hex, no leading `#`. */
|
|
25
36
|
readonly colorHex: string;
|
|
26
37
|
readonly widthPt: number;
|
|
27
38
|
readonly cap?: 'butt' | 'round' | 'square';
|
|
28
39
|
readonly join?: 'miter' | 'round' | 'bevel';
|
|
40
|
+
/** Dash pattern in points (§8.4.3.6). Empty/omitted = solid line. */
|
|
29
41
|
readonly dash?: ReadonlyArray<number>;
|
|
30
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* One stop of a {@link ShapeGradient}: a colour pinned at a fractional `offset`
|
|
45
|
+
* along the gradient axis.
|
|
46
|
+
*/
|
|
31
47
|
export interface GradientStop {
|
|
48
|
+
/** Position along the gradient axis, `0..1`. */
|
|
32
49
|
readonly offset: number;
|
|
50
|
+
/** Stop colour as 6-hex, no leading `#`. */
|
|
33
51
|
readonly colorHex: string;
|
|
34
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A gradient fill — the format-agnostic vocabulary shared by the shape model
|
|
55
|
+
* (DrawingML `a:gradFill`) and the readers (PDF axial/radial shadings, EP16). A
|
|
56
|
+
* linear gradient runs along `angle` (degrees clockwise, 0 = left→right); a
|
|
57
|
+
* radial gradient runs centre→edge. Stops are sorted, offset `0..1`.
|
|
58
|
+
*/
|
|
35
59
|
export interface ShapeGradient {
|
|
36
60
|
readonly kind: 'linear' | 'radial';
|
|
61
|
+
/** Linear only: gradient direction in degrees clockwise (0 = left→right). */
|
|
37
62
|
readonly angle?: number;
|
|
38
63
|
readonly stops: ReadonlyArray<GradientStop>;
|
|
39
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* A drawable shape: one or more {@link VectorPath}s with a fill (solid or
|
|
67
|
+
* gradient), an optional stroke, and the CTM that maps its local frame onto the
|
|
68
|
+
* page.
|
|
69
|
+
*/
|
|
40
70
|
export interface VectorShape {
|
|
41
71
|
readonly paths: ReadonlyArray<VectorPath>;
|
|
72
|
+
/**
|
|
73
|
+
* Non-stroking fill colour (6-hex). Omitted = no fill. When `fillGradient` is
|
|
74
|
+
* present this carries its solid approximation (writers without gradient
|
|
75
|
+
* support, e.g. the plain PDF emitter, paint this instead).
|
|
76
|
+
*/
|
|
42
77
|
readonly fillColorHex?: string;
|
|
78
|
+
/**
|
|
79
|
+
* A gradient fill (EP16). Writers that support gradients (SVG) prefer this
|
|
80
|
+
* over `fillColorHex`.
|
|
81
|
+
*/
|
|
43
82
|
readonly fillGradient?: ShapeGradient;
|
|
83
|
+
/** Stroke description. Omitted = no stroke. */
|
|
44
84
|
readonly stroke?: StrokeStyle;
|
|
85
|
+
/**
|
|
86
|
+
* CTM applied via `cm` (§8.3.4): maps the local frame onto the page. The
|
|
87
|
+
* 6-tuple is `[a b c d e f]` of the matrix `[[a b 0][c d 0][e f 1]]`.
|
|
88
|
+
*/
|
|
45
89
|
readonly transform: readonly [number, number, number, number, number, number];
|
|
46
90
|
}
|
|
91
|
+
/** Fluent builder so geometry modules read like the shape they describe. */
|
|
47
92
|
export declare class PathBuilder {
|
|
48
93
|
private readonly segments;
|
|
94
|
+
/** Begin a new subpath at `(x, y)`. */
|
|
49
95
|
moveTo(x: number, y: number): this;
|
|
96
|
+
/** Add a straight segment to `(x, y)`. */
|
|
50
97
|
lineTo(x: number, y: number): this;
|
|
98
|
+
/** Add a cubic Bézier to `(x, y)` with control points `(x1, y1)` and `(x2, y2)`. */
|
|
51
99
|
cubicTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this;
|
|
100
|
+
/** Append already-built segments (e.g. an arc decomposed into cubics). */
|
|
52
101
|
append(segments: ReadonlyArray<PathSegment>): this;
|
|
102
|
+
/** Close the current subpath back to its start. */
|
|
53
103
|
close(): this;
|
|
104
|
+
/** Snapshot the accumulated segments as a {@link VectorPath}. */
|
|
54
105
|
build(fillRule?: 'nonzero' | 'evenodd'): VectorPath;
|
|
55
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Compose the page flip with a local→page CTM built in the y-up frame, so the
|
|
109
|
+
* stored transform targets the top-left frame the PageDoc schema froze on.
|
|
110
|
+
* The flip is an involution: the PDF emitter applies the same operation to
|
|
111
|
+
* recover the y-up matrix. Negating the linear part only flips sign bits
|
|
112
|
+
* (exact in IEEE 754); the y-translation is the one component that re-rounds.
|
|
113
|
+
*
|
|
114
|
+
* @param m The local→page CTM 6-tuple `[a b c d e f]`.
|
|
115
|
+
* @param pageHeight The page height the y-translation flips about.
|
|
116
|
+
*/
|
|
56
117
|
export declare function flipTransform(m: readonly [number, number, number, number, number, number], pageHeight: number): [number, number, number, number, number, number];
|
|
118
|
+
/**
|
|
119
|
+
* SVG path-data string from `segments`, in raw coordinates (the caller's
|
|
120
|
+
* transform maps the local frame into the target one).
|
|
121
|
+
*
|
|
122
|
+
* @param fmt Number formatter applied to every coordinate.
|
|
123
|
+
*/
|
|
57
124
|
export declare function svgPathData(segments: ReadonlyArray<PathSegment>, fmt: (n: number) => string): string;
|
package/dist/esm/core/vector.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
//#region src/core/vector.ts
|
|
2
|
+
/** Fluent builder so geometry modules read like the shape they describe. */
|
|
2
3
|
var PathBuilder = class {
|
|
3
4
|
segments = [];
|
|
5
|
+
/** Begin a new subpath at `(x, y)`. */
|
|
4
6
|
moveTo(x, y) {
|
|
5
7
|
this.segments.push({
|
|
6
8
|
op: "move",
|
|
@@ -9,6 +11,7 @@ var PathBuilder = class {
|
|
|
9
11
|
});
|
|
10
12
|
return this;
|
|
11
13
|
}
|
|
14
|
+
/** Add a straight segment to `(x, y)`. */
|
|
12
15
|
lineTo(x, y) {
|
|
13
16
|
this.segments.push({
|
|
14
17
|
op: "line",
|
|
@@ -17,6 +20,7 @@ var PathBuilder = class {
|
|
|
17
20
|
});
|
|
18
21
|
return this;
|
|
19
22
|
}
|
|
23
|
+
/** Add a cubic Bézier to `(x, y)` with control points `(x1, y1)` and `(x2, y2)`. */
|
|
20
24
|
cubicTo(x1, y1, x2, y2, x, y) {
|
|
21
25
|
this.segments.push({
|
|
22
26
|
op: "cubic",
|
|
@@ -29,14 +33,17 @@ var PathBuilder = class {
|
|
|
29
33
|
});
|
|
30
34
|
return this;
|
|
31
35
|
}
|
|
36
|
+
/** Append already-built segments (e.g. an arc decomposed into cubics). */
|
|
32
37
|
append(segments) {
|
|
33
38
|
for (const s of segments) this.segments.push(s);
|
|
34
39
|
return this;
|
|
35
40
|
}
|
|
41
|
+
/** Close the current subpath back to its start. */
|
|
36
42
|
close() {
|
|
37
43
|
this.segments.push({ op: "close" });
|
|
38
44
|
return this;
|
|
39
45
|
}
|
|
46
|
+
/** Snapshot the accumulated segments as a {@link VectorPath}. */
|
|
40
47
|
build(fillRule) {
|
|
41
48
|
return {
|
|
42
49
|
segments: this.segments.slice(),
|
|
@@ -44,6 +51,16 @@ var PathBuilder = class {
|
|
|
44
51
|
};
|
|
45
52
|
}
|
|
46
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Compose the page flip with a local→page CTM built in the y-up frame, so the
|
|
56
|
+
* stored transform targets the top-left frame the PageDoc schema froze on.
|
|
57
|
+
* The flip is an involution: the PDF emitter applies the same operation to
|
|
58
|
+
* recover the y-up matrix. Negating the linear part only flips sign bits
|
|
59
|
+
* (exact in IEEE 754); the y-translation is the one component that re-rounds.
|
|
60
|
+
*
|
|
61
|
+
* @param m The local→page CTM 6-tuple `[a b c d e f]`.
|
|
62
|
+
* @param pageHeight The page height the y-translation flips about.
|
|
63
|
+
*/
|
|
47
64
|
function flipTransform(m, pageHeight) {
|
|
48
65
|
return [
|
|
49
66
|
m[0],
|
|
@@ -54,6 +71,12 @@ function flipTransform(m, pageHeight) {
|
|
|
54
71
|
pageHeight - m[5]
|
|
55
72
|
];
|
|
56
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* SVG path-data string from `segments`, in raw coordinates (the caller's
|
|
76
|
+
* transform maps the local frame into the target one).
|
|
77
|
+
*
|
|
78
|
+
* @param fmt Number formatter applied to every coordinate.
|
|
79
|
+
*/
|
|
57
80
|
function svgPathData(segments, fmt) {
|
|
58
81
|
const parts = [];
|
|
59
82
|
for (const s of segments) if (s.op === "move") parts.push(`M ${fmt(s.x)} ${fmt(s.y)}`);
|
|
@@ -1,9 +1,40 @@
|
|
|
1
|
+
/** An ActiveX control's visible state from its property bag / binary stream (E-SHEET W10). */
|
|
1
2
|
export interface ActiveXProps {
|
|
3
|
+
/** The control's displayed text (CommandButton/Label/CheckBox/OptionButton). */
|
|
2
4
|
readonly caption?: string;
|
|
5
|
+
/**
|
|
6
|
+
* The control's state/value as persisted (`"1"`/`"0"` for a checkbox/option, the
|
|
7
|
+
* text for a textbox, a number for a spin/scroll).
|
|
8
|
+
*/
|
|
3
9
|
readonly value?: string;
|
|
10
|
+
/** OptionButton group membership (mutually-exclusive set). */
|
|
4
11
|
readonly groupName?: string;
|
|
5
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse a `xl/activeX/activeX#.xml` part (an `<ax:ocx>` whose `<ax:ocxPr name
|
|
15
|
+
* value>` children persist the visible state) into {@link ActiveXProps}. Reads the
|
|
16
|
+
* caption / value / group name; returns `{}` for a non-property-bag control.
|
|
17
|
+
*/
|
|
6
18
|
export declare function parseActiveX(data: Uint8Array): ActiveXProps;
|
|
19
|
+
/**
|
|
20
|
+
* Map an ActiveX `<oleObject progId>` to the affordance key the projection switches
|
|
21
|
+
* on: `Forms.CheckBox.1 → 'checkbox'`, `Forms.CommandButton.1 → 'button'`, …. An
|
|
22
|
+
* unknown progId falls back to a generic `'control'`.
|
|
23
|
+
*/
|
|
7
24
|
export declare function activeXType(progId: string | undefined): string;
|
|
25
|
+
/**
|
|
26
|
+
* The `<ax:ocx r:id>` of a control whose state is persisted to a binary stream
|
|
27
|
+
* (`persistStreamInit` / `persistStream` / `persistStorage`) rather than to
|
|
28
|
+
* `<ax:ocxPr>`; the reader resolves it (through the `activeX#.xml` part's own
|
|
29
|
+
* relationships) to the `activeX#.bin`. Returns undefined for a property-bag
|
|
30
|
+
* control (the `.bin` is not needed).
|
|
31
|
+
*/
|
|
8
32
|
export declare function activeXBinRelId(xmlData: Uint8Array): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Parse an `activeX#.bin` (a `persistStreamInit` MorphDataControl) for its caption,
|
|
35
|
+
* value and group name, per [MS-OFORMS] §2.2.5. Returns `{}` for any non-MorphData
|
|
36
|
+
* stream (a CFB storage, a CommandButton/Label, a structurally implausible blob) —
|
|
37
|
+
* a graceful miss, never a wrong caption. Bounds-checked throughout; any overflow
|
|
38
|
+
* bails to `{}`.
|
|
39
|
+
*/
|
|
9
40
|
export declare function parseActiveXBin(data: Uint8Array): ActiveXProps;
|
|
@@ -7,6 +7,11 @@ var parser = new XMLParser({
|
|
|
7
7
|
parseAttributeValue: false,
|
|
8
8
|
removeNSPrefix: true
|
|
9
9
|
});
|
|
10
|
+
/**
|
|
11
|
+
* Parse a `xl/activeX/activeX#.xml` part (an `<ax:ocx>` whose `<ax:ocxPr name
|
|
12
|
+
* value>` children persist the visible state) into {@link ActiveXProps}. Reads the
|
|
13
|
+
* caption / value / group name; returns `{}` for a non-property-bag control.
|
|
14
|
+
*/
|
|
10
15
|
function parseActiveX(data) {
|
|
11
16
|
const ocx = asObject(parser.parse(decoder.decode(data))["ocx"]);
|
|
12
17
|
if (!ocx) return {};
|
|
@@ -26,6 +31,11 @@ function parseActiveX(data) {
|
|
|
26
31
|
...groupName !== void 0 ? { groupName } : {}
|
|
27
32
|
};
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Map an ActiveX `<oleObject progId>` to the affordance key the projection switches
|
|
36
|
+
* on: `Forms.CheckBox.1 → 'checkbox'`, `Forms.CommandButton.1 → 'button'`, …. An
|
|
37
|
+
* unknown progId falls back to a generic `'control'`.
|
|
38
|
+
*/
|
|
29
39
|
function activeXType(progId) {
|
|
30
40
|
switch ((/Forms\.(\w+)\.\d+/i.exec(progId ?? "")?.[1] ?? "").toLowerCase()) {
|
|
31
41
|
case "checkbox": return "checkbox";
|
|
@@ -52,6 +62,13 @@ function strAttr(obj, key) {
|
|
|
52
62
|
const v = obj[`@_${key}`];
|
|
53
63
|
return typeof v === "string" ? v : void 0;
|
|
54
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* The `<ax:ocx r:id>` of a control whose state is persisted to a binary stream
|
|
67
|
+
* (`persistStreamInit` / `persistStream` / `persistStorage`) rather than to
|
|
68
|
+
* `<ax:ocxPr>`; the reader resolves it (through the `activeX#.xml` part's own
|
|
69
|
+
* relationships) to the `activeX#.bin`. Returns undefined for a property-bag
|
|
70
|
+
* control (the `.bin` is not needed).
|
|
71
|
+
*/
|
|
55
72
|
function activeXBinRelId(xmlData) {
|
|
56
73
|
const ocx = asObject(parser.parse(decoder.decode(xmlData))["ocx"]);
|
|
57
74
|
if (!ocx) return void 0;
|
|
@@ -112,6 +129,13 @@ function u16le(d, i) {
|
|
|
112
129
|
function u32le(d, i) {
|
|
113
130
|
return (d[i] | d[i + 1] << 8 | d[i + 2] << 16 | d[i + 3] << 24) >>> 0;
|
|
114
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Parse an `activeX#.bin` (a `persistStreamInit` MorphDataControl) for its caption,
|
|
134
|
+
* value and group name, per [MS-OFORMS] §2.2.5. Returns `{}` for any non-MorphData
|
|
135
|
+
* stream (a CFB storage, a CommandButton/Label, a structurally implausible blob) —
|
|
136
|
+
* a graceful miss, never a wrong caption. Bounds-checked throughout; any overflow
|
|
137
|
+
* bails to `{}`.
|
|
138
|
+
*/
|
|
115
139
|
function parseActiveXBin(data) {
|
|
116
140
|
if (data.length >= 8 && CFB_MAGIC.every((b, i) => data[i] === b)) return {};
|
|
117
141
|
let off;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
/** A 0-indexed cell address (`A1` → `{ column: 0, row: 0 }`). */
|
|
1
2
|
export interface CellAddress {
|
|
2
3
|
readonly column: number;
|
|
3
4
|
readonly row: number;
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Parse an A1-style cell reference (§18.18.62) into a 0-indexed {@link CellAddress}.
|
|
8
|
+
* The column letters are base-26 (`A`=1 … `Z`=26, `AA`=27, …); the row is a plain
|
|
9
|
+
* 1-indexed integer. Both are decremented to 0-indexed on the way out.
|
|
10
|
+
*
|
|
11
|
+
* @param ref The reference, e.g. `"AB12"` (case-insensitive column letters).
|
|
12
|
+
* @returns The 0-indexed column/row.
|
|
13
|
+
* @throws Error when `ref` has no column letters or a non-positive-integer row.
|
|
14
|
+
*/
|
|
5
15
|
export declare function parseCellRef(ref: string): CellAddress;
|
|
16
|
+
/**
|
|
17
|
+
* Format a 0-indexed {@link CellAddress} back to an A1-style reference — the
|
|
18
|
+
* inverse of {@link parseCellRef} (`{ column: 0, row: 0 }` → `"A1"`).
|
|
19
|
+
*/
|
|
6
20
|
export declare function formatCellRef(address: CellAddress): string;
|
|
@@ -3,6 +3,15 @@ var A = 65;
|
|
|
3
3
|
var Z = 90;
|
|
4
4
|
var a = 97;
|
|
5
5
|
var z = 122;
|
|
6
|
+
/**
|
|
7
|
+
* Parse an A1-style cell reference (§18.18.62) into a 0-indexed {@link CellAddress}.
|
|
8
|
+
* The column letters are base-26 (`A`=1 … `Z`=26, `AA`=27, …); the row is a plain
|
|
9
|
+
* 1-indexed integer. Both are decremented to 0-indexed on the way out.
|
|
10
|
+
*
|
|
11
|
+
* @param ref The reference, e.g. `"AB12"` (case-insensitive column letters).
|
|
12
|
+
* @returns The 0-indexed column/row.
|
|
13
|
+
* @throws Error when `ref` has no column letters or a non-positive-integer row.
|
|
14
|
+
*/
|
|
6
15
|
function parseCellRef(ref) {
|
|
7
16
|
let i = 0;
|
|
8
17
|
let column = 0;
|
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { BodyElement, TableProperties, TableRow } from '../core/document-model/index.js';
|
|
2
|
+
/** A contiguous run of columns that prints together as one band (E-SHEET SE1). */
|
|
2
3
|
export interface ColumnBand {
|
|
4
|
+
/** First local column index (inclusive). */
|
|
3
5
|
readonly start: number;
|
|
6
|
+
/** Last local column index (inclusive). */
|
|
4
7
|
readonly end: number;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Greedy fill: accumulate column widths until the next column would overflow the
|
|
11
|
+
* content width, then start a new band. A manual column break (`colBreaks` holds
|
|
12
|
+
* local indices that begin a new page) always starts a new band. Every band keeps
|
|
13
|
+
* at least one column — a single column wider than the page stands alone (the
|
|
14
|
+
* layout shrinks it, the one case where fitting is unavoidable).
|
|
15
|
+
*
|
|
16
|
+
* @param columnWidths Per-column widths in twips, by local index.
|
|
17
|
+
* @param contentWidthTwips The printable content width one band must fit within.
|
|
18
|
+
* @param colBreaks Local column indices that force a new band.
|
|
19
|
+
* @returns The bands in left-to-right order.
|
|
20
|
+
*/
|
|
6
21
|
export declare function computeColumnBands(columnWidths: ReadonlyArray<number>, contentWidthTwips: number, colBreaks: ReadonlySet<number>): Array<ColumnBand>;
|
|
22
|
+
/**
|
|
23
|
+
* Build one table {@link BodyElement} per band from the fully materialised rows +
|
|
24
|
+
* column widths (twips, local index). Bands after the first force a page break
|
|
25
|
+
* before their first row, so each band starts on a fresh page. A horizontal span
|
|
26
|
+
* that crosses a band boundary is clipped to the band it starts in; later bands
|
|
27
|
+
* render the overlapped columns blank, matching Excel's split-at-the-break
|
|
28
|
+
* behaviour.
|
|
29
|
+
*
|
|
30
|
+
* @param rows The full sheet rows (every band slices the same rows).
|
|
31
|
+
* @param columnWidths Per-column widths in twips, by local index.
|
|
32
|
+
* @param bands The bands from {@link computeColumnBands}.
|
|
33
|
+
* @param properties The shared table properties applied to every band.
|
|
34
|
+
* @returns One table body element per band, in band order.
|
|
35
|
+
*/
|
|
7
36
|
export declare function bandedTables(rows: ReadonlyArray<TableRow>, columnWidths: ReadonlyArray<number>, bands: ReadonlyArray<ColumnBand>, properties: TableProperties): Array<BodyElement>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { twipsToPt } from "../core/ir/units.js";
|
|
2
2
|
//#region src/excel/column-bands.ts
|
|
3
|
+
/**
|
|
4
|
+
* Greedy fill: accumulate column widths until the next column would overflow the
|
|
5
|
+
* content width, then start a new band. A manual column break (`colBreaks` holds
|
|
6
|
+
* local indices that begin a new page) always starts a new band. Every band keeps
|
|
7
|
+
* at least one column — a single column wider than the page stands alone (the
|
|
8
|
+
* layout shrinks it, the one case where fitting is unavoidable).
|
|
9
|
+
*
|
|
10
|
+
* @param columnWidths Per-column widths in twips, by local index.
|
|
11
|
+
* @param contentWidthTwips The printable content width one band must fit within.
|
|
12
|
+
* @param colBreaks Local column indices that force a new band.
|
|
13
|
+
* @returns The bands in left-to-right order.
|
|
14
|
+
*/
|
|
3
15
|
function computeColumnBands(columnWidths, contentWidthTwips, colBreaks) {
|
|
4
16
|
const n = columnWidths.length;
|
|
5
17
|
if (n === 0) return [];
|
|
@@ -26,6 +38,20 @@ function computeColumnBands(columnWidths, contentWidthTwips, colBreaks) {
|
|
|
26
38
|
});
|
|
27
39
|
return bands;
|
|
28
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Build one table {@link BodyElement} per band from the fully materialised rows +
|
|
43
|
+
* column widths (twips, local index). Bands after the first force a page break
|
|
44
|
+
* before their first row, so each band starts on a fresh page. A horizontal span
|
|
45
|
+
* that crosses a band boundary is clipped to the band it starts in; later bands
|
|
46
|
+
* render the overlapped columns blank, matching Excel's split-at-the-break
|
|
47
|
+
* behaviour.
|
|
48
|
+
*
|
|
49
|
+
* @param rows The full sheet rows (every band slices the same rows).
|
|
50
|
+
* @param columnWidths Per-column widths in twips, by local index.
|
|
51
|
+
* @param bands The bands from {@link computeColumnBands}.
|
|
52
|
+
* @param properties The shared table properties applied to every band.
|
|
53
|
+
* @returns One table body element per band, in band order.
|
|
54
|
+
*/
|
|
29
55
|
function bandedTables(rows, columnWidths, bands, properties) {
|
|
30
56
|
return bands.map((band, bandIndex) => {
|
|
31
57
|
return {
|
|
@@ -74,13 +100,7 @@ function withColSpan(cell, span) {
|
|
|
74
100
|
function blankCell(span) {
|
|
75
101
|
return {
|
|
76
102
|
properties: span > 1 ? { colSpan: span } : {},
|
|
77
|
-
content: [
|
|
78
|
-
kind: "paragraph",
|
|
79
|
-
paragraph: {
|
|
80
|
-
properties: {},
|
|
81
|
-
runs: []
|
|
82
|
-
}
|
|
83
|
-
}]
|
|
103
|
+
content: []
|
|
84
104
|
};
|
|
85
105
|
}
|
|
86
106
|
//#endregion
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { SheetComment } from '../core/ir/sheet.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a legacy `xl/comments#.xml` part (§18.7.3/§18.7.6) into {@link SheetComment}s.
|
|
4
|
+
* `authorId` indexes the `<authors>` list; the text is rich (`<r><t>`) so it
|
|
5
|
+
* flattens like a shared string. Excel stores a bold "Author:\n" run at the head
|
|
6
|
+
* of the text — stripped here so the resolved author is not shown twice.
|
|
7
|
+
*/
|
|
2
8
|
export declare function parseLegacyComments(data: Uint8Array): Array<SheetComment>;
|
|
9
|
+
/**
|
|
10
|
+
* Parse `xl/persons/person.xml` into an `id → displayName` map, used to resolve
|
|
11
|
+
* the authors of threaded comments.
|
|
12
|
+
*/
|
|
3
13
|
export declare function parsePersons(data: Uint8Array): Map<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Parse a modern `xl/threadedComments/threadedComment#.xml` part (a conversation)
|
|
16
|
+
* into {@link SheetComment}s. Each entry is one message (replies share the `ref`);
|
|
17
|
+
* `personId` resolves through `persons`. Entries are returned in document order so
|
|
18
|
+
* a thread reads top to bottom.
|
|
19
|
+
*
|
|
20
|
+
* @param data The threaded-comments part bytes.
|
|
21
|
+
* @param persons The `id → displayName` map from {@link parsePersons}.
|
|
22
|
+
*/
|
|
4
23
|
export declare function parseThreadedComments(data: Uint8Array, persons: ReadonlyMap<string, string>): Array<SheetComment>;
|
|
@@ -10,6 +10,12 @@ var parser = new XMLParser({
|
|
|
10
10
|
trimValues: false,
|
|
11
11
|
removeNSPrefix: true
|
|
12
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* Parse a legacy `xl/comments#.xml` part (§18.7.3/§18.7.6) into {@link SheetComment}s.
|
|
15
|
+
* `authorId` indexes the `<authors>` list; the text is rich (`<r><t>`) so it
|
|
16
|
+
* flattens like a shared string. Excel stores a bold "Author:\n" run at the head
|
|
17
|
+
* of the text — stripped here so the resolved author is not shown twice.
|
|
18
|
+
*/
|
|
13
19
|
function parseLegacyComments(data) {
|
|
14
20
|
const root = asObject(parser.parse(decoder.decode(data))["comments"]);
|
|
15
21
|
if (!root) return [];
|
|
@@ -33,6 +39,10 @@ function parseLegacyComments(data) {
|
|
|
33
39
|
}
|
|
34
40
|
return out;
|
|
35
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Parse `xl/persons/person.xml` into an `id → displayName` map, used to resolve
|
|
44
|
+
* the authors of threaded comments.
|
|
45
|
+
*/
|
|
36
46
|
function parsePersons(data) {
|
|
37
47
|
const root = asObject(parser.parse(decoder.decode(data))["personList"]);
|
|
38
48
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -45,6 +55,15 @@ function parsePersons(data) {
|
|
|
45
55
|
}
|
|
46
56
|
return map;
|
|
47
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse a modern `xl/threadedComments/threadedComment#.xml` part (a conversation)
|
|
60
|
+
* into {@link SheetComment}s. Each entry is one message (replies share the `ref`);
|
|
61
|
+
* `personId` resolves through `persons`. Entries are returned in document order so
|
|
62
|
+
* a thread reads top to bottom.
|
|
63
|
+
*
|
|
64
|
+
* @param data The threaded-comments part bytes.
|
|
65
|
+
* @param persons The `id → displayName` map from {@link parsePersons}.
|
|
66
|
+
*/
|
|
48
67
|
function parseThreadedComments(data, persons) {
|
|
49
68
|
const root = asObject(parser.parse(decoder.decode(data))["ThreadedComments"]);
|
|
50
69
|
if (!root) return [];
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { CellIcon } from '../core/document-model/index.js';
|
|
2
2
|
import { ConditionalFormat, DefinedName, WorksheetCell, XlsxStyles } from '../core/spreadsheet-model/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* A resolved per-cell override the print model layers over a cell's base format: a
|
|
5
|
+
* solid highlight fill, font tweaks, an in-cell data bar (fraction of the cell
|
|
6
|
+
* width 0..1 + colour), and/or a leading icon.
|
|
7
|
+
*/
|
|
3
8
|
export interface CfOverride {
|
|
4
9
|
readonly fillHex?: string;
|
|
5
10
|
readonly fontColorHex?: string;
|
|
6
11
|
readonly bold?: boolean;
|
|
7
12
|
readonly italic?: boolean;
|
|
13
|
+
/** An in-cell data bar: its fraction of the cell width, colour, and optional left offset. */
|
|
8
14
|
readonly dataBar?: {
|
|
9
15
|
readonly fraction: number;
|
|
10
16
|
readonly colorHex: string;
|
|
@@ -12,7 +18,39 @@ export interface CfOverride {
|
|
|
12
18
|
};
|
|
13
19
|
readonly icon?: CellIcon;
|
|
14
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A per-cell lookup returning the {@link CfOverride} for the cell at `(row, col)`,
|
|
23
|
+
* or undefined when no rule applies. `numericValue` is the cell's comparable number
|
|
24
|
+
* (undefined for non-numeric cells); `text` is its resolved string — needed by the
|
|
25
|
+
* text tests and to key duplicate / unique comparisons for non-numeric cells
|
|
26
|
+
* (empty/undefined for a blank cell).
|
|
27
|
+
*/
|
|
15
28
|
export type CellConditionalFormatter = (row: number, col: number, numericValue: number | undefined, text: string | undefined) => CfOverride | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Compile a sheet's `<conditionalFormatting>` rules + the workbook's `<dxfs>` into
|
|
31
|
+
* a per-cell {@link CellConditionalFormatter}. Returns undefined when the sheet has
|
|
32
|
+
* no conditional formats (the common case) so callers skip the work entirely and
|
|
33
|
+
* stay byte-identical.
|
|
34
|
+
*
|
|
35
|
+
* @param conditionalFormats The sheet's rules; undefined/empty ⇒ no formatter.
|
|
36
|
+
* @param styles The workbook style table (its `dxfs` supply the highlights).
|
|
37
|
+
* @param cells The range values the extent rules need
|
|
38
|
+
* (min/max/percentile/mean/frequency); `cellIs` and the
|
|
39
|
+
* text tests ignore it.
|
|
40
|
+
* @param resolveText Resolves a cell's string value (shared strings / number
|
|
41
|
+
* format) for the duplicate/unique frequency map — numeric
|
|
42
|
+
* cells key by value without it, so it is only needed for
|
|
43
|
+
* text cells.
|
|
44
|
+
* @param date1904 The workbook date epoch (feeds the W9 formula engine).
|
|
45
|
+
* @param now An injected reference date — never the wall clock —
|
|
46
|
+
* driving `TODAY()`/`NOW()` and the `timePeriod` windows;
|
|
47
|
+
* absent ⇒ those constructs no-op (deterministic output).
|
|
48
|
+
* @param sheetGrids The whole workbook, for an `expression` rule that reaches
|
|
49
|
+
* another sheet (`Sheet2!A1`) or a defined name; absent ⇒
|
|
50
|
+
* same-sheet references only.
|
|
51
|
+
* @param currentSheet The rule sheet's name, for resolving sheet-local names.
|
|
52
|
+
* @param definedNames The workbook defined names visible to `expression` rules.
|
|
53
|
+
*/
|
|
16
54
|
export declare function buildConditionalFormatter(conditionalFormats: ReadonlyArray<ConditionalFormat> | undefined, styles: XlsxStyles, cells: ReadonlyArray<WorksheetCell>, resolveText?: (cell: WorksheetCell) => string, date1904?: boolean, now?: Date, sheetGrids?: ReadonlyMap<string, {
|
|
17
55
|
readonly cells: ReadonlyArray<WorksheetCell>;
|
|
18
56
|
}>, currentSheet?: string, definedNames?: ReadonlyArray<DefinedName>): CellConditionalFormatter | undefined;
|
|
@@ -3,6 +3,31 @@ import { BLANK, bool, err, num, str } from "./formula/value.js";
|
|
|
3
3
|
import { NO_SHIFT, evaluate } from "./formula/eval.js";
|
|
4
4
|
import { compileFormula, evaluateToBool } from "./formula/index.js";
|
|
5
5
|
//#region src/excel/conditional-format.ts
|
|
6
|
+
/**
|
|
7
|
+
* Compile a sheet's `<conditionalFormatting>` rules + the workbook's `<dxfs>` into
|
|
8
|
+
* a per-cell {@link CellConditionalFormatter}. Returns undefined when the sheet has
|
|
9
|
+
* no conditional formats (the common case) so callers skip the work entirely and
|
|
10
|
+
* stay byte-identical.
|
|
11
|
+
*
|
|
12
|
+
* @param conditionalFormats The sheet's rules; undefined/empty ⇒ no formatter.
|
|
13
|
+
* @param styles The workbook style table (its `dxfs` supply the highlights).
|
|
14
|
+
* @param cells The range values the extent rules need
|
|
15
|
+
* (min/max/percentile/mean/frequency); `cellIs` and the
|
|
16
|
+
* text tests ignore it.
|
|
17
|
+
* @param resolveText Resolves a cell's string value (shared strings / number
|
|
18
|
+
* format) for the duplicate/unique frequency map — numeric
|
|
19
|
+
* cells key by value without it, so it is only needed for
|
|
20
|
+
* text cells.
|
|
21
|
+
* @param date1904 The workbook date epoch (feeds the W9 formula engine).
|
|
22
|
+
* @param now An injected reference date — never the wall clock —
|
|
23
|
+
* driving `TODAY()`/`NOW()` and the `timePeriod` windows;
|
|
24
|
+
* absent ⇒ those constructs no-op (deterministic output).
|
|
25
|
+
* @param sheetGrids The whole workbook, for an `expression` rule that reaches
|
|
26
|
+
* another sheet (`Sheet2!A1`) or a defined name; absent ⇒
|
|
27
|
+
* same-sheet references only.
|
|
28
|
+
* @param currentSheet The rule sheet's name, for resolving sheet-local names.
|
|
29
|
+
* @param definedNames The workbook defined names visible to `expression` rules.
|
|
30
|
+
*/
|
|
6
31
|
function buildConditionalFormatter(conditionalFormats, styles, cells, resolveText, date1904 = false, now, sheetGrids, currentSheet, definedNames) {
|
|
7
32
|
if (!conditionalFormats || conditionalFormats.length === 0) return void 0;
|
|
8
33
|
const dxfs = styles.dxfs ?? [];
|