@univerjs/engine-formula 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +398 -351
- package/lib/types/basics/object-class-type.d.ts +17 -2
- package/lib/types/basics/regex.d.ts +19 -2
- package/lib/types/engine/analysis/parser.d.ts +1 -2
- package/lib/types/engine/ast-node/base-ast-node-factory.d.ts +3 -2
- package/lib/types/engine/ast-node/base-ast-node.d.ts +2 -9
- package/lib/types/engine/ast-node/reference-node.d.ts +9 -2
- package/lib/types/engine/dependency/dependency-tree.d.ts +4 -4
- package/lib/types/engine/dependency/formula-dependency.d.ts +1 -0
- package/lib/types/engine/interpreter/interpreter.d.ts +3 -2
- package/lib/types/engine/utils/ast-node-tool.d.ts +10 -0
- package/lib/types/engine/utils/numfmt-kit.d.ts +1 -0
- package/lib/types/engine/utils/reference.d.ts +2 -0
- package/lib/types/engine/value-object/lambda-value-object.d.ts +2 -2
- package/lib/types/functions/base-function.d.ts +6 -5
- package/lib/types/services/dependency-manager.service.d.ts +4 -6
- package/lib/types/services/runtime.service.d.ts +2 -0
- package/lib/umd/index.js +2 -2
- package/package.json +4 -4
- package/lib/types/engine/dependency/generate-tree-id.d.ts +0 -2
package/lib/es/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "sym
|
|
|
5
5
|
import { ObjectMatrix, CommandType, Tools, AbsoluteRefType, RANGE_TYPE, createIdentifier, Disposable, IUniverInstanceService, LRUMap, hashAlgorithm, moveRangeByOffset, isValidRange, isFormulaString, isFormulaId, Rectangle, cellToRange, Inject, UniverInstanceType, numfmt, isRealNum, CellValueType, isNullCell, toDisposable, Injector, BuildTextUtils, sortRules, RTree, generateRandomId, requestImmediateMacroTask, IConfigService, ICommandService, BooleanNumber, Optional, Plugin } from "@univerjs/core";
|
|
6
6
|
import { Subject } from "rxjs";
|
|
7
7
|
import { DataSyncPrimaryController } from "@univerjs/rpc";
|
|
8
|
-
var BooleanValue = /* @__PURE__ */ ((BooleanValue2) => (BooleanValue2.FALSE = "FALSE", BooleanValue2.TRUE = "TRUE", BooleanValue2))(BooleanValue || {}), AstNodePromiseType = /* @__PURE__ */ ((AstNodePromiseType2) => (AstNodePromiseType2[AstNodePromiseType2.SUCCESS = 0] = "SUCCESS", AstNodePromiseType2[AstNodePromiseType2.ERROR = 1] = "ERROR", AstNodePromiseType2))(AstNodePromiseType || {}),
|
|
8
|
+
var BooleanValue = /* @__PURE__ */ ((BooleanValue2) => (BooleanValue2.FALSE = "FALSE", BooleanValue2.TRUE = "TRUE", BooleanValue2))(BooleanValue || {}), AstNodePromiseType = /* @__PURE__ */ ((AstNodePromiseType2) => (AstNodePromiseType2[AstNodePromiseType2.SUCCESS = 0] = "SUCCESS", AstNodePromiseType2[AstNodePromiseType2.ERROR = 1] = "ERROR", AstNodePromiseType2))(AstNodePromiseType || {}), ConcatenateType = /* @__PURE__ */ ((ConcatenateType2) => (ConcatenateType2[ConcatenateType2.FRONT = 0] = "FRONT", ConcatenateType2[ConcatenateType2.BACK = 1] = "BACK", ConcatenateType2))(ConcatenateType || {});
|
|
9
9
|
function isInDirtyRange(dirtyRanges, unitId, sheetId, row, column) {
|
|
10
10
|
for (let i = 0, len = dirtyRanges.length; i < len; i++) {
|
|
11
11
|
const dirtyRange = dirtyRanges[i];
|
|
@@ -150,9 +150,37 @@ function convertRuntimeToUnitData(unitData) {
|
|
|
150
150
|
}), unitPrimitiveData;
|
|
151
151
|
}
|
|
152
152
|
__name(convertRuntimeToUnitData, "convertRuntimeToUnitData");
|
|
153
|
-
const UNIT_NAME_REGEX = '\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]', SHEET_NAME_REGEX = "((?![\\[\\]\\/?*\\\\]).)*!", ABSOLUTE_SYMBOL = "$", RANGE_SYMBOL = "\\s*?:\\s*?", COLUMN_REGEX = "[A-Za-z]+", ROW_REGEX = "[1-9][0-9]*", UNIT_NAME_SHEET_NAME_REGEX = `'?(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`, SIMPLE_SINGLE_RANGE_REGEX = `\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}`, REFERENCE_MULTIPLE_RANGE_REGEX = `^(${prefixToken.AT})?${UNIT_NAME_SHEET_NAME_REGEX}${SIMPLE_SINGLE_RANGE_REGEX}${RANGE_SYMBOL}${SIMPLE_SINGLE_RANGE_REGEX}$`, REFERENCE_SINGLE_RANGE_REGEX = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?${SIMPLE_SINGLE_RANGE_REGEX}(${suffixToken.POUND})?$`, REFERENCE_REGEX_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}${RANGE_SYMBOL}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}$`, REFERENCE_REGEX_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}${RANGE_SYMBOL}\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}$`, REFERENCE_REGEX_SINGLE_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}$`, REFERENCE_REGEX_SINGLE_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}$`,
|
|
153
|
+
const UNIT_NAME_REGEX = '\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]', UNIT_NAME_REGEX_PRECOMPILING = new RegExp(UNIT_NAME_REGEX), SHEET_NAME_REGEX = "((?![\\[\\]\\/?*\\\\]).)*!", ABSOLUTE_SYMBOL = "$", RANGE_SYMBOL = "\\s*?:\\s*?", COLUMN_REGEX = "[A-Za-z]+", ROW_REGEX = "[1-9][0-9]*", UNIT_NAME_SHEET_NAME_REGEX = `'?(${UNIT_NAME_REGEX})?(${SHEET_NAME_REGEX})?'?`, SIMPLE_SINGLE_RANGE_REGEX = `\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}`, REFERENCE_MULTIPLE_RANGE_REGEX = `^(${prefixToken.AT})?${UNIT_NAME_SHEET_NAME_REGEX}${SIMPLE_SINGLE_RANGE_REGEX}${RANGE_SYMBOL}${SIMPLE_SINGLE_RANGE_REGEX}$`, REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING = new RegExp(REFERENCE_MULTIPLE_RANGE_REGEX), REFERENCE_SINGLE_RANGE_REGEX = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?${SIMPLE_SINGLE_RANGE_REGEX}(${suffixToken.POUND})?$`, REFERENCE_SINGLE_RANGE_REGEX_PRECOMPILING = new RegExp(REFERENCE_SINGLE_RANGE_REGEX), REFERENCE_REGEX_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}${RANGE_SYMBOL}\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}$`, REFERENCE_REGEX_ROW_PRECOMPILING = new RegExp(REFERENCE_REGEX_ROW), REFERENCE_REGEX_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}${RANGE_SYMBOL}\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}$`, REFERENCE_REGEX_COLUMN_PRECOMPILING = new RegExp(REFERENCE_REGEX_COLUMN), REFERENCE_REGEX_SINGLE_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${ABSOLUTE_SYMBOL}?${ROW_REGEX}$`, REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_ROW), REFERENCE_REGEX_SINGLE_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${ABSOLUTE_SYMBOL}?${COLUMN_REGEX}$`, REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_COLUMN), ARRAY_VALUE_REGEX = "{.*?}", ARRAY_VALUE_REGEX_PRECOMPILING = new RegExp(ARRAY_VALUE_REGEX, "g");
|
|
154
|
+
function regexTestSingeRange(token) {
|
|
155
|
+
return REFERENCE_SINGLE_RANGE_REGEX_PRECOMPILING.lastIndex = 0, REFERENCE_SINGLE_RANGE_REGEX_PRECOMPILING.test(token);
|
|
156
|
+
}
|
|
157
|
+
__name(regexTestSingeRange, "regexTestSingeRange");
|
|
158
|
+
function regexTestMultipleRange(token) {
|
|
159
|
+
return REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING.lastIndex = 0, REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING.test(token);
|
|
160
|
+
}
|
|
161
|
+
__name(regexTestMultipleRange, "regexTestMultipleRange");
|
|
162
|
+
function regexTestRow(token) {
|
|
163
|
+
return REFERENCE_REGEX_ROW_PRECOMPILING.lastIndex = 0, REFERENCE_REGEX_ROW_PRECOMPILING.test(token);
|
|
164
|
+
}
|
|
165
|
+
__name(regexTestRow, "regexTestRow");
|
|
166
|
+
function regexTestColumn(token) {
|
|
167
|
+
return REFERENCE_REGEX_COLUMN_PRECOMPILING.lastIndex = 0, REFERENCE_REGEX_COLUMN_PRECOMPILING.test(token);
|
|
168
|
+
}
|
|
169
|
+
__name(regexTestColumn, "regexTestColumn");
|
|
170
|
+
function regexTestSingleRow(token) {
|
|
171
|
+
return REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING.lastIndex = 0, REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING.test(token);
|
|
172
|
+
}
|
|
173
|
+
__name(regexTestSingleRow, "regexTestSingleRow");
|
|
174
|
+
function regexTestSingleColumn(token) {
|
|
175
|
+
return REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING.lastIndex = 0, REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING.test(token);
|
|
176
|
+
}
|
|
177
|
+
__name(regexTestSingleColumn, "regexTestSingleColumn");
|
|
178
|
+
function regexTestArrayValue(token) {
|
|
179
|
+
return ARRAY_VALUE_REGEX_PRECOMPILING.lastIndex = 0, ARRAY_VALUE_REGEX_PRECOMPILING.test(token);
|
|
180
|
+
}
|
|
181
|
+
__name(regexTestArrayValue, "regexTestArrayValue");
|
|
154
182
|
function isReferenceString(refString) {
|
|
155
|
-
return
|
|
183
|
+
return regexTestSingeRange(refString) || regexTestMultipleRange(refString) || regexTestRow(refString) || regexTestColumn(refString);
|
|
156
184
|
}
|
|
157
185
|
__name(isReferenceString, "isReferenceString");
|
|
158
186
|
const RegisterFunctionMutation = {
|
|
@@ -234,9 +262,9 @@ function singleReferenceToGrid(refBody) {
|
|
|
234
262
|
}
|
|
235
263
|
__name(singleReferenceToGrid, "singleReferenceToGrid");
|
|
236
264
|
function handleRefStringInfo(refString) {
|
|
237
|
-
const unitIdMatch =
|
|
265
|
+
const unitIdMatch = UNIT_NAME_REGEX_PRECOMPILING.exec(refString);
|
|
238
266
|
let unitId = "";
|
|
239
|
-
unitIdMatch != null && (unitId = unitIdMatch[0].trim(), unitId = unitId.slice(1, unitId.length - 1), refString = refString.replace(
|
|
267
|
+
unitIdMatch != null && (unitId = unitIdMatch[0].trim(), unitId = unitId.slice(1, unitId.length - 1), refString = refString.replace(UNIT_NAME_REGEX_PRECOMPILING, ""));
|
|
240
268
|
const sheetNameIndex = refString.indexOf("!");
|
|
241
269
|
let sheetName = "", refBody = "";
|
|
242
270
|
return sheetNameIndex > -1 ? (sheetName = refString.substring(0, sheetNameIndex), sheetName[0] === "'" && sheetName[sheetName.length - 1] === "'" && (sheetName = sheetName.substring(1, sheetName.length - 1)), refBody = refString.substring(sheetNameIndex + 1)) : refBody = refString, {
|
|
@@ -280,6 +308,18 @@ function deserializeRangeWithSheet(refString) {
|
|
|
280
308
|
};
|
|
281
309
|
}
|
|
282
310
|
__name(deserializeRangeWithSheet, "deserializeRangeWithSheet");
|
|
311
|
+
const referenceToRangeCache = /* @__PURE__ */ new Map();
|
|
312
|
+
function deserializeRangeWithSheetWithCache(refString) {
|
|
313
|
+
if (referenceToRangeCache.has(refString))
|
|
314
|
+
return referenceToRangeCache.get(refString);
|
|
315
|
+
const result = deserializeRangeWithSheet(refString);
|
|
316
|
+
return referenceToRangeCache.set(refString, result), deserializeRangeWithSheet(refString);
|
|
317
|
+
}
|
|
318
|
+
__name(deserializeRangeWithSheetWithCache, "deserializeRangeWithSheetWithCache");
|
|
319
|
+
function clearReferenceToRangeCache() {
|
|
320
|
+
referenceToRangeCache.clear();
|
|
321
|
+
}
|
|
322
|
+
__name(clearReferenceToRangeCache, "clearReferenceToRangeCache");
|
|
283
323
|
const EXCEPTION_REF_STRINGS = ["LOG10"];
|
|
284
324
|
function isReferenceStringWithEffectiveColumn(refString) {
|
|
285
325
|
const noPrefixRefString = replaceRefPrefixString(refString);
|
|
@@ -502,7 +542,7 @@ const IDefinedNamesService = createIdentifier("univer.formula.defined-names.serv
|
|
|
502
542
|
this._cache.clear();
|
|
503
543
|
}
|
|
504
544
|
_hash(formulaString) {
|
|
505
|
-
return hashAlgorithm(formulaString);
|
|
545
|
+
return formulaString.length <= 64 ? formulaString : hashAlgorithm(formulaString).toString();
|
|
506
546
|
}
|
|
507
547
|
};
|
|
508
548
|
__name(_FormulaAstLRU, "FormulaAstLRU");
|
|
@@ -828,7 +868,7 @@ const FORMULA_CACHE_LRU_COUNT$2 = 1e5, FormulaLexerNodeCache = new FormulaAstLRU
|
|
|
828
868
|
continue;
|
|
829
869
|
}
|
|
830
870
|
const preSegmentTrim = preSegment.trim(), preSegmentNotPrefixToken = replaceRefPrefixString(preSegmentTrim);
|
|
831
|
-
maybeString === !0 && preSegmentTrim[preSegmentTrim.length - 1] === matchToken.DOUBLE_QUOTATION && preSegmentTrim[0] !== matchToken.OPEN_BRACES ? (maybeString = !1, this._processPushSequenceNode(sequenceNodes, sequenceNodeType.STRING, preSegment, startIndex, endIndex, deleteEndIndex)) :
|
|
871
|
+
maybeString === !0 && preSegmentTrim[preSegmentTrim.length - 1] === matchToken.DOUBLE_QUOTATION && preSegmentTrim[0] !== matchToken.OPEN_BRACES ? (maybeString = !1, this._processPushSequenceNode(sequenceNodes, sequenceNodeType.STRING, preSegment, startIndex, endIndex, deleteEndIndex)) : regexTestSingeRange(preSegmentNotPrefixToken) && isReferenceStringWithEffectiveColumn(preSegmentNotPrefixToken) ? this._processPushSequenceNode(sequenceNodes, sequenceNodeType.REFERENCE, preSegment, startIndex, endIndex, deleteEndIndex) : Tools.isStringNumber(preSegmentTrim) ? this._processPushSequenceNode(sequenceNodes, sequenceNodeType.NUMBER, preSegment, startIndex, endIndex, deleteEndIndex) : preSegmentTrim.length > 0 && this._processPushSequenceNode(sequenceNodes, sequenceNodeType.FUNCTION, preSegment, startIndex, endIndex, deleteEndIndex), (i !== len - 1 || !this._isLastMergeString(currentString)) && sequenceNodes.push(currentString);
|
|
832
872
|
}
|
|
833
873
|
return this._mergeSequenceNodeReference(sequenceNodes);
|
|
834
874
|
}
|
|
@@ -2197,11 +2237,102 @@ function getRuntimeFeatureCell(row, column, sheetId, unitId, runtimeFeatureCellD
|
|
|
2197
2237
|
}
|
|
2198
2238
|
}
|
|
2199
2239
|
__name(getRuntimeFeatureCell, "getRuntimeFeatureCell");
|
|
2200
|
-
const
|
|
2240
|
+
const currencySymbols = [
|
|
2241
|
+
"$",
|
|
2242
|
+
"£",
|
|
2243
|
+
"¥",
|
|
2244
|
+
"¤",
|
|
2245
|
+
"֏",
|
|
2246
|
+
"؋",
|
|
2247
|
+
"৳",
|
|
2248
|
+
"฿",
|
|
2249
|
+
"៛",
|
|
2250
|
+
"₡",
|
|
2251
|
+
"₦",
|
|
2252
|
+
"₩",
|
|
2253
|
+
"₪",
|
|
2254
|
+
"₫",
|
|
2255
|
+
"€",
|
|
2256
|
+
"₭",
|
|
2257
|
+
"₮",
|
|
2258
|
+
"₱",
|
|
2259
|
+
"₲",
|
|
2260
|
+
"₴",
|
|
2261
|
+
"₸",
|
|
2262
|
+
"₹",
|
|
2263
|
+
"₺",
|
|
2264
|
+
"₼",
|
|
2265
|
+
"₽",
|
|
2266
|
+
"₾",
|
|
2267
|
+
"₿"
|
|
2268
|
+
], NumberFormatTypeMap = {
|
|
2269
|
+
currency: 2,
|
|
2270
|
+
date: 4,
|
|
2271
|
+
datetime: 5,
|
|
2272
|
+
error: 11,
|
|
2273
|
+
fraction: 7,
|
|
2274
|
+
general: 0,
|
|
2275
|
+
grouped: 11,
|
|
2276
|
+
number: 1,
|
|
2277
|
+
percent: 6,
|
|
2278
|
+
scientific: 8,
|
|
2279
|
+
text: 9,
|
|
2280
|
+
time: 5,
|
|
2281
|
+
unknown: 11
|
|
2282
|
+
/* Custom */
|
|
2283
|
+
};
|
|
2284
|
+
function handleNumfmtInCell(oldCell, cell, styles) {
|
|
2285
|
+
var _a27, _b;
|
|
2286
|
+
if (oldCell == null || cell == null)
|
|
2287
|
+
return cell;
|
|
2288
|
+
const oldCellStyle = (styles == null ? void 0 : styles.getStyleByCell(oldCell)) || oldCell.s, cellStyle = (styles == null ? void 0 : styles.getStyleByCell(cell)) || cell.s;
|
|
2289
|
+
if (oldCellStyle == null || cellStyle == null || typeof oldCellStyle != "object" || typeof cellStyle != "object")
|
|
2290
|
+
return cell;
|
|
2291
|
+
const oldPattern = (_a27 = oldCellStyle == null ? void 0 : oldCellStyle.n) == null ? void 0 : _a27.pattern, pattern = (_b = cellStyle == null ? void 0 : cellStyle.n) == null ? void 0 : _b.pattern;
|
|
2292
|
+
if (oldPattern == null || pattern == null)
|
|
2293
|
+
return cell;
|
|
2294
|
+
const newPattern = oldPattern || pattern;
|
|
2295
|
+
return cellStyle.n.pattern = newPattern, cell;
|
|
2296
|
+
}
|
|
2297
|
+
__name(handleNumfmtInCell, "handleNumfmtInCell");
|
|
2298
|
+
const numberFormatTypeCache = /* @__PURE__ */ new Map();
|
|
2299
|
+
function getNumberFormatType(pattern) {
|
|
2300
|
+
if (numberFormatTypeCache.has(pattern))
|
|
2301
|
+
return numberFormatTypeCache.get(pattern);
|
|
2302
|
+
const type = getNumberFormatTypeRaw(pattern);
|
|
2303
|
+
return numberFormatTypeCache.set(pattern, type), type;
|
|
2304
|
+
}
|
|
2305
|
+
__name(getNumberFormatType, "getNumberFormatType");
|
|
2306
|
+
function clearNumberFormatTypeCache() {
|
|
2307
|
+
numberFormatTypeCache.clear();
|
|
2308
|
+
}
|
|
2309
|
+
__name(clearNumberFormatTypeCache, "clearNumberFormatTypeCache");
|
|
2310
|
+
function getNumberFormatTypeRaw(pattern) {
|
|
2311
|
+
if (isAccounting(pattern))
|
|
2312
|
+
return 3;
|
|
2313
|
+
const type = numfmt.getInfo(pattern).type || "unknown";
|
|
2314
|
+
return NumberFormatTypeMap[type];
|
|
2315
|
+
}
|
|
2316
|
+
__name(getNumberFormatTypeRaw, "getNumberFormatTypeRaw");
|
|
2317
|
+
function isAccounting(pattern) {
|
|
2318
|
+
return !!currencySymbols.find((code) => pattern.includes(code)) && pattern.startsWith("_(");
|
|
2319
|
+
}
|
|
2320
|
+
__name(isAccounting, "isAccounting");
|
|
2321
|
+
function comparePatternPriority(previousPattern, nextPattern, operator) {
|
|
2322
|
+
if (previousPattern === "")
|
|
2323
|
+
return nextPattern;
|
|
2324
|
+
if (nextPattern === "")
|
|
2325
|
+
return previousPattern;
|
|
2326
|
+
const previousPatternType = getNumberFormatType(previousPattern), nextPatternType = getNumberFormatType(nextPattern);
|
|
2327
|
+
return operator === operatorToken.PLUS || operator === operatorToken.MINUS ? previousPatternType === 4 && nextPatternType === 4 || previousPatternType === 11 && nextPatternType === 11 ? "" : nextPattern : operator === operatorToken.MULTIPLY || operator === operatorToken.DIVIDED ? previousPatternType === 6 && nextPatternType === 6 || previousPatternType === 7 && nextPatternType === 7 || previousPatternType === 8 && nextPatternType === 8 || previousPatternType === 9 && nextPatternType === 9 ? nextPattern : "" : previousPattern || nextPattern;
|
|
2328
|
+
}
|
|
2329
|
+
__name(comparePatternPriority, "comparePatternPriority");
|
|
2330
|
+
const _ObjectClassType = class _ObjectClassType {
|
|
2201
2331
|
constructor() {
|
|
2202
|
-
super(...arguments);
|
|
2203
2332
|
__publicField(this, "pattern", "");
|
|
2204
2333
|
}
|
|
2334
|
+
dispose() {
|
|
2335
|
+
}
|
|
2205
2336
|
getPattern() {
|
|
2206
2337
|
return this.pattern;
|
|
2207
2338
|
}
|
|
@@ -3725,19 +3856,23 @@ var Decimal$1 = P.constructor = clone(DEFAULTS);
|
|
|
3725
3856
|
LN10 = new Decimal$1(LN10);
|
|
3726
3857
|
PI = new Decimal$1(PI);
|
|
3727
3858
|
function plus(a, b) {
|
|
3728
|
-
|
|
3859
|
+
const result = a + b;
|
|
3860
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).add(b).toNumber();
|
|
3729
3861
|
}
|
|
3730
3862
|
__name(plus, "plus");
|
|
3731
3863
|
function minus(a, b) {
|
|
3732
|
-
|
|
3864
|
+
const result = a - b;
|
|
3865
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).sub(b).toNumber();
|
|
3733
3866
|
}
|
|
3734
3867
|
__name(minus, "minus");
|
|
3735
3868
|
function multiply(a, b) {
|
|
3736
|
-
|
|
3869
|
+
const result = a * b;
|
|
3870
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).mul(b).toNumber();
|
|
3737
3871
|
}
|
|
3738
3872
|
__name(multiply, "multiply");
|
|
3739
3873
|
function divide(a, b) {
|
|
3740
|
-
|
|
3874
|
+
const result = a / b;
|
|
3875
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).div(b).toNumber();
|
|
3741
3876
|
}
|
|
3742
3877
|
__name(divide, "divide");
|
|
3743
3878
|
function round(base, precision) {
|
|
@@ -3808,84 +3943,6 @@ function getFractionalPart(num) {
|
|
|
3808
3943
|
return num - Math.trunc(num);
|
|
3809
3944
|
}
|
|
3810
3945
|
__name(getFractionalPart, "getFractionalPart");
|
|
3811
|
-
const currencySymbols = [
|
|
3812
|
-
"$",
|
|
3813
|
-
"£",
|
|
3814
|
-
"¥",
|
|
3815
|
-
"¤",
|
|
3816
|
-
"֏",
|
|
3817
|
-
"؋",
|
|
3818
|
-
"৳",
|
|
3819
|
-
"฿",
|
|
3820
|
-
"៛",
|
|
3821
|
-
"₡",
|
|
3822
|
-
"₦",
|
|
3823
|
-
"₩",
|
|
3824
|
-
"₪",
|
|
3825
|
-
"₫",
|
|
3826
|
-
"€",
|
|
3827
|
-
"₭",
|
|
3828
|
-
"₮",
|
|
3829
|
-
"₱",
|
|
3830
|
-
"₲",
|
|
3831
|
-
"₴",
|
|
3832
|
-
"₸",
|
|
3833
|
-
"₹",
|
|
3834
|
-
"₺",
|
|
3835
|
-
"₼",
|
|
3836
|
-
"₽",
|
|
3837
|
-
"₾",
|
|
3838
|
-
"₿"
|
|
3839
|
-
], NumberFormatTypeMap = {
|
|
3840
|
-
currency: 2,
|
|
3841
|
-
date: 4,
|
|
3842
|
-
datetime: 5,
|
|
3843
|
-
error: 11,
|
|
3844
|
-
fraction: 7,
|
|
3845
|
-
general: 0,
|
|
3846
|
-
grouped: 11,
|
|
3847
|
-
number: 1,
|
|
3848
|
-
percent: 6,
|
|
3849
|
-
scientific: 8,
|
|
3850
|
-
text: 9,
|
|
3851
|
-
time: 5,
|
|
3852
|
-
unknown: 11
|
|
3853
|
-
/* Custom */
|
|
3854
|
-
};
|
|
3855
|
-
function handleNumfmtInCell(oldCell, cell, styles) {
|
|
3856
|
-
var _a27, _b;
|
|
3857
|
-
if (oldCell == null || cell == null)
|
|
3858
|
-
return cell;
|
|
3859
|
-
const oldCellStyle = (styles == null ? void 0 : styles.getStyleByCell(oldCell)) || oldCell.s, cellStyle = (styles == null ? void 0 : styles.getStyleByCell(cell)) || cell.s;
|
|
3860
|
-
if (oldCellStyle == null || cellStyle == null || typeof oldCellStyle != "object" || typeof cellStyle != "object")
|
|
3861
|
-
return cell;
|
|
3862
|
-
const oldPattern = (_a27 = oldCellStyle == null ? void 0 : oldCellStyle.n) == null ? void 0 : _a27.pattern, pattern = (_b = cellStyle == null ? void 0 : cellStyle.n) == null ? void 0 : _b.pattern;
|
|
3863
|
-
if (oldPattern == null || pattern == null)
|
|
3864
|
-
return cell;
|
|
3865
|
-
const newPattern = oldPattern || pattern;
|
|
3866
|
-
return cellStyle.n.pattern = newPattern, cell;
|
|
3867
|
-
}
|
|
3868
|
-
__name(handleNumfmtInCell, "handleNumfmtInCell");
|
|
3869
|
-
function getNumberFormatType(pattern) {
|
|
3870
|
-
if (isAccounting(pattern))
|
|
3871
|
-
return 3;
|
|
3872
|
-
const type = numfmt.getInfo(pattern).type || "unknown";
|
|
3873
|
-
return NumberFormatTypeMap[type];
|
|
3874
|
-
}
|
|
3875
|
-
__name(getNumberFormatType, "getNumberFormatType");
|
|
3876
|
-
function isAccounting(pattern) {
|
|
3877
|
-
return !!currencySymbols.find((code) => pattern.includes(code)) && pattern.startsWith("_(");
|
|
3878
|
-
}
|
|
3879
|
-
__name(isAccounting, "isAccounting");
|
|
3880
|
-
function comparePatternPriority(previousPattern, nextPattern, operator) {
|
|
3881
|
-
if (previousPattern === "")
|
|
3882
|
-
return nextPattern;
|
|
3883
|
-
if (nextPattern === "")
|
|
3884
|
-
return previousPattern;
|
|
3885
|
-
const previousPatternType = getNumberFormatType(previousPattern), nextPatternType = getNumberFormatType(nextPattern);
|
|
3886
|
-
return operator === operatorToken.PLUS || operator === operatorToken.MINUS ? previousPatternType === 4 && nextPatternType === 4 || previousPatternType === 11 && nextPatternType === 11 ? "" : nextPattern : operator === operatorToken.MULTIPLY || operator === operatorToken.DIVIDED ? previousPatternType === 6 && nextPatternType === 6 || previousPatternType === 7 && nextPatternType === 7 || previousPatternType === 8 && nextPatternType === 8 || previousPatternType === 9 && nextPatternType === 9 ? nextPattern : "" : previousPattern || nextPattern;
|
|
3887
|
-
}
|
|
3888
|
-
__name(comparePatternPriority, "comparePatternPriority");
|
|
3889
3946
|
const _NullValueObject = class _NullValueObject extends BaseValueObject {
|
|
3890
3947
|
static create() {
|
|
3891
3948
|
return this._instance = this._instance || new _NullValueObject(0), this._instance;
|
|
@@ -5693,7 +5750,7 @@ const _ValueObjectFactory = class _ValueObjectFactory {
|
|
|
5693
5750
|
if (isRealNum(rawValue))
|
|
5694
5751
|
return NumberValueObject.create(Number(rawValue));
|
|
5695
5752
|
const rawValueSingleLine = rawValue.replace(/\n/g, "").replace(/\r/g, "");
|
|
5696
|
-
return !isStringWrappedByDoubleQuotes(rawValueSingleLine) &&
|
|
5753
|
+
return !isStringWrappedByDoubleQuotes(rawValueSingleLine) && regexTestArrayValue(rawValueSingleLine) ? ArrayValueObject.create(rawValueSingleLine) : createStringValueObjectByRawValue(rawValue);
|
|
5697
5754
|
}
|
|
5698
5755
|
return typeof rawValue == "number" ? createNumberValueObjectByRawValue(rawValue) : ErrorValueObject.create(ErrorType$1.VALUE);
|
|
5699
5756
|
}
|
|
@@ -5968,7 +6025,7 @@ let FormulaRuntimeService = (_a5 = class extends Disposable {
|
|
|
5968
6025
|
return this._currentUnitId;
|
|
5969
6026
|
}
|
|
5970
6027
|
dispose() {
|
|
5971
|
-
this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {};
|
|
6028
|
+
this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {}, this.clearReferenceAndNumberformatCache();
|
|
5972
6029
|
}
|
|
5973
6030
|
enableCycleDependency() {
|
|
5974
6031
|
this._isCycleDependency = !0;
|
|
@@ -6039,6 +6096,9 @@ let FormulaRuntimeService = (_a5 = class extends Disposable {
|
|
|
6039
6096
|
reset() {
|
|
6040
6097
|
this._formulaExecuteStage = 0, this._runtimeData = {}, this._runtimeOtherData = {}, this._unitArrayFormulaRange = {}, this._runtimeArrayFormulaCellData = {}, this._runtimeClearArrayFormulaCellData = {}, this._functionDefinitionPrivacyVar.clear(), this.markedAsInitialFunctionsExecuted(), this._stopState = !1, this._isCycleDependency = !1, this._totalFormulasToCalculate = 0, this._completedFormulasCount = 0;
|
|
6041
6098
|
}
|
|
6099
|
+
clearReferenceAndNumberformatCache() {
|
|
6100
|
+
clearNumberFormatTypeCache(), clearReferenceToRangeCache();
|
|
6101
|
+
}
|
|
6042
6102
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
6043
6103
|
this._currentRow = row, this._currentColumn = column, this._currentRowCount = rowCount, this._currentColumnCount = columnCount, this._currentSubUnitId = sheetId, this._currentUnitId = unitId;
|
|
6044
6104
|
}
|
|
@@ -6284,9 +6344,8 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6284
6344
|
["UnionNode", 3],
|
|
6285
6345
|
["PrefixNode", 4],
|
|
6286
6346
|
["SuffixNode", 5]
|
|
6287
|
-
]), _BaseAstNode = class _BaseAstNode
|
|
6347
|
+
]), _BaseAstNode = class _BaseAstNode {
|
|
6288
6348
|
constructor(_token) {
|
|
6289
|
-
super();
|
|
6290
6349
|
__publicField(this, "_children", []);
|
|
6291
6350
|
__publicField(this, "_definedNames", []);
|
|
6292
6351
|
__publicField(this, "_parent");
|
|
@@ -6294,8 +6353,6 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6294
6353
|
__publicField(this, "_calculateState", !1);
|
|
6295
6354
|
__publicField(this, "_async", !1);
|
|
6296
6355
|
__publicField(this, "_address", !1);
|
|
6297
|
-
__publicField(this, "_refOffsetX", 0);
|
|
6298
|
-
__publicField(this, "_refOffsetY", 0);
|
|
6299
6356
|
__publicField(this, "_isForcedCalculateFunction", !1);
|
|
6300
6357
|
this._token = _token;
|
|
6301
6358
|
}
|
|
@@ -6357,15 +6414,6 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6357
6414
|
}
|
|
6358
6415
|
setNotEmpty(state = !0) {
|
|
6359
6416
|
}
|
|
6360
|
-
setRefOffset(x = 0, y = 0) {
|
|
6361
|
-
this._refOffsetX = x, this._refOffsetY = y;
|
|
6362
|
-
}
|
|
6363
|
-
getRefOffset() {
|
|
6364
|
-
return {
|
|
6365
|
-
x: this._refOffsetX,
|
|
6366
|
-
y: this._refOffsetY
|
|
6367
|
-
};
|
|
6368
|
-
}
|
|
6369
6417
|
async executeAsync() {
|
|
6370
6418
|
return Promise.resolve(AstNodePromiseType.SUCCESS);
|
|
6371
6419
|
}
|
|
@@ -6408,10 +6456,12 @@ const _ErrorNode = class _ErrorNode extends BaseAstNode {
|
|
|
6408
6456
|
};
|
|
6409
6457
|
__name(_ErrorNode, "ErrorNode");
|
|
6410
6458
|
let ErrorNode = _ErrorNode;
|
|
6411
|
-
const DEFAULT_AST_NODE_FACTORY_Z_INDEX = 100, _BaseAstNodeFactory = class _BaseAstNodeFactory
|
|
6459
|
+
const DEFAULT_AST_NODE_FACTORY_Z_INDEX = 100, _BaseAstNodeFactory = class _BaseAstNodeFactory {
|
|
6412
6460
|
get zIndex() {
|
|
6413
6461
|
return 0;
|
|
6414
6462
|
}
|
|
6463
|
+
dispose() {
|
|
6464
|
+
}
|
|
6415
6465
|
create(param, currentRow, currentColumn) {
|
|
6416
6466
|
let token;
|
|
6417
6467
|
return param instanceof LexerNode ? token = param.getToken() : token = param, new BaseAstNode(token);
|
|
@@ -6567,15 +6617,17 @@ PrefixNodeFactory = __decorateClass$i([
|
|
|
6567
6617
|
__decorateParam$i(0, IFunctionService),
|
|
6568
6618
|
__decorateParam$i(1, Inject(Injector))
|
|
6569
6619
|
], PrefixNodeFactory);
|
|
6620
|
+
new RegExp(prefixToken.MINUS, "g");
|
|
6621
|
+
new RegExp(prefixToken.AT, "g");
|
|
6570
6622
|
function prefixHandler(tokenTrimParam, functionService, injector) {
|
|
6571
6623
|
let minusPrefixNode, atPrefixNode, tokenTrim = tokenTrimParam;
|
|
6572
6624
|
const prefix = tokenTrim.slice(0, 2);
|
|
6573
6625
|
let sliceLength = 0;
|
|
6574
|
-
if (
|
|
6626
|
+
if (prefix[0] === prefixToken.MINUS) {
|
|
6575
6627
|
const functionExecutor = functionService.getExecutor(FUNCTION_NAMES_META.MINUS);
|
|
6576
6628
|
minusPrefixNode = new PrefixNode(injector, prefixToken.MINUS, functionExecutor), sliceLength++;
|
|
6577
6629
|
}
|
|
6578
|
-
return
|
|
6630
|
+
return prefix[0] === prefixToken.AT && (atPrefixNode = new PrefixNode(injector, prefixToken.AT), minusPrefixNode && atPrefixNode.setParent(minusPrefixNode), sliceLength++), sliceLength > 0 && (tokenTrim = tokenTrim.slice(sliceLength)), { tokenTrim, minusPrefixNode, atPrefixNode };
|
|
6579
6631
|
}
|
|
6580
6632
|
__name(prefixHandler, "prefixHandler");
|
|
6581
6633
|
var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
@@ -6743,17 +6795,19 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6743
6795
|
constructor(_runtimeService) {
|
|
6744
6796
|
super(), this._runtimeService = _runtimeService;
|
|
6745
6797
|
}
|
|
6746
|
-
async executeAsync(
|
|
6747
|
-
if (!
|
|
6798
|
+
async executeAsync(nodeData) {
|
|
6799
|
+
if (!nodeData)
|
|
6748
6800
|
return Promise.resolve(ErrorValueObject.create(ErrorType$1.VALUE));
|
|
6749
|
-
|
|
6801
|
+
const node = nodeData.node, refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
6802
|
+
await this._executeAsync(node, refOffsetX, refOffsetY);
|
|
6750
6803
|
const value = node.getValue();
|
|
6751
6804
|
return value == null ? Promise.resolve(ErrorValueObject.create(ErrorType$1.VALUE)) : Promise.resolve(value);
|
|
6752
6805
|
}
|
|
6753
|
-
execute(
|
|
6754
|
-
if (!
|
|
6806
|
+
execute(nodeData) {
|
|
6807
|
+
if (!nodeData)
|
|
6755
6808
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6756
|
-
|
|
6809
|
+
const node = nodeData.node, refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
6810
|
+
this._execute(node, refOffsetX, refOffsetY);
|
|
6757
6811
|
const value = node.getValue();
|
|
6758
6812
|
return value == null ? ErrorValueObject.create(ErrorType$1.VALUE) : value;
|
|
6759
6813
|
}
|
|
@@ -6775,7 +6829,7 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6775
6829
|
resultList.push(item.isAsync()), this._checkAsyncNode(item, resultList);
|
|
6776
6830
|
}
|
|
6777
6831
|
}
|
|
6778
|
-
async _executeAsync(node) {
|
|
6832
|
+
async _executeAsync(node, refOffsetX = 0, refOffsetY = 0) {
|
|
6779
6833
|
if (this._runtimeService.isStopExecution())
|
|
6780
6834
|
return Promise.resolve(AstNodePromiseType.ERROR);
|
|
6781
6835
|
const children = node.getChildren(), childrenCount = children.length;
|
|
@@ -6785,11 +6839,11 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6785
6839
|
item.execute();
|
|
6786
6840
|
continue;
|
|
6787
6841
|
}
|
|
6788
|
-
await this._executeAsync(item);
|
|
6842
|
+
await this._executeAsync(item, refOffsetX, refOffsetY);
|
|
6789
6843
|
}
|
|
6790
|
-
return node.nodeType === NodeType.FUNCTION && node.isAsync() ? await node.executeAsync() : node.execute(), Promise.resolve(AstNodePromiseType.SUCCESS);
|
|
6844
|
+
return node.nodeType === NodeType.REFERENCE && node.setRefOffset(refOffsetX, refOffsetY), node.nodeType === NodeType.FUNCTION && node.isAsync() ? await node.executeAsync() : node.execute(), Promise.resolve(AstNodePromiseType.SUCCESS);
|
|
6791
6845
|
}
|
|
6792
|
-
_execute(node) {
|
|
6846
|
+
_execute(node, refOffsetX = 0, refOffsetY = 0) {
|
|
6793
6847
|
if (this._runtimeService.isStopExecution())
|
|
6794
6848
|
return AstNodePromiseType.ERROR;
|
|
6795
6849
|
const children = node.getChildren(), childrenCount = children.length;
|
|
@@ -6799,9 +6853,9 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6799
6853
|
item.execute();
|
|
6800
6854
|
continue;
|
|
6801
6855
|
}
|
|
6802
|
-
this._execute(item);
|
|
6856
|
+
this._execute(item, refOffsetX, refOffsetY);
|
|
6803
6857
|
}
|
|
6804
|
-
return node.execute(), AstNodePromiseType.SUCCESS;
|
|
6858
|
+
return node.nodeType === NodeType.REFERENCE && node.setRefOffset(refOffsetX, refOffsetY), node.execute(), AstNodePromiseType.SUCCESS;
|
|
6805
6859
|
}
|
|
6806
6860
|
}, __name(_a8, "Interpreter"), _a8);
|
|
6807
6861
|
Interpreter = __decorateClass$g([
|
|
@@ -7240,6 +7294,21 @@ const _AsyncArrayObject = class _AsyncArrayObject extends ObjectClassType {
|
|
|
7240
7294
|
};
|
|
7241
7295
|
__name(_AsyncArrayObject, "AsyncArrayObject");
|
|
7242
7296
|
let AsyncArrayObject = _AsyncArrayObject;
|
|
7297
|
+
function getAstNodeTopParent(node) {
|
|
7298
|
+
let parent = node;
|
|
7299
|
+
for (; parent != null && parent.getParent(); )
|
|
7300
|
+
parent = parent.getParent();
|
|
7301
|
+
return parent;
|
|
7302
|
+
}
|
|
7303
|
+
__name(getAstNodeTopParent, "getAstNodeTopParent");
|
|
7304
|
+
function generateExecuteAstNodeData(node, refOffsetX = 0, refOffsetY = 0) {
|
|
7305
|
+
return {
|
|
7306
|
+
node,
|
|
7307
|
+
refOffsetX,
|
|
7308
|
+
refOffsetY
|
|
7309
|
+
};
|
|
7310
|
+
}
|
|
7311
|
+
__name(generateExecuteAstNodeData, "generateExecuteAstNodeData");
|
|
7243
7312
|
function getRootLexerHasValueNode(node) {
|
|
7244
7313
|
if (!node)
|
|
7245
7314
|
return;
|
|
@@ -7271,9 +7340,9 @@ const _LambdaValueObjectObject = class _LambdaValueObjectObject extends BaseValu
|
|
|
7271
7340
|
this._setLambdaPrivacyValueMap(variants), this._setLambdaNodeValue(this._lambdaNode), this._lambdaNode.setNotEmpty(!1);
|
|
7272
7341
|
let value;
|
|
7273
7342
|
if (this._interpreter.checkAsyncNode(this._lambdaNode))
|
|
7274
|
-
value = new AsyncObject(this._interpreter.executeAsync(this._lambdaNode));
|
|
7343
|
+
value = new AsyncObject(this._interpreter.executeAsync(generateExecuteAstNodeData(this._lambdaNode)));
|
|
7275
7344
|
else {
|
|
7276
|
-
const o = this._interpreter.execute(this._lambdaNode);
|
|
7345
|
+
const o = this._interpreter.execute(generateExecuteAstNodeData(this._lambdaNode));
|
|
7277
7346
|
o.isReferenceObject() ? value = o.toArrayValueObject() : value = o;
|
|
7278
7347
|
}
|
|
7279
7348
|
return this._lambdaNode.setNotEmpty(!0), value;
|
|
@@ -7562,7 +7631,7 @@ let RangeReferenceObject = _RangeReferenceObject;
|
|
|
7562
7631
|
const _CellReferenceObject = class _CellReferenceObject extends BaseReferenceObject {
|
|
7563
7632
|
constructor(token) {
|
|
7564
7633
|
super(token);
|
|
7565
|
-
const grid =
|
|
7634
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7566
7635
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName), this.setRangeData(grid.range);
|
|
7567
7636
|
}
|
|
7568
7637
|
isCell() {
|
|
@@ -7603,7 +7672,7 @@ let CellReferenceObject = _CellReferenceObject;
|
|
|
7603
7672
|
const _ColumnReferenceObject = class _ColumnReferenceObject extends BaseReferenceObject {
|
|
7604
7673
|
constructor(token) {
|
|
7605
7674
|
super(token);
|
|
7606
|
-
const grid =
|
|
7675
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7607
7676
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
7608
7677
|
const range = {
|
|
7609
7678
|
startColumn: grid.range.startColumn,
|
|
@@ -7634,7 +7703,7 @@ let ColumnReferenceObject = _ColumnReferenceObject;
|
|
|
7634
7703
|
const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObject {
|
|
7635
7704
|
constructor(token) {
|
|
7636
7705
|
super(token);
|
|
7637
|
-
const grid =
|
|
7706
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7638
7707
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
7639
7708
|
const range = {
|
|
7640
7709
|
startColumn: Number.NaN,
|
|
@@ -7662,58 +7731,6 @@ const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObjec
|
|
|
7662
7731
|
};
|
|
7663
7732
|
__name(_RowReferenceObject, "RowReferenceObject");
|
|
7664
7733
|
let RowReferenceObject = _RowReferenceObject;
|
|
7665
|
-
const _TableReferenceObject = class _TableReferenceObject extends BaseReferenceObject {
|
|
7666
|
-
constructor(token, _tableData, _columnDataString, tableOptionMap) {
|
|
7667
|
-
super(token), this._tableData = _tableData, this._columnDataString = _columnDataString;
|
|
7668
|
-
const sheetId = this._tableData.sheetId, range = this._tableData.range, titleMap = this._tableData.titleMap;
|
|
7669
|
-
this.setForcedSheetIdDirect(sheetId);
|
|
7670
|
-
const columnData = this._stringToColumnData(this._columnDataString, titleMap, tableOptionMap), startColumn = columnData.startColumn, endColumn = columnData.endColumn, type = columnData.type;
|
|
7671
|
-
let startRow = -1, endRow = -1;
|
|
7672
|
-
const tableStartRow = range.startRow, tableEndRow = range.startColumn;
|
|
7673
|
-
type === TableOptionType.ALL ? (startRow = tableStartRow, endRow = tableEndRow) : type === TableOptionType.DATA ? (startRow = tableStartRow + 1, endRow = tableEndRow) : type === TableOptionType.HEADERS ? (startRow = tableStartRow, endRow = tableStartRow) : type === TableOptionType.TOTALS && (startRow = tableEndRow, endRow = tableEndRow), this.setRangeData({
|
|
7674
|
-
startColumn,
|
|
7675
|
-
endColumn,
|
|
7676
|
-
startRow,
|
|
7677
|
-
endRow
|
|
7678
|
-
});
|
|
7679
|
-
}
|
|
7680
|
-
isTable() {
|
|
7681
|
-
return !0;
|
|
7682
|
-
}
|
|
7683
|
-
_stringToColumnData(columnDataString, titleMap, tableOptionMap) {
|
|
7684
|
-
columnDataString = columnDataString.substring(1, -1);
|
|
7685
|
-
const commaIndex = columnDataString.indexOf(matchToken.COMMA);
|
|
7686
|
-
let startColumn = -1, endColumn = -1, type = TableOptionType.ALL;
|
|
7687
|
-
if (commaIndex === -1) {
|
|
7688
|
-
const data = this._columnHandler(columnDataString, titleMap);
|
|
7689
|
-
startColumn = data.startColumn, endColumn = data.endColumn;
|
|
7690
|
-
} else {
|
|
7691
|
-
const rowString = columnDataString.substring(0, commaIndex).substring(1, -1), columnString = columnDataString.substring(commaIndex + 1), data = this._columnHandler(columnString, titleMap, !0);
|
|
7692
|
-
startColumn = data.startColumn, endColumn = data.endColumn, type = tableOptionMap.get(rowString), type || (type = TableOptionType.ALL);
|
|
7693
|
-
}
|
|
7694
|
-
return {
|
|
7695
|
-
startColumn,
|
|
7696
|
-
endColumn,
|
|
7697
|
-
type
|
|
7698
|
-
};
|
|
7699
|
-
}
|
|
7700
|
-
_columnHandler(rightString, titleMap, isSingle = !1) {
|
|
7701
|
-
var _a27, _b, _c;
|
|
7702
|
-
let startColumn = -1, endColumn = -1;
|
|
7703
|
-
const colonIndex = rightString.indexOf(matchToken.COLON);
|
|
7704
|
-
if (new RegExp($SUPER_TABLE_COLUMN_REGEX, "g").test(rightString)) {
|
|
7705
|
-
const startColumnString = rightString.substring(0, colonIndex).substring(1, -1), endColumnString = rightString.substring(colonIndex + 1).substring(1, -1);
|
|
7706
|
-
startColumn = (_a27 = titleMap.get(startColumnString)) != null ? _a27 : -1, endColumn = (_b = titleMap.get(endColumnString)) != null ? _b : -1;
|
|
7707
|
-
} else
|
|
7708
|
-
isSingle && (rightString = rightString.substring(1, -1)), startColumn = (_c = titleMap.get(rightString)) != null ? _c : -1, endColumn = startColumn;
|
|
7709
|
-
return {
|
|
7710
|
-
startColumn,
|
|
7711
|
-
endColumn
|
|
7712
|
-
};
|
|
7713
|
-
}
|
|
7714
|
-
};
|
|
7715
|
-
__name(_TableReferenceObject, "TableReferenceObject");
|
|
7716
|
-
let TableReferenceObject = _TableReferenceObject;
|
|
7717
7734
|
var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
7718
7735
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7719
7736
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -7721,7 +7738,10 @@ var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPrope
|
|
|
7721
7738
|
}, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
|
|
7722
7739
|
const _ReferenceNode = class _ReferenceNode extends BaseAstNode {
|
|
7723
7740
|
constructor(_accessor, _operatorString, _referenceObject, _isPrepareMerge = !1) {
|
|
7724
|
-
super(_operatorString)
|
|
7741
|
+
super(_operatorString);
|
|
7742
|
+
__publicField(this, "_refOffsetX", 0);
|
|
7743
|
+
__publicField(this, "_refOffsetY", 0);
|
|
7744
|
+
this._accessor = _accessor, this._operatorString = _operatorString, this._referenceObject = _referenceObject, this._isPrepareMerge = _isPrepareMerge;
|
|
7725
7745
|
}
|
|
7726
7746
|
get nodeType() {
|
|
7727
7747
|
return NodeType.REFERENCE;
|
|
@@ -7732,6 +7752,15 @@ const _ReferenceNode = class _ReferenceNode extends BaseAstNode {
|
|
|
7732
7752
|
const { x, y } = this.getRefOffset();
|
|
7733
7753
|
this._referenceObject.setRefOffset(x, y), !this._isPrepareMerge && this._referenceObject.isExceedRange() ? this.setValue(ErrorValueObject.create(ErrorType$1.NAME)) : this.setValue(this._referenceObject);
|
|
7734
7754
|
}
|
|
7755
|
+
setRefOffset(x = 0, y = 0) {
|
|
7756
|
+
this._refOffsetX = x, this._refOffsetY = y;
|
|
7757
|
+
}
|
|
7758
|
+
getRefOffset() {
|
|
7759
|
+
return {
|
|
7760
|
+
x: this._refOffsetX,
|
|
7761
|
+
y: this._refOffsetY
|
|
7762
|
+
};
|
|
7763
|
+
}
|
|
7735
7764
|
};
|
|
7736
7765
|
__name(_ReferenceNode, "ReferenceNode");
|
|
7737
7766
|
let ReferenceNode = _ReferenceNode;
|
|
@@ -7751,25 +7780,7 @@ let ReferenceNodeFactory = (_a11 = class extends BaseAstNodeFactory {
|
|
|
7751
7780
|
if (!isLexerNode && tokenTrim.charAt(0) === '"' && tokenTrim.charAt(tokenTrim.length - 1) === '"')
|
|
7752
7781
|
return;
|
|
7753
7782
|
let node;
|
|
7754
|
-
if (new
|
|
7755
|
-
node = new ReferenceNode(this._injector, tokenTrim, new CellReferenceObject(tokenTrim), isPrepareMerge);
|
|
7756
|
-
else if (isLexerNode && this._checkParentIsUnionOperator(param))
|
|
7757
|
-
new RegExp(REFERENCE_REGEX_SINGLE_ROW).test(tokenTrim) ? node = new ReferenceNode(this._injector, tokenTrim, new RowReferenceObject(tokenTrim), isPrepareMerge) : new RegExp(REFERENCE_REGEX_SINGLE_COLUMN).test(tokenTrim) && (node = new ReferenceNode(this._injector, tokenTrim, new ColumnReferenceObject(tokenTrim), isPrepareMerge));
|
|
7758
|
-
else {
|
|
7759
|
-
const unitId = this._formulaRuntimeService.currentUnitId, tableMap = this._superTableService.getTableMap(unitId), $regex = new RegExp($SUPER_TABLE_COLUMN_REGEX, "g"), tableName = tokenTrim.replace($regex, "");
|
|
7760
|
-
if (!isLexerNode && (tableMap != null && tableMap.has(tableName))) {
|
|
7761
|
-
const columnResult = $regex.exec(tokenTrim);
|
|
7762
|
-
let columnDataString = "";
|
|
7763
|
-
columnResult && (columnDataString = columnResult[0]);
|
|
7764
|
-
const tableData = tableMap.get(tableName), tableOption = this._superTableService.getTableOptionMap();
|
|
7765
|
-
node = new ReferenceNode(
|
|
7766
|
-
this._injector,
|
|
7767
|
-
tokenTrim,
|
|
7768
|
-
new TableReferenceObject(tokenTrim, tableData, columnDataString, tableOption)
|
|
7769
|
-
);
|
|
7770
|
-
}
|
|
7771
|
-
}
|
|
7772
|
-
if (node)
|
|
7783
|
+
if (regexTestSingeRange(tokenTrim) ? node = new ReferenceNode(this._injector, tokenTrim, new CellReferenceObject(tokenTrim), isPrepareMerge) : isLexerNode && this._checkParentIsUnionOperator(param) && (regexTestSingleRow(tokenTrim) ? node = new ReferenceNode(this._injector, tokenTrim, new RowReferenceObject(tokenTrim), isPrepareMerge) : regexTestSingleColumn(tokenTrim) && (node = new ReferenceNode(this._injector, tokenTrim, new ColumnReferenceObject(tokenTrim), isPrepareMerge))), node)
|
|
7773
7784
|
return atPrefixNode ? node.setParent(atPrefixNode) : minusPrefixNode && node.setParent(minusPrefixNode), node;
|
|
7774
7785
|
}
|
|
7775
7786
|
_checkParentIsUnionOperator(param) {
|
|
@@ -7935,13 +7946,6 @@ const _ValueNodeFactory = class _ValueNodeFactory extends BaseAstNodeFactory {
|
|
|
7935
7946
|
};
|
|
7936
7947
|
__name(_ValueNodeFactory, "ValueNodeFactory");
|
|
7937
7948
|
let ValueNodeFactory = _ValueNodeFactory;
|
|
7938
|
-
function getAstNodeTopParent(node) {
|
|
7939
|
-
let parent = node;
|
|
7940
|
-
for (; parent != null && parent.getParent(); )
|
|
7941
|
-
parent = parent.getParent();
|
|
7942
|
-
return parent;
|
|
7943
|
-
}
|
|
7944
|
-
__name(getAstNodeTopParent, "getAstNodeTopParent");
|
|
7945
7949
|
var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
7946
7950
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7947
7951
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -7960,10 +7964,8 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
7960
7964
|
nodeFactory.dispose();
|
|
7961
7965
|
}), this._astNodeFactoryList = [];
|
|
7962
7966
|
}
|
|
7963
|
-
parse(lexerNode
|
|
7964
|
-
const astNode = new AstRootNode(DEFAULT_TOKEN_TYPE_ROOT);
|
|
7965
|
-
this._refOffsetX = refOffsetX, this._refOffsetY = refOffsetY;
|
|
7966
|
-
const node = this._parse(lexerNode, astNode);
|
|
7967
|
+
parse(lexerNode) {
|
|
7968
|
+
const astNode = new AstRootNode(DEFAULT_TOKEN_TYPE_ROOT), node = this._parse(lexerNode, astNode);
|
|
7967
7969
|
return lexerNode.hasDefinedNames() && (node == null || node.setDefinedNames(lexerNode.getDefinedNames())), node;
|
|
7968
7970
|
}
|
|
7969
7971
|
_lambdaParameterHandler(lexerNode, parent) {
|
|
@@ -8059,7 +8061,7 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8059
8061
|
break;
|
|
8060
8062
|
}
|
|
8061
8063
|
case NodeType.REFERENCE:
|
|
8062
|
-
|
|
8064
|
+
calculateStack.push(astNode);
|
|
8063
8065
|
break;
|
|
8064
8066
|
case NodeType.ROOT:
|
|
8065
8067
|
calculateStack.push(astNode);
|
|
@@ -8071,7 +8073,7 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8071
8073
|
calculateStack.push(astNode);
|
|
8072
8074
|
break;
|
|
8073
8075
|
case NodeType.PREFIX:
|
|
8074
|
-
|
|
8076
|
+
calculateStack.push(astNode);
|
|
8075
8077
|
break;
|
|
8076
8078
|
case NodeType.SUFFIX:
|
|
8077
8079
|
calculateStack.push(astNode);
|
|
@@ -8083,13 +8085,16 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8083
8085
|
calculateStack[i].setParent(currentAstNode);
|
|
8084
8086
|
return currentAstNode;
|
|
8085
8087
|
}
|
|
8086
|
-
_setPrefixRefOffset(astNode) {
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8088
|
+
// private _setPrefixRefOffset(astNode: BaseAstNode) {
|
|
8089
|
+
// const children = astNode.getChildren();
|
|
8090
|
+
// const childrenCount = children.length;
|
|
8091
|
+
// for (let i = 0; i < childrenCount; i++) {
|
|
8092
|
+
// const item = children[i];
|
|
8093
|
+
// if (item.nodeType === NodeType.REFERENCE) {
|
|
8094
|
+
// item.setRefOffset(this._refOffsetX, this._refOffsetY);
|
|
8095
|
+
// }
|
|
8096
|
+
// }
|
|
8097
|
+
// }
|
|
8093
8098
|
_checkAstNode(item) {
|
|
8094
8099
|
let astNode = null;
|
|
8095
8100
|
const astNodeFactoryListCount = this._astNodeFactoryList.length;
|
|
@@ -8132,36 +8137,48 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8132
8137
|
__publicField(this, "_featureFormulaData", {});
|
|
8133
8138
|
__publicField(this, "_formulaData", {});
|
|
8134
8139
|
__publicField(this, "_dependencyRTreeCache", new RTree());
|
|
8135
|
-
__publicField(this, "
|
|
8140
|
+
__publicField(this, "_dependencyTreeIdLast", 0);
|
|
8136
8141
|
}
|
|
8137
8142
|
dispose() {
|
|
8138
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.dispose(), this.
|
|
8143
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.dispose(), this._restDependencyTreeId();
|
|
8139
8144
|
}
|
|
8140
8145
|
/**
|
|
8141
8146
|
* Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
|
|
8142
8147
|
* return FormulaDependencyTree[]
|
|
8143
8148
|
*/
|
|
8144
8149
|
getAllTree() {
|
|
8145
|
-
const trees = []
|
|
8146
|
-
return Object.values(this._otherFormulaData).forEach((unit) => {
|
|
8147
|
-
if (unit == null)
|
|
8148
|
-
return !0;
|
|
8149
|
-
Object.values(unit).forEach((sheet) => {
|
|
8150
|
-
Object.values(sheet).forEach((formula) => {
|
|
8151
|
-
formula && (formula.resetState(), trees.push(formula));
|
|
8152
|
-
});
|
|
8153
|
-
});
|
|
8154
|
-
}), Object.values(this._featureFormulaData).forEach((unit) => {
|
|
8155
|
-
if (unit == null)
|
|
8156
|
-
return !0;
|
|
8157
|
-
Object.values(unit).forEach((sheet) => {
|
|
8158
|
-
Object.values(sheet).forEach((feature) => {
|
|
8159
|
-
feature && (feature.resetState(), trees.push(feature));
|
|
8160
|
-
});
|
|
8161
|
-
});
|
|
8162
|
-
}), Object.values(this._formulaData).map((unit) => unit == null ? [] : Object.values(unit).forEach((sheet) => sheet.forValue((row, col, item) => {
|
|
8150
|
+
const trees = [], resetAndPush = /* @__PURE__ */ __name((item) => {
|
|
8163
8151
|
item && (item.resetState(), trees.push(item));
|
|
8164
|
-
}
|
|
8152
|
+
}, "resetAndPush");
|
|
8153
|
+
for (const unitKey in this._otherFormulaData) {
|
|
8154
|
+
const unit = this._otherFormulaData[unitKey];
|
|
8155
|
+
if (unit)
|
|
8156
|
+
for (const sheetKey in unit) {
|
|
8157
|
+
const sheet = unit[sheetKey];
|
|
8158
|
+
for (const formulaKey in sheet)
|
|
8159
|
+
sheet[formulaKey] != null && resetAndPush(sheet[formulaKey]);
|
|
8160
|
+
}
|
|
8161
|
+
}
|
|
8162
|
+
for (const unitKey in this._featureFormulaData) {
|
|
8163
|
+
const unit = this._featureFormulaData[unitKey];
|
|
8164
|
+
if (unit)
|
|
8165
|
+
for (const sheetKey in unit) {
|
|
8166
|
+
const sheet = unit[sheetKey];
|
|
8167
|
+
for (const featureKey in sheet)
|
|
8168
|
+
sheet[featureKey] != null && resetAndPush(sheet[featureKey]);
|
|
8169
|
+
}
|
|
8170
|
+
}
|
|
8171
|
+
for (const unitKey in this._formulaData) {
|
|
8172
|
+
const unit = this._formulaData[unitKey];
|
|
8173
|
+
if (unit)
|
|
8174
|
+
for (const sheetKey in unit)
|
|
8175
|
+
unit[sheetKey].forValue((row, col, item) => {
|
|
8176
|
+
if (item == null)
|
|
8177
|
+
return !0;
|
|
8178
|
+
resetAndPush(item);
|
|
8179
|
+
});
|
|
8180
|
+
}
|
|
8181
|
+
return trees;
|
|
8165
8182
|
}
|
|
8166
8183
|
buildDependencyTree(shouldBeBuildTrees, dependencyTrees = []) {
|
|
8167
8184
|
const allTrees = this.getAllTree();
|
|
@@ -8177,17 +8194,18 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8177
8194
|
*/
|
|
8178
8195
|
_buildDependencyTree(allTrees, shouldBeBuildTrees) {
|
|
8179
8196
|
const shouldBeBuildTreeMap = /* @__PURE__ */ new Map();
|
|
8180
|
-
|
|
8181
|
-
const
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
}
|
|
8190
|
-
}
|
|
8197
|
+
for (let i = 0; i < shouldBeBuildTrees.length; i++) {
|
|
8198
|
+
const tree = shouldBeBuildTrees[i];
|
|
8199
|
+
shouldBeBuildTreeMap.set(tree.treeId, tree);
|
|
8200
|
+
}
|
|
8201
|
+
for (let i = 0; i < allTrees.length; i++) {
|
|
8202
|
+
const tree = allTrees[i], RTreeItem = tree.toRTreeItem(), searchResults = this._dependencyRTreeCache.search(RTreeItem);
|
|
8203
|
+
for (let j = 0; j < searchResults.length; j++) {
|
|
8204
|
+
const searchResult = searchResults[j], shouldBeBuildTree = shouldBeBuildTreeMap.get(searchResult.id);
|
|
8205
|
+
shouldBeBuildTree && tree !== shouldBeBuildTree && !shouldBeBuildTree.hasChildren(tree) && shouldBeBuildTree.pushChildren(tree);
|
|
8206
|
+
}
|
|
8207
|
+
}
|
|
8208
|
+
shouldBeBuildTreeMap.clear();
|
|
8191
8209
|
}
|
|
8192
8210
|
/**
|
|
8193
8211
|
* Build the reverse dependency relationship between the trees.
|
|
@@ -8196,17 +8214,18 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8196
8214
|
*/
|
|
8197
8215
|
_buildReverseDependency(allTrees, dependencyTrees) {
|
|
8198
8216
|
const allTreeMap = /* @__PURE__ */ new Map();
|
|
8199
|
-
|
|
8200
|
-
const
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
}
|
|
8209
|
-
}
|
|
8217
|
+
for (let i = 0; i < allTrees.length; i++) {
|
|
8218
|
+
const tree = allTrees[i];
|
|
8219
|
+
allTreeMap.set(tree.treeId, tree);
|
|
8220
|
+
}
|
|
8221
|
+
for (let i = 0; i < dependencyTrees.length; i++) {
|
|
8222
|
+
const tree = dependencyTrees[i], RTreeItem = tree.toRTreeItem(), searchResults = this._dependencyRTreeCache.search(RTreeItem);
|
|
8223
|
+
for (let j = 0; j < searchResults.length; j++) {
|
|
8224
|
+
const searchResult = searchResults[j], allTree = allTreeMap.get(searchResult.id);
|
|
8225
|
+
allTree && tree !== allTree && !allTree.hasChildren(tree) && allTree.pushChildren(tree);
|
|
8226
|
+
}
|
|
8227
|
+
}
|
|
8228
|
+
allTreeMap.clear();
|
|
8210
8229
|
}
|
|
8211
8230
|
/**
|
|
8212
8231
|
* Clear the dependency relationship of the tree.
|
|
@@ -8226,15 +8245,15 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8226
8245
|
this._buildDependencyTree(parentsArray, childrenArray), this._buildReverseDependency(parentsArray, childrenArray), shouldBeClearTree.dispose();
|
|
8227
8246
|
}
|
|
8228
8247
|
reset() {
|
|
8229
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this.
|
|
8248
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this._restDependencyTreeId();
|
|
8230
8249
|
}
|
|
8231
8250
|
addOtherFormulaDependency(unitId, sheetId, formulaId, dependencyTree) {
|
|
8232
|
-
this._otherFormulaData[unitId] || (this._otherFormulaData[unitId] = {}), this._otherFormulaData[unitId][sheetId] || (this._otherFormulaData[unitId][sheetId] = {}), this._otherFormulaData[unitId][sheetId][formulaId] = dependencyTree
|
|
8251
|
+
this._otherFormulaData[unitId] || (this._otherFormulaData[unitId] = {}), this._otherFormulaData[unitId][sheetId] || (this._otherFormulaData[unitId][sheetId] = {}), this._otherFormulaData[unitId][sheetId][formulaId] = dependencyTree;
|
|
8233
8252
|
}
|
|
8234
8253
|
removeOtherFormulaDependency(unitId, sheetId, formulaIds) {
|
|
8235
8254
|
this._otherFormulaData[unitId] && this._otherFormulaData[unitId][sheetId] && formulaIds.forEach((formulaId) => {
|
|
8236
8255
|
const deleteTree = this._otherFormulaData[unitId][sheetId][formulaId];
|
|
8237
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._otherFormulaData[unitId][sheetId][formulaId]
|
|
8256
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._otherFormulaData[unitId][sheetId][formulaId];
|
|
8238
8257
|
});
|
|
8239
8258
|
}
|
|
8240
8259
|
getOtherFormulaDependency(unitId, sheetId, formulaId) {
|
|
@@ -8248,36 +8267,36 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8248
8267
|
clearOtherFormulaDependency(unitId, sheetId) {
|
|
8249
8268
|
if (sheetId && this._otherFormulaData[unitId] && this._otherFormulaData[unitId][sheetId])
|
|
8250
8269
|
this._removeDependencyRTreeCacheById(unitId, sheetId), Object.values(this._otherFormulaData[unitId][sheetId]).forEach((formula) => {
|
|
8251
|
-
this.clearDependencyForTree(formula)
|
|
8270
|
+
this.clearDependencyForTree(formula);
|
|
8252
8271
|
}), this._otherFormulaData[unitId][sheetId] = {};
|
|
8253
8272
|
else if (this._otherFormulaData[unitId]) {
|
|
8254
8273
|
const unitOtherData = this._otherFormulaData[unitId];
|
|
8255
8274
|
Object.keys(unitOtherData).forEach((sheetId2) => {
|
|
8256
8275
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), Object.values(unitOtherData[sheetId2]).forEach((formula) => {
|
|
8257
|
-
this.clearDependencyForTree(formula)
|
|
8276
|
+
this.clearDependencyForTree(formula);
|
|
8258
8277
|
}));
|
|
8259
8278
|
}), this._otherFormulaData[unitId] = null;
|
|
8260
8279
|
}
|
|
8261
8280
|
}
|
|
8262
8281
|
addFeatureFormulaDependency(unitId, sheetId, featureId, dependencyTree) {
|
|
8263
|
-
this._featureFormulaData[unitId] || (this._featureFormulaData[unitId] = {}), this._featureFormulaData[unitId][sheetId] || (this._featureFormulaData[unitId][sheetId] = {}), this._featureFormulaData[unitId][sheetId][featureId] = dependencyTree
|
|
8282
|
+
this._featureFormulaData[unitId] || (this._featureFormulaData[unitId] = {}), this._featureFormulaData[unitId][sheetId] || (this._featureFormulaData[unitId][sheetId] = {}), this._featureFormulaData[unitId][sheetId][featureId] = dependencyTree;
|
|
8264
8283
|
}
|
|
8265
8284
|
removeFeatureFormulaDependency(unitId, sheetId, featureIds) {
|
|
8266
8285
|
this._featureFormulaData[unitId] && this._featureFormulaData[unitId][sheetId] && featureIds.forEach((featureId) => {
|
|
8267
8286
|
const deleteTree = this._featureFormulaData[unitId][sheetId][featureId];
|
|
8268
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._featureFormulaData[unitId][sheetId][featureId]
|
|
8287
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._featureFormulaData[unitId][sheetId][featureId];
|
|
8269
8288
|
});
|
|
8270
8289
|
}
|
|
8271
8290
|
clearFeatureFormulaDependency(unitId, sheetId) {
|
|
8272
8291
|
if (sheetId && this._featureFormulaData[unitId] && this._featureFormulaData[unitId][sheetId])
|
|
8273
8292
|
this._removeDependencyRTreeCacheById(unitId, sheetId), Object.values(this._featureFormulaData[unitId][sheetId]).forEach((feature) => {
|
|
8274
|
-
this._removeDependencyRTreeCache(feature), this.clearDependencyForTree(feature)
|
|
8293
|
+
this._removeDependencyRTreeCache(feature), this.clearDependencyForTree(feature);
|
|
8275
8294
|
}), this._featureFormulaData[unitId][sheetId] = {};
|
|
8276
8295
|
else if (this._featureFormulaData[unitId]) {
|
|
8277
8296
|
const unitFeatureData = this._featureFormulaData[unitId];
|
|
8278
8297
|
Object.keys(unitFeatureData).forEach((sheetId2) => {
|
|
8279
8298
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), Object.values(unitFeatureData[sheetId2]).forEach((feature) => {
|
|
8280
|
-
this.clearDependencyForTree(feature)
|
|
8299
|
+
this.clearDependencyForTree(feature);
|
|
8281
8300
|
}));
|
|
8282
8301
|
}), this._featureFormulaData[unitId] = null;
|
|
8283
8302
|
}
|
|
@@ -8287,30 +8306,30 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8287
8306
|
return (_b = (_a27 = this._featureFormulaData[unitId]) == null ? void 0 : _a27[sheetId]) == null ? void 0 : _b[featureId];
|
|
8288
8307
|
}
|
|
8289
8308
|
addFormulaDependency(unitId, sheetId, row, column, dependencyTree) {
|
|
8290
|
-
this._formulaData[unitId] || (this._formulaData[unitId] = {}), this._formulaData[unitId][sheetId] || (this._formulaData[unitId][sheetId] = new ObjectMatrix()), this._formulaData[unitId][sheetId].setValue(row, column, dependencyTree)
|
|
8309
|
+
this._formulaData[unitId] || (this._formulaData[unitId] = {}), this._formulaData[unitId][sheetId] || (this._formulaData[unitId][sheetId] = new ObjectMatrix()), this._formulaData[unitId][sheetId].setValue(row, column, dependencyTree);
|
|
8291
8310
|
}
|
|
8292
8311
|
removeFormulaDependency(unitId, sheetId, row, column) {
|
|
8293
8312
|
if (this._formulaData[unitId] && this._formulaData[unitId][sheetId]) {
|
|
8294
8313
|
const deleteTree = this._formulaData[unitId][sheetId].getValue(row, column);
|
|
8295
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), this._formulaData[unitId][sheetId].realDeleteValue(row, column)
|
|
8314
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), this._formulaData[unitId][sheetId].realDeleteValue(row, column);
|
|
8296
8315
|
}
|
|
8297
8316
|
}
|
|
8298
8317
|
clearFormulaDependency(unitId, sheetId) {
|
|
8299
8318
|
if (sheetId && this._formulaData[unitId] && this._formulaData[unitId][sheetId])
|
|
8300
8319
|
this._removeDependencyRTreeCacheById(unitId, sheetId), this._formulaData[unitId][sheetId].forValue((row, column, item) => {
|
|
8301
|
-
this.clearDependencyForTree(item)
|
|
8320
|
+
this.clearDependencyForTree(item);
|
|
8302
8321
|
}), this._formulaData[unitId][sheetId].reset();
|
|
8303
8322
|
else if (this._formulaData[unitId]) {
|
|
8304
8323
|
const unitFormulaData = this._formulaData[unitId];
|
|
8305
8324
|
Object.keys(unitFormulaData).forEach((sheetId2) => {
|
|
8306
8325
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), unitFormulaData[sheetId2].forValue((row, column, item) => {
|
|
8307
|
-
this.clearDependencyForTree(item)
|
|
8326
|
+
this.clearDependencyForTree(item);
|
|
8308
8327
|
}));
|
|
8309
8328
|
}), this._formulaData[unitId] = null;
|
|
8310
8329
|
}
|
|
8311
8330
|
}
|
|
8312
8331
|
clearDependencyAll() {
|
|
8313
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this.
|
|
8332
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this._restDependencyTreeId();
|
|
8314
8333
|
}
|
|
8315
8334
|
getFormulaDependency(unitId, sheetId, row, column) {
|
|
8316
8335
|
var _a27, _b;
|
|
@@ -8322,17 +8341,12 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8322
8341
|
id: tree.treeId
|
|
8323
8342
|
})));
|
|
8324
8343
|
}
|
|
8325
|
-
|
|
8326
|
-
this.
|
|
8344
|
+
_restDependencyTreeId() {
|
|
8345
|
+
this._dependencyTreeIdLast = 0;
|
|
8327
8346
|
}
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
_clearTreeIdCache() {
|
|
8332
|
-
this._dependencyTreeIdsCache.clear();
|
|
8333
|
-
}
|
|
8334
|
-
hasTreeIdInCache(treeId) {
|
|
8335
|
-
return this._dependencyTreeIdsCache.has(treeId);
|
|
8347
|
+
getLastTreeId() {
|
|
8348
|
+
const id = this._dependencyTreeIdLast;
|
|
8349
|
+
return this._dependencyTreeIdLast++, id;
|
|
8336
8350
|
}
|
|
8337
8351
|
_removeDependencyRTreeCacheById(unitId, sheetId) {
|
|
8338
8352
|
this._dependencyRTreeCache.removeById(unitId, sheetId);
|
|
@@ -8347,7 +8361,7 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8347
8361
|
this._formulaData[unitId] && Object.values(this._formulaData[unitId]).forEach((sheet) => {
|
|
8348
8362
|
sheet.forValue((row, column, tree) => {
|
|
8349
8363
|
var _a27;
|
|
8350
|
-
(_a27 = tree == null ? void 0 : tree.
|
|
8364
|
+
(_a27 = tree == null ? void 0 : tree.nodeData) != null && _a27.node.hasDefinedName(definedName) && (this._removeDependencyRTreeCache(tree), this.clearDependencyForTree(tree), sheet.realDeleteValue(row, column));
|
|
8351
8365
|
});
|
|
8352
8366
|
});
|
|
8353
8367
|
}
|
|
@@ -8480,11 +8494,10 @@ __name(_OtherFormulaManagerService, "OtherFormulaManagerService");
|
|
|
8480
8494
|
let OtherFormulaManagerService = _OtherFormulaManagerService;
|
|
8481
8495
|
const IOtherFormulaManagerService = createIdentifier(
|
|
8482
8496
|
"univer.formula.other-formula-manager.service"
|
|
8483
|
-
), _FormulaDependencyTree = class _FormulaDependencyTree
|
|
8497
|
+
), _FormulaDependencyTree = class _FormulaDependencyTree {
|
|
8484
8498
|
constructor(treeId) {
|
|
8485
|
-
super();
|
|
8486
8499
|
__publicField(this, "treeId", "");
|
|
8487
|
-
__publicField(this, "
|
|
8500
|
+
__publicField(this, "nodeData");
|
|
8488
8501
|
__publicField(this, "children", /* @__PURE__ */ new Set());
|
|
8489
8502
|
__publicField(this, "parents", /* @__PURE__ */ new Set());
|
|
8490
8503
|
__publicField(this, "formula", "");
|
|
@@ -8504,7 +8517,7 @@ const IOtherFormulaManagerService = createIdentifier(
|
|
|
8504
8517
|
}
|
|
8505
8518
|
dispose() {
|
|
8506
8519
|
var _a27;
|
|
8507
|
-
|
|
8520
|
+
this.children = /* @__PURE__ */ new Set(), this.rangeList = [], this.parents = /* @__PURE__ */ new Set(), (_a27 = this.nodeData) == null || _a27.node.dispose(), this.nodeData = null;
|
|
8508
8521
|
}
|
|
8509
8522
|
disposeWithChildren() {
|
|
8510
8523
|
this.children.forEach((tree) => {
|
|
@@ -8604,19 +8617,16 @@ const IOtherFormulaManagerService = createIdentifier(
|
|
|
8604
8617
|
};
|
|
8605
8618
|
__name(_FormulaDependencyTree, "FormulaDependencyTree");
|
|
8606
8619
|
let FormulaDependencyTree = _FormulaDependencyTree;
|
|
8607
|
-
function generateRandomDependencyTreeId(dependencyManagerService) {
|
|
8608
|
-
let idLength = 4, id = generateRandomId(idLength);
|
|
8609
|
-
for (; dependencyManagerService.hasTreeIdInCache(id); )
|
|
8610
|
-
id = generateRandomId(++idLength);
|
|
8611
|
-
return id;
|
|
8612
|
-
}
|
|
8613
|
-
__name(generateRandomDependencyTreeId, "generateRandomDependencyTreeId");
|
|
8614
8620
|
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
8615
8621
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8616
8622
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8617
8623
|
return kind && result && __defProp$9(target, key, result), result;
|
|
8618
8624
|
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
8619
8625
|
const FORMULA_CACHE_LRU_COUNT = 1e5;
|
|
8626
|
+
function generateRandomDependencyTreeId(dependencyManagerService) {
|
|
8627
|
+
return (dependencyManagerService.getLastTreeId() || 0).toString();
|
|
8628
|
+
}
|
|
8629
|
+
__name(generateRandomDependencyTreeId, "generateRandomDependencyTreeId");
|
|
8620
8630
|
var _a15;
|
|
8621
8631
|
let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
8622
8632
|
constructor(_currentConfigService, _runtimeService, _otherFormulaManagerService, _featureCalculationManagerService, _interpreter, _astTreeBuilder, _lexer, _dependencyManagerService) {
|
|
@@ -8665,23 +8675,46 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8665
8675
|
* @param formulaData
|
|
8666
8676
|
*/
|
|
8667
8677
|
async _generateTreeList(formulaData, otherFormulaData, unitData) {
|
|
8668
|
-
const formulaDataKeys = Object.keys(formulaData), otherFormulaDataKeys = Object.keys(otherFormulaData), treeList = [];
|
|
8669
|
-
this._currentConfigService.isForceCalculate() && (this._dependencyManagerService.reset(), this._formulaASTCache.clear()), this._registerFormulas(formulaDataKeys, formulaData, unitData, treeList), this._registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList), this._registerFeatureFormulas(treeList);
|
|
8678
|
+
const formulaDataKeys = Object.keys(formulaData), otherFormulaDataKeys = Object.keys(otherFormulaData), treeList = [], formulaRefCache = /* @__PURE__ */ new Map();
|
|
8679
|
+
this._currentConfigService.isForceCalculate() && (this._dependencyManagerService.reset(), this._formulaASTCache.clear()), this._registerFormulas(formulaDataKeys, formulaData, unitData, treeList, formulaRefCache), this._registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList, formulaRefCache), this._registerFeatureFormulas(treeList);
|
|
8670
8680
|
for (let i = 0, len = treeList.length; i < len; i++) {
|
|
8671
8681
|
const tree = treeList[i];
|
|
8672
|
-
|
|
8682
|
+
this._runtimeService.setCurrent(
|
|
8673
8683
|
tree.row,
|
|
8674
8684
|
tree.column,
|
|
8675
8685
|
tree.rowCount,
|
|
8676
8686
|
tree.columnCount,
|
|
8677
8687
|
tree.subUnitId,
|
|
8678
8688
|
tree.unitId
|
|
8679
|
-
)
|
|
8689
|
+
);
|
|
8690
|
+
const { unitId, formula, nodeData } = tree;
|
|
8691
|
+
if (nodeData == null)
|
|
8680
8692
|
continue;
|
|
8681
|
-
const
|
|
8682
|
-
|
|
8693
|
+
const { refOffsetX, refOffsetY } = nodeData;
|
|
8694
|
+
let applyCacheRange = !1;
|
|
8695
|
+
if (refOffsetX !== 0 || refOffsetY !== 0) {
|
|
8696
|
+
const refTreeNode = formulaRefCache.get(`${unitId}${formula}`);
|
|
8697
|
+
refTreeNode && refTreeNode.rangeList.length > 0 && (tree.pushRangeList(this._moveRangeList(refTreeNode, refOffsetX, refOffsetY)), applyCacheRange = !0);
|
|
8698
|
+
}
|
|
8699
|
+
if (!applyCacheRange) {
|
|
8700
|
+
const rangeList = await this._getRangeListByNode(nodeData);
|
|
8701
|
+
tree.pushRangeList(rangeList);
|
|
8702
|
+
}
|
|
8703
|
+
tree.isCache || this._dependencyManagerService.addDependencyRTreeCache(tree);
|
|
8683
8704
|
}
|
|
8684
|
-
return treeList;
|
|
8705
|
+
return formulaRefCache.clear(), treeList;
|
|
8706
|
+
}
|
|
8707
|
+
_moveRangeList(tree, refOffsetX, refOffsetY) {
|
|
8708
|
+
const rangeList = tree.rangeList, newRangeList = [];
|
|
8709
|
+
for (let i = 0, len = rangeList.length; i < len; i++) {
|
|
8710
|
+
const range = rangeList[i], newRange = {
|
|
8711
|
+
unitId: tree.unitId,
|
|
8712
|
+
sheetId: tree.subUnitId,
|
|
8713
|
+
range: { ...range.range }
|
|
8714
|
+
};
|
|
8715
|
+
newRange.range.startRow += refOffsetY, newRange.range.endRow += refOffsetY, newRange.range.startColumn += refOffsetX, newRange.range.endColumn += refOffsetX, newRangeList.push(newRange);
|
|
8716
|
+
}
|
|
8717
|
+
return newRangeList;
|
|
8685
8718
|
}
|
|
8686
8719
|
_registerFeatureFormulas(treeList) {
|
|
8687
8720
|
this._featureCalculationManagerService.getReferenceExecutorMap().forEach((subUnitMap, _) => {
|
|
@@ -8701,7 +8734,7 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8701
8734
|
const { unitId, subUnitId, dependencyRanges, getDirtyData } = params, FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
8702
8735
|
return FDtree.unitId = unitId, FDtree.subUnitId = subUnitId, FDtree.getDirtyData = getDirtyData, FDtree.featureId = featureId, FDtree.rangeList = dependencyRanges, this._dependencyManagerService.addFeatureFormulaDependency(unitId, subUnitId, featureId, FDtree), FDtree;
|
|
8703
8736
|
}
|
|
8704
|
-
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
|
|
8737
|
+
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList, formulaRefCache) {
|
|
8705
8738
|
for (const unitId of otherFormulaDataKeys) {
|
|
8706
8739
|
const subComponentData = otherFormulaData[unitId];
|
|
8707
8740
|
if (subComponentData == null)
|
|
@@ -8713,18 +8746,18 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8713
8746
|
continue;
|
|
8714
8747
|
const subFormulaDataKeys = Object.keys(subFormulaData);
|
|
8715
8748
|
for (const subFormulaDataId of subFormulaDataKeys) {
|
|
8716
|
-
const treeCache = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
8749
|
+
const treeCache = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId), formulaDataItem = subFormulaData[subFormulaDataId], { f: formulaString, x = 0, y = 0 } = formulaDataItem;
|
|
8717
8750
|
if (treeCache) {
|
|
8718
|
-
treeCache.isCache = !0;
|
|
8751
|
+
treeCache.isCache = !0, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, treeCache);
|
|
8719
8752
|
continue;
|
|
8720
8753
|
}
|
|
8721
|
-
const
|
|
8722
|
-
FDtree.
|
|
8754
|
+
const nodeData = this._generateAstNode(unitId, formulaString, x, y), FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
8755
|
+
FDtree.nodeData = nodeData, FDtree.formula = formulaString, FDtree.unitId = unitId, FDtree.subUnitId = subUnitId, FDtree.formulaId = subFormulaDataId, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, FDtree), this._dependencyManagerService.addOtherFormulaDependency(unitId, subUnitId, subFormulaDataId, FDtree), treeList.push(FDtree);
|
|
8723
8756
|
}
|
|
8724
8757
|
}
|
|
8725
8758
|
}
|
|
8726
8759
|
}
|
|
8727
|
-
_registerFormulas(formulaDataKeys, formulaData, unitData, treeList) {
|
|
8760
|
+
_registerFormulas(formulaDataKeys, formulaData, unitData, treeList, formulaRefCache) {
|
|
8728
8761
|
for (const unitId of formulaDataKeys) {
|
|
8729
8762
|
const sheetData = formulaData[unitId];
|
|
8730
8763
|
if (sheetData == null)
|
|
@@ -8734,11 +8767,11 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8734
8767
|
new ObjectMatrix(sheetData[sheetId] || {}).forValue((row, column, formulaDataItem) => {
|
|
8735
8768
|
if (formulaDataItem == null)
|
|
8736
8769
|
return !0;
|
|
8737
|
-
const { f: formulaString, x, y } = formulaDataItem, treeCache = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
|
|
8770
|
+
const { f: formulaString, x = 0, y = 0 } = formulaDataItem, treeCache = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
|
|
8738
8771
|
if (treeCache)
|
|
8739
|
-
return treeCache.isCache = !0, !0;
|
|
8740
|
-
const
|
|
8741
|
-
FDtree.
|
|
8772
|
+
return treeCache.isCache = !0, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, treeCache), !0;
|
|
8773
|
+
const nodeData = this._generateAstNode(unitId, formulaString, x, y), FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService)), sheetItem = unitData[unitId][sheetId];
|
|
8774
|
+
FDtree.nodeData = nodeData, FDtree.formula = formulaString, FDtree.unitId = unitId, FDtree.subUnitId = sheetId, FDtree.row = row, FDtree.column = column, FDtree.rowCount = sheetItem.rowCount, FDtree.columnCount = sheetItem.columnCount, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, FDtree), this._dependencyManagerService.addFormulaDependency(unitId, sheetId, row, column, FDtree), treeList.push(FDtree);
|
|
8742
8775
|
});
|
|
8743
8776
|
}
|
|
8744
8777
|
}
|
|
@@ -8756,15 +8789,19 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8756
8789
|
}
|
|
8757
8790
|
}
|
|
8758
8791
|
_generateAstNode(unitId, formulaString, refOffsetX = 0, refOffsetY = 0) {
|
|
8759
|
-
let astNode = this._formulaASTCache.get(`${unitId}${formulaString}
|
|
8792
|
+
let astNode = this._formulaASTCache.get(`${unitId}${formulaString}`);
|
|
8760
8793
|
if (astNode && !this._isDirtyDefinedForNode(astNode))
|
|
8761
|
-
return astNode;
|
|
8794
|
+
return generateExecuteAstNodeData(astNode, refOffsetX, refOffsetY);
|
|
8762
8795
|
const lexerNode = this._lexer.treeBuilder(formulaString);
|
|
8763
8796
|
if (ERROR_TYPE_SET.has(lexerNode))
|
|
8764
|
-
return
|
|
8765
|
-
|
|
8797
|
+
return {
|
|
8798
|
+
node: ErrorNode.create(lexerNode),
|
|
8799
|
+
refOffsetX,
|
|
8800
|
+
refOffsetY
|
|
8801
|
+
};
|
|
8802
|
+
if (astNode = this._astTreeBuilder.parse(lexerNode), astNode == null)
|
|
8766
8803
|
throw new Error("astNode is null");
|
|
8767
|
-
return this._formulaASTCache.set(`${unitId}${formulaString}
|
|
8804
|
+
return this._formulaASTCache.set(`${unitId}${formulaString}`, astNode), generateExecuteAstNodeData(astNode, refOffsetX, refOffsetY);
|
|
8768
8805
|
}
|
|
8769
8806
|
_addFlattenCache(unitId, sheetId, range) {
|
|
8770
8807
|
let unitMatrix = this._updateRangeFlattenCache.get(unitId);
|
|
@@ -8797,25 +8834,30 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8797
8834
|
this._nodeTraversalReferenceFunction(item, result);
|
|
8798
8835
|
}
|
|
8799
8836
|
}
|
|
8800
|
-
async _executeNode(node) {
|
|
8837
|
+
async _executeNode(node, refOffsetX = 0, refOffsetY = 0) {
|
|
8801
8838
|
let value;
|
|
8802
|
-
|
|
8839
|
+
const nodeData = {
|
|
8840
|
+
node,
|
|
8841
|
+
refOffsetX,
|
|
8842
|
+
refOffsetY
|
|
8843
|
+
};
|
|
8844
|
+
return this._interpreter.checkAsyncNode(node) ? value = await this._interpreter.executeAsync(nodeData) : value = this._interpreter.execute(nodeData), value;
|
|
8803
8845
|
}
|
|
8804
8846
|
/**
|
|
8805
8847
|
* Calculate the range required for collection in advance,
|
|
8806
8848
|
* including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
|
|
8807
8849
|
* @param node
|
|
8808
8850
|
*/
|
|
8809
|
-
async _getRangeListByNode(
|
|
8810
|
-
const preCalculateNodeList = [], referenceFunctionList = [];
|
|
8811
|
-
this._nodeTraversalRef(node, preCalculateNodeList), this._nodeTraversalReferenceFunction(node, referenceFunctionList);
|
|
8851
|
+
async _getRangeListByNode(nodeData) {
|
|
8852
|
+
const preCalculateNodeList = [], referenceFunctionList = [], refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
8853
|
+
this._nodeTraversalRef(nodeData.node, preCalculateNodeList), this._nodeTraversalReferenceFunction(nodeData.node, referenceFunctionList);
|
|
8812
8854
|
const rangeList = [];
|
|
8813
8855
|
for (let i = 0, len = preCalculateNodeList.length; i < len; i++) {
|
|
8814
|
-
const
|
|
8856
|
+
const node = preCalculateNodeList[i], gridRange = (await this._executeNode(node, refOffsetX, refOffsetY)).toUnitRange();
|
|
8815
8857
|
rangeList.push(gridRange);
|
|
8816
8858
|
}
|
|
8817
8859
|
for (let i = 0, len = referenceFunctionList.length; i < len; i++) {
|
|
8818
|
-
const
|
|
8860
|
+
const node = referenceFunctionList[i], gridRange = (await this._executeNode(node, refOffsetX, refOffsetY)).toUnitRange();
|
|
8819
8861
|
rangeList.push(gridRange);
|
|
8820
8862
|
}
|
|
8821
8863
|
return rangeList;
|
|
@@ -8846,9 +8888,12 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8846
8888
|
return newTreeList;
|
|
8847
8889
|
}
|
|
8848
8890
|
_dependencyFeatureCalculation(newTreeList) {
|
|
8891
|
+
const featureMap = this._featureCalculationManagerService.getReferenceExecutorMap();
|
|
8892
|
+
if (featureMap.size === 0)
|
|
8893
|
+
return;
|
|
8849
8894
|
this._clearFeatureCalculationNode(newTreeList);
|
|
8850
8895
|
let hasFeatureCalculation = !1;
|
|
8851
|
-
return
|
|
8896
|
+
return featureMap.forEach((subUnitMap, _) => {
|
|
8852
8897
|
subUnitMap.forEach((featureMap2, _2) => {
|
|
8853
8898
|
featureMap2.forEach((params, featureId) => {
|
|
8854
8899
|
const { unitId, subUnitId, getDirtyData } = params, allDependency = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData()), dirtyRanges = this._convertDirtyRangesToUnitRange(allDependency.dirtyRanges), intersectTrees = this._intersectFeatureCalculation(dirtyRanges, newTreeList, { unitId, subUnitId, featureId });
|
|
@@ -8936,11 +8981,13 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8936
8981
|
return !1;
|
|
8937
8982
|
}
|
|
8938
8983
|
_includeDefinedName(tree) {
|
|
8939
|
-
|
|
8984
|
+
var _a27;
|
|
8985
|
+
const node = (_a27 = tree.nodeData) == null ? void 0 : _a27.node;
|
|
8940
8986
|
return !!(node != null && this._isDirtyDefinedForNode(node));
|
|
8941
8987
|
}
|
|
8942
8988
|
_detectForcedRecalculationNode(tree) {
|
|
8943
|
-
|
|
8989
|
+
var _a27;
|
|
8990
|
+
const node = (_a27 = tree.nodeData) == null ? void 0 : _a27.node;
|
|
8944
8991
|
return node == null ? !1 : this._detectForcedRecalculationNodeRecursion(node);
|
|
8945
8992
|
}
|
|
8946
8993
|
_detectForcedRecalculationNodeRecursion(node) {
|
|
@@ -8989,20 +9036,19 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8989
9036
|
* @param treeList
|
|
8990
9037
|
*/
|
|
8991
9038
|
_calculateRunList(treeList) {
|
|
8992
|
-
|
|
8993
|
-
const formulaRunList = [];
|
|
9039
|
+
const stack = treeList, formulaRunList = [], cacheStack = [];
|
|
8994
9040
|
for (; stack.length > 0; ) {
|
|
8995
9041
|
const tree = stack.pop();
|
|
8996
|
-
if (tree === void 0 || tree.isSkip())
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9042
|
+
if (!(tree === void 0 || tree.isSkip())) {
|
|
9043
|
+
if (tree.isAdded()) {
|
|
9044
|
+
formulaRunList.push(tree), tree.setSkip();
|
|
9045
|
+
continue;
|
|
9046
|
+
}
|
|
9047
|
+
cacheStack.length = 0;
|
|
9048
|
+
for (const parentTree of tree.parents)
|
|
9049
|
+
parentTree.isAdded() || tree.isSkip() || cacheStack.push(parentTree);
|
|
9050
|
+
cacheStack.length === 0 ? (formulaRunList.push(tree), tree.setSkip()) : (tree.setAdded(), stack.push(tree, ...cacheStack));
|
|
9001
9051
|
}
|
|
9002
|
-
const cacheStack = [];
|
|
9003
|
-
for (const parentTree of tree.parents)
|
|
9004
|
-
parentTree.isAdded() || tree.isSkip() || cacheStack.push(parentTree);
|
|
9005
|
-
cacheStack.length === 0 ? (formulaRunList.push(tree), tree.setSkip()) : (tree.setAdded(), stack.push(tree), stack = stack.concat(cacheStack));
|
|
9006
9052
|
}
|
|
9007
9053
|
return formulaRunList.reverse();
|
|
9008
9054
|
}
|
|
@@ -9116,9 +9162,9 @@ let CalculateFormulaService = (_a16 = class extends Disposable {
|
|
|
9116
9162
|
this._runtimeService.setFormulaExecuteStage(FormulaExecuteStageType.IDLE), this._runtimeService.markedAsStopFunctionsExecuted(), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());
|
|
9117
9163
|
return;
|
|
9118
9164
|
}
|
|
9119
|
-
const tree = treeList[i],
|
|
9165
|
+
const tree = treeList[i], nodeData = tree.nodeData, getDirtyData = tree.getDirtyData;
|
|
9120
9166
|
let value;
|
|
9121
|
-
if (
|
|
9167
|
+
if (nodeData == null && getDirtyData == null)
|
|
9122
9168
|
throw new Error("AstNode or executor is null");
|
|
9123
9169
|
if (this._runtimeService.setCurrent(
|
|
9124
9170
|
tree.row,
|
|
@@ -9130,12 +9176,12 @@ let CalculateFormulaService = (_a16 = class extends Disposable {
|
|
|
9130
9176
|
), getDirtyData != null && tree.featureId != null) {
|
|
9131
9177
|
const { runtimeCellData, dirtyRanges } = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
|
|
9132
9178
|
this._runtimeService.setRuntimeFeatureCellData(tree.featureId, runtimeCellData), this._runtimeService.setRuntimeFeatureRange(tree.featureId, dirtyRanges);
|
|
9133
|
-
} else
|
|
9179
|
+
} else nodeData != null && (interpreter.checkAsyncNode(nodeData.node) ? value = await interpreter.executeAsync(nodeData) : value = interpreter.execute(nodeData), tree.formulaId != null ? this._runtimeService.setRuntimeOtherData(tree.formulaId, value) : this._runtimeService.setRuntimeData(value));
|
|
9134
9180
|
isArrayFormulaState ? (this._runtimeService.setFormulaExecuteStage(
|
|
9135
9181
|
FormulaExecuteStageType.CURRENTLY_CALCULATING_ARRAY_FORMULA
|
|
9136
9182
|
), this._runtimeService.setCompletedArrayFormulasCount(i + 1)) : (this._runtimeService.setFormulaExecuteStage(FormulaExecuteStageType.CURRENTLY_CALCULATING), this._runtimeService.setCompletedFormulasCount(i + 1)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
|
|
9137
9183
|
}
|
|
9138
|
-
return pendingTasks.forEach((cancel) => cancel()), pendingTasks = [], treeList.length > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : isArrayFormulaState || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.getAllRuntimeData();
|
|
9184
|
+
return pendingTasks.forEach((cancel) => cancel()), pendingTasks = [], treeList.length > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : isArrayFormulaState || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.clearReferenceAndNumberformatCache(), this._runtimeService.getAllRuntimeData();
|
|
9139
9185
|
}
|
|
9140
9186
|
calculate(formulaString, transformSuffix = !0) {
|
|
9141
9187
|
const lexerNode = this._lexer.treeBuilder(formulaString, transformSuffix);
|
|
@@ -9394,9 +9440,8 @@ function getR1C1Ref(index, absoluteRefType = AbsoluteRefType.ALL, isRow) {
|
|
|
9394
9440
|
__name(getR1C1Ref, "getR1C1Ref");
|
|
9395
9441
|
const functionArray = [];
|
|
9396
9442
|
var FUNCTION_NAMES_ARRAY = /* @__PURE__ */ ((FUNCTION_NAMES_ARRAY2) => FUNCTION_NAMES_ARRAY2)(FUNCTION_NAMES_ARRAY || {});
|
|
9397
|
-
const _BaseFunction = class _BaseFunction
|
|
9443
|
+
const _BaseFunction = class _BaseFunction {
|
|
9398
9444
|
constructor(_name) {
|
|
9399
|
-
super();
|
|
9400
9445
|
__publicField(this, "_unitId");
|
|
9401
9446
|
__publicField(this, "_subUnitId");
|
|
9402
9447
|
__publicField(this, "_row", -1);
|
|
@@ -9435,6 +9480,8 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9435
9480
|
get column() {
|
|
9436
9481
|
return this._column;
|
|
9437
9482
|
}
|
|
9483
|
+
dispose() {
|
|
9484
|
+
}
|
|
9438
9485
|
/**
|
|
9439
9486
|
* In Excel, to inject a defined name into a function that has positioning capabilities,
|
|
9440
9487
|
* such as using the INDIRECT function to reference a named range,
|
|
@@ -9615,7 +9662,7 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9615
9662
|
range
|
|
9616
9663
|
});
|
|
9617
9664
|
let referenceObject;
|
|
9618
|
-
return
|
|
9665
|
+
return regexTestSingeRange(token) ? referenceObject = new CellReferenceObject(token) : regexTestSingleRow(token) ? referenceObject = new RowReferenceObject(token) : regexTestSingleColumn(token) ? referenceObject = new ColumnReferenceObject(token) : referenceObject = new RangeReferenceObject(range, sheetId, unitId), this._setReferenceDefault(reference, referenceObject);
|
|
9619
9666
|
}
|
|
9620
9667
|
_setReferenceDefault(reference, object) {
|
|
9621
9668
|
return this.unitId == null || this.subUnitId == null ? ErrorValueObject.create(ErrorType$1.REF) : (object.setDefaultUnitId(this.unitId), object.setDefaultSheetId(this.subUnitId), object.setUnitData(reference.getUnitData()), object.setRuntimeData(reference.getRuntimeData()), object.setArrayFormulaCellData(reference.getArrayFormulaCellData()), object.setRuntimeArrayFormulaCellData(reference.getRuntimeArrayFormulaCellData()), object);
|
|
@@ -18745,13 +18792,13 @@ const _Indirect = class _Indirect extends BaseFunction {
|
|
|
18745
18792
|
const gridRange2 = deserializeRangeForR1C1(refTextV), { range: range2, sheetName: sheetName2, unitId: unitId2 } = gridRange2, rangeReferenceObject2 = new RangeReferenceObject(range2);
|
|
18746
18793
|
return rangeReferenceObject2.setForcedUnitIdDirect(unitId2), rangeReferenceObject2.setForcedSheetName(sheetName2), this._setDefault(rangeReferenceObject2);
|
|
18747
18794
|
}
|
|
18748
|
-
if (
|
|
18795
|
+
if (regexTestSingeRange(refTextV))
|
|
18749
18796
|
return this._setDefault(new CellReferenceObject(refTextV));
|
|
18750
|
-
if (
|
|
18797
|
+
if (regexTestRow(refTextV))
|
|
18751
18798
|
return this._setDefault(new RowReferenceObject(refTextV));
|
|
18752
|
-
if (
|
|
18799
|
+
if (regexTestColumn(refTextV))
|
|
18753
18800
|
return this._setDefault(new ColumnReferenceObject(refTextV));
|
|
18754
|
-
const gridRange =
|
|
18801
|
+
const gridRange = deserializeRangeWithSheetWithCache(refTextV), { range, sheetName, unitId } = gridRange;
|
|
18755
18802
|
if (Number.isNaN(range.startRow) || range.endRow + 1 > 1048576 || Number.isNaN(range.startColumn) || range.endColumn + 1 > 16384)
|
|
18756
18803
|
return ErrorValueObject.create(ErrorType$1.REF);
|
|
18757
18804
|
const rangeReferenceObject = new RangeReferenceObject(range);
|