reamkit 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/esm/bidi/algorithm.d.ts +9 -0
- package/dist/esm/bidi/algorithm.js +458 -0
- package/dist/esm/bidi/char-types.d.ts +2 -0
- package/dist/esm/bidi/char-types.js +439 -0
- package/dist/esm/bidi/index.d.ts +14 -0
- package/dist/esm/bidi/index.js +25 -0
- package/dist/esm/converter/docx-to-pdf.d.ts +15 -0
- package/dist/esm/converter/docx-to-pdf.js +227 -0
- package/dist/esm/converter/index.d.ts +4 -0
- package/dist/esm/converter/index.js +2 -0
- package/dist/esm/converter/xlsx-to-pdf.d.ts +13 -0
- package/dist/esm/converter/xlsx-to-pdf.js +515 -0
- package/dist/esm/crypto/asn1.d.ts +23 -0
- package/dist/esm/crypto/asn1.js +123 -0
- package/dist/esm/crypto/cms.d.ts +9 -0
- package/dist/esm/crypto/cms.js +34 -0
- package/dist/esm/crypto/index.d.ts +2 -0
- package/dist/esm/crypto/index.js +1 -0
- package/dist/esm/document-model/index.d.ts +1 -0
- package/dist/esm/document-model/index.js +0 -0
- package/dist/esm/document-model/types.d.ts +403 -0
- package/dist/esm/font/arabic-joining.d.ts +4 -0
- package/dist/esm/font/arabic-joining.js +97 -0
- package/dist/esm/font/binary-reader.d.ts +13 -0
- package/dist/esm/font/binary-reader.js +44 -0
- package/dist/esm/font/font-registry.d.ts +19 -0
- package/dist/esm/font/font-registry.js +39 -0
- package/dist/esm/font/index.d.ts +7 -0
- package/dist/esm/font/opentype-layout.d.ts +21 -0
- package/dist/esm/font/opentype-layout.js +329 -0
- package/dist/esm/font/ttf-parser.d.ts +29 -0
- package/dist/esm/font/ttf-parser.js +290 -0
- package/dist/esm/font/ttf-subset.d.ts +3 -0
- package/dist/esm/font/ttf-subset.js +201 -0
- package/dist/esm/fonts/index.d.ts +2 -0
- package/dist/esm/fonts/remote-fonts.d.ts +13 -0
- package/dist/esm/fonts/remote-fonts.js +94 -0
- package/dist/esm/hyphenation/index.d.ts +10 -0
- package/dist/esm/hyphenation/index.js +38 -0
- package/dist/esm/hyphenation/liang.d.ts +10 -0
- package/dist/esm/hyphenation/liang.js +79 -0
- package/dist/esm/hyphenation/patterns-en-us.d.ts +2 -0
- package/dist/esm/hyphenation/patterns-en-us.js +5 -0
- package/dist/esm/hyphenation/patterns-ru.d.ts +2 -0
- package/dist/esm/hyphenation/patterns-ru.js +5 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/line-breaker/index.d.ts +2 -0
- package/dist/esm/line-breaker/knuth-plass.d.ts +30 -0
- package/dist/esm/line-breaker/knuth-plass.js +172 -0
- package/dist/esm/numbering/index.d.ts +1 -0
- package/dist/esm/numbering/state.d.ts +6 -0
- package/dist/esm/numbering/state.js +83 -0
- package/dist/esm/ooxml/drawingml/chart-parser.d.ts +3 -0
- package/dist/esm/ooxml/drawingml/chart-parser.js +218 -0
- package/dist/esm/ooxml/drawingml/colors.d.ts +17 -0
- package/dist/esm/ooxml/drawingml/colors.js +125 -0
- package/dist/esm/ooxml/drawingml/theme-parser.d.ts +1 -0
- package/dist/esm/ooxml/drawingml/theme-parser.js +55 -0
- package/dist/esm/ooxml/index.d.ts +1 -0
- package/dist/esm/ooxml/math/omml-parser.d.ts +4 -0
- package/dist/esm/ooxml/math/omml-parser.js +217 -0
- package/dist/esm/ooxml/spreadsheet/cell-reference.d.ts +6 -0
- package/dist/esm/ooxml/spreadsheet/cell-reference.js +26 -0
- package/dist/esm/ooxml/spreadsheet/defined-name-ref.d.ts +11 -0
- package/dist/esm/ooxml/spreadsheet/defined-name-ref.js +64 -0
- package/dist/esm/ooxml/spreadsheet/index.d.ts +12 -0
- package/dist/esm/ooxml/spreadsheet/index.js +7 -0
- package/dist/esm/ooxml/spreadsheet/number-format.d.ts +1 -0
- package/dist/esm/ooxml/spreadsheet/number-format.js +438 -0
- package/dist/esm/ooxml/spreadsheet/shared-strings-parser.d.ts +1 -0
- package/dist/esm/ooxml/spreadsheet/shared-strings-parser.js +47 -0
- package/dist/esm/ooxml/spreadsheet/styles-parser.d.ts +52 -0
- package/dist/esm/ooxml/spreadsheet/styles-parser.js +225 -0
- package/dist/esm/ooxml/spreadsheet/workbook-parser.d.ts +16 -0
- package/dist/esm/ooxml/spreadsheet/workbook-parser.js +90 -0
- package/dist/esm/ooxml/spreadsheet/worksheet-parser.d.ts +60 -0
- package/dist/esm/ooxml/spreadsheet/worksheet-parser.js +311 -0
- package/dist/esm/ooxml/wordproc/document-parser.d.ts +9 -0
- package/dist/esm/ooxml/wordproc/document-parser.js +274 -0
- package/dist/esm/ooxml/wordproc/drawing-parser.d.ts +33 -0
- package/dist/esm/ooxml/wordproc/drawing-parser.js +374 -0
- package/dist/esm/ooxml/wordproc/font-table.d.ts +15 -0
- package/dist/esm/ooxml/wordproc/font-table.js +82 -0
- package/dist/esm/ooxml/wordproc/index.d.ts +10 -0
- package/dist/esm/ooxml/wordproc/index.js +9 -0
- package/dist/esm/ooxml/wordproc/numbering-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/numbering-parser.js +89 -0
- package/dist/esm/ooxml/wordproc/paragraph-properties.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/paragraph-properties.js +85 -0
- package/dist/esm/ooxml/wordproc/po-helpers.d.ts +14 -0
- package/dist/esm/ooxml/wordproc/po-helpers.js +76 -0
- package/dist/esm/ooxml/wordproc/po-to-flat.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/po-to-flat.js +28 -0
- package/dist/esm/ooxml/wordproc/run-properties.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/run-properties.js +82 -0
- package/dist/esm/ooxml/wordproc/settings-parser.d.ts +5 -0
- package/dist/esm/ooxml/wordproc/settings-parser.js +26 -0
- package/dist/esm/ooxml/wordproc/styles-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/styles-parser.js +67 -0
- package/dist/esm/ooxml/wordproc/table-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/table-parser.js +162 -0
- package/dist/esm/ooxml/wordproc/text-extractor.d.ts +1 -0
- package/dist/esm/ooxml/wordproc/text-extractor.js +1 -0
- package/dist/esm/ooxml/wordproc/xml-helpers.d.ts +9 -0
- package/dist/esm/ooxml/wordproc/xml-helpers.js +36 -0
- package/dist/esm/opc/core-properties.d.ts +11 -0
- package/dist/esm/opc/core-properties.js +51 -0
- package/dist/esm/opc/index.d.ts +5 -0
- package/dist/esm/opc/index.js +3 -0
- package/dist/esm/opc/package.d.ts +26 -0
- package/dist/esm/opc/package.js +113 -0
- package/dist/esm/opc/relationship-types.d.ts +3 -0
- package/dist/esm/opc/relationship-types.js +4 -0
- package/dist/esm/opc/relationships.d.ts +7 -0
- package/dist/esm/opc/relationships.js +28 -0
- package/dist/esm/pdf/arc-to-bezier.d.ts +5 -0
- package/dist/esm/pdf/arc-to-bezier.js +58 -0
- package/dist/esm/pdf/builtin-fonts.d.ts +2 -0
- package/dist/esm/pdf/chart-geometry.d.ts +64 -0
- package/dist/esm/pdf/chart-geometry.js +674 -0
- package/dist/esm/pdf/cid-font.d.ts +15 -0
- package/dist/esm/pdf/cid-font.js +174 -0
- package/dist/esm/pdf/embedded-file.d.ts +11 -0
- package/dist/esm/pdf/embedded-file.js +23 -0
- package/dist/esm/pdf/icc-profile.d.ts +1 -0
- package/dist/esm/pdf/icc-profile.js +166 -0
- package/dist/esm/pdf/image-xobject.d.ts +13 -0
- package/dist/esm/pdf/image-xobject.js +335 -0
- package/dist/esm/pdf/index.d.ts +11 -0
- package/dist/esm/pdf/index.js +5 -0
- package/dist/esm/pdf/math-layout.d.ts +45 -0
- package/dist/esm/pdf/math-layout.js +1138 -0
- package/dist/esm/pdf/objects.d.ts +32 -0
- package/dist/esm/pdf/objects.js +54 -0
- package/dist/esm/pdf/preset-geometry.d.ts +6 -0
- package/dist/esm/pdf/preset-geometry.js +199 -0
- package/dist/esm/pdf/serialize.d.ts +3 -0
- package/dist/esm/pdf/serialize.js +54 -0
- package/dist/esm/pdf/signature.d.ts +25 -0
- package/dist/esm/pdf/signature.js +126 -0
- package/dist/esm/pdf/struct-tree.d.ts +31 -0
- package/dist/esm/pdf/struct-tree.js +109 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +43 -0
- package/dist/esm/pdf/styled-page-renderer.js +2317 -0
- package/dist/esm/pdf/text-encoding.d.ts +2 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.js +4 -0
- package/dist/esm/pdf/vector-graphics.d.ts +46 -0
- package/dist/esm/pdf/vector-graphics.js +103 -0
- package/dist/esm/pdf/writer.d.ts +10 -0
- package/dist/esm/pdf/writer.js +81 -0
- package/dist/esm/pdf/xmp.d.ts +13 -0
- package/dist/esm/pdf/xmp.js +38 -0
- package/dist/esm/style-cascade/index.d.ts +3 -0
- package/dist/esm/style-cascade/resolver.d.ts +4 -0
- package/dist/esm/style-cascade/resolver.js +96 -0
- package/dist/esm/style-cascade/types.d.ts +29 -0
- package/dist/esm/style-cascade/types.js +26 -0
- package/package.json +90 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { poChildren, poChildrenWith, poIs, poTag, poText, poToggle, poVal } from "../wordproc/po-helpers.js";
|
|
2
|
+
//#region src/ooxml/math/omml-parser.ts
|
|
3
|
+
function parseOMath(oMath) {
|
|
4
|
+
return {
|
|
5
|
+
type: "row",
|
|
6
|
+
children: parseMathSeq(poChildren(oMath))
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function parseMathSeq(children) {
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const child of children) {
|
|
12
|
+
const node = parseMathNode(child);
|
|
13
|
+
if (node) out.push(node);
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
function parseMathNode(node) {
|
|
18
|
+
switch (poTag(node)) {
|
|
19
|
+
case "m:r": return parseMathRun(node);
|
|
20
|
+
case "m:f": return parseFraction(node);
|
|
21
|
+
case "m:sSup": return parseScript(node, false, true);
|
|
22
|
+
case "m:sSub": return parseScript(node, true, false);
|
|
23
|
+
case "m:sSubSup": return parseScript(node, true, true);
|
|
24
|
+
case "m:sPre": return {
|
|
25
|
+
type: "script",
|
|
26
|
+
base: childRow(node, "m:e"),
|
|
27
|
+
sub: childRow(node, "m:sub"),
|
|
28
|
+
sup: childRow(node, "m:sup"),
|
|
29
|
+
pre: true
|
|
30
|
+
};
|
|
31
|
+
case "m:rad": return parseRadical(node);
|
|
32
|
+
case "m:nary": return parseNary(node);
|
|
33
|
+
case "m:func": return {
|
|
34
|
+
type: "func",
|
|
35
|
+
name: childRow(node, "m:fName"),
|
|
36
|
+
body: childRow(node, "m:e")
|
|
37
|
+
};
|
|
38
|
+
case "m:limLow": return {
|
|
39
|
+
type: "limit",
|
|
40
|
+
base: childRow(node, "m:e"),
|
|
41
|
+
lim: childRow(node, "m:lim"),
|
|
42
|
+
pos: "low"
|
|
43
|
+
};
|
|
44
|
+
case "m:limUpp": return {
|
|
45
|
+
type: "limit",
|
|
46
|
+
base: childRow(node, "m:e"),
|
|
47
|
+
lim: childRow(node, "m:lim"),
|
|
48
|
+
pos: "upp"
|
|
49
|
+
};
|
|
50
|
+
case "m:d": return parseDelimiter(node);
|
|
51
|
+
case "m:m": return parseMatrix(node);
|
|
52
|
+
case "m:eqArr": return parseEqArray(node);
|
|
53
|
+
case "m:acc": return parseAccent(node);
|
|
54
|
+
case "m:bar": return parseBar(node);
|
|
55
|
+
case "m:groupChr": return parseGroupChr(node);
|
|
56
|
+
case "m:rPr":
|
|
57
|
+
case "m:fPr":
|
|
58
|
+
case "m:ctrlPr": return null;
|
|
59
|
+
default: {
|
|
60
|
+
const kids = parseMathSeq(poChildren(node));
|
|
61
|
+
return kids.length > 0 ? {
|
|
62
|
+
type: "row",
|
|
63
|
+
children: kids
|
|
64
|
+
} : null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function childRow(parent, tag) {
|
|
69
|
+
const el = poChildren(parent).find((c) => poIs(c, tag));
|
|
70
|
+
return {
|
|
71
|
+
type: "row",
|
|
72
|
+
children: el ? parseMathSeq(poChildren(el)) : []
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function parseMathRun(r) {
|
|
76
|
+
let text = "";
|
|
77
|
+
for (const c of poChildren(r)) if (poIs(c, "m:t")) text += poText(c);
|
|
78
|
+
const rPr = poChildren(r).find((c) => poIs(c, "m:rPr"));
|
|
79
|
+
let italic = false;
|
|
80
|
+
let bold = false;
|
|
81
|
+
let nor = false;
|
|
82
|
+
if (rPr) {
|
|
83
|
+
const sty = poVal(poChildren(rPr).find((c) => poIs(c, "m:sty")));
|
|
84
|
+
if (sty === "i") italic = true;
|
|
85
|
+
else if (sty === "b") bold = true;
|
|
86
|
+
else if (sty === "bi") {
|
|
87
|
+
italic = true;
|
|
88
|
+
bold = true;
|
|
89
|
+
} else if (sty === "p") nor = true;
|
|
90
|
+
if (poChildren(rPr).some((c) => poIs(c, "m:nor"))) nor = true;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
type: "run",
|
|
94
|
+
text,
|
|
95
|
+
...italic ? { italic: true } : {},
|
|
96
|
+
...bold ? { bold: true } : {},
|
|
97
|
+
...nor ? { nor: true } : {}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function parseFraction(f) {
|
|
101
|
+
const num = childRow(f, "m:num");
|
|
102
|
+
const den = childRow(f, "m:den");
|
|
103
|
+
const fPr = poChildren(f).find((c) => poIs(c, "m:fPr"));
|
|
104
|
+
return {
|
|
105
|
+
type: "fraction",
|
|
106
|
+
num,
|
|
107
|
+
den,
|
|
108
|
+
...(fPr ? poVal(poChildren(fPr).find((c) => poIs(c, "m:type"))) : void 0) === "noBar" ? { barless: true } : {}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function parseScript(node, hasSub, hasSup) {
|
|
112
|
+
return {
|
|
113
|
+
type: "script",
|
|
114
|
+
base: childRow(node, "m:e"),
|
|
115
|
+
...hasSub ? { sub: childRow(node, "m:sub") } : {},
|
|
116
|
+
...hasSup ? { sup: childRow(node, "m:sup") } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function parseNary(node) {
|
|
120
|
+
const naryPr = poChildren(node).find((c) => poIs(c, "m:naryPr"));
|
|
121
|
+
let op = "∫";
|
|
122
|
+
let limLoc;
|
|
123
|
+
const hidden = (tag) => {
|
|
124
|
+
if (!naryPr) return false;
|
|
125
|
+
const el = poChildren(naryPr).find((c) => poIs(c, tag));
|
|
126
|
+
return el !== void 0 && poToggle(el) !== false;
|
|
127
|
+
};
|
|
128
|
+
if (naryPr) {
|
|
129
|
+
const chr = poVal(poChildren(naryPr).find((c) => poIs(c, "m:chr")));
|
|
130
|
+
if (chr) op = chr;
|
|
131
|
+
const ll = poVal(poChildren(naryPr).find((c) => poIs(c, "m:limLoc")));
|
|
132
|
+
if (ll === "undOvr" || ll === "subSup") limLoc = ll;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
type: "nary",
|
|
136
|
+
op,
|
|
137
|
+
body: childRow(node, "m:e"),
|
|
138
|
+
...hidden("m:subHide") ? {} : { sub: childRow(node, "m:sub") },
|
|
139
|
+
...hidden("m:supHide") ? {} : { sup: childRow(node, "m:sup") },
|
|
140
|
+
...limLoc ? { limLoc } : {}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function parseDelimiter(node) {
|
|
144
|
+
const dPr = poChildren(node).find((c) => poIs(c, "m:dPr"));
|
|
145
|
+
const chrVal = (tag) => dPr ? poVal(poChildren(dPr).find((c) => poIs(c, tag))) : void 0;
|
|
146
|
+
const beg = chrVal("m:begChr");
|
|
147
|
+
const end = chrVal("m:endChr");
|
|
148
|
+
const sep = chrVal("m:sepChr");
|
|
149
|
+
const children = poChildrenWith(node, "m:e").map((e) => ({
|
|
150
|
+
type: "row",
|
|
151
|
+
children: parseMathSeq(poChildren(e))
|
|
152
|
+
}));
|
|
153
|
+
return {
|
|
154
|
+
type: "delimiter",
|
|
155
|
+
begChr: beg ?? "(",
|
|
156
|
+
endChr: end ?? ")",
|
|
157
|
+
children,
|
|
158
|
+
...sep !== void 0 ? { sepChr: sep } : {}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function parseMatrix(node) {
|
|
162
|
+
return {
|
|
163
|
+
type: "matrix",
|
|
164
|
+
rows: poChildrenWith(node, "m:mr").map((mr) => poChildrenWith(mr, "m:e").map((e) => ({
|
|
165
|
+
type: "row",
|
|
166
|
+
children: parseMathSeq(poChildren(e))
|
|
167
|
+
})))
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function parseEqArray(node) {
|
|
171
|
+
return {
|
|
172
|
+
type: "eqArr",
|
|
173
|
+
rows: poChildrenWith(node, "m:e").map((e) => ({
|
|
174
|
+
type: "row",
|
|
175
|
+
children: parseMathSeq(poChildren(e))
|
|
176
|
+
}))
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function parseAccent(node) {
|
|
180
|
+
const accPr = poChildren(node).find((c) => poIs(c, "m:accPr"));
|
|
181
|
+
return {
|
|
182
|
+
type: "accent",
|
|
183
|
+
char: (accPr ? poVal(poChildren(accPr).find((c) => poIs(c, "m:chr"))) : void 0) ?? "̂",
|
|
184
|
+
base: childRow(node, "m:e")
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function parseBar(node) {
|
|
188
|
+
const barPr = poChildren(node).find((c) => poIs(c, "m:barPr"));
|
|
189
|
+
const pos = barPr ? poVal(poChildren(barPr).find((c) => poIs(c, "m:pos"))) : void 0;
|
|
190
|
+
return {
|
|
191
|
+
type: "bar",
|
|
192
|
+
base: childRow(node, "m:e"),
|
|
193
|
+
pos: pos === "bot" ? "bot" : "top"
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function parseGroupChr(node) {
|
|
197
|
+
const gPr = poChildren(node).find((c) => poIs(c, "m:groupChrPr"));
|
|
198
|
+
const chr = gPr ? poVal(poChildren(gPr).find((c) => poIs(c, "m:chr"))) : void 0;
|
|
199
|
+
const pos = gPr ? poVal(poChildren(gPr).find((c) => poIs(c, "m:pos"))) : void 0;
|
|
200
|
+
return {
|
|
201
|
+
type: "groupChr",
|
|
202
|
+
char: chr ?? "⏟",
|
|
203
|
+
base: childRow(node, "m:e"),
|
|
204
|
+
pos: pos === "top" ? "top" : "bot"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function parseRadical(node) {
|
|
208
|
+
const degEl = poChildren(node).find((c) => poIs(c, "m:deg"));
|
|
209
|
+
const hasDeg = degEl !== void 0 && parseMathSeq(poChildren(degEl)).length > 0;
|
|
210
|
+
return {
|
|
211
|
+
type: "radical",
|
|
212
|
+
radicand: childRow(node, "m:e"),
|
|
213
|
+
...hasDeg ? { degree: childRow(node, "m:deg") } : {}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { parseOMath };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/ooxml/spreadsheet/cell-reference.ts
|
|
2
|
+
var A = 65;
|
|
3
|
+
var Z = 90;
|
|
4
|
+
var a = 97;
|
|
5
|
+
var z = 122;
|
|
6
|
+
function parseCellRef(ref) {
|
|
7
|
+
let i = 0;
|
|
8
|
+
let column = 0;
|
|
9
|
+
while (i < ref.length) {
|
|
10
|
+
const code = ref.charCodeAt(i);
|
|
11
|
+
if (code >= A && code <= Z) column = column * 26 + (code - A + 1);
|
|
12
|
+
else if (code >= a && code <= z) column = column * 26 + (code - a + 1);
|
|
13
|
+
else break;
|
|
14
|
+
i++;
|
|
15
|
+
}
|
|
16
|
+
if (column === 0) throw new Error(`Invalid cell reference: ${ref}`);
|
|
17
|
+
const rowPart = ref.substring(i);
|
|
18
|
+
const row = Number(rowPart);
|
|
19
|
+
if (!Number.isInteger(row) || row < 1) throw new Error(`Invalid cell reference: ${ref}`);
|
|
20
|
+
return {
|
|
21
|
+
column: column - 1,
|
|
22
|
+
row: row - 1
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { parseCellRef };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CellRange {
|
|
2
|
+
readonly startColumn: number;
|
|
3
|
+
readonly startRow: number;
|
|
4
|
+
readonly endColumn: number;
|
|
5
|
+
readonly endRow: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseTitleRowRange(value: string): {
|
|
8
|
+
readonly startRow: number;
|
|
9
|
+
readonly endRow: number;
|
|
10
|
+
} | undefined;
|
|
11
|
+
export declare function parseAreaRef(value: string): CellRange | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { parseCellRef } from "./cell-reference.js";
|
|
2
|
+
//#region src/ooxml/spreadsheet/defined-name-ref.ts
|
|
3
|
+
function stripQualifier(token) {
|
|
4
|
+
const bang = token.lastIndexOf("!");
|
|
5
|
+
return (bang >= 0 ? token.substring(bang + 1) : token).replace(/\$/g, "").trim();
|
|
6
|
+
}
|
|
7
|
+
function parseSingleArea(token) {
|
|
8
|
+
const ref = stripQualifier(token);
|
|
9
|
+
if (ref.length === 0) return void 0;
|
|
10
|
+
const colon = ref.indexOf(":");
|
|
11
|
+
try {
|
|
12
|
+
if (colon < 0) {
|
|
13
|
+
const a = parseCellRef(ref);
|
|
14
|
+
return {
|
|
15
|
+
startColumn: a.column,
|
|
16
|
+
startRow: a.row,
|
|
17
|
+
endColumn: a.column,
|
|
18
|
+
endRow: a.row
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const a = parseCellRef(ref.substring(0, colon));
|
|
22
|
+
const b = parseCellRef(ref.substring(colon + 1));
|
|
23
|
+
return {
|
|
24
|
+
startColumn: Math.min(a.column, b.column),
|
|
25
|
+
startRow: Math.min(a.row, b.row),
|
|
26
|
+
endColumn: Math.max(a.column, b.column),
|
|
27
|
+
endRow: Math.max(a.row, b.row)
|
|
28
|
+
};
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function parseTitleRowRange(value) {
|
|
34
|
+
if (!value) return void 0;
|
|
35
|
+
for (const token of value.split(",")) {
|
|
36
|
+
const ref = stripQualifier(token);
|
|
37
|
+
const m = /^(\d+)(?::(\d+))?$/.exec(ref);
|
|
38
|
+
if (!m) continue;
|
|
39
|
+
const a = Number(m[1]);
|
|
40
|
+
const b = m[2] !== void 0 ? Number(m[2]) : a;
|
|
41
|
+
if (!Number.isInteger(a) || a < 1 || !Number.isInteger(b) || b < 1) continue;
|
|
42
|
+
return {
|
|
43
|
+
startRow: Math.min(a, b) - 1,
|
|
44
|
+
endRow: Math.max(a, b) - 1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function parseAreaRef(value) {
|
|
49
|
+
if (!value) return void 0;
|
|
50
|
+
let box;
|
|
51
|
+
for (const token of value.split(",")) {
|
|
52
|
+
const area = parseSingleArea(token);
|
|
53
|
+
if (!area) continue;
|
|
54
|
+
box = box ? {
|
|
55
|
+
startColumn: Math.min(box.startColumn, area.startColumn),
|
|
56
|
+
startRow: Math.min(box.startRow, area.startRow),
|
|
57
|
+
endColumn: Math.max(box.endColumn, area.endColumn),
|
|
58
|
+
endRow: Math.max(box.endRow, area.endRow)
|
|
59
|
+
} : area;
|
|
60
|
+
}
|
|
61
|
+
return box;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { parseAreaRef, parseTitleRowRange };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { parseCellRef, formatCellRef } from './cell-reference.js';
|
|
2
|
+
export type { CellAddress } from './cell-reference.js';
|
|
3
|
+
export { parseAreaRef, parseTitleRowRange } from './defined-name-ref.js';
|
|
4
|
+
export type { CellRange } from './defined-name-ref.js';
|
|
5
|
+
export { parseSharedStrings } from './shared-strings-parser.js';
|
|
6
|
+
export { parseWorkbook } from './workbook-parser.js';
|
|
7
|
+
export type { DefinedName, ParsedWorkbook, SheetReference, } from './workbook-parser.js';
|
|
8
|
+
export { parseWorksheet } from './worksheet-parser.js';
|
|
9
|
+
export type { CellType, ColumnWidth, MergedRange, ParsedWorksheet, RowHeight, WorksheetCell, XlsxPageMargins, XlsxPageSetup, XlsxPrintOptions, } from './worksheet-parser.js';
|
|
10
|
+
export { parseXlsxStyles, EMPTY_XLSX_STYLES } from './styles-parser.js';
|
|
11
|
+
export type { XlsxBorder, XlsxBorderEdge, XlsxBorderStyleName, XlsxCellAlignment, XlsxCellXf, XlsxFill, XlsxFont, XlsxHorizontalAlign, XlsxStyles, XlsxVerticalAlign, } from './styles-parser.js';
|
|
12
|
+
export { applyNumberFormat } from './number-format.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function applyNumberFormat(rawValue: string, numFmtId: number, customFormats: ReadonlyMap<number, string>, date1904?: boolean): string;
|