@univerjs/engine-formula 0.4.0 → 0.4.1-nightly.202410201605
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 +1969 -413
- package/lib/types/basics/database.d.ts +31 -0
- package/lib/types/basics/math.d.ts +12 -0
- 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/__tests__/dependency.spec.d.ts +16 -0
- 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/function-node.d.ts +1 -0
- package/lib/types/engine/ast-node/reference-node.d.ts +9 -2
- package/lib/types/engine/dependency/dependency-tree.d.ts +13 -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/char-kit.d.ts +5 -7
- package/lib/types/engine/utils/numfmt-kit.d.ts +14 -1
- package/lib/types/engine/utils/reference-cache.d.ts +3 -0
- package/lib/types/engine/value-object/lambda-value-object.d.ts +2 -2
- package/lib/types/functions/base-function.d.ts +13 -5
- package/lib/types/functions/database/daverage/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/daverage/index.d.ts +8 -0
- package/lib/types/functions/database/dcount/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dcount/index.d.ts +8 -0
- package/lib/types/functions/database/dcounta/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dcounta/index.d.ts +8 -0
- package/lib/types/functions/database/dget/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dget/index.d.ts +7 -0
- package/lib/types/functions/database/dmax/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dmax/index.d.ts +8 -0
- package/lib/types/functions/database/dmin/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dmin/index.d.ts +8 -0
- package/lib/types/functions/database/dproduct/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dproduct/index.d.ts +8 -0
- package/lib/types/functions/database/dstdev/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dstdev/index.d.ts +8 -0
- package/lib/types/functions/database/dstdevp/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dstdevp/index.d.ts +8 -0
- package/lib/types/functions/database/dsum/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dsum/index.d.ts +8 -0
- package/lib/types/functions/database/dvar/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dvar/index.d.ts +8 -0
- package/lib/types/functions/database/dvarp/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/database/dvarp/index.d.ts +8 -0
- package/lib/types/functions/database/function-map.d.ts +3 -16
- package/lib/types/functions/financial/db/index.d.ts +1 -0
- package/lib/types/functions/financial/ddb/index.d.ts +1 -0
- package/lib/types/functions/financial/fv/index.d.ts +2 -1
- package/lib/types/functions/financial/ipmt/index.d.ts +2 -1
- package/lib/types/functions/financial/npv/index.d.ts +1 -0
- package/lib/types/functions/financial/pmt/index.d.ts +2 -1
- package/lib/types/functions/financial/ppmt/index.d.ts +2 -1
- package/lib/types/functions/financial/pv/index.d.ts +2 -1
- package/lib/types/functions/financial/sln/index.d.ts +1 -0
- package/lib/types/functions/financial/syd/index.d.ts +1 -0
- package/lib/types/functions/financial/tbillprice/index.d.ts +1 -0
- package/lib/types/functions/financial/vdb/index.d.ts +1 -0
- package/lib/types/functions/math/arabic/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/math/arabic/index.d.ts +8 -0
- package/lib/types/functions/math/roman/__tests__/index.spec.d.ts +16 -0
- package/lib/types/functions/math/roman/index.d.ts +9 -0
- package/lib/types/functions/text/arraytotext/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/arraytotext/index.d.ts +9 -0
- package/lib/types/functions/text/asc/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/asc/index.d.ts +8 -0
- package/lib/types/functions/text/bahttext/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/bahttext/index.d.ts +9 -0
- package/lib/types/functions/text/char/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/char/index.d.ts +8 -0
- package/lib/types/functions/text/clean/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/clean/index.d.ts +8 -0
- package/lib/types/functions/text/code/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/code/index.d.ts +8 -0
- package/lib/types/functions/text/dbcs/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/dbcs/index.d.ts +8 -0
- package/lib/types/functions/text/dollar/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/dollar/index.d.ts +9 -0
- package/lib/types/functions/text/exact/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/exact/index.d.ts +8 -0
- package/lib/types/functions/text/fixed/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/fixed/index.d.ts +8 -0
- package/lib/types/functions/text/leftb/index.d.ts +1 -2
- package/lib/types/functions/text/numbervalue/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/numbervalue/index.d.ts +8 -0
- package/lib/types/functions/text/proper/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/proper/index.d.ts +8 -0
- package/lib/types/functions/text/right/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/right/index.d.ts +8 -0
- package/lib/types/functions/text/rightb/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/rightb/index.d.ts +8 -0
- package/lib/types/functions/text/substitute/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/substitute/index.d.ts +9 -0
- package/lib/types/functions/text/t/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/t/index.d.ts +7 -0
- package/lib/types/functions/text/unichar/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/unichar/index.d.ts +8 -0
- package/lib/types/functions/text/unicode/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/unicode/index.d.ts +8 -0
- package/lib/types/functions/text/value/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/value/index.d.ts +8 -0
- package/lib/types/functions/text/valuetotext/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/valuetotext/index.d.ts +8 -0
- package/lib/types/services/current-data.service.d.ts +5 -2
- 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/LICENSE +0 -176
- package/lib/types/engine/dependency/generate-tree-id.d.ts +0 -2
package/lib/es/index.js
CHANGED
|
@@ -2,10 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
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";
|
|
5
|
+
import { ObjectMatrix, CommandType, Tools, AbsoluteRefType, RANGE_TYPE, createIdentifier, Disposable, IUniverInstanceService, LRUMap, hashAlgorithm, moveRangeByOffset, isValidRange, isFormulaString, isFormulaId, Rectangle, cellToRange, Inject, UniverInstanceType, LocaleService, LocaleType, numfmt, isRealNum, CellValueType, isNullCell, toDisposable, Injector, BuildTextUtils, sortRules, RTree, generateRandomId, requestImmediateMacroTask, IConfigService, ICommandService, BooleanNumber, DataStreamTreeTokenType, 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, {
|
|
@@ -502,7 +530,7 @@ const IDefinedNamesService = createIdentifier("univer.formula.defined-names.serv
|
|
|
502
530
|
this._cache.clear();
|
|
503
531
|
}
|
|
504
532
|
_hash(formulaString) {
|
|
505
|
-
return hashAlgorithm(formulaString);
|
|
533
|
+
return formulaString.length <= 64 ? formulaString : hashAlgorithm(formulaString).toString();
|
|
506
534
|
}
|
|
507
535
|
};
|
|
508
536
|
__name(_FormulaAstLRU, "FormulaAstLRU");
|
|
@@ -828,7 +856,7 @@ const FORMULA_CACHE_LRU_COUNT$2 = 1e5, FormulaLexerNodeCache = new FormulaAstLRU
|
|
|
828
856
|
continue;
|
|
829
857
|
}
|
|
830
858
|
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)) :
|
|
859
|
+
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
860
|
}
|
|
833
861
|
return this._mergeSequenceNodeReference(sequenceNodes);
|
|
834
862
|
}
|
|
@@ -1900,7 +1928,7 @@ var __defProp$l = Object.defineProperty, __getOwnPropDesc$l = Object.getOwnPrope
|
|
|
1900
1928
|
return kind && result && __defProp$l(target, key, result), result;
|
|
1901
1929
|
}, "__decorateClass$l"), __decorateParam$l = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$l"), _a3;
|
|
1902
1930
|
let FormulaCurrentConfigService = (_a3 = class extends Disposable {
|
|
1903
|
-
constructor(_univerInstanceService) {
|
|
1931
|
+
constructor(_univerInstanceService, _localeService) {
|
|
1904
1932
|
super();
|
|
1905
1933
|
__publicField(this, "_unitData", {});
|
|
1906
1934
|
__publicField(this, "_unitStylesData", {});
|
|
@@ -1919,7 +1947,7 @@ let FormulaCurrentConfigService = (_a3 = class extends Disposable {
|
|
|
1919
1947
|
__publicField(this, "_sheetIdToNameMap", {});
|
|
1920
1948
|
__publicField(this, "_executeUnitId", "");
|
|
1921
1949
|
__publicField(this, "_executeSubUnitId", "");
|
|
1922
|
-
this._univerInstanceService = _univerInstanceService;
|
|
1950
|
+
this._univerInstanceService = _univerInstanceService, this._localeService = _localeService;
|
|
1923
1951
|
}
|
|
1924
1952
|
dispose() {
|
|
1925
1953
|
this._unitData = {}, this._unitStylesData = {}, this._formulaData = {}, this._arrayFormulaCellData = {}, this._arrayFormulaRange = {}, this._sheetNameMap = {}, this._dirtyRanges = [], this._dirtyNameMap = {}, this._dirtyDefinedNameMap = {}, this._dirtyUnitFeatureMap = {}, this._excludedCell = {}, this._sheetIdToNameMap = {}, this._dirtyUnitOtherFormulaMap = {};
|
|
@@ -1981,6 +2009,9 @@ let FormulaCurrentConfigService = (_a3 = class extends Disposable {
|
|
|
1981
2009
|
getClearDependencyTreeCache() {
|
|
1982
2010
|
return this._clearDependencyTreeCache;
|
|
1983
2011
|
}
|
|
2012
|
+
getLocale() {
|
|
2013
|
+
return this._localeService.getCurrentLocale();
|
|
2014
|
+
}
|
|
1984
2015
|
load(config2) {
|
|
1985
2016
|
if (config2.allUnitData && config2.unitSheetNameMap && config2.unitStylesData)
|
|
1986
2017
|
this._unitData = config2.allUnitData, this._unitStylesData = config2.unitStylesData, this._sheetNameMap = config2.unitSheetNameMap;
|
|
@@ -2106,7 +2137,8 @@ let FormulaCurrentConfigService = (_a3 = class extends Disposable {
|
|
|
2106
2137
|
}
|
|
2107
2138
|
}, __name(_a3, "FormulaCurrentConfigService"), _a3);
|
|
2108
2139
|
FormulaCurrentConfigService = __decorateClass$l([
|
|
2109
|
-
__decorateParam$l(0, IUniverInstanceService)
|
|
2140
|
+
__decorateParam$l(0, IUniverInstanceService),
|
|
2141
|
+
__decorateParam$l(1, Inject(LocaleService))
|
|
2110
2142
|
], FormulaCurrentConfigService);
|
|
2111
2143
|
const IFormulaCurrentConfigService = createIdentifier(
|
|
2112
2144
|
"univer.formula.current-data.service"
|
|
@@ -2197,11 +2229,187 @@ function getRuntimeFeatureCell(row, column, sheetId, unitId, runtimeFeatureCellD
|
|
|
2197
2229
|
}
|
|
2198
2230
|
}
|
|
2199
2231
|
__name(getRuntimeFeatureCell, "getRuntimeFeatureCell");
|
|
2200
|
-
const
|
|
2232
|
+
const currencySymbols = [
|
|
2233
|
+
"$",
|
|
2234
|
+
"£",
|
|
2235
|
+
"¥",
|
|
2236
|
+
"¤",
|
|
2237
|
+
"֏",
|
|
2238
|
+
"؋",
|
|
2239
|
+
"৳",
|
|
2240
|
+
"฿",
|
|
2241
|
+
"៛",
|
|
2242
|
+
"₡",
|
|
2243
|
+
"₦",
|
|
2244
|
+
"₩",
|
|
2245
|
+
"₪",
|
|
2246
|
+
"₫",
|
|
2247
|
+
"€",
|
|
2248
|
+
"₭",
|
|
2249
|
+
"₮",
|
|
2250
|
+
"₱",
|
|
2251
|
+
"₲",
|
|
2252
|
+
"₴",
|
|
2253
|
+
"₸",
|
|
2254
|
+
"₹",
|
|
2255
|
+
"₺",
|
|
2256
|
+
"₼",
|
|
2257
|
+
"₽",
|
|
2258
|
+
"₾",
|
|
2259
|
+
"₿"
|
|
2260
|
+
], NumberFormatTypeMap = {
|
|
2261
|
+
currency: 2,
|
|
2262
|
+
date: 4,
|
|
2263
|
+
datetime: 5,
|
|
2264
|
+
error: 11,
|
|
2265
|
+
fraction: 7,
|
|
2266
|
+
general: 0,
|
|
2267
|
+
grouped: 11,
|
|
2268
|
+
number: 1,
|
|
2269
|
+
percent: 6,
|
|
2270
|
+
scientific: 8,
|
|
2271
|
+
text: 9,
|
|
2272
|
+
time: 5,
|
|
2273
|
+
unknown: 11
|
|
2274
|
+
/* Custom */
|
|
2275
|
+
};
|
|
2276
|
+
function handleNumfmtInCell(oldCell, cell, styles) {
|
|
2277
|
+
var _a27, _b;
|
|
2278
|
+
if (oldCell == null || cell == null)
|
|
2279
|
+
return cell;
|
|
2280
|
+
const oldCellStyle = (styles == null ? void 0 : styles.getStyleByCell(oldCell)) || oldCell.s, cellStyle = (styles == null ? void 0 : styles.getStyleByCell(cell)) || cell.s;
|
|
2281
|
+
if (oldCellStyle == null || cellStyle == null || typeof oldCellStyle != "object" || typeof cellStyle != "object")
|
|
2282
|
+
return cell;
|
|
2283
|
+
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;
|
|
2284
|
+
if (oldPattern == null || pattern == null)
|
|
2285
|
+
return cell;
|
|
2286
|
+
const newPattern = oldPattern || pattern;
|
|
2287
|
+
return cellStyle.n.pattern = newPattern, cell;
|
|
2288
|
+
}
|
|
2289
|
+
__name(handleNumfmtInCell, "handleNumfmtInCell");
|
|
2290
|
+
const numberFormatTypeCache = new FormulaAstLRU(1e5);
|
|
2291
|
+
function getNumberFormatType(pattern) {
|
|
2292
|
+
const patternTypeCache = numberFormatTypeCache.get(pattern);
|
|
2293
|
+
if (patternTypeCache !== void 0)
|
|
2294
|
+
return patternTypeCache;
|
|
2295
|
+
const type = getNumberFormatTypeRaw(pattern);
|
|
2296
|
+
return numberFormatTypeCache.set(pattern, type), type;
|
|
2297
|
+
}
|
|
2298
|
+
__name(getNumberFormatType, "getNumberFormatType");
|
|
2299
|
+
function clearNumberFormatTypeCache() {
|
|
2300
|
+
numberFormatTypeCache.clear();
|
|
2301
|
+
}
|
|
2302
|
+
__name(clearNumberFormatTypeCache, "clearNumberFormatTypeCache");
|
|
2303
|
+
function getNumberFormatTypeRaw(pattern) {
|
|
2304
|
+
if (isAccounting(pattern))
|
|
2305
|
+
return 3;
|
|
2306
|
+
const type = numfmt.getInfo(pattern).type || "unknown";
|
|
2307
|
+
return NumberFormatTypeMap[type];
|
|
2308
|
+
}
|
|
2309
|
+
__name(getNumberFormatTypeRaw, "getNumberFormatTypeRaw");
|
|
2310
|
+
function isAccounting(pattern) {
|
|
2311
|
+
return !!currencySymbols.find((code) => pattern.includes(code)) && pattern.startsWith("_(");
|
|
2312
|
+
}
|
|
2313
|
+
__name(isAccounting, "isAccounting");
|
|
2314
|
+
function comparePatternPriority(previousPattern, nextPattern, operator) {
|
|
2315
|
+
if (previousPattern === "")
|
|
2316
|
+
return nextPattern;
|
|
2317
|
+
if (nextPattern === "")
|
|
2318
|
+
return previousPattern;
|
|
2319
|
+
const previousPatternType = getNumberFormatType(previousPattern), nextPatternType = getNumberFormatType(nextPattern);
|
|
2320
|
+
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;
|
|
2321
|
+
}
|
|
2322
|
+
__name(comparePatternPriority, "comparePatternPriority");
|
|
2323
|
+
const countryCurrencySymbolMap = /* @__PURE__ */ new Map([
|
|
2324
|
+
[LocaleType.EN_US, "$"],
|
|
2325
|
+
// [LocaleType.JA_JP, '¥'],
|
|
2326
|
+
[LocaleType.RU_RU, "₽"],
|
|
2327
|
+
[LocaleType.VI_VN, "₫"],
|
|
2328
|
+
[LocaleType.ZH_CN, "¥"],
|
|
2329
|
+
[LocaleType.ZH_TW, "NT$"]
|
|
2330
|
+
]);
|
|
2331
|
+
function getCurrencySymbol(locale) {
|
|
2332
|
+
return countryCurrencySymbolMap.get(locale) || "$";
|
|
2333
|
+
}
|
|
2334
|
+
__name(getCurrencySymbol, "getCurrencySymbol");
|
|
2335
|
+
function getCurrencyFormat(locale, numberDigits = 2) {
|
|
2336
|
+
let _numberDigits = numberDigits;
|
|
2337
|
+
numberDigits > 127 && (_numberDigits = 127);
|
|
2338
|
+
let decimal = "";
|
|
2339
|
+
return _numberDigits > 0 && (decimal = `.${"0".repeat(_numberDigits)}`), `"${getCurrencySymbol(locale)}"#,##0${decimal}_);[Red]("${getCurrencySymbol(locale)}"#,##0${decimal})`;
|
|
2340
|
+
}
|
|
2341
|
+
__name(getCurrencyFormat, "getCurrencyFormat");
|
|
2342
|
+
function applyCurrencyFormat(locale, number, numberDigits = 2) {
|
|
2343
|
+
return numfmt.format(getCurrencyFormat(locale, numberDigits), number);
|
|
2344
|
+
}
|
|
2345
|
+
__name(applyCurrencyFormat, "applyCurrencyFormat");
|
|
2346
|
+
const stringToNumberPatternCache = new FormulaAstLRU(1e5);
|
|
2347
|
+
function stringIsNumberPattern(input) {
|
|
2348
|
+
let _input = input;
|
|
2349
|
+
_input.startsWith('"') && _input.endsWith('"') && (_input = _input.slice(1, -1));
|
|
2350
|
+
const cacheValue = stringToNumberPatternCache.get(_input);
|
|
2351
|
+
if (cacheValue)
|
|
2352
|
+
return {
|
|
2353
|
+
isNumberPattern: !0,
|
|
2354
|
+
value: cacheValue.value,
|
|
2355
|
+
pattern: cacheValue.pattern
|
|
2356
|
+
};
|
|
2357
|
+
const numberPattern = numfmt.parseNumber(_input);
|
|
2358
|
+
if (numberPattern)
|
|
2359
|
+
return stringToNumberPatternCache.set(_input, {
|
|
2360
|
+
value: numberPattern.v,
|
|
2361
|
+
pattern: numberPattern.z
|
|
2362
|
+
}), {
|
|
2363
|
+
isNumberPattern: !0,
|
|
2364
|
+
value: numberPattern.v,
|
|
2365
|
+
pattern: numberPattern.z
|
|
2366
|
+
};
|
|
2367
|
+
const datePattern = numfmt.parseDate(_input);
|
|
2368
|
+
if (datePattern)
|
|
2369
|
+
return stringToNumberPatternCache.set(_input, {
|
|
2370
|
+
value: datePattern.v,
|
|
2371
|
+
pattern: datePattern.z
|
|
2372
|
+
}), {
|
|
2373
|
+
isNumberPattern: !0,
|
|
2374
|
+
value: datePattern.v,
|
|
2375
|
+
pattern: datePattern.z
|
|
2376
|
+
};
|
|
2377
|
+
const timePattern = numfmt.parseTime(_input);
|
|
2378
|
+
return timePattern ? (stringToNumberPatternCache.set(_input, {
|
|
2379
|
+
value: timePattern.v,
|
|
2380
|
+
pattern: timePattern.z
|
|
2381
|
+
}), {
|
|
2382
|
+
isNumberPattern: !0,
|
|
2383
|
+
value: timePattern.v,
|
|
2384
|
+
pattern: timePattern.z
|
|
2385
|
+
}) : {
|
|
2386
|
+
isNumberPattern: !1
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
__name(stringIsNumberPattern, "stringIsNumberPattern");
|
|
2390
|
+
function clearStringToNumberPatternCache() {
|
|
2391
|
+
stringToNumberPatternCache.clear();
|
|
2392
|
+
}
|
|
2393
|
+
__name(clearStringToNumberPatternCache, "clearStringToNumberPatternCache");
|
|
2394
|
+
const referenceToRangeCache = new FormulaAstLRU(1e5);
|
|
2395
|
+
function deserializeRangeWithSheetWithCache(refString) {
|
|
2396
|
+
const refCache = referenceToRangeCache.get(refString);
|
|
2397
|
+
if (refCache)
|
|
2398
|
+
return refCache;
|
|
2399
|
+
const result = deserializeRangeWithSheet(refString);
|
|
2400
|
+
return referenceToRangeCache.set(refString, result), deserializeRangeWithSheet(refString);
|
|
2401
|
+
}
|
|
2402
|
+
__name(deserializeRangeWithSheetWithCache, "deserializeRangeWithSheetWithCache");
|
|
2403
|
+
function clearReferenceToRangeCache() {
|
|
2404
|
+
referenceToRangeCache.clear();
|
|
2405
|
+
}
|
|
2406
|
+
__name(clearReferenceToRangeCache, "clearReferenceToRangeCache");
|
|
2407
|
+
const _ObjectClassType = class _ObjectClassType {
|
|
2201
2408
|
constructor() {
|
|
2202
|
-
super(...arguments);
|
|
2203
2409
|
__publicField(this, "pattern", "");
|
|
2204
2410
|
}
|
|
2411
|
+
dispose() {
|
|
2412
|
+
}
|
|
2205
2413
|
getPattern() {
|
|
2206
2414
|
return this.pattern;
|
|
2207
2415
|
}
|
|
@@ -3725,19 +3933,23 @@ var Decimal$1 = P.constructor = clone(DEFAULTS);
|
|
|
3725
3933
|
LN10 = new Decimal$1(LN10);
|
|
3726
3934
|
PI = new Decimal$1(PI);
|
|
3727
3935
|
function plus(a, b) {
|
|
3728
|
-
|
|
3936
|
+
const result = a + b;
|
|
3937
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).add(b).toNumber();
|
|
3729
3938
|
}
|
|
3730
3939
|
__name(plus, "plus");
|
|
3731
3940
|
function minus(a, b) {
|
|
3732
|
-
|
|
3941
|
+
const result = a - b;
|
|
3942
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).sub(b).toNumber();
|
|
3733
3943
|
}
|
|
3734
3944
|
__name(minus, "minus");
|
|
3735
3945
|
function multiply(a, b) {
|
|
3736
|
-
|
|
3946
|
+
const result = a * b;
|
|
3947
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).mul(b).toNumber();
|
|
3737
3948
|
}
|
|
3738
3949
|
__name(multiply, "multiply");
|
|
3739
3950
|
function divide(a, b) {
|
|
3740
|
-
|
|
3951
|
+
const result = a / b;
|
|
3952
|
+
return Number.isSafeInteger(result) ? result : new Decimal$1(a).div(b).toNumber();
|
|
3741
3953
|
}
|
|
3742
3954
|
__name(divide, "divide");
|
|
3743
3955
|
function round(base, precision) {
|
|
@@ -3808,84 +4020,6 @@ function getFractionalPart(num) {
|
|
|
3808
4020
|
return num - Math.trunc(num);
|
|
3809
4021
|
}
|
|
3810
4022
|
__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
4023
|
const _NullValueObject = class _NullValueObject extends BaseValueObject {
|
|
3890
4024
|
static create() {
|
|
3891
4025
|
return this._instance = this._instance || new _NullValueObject(0), this._instance;
|
|
@@ -5692,8 +5826,11 @@ const _ValueObjectFactory = class _ValueObjectFactory {
|
|
|
5692
5826
|
return createBooleanValueObjectByRawValue(rawValue);
|
|
5693
5827
|
if (isRealNum(rawValue))
|
|
5694
5828
|
return NumberValueObject.create(Number(rawValue));
|
|
5829
|
+
const { isNumberPattern, value, pattern } = stringIsNumberPattern(rawValue);
|
|
5830
|
+
if (isNumberPattern)
|
|
5831
|
+
return NumberValueObject.create(value, pattern);
|
|
5695
5832
|
const rawValueSingleLine = rawValue.replace(/\n/g, "").replace(/\r/g, "");
|
|
5696
|
-
return !isStringWrappedByDoubleQuotes(rawValueSingleLine) &&
|
|
5833
|
+
return !isStringWrappedByDoubleQuotes(rawValueSingleLine) && regexTestArrayValue(rawValueSingleLine) ? ArrayValueObject.create(rawValueSingleLine) : createStringValueObjectByRawValue(rawValue);
|
|
5697
5834
|
}
|
|
5698
5835
|
return typeof rawValue == "number" ? createNumberValueObjectByRawValue(rawValue) : ErrorValueObject.create(ErrorType$1.VALUE);
|
|
5699
5836
|
}
|
|
@@ -5968,7 +6105,7 @@ let FormulaRuntimeService = (_a5 = class extends Disposable {
|
|
|
5968
6105
|
return this._currentUnitId;
|
|
5969
6106
|
}
|
|
5970
6107
|
dispose() {
|
|
5971
|
-
this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {};
|
|
6108
|
+
this.reset(), this._runtimeFeatureCellData = {}, this._runtimeFeatureRange = {}, this.clearReferenceAndNumberformatCache();
|
|
5972
6109
|
}
|
|
5973
6110
|
enableCycleDependency() {
|
|
5974
6111
|
this._isCycleDependency = !0;
|
|
@@ -6039,6 +6176,9 @@ let FormulaRuntimeService = (_a5 = class extends Disposable {
|
|
|
6039
6176
|
reset() {
|
|
6040
6177
|
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
6178
|
}
|
|
6179
|
+
clearReferenceAndNumberformatCache() {
|
|
6180
|
+
clearNumberFormatTypeCache(), clearStringToNumberPatternCache(), clearReferenceToRangeCache();
|
|
6181
|
+
}
|
|
6042
6182
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
6043
6183
|
this._currentRow = row, this._currentColumn = column, this._currentRowCount = rowCount, this._currentColumnCount = columnCount, this._currentSubUnitId = sheetId, this._currentUnitId = unitId;
|
|
6044
6184
|
}
|
|
@@ -6284,9 +6424,8 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6284
6424
|
["UnionNode", 3],
|
|
6285
6425
|
["PrefixNode", 4],
|
|
6286
6426
|
["SuffixNode", 5]
|
|
6287
|
-
]), _BaseAstNode = class _BaseAstNode
|
|
6427
|
+
]), _BaseAstNode = class _BaseAstNode {
|
|
6288
6428
|
constructor(_token) {
|
|
6289
|
-
super();
|
|
6290
6429
|
__publicField(this, "_children", []);
|
|
6291
6430
|
__publicField(this, "_definedNames", []);
|
|
6292
6431
|
__publicField(this, "_parent");
|
|
@@ -6294,8 +6433,6 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6294
6433
|
__publicField(this, "_calculateState", !1);
|
|
6295
6434
|
__publicField(this, "_async", !1);
|
|
6296
6435
|
__publicField(this, "_address", !1);
|
|
6297
|
-
__publicField(this, "_refOffsetX", 0);
|
|
6298
|
-
__publicField(this, "_refOffsetY", 0);
|
|
6299
6436
|
__publicField(this, "_isForcedCalculateFunction", !1);
|
|
6300
6437
|
this._token = _token;
|
|
6301
6438
|
}
|
|
@@ -6357,15 +6494,6 @@ const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
|
6357
6494
|
}
|
|
6358
6495
|
setNotEmpty(state = !0) {
|
|
6359
6496
|
}
|
|
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
6497
|
async executeAsync() {
|
|
6370
6498
|
return Promise.resolve(AstNodePromiseType.SUCCESS);
|
|
6371
6499
|
}
|
|
@@ -6408,10 +6536,12 @@ const _ErrorNode = class _ErrorNode extends BaseAstNode {
|
|
|
6408
6536
|
};
|
|
6409
6537
|
__name(_ErrorNode, "ErrorNode");
|
|
6410
6538
|
let ErrorNode = _ErrorNode;
|
|
6411
|
-
const DEFAULT_AST_NODE_FACTORY_Z_INDEX = 100, _BaseAstNodeFactory = class _BaseAstNodeFactory
|
|
6539
|
+
const DEFAULT_AST_NODE_FACTORY_Z_INDEX = 100, _BaseAstNodeFactory = class _BaseAstNodeFactory {
|
|
6412
6540
|
get zIndex() {
|
|
6413
6541
|
return 0;
|
|
6414
6542
|
}
|
|
6543
|
+
dispose() {
|
|
6544
|
+
}
|
|
6415
6545
|
create(param, currentRow, currentColumn) {
|
|
6416
6546
|
let token;
|
|
6417
6547
|
return param instanceof LexerNode ? token = param.getToken() : token = param, new BaseAstNode(token);
|
|
@@ -6567,15 +6697,17 @@ PrefixNodeFactory = __decorateClass$i([
|
|
|
6567
6697
|
__decorateParam$i(0, IFunctionService),
|
|
6568
6698
|
__decorateParam$i(1, Inject(Injector))
|
|
6569
6699
|
], PrefixNodeFactory);
|
|
6700
|
+
new RegExp(prefixToken.MINUS, "g");
|
|
6701
|
+
new RegExp(prefixToken.AT, "g");
|
|
6570
6702
|
function prefixHandler(tokenTrimParam, functionService, injector) {
|
|
6571
6703
|
let minusPrefixNode, atPrefixNode, tokenTrim = tokenTrimParam;
|
|
6572
6704
|
const prefix = tokenTrim.slice(0, 2);
|
|
6573
6705
|
let sliceLength = 0;
|
|
6574
|
-
if (
|
|
6706
|
+
if (prefix[0] === prefixToken.MINUS) {
|
|
6575
6707
|
const functionExecutor = functionService.getExecutor(FUNCTION_NAMES_META.MINUS);
|
|
6576
6708
|
minusPrefixNode = new PrefixNode(injector, prefixToken.MINUS, functionExecutor), sliceLength++;
|
|
6577
6709
|
}
|
|
6578
|
-
return
|
|
6710
|
+
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
6711
|
}
|
|
6580
6712
|
__name(prefixHandler, "prefixHandler");
|
|
6581
6713
|
var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
@@ -6585,7 +6717,7 @@ var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPrope
|
|
|
6585
6717
|
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h");
|
|
6586
6718
|
const _FunctionNode = class _FunctionNode extends BaseAstNode {
|
|
6587
6719
|
constructor(token, _functionExecutor, _currentConfigService, _runtimeService, _definedNamesService) {
|
|
6588
|
-
super(token), this._functionExecutor = _functionExecutor, this._currentConfigService = _currentConfigService, this._runtimeService = _runtimeService, this._definedNamesService = _definedNamesService, this._functionExecutor.isAsync() && this.setAsync(), this._functionExecutor.isAddress() && this.setAddress();
|
|
6720
|
+
super(token), this._functionExecutor = _functionExecutor, this._currentConfigService = _currentConfigService, this._runtimeService = _runtimeService, this._definedNamesService = _definedNamesService, this._functionExecutor.isAsync() && this.setAsync(), this._functionExecutor.isAddress() && this.setAddress(), this._functionExecutor.needsLocale && this._setLocale();
|
|
6589
6721
|
}
|
|
6590
6722
|
get nodeType() {
|
|
6591
6723
|
return NodeType.FUNCTION;
|
|
@@ -6679,6 +6811,9 @@ const _FunctionNode = class _FunctionNode extends BaseAstNode {
|
|
|
6679
6811
|
const referenceObject = variant;
|
|
6680
6812
|
referenceObject.setForcedSheetId(this._currentConfigService.getSheetNameMap()), referenceObject.setUnitData(this._currentConfigService.getUnitData()), referenceObject.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()), referenceObject.setRuntimeData(this._runtimeService.getUnitData()), referenceObject.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()), referenceObject.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData());
|
|
6681
6813
|
}
|
|
6814
|
+
_setLocale() {
|
|
6815
|
+
this._functionExecutor.setLocale(this._currentConfigService.getLocale());
|
|
6816
|
+
}
|
|
6682
6817
|
};
|
|
6683
6818
|
__name(_FunctionNode, "FunctionNode");
|
|
6684
6819
|
let FunctionNode = _FunctionNode;
|
|
@@ -6743,17 +6878,19 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6743
6878
|
constructor(_runtimeService) {
|
|
6744
6879
|
super(), this._runtimeService = _runtimeService;
|
|
6745
6880
|
}
|
|
6746
|
-
async executeAsync(
|
|
6747
|
-
if (!
|
|
6881
|
+
async executeAsync(nodeData) {
|
|
6882
|
+
if (!nodeData)
|
|
6748
6883
|
return Promise.resolve(ErrorValueObject.create(ErrorType$1.VALUE));
|
|
6749
|
-
|
|
6884
|
+
const node = nodeData.node, refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
6885
|
+
await this._executeAsync(node, refOffsetX, refOffsetY);
|
|
6750
6886
|
const value = node.getValue();
|
|
6751
6887
|
return value == null ? Promise.resolve(ErrorValueObject.create(ErrorType$1.VALUE)) : Promise.resolve(value);
|
|
6752
6888
|
}
|
|
6753
|
-
execute(
|
|
6754
|
-
if (!
|
|
6889
|
+
execute(nodeData) {
|
|
6890
|
+
if (!nodeData)
|
|
6755
6891
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
6756
|
-
|
|
6892
|
+
const node = nodeData.node, refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
6893
|
+
this._execute(node, refOffsetX, refOffsetY);
|
|
6757
6894
|
const value = node.getValue();
|
|
6758
6895
|
return value == null ? ErrorValueObject.create(ErrorType$1.VALUE) : value;
|
|
6759
6896
|
}
|
|
@@ -6775,7 +6912,7 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6775
6912
|
resultList.push(item.isAsync()), this._checkAsyncNode(item, resultList);
|
|
6776
6913
|
}
|
|
6777
6914
|
}
|
|
6778
|
-
async _executeAsync(node) {
|
|
6915
|
+
async _executeAsync(node, refOffsetX = 0, refOffsetY = 0) {
|
|
6779
6916
|
if (this._runtimeService.isStopExecution())
|
|
6780
6917
|
return Promise.resolve(AstNodePromiseType.ERROR);
|
|
6781
6918
|
const children = node.getChildren(), childrenCount = children.length;
|
|
@@ -6785,11 +6922,11 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6785
6922
|
item.execute();
|
|
6786
6923
|
continue;
|
|
6787
6924
|
}
|
|
6788
|
-
await this._executeAsync(item);
|
|
6925
|
+
await this._executeAsync(item, refOffsetX, refOffsetY);
|
|
6789
6926
|
}
|
|
6790
|
-
return node.nodeType === NodeType.FUNCTION && node.isAsync() ? await node.executeAsync() : node.execute(), Promise.resolve(AstNodePromiseType.SUCCESS);
|
|
6927
|
+
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
6928
|
}
|
|
6792
|
-
_execute(node) {
|
|
6929
|
+
_execute(node, refOffsetX = 0, refOffsetY = 0) {
|
|
6793
6930
|
if (this._runtimeService.isStopExecution())
|
|
6794
6931
|
return AstNodePromiseType.ERROR;
|
|
6795
6932
|
const children = node.getChildren(), childrenCount = children.length;
|
|
@@ -6799,9 +6936,9 @@ let Interpreter = (_a8 = class extends Disposable {
|
|
|
6799
6936
|
item.execute();
|
|
6800
6937
|
continue;
|
|
6801
6938
|
}
|
|
6802
|
-
this._execute(item);
|
|
6939
|
+
this._execute(item, refOffsetX, refOffsetY);
|
|
6803
6940
|
}
|
|
6804
|
-
return node.execute(), AstNodePromiseType.SUCCESS;
|
|
6941
|
+
return node.nodeType === NodeType.REFERENCE && node.setRefOffset(refOffsetX, refOffsetY), node.execute(), AstNodePromiseType.SUCCESS;
|
|
6805
6942
|
}
|
|
6806
6943
|
}, __name(_a8, "Interpreter"), _a8);
|
|
6807
6944
|
Interpreter = __decorateClass$g([
|
|
@@ -7240,6 +7377,21 @@ const _AsyncArrayObject = class _AsyncArrayObject extends ObjectClassType {
|
|
|
7240
7377
|
};
|
|
7241
7378
|
__name(_AsyncArrayObject, "AsyncArrayObject");
|
|
7242
7379
|
let AsyncArrayObject = _AsyncArrayObject;
|
|
7380
|
+
function getAstNodeTopParent(node) {
|
|
7381
|
+
let parent = node;
|
|
7382
|
+
for (; parent != null && parent.getParent(); )
|
|
7383
|
+
parent = parent.getParent();
|
|
7384
|
+
return parent;
|
|
7385
|
+
}
|
|
7386
|
+
__name(getAstNodeTopParent, "getAstNodeTopParent");
|
|
7387
|
+
function generateExecuteAstNodeData(node, refOffsetX = 0, refOffsetY = 0) {
|
|
7388
|
+
return {
|
|
7389
|
+
node,
|
|
7390
|
+
refOffsetX,
|
|
7391
|
+
refOffsetY
|
|
7392
|
+
};
|
|
7393
|
+
}
|
|
7394
|
+
__name(generateExecuteAstNodeData, "generateExecuteAstNodeData");
|
|
7243
7395
|
function getRootLexerHasValueNode(node) {
|
|
7244
7396
|
if (!node)
|
|
7245
7397
|
return;
|
|
@@ -7271,9 +7423,9 @@ const _LambdaValueObjectObject = class _LambdaValueObjectObject extends BaseValu
|
|
|
7271
7423
|
this._setLambdaPrivacyValueMap(variants), this._setLambdaNodeValue(this._lambdaNode), this._lambdaNode.setNotEmpty(!1);
|
|
7272
7424
|
let value;
|
|
7273
7425
|
if (this._interpreter.checkAsyncNode(this._lambdaNode))
|
|
7274
|
-
value = new AsyncObject(this._interpreter.executeAsync(this._lambdaNode));
|
|
7426
|
+
value = new AsyncObject(this._interpreter.executeAsync(generateExecuteAstNodeData(this._lambdaNode)));
|
|
7275
7427
|
else {
|
|
7276
|
-
const o = this._interpreter.execute(this._lambdaNode);
|
|
7428
|
+
const o = this._interpreter.execute(generateExecuteAstNodeData(this._lambdaNode));
|
|
7277
7429
|
o.isReferenceObject() ? value = o.toArrayValueObject() : value = o;
|
|
7278
7430
|
}
|
|
7279
7431
|
return this._lambdaNode.setNotEmpty(!0), value;
|
|
@@ -7562,7 +7714,7 @@ let RangeReferenceObject = _RangeReferenceObject;
|
|
|
7562
7714
|
const _CellReferenceObject = class _CellReferenceObject extends BaseReferenceObject {
|
|
7563
7715
|
constructor(token) {
|
|
7564
7716
|
super(token);
|
|
7565
|
-
const grid =
|
|
7717
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7566
7718
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName), this.setRangeData(grid.range);
|
|
7567
7719
|
}
|
|
7568
7720
|
isCell() {
|
|
@@ -7603,7 +7755,7 @@ let CellReferenceObject = _CellReferenceObject;
|
|
|
7603
7755
|
const _ColumnReferenceObject = class _ColumnReferenceObject extends BaseReferenceObject {
|
|
7604
7756
|
constructor(token) {
|
|
7605
7757
|
super(token);
|
|
7606
|
-
const grid =
|
|
7758
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7607
7759
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
7608
7760
|
const range = {
|
|
7609
7761
|
startColumn: grid.range.startColumn,
|
|
@@ -7634,7 +7786,7 @@ let ColumnReferenceObject = _ColumnReferenceObject;
|
|
|
7634
7786
|
const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObject {
|
|
7635
7787
|
constructor(token) {
|
|
7636
7788
|
super(token);
|
|
7637
|
-
const grid =
|
|
7789
|
+
const grid = deserializeRangeWithSheetWithCache(token);
|
|
7638
7790
|
this.setForcedUnitIdDirect(grid.unitId), this.setForcedSheetName(grid.sheetName);
|
|
7639
7791
|
const range = {
|
|
7640
7792
|
startColumn: Number.NaN,
|
|
@@ -7662,58 +7814,6 @@ const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObjec
|
|
|
7662
7814
|
};
|
|
7663
7815
|
__name(_RowReferenceObject, "RowReferenceObject");
|
|
7664
7816
|
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
7817
|
var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
7718
7818
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7719
7819
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -7721,7 +7821,10 @@ var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPrope
|
|
|
7721
7821
|
}, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
|
|
7722
7822
|
const _ReferenceNode = class _ReferenceNode extends BaseAstNode {
|
|
7723
7823
|
constructor(_accessor, _operatorString, _referenceObject, _isPrepareMerge = !1) {
|
|
7724
|
-
super(_operatorString)
|
|
7824
|
+
super(_operatorString);
|
|
7825
|
+
__publicField(this, "_refOffsetX", 0);
|
|
7826
|
+
__publicField(this, "_refOffsetY", 0);
|
|
7827
|
+
this._accessor = _accessor, this._operatorString = _operatorString, this._referenceObject = _referenceObject, this._isPrepareMerge = _isPrepareMerge;
|
|
7725
7828
|
}
|
|
7726
7829
|
get nodeType() {
|
|
7727
7830
|
return NodeType.REFERENCE;
|
|
@@ -7732,6 +7835,15 @@ const _ReferenceNode = class _ReferenceNode extends BaseAstNode {
|
|
|
7732
7835
|
const { x, y } = this.getRefOffset();
|
|
7733
7836
|
this._referenceObject.setRefOffset(x, y), !this._isPrepareMerge && this._referenceObject.isExceedRange() ? this.setValue(ErrorValueObject.create(ErrorType$1.NAME)) : this.setValue(this._referenceObject);
|
|
7734
7837
|
}
|
|
7838
|
+
setRefOffset(x = 0, y = 0) {
|
|
7839
|
+
this._refOffsetX = x, this._refOffsetY = y;
|
|
7840
|
+
}
|
|
7841
|
+
getRefOffset() {
|
|
7842
|
+
return {
|
|
7843
|
+
x: this._refOffsetX,
|
|
7844
|
+
y: this._refOffsetY
|
|
7845
|
+
};
|
|
7846
|
+
}
|
|
7735
7847
|
};
|
|
7736
7848
|
__name(_ReferenceNode, "ReferenceNode");
|
|
7737
7849
|
let ReferenceNode = _ReferenceNode;
|
|
@@ -7751,25 +7863,7 @@ let ReferenceNodeFactory = (_a11 = class extends BaseAstNodeFactory {
|
|
|
7751
7863
|
if (!isLexerNode && tokenTrim.charAt(0) === '"' && tokenTrim.charAt(tokenTrim.length - 1) === '"')
|
|
7752
7864
|
return;
|
|
7753
7865
|
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)
|
|
7866
|
+
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
7867
|
return atPrefixNode ? node.setParent(atPrefixNode) : minusPrefixNode && node.setParent(minusPrefixNode), node;
|
|
7774
7868
|
}
|
|
7775
7869
|
_checkParentIsUnionOperator(param) {
|
|
@@ -7935,13 +8029,6 @@ const _ValueNodeFactory = class _ValueNodeFactory extends BaseAstNodeFactory {
|
|
|
7935
8029
|
};
|
|
7936
8030
|
__name(_ValueNodeFactory, "ValueNodeFactory");
|
|
7937
8031
|
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
8032
|
var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
7946
8033
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7947
8034
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -7960,10 +8047,8 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
7960
8047
|
nodeFactory.dispose();
|
|
7961
8048
|
}), this._astNodeFactoryList = [];
|
|
7962
8049
|
}
|
|
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);
|
|
8050
|
+
parse(lexerNode) {
|
|
8051
|
+
const astNode = new AstRootNode(DEFAULT_TOKEN_TYPE_ROOT), node = this._parse(lexerNode, astNode);
|
|
7967
8052
|
return lexerNode.hasDefinedNames() && (node == null || node.setDefinedNames(lexerNode.getDefinedNames())), node;
|
|
7968
8053
|
}
|
|
7969
8054
|
_lambdaParameterHandler(lexerNode, parent) {
|
|
@@ -8059,7 +8144,7 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8059
8144
|
break;
|
|
8060
8145
|
}
|
|
8061
8146
|
case NodeType.REFERENCE:
|
|
8062
|
-
|
|
8147
|
+
calculateStack.push(astNode);
|
|
8063
8148
|
break;
|
|
8064
8149
|
case NodeType.ROOT:
|
|
8065
8150
|
calculateStack.push(astNode);
|
|
@@ -8071,7 +8156,7 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8071
8156
|
calculateStack.push(astNode);
|
|
8072
8157
|
break;
|
|
8073
8158
|
case NodeType.PREFIX:
|
|
8074
|
-
|
|
8159
|
+
calculateStack.push(astNode);
|
|
8075
8160
|
break;
|
|
8076
8161
|
case NodeType.SUFFIX:
|
|
8077
8162
|
calculateStack.push(astNode);
|
|
@@ -8083,13 +8168,16 @@ let AstTreeBuilder = (_a14 = class extends Disposable {
|
|
|
8083
8168
|
calculateStack[i].setParent(currentAstNode);
|
|
8084
8169
|
return currentAstNode;
|
|
8085
8170
|
}
|
|
8086
|
-
_setPrefixRefOffset(astNode) {
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8171
|
+
// private _setPrefixRefOffset(astNode: BaseAstNode) {
|
|
8172
|
+
// const children = astNode.getChildren();
|
|
8173
|
+
// const childrenCount = children.length;
|
|
8174
|
+
// for (let i = 0; i < childrenCount; i++) {
|
|
8175
|
+
// const item = children[i];
|
|
8176
|
+
// if (item.nodeType === NodeType.REFERENCE) {
|
|
8177
|
+
// item.setRefOffset(this._refOffsetX, this._refOffsetY);
|
|
8178
|
+
// }
|
|
8179
|
+
// }
|
|
8180
|
+
// }
|
|
8093
8181
|
_checkAstNode(item) {
|
|
8094
8182
|
let astNode = null;
|
|
8095
8183
|
const astNodeFactoryListCount = this._astNodeFactoryList.length;
|
|
@@ -8132,36 +8220,48 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8132
8220
|
__publicField(this, "_featureFormulaData", {});
|
|
8133
8221
|
__publicField(this, "_formulaData", {});
|
|
8134
8222
|
__publicField(this, "_dependencyRTreeCache", new RTree());
|
|
8135
|
-
__publicField(this, "
|
|
8223
|
+
__publicField(this, "_dependencyTreeIdLast", 0);
|
|
8136
8224
|
}
|
|
8137
8225
|
dispose() {
|
|
8138
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.dispose(), this.
|
|
8226
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.dispose(), this._restDependencyTreeId();
|
|
8139
8227
|
}
|
|
8140
8228
|
/**
|
|
8141
8229
|
* Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
|
|
8142
8230
|
* return FormulaDependencyTree[]
|
|
8143
8231
|
*/
|
|
8144
8232
|
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) => {
|
|
8233
|
+
const trees = [], resetAndPush = /* @__PURE__ */ __name((item) => {
|
|
8163
8234
|
item && (item.resetState(), trees.push(item));
|
|
8164
|
-
}
|
|
8235
|
+
}, "resetAndPush");
|
|
8236
|
+
for (const unitKey in this._otherFormulaData) {
|
|
8237
|
+
const unit = this._otherFormulaData[unitKey];
|
|
8238
|
+
if (unit)
|
|
8239
|
+
for (const sheetKey in unit) {
|
|
8240
|
+
const sheet = unit[sheetKey];
|
|
8241
|
+
for (const formulaKey in sheet)
|
|
8242
|
+
sheet[formulaKey] != null && resetAndPush(sheet[formulaKey]);
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
for (const unitKey in this._featureFormulaData) {
|
|
8246
|
+
const unit = this._featureFormulaData[unitKey];
|
|
8247
|
+
if (unit)
|
|
8248
|
+
for (const sheetKey in unit) {
|
|
8249
|
+
const sheet = unit[sheetKey];
|
|
8250
|
+
for (const featureKey in sheet)
|
|
8251
|
+
sheet[featureKey] != null && resetAndPush(sheet[featureKey]);
|
|
8252
|
+
}
|
|
8253
|
+
}
|
|
8254
|
+
for (const unitKey in this._formulaData) {
|
|
8255
|
+
const unit = this._formulaData[unitKey];
|
|
8256
|
+
if (unit)
|
|
8257
|
+
for (const sheetKey in unit)
|
|
8258
|
+
unit[sheetKey].forValue((row, col, item) => {
|
|
8259
|
+
if (item == null)
|
|
8260
|
+
return !0;
|
|
8261
|
+
resetAndPush(item);
|
|
8262
|
+
});
|
|
8263
|
+
}
|
|
8264
|
+
return trees;
|
|
8165
8265
|
}
|
|
8166
8266
|
buildDependencyTree(shouldBeBuildTrees, dependencyTrees = []) {
|
|
8167
8267
|
const allTrees = this.getAllTree();
|
|
@@ -8177,17 +8277,18 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8177
8277
|
*/
|
|
8178
8278
|
_buildDependencyTree(allTrees, shouldBeBuildTrees) {
|
|
8179
8279
|
const shouldBeBuildTreeMap = /* @__PURE__ */ new Map();
|
|
8180
|
-
|
|
8181
|
-
const
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
}
|
|
8190
|
-
}
|
|
8280
|
+
for (let i = 0; i < shouldBeBuildTrees.length; i++) {
|
|
8281
|
+
const tree = shouldBeBuildTrees[i];
|
|
8282
|
+
shouldBeBuildTreeMap.set(tree.treeId, tree);
|
|
8283
|
+
}
|
|
8284
|
+
for (let i = 0; i < allTrees.length; i++) {
|
|
8285
|
+
const tree = allTrees[i], RTreeItem = tree.toRTreeItem(), searchResults = this._dependencyRTreeCache.search(RTreeItem);
|
|
8286
|
+
for (let j = 0; j < searchResults.length; j++) {
|
|
8287
|
+
const searchResult = searchResults[j], shouldBeBuildTree = shouldBeBuildTreeMap.get(searchResult.id);
|
|
8288
|
+
shouldBeBuildTree && tree !== shouldBeBuildTree && !shouldBeBuildTree.hasChildren(tree) && shouldBeBuildTree.pushChildren(tree);
|
|
8289
|
+
}
|
|
8290
|
+
}
|
|
8291
|
+
shouldBeBuildTreeMap.clear();
|
|
8191
8292
|
}
|
|
8192
8293
|
/**
|
|
8193
8294
|
* Build the reverse dependency relationship between the trees.
|
|
@@ -8196,17 +8297,18 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8196
8297
|
*/
|
|
8197
8298
|
_buildReverseDependency(allTrees, dependencyTrees) {
|
|
8198
8299
|
const allTreeMap = /* @__PURE__ */ new Map();
|
|
8199
|
-
|
|
8200
|
-
const
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
}
|
|
8209
|
-
}
|
|
8300
|
+
for (let i = 0; i < allTrees.length; i++) {
|
|
8301
|
+
const tree = allTrees[i];
|
|
8302
|
+
allTreeMap.set(tree.treeId, tree);
|
|
8303
|
+
}
|
|
8304
|
+
for (let i = 0; i < dependencyTrees.length; i++) {
|
|
8305
|
+
const tree = dependencyTrees[i], RTreeItem = tree.toRTreeItem(), searchResults = this._dependencyRTreeCache.search(RTreeItem);
|
|
8306
|
+
for (let j = 0; j < searchResults.length; j++) {
|
|
8307
|
+
const searchResult = searchResults[j], allTree = allTreeMap.get(searchResult.id);
|
|
8308
|
+
allTree && tree !== allTree && !allTree.hasChildren(tree) && allTree.pushChildren(tree);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
allTreeMap.clear();
|
|
8210
8312
|
}
|
|
8211
8313
|
/**
|
|
8212
8314
|
* Clear the dependency relationship of the tree.
|
|
@@ -8226,15 +8328,15 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8226
8328
|
this._buildDependencyTree(parentsArray, childrenArray), this._buildReverseDependency(parentsArray, childrenArray), shouldBeClearTree.dispose();
|
|
8227
8329
|
}
|
|
8228
8330
|
reset() {
|
|
8229
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this.
|
|
8331
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this._restDependencyTreeId();
|
|
8230
8332
|
}
|
|
8231
8333
|
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
|
|
8334
|
+
this._otherFormulaData[unitId] || (this._otherFormulaData[unitId] = {}), this._otherFormulaData[unitId][sheetId] || (this._otherFormulaData[unitId][sheetId] = {}), this._otherFormulaData[unitId][sheetId][formulaId] = dependencyTree;
|
|
8233
8335
|
}
|
|
8234
8336
|
removeOtherFormulaDependency(unitId, sheetId, formulaIds) {
|
|
8235
8337
|
this._otherFormulaData[unitId] && this._otherFormulaData[unitId][sheetId] && formulaIds.forEach((formulaId) => {
|
|
8236
8338
|
const deleteTree = this._otherFormulaData[unitId][sheetId][formulaId];
|
|
8237
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._otherFormulaData[unitId][sheetId][formulaId]
|
|
8339
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._otherFormulaData[unitId][sheetId][formulaId];
|
|
8238
8340
|
});
|
|
8239
8341
|
}
|
|
8240
8342
|
getOtherFormulaDependency(unitId, sheetId, formulaId) {
|
|
@@ -8248,36 +8350,36 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8248
8350
|
clearOtherFormulaDependency(unitId, sheetId) {
|
|
8249
8351
|
if (sheetId && this._otherFormulaData[unitId] && this._otherFormulaData[unitId][sheetId])
|
|
8250
8352
|
this._removeDependencyRTreeCacheById(unitId, sheetId), Object.values(this._otherFormulaData[unitId][sheetId]).forEach((formula) => {
|
|
8251
|
-
this.clearDependencyForTree(formula)
|
|
8353
|
+
this.clearDependencyForTree(formula);
|
|
8252
8354
|
}), this._otherFormulaData[unitId][sheetId] = {};
|
|
8253
8355
|
else if (this._otherFormulaData[unitId]) {
|
|
8254
8356
|
const unitOtherData = this._otherFormulaData[unitId];
|
|
8255
8357
|
Object.keys(unitOtherData).forEach((sheetId2) => {
|
|
8256
8358
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), Object.values(unitOtherData[sheetId2]).forEach((formula) => {
|
|
8257
|
-
this.clearDependencyForTree(formula)
|
|
8359
|
+
this.clearDependencyForTree(formula);
|
|
8258
8360
|
}));
|
|
8259
8361
|
}), this._otherFormulaData[unitId] = null;
|
|
8260
8362
|
}
|
|
8261
8363
|
}
|
|
8262
8364
|
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
|
|
8365
|
+
this._featureFormulaData[unitId] || (this._featureFormulaData[unitId] = {}), this._featureFormulaData[unitId][sheetId] || (this._featureFormulaData[unitId][sheetId] = {}), this._featureFormulaData[unitId][sheetId][featureId] = dependencyTree;
|
|
8264
8366
|
}
|
|
8265
8367
|
removeFeatureFormulaDependency(unitId, sheetId, featureIds) {
|
|
8266
8368
|
this._featureFormulaData[unitId] && this._featureFormulaData[unitId][sheetId] && featureIds.forEach((featureId) => {
|
|
8267
8369
|
const deleteTree = this._featureFormulaData[unitId][sheetId][featureId];
|
|
8268
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._featureFormulaData[unitId][sheetId][featureId]
|
|
8370
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), delete this._featureFormulaData[unitId][sheetId][featureId];
|
|
8269
8371
|
});
|
|
8270
8372
|
}
|
|
8271
8373
|
clearFeatureFormulaDependency(unitId, sheetId) {
|
|
8272
8374
|
if (sheetId && this._featureFormulaData[unitId] && this._featureFormulaData[unitId][sheetId])
|
|
8273
8375
|
this._removeDependencyRTreeCacheById(unitId, sheetId), Object.values(this._featureFormulaData[unitId][sheetId]).forEach((feature) => {
|
|
8274
|
-
this._removeDependencyRTreeCache(feature), this.clearDependencyForTree(feature)
|
|
8376
|
+
this._removeDependencyRTreeCache(feature), this.clearDependencyForTree(feature);
|
|
8275
8377
|
}), this._featureFormulaData[unitId][sheetId] = {};
|
|
8276
8378
|
else if (this._featureFormulaData[unitId]) {
|
|
8277
8379
|
const unitFeatureData = this._featureFormulaData[unitId];
|
|
8278
8380
|
Object.keys(unitFeatureData).forEach((sheetId2) => {
|
|
8279
8381
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), Object.values(unitFeatureData[sheetId2]).forEach((feature) => {
|
|
8280
|
-
this.clearDependencyForTree(feature)
|
|
8382
|
+
this.clearDependencyForTree(feature);
|
|
8281
8383
|
}));
|
|
8282
8384
|
}), this._featureFormulaData[unitId] = null;
|
|
8283
8385
|
}
|
|
@@ -8287,30 +8389,30 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8287
8389
|
return (_b = (_a27 = this._featureFormulaData[unitId]) == null ? void 0 : _a27[sheetId]) == null ? void 0 : _b[featureId];
|
|
8288
8390
|
}
|
|
8289
8391
|
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)
|
|
8392
|
+
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
8393
|
}
|
|
8292
8394
|
removeFormulaDependency(unitId, sheetId, row, column) {
|
|
8293
8395
|
if (this._formulaData[unitId] && this._formulaData[unitId][sheetId]) {
|
|
8294
8396
|
const deleteTree = this._formulaData[unitId][sheetId].getValue(row, column);
|
|
8295
|
-
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), this._formulaData[unitId][sheetId].realDeleteValue(row, column)
|
|
8397
|
+
this._removeDependencyRTreeCache(deleteTree), this.clearDependencyForTree(deleteTree), this._formulaData[unitId][sheetId].realDeleteValue(row, column);
|
|
8296
8398
|
}
|
|
8297
8399
|
}
|
|
8298
8400
|
clearFormulaDependency(unitId, sheetId) {
|
|
8299
8401
|
if (sheetId && this._formulaData[unitId] && this._formulaData[unitId][sheetId])
|
|
8300
8402
|
this._removeDependencyRTreeCacheById(unitId, sheetId), this._formulaData[unitId][sheetId].forValue((row, column, item) => {
|
|
8301
|
-
this.clearDependencyForTree(item)
|
|
8403
|
+
this.clearDependencyForTree(item);
|
|
8302
8404
|
}), this._formulaData[unitId][sheetId].reset();
|
|
8303
8405
|
else if (this._formulaData[unitId]) {
|
|
8304
8406
|
const unitFormulaData = this._formulaData[unitId];
|
|
8305
8407
|
Object.keys(unitFormulaData).forEach((sheetId2) => {
|
|
8306
8408
|
sheetId2 != null && (this._removeDependencyRTreeCacheById(unitId, sheetId2), unitFormulaData[sheetId2].forValue((row, column, item) => {
|
|
8307
|
-
this.clearDependencyForTree(item)
|
|
8409
|
+
this.clearDependencyForTree(item);
|
|
8308
8410
|
}));
|
|
8309
8411
|
}), this._formulaData[unitId] = null;
|
|
8310
8412
|
}
|
|
8311
8413
|
}
|
|
8312
8414
|
clearDependencyAll() {
|
|
8313
|
-
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this.
|
|
8415
|
+
this._otherFormulaData = {}, this._featureFormulaData = {}, this._formulaData = {}, this._dependencyRTreeCache.clear(), this._restDependencyTreeId();
|
|
8314
8416
|
}
|
|
8315
8417
|
getFormulaDependency(unitId, sheetId, row, column) {
|
|
8316
8418
|
var _a27, _b;
|
|
@@ -8322,17 +8424,12 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8322
8424
|
id: tree.treeId
|
|
8323
8425
|
})));
|
|
8324
8426
|
}
|
|
8325
|
-
|
|
8326
|
-
this.
|
|
8327
|
-
}
|
|
8328
|
-
_removeTreeIdFromCache(tree) {
|
|
8329
|
-
tree != null && this._dependencyTreeIdsCache.delete(tree.treeId);
|
|
8427
|
+
_restDependencyTreeId() {
|
|
8428
|
+
this._dependencyTreeIdLast = 0;
|
|
8330
8429
|
}
|
|
8331
|
-
|
|
8332
|
-
this.
|
|
8333
|
-
|
|
8334
|
-
hasTreeIdInCache(treeId) {
|
|
8335
|
-
return this._dependencyTreeIdsCache.has(treeId);
|
|
8430
|
+
getLastTreeId() {
|
|
8431
|
+
const id = this._dependencyTreeIdLast;
|
|
8432
|
+
return this._dependencyTreeIdLast++, id;
|
|
8336
8433
|
}
|
|
8337
8434
|
_removeDependencyRTreeCacheById(unitId, sheetId) {
|
|
8338
8435
|
this._dependencyRTreeCache.removeById(unitId, sheetId);
|
|
@@ -8347,7 +8444,7 @@ const _DependencyManagerService = class _DependencyManagerService extends Dispos
|
|
|
8347
8444
|
this._formulaData[unitId] && Object.values(this._formulaData[unitId]).forEach((sheet) => {
|
|
8348
8445
|
sheet.forValue((row, column, tree) => {
|
|
8349
8446
|
var _a27;
|
|
8350
|
-
(_a27 = tree == null ? void 0 : tree.
|
|
8447
|
+
(_a27 = tree == null ? void 0 : tree.nodeData) != null && _a27.node.hasDefinedName(definedName) && (this._removeDependencyRTreeCache(tree), this.clearDependencyForTree(tree), sheet.realDeleteValue(row, column));
|
|
8351
8448
|
});
|
|
8352
8449
|
});
|
|
8353
8450
|
}
|
|
@@ -8480,11 +8577,10 @@ __name(_OtherFormulaManagerService, "OtherFormulaManagerService");
|
|
|
8480
8577
|
let OtherFormulaManagerService = _OtherFormulaManagerService;
|
|
8481
8578
|
const IOtherFormulaManagerService = createIdentifier(
|
|
8482
8579
|
"univer.formula.other-formula-manager.service"
|
|
8483
|
-
), _FormulaDependencyTree = class _FormulaDependencyTree
|
|
8580
|
+
), _FormulaDependencyTree = class _FormulaDependencyTree {
|
|
8484
8581
|
constructor(treeId) {
|
|
8485
|
-
super();
|
|
8486
8582
|
__publicField(this, "treeId", "");
|
|
8487
|
-
__publicField(this, "
|
|
8583
|
+
__publicField(this, "nodeData");
|
|
8488
8584
|
__publicField(this, "children", /* @__PURE__ */ new Set());
|
|
8489
8585
|
__publicField(this, "parents", /* @__PURE__ */ new Set());
|
|
8490
8586
|
__publicField(this, "formula", "");
|
|
@@ -8502,9 +8598,20 @@ const IOtherFormulaManagerService = createIdentifier(
|
|
|
8502
8598
|
__publicField(this, "_state", 0);
|
|
8503
8599
|
treeId != null ? this.treeId = treeId : this.treeId = generateRandomId(8);
|
|
8504
8600
|
}
|
|
8601
|
+
toJson() {
|
|
8602
|
+
return {
|
|
8603
|
+
formula: this.formula,
|
|
8604
|
+
row: this.row,
|
|
8605
|
+
column: this.column,
|
|
8606
|
+
subUnitId: this.subUnitId,
|
|
8607
|
+
unitId: this.unitId,
|
|
8608
|
+
formulaId: this.formulaId,
|
|
8609
|
+
featureId: this.featureId
|
|
8610
|
+
};
|
|
8611
|
+
}
|
|
8505
8612
|
dispose() {
|
|
8506
8613
|
var _a27;
|
|
8507
|
-
|
|
8614
|
+
this.children = /* @__PURE__ */ new Set(), this.rangeList = [], this.parents = /* @__PURE__ */ new Set(), (_a27 = this.nodeData) == null || _a27.node.dispose(), this.nodeData = null;
|
|
8508
8615
|
}
|
|
8509
8616
|
disposeWithChildren() {
|
|
8510
8617
|
this.children.forEach((tree) => {
|
|
@@ -8604,19 +8711,16 @@ const IOtherFormulaManagerService = createIdentifier(
|
|
|
8604
8711
|
};
|
|
8605
8712
|
__name(_FormulaDependencyTree, "FormulaDependencyTree");
|
|
8606
8713
|
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
8714
|
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
8615
8715
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8616
8716
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8617
8717
|
return kind && result && __defProp$9(target, key, result), result;
|
|
8618
8718
|
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
8619
8719
|
const FORMULA_CACHE_LRU_COUNT = 1e5;
|
|
8720
|
+
function generateRandomDependencyTreeId(dependencyManagerService) {
|
|
8721
|
+
return (dependencyManagerService.getLastTreeId() || 0).toString();
|
|
8722
|
+
}
|
|
8723
|
+
__name(generateRandomDependencyTreeId, "generateRandomDependencyTreeId");
|
|
8620
8724
|
var _a15;
|
|
8621
8725
|
let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
8622
8726
|
constructor(_currentConfigService, _runtimeService, _otherFormulaManagerService, _featureCalculationManagerService, _interpreter, _astTreeBuilder, _lexer, _dependencyManagerService) {
|
|
@@ -8665,23 +8769,46 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8665
8769
|
* @param formulaData
|
|
8666
8770
|
*/
|
|
8667
8771
|
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);
|
|
8772
|
+
const formulaDataKeys = Object.keys(formulaData), otherFormulaDataKeys = Object.keys(otherFormulaData), treeList = [], formulaRefCache = /* @__PURE__ */ new Map();
|
|
8773
|
+
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
8774
|
for (let i = 0, len = treeList.length; i < len; i++) {
|
|
8671
8775
|
const tree = treeList[i];
|
|
8672
|
-
|
|
8776
|
+
this._runtimeService.setCurrent(
|
|
8673
8777
|
tree.row,
|
|
8674
8778
|
tree.column,
|
|
8675
8779
|
tree.rowCount,
|
|
8676
8780
|
tree.columnCount,
|
|
8677
8781
|
tree.subUnitId,
|
|
8678
8782
|
tree.unitId
|
|
8679
|
-
)
|
|
8783
|
+
);
|
|
8784
|
+
const { unitId, formula, nodeData } = tree;
|
|
8785
|
+
if (nodeData == null)
|
|
8680
8786
|
continue;
|
|
8681
|
-
const
|
|
8682
|
-
|
|
8787
|
+
const { refOffsetX, refOffsetY } = nodeData;
|
|
8788
|
+
let applyCacheRange = !1;
|
|
8789
|
+
if (refOffsetX !== 0 || refOffsetY !== 0) {
|
|
8790
|
+
const refTreeNode = formulaRefCache.get(`${unitId}${formula}`);
|
|
8791
|
+
refTreeNode && refTreeNode.rangeList.length > 0 && (tree.pushRangeList(this._moveRangeList(refTreeNode, refOffsetX, refOffsetY)), applyCacheRange = !0);
|
|
8792
|
+
}
|
|
8793
|
+
if (!applyCacheRange) {
|
|
8794
|
+
const rangeList = await this._getRangeListByNode(nodeData);
|
|
8795
|
+
tree.pushRangeList(rangeList);
|
|
8796
|
+
}
|
|
8797
|
+
tree.isCache || this._dependencyManagerService.addDependencyRTreeCache(tree);
|
|
8798
|
+
}
|
|
8799
|
+
return formulaRefCache.clear(), treeList;
|
|
8800
|
+
}
|
|
8801
|
+
_moveRangeList(tree, refOffsetX, refOffsetY) {
|
|
8802
|
+
const rangeList = tree.rangeList, newRangeList = [];
|
|
8803
|
+
for (let i = 0, len = rangeList.length; i < len; i++) {
|
|
8804
|
+
const range = rangeList[i], newRange = {
|
|
8805
|
+
unitId: tree.unitId,
|
|
8806
|
+
sheetId: tree.subUnitId,
|
|
8807
|
+
range: { ...range.range }
|
|
8808
|
+
};
|
|
8809
|
+
newRange.range.startRow += refOffsetY, newRange.range.endRow += refOffsetY, newRange.range.startColumn += refOffsetX, newRange.range.endColumn += refOffsetX, newRangeList.push(newRange);
|
|
8683
8810
|
}
|
|
8684
|
-
return
|
|
8811
|
+
return newRangeList;
|
|
8685
8812
|
}
|
|
8686
8813
|
_registerFeatureFormulas(treeList) {
|
|
8687
8814
|
this._featureCalculationManagerService.getReferenceExecutorMap().forEach((subUnitMap, _) => {
|
|
@@ -8701,7 +8828,7 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8701
8828
|
const { unitId, subUnitId, dependencyRanges, getDirtyData } = params, FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
8702
8829
|
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
8830
|
}
|
|
8704
|
-
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
|
|
8831
|
+
_registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList, formulaRefCache) {
|
|
8705
8832
|
for (const unitId of otherFormulaDataKeys) {
|
|
8706
8833
|
const subComponentData = otherFormulaData[unitId];
|
|
8707
8834
|
if (subComponentData == null)
|
|
@@ -8713,18 +8840,18 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8713
8840
|
continue;
|
|
8714
8841
|
const subFormulaDataKeys = Object.keys(subFormulaData);
|
|
8715
8842
|
for (const subFormulaDataId of subFormulaDataKeys) {
|
|
8716
|
-
const treeCache = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
8843
|
+
const treeCache = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId), formulaDataItem = subFormulaData[subFormulaDataId], { f: formulaString, x = 0, y = 0 } = formulaDataItem;
|
|
8717
8844
|
if (treeCache) {
|
|
8718
|
-
treeCache.isCache = !0;
|
|
8845
|
+
treeCache.isCache = !0, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, treeCache);
|
|
8719
8846
|
continue;
|
|
8720
8847
|
}
|
|
8721
|
-
const
|
|
8722
|
-
FDtree.
|
|
8848
|
+
const nodeData = this._generateAstNode(unitId, formulaString, x, y), FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
8849
|
+
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
8850
|
}
|
|
8724
8851
|
}
|
|
8725
8852
|
}
|
|
8726
8853
|
}
|
|
8727
|
-
_registerFormulas(formulaDataKeys, formulaData, unitData, treeList) {
|
|
8854
|
+
_registerFormulas(formulaDataKeys, formulaData, unitData, treeList, formulaRefCache) {
|
|
8728
8855
|
for (const unitId of formulaDataKeys) {
|
|
8729
8856
|
const sheetData = formulaData[unitId];
|
|
8730
8857
|
if (sheetData == null)
|
|
@@ -8734,11 +8861,11 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8734
8861
|
new ObjectMatrix(sheetData[sheetId] || {}).forValue((row, column, formulaDataItem) => {
|
|
8735
8862
|
if (formulaDataItem == null)
|
|
8736
8863
|
return !0;
|
|
8737
|
-
const { f: formulaString, x, y } = formulaDataItem, treeCache = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
|
|
8864
|
+
const { f: formulaString, x = 0, y = 0 } = formulaDataItem, treeCache = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
|
|
8738
8865
|
if (treeCache)
|
|
8739
|
-
return treeCache.isCache = !0, !0;
|
|
8740
|
-
const
|
|
8741
|
-
FDtree.
|
|
8866
|
+
return treeCache.isCache = !0, x === 0 && y === 0 && formulaRefCache.set(`${unitId}${formulaString}`, treeCache), !0;
|
|
8867
|
+
const nodeData = this._generateAstNode(unitId, formulaString, x, y), FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService)), sheetItem = unitData[unitId][sheetId];
|
|
8868
|
+
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
8869
|
});
|
|
8743
8870
|
}
|
|
8744
8871
|
}
|
|
@@ -8756,15 +8883,19 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8756
8883
|
}
|
|
8757
8884
|
}
|
|
8758
8885
|
_generateAstNode(unitId, formulaString, refOffsetX = 0, refOffsetY = 0) {
|
|
8759
|
-
let astNode = this._formulaASTCache.get(`${unitId}${formulaString}
|
|
8886
|
+
let astNode = this._formulaASTCache.get(`${unitId}${formulaString}`);
|
|
8760
8887
|
if (astNode && !this._isDirtyDefinedForNode(astNode))
|
|
8761
|
-
return astNode;
|
|
8888
|
+
return generateExecuteAstNodeData(astNode, refOffsetX, refOffsetY);
|
|
8762
8889
|
const lexerNode = this._lexer.treeBuilder(formulaString);
|
|
8763
8890
|
if (ERROR_TYPE_SET.has(lexerNode))
|
|
8764
|
-
return
|
|
8765
|
-
|
|
8891
|
+
return {
|
|
8892
|
+
node: ErrorNode.create(lexerNode),
|
|
8893
|
+
refOffsetX,
|
|
8894
|
+
refOffsetY
|
|
8895
|
+
};
|
|
8896
|
+
if (astNode = this._astTreeBuilder.parse(lexerNode), astNode == null)
|
|
8766
8897
|
throw new Error("astNode is null");
|
|
8767
|
-
return this._formulaASTCache.set(`${unitId}${formulaString}
|
|
8898
|
+
return this._formulaASTCache.set(`${unitId}${formulaString}`, astNode), generateExecuteAstNodeData(astNode, refOffsetX, refOffsetY);
|
|
8768
8899
|
}
|
|
8769
8900
|
_addFlattenCache(unitId, sheetId, range) {
|
|
8770
8901
|
let unitMatrix = this._updateRangeFlattenCache.get(unitId);
|
|
@@ -8797,25 +8928,30 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8797
8928
|
this._nodeTraversalReferenceFunction(item, result);
|
|
8798
8929
|
}
|
|
8799
8930
|
}
|
|
8800
|
-
async _executeNode(node) {
|
|
8931
|
+
async _executeNode(node, refOffsetX = 0, refOffsetY = 0) {
|
|
8801
8932
|
let value;
|
|
8802
|
-
|
|
8933
|
+
const nodeData = {
|
|
8934
|
+
node,
|
|
8935
|
+
refOffsetX,
|
|
8936
|
+
refOffsetY
|
|
8937
|
+
};
|
|
8938
|
+
return this._interpreter.checkAsyncNode(node) ? value = await this._interpreter.executeAsync(nodeData) : value = this._interpreter.execute(nodeData), value;
|
|
8803
8939
|
}
|
|
8804
8940
|
/**
|
|
8805
8941
|
* Calculate the range required for collection in advance,
|
|
8806
8942
|
* including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
|
|
8807
8943
|
* @param node
|
|
8808
8944
|
*/
|
|
8809
|
-
async _getRangeListByNode(
|
|
8810
|
-
const preCalculateNodeList = [], referenceFunctionList = [];
|
|
8811
|
-
this._nodeTraversalRef(node, preCalculateNodeList), this._nodeTraversalReferenceFunction(node, referenceFunctionList);
|
|
8945
|
+
async _getRangeListByNode(nodeData) {
|
|
8946
|
+
const preCalculateNodeList = [], referenceFunctionList = [], refOffsetX = nodeData.refOffsetX, refOffsetY = nodeData.refOffsetY;
|
|
8947
|
+
this._nodeTraversalRef(nodeData.node, preCalculateNodeList), this._nodeTraversalReferenceFunction(nodeData.node, referenceFunctionList);
|
|
8812
8948
|
const rangeList = [];
|
|
8813
8949
|
for (let i = 0, len = preCalculateNodeList.length; i < len; i++) {
|
|
8814
|
-
const
|
|
8950
|
+
const node = preCalculateNodeList[i], gridRange = (await this._executeNode(node, refOffsetX, refOffsetY)).toUnitRange();
|
|
8815
8951
|
rangeList.push(gridRange);
|
|
8816
8952
|
}
|
|
8817
8953
|
for (let i = 0, len = referenceFunctionList.length; i < len; i++) {
|
|
8818
|
-
const
|
|
8954
|
+
const node = referenceFunctionList[i], gridRange = (await this._executeNode(node, refOffsetX, refOffsetY)).toUnitRange();
|
|
8819
8955
|
rangeList.push(gridRange);
|
|
8820
8956
|
}
|
|
8821
8957
|
return rangeList;
|
|
@@ -8846,9 +8982,12 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8846
8982
|
return newTreeList;
|
|
8847
8983
|
}
|
|
8848
8984
|
_dependencyFeatureCalculation(newTreeList) {
|
|
8985
|
+
const featureMap = this._featureCalculationManagerService.getReferenceExecutorMap();
|
|
8986
|
+
if (featureMap.size === 0)
|
|
8987
|
+
return;
|
|
8849
8988
|
this._clearFeatureCalculationNode(newTreeList);
|
|
8850
8989
|
let hasFeatureCalculation = !1;
|
|
8851
|
-
return
|
|
8990
|
+
return featureMap.forEach((subUnitMap, _) => {
|
|
8852
8991
|
subUnitMap.forEach((featureMap2, _2) => {
|
|
8853
8992
|
featureMap2.forEach((params, featureId) => {
|
|
8854
8993
|
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 +9075,13 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8936
9075
|
return !1;
|
|
8937
9076
|
}
|
|
8938
9077
|
_includeDefinedName(tree) {
|
|
8939
|
-
|
|
9078
|
+
var _a27;
|
|
9079
|
+
const node = (_a27 = tree.nodeData) == null ? void 0 : _a27.node;
|
|
8940
9080
|
return !!(node != null && this._isDirtyDefinedForNode(node));
|
|
8941
9081
|
}
|
|
8942
9082
|
_detectForcedRecalculationNode(tree) {
|
|
8943
|
-
|
|
9083
|
+
var _a27;
|
|
9084
|
+
const node = (_a27 = tree.nodeData) == null ? void 0 : _a27.node;
|
|
8944
9085
|
return node == null ? !1 : this._detectForcedRecalculationNodeRecursion(node);
|
|
8945
9086
|
}
|
|
8946
9087
|
_detectForcedRecalculationNodeRecursion(node) {
|
|
@@ -8989,20 +9130,19 @@ let FormulaDependencyGenerator = (_a15 = class extends Disposable {
|
|
|
8989
9130
|
* @param treeList
|
|
8990
9131
|
*/
|
|
8991
9132
|
_calculateRunList(treeList) {
|
|
8992
|
-
|
|
8993
|
-
const formulaRunList = [];
|
|
9133
|
+
const stack = treeList, formulaRunList = [], cacheStack = [];
|
|
8994
9134
|
for (; stack.length > 0; ) {
|
|
8995
9135
|
const tree = stack.pop();
|
|
8996
|
-
if (tree === void 0 || tree.isSkip())
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9136
|
+
if (!(tree === void 0 || tree.isSkip())) {
|
|
9137
|
+
if (tree.isAdded()) {
|
|
9138
|
+
formulaRunList.push(tree), tree.setSkip();
|
|
9139
|
+
continue;
|
|
9140
|
+
}
|
|
9141
|
+
cacheStack.length = 0;
|
|
9142
|
+
for (const parentTree of tree.parents)
|
|
9143
|
+
parentTree.isAdded() || tree.isSkip() || cacheStack.push(parentTree);
|
|
9144
|
+
cacheStack.length === 0 ? (formulaRunList.push(tree), tree.setSkip()) : (tree.setAdded(), stack.push(tree, ...cacheStack));
|
|
9001
9145
|
}
|
|
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
9146
|
}
|
|
9007
9147
|
return formulaRunList.reverse();
|
|
9008
9148
|
}
|
|
@@ -9116,9 +9256,9 @@ let CalculateFormulaService = (_a16 = class extends Disposable {
|
|
|
9116
9256
|
this._runtimeService.setFormulaExecuteStage(FormulaExecuteStageType.IDLE), this._runtimeService.markedAsStopFunctionsExecuted(), this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());
|
|
9117
9257
|
return;
|
|
9118
9258
|
}
|
|
9119
|
-
const tree = treeList[i],
|
|
9259
|
+
const tree = treeList[i], nodeData = tree.nodeData, getDirtyData = tree.getDirtyData;
|
|
9120
9260
|
let value;
|
|
9121
|
-
if (
|
|
9261
|
+
if (nodeData == null && getDirtyData == null)
|
|
9122
9262
|
throw new Error("AstNode or executor is null");
|
|
9123
9263
|
if (this._runtimeService.setCurrent(
|
|
9124
9264
|
tree.row,
|
|
@@ -9130,12 +9270,12 @@ let CalculateFormulaService = (_a16 = class extends Disposable {
|
|
|
9130
9270
|
), getDirtyData != null && tree.featureId != null) {
|
|
9131
9271
|
const { runtimeCellData, dirtyRanges } = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
|
|
9132
9272
|
this._runtimeService.setRuntimeFeatureCellData(tree.featureId, runtimeCellData), this._runtimeService.setRuntimeFeatureRange(tree.featureId, dirtyRanges);
|
|
9133
|
-
} else
|
|
9273
|
+
} 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
9274
|
isArrayFormulaState ? (this._runtimeService.setFormulaExecuteStage(
|
|
9135
9275
|
FormulaExecuteStageType.CURRENTLY_CALCULATING_ARRAY_FORMULA
|
|
9136
9276
|
), this._runtimeService.setCompletedArrayFormulasCount(i + 1)) : (this._runtimeService.setFormulaExecuteStage(FormulaExecuteStageType.CURRENTLY_CALCULATING), this._runtimeService.setCompletedFormulasCount(i + 1)), this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
|
|
9137
9277
|
}
|
|
9138
|
-
return pendingTasks.forEach((cancel) => cancel()), pendingTasks = [], treeList.length > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : isArrayFormulaState || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.getAllRuntimeData();
|
|
9278
|
+
return pendingTasks.forEach((cancel) => cancel()), pendingTasks = [], treeList.length > 0 ? this._runtimeService.markedAsSuccessfullyExecuted() : isArrayFormulaState || this._runtimeService.markedAsNoFunctionsExecuted(), this._runtimeService.clearReferenceAndNumberformatCache(), this._runtimeService.getAllRuntimeData();
|
|
9139
9279
|
}
|
|
9140
9280
|
calculate(formulaString, transformSuffix = !0) {
|
|
9141
9281
|
const lexerNode = this._lexer.treeBuilder(formulaString, transformSuffix);
|
|
@@ -9394,14 +9534,14 @@ function getR1C1Ref(index, absoluteRefType = AbsoluteRefType.ALL, isRow) {
|
|
|
9394
9534
|
__name(getR1C1Ref, "getR1C1Ref");
|
|
9395
9535
|
const functionArray = [];
|
|
9396
9536
|
var FUNCTION_NAMES_ARRAY = /* @__PURE__ */ ((FUNCTION_NAMES_ARRAY2) => FUNCTION_NAMES_ARRAY2)(FUNCTION_NAMES_ARRAY || {});
|
|
9397
|
-
const _BaseFunction = class _BaseFunction
|
|
9537
|
+
const _BaseFunction = class _BaseFunction {
|
|
9398
9538
|
constructor(_name) {
|
|
9399
|
-
super();
|
|
9400
9539
|
__publicField(this, "_unitId");
|
|
9401
9540
|
__publicField(this, "_subUnitId");
|
|
9402
9541
|
__publicField(this, "_row", -1);
|
|
9403
9542
|
__publicField(this, "_column", -1);
|
|
9404
9543
|
__publicField(this, "_definedNames");
|
|
9544
|
+
__publicField(this, "_locale");
|
|
9405
9545
|
/**
|
|
9406
9546
|
* Whether the function needs to expand the parameters
|
|
9407
9547
|
*/
|
|
@@ -9410,6 +9550,10 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9410
9550
|
* Whether the function needs to pass in reference object
|
|
9411
9551
|
*/
|
|
9412
9552
|
__publicField(this, "needsReferenceObject", !1);
|
|
9553
|
+
/**
|
|
9554
|
+
* Whether the function needs handle locale
|
|
9555
|
+
*/
|
|
9556
|
+
__publicField(this, "needsLocale", !1);
|
|
9413
9557
|
/**
|
|
9414
9558
|
* Minimum number of parameters
|
|
9415
9559
|
*/
|
|
@@ -9435,6 +9579,8 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9435
9579
|
get column() {
|
|
9436
9580
|
return this._column;
|
|
9437
9581
|
}
|
|
9582
|
+
dispose() {
|
|
9583
|
+
}
|
|
9438
9584
|
/**
|
|
9439
9585
|
* In Excel, to inject a defined name into a function that has positioning capabilities,
|
|
9440
9586
|
* such as using the INDIRECT function to reference a named range,
|
|
@@ -9449,6 +9595,12 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9449
9595
|
setDefinedNames(definedNames) {
|
|
9450
9596
|
this._definedNames = definedNames;
|
|
9451
9597
|
}
|
|
9598
|
+
getLocale() {
|
|
9599
|
+
return this._locale;
|
|
9600
|
+
}
|
|
9601
|
+
setLocale(locale) {
|
|
9602
|
+
this._locale = locale;
|
|
9603
|
+
}
|
|
9452
9604
|
isAsync() {
|
|
9453
9605
|
return !1;
|
|
9454
9606
|
}
|
|
@@ -9615,7 +9767,7 @@ const _BaseFunction = class _BaseFunction extends Disposable {
|
|
|
9615
9767
|
range
|
|
9616
9768
|
});
|
|
9617
9769
|
let referenceObject;
|
|
9618
|
-
return
|
|
9770
|
+
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
9771
|
}
|
|
9620
9772
|
_setReferenceDefault(reference, object) {
|
|
9621
9773
|
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);
|
|
@@ -9905,6 +10057,47 @@ function adjoint(matrix) {
|
|
|
9905
10057
|
return adj;
|
|
9906
10058
|
}
|
|
9907
10059
|
__name(adjoint, "adjoint");
|
|
10060
|
+
const romanToArabicMap = /* @__PURE__ */ new Map([
|
|
10061
|
+
["I", 1],
|
|
10062
|
+
["V", 5],
|
|
10063
|
+
["X", 10],
|
|
10064
|
+
["L", 50],
|
|
10065
|
+
["C", 100],
|
|
10066
|
+
["D", 500],
|
|
10067
|
+
["M", 1e3]
|
|
10068
|
+
]), arabicToRomanMap = /* @__PURE__ */ new Map([
|
|
10069
|
+
[1, "I"],
|
|
10070
|
+
[4, "IV"],
|
|
10071
|
+
[5, "V"],
|
|
10072
|
+
[9, "IX"],
|
|
10073
|
+
[10, "X"],
|
|
10074
|
+
[40, "XL"],
|
|
10075
|
+
[45, "VL"],
|
|
10076
|
+
[49, "IL"],
|
|
10077
|
+
[50, "L"],
|
|
10078
|
+
[90, "XC"],
|
|
10079
|
+
[95, "VC"],
|
|
10080
|
+
[99, "IC"],
|
|
10081
|
+
[100, "C"],
|
|
10082
|
+
[400, "CD"],
|
|
10083
|
+
[450, "LD"],
|
|
10084
|
+
[490, "XD"],
|
|
10085
|
+
[495, "VD"],
|
|
10086
|
+
[499, "ID"],
|
|
10087
|
+
[500, "D"],
|
|
10088
|
+
[900, "CM"],
|
|
10089
|
+
[950, "LM"],
|
|
10090
|
+
[990, "XM"],
|
|
10091
|
+
[995, "VM"],
|
|
10092
|
+
[999, "IM"],
|
|
10093
|
+
[1e3, "M"]
|
|
10094
|
+
]), romanFormArray = [
|
|
10095
|
+
[1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1e3, 4e3],
|
|
10096
|
+
[1, 4, 5, 9, 10, 40, 45, 50, 90, 95, 100, 400, 450, 500, 900, 950, 1e3, 4e3],
|
|
10097
|
+
[1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 500, 900, 950, 990, 1e3, 4e3],
|
|
10098
|
+
[1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 500, 900, 950, 990, 995, 1e3, 4e3],
|
|
10099
|
+
[1, 4, 5, 9, 10, 40, 45, 49, 50, 90, 95, 99, 100, 400, 450, 490, 495, 499, 500, 900, 950, 990, 995, 999, 1e3, 4e3]
|
|
10100
|
+
];
|
|
9908
10101
|
function betaCDF(x, alpha, beta) {
|
|
9909
10102
|
return x <= 0 ? 0 : x >= 1 ? 1 : incompleteBetaFunction(x, alpha, beta);
|
|
9910
10103
|
}
|
|
@@ -11097,8 +11290,522 @@ const _CustomFunction = class _CustomFunction extends BaseFunction {
|
|
|
11097
11290
|
};
|
|
11098
11291
|
__name(_CustomFunction, "CustomFunction");
|
|
11099
11292
|
let CustomFunction = _CustomFunction;
|
|
11100
|
-
|
|
11101
|
-
|
|
11293
|
+
function checkDatabase(database) {
|
|
11294
|
+
const databaseValues = [];
|
|
11295
|
+
if (database.isError())
|
|
11296
|
+
return {
|
|
11297
|
+
isError: !0,
|
|
11298
|
+
errorObject: database,
|
|
11299
|
+
databaseValues
|
|
11300
|
+
};
|
|
11301
|
+
const rowCount = database.isArray() ? database.getRowCount() : 1, columnCount = database.isArray() ? database.getColumnCount() : 1;
|
|
11302
|
+
if (rowCount < 2)
|
|
11303
|
+
return {
|
|
11304
|
+
isError: !0,
|
|
11305
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
11306
|
+
databaseValues
|
|
11307
|
+
};
|
|
11308
|
+
for (let r = 0; r < rowCount; r++) {
|
|
11309
|
+
const row = [];
|
|
11310
|
+
for (let c = 0; c < columnCount; c++) {
|
|
11311
|
+
const valueObject = database.get(r, c);
|
|
11312
|
+
if (valueObject.isNull()) {
|
|
11313
|
+
row.push(null);
|
|
11314
|
+
continue;
|
|
11315
|
+
}
|
|
11316
|
+
let value = `${valueObject.getValue()}`;
|
|
11317
|
+
if (valueObject.isBoolean() && (value = value.toLocaleUpperCase()), valueObject.isNumber() || isRealNum(value)) {
|
|
11318
|
+
row.push(+value);
|
|
11319
|
+
continue;
|
|
11320
|
+
}
|
|
11321
|
+
row.push(value);
|
|
11322
|
+
}
|
|
11323
|
+
databaseValues.push(row);
|
|
11324
|
+
}
|
|
11325
|
+
return {
|
|
11326
|
+
isError: !1,
|
|
11327
|
+
errorObject: null,
|
|
11328
|
+
databaseValues
|
|
11329
|
+
};
|
|
11330
|
+
}
|
|
11331
|
+
__name(checkDatabase, "checkDatabase");
|
|
11332
|
+
function checkField(field, database) {
|
|
11333
|
+
let fieldIndex = -1;
|
|
11334
|
+
if (field.isError())
|
|
11335
|
+
return {
|
|
11336
|
+
isError: !0,
|
|
11337
|
+
errorObject: field,
|
|
11338
|
+
fieldIndex
|
|
11339
|
+
};
|
|
11340
|
+
const rowCount = field.isArray() ? field.getRowCount() : 1, columnCount = field.isArray() ? field.getColumnCount() : 1;
|
|
11341
|
+
if (rowCount > 1 || columnCount > 1)
|
|
11342
|
+
return {
|
|
11343
|
+
isError: !0,
|
|
11344
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
11345
|
+
fieldIndex
|
|
11346
|
+
};
|
|
11347
|
+
const fieldObject = field.isArray() ? field.get(0, 0) : field;
|
|
11348
|
+
let fieldValue = `${fieldObject.getValue()}`;
|
|
11349
|
+
if (fieldObject.isNull() ? fieldValue = 0 : fieldObject.isBoolean() ? fieldValue = fieldObject.getValue() ? 1 : 0 : (fieldObject.isNumber() || isRealNum(fieldValue)) && (fieldValue = Math.floor(+fieldValue)), typeof fieldValue == "number") {
|
|
11350
|
+
if (fieldValue < 1 || fieldValue > database[0].length)
|
|
11351
|
+
return {
|
|
11352
|
+
isError: !0,
|
|
11353
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
11354
|
+
fieldIndex
|
|
11355
|
+
};
|
|
11356
|
+
fieldIndex = fieldValue - 1;
|
|
11357
|
+
} else if (fieldIndex = database[0].findIndex((value) => value === null ? !1 : `${value}`.toLocaleLowerCase() === fieldValue.toLocaleLowerCase()), fieldIndex === -1)
|
|
11358
|
+
return {
|
|
11359
|
+
isError: !0,
|
|
11360
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
11361
|
+
fieldIndex
|
|
11362
|
+
};
|
|
11363
|
+
return {
|
|
11364
|
+
isError: !1,
|
|
11365
|
+
errorObject: null,
|
|
11366
|
+
fieldIndex
|
|
11367
|
+
};
|
|
11368
|
+
}
|
|
11369
|
+
__name(checkField, "checkField");
|
|
11370
|
+
function checkCriteria(criteria) {
|
|
11371
|
+
const criteriaValues = [];
|
|
11372
|
+
if (criteria.isError())
|
|
11373
|
+
return {
|
|
11374
|
+
isError: !0,
|
|
11375
|
+
errorObject: criteria,
|
|
11376
|
+
criteriaValues
|
|
11377
|
+
};
|
|
11378
|
+
const rowCount = criteria.isArray() ? criteria.getRowCount() : 1, columnCount = criteria.isArray() ? criteria.getColumnCount() : 1;
|
|
11379
|
+
if (rowCount < 2)
|
|
11380
|
+
return {
|
|
11381
|
+
isError: !0,
|
|
11382
|
+
errorObject: ErrorValueObject.create(ErrorType$1.VALUE),
|
|
11383
|
+
criteriaValues
|
|
11384
|
+
};
|
|
11385
|
+
for (let r = 0; r < rowCount; r++) {
|
|
11386
|
+
const row = [];
|
|
11387
|
+
for (let c = 0; c < columnCount; c++) {
|
|
11388
|
+
const valueObject = criteria.get(r, c);
|
|
11389
|
+
if (valueObject.isNull()) {
|
|
11390
|
+
row.push(null);
|
|
11391
|
+
continue;
|
|
11392
|
+
}
|
|
11393
|
+
const value = `${valueObject.getValue()}`;
|
|
11394
|
+
if (valueObject.isBoolean()) {
|
|
11395
|
+
row.push(valueObject.getValue() ? 1 : 0);
|
|
11396
|
+
continue;
|
|
11397
|
+
}
|
|
11398
|
+
if (valueObject.isNumber() || isRealNum(value)) {
|
|
11399
|
+
row.push(+value);
|
|
11400
|
+
continue;
|
|
11401
|
+
}
|
|
11402
|
+
row.push(value);
|
|
11403
|
+
}
|
|
11404
|
+
criteriaValues.push(row);
|
|
11405
|
+
}
|
|
11406
|
+
return {
|
|
11407
|
+
isError: !1,
|
|
11408
|
+
errorObject: null,
|
|
11409
|
+
criteriaValues
|
|
11410
|
+
};
|
|
11411
|
+
}
|
|
11412
|
+
__name(checkCriteria, "checkCriteria");
|
|
11413
|
+
function isCriteriaMatch(criteria, database, databaseRowIndex) {
|
|
11414
|
+
const rowCount = criteria.length, columnCount = criteria[0].length, criteriaTitleIndexCache = {};
|
|
11415
|
+
let isMatch = !1;
|
|
11416
|
+
for (let r = 1; r < rowCount; r++) {
|
|
11417
|
+
let isRowMatch = !0;
|
|
11418
|
+
for (let c = 0; c < columnCount; c++) {
|
|
11419
|
+
const criteriaValue = criteria[r][c];
|
|
11420
|
+
if (criteriaValue === null)
|
|
11421
|
+
continue;
|
|
11422
|
+
let criteriaTitleIndex = criteriaTitleIndexCache[c];
|
|
11423
|
+
if (criteriaTitleIndex === void 0) {
|
|
11424
|
+
const criteriaTitleValue = criteria[0][c];
|
|
11425
|
+
criteriaTitleIndex = database[0].findIndex((value) => value === null || criteriaTitleValue === null ? !1 : `${value}`.toLocaleLowerCase() === `${criteriaTitleValue}`.toLocaleLowerCase()), criteriaTitleIndexCache[c] = criteriaTitleIndex;
|
|
11426
|
+
}
|
|
11427
|
+
if (criteriaTitleIndex === -1 && (typeof criteriaValue == "string" || criteriaValue === 0)) {
|
|
11428
|
+
isRowMatch = !1;
|
|
11429
|
+
break;
|
|
11430
|
+
} else if (criteriaTitleIndex > -1) {
|
|
11431
|
+
const databaseValue = database[databaseRowIndex][criteriaTitleIndex];
|
|
11432
|
+
if (databaseValue === null) {
|
|
11433
|
+
isRowMatch = !1;
|
|
11434
|
+
break;
|
|
11435
|
+
}
|
|
11436
|
+
const [compareToken2, criteriaObject] = findCompareToken(`${criteriaValue}`);
|
|
11437
|
+
if (!ValueObjectFactory.create(`${databaseValue}`).compare(criteriaObject, compareToken2).getValue()) {
|
|
11438
|
+
isRowMatch = !1;
|
|
11439
|
+
break;
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
if (isRowMatch) {
|
|
11444
|
+
isMatch = !0;
|
|
11445
|
+
break;
|
|
11446
|
+
}
|
|
11447
|
+
}
|
|
11448
|
+
return isMatch;
|
|
11449
|
+
}
|
|
11450
|
+
__name(isCriteriaMatch, "isCriteriaMatch");
|
|
11451
|
+
const _Daverage = class _Daverage extends BaseFunction {
|
|
11452
|
+
constructor() {
|
|
11453
|
+
super(...arguments);
|
|
11454
|
+
__publicField(this, "minParams", 3);
|
|
11455
|
+
__publicField(this, "maxParams", 3);
|
|
11456
|
+
}
|
|
11457
|
+
calculate(database, field, criteria) {
|
|
11458
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11459
|
+
if (databaseIsError)
|
|
11460
|
+
return databaseErrorObject;
|
|
11461
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11462
|
+
if (fieldIsError)
|
|
11463
|
+
return filedErrorObject;
|
|
11464
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11465
|
+
if (criteriaIsError)
|
|
11466
|
+
return criteriaErrorObject;
|
|
11467
|
+
let sum2 = 0, count = 0;
|
|
11468
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11469
|
+
const value = databaseValues[r][fieldIndex];
|
|
11470
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (sum2 += value, count++);
|
|
11471
|
+
}
|
|
11472
|
+
return count === 0 ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : NumberValueObject.create(sum2 / count);
|
|
11473
|
+
}
|
|
11474
|
+
};
|
|
11475
|
+
__name(_Daverage, "Daverage");
|
|
11476
|
+
let Daverage = _Daverage;
|
|
11477
|
+
const _Dcount = class _Dcount extends BaseFunction {
|
|
11478
|
+
constructor() {
|
|
11479
|
+
super(...arguments);
|
|
11480
|
+
__publicField(this, "minParams", 3);
|
|
11481
|
+
__publicField(this, "maxParams", 3);
|
|
11482
|
+
}
|
|
11483
|
+
calculate(database, field, criteria) {
|
|
11484
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11485
|
+
if (databaseIsError)
|
|
11486
|
+
return databaseErrorObject;
|
|
11487
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11488
|
+
if (fieldIsError)
|
|
11489
|
+
return filedErrorObject;
|
|
11490
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11491
|
+
if (criteriaIsError)
|
|
11492
|
+
return criteriaErrorObject;
|
|
11493
|
+
let count = 0;
|
|
11494
|
+
for (let r = 1; r < databaseValues.length; r++)
|
|
11495
|
+
typeof databaseValues[r][fieldIndex] == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && count++;
|
|
11496
|
+
return NumberValueObject.create(count);
|
|
11497
|
+
}
|
|
11498
|
+
};
|
|
11499
|
+
__name(_Dcount, "Dcount");
|
|
11500
|
+
let Dcount = _Dcount;
|
|
11501
|
+
const _Dcounta = class _Dcounta extends BaseFunction {
|
|
11502
|
+
constructor() {
|
|
11503
|
+
super(...arguments);
|
|
11504
|
+
__publicField(this, "minParams", 3);
|
|
11505
|
+
__publicField(this, "maxParams", 3);
|
|
11506
|
+
}
|
|
11507
|
+
calculate(database, field, criteria) {
|
|
11508
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11509
|
+
if (databaseIsError)
|
|
11510
|
+
return databaseErrorObject;
|
|
11511
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11512
|
+
if (fieldIsError)
|
|
11513
|
+
return filedErrorObject;
|
|
11514
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11515
|
+
if (criteriaIsError)
|
|
11516
|
+
return criteriaErrorObject;
|
|
11517
|
+
let count = 0;
|
|
11518
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11519
|
+
const value = databaseValues[r][fieldIndex];
|
|
11520
|
+
value != null && isCriteriaMatch(criteriaValues, databaseValues, r) && count++;
|
|
11521
|
+
}
|
|
11522
|
+
return NumberValueObject.create(count);
|
|
11523
|
+
}
|
|
11524
|
+
};
|
|
11525
|
+
__name(_Dcounta, "Dcounta");
|
|
11526
|
+
let Dcounta = _Dcounta;
|
|
11527
|
+
const _Dget = class _Dget extends BaseFunction {
|
|
11528
|
+
constructor() {
|
|
11529
|
+
super(...arguments);
|
|
11530
|
+
__publicField(this, "minParams", 3);
|
|
11531
|
+
__publicField(this, "maxParams", 3);
|
|
11532
|
+
}
|
|
11533
|
+
calculate(database, field, criteria) {
|
|
11534
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11535
|
+
if (databaseIsError)
|
|
11536
|
+
return databaseErrorObject;
|
|
11537
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11538
|
+
if (fieldIsError)
|
|
11539
|
+
return filedErrorObject;
|
|
11540
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11541
|
+
if (criteriaIsError)
|
|
11542
|
+
return criteriaErrorObject;
|
|
11543
|
+
let count = 0, resultRowIndex = 0;
|
|
11544
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11545
|
+
const value = databaseValues[r][fieldIndex];
|
|
11546
|
+
value != null && isCriteriaMatch(criteriaValues, databaseValues, r) && (count++, resultRowIndex = r);
|
|
11547
|
+
}
|
|
11548
|
+
return count === 0 ? ErrorValueObject.create(ErrorType$1.VALUE) : count > 1 ? ErrorValueObject.create(ErrorType$1.NUM) : database.get(resultRowIndex, fieldIndex);
|
|
11549
|
+
}
|
|
11550
|
+
};
|
|
11551
|
+
__name(_Dget, "Dget");
|
|
11552
|
+
let Dget = _Dget;
|
|
11553
|
+
const _Dmax = class _Dmax extends BaseFunction {
|
|
11554
|
+
constructor() {
|
|
11555
|
+
super(...arguments);
|
|
11556
|
+
__publicField(this, "minParams", 3);
|
|
11557
|
+
__publicField(this, "maxParams", 3);
|
|
11558
|
+
}
|
|
11559
|
+
calculate(database, field, criteria) {
|
|
11560
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11561
|
+
if (databaseIsError)
|
|
11562
|
+
return databaseErrorObject;
|
|
11563
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11564
|
+
if (fieldIsError)
|
|
11565
|
+
return filedErrorObject;
|
|
11566
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11567
|
+
if (criteriaIsError)
|
|
11568
|
+
return criteriaErrorObject;
|
|
11569
|
+
let result = -1 / 0, count = 0;
|
|
11570
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11571
|
+
const value = databaseValues[r][fieldIndex];
|
|
11572
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (result = Math.max(result, value), count++);
|
|
11573
|
+
}
|
|
11574
|
+
return count === 0 ? NumberValueObject.create(0) : NumberValueObject.create(result);
|
|
11575
|
+
}
|
|
11576
|
+
};
|
|
11577
|
+
__name(_Dmax, "Dmax");
|
|
11578
|
+
let Dmax = _Dmax;
|
|
11579
|
+
const _Dmin = class _Dmin extends BaseFunction {
|
|
11580
|
+
constructor() {
|
|
11581
|
+
super(...arguments);
|
|
11582
|
+
__publicField(this, "minParams", 3);
|
|
11583
|
+
__publicField(this, "maxParams", 3);
|
|
11584
|
+
}
|
|
11585
|
+
calculate(database, field, criteria) {
|
|
11586
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11587
|
+
if (databaseIsError)
|
|
11588
|
+
return databaseErrorObject;
|
|
11589
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11590
|
+
if (fieldIsError)
|
|
11591
|
+
return filedErrorObject;
|
|
11592
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11593
|
+
if (criteriaIsError)
|
|
11594
|
+
return criteriaErrorObject;
|
|
11595
|
+
let result = 1 / 0, count = 0;
|
|
11596
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11597
|
+
const value = databaseValues[r][fieldIndex];
|
|
11598
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (result = Math.min(result, value), count++);
|
|
11599
|
+
}
|
|
11600
|
+
return count === 0 ? NumberValueObject.create(0) : NumberValueObject.create(result);
|
|
11601
|
+
}
|
|
11602
|
+
};
|
|
11603
|
+
__name(_Dmin, "Dmin");
|
|
11604
|
+
let Dmin = _Dmin;
|
|
11605
|
+
const _Dproduct = class _Dproduct extends BaseFunction {
|
|
11606
|
+
constructor() {
|
|
11607
|
+
super(...arguments);
|
|
11608
|
+
__publicField(this, "minParams", 3);
|
|
11609
|
+
__publicField(this, "maxParams", 3);
|
|
11610
|
+
}
|
|
11611
|
+
calculate(database, field, criteria) {
|
|
11612
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11613
|
+
if (databaseIsError)
|
|
11614
|
+
return databaseErrorObject;
|
|
11615
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11616
|
+
if (fieldIsError)
|
|
11617
|
+
return filedErrorObject;
|
|
11618
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11619
|
+
if (criteriaIsError)
|
|
11620
|
+
return criteriaErrorObject;
|
|
11621
|
+
let result = 1, count = 0;
|
|
11622
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11623
|
+
const value = databaseValues[r][fieldIndex];
|
|
11624
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (result *= value, count++);
|
|
11625
|
+
}
|
|
11626
|
+
return count === 0 ? NumberValueObject.create(0) : NumberValueObject.create(result);
|
|
11627
|
+
}
|
|
11628
|
+
};
|
|
11629
|
+
__name(_Dproduct, "Dproduct");
|
|
11630
|
+
let Dproduct = _Dproduct;
|
|
11631
|
+
const _Dstdev = class _Dstdev extends BaseFunction {
|
|
11632
|
+
constructor() {
|
|
11633
|
+
super(...arguments);
|
|
11634
|
+
__publicField(this, "minParams", 3);
|
|
11635
|
+
__publicField(this, "maxParams", 3);
|
|
11636
|
+
}
|
|
11637
|
+
calculate(database, field, criteria) {
|
|
11638
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11639
|
+
if (databaseIsError)
|
|
11640
|
+
return databaseErrorObject;
|
|
11641
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11642
|
+
if (fieldIsError)
|
|
11643
|
+
return filedErrorObject;
|
|
11644
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11645
|
+
if (criteriaIsError)
|
|
11646
|
+
return criteriaErrorObject;
|
|
11647
|
+
const values = [];
|
|
11648
|
+
let sum2 = 0, count = 0;
|
|
11649
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11650
|
+
const value = databaseValues[r][fieldIndex];
|
|
11651
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (values.push(value), sum2 += value, count++);
|
|
11652
|
+
}
|
|
11653
|
+
if (count <= 1)
|
|
11654
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
11655
|
+
const mean = sum2 / count;
|
|
11656
|
+
let sumOfSquaresDifferences = 0;
|
|
11657
|
+
for (let i = 0; i < count; i++)
|
|
11658
|
+
sumOfSquaresDifferences += (values[i] - mean) ** 2;
|
|
11659
|
+
const result = Math.sqrt(sumOfSquaresDifferences / (count - 1));
|
|
11660
|
+
return NumberValueObject.create(result);
|
|
11661
|
+
}
|
|
11662
|
+
};
|
|
11663
|
+
__name(_Dstdev, "Dstdev");
|
|
11664
|
+
let Dstdev = _Dstdev;
|
|
11665
|
+
const _Dstdevp = class _Dstdevp extends BaseFunction {
|
|
11666
|
+
constructor() {
|
|
11667
|
+
super(...arguments);
|
|
11668
|
+
__publicField(this, "minParams", 3);
|
|
11669
|
+
__publicField(this, "maxParams", 3);
|
|
11670
|
+
}
|
|
11671
|
+
calculate(database, field, criteria) {
|
|
11672
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11673
|
+
if (databaseIsError)
|
|
11674
|
+
return databaseErrorObject;
|
|
11675
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11676
|
+
if (fieldIsError)
|
|
11677
|
+
return filedErrorObject;
|
|
11678
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11679
|
+
if (criteriaIsError)
|
|
11680
|
+
return criteriaErrorObject;
|
|
11681
|
+
const values = [];
|
|
11682
|
+
let sum2 = 0, count = 0;
|
|
11683
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11684
|
+
const value = databaseValues[r][fieldIndex];
|
|
11685
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (values.push(value), sum2 += value, count++);
|
|
11686
|
+
}
|
|
11687
|
+
if (count === 0)
|
|
11688
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
11689
|
+
const mean = sum2 / count;
|
|
11690
|
+
let sumOfSquaresDifferences = 0;
|
|
11691
|
+
for (let i = 0; i < count; i++)
|
|
11692
|
+
sumOfSquaresDifferences += (values[i] - mean) ** 2;
|
|
11693
|
+
const result = Math.sqrt(sumOfSquaresDifferences / count);
|
|
11694
|
+
return NumberValueObject.create(result);
|
|
11695
|
+
}
|
|
11696
|
+
};
|
|
11697
|
+
__name(_Dstdevp, "Dstdevp");
|
|
11698
|
+
let Dstdevp = _Dstdevp;
|
|
11699
|
+
const _Dsum = class _Dsum extends BaseFunction {
|
|
11700
|
+
constructor() {
|
|
11701
|
+
super(...arguments);
|
|
11702
|
+
__publicField(this, "minParams", 3);
|
|
11703
|
+
__publicField(this, "maxParams", 3);
|
|
11704
|
+
}
|
|
11705
|
+
calculate(database, field, criteria) {
|
|
11706
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11707
|
+
if (databaseIsError)
|
|
11708
|
+
return databaseErrorObject;
|
|
11709
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11710
|
+
if (fieldIsError)
|
|
11711
|
+
return filedErrorObject;
|
|
11712
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11713
|
+
if (criteriaIsError)
|
|
11714
|
+
return criteriaErrorObject;
|
|
11715
|
+
let result = 0;
|
|
11716
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11717
|
+
const value = databaseValues[r][fieldIndex];
|
|
11718
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (result += value);
|
|
11719
|
+
}
|
|
11720
|
+
return NumberValueObject.create(result);
|
|
11721
|
+
}
|
|
11722
|
+
};
|
|
11723
|
+
__name(_Dsum, "Dsum");
|
|
11724
|
+
let Dsum = _Dsum;
|
|
11725
|
+
const _Dvar = class _Dvar extends BaseFunction {
|
|
11726
|
+
constructor() {
|
|
11727
|
+
super(...arguments);
|
|
11728
|
+
__publicField(this, "minParams", 3);
|
|
11729
|
+
__publicField(this, "maxParams", 3);
|
|
11730
|
+
}
|
|
11731
|
+
calculate(database, field, criteria) {
|
|
11732
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11733
|
+
if (databaseIsError)
|
|
11734
|
+
return databaseErrorObject;
|
|
11735
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11736
|
+
if (fieldIsError)
|
|
11737
|
+
return filedErrorObject;
|
|
11738
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11739
|
+
if (criteriaIsError)
|
|
11740
|
+
return criteriaErrorObject;
|
|
11741
|
+
const values = [];
|
|
11742
|
+
let sum2 = 0, count = 0;
|
|
11743
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11744
|
+
const value = databaseValues[r][fieldIndex];
|
|
11745
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (values.push(value), sum2 += value, count++);
|
|
11746
|
+
}
|
|
11747
|
+
if (count <= 1)
|
|
11748
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
11749
|
+
const mean = sum2 / count;
|
|
11750
|
+
let sumOfSquaresDifferences = 0;
|
|
11751
|
+
for (let i = 0; i < count; i++)
|
|
11752
|
+
sumOfSquaresDifferences += (values[i] - mean) ** 2;
|
|
11753
|
+
const result = sumOfSquaresDifferences / (count - 1);
|
|
11754
|
+
return NumberValueObject.create(result);
|
|
11755
|
+
}
|
|
11756
|
+
};
|
|
11757
|
+
__name(_Dvar, "Dvar");
|
|
11758
|
+
let Dvar = _Dvar;
|
|
11759
|
+
const _Dvarp = class _Dvarp extends BaseFunction {
|
|
11760
|
+
constructor() {
|
|
11761
|
+
super(...arguments);
|
|
11762
|
+
__publicField(this, "minParams", 3);
|
|
11763
|
+
__publicField(this, "maxParams", 3);
|
|
11764
|
+
}
|
|
11765
|
+
calculate(database, field, criteria) {
|
|
11766
|
+
const { isError: databaseIsError, errorObject: databaseErrorObject, databaseValues } = checkDatabase(database);
|
|
11767
|
+
if (databaseIsError)
|
|
11768
|
+
return databaseErrorObject;
|
|
11769
|
+
const { isError: fieldIsError, errorObject: filedErrorObject, fieldIndex } = checkField(field, databaseValues);
|
|
11770
|
+
if (fieldIsError)
|
|
11771
|
+
return filedErrorObject;
|
|
11772
|
+
const { isError: criteriaIsError, errorObject: criteriaErrorObject, criteriaValues } = checkCriteria(criteria);
|
|
11773
|
+
if (criteriaIsError)
|
|
11774
|
+
return criteriaErrorObject;
|
|
11775
|
+
const values = [];
|
|
11776
|
+
let sum2 = 0, count = 0;
|
|
11777
|
+
for (let r = 1; r < databaseValues.length; r++) {
|
|
11778
|
+
const value = databaseValues[r][fieldIndex];
|
|
11779
|
+
typeof value == "number" && isCriteriaMatch(criteriaValues, databaseValues, r) && (values.push(value), sum2 += value, count++);
|
|
11780
|
+
}
|
|
11781
|
+
if (count === 0)
|
|
11782
|
+
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
11783
|
+
const mean = sum2 / count;
|
|
11784
|
+
let sumOfSquaresDifferences = 0;
|
|
11785
|
+
for (let i = 0; i < count; i++)
|
|
11786
|
+
sumOfSquaresDifferences += (values[i] - mean) ** 2;
|
|
11787
|
+
const result = sumOfSquaresDifferences / count;
|
|
11788
|
+
return NumberValueObject.create(result);
|
|
11789
|
+
}
|
|
11790
|
+
};
|
|
11791
|
+
__name(_Dvarp, "Dvarp");
|
|
11792
|
+
let Dvarp = _Dvarp;
|
|
11793
|
+
var FUNCTION_NAMES_DATABASE = /* @__PURE__ */ ((FUNCTION_NAMES_DATABASE2) => (FUNCTION_NAMES_DATABASE2.DAVERAGE = "DAVERAGE", FUNCTION_NAMES_DATABASE2.DCOUNT = "DCOUNT", FUNCTION_NAMES_DATABASE2.DCOUNTA = "DCOUNTA", FUNCTION_NAMES_DATABASE2.DGET = "DGET", FUNCTION_NAMES_DATABASE2.DMAX = "DMAX", FUNCTION_NAMES_DATABASE2.DMIN = "DMIN", FUNCTION_NAMES_DATABASE2.DPRODUCT = "DPRODUCT", FUNCTION_NAMES_DATABASE2.DSTDEV = "DSTDEV", FUNCTION_NAMES_DATABASE2.DSTDEVP = "DSTDEVP", FUNCTION_NAMES_DATABASE2.DSUM = "DSUM", FUNCTION_NAMES_DATABASE2.DVAR = "DVAR", FUNCTION_NAMES_DATABASE2.DVARP = "DVARP", FUNCTION_NAMES_DATABASE2))(FUNCTION_NAMES_DATABASE || {});
|
|
11794
|
+
const functionDatabase = [
|
|
11795
|
+
[Daverage, FUNCTION_NAMES_DATABASE.DAVERAGE],
|
|
11796
|
+
[Dcount, FUNCTION_NAMES_DATABASE.DCOUNT],
|
|
11797
|
+
[Dcounta, FUNCTION_NAMES_DATABASE.DCOUNTA],
|
|
11798
|
+
[Dget, FUNCTION_NAMES_DATABASE.DGET],
|
|
11799
|
+
[Dmax, FUNCTION_NAMES_DATABASE.DMAX],
|
|
11800
|
+
[Dmin, FUNCTION_NAMES_DATABASE.DMIN],
|
|
11801
|
+
[Dproduct, FUNCTION_NAMES_DATABASE.DPRODUCT],
|
|
11802
|
+
[Dstdev, FUNCTION_NAMES_DATABASE.DSTDEV],
|
|
11803
|
+
[Dstdevp, FUNCTION_NAMES_DATABASE.DSTDEVP],
|
|
11804
|
+
[Dsum, FUNCTION_NAMES_DATABASE.DSUM],
|
|
11805
|
+
[Dvar, FUNCTION_NAMES_DATABASE.DVAR],
|
|
11806
|
+
[Dvarp, FUNCTION_NAMES_DATABASE.DVARP]
|
|
11807
|
+
];
|
|
11808
|
+
var FUNCTION_NAMES_DATE = /* @__PURE__ */ ((FUNCTION_NAMES_DATE2) => (FUNCTION_NAMES_DATE2.DATE = "DATE", FUNCTION_NAMES_DATE2.DATEDIF = "DATEDIF", FUNCTION_NAMES_DATE2.DATEVALUE = "DATEVALUE", FUNCTION_NAMES_DATE2.DAY = "DAY", FUNCTION_NAMES_DATE2.DAYS = "DAYS", FUNCTION_NAMES_DATE2.DAYS360 = "DAYS360", FUNCTION_NAMES_DATE2.EDATE = "EDATE", FUNCTION_NAMES_DATE2.EOMONTH = "EOMONTH", FUNCTION_NAMES_DATE2.HOUR = "HOUR", FUNCTION_NAMES_DATE2.ISOWEEKNUM = "ISOWEEKNUM", FUNCTION_NAMES_DATE2.MINUTE = "MINUTE", FUNCTION_NAMES_DATE2.MONTH = "MONTH", FUNCTION_NAMES_DATE2.NETWORKDAYS = "NETWORKDAYS", FUNCTION_NAMES_DATE2.NETWORKDAYS_INTL = "NETWORKDAYS.INTL", FUNCTION_NAMES_DATE2.NOW = "NOW", FUNCTION_NAMES_DATE2.SECOND = "SECOND", FUNCTION_NAMES_DATE2.TIME = "TIME", FUNCTION_NAMES_DATE2.TIMEVALUE = "TIMEVALUE", FUNCTION_NAMES_DATE2.TODAY = "TODAY", FUNCTION_NAMES_DATE2.WEEKDAY = "WEEKDAY", FUNCTION_NAMES_DATE2.WEEKNUM = "WEEKNUM", FUNCTION_NAMES_DATE2.WORKDAY = "WORKDAY", FUNCTION_NAMES_DATE2.WORKDAY_INTL = "WORKDAY.INTL", FUNCTION_NAMES_DATE2.YEAR = "YEAR", FUNCTION_NAMES_DATE2.YEARFRAC = "YEARFRAC", FUNCTION_NAMES_DATE2))(FUNCTION_NAMES_DATE || {});
|
|
11102
11809
|
const DEFAULT_DATE_FORMAT = "yyyy/mm/dd;@", DEFAULT_NOW_FORMAT = "yyyy/mm/dd hh:mm", DEFAULT_TIME_FORMAT = "h:mm A/P";
|
|
11103
11810
|
function excelDateSerial(date) {
|
|
11104
11811
|
const baseDate = new Date(Date.UTC(1900, 0, 1)), leapDayDate = new Date(Date.UTC(1900, 1, 28)), dateInUTC = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
@@ -15026,6 +15733,7 @@ const _Db = class _Db extends BaseFunction {
|
|
|
15026
15733
|
super(...arguments);
|
|
15027
15734
|
__publicField(this, "minParams", 4);
|
|
15028
15735
|
__publicField(this, "maxParams", 5);
|
|
15736
|
+
__publicField(this, "needsLocale", !0);
|
|
15029
15737
|
}
|
|
15030
15738
|
calculate(cost, salvage, life, period, month) {
|
|
15031
15739
|
let _month = month != null ? month : NumberValueObject.create(12);
|
|
@@ -15060,7 +15768,7 @@ const _Db = class _Db extends BaseFunction {
|
|
|
15060
15768
|
for (let i = 2; i <= ceiling; i++)
|
|
15061
15769
|
current = (costValue - total) * rate, total += current;
|
|
15062
15770
|
let result;
|
|
15063
|
-
return periodValue === 1 ? result = initial : periodValue === lifeValue ? result = (costValue - total) * rate : result = current, Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
15771
|
+
return periodValue === 1 ? result = initial : periodValue === lifeValue ? result = (costValue - total) * rate : result = current, Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15064
15772
|
}
|
|
15065
15773
|
};
|
|
15066
15774
|
__name(_Db, "Db");
|
|
@@ -15070,6 +15778,7 @@ const _Ddb = class _Ddb extends BaseFunction {
|
|
|
15070
15778
|
super(...arguments);
|
|
15071
15779
|
__publicField(this, "minParams", 4);
|
|
15072
15780
|
__publicField(this, "maxParams", 5);
|
|
15781
|
+
__publicField(this, "needsLocale", !0);
|
|
15073
15782
|
}
|
|
15074
15783
|
calculate(cost, salvage, life, period, factor) {
|
|
15075
15784
|
let _factor = factor != null ? factor : NumberValueObject.create(2);
|
|
@@ -15094,7 +15803,7 @@ const _Ddb = class _Ddb extends BaseFunction {
|
|
|
15094
15803
|
if (costValue < 0 || salvageValue < 0 || lifeValue <= 0 || periodValue <= 0 || periodValue > lifeValue || factorValue <= 0)
|
|
15095
15804
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
15096
15805
|
const result = calculateDDB(costValue, salvageValue, lifeValue, periodValue, factorValue);
|
|
15097
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
15806
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15098
15807
|
});
|
|
15099
15808
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15100
15809
|
}
|
|
@@ -15237,6 +15946,7 @@ const _Fv = class _Fv extends BaseFunction {
|
|
|
15237
15946
|
super(...arguments);
|
|
15238
15947
|
__publicField(this, "minParams", 3);
|
|
15239
15948
|
__publicField(this, "maxParams", 5);
|
|
15949
|
+
__publicField(this, "needsLocale", !0);
|
|
15240
15950
|
}
|
|
15241
15951
|
calculate(rate, nper, pmt, pv, type) {
|
|
15242
15952
|
const _pv = pv != null ? pv : NumberValueObject.create(0), _type = type != null ? type : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
@@ -15256,7 +15966,7 @@ const _Fv = class _Fv extends BaseFunction {
|
|
|
15256
15966
|
if (isError)
|
|
15257
15967
|
return errorObject;
|
|
15258
15968
|
const [_rateObject, _nperObject, _pmtObject, _pvObject, _typeObject] = variants, rateValue = +_rateObject.getValue(), nperValue = +_nperObject.getValue(), pmtValue = +_pmtObject.getValue(), pvValue = +_pvObject.getValue(), typeValue = +_typeObject.getValue(), result = calculateFV(rateValue, nperValue, pmtValue, pvValue, typeValue ? 1 : 0);
|
|
15259
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
15969
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15260
15970
|
});
|
|
15261
15971
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15262
15972
|
}
|
|
@@ -15333,6 +16043,7 @@ const _Ipmt = class _Ipmt extends BaseFunction {
|
|
|
15333
16043
|
super(...arguments);
|
|
15334
16044
|
__publicField(this, "minParams", 4);
|
|
15335
16045
|
__publicField(this, "maxParams", 6);
|
|
16046
|
+
__publicField(this, "needsLocale", !0);
|
|
15336
16047
|
}
|
|
15337
16048
|
calculate(rate, per, nper, pv, fv, type) {
|
|
15338
16049
|
const _fv = fv != null ? fv : NumberValueObject.create(0), _type = type != null ? type : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
@@ -15357,7 +16068,7 @@ const _Ipmt = class _Ipmt extends BaseFunction {
|
|
|
15357
16068
|
if (perValue < 1 || Math.floor(perValue) > Math.ceil(nperValue))
|
|
15358
16069
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
15359
16070
|
const result = calculateIPMT(rateValue, perValue, nperValue, pvValue, fvValue, typeValue ? 1 : 0);
|
|
15360
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
16071
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15361
16072
|
});
|
|
15362
16073
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15363
16074
|
}
|
|
@@ -15645,6 +16356,7 @@ const _Npv = class _Npv extends BaseFunction {
|
|
|
15645
16356
|
super(...arguments);
|
|
15646
16357
|
__publicField(this, "minParams", 2);
|
|
15647
16358
|
__publicField(this, "maxParams", 255);
|
|
16359
|
+
__publicField(this, "needsLocale", !0);
|
|
15648
16360
|
}
|
|
15649
16361
|
calculate(rate, ...variants) {
|
|
15650
16362
|
if (rate.isError())
|
|
@@ -15659,7 +16371,7 @@ const _Npv = class _Npv extends BaseFunction {
|
|
|
15659
16371
|
if (isError)
|
|
15660
16372
|
return errorObject;
|
|
15661
16373
|
const rateValue = +rate.getValue(), result = calculateNpv(rateValue, values);
|
|
15662
|
-
return Number.isNaN(result) || Math.abs(result) === 1 / 0 ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
16374
|
+
return Number.isNaN(result) || Math.abs(result) === 1 / 0 ? ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15663
16375
|
}
|
|
15664
16376
|
_getValues(variants) {
|
|
15665
16377
|
const values = [];
|
|
@@ -15956,6 +16668,7 @@ const _Pmt = class _Pmt extends BaseFunction {
|
|
|
15956
16668
|
super(...arguments);
|
|
15957
16669
|
__publicField(this, "minParams", 3);
|
|
15958
16670
|
__publicField(this, "maxParams", 5);
|
|
16671
|
+
__publicField(this, "needsLocale", !0);
|
|
15959
16672
|
}
|
|
15960
16673
|
calculate(rate, nper, pv, fv, type) {
|
|
15961
16674
|
const _fv = fv != null ? fv : NumberValueObject.create(0), _type = type != null ? type : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
@@ -15978,7 +16691,7 @@ const _Pmt = class _Pmt extends BaseFunction {
|
|
|
15978
16691
|
if (rateValue <= -1)
|
|
15979
16692
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
15980
16693
|
const result = calculatePMT(rateValue, nperValue, pvValue, fvValue, typeValue ? 1 : 0);
|
|
15981
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
16694
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
15982
16695
|
});
|
|
15983
16696
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
15984
16697
|
}
|
|
@@ -15990,6 +16703,7 @@ const _Ppmt = class _Ppmt extends BaseFunction {
|
|
|
15990
16703
|
super(...arguments);
|
|
15991
16704
|
__publicField(this, "minParams", 4);
|
|
15992
16705
|
__publicField(this, "maxParams", 6);
|
|
16706
|
+
__publicField(this, "needsLocale", !0);
|
|
15993
16707
|
}
|
|
15994
16708
|
calculate(rate, per, nper, pv, fv, type) {
|
|
15995
16709
|
const _fv = fv != null ? fv : NumberValueObject.create(0), _type = type != null ? type : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
@@ -16014,7 +16728,7 @@ const _Ppmt = class _Ppmt extends BaseFunction {
|
|
|
16014
16728
|
if (perValue < 1 || Math.floor(perValue) > Math.ceil(nperValue) || perValue - nperValue >= 1)
|
|
16015
16729
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
16016
16730
|
const result = calculatePMT(rateValue, nperValue, pvValue, fvValue, typeValue ? 1 : 0) - calculateIPMT(rateValue, perValue, nperValue, pvValue, fvValue, typeValue ? 1 : 0);
|
|
16017
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
16731
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
16018
16732
|
});
|
|
16019
16733
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16020
16734
|
}
|
|
@@ -16120,6 +16834,7 @@ const _Pv = class _Pv extends BaseFunction {
|
|
|
16120
16834
|
super(...arguments);
|
|
16121
16835
|
__publicField(this, "minParams", 3);
|
|
16122
16836
|
__publicField(this, "maxParams", 5);
|
|
16837
|
+
__publicField(this, "needsLocale", !0);
|
|
16123
16838
|
}
|
|
16124
16839
|
calculate(rate, nper, pmt, fv, type) {
|
|
16125
16840
|
const _fv = fv != null ? fv : NumberValueObject.create(0), _type = type != null ? type : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
@@ -16142,7 +16857,7 @@ const _Pv = class _Pv extends BaseFunction {
|
|
|
16142
16857
|
let typeValue = +_typeObject.getValue();
|
|
16143
16858
|
typeValue = typeValue ? 1 : 0;
|
|
16144
16859
|
const result = rateValue === 0 ? -pmtValue * nperValue - fvValue : ((1 - (1 + rateValue) ** nperValue) / rateValue * pmtValue * (1 + rateValue * typeValue) - fvValue) / (1 + rateValue) ** nperValue;
|
|
16145
|
-
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
16860
|
+
return Number.isNaN(result) || !Number.isFinite(result) ? ErrorValueObject.create(ErrorType$1.NUM) : rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
16146
16861
|
});
|
|
16147
16862
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16148
16863
|
}
|
|
@@ -16270,6 +16985,7 @@ const _Sln = class _Sln extends BaseFunction {
|
|
|
16270
16985
|
super(...arguments);
|
|
16271
16986
|
__publicField(this, "minParams", 3);
|
|
16272
16987
|
__publicField(this, "maxParams", 3);
|
|
16988
|
+
__publicField(this, "needsLocale", !0);
|
|
16273
16989
|
}
|
|
16274
16990
|
calculate(cost, salvage, life) {
|
|
16275
16991
|
const maxRowLength = Math.max(
|
|
@@ -16292,7 +17008,7 @@ const _Sln = class _Sln extends BaseFunction {
|
|
|
16292
17008
|
if (lifeValue === 0)
|
|
16293
17009
|
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
16294
17010
|
const result = (costValue - salvageValue) / lifeValue;
|
|
16295
|
-
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
17011
|
+
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
16296
17012
|
});
|
|
16297
17013
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16298
17014
|
}
|
|
@@ -16304,6 +17020,7 @@ const _Syd = class _Syd extends BaseFunction {
|
|
|
16304
17020
|
super(...arguments);
|
|
16305
17021
|
__publicField(this, "minParams", 4);
|
|
16306
17022
|
__publicField(this, "maxParams", 4);
|
|
17023
|
+
__publicField(this, "needsLocale", !0);
|
|
16307
17024
|
}
|
|
16308
17025
|
calculate(cost, salvage, life, per) {
|
|
16309
17026
|
const maxRowLength = Math.max(
|
|
@@ -16330,7 +17047,7 @@ const _Syd = class _Syd extends BaseFunction {
|
|
|
16330
17047
|
if (salvageValue < 0 || lifeValue <= 0 || perValue > lifeValue)
|
|
16331
17048
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
16332
17049
|
const result = (costValue - salvageValue) * (lifeValue - perValue + 1) * 2 / (lifeValue * (lifeValue + 1));
|
|
16333
|
-
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
17050
|
+
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
16334
17051
|
});
|
|
16335
17052
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16336
17053
|
}
|
|
@@ -16377,6 +17094,7 @@ const _Tbillprice = class _Tbillprice extends BaseFunction {
|
|
|
16377
17094
|
super(...arguments);
|
|
16378
17095
|
__publicField(this, "minParams", 3);
|
|
16379
17096
|
__publicField(this, "maxParams", 3);
|
|
17097
|
+
__publicField(this, "needsLocale", !0);
|
|
16380
17098
|
}
|
|
16381
17099
|
calculate(settlement, maturity, discount) {
|
|
16382
17100
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, discount);
|
|
@@ -16397,7 +17115,7 @@ const _Tbillprice = class _Tbillprice extends BaseFunction {
|
|
|
16397
17115
|
if (DSM > yearDays)
|
|
16398
17116
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
16399
17117
|
const result = 100 * (1 - discountValue * DSM / 360);
|
|
16400
|
-
return result < 0 ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result,
|
|
17118
|
+
return result < 0 ? ErrorValueObject.create(ErrorType$1.NUM) : NumberValueObject.create(result, getCurrencyFormat(this.getLocale()));
|
|
16401
17119
|
}
|
|
16402
17120
|
};
|
|
16403
17121
|
__name(_Tbillprice, "Tbillprice");
|
|
@@ -16437,6 +17155,7 @@ const _Vdb = class _Vdb extends BaseFunction {
|
|
|
16437
17155
|
super(...arguments);
|
|
16438
17156
|
__publicField(this, "minParams", 5);
|
|
16439
17157
|
__publicField(this, "maxParams", 7);
|
|
17158
|
+
__publicField(this, "needsLocale", !0);
|
|
16440
17159
|
}
|
|
16441
17160
|
calculate(cost, salvage, life, startPeriod, endPeriod, factor, noSwitch) {
|
|
16442
17161
|
let _factor = factor != null ? factor : NumberValueObject.create(2);
|
|
@@ -16483,7 +17202,7 @@ const _Vdb = class _Vdb extends BaseFunction {
|
|
|
16483
17202
|
if (lifeValue === 0 && startPeriodValue === 0 && endPeriodValue === 0)
|
|
16484
17203
|
return ErrorValueObject.create(ErrorType$1.DIV_BY_ZERO);
|
|
16485
17204
|
const result = this._getResult(costValue, salvageValue, lifeValue, startPeriodValue, endPeriodValue, factorValue, noSwitchValue);
|
|
16486
|
-
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result,
|
|
17205
|
+
return rowIndex === 0 && columnIndex === 0 ? NumberValueObject.create(result, getCurrencyFormat(this.getLocale())) : NumberValueObject.create(result);
|
|
16487
17206
|
});
|
|
16488
17207
|
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
16489
17208
|
}
|
|
@@ -17510,8 +18229,6 @@ const _If = class _If extends BaseFunction {
|
|
|
17510
18229
|
calculate(logicalTest, valueIfTrue, valueIfFalse = BooleanValueObject.create(!1)) {
|
|
17511
18230
|
if (logicalTest.isError())
|
|
17512
18231
|
return logicalTest;
|
|
17513
|
-
if (valueIfTrue.isError())
|
|
17514
|
-
return valueIfTrue;
|
|
17515
18232
|
const _logicalTest = this._getSingleValueObject(logicalTest);
|
|
17516
18233
|
if (!_logicalTest.isArray())
|
|
17517
18234
|
return _logicalTest.getValue() ? valueIfTrue : valueIfFalse;
|
|
@@ -18745,13 +19462,13 @@ const _Indirect = class _Indirect extends BaseFunction {
|
|
|
18745
19462
|
const gridRange2 = deserializeRangeForR1C1(refTextV), { range: range2, sheetName: sheetName2, unitId: unitId2 } = gridRange2, rangeReferenceObject2 = new RangeReferenceObject(range2);
|
|
18746
19463
|
return rangeReferenceObject2.setForcedUnitIdDirect(unitId2), rangeReferenceObject2.setForcedSheetName(sheetName2), this._setDefault(rangeReferenceObject2);
|
|
18747
19464
|
}
|
|
18748
|
-
if (
|
|
19465
|
+
if (regexTestSingeRange(refTextV))
|
|
18749
19466
|
return this._setDefault(new CellReferenceObject(refTextV));
|
|
18750
|
-
if (
|
|
19467
|
+
if (regexTestRow(refTextV))
|
|
18751
19468
|
return this._setDefault(new RowReferenceObject(refTextV));
|
|
18752
|
-
if (
|
|
19469
|
+
if (regexTestColumn(refTextV))
|
|
18753
19470
|
return this._setDefault(new ColumnReferenceObject(refTextV));
|
|
18754
|
-
const gridRange =
|
|
19471
|
+
const gridRange = deserializeRangeWithSheetWithCache(refTextV), { range, sheetName, unitId } = gridRange;
|
|
18755
19472
|
if (Number.isNaN(range.startRow) || range.endRow + 1 > 1048576 || Number.isNaN(range.startColumn) || range.endColumn + 1 > 16384)
|
|
18756
19473
|
return ErrorValueObject.create(ErrorType$1.REF);
|
|
18757
19474
|
const rangeReferenceObject = new RangeReferenceObject(range);
|
|
@@ -20127,7 +20844,45 @@ function acoth(num) {
|
|
|
20127
20844
|
return Number.isNaN(result) ? ErrorValueObject.create(ErrorType$1.VALUE) : NumberValueObject.create(result);
|
|
20128
20845
|
}
|
|
20129
20846
|
__name(acoth, "acoth");
|
|
20130
|
-
const
|
|
20847
|
+
const _Arabic = class _Arabic extends BaseFunction {
|
|
20848
|
+
constructor() {
|
|
20849
|
+
super(...arguments);
|
|
20850
|
+
__publicField(this, "minParams", 1);
|
|
20851
|
+
__publicField(this, "maxParams", 1);
|
|
20852
|
+
}
|
|
20853
|
+
calculate(text) {
|
|
20854
|
+
if (text.isArray()) {
|
|
20855
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
20856
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
20857
|
+
}
|
|
20858
|
+
return this._handleSingleObject(text);
|
|
20859
|
+
}
|
|
20860
|
+
// eslint-disable-next-line
|
|
20861
|
+
_handleSingleObject(text) {
|
|
20862
|
+
if (text.isError())
|
|
20863
|
+
return text;
|
|
20864
|
+
if (text.isNull())
|
|
20865
|
+
return NumberValueObject.create(0);
|
|
20866
|
+
if (text.isBoolean() || text.isNumber())
|
|
20867
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
20868
|
+
let textValue = text.getValue().toLocaleString().toLocaleUpperCase();
|
|
20869
|
+
if (textValue.length > 255)
|
|
20870
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
20871
|
+
const isNegtive = textValue.startsWith("-");
|
|
20872
|
+
isNegtive && (textValue = textValue.slice(1));
|
|
20873
|
+
let result = 0;
|
|
20874
|
+
for (let i = 0; i < textValue.length; i++) {
|
|
20875
|
+
const currentCharValue = romanToArabicMap.get(textValue[i]) || 0, nextCharValue = romanToArabicMap.get(textValue[i + 1]) || 0, nextnextCharValue = romanToArabicMap.get(textValue[i + 2]) || 0, nextnextnextCharValue = romanToArabicMap.get(textValue[i + 3]) || 0;
|
|
20876
|
+
if (!currentCharValue || nextnextCharValue >= nextCharValue && nextnextCharValue > currentCharValue || currentCharValue === nextCharValue && currentCharValue === nextnextCharValue && currentCharValue === nextnextnextCharValue || currentCharValue === nextCharValue / 2)
|
|
20877
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
20878
|
+
currentCharValue < nextCharValue ? result -= currentCharValue : result += currentCharValue;
|
|
20879
|
+
}
|
|
20880
|
+
return NumberValueObject.create(isNegtive ? -result : result);
|
|
20881
|
+
}
|
|
20882
|
+
};
|
|
20883
|
+
__name(_Arabic, "Arabic");
|
|
20884
|
+
let Arabic = _Arabic;
|
|
20885
|
+
const _Asin = class _Asin extends BaseFunction {
|
|
20131
20886
|
constructor() {
|
|
20132
20887
|
super(...arguments);
|
|
20133
20888
|
__publicField(this, "minParams", 1);
|
|
@@ -21535,6 +22290,58 @@ const _Randbetween = class _Randbetween extends BaseFunction {
|
|
|
21535
22290
|
};
|
|
21536
22291
|
__name(_Randbetween, "Randbetween");
|
|
21537
22292
|
let Randbetween = _Randbetween;
|
|
22293
|
+
const _Roman = class _Roman extends BaseFunction {
|
|
22294
|
+
constructor() {
|
|
22295
|
+
super(...arguments);
|
|
22296
|
+
__publicField(this, "minParams", 1);
|
|
22297
|
+
__publicField(this, "maxParams", 2);
|
|
22298
|
+
}
|
|
22299
|
+
calculate(number, form) {
|
|
22300
|
+
const _form = form != null ? form : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
22301
|
+
number.isArray() ? number.getRowCount() : 1,
|
|
22302
|
+
_form.isArray() ? _form.getRowCount() : 1
|
|
22303
|
+
), maxColumnLength = Math.max(
|
|
22304
|
+
number.isArray() ? number.getColumnCount() : 1,
|
|
22305
|
+
_form.isArray() ? _form.getColumnCount() : 1
|
|
22306
|
+
), numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType$1.NA)), formArray = expandArrayValueObject(maxRowLength, maxColumnLength, _form, ErrorValueObject.create(ErrorType$1.NA)), resultArray = numberArray.mapValue((numberObject, rowIndex, columnIndex) => {
|
|
22307
|
+
const formObject = formArray.get(rowIndex, columnIndex);
|
|
22308
|
+
return numberObject.isError() ? numberObject : formObject.isError() ? formObject : this._handleSingleObject(numberObject, formObject);
|
|
22309
|
+
});
|
|
22310
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
22311
|
+
}
|
|
22312
|
+
_handleSingleObject(number, form) {
|
|
22313
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number);
|
|
22314
|
+
if (isError)
|
|
22315
|
+
return errorObject;
|
|
22316
|
+
const [numberObject] = variants;
|
|
22317
|
+
let numberValue = Math.floor(+numberObject.getValue()), _form = form;
|
|
22318
|
+
if (_form.isString() && (_form = _form.convertToNumberObjectValue(), _form.isError()))
|
|
22319
|
+
return _form;
|
|
22320
|
+
let formValue = Math.floor(+_form.getValue());
|
|
22321
|
+
if (_form.isBoolean() && (formValue = _form.getValue() ? 0 : 4), numberValue < 0 || numberValue > 3999 || formValue < 0 || formValue > 4)
|
|
22322
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
22323
|
+
const formArray = romanFormArray[formValue];
|
|
22324
|
+
let index = formArray.length - 1, result = "";
|
|
22325
|
+
for (; numberValue > 0; ) {
|
|
22326
|
+
index = this._binarySearch(numberValue, 0, index, formArray);
|
|
22327
|
+
const number2 = formArray[index];
|
|
22328
|
+
numberValue -= number2, result += arabicToRomanMap.get(number2);
|
|
22329
|
+
}
|
|
22330
|
+
return StringValueObject.create(result);
|
|
22331
|
+
}
|
|
22332
|
+
_binarySearch(target, left, right, array) {
|
|
22333
|
+
let _left = left, _right = right;
|
|
22334
|
+
for (; _right - _left > 1; ) {
|
|
22335
|
+
const mid = Math.floor((_left + _right) / 2), midValue = array[mid];
|
|
22336
|
+
if (midValue === target)
|
|
22337
|
+
return mid;
|
|
22338
|
+
midValue > target ? _right = mid : _left = mid;
|
|
22339
|
+
}
|
|
22340
|
+
return _left !== _right && array[_right] <= target ? _right : _left;
|
|
22341
|
+
}
|
|
22342
|
+
};
|
|
22343
|
+
__name(_Roman, "Roman");
|
|
22344
|
+
let Roman = _Roman;
|
|
21538
22345
|
const _Round = class _Round extends BaseFunction {
|
|
21539
22346
|
constructor() {
|
|
21540
22347
|
super(...arguments);
|
|
@@ -22426,6 +23233,7 @@ const functionMath = [
|
|
|
22426
23233
|
[Acosh, FUNCTION_NAMES_MATH.ACOSH],
|
|
22427
23234
|
[Acot, FUNCTION_NAMES_MATH.ACOT],
|
|
22428
23235
|
[Acoth, FUNCTION_NAMES_MATH.ACOTH],
|
|
23236
|
+
[Arabic, FUNCTION_NAMES_MATH.ARABIC],
|
|
22429
23237
|
[Asin, FUNCTION_NAMES_MATH.ASIN],
|
|
22430
23238
|
[Asinh, FUNCTION_NAMES_MATH.ASINH],
|
|
22431
23239
|
[Atan, FUNCTION_NAMES_MATH.ATAN],
|
|
@@ -22474,6 +23282,7 @@ const functionMath = [
|
|
|
22474
23282
|
[Rand, FUNCTION_NAMES_MATH.RAND],
|
|
22475
23283
|
[Randarray, FUNCTION_NAMES_MATH.RANDARRAY],
|
|
22476
23284
|
[Randbetween, FUNCTION_NAMES_MATH.RANDBETWEEN],
|
|
23285
|
+
[Roman, FUNCTION_NAMES_MATH.ROMAN],
|
|
22477
23286
|
[Round, FUNCTION_NAMES_MATH.ROUND],
|
|
22478
23287
|
[Rounddown, FUNCTION_NAMES_MATH.ROUNDDOWN],
|
|
22479
23288
|
[Roundup, FUNCTION_NAMES_MATH.ROUNDUP],
|
|
@@ -23947,7 +24756,214 @@ const functionStatistical = [
|
|
|
23947
24756
|
[VarS, FUNCTION_NAMES_STATISTICAL.VAR_S],
|
|
23948
24757
|
[Vara, FUNCTION_NAMES_STATISTICAL.VARA],
|
|
23949
24758
|
[Varpa, FUNCTION_NAMES_STATISTICAL.VARPA]
|
|
23950
|
-
],
|
|
24759
|
+
], _Arraytotext = class _Arraytotext extends BaseFunction {
|
|
24760
|
+
constructor() {
|
|
24761
|
+
super(...arguments);
|
|
24762
|
+
__publicField(this, "minParams", 1);
|
|
24763
|
+
__publicField(this, "maxParams", 2);
|
|
24764
|
+
}
|
|
24765
|
+
calculate(array, format) {
|
|
24766
|
+
let _format = format != null ? format : NumberValueObject.create(0);
|
|
24767
|
+
if (format != null && format.isNull() && (_format = NumberValueObject.create(0)), _format.isArray()) {
|
|
24768
|
+
const resultArray = _format.mapValue((formatObject) => this._handleSingleObject(array, formatObject));
|
|
24769
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24770
|
+
}
|
|
24771
|
+
return this._handleSingleObject(array, _format);
|
|
24772
|
+
}
|
|
24773
|
+
_handleSingleObject(array, format) {
|
|
24774
|
+
const _array = this._checkArray(array);
|
|
24775
|
+
if (_array.isError())
|
|
24776
|
+
return _array;
|
|
24777
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(format);
|
|
24778
|
+
if (isError)
|
|
24779
|
+
return errorObject;
|
|
24780
|
+
const [formatObject] = variants, formatValue = +formatObject.getValue(), arrayRowCount = array.isArray() ? array.getRowCount() : 1, arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
24781
|
+
let result = "";
|
|
24782
|
+
for (let r = 0; r < arrayRowCount; r++)
|
|
24783
|
+
for (let c = 0; c < arrayColumnCount; c++) {
|
|
24784
|
+
const valueObject = array.isArray() ? array.get(r, c) : array;
|
|
24785
|
+
let value = `${valueObject.getValue()}`;
|
|
24786
|
+
valueObject.isNull() && (value = ""), valueObject.isBoolean() && (value = value.toLocaleUpperCase()), valueObject.isString() && formatValue ? result += `"${value}"` : result += value, r === arrayRowCount - 1 && c === arrayColumnCount - 1 || (formatValue ? c === arrayColumnCount - 1 ? result += ";" : result += "," : result += ", ");
|
|
24787
|
+
}
|
|
24788
|
+
return formatValue && (result = `{${result}}`), result.length > 32767 ? ErrorValueObject.create(ErrorType$1.CALC) : StringValueObject.create(result);
|
|
24789
|
+
}
|
|
24790
|
+
_checkArray(array) {
|
|
24791
|
+
if (array.isArray()) {
|
|
24792
|
+
const arrayRowCount = array.getRowCount(), arrayColumnCount = array.getColumnCount();
|
|
24793
|
+
return arrayRowCount > 1 || arrayColumnCount > 1 ? array : array.get(0, 0);
|
|
24794
|
+
}
|
|
24795
|
+
return array;
|
|
24796
|
+
}
|
|
24797
|
+
};
|
|
24798
|
+
__name(_Arraytotext, "Arraytotext");
|
|
24799
|
+
let Arraytotext = _Arraytotext;
|
|
24800
|
+
const _Asc = class _Asc extends BaseFunction {
|
|
24801
|
+
constructor() {
|
|
24802
|
+
super(...arguments);
|
|
24803
|
+
__publicField(this, "minParams", 1);
|
|
24804
|
+
__publicField(this, "maxParams", 1);
|
|
24805
|
+
}
|
|
24806
|
+
calculate(text) {
|
|
24807
|
+
if (text.isArray()) {
|
|
24808
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
24809
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24810
|
+
}
|
|
24811
|
+
return this._handleSingleObject(text);
|
|
24812
|
+
}
|
|
24813
|
+
_handleSingleObject(text) {
|
|
24814
|
+
if (text.isError() || text.isNull() || text.isBoolean() || text.isNumber())
|
|
24815
|
+
return text;
|
|
24816
|
+
const textValue = text.getValue().toLocaleString();
|
|
24817
|
+
let result = "";
|
|
24818
|
+
for (let i = 0; i < textValue.length; i++) {
|
|
24819
|
+
let charCode = textValue.charCodeAt(i);
|
|
24820
|
+
charCode === 12288 ? charCode = 32 : charCode >= 65281 && charCode <= 65374 && (charCode -= 65248), result += String.fromCharCode(charCode);
|
|
24821
|
+
}
|
|
24822
|
+
return StringValueObject.create(result);
|
|
24823
|
+
}
|
|
24824
|
+
};
|
|
24825
|
+
__name(_Asc, "Asc");
|
|
24826
|
+
let Asc = _Asc;
|
|
24827
|
+
const _Bahttext = class _Bahttext extends BaseFunction {
|
|
24828
|
+
constructor() {
|
|
24829
|
+
super(...arguments);
|
|
24830
|
+
__publicField(this, "minParams", 1);
|
|
24831
|
+
__publicField(this, "maxParams", 1);
|
|
24832
|
+
}
|
|
24833
|
+
calculate(number) {
|
|
24834
|
+
if (number.isArray()) {
|
|
24835
|
+
const resultArray = number.mapValue((numberObject) => this._handleSingleObject(numberObject));
|
|
24836
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24837
|
+
}
|
|
24838
|
+
return this._handleSingleObject(number);
|
|
24839
|
+
}
|
|
24840
|
+
_handleSingleObject(number) {
|
|
24841
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number);
|
|
24842
|
+
if (isError)
|
|
24843
|
+
return errorObject;
|
|
24844
|
+
const [numberObject] = variants, numberValue = +numberObject.getValue(), integerPart = Math.abs(Number.parseInt(numberValue.toString(), 10)), decimalPart = Number.parseFloat((Math.abs(numberValue) - integerPart).toFixed(2));
|
|
24845
|
+
let result = "";
|
|
24846
|
+
return integerPart === 0 ? decimalPart !== 0 ? result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(decimalPart * 100)}สตางค์` : result = "ศูนย์บาทถ้วน" : decimalPart === 0 ? result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาทถ้วน` : result = `${numberValue < 0 ? "ลบ" : ""}${this._convertNumberToThaiText(integerPart)}บาท${this._convertNumberToThaiText(decimalPart * 100)}สตางค์`, StringValueObject.create(result);
|
|
24847
|
+
}
|
|
24848
|
+
_convertNumberToThaiText(number) {
|
|
24849
|
+
const units = ["ล้าน", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", ""], digits = ["ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า"], special = ["ลบ", "บาท", "ถ้วน", "สตางค์", "ยี่", "เอ็ด", ",", " ", "฿"], numberText = number.toString(), n = numberText.length;
|
|
24850
|
+
let result = "";
|
|
24851
|
+
for (let i = n; i > 0; i--) {
|
|
24852
|
+
const digit = Number.parseInt(numberText.charAt(n - i), 10);
|
|
24853
|
+
let digitText = digits[digit];
|
|
24854
|
+
const position = i > 1 ? (i - 1) % 6 : 6;
|
|
24855
|
+
if (position === 1 && digit === 2 && (digitText = special[4]), digit === 1)
|
|
24856
|
+
switch (position) {
|
|
24857
|
+
case 0:
|
|
24858
|
+
case 6:
|
|
24859
|
+
result += i < n ? special[5] : digitText;
|
|
24860
|
+
break;
|
|
24861
|
+
case 1:
|
|
24862
|
+
break;
|
|
24863
|
+
default:
|
|
24864
|
+
result += digitText;
|
|
24865
|
+
break;
|
|
24866
|
+
}
|
|
24867
|
+
else if (digit === 0) {
|
|
24868
|
+
position === 0 && (result += units[position]);
|
|
24869
|
+
continue;
|
|
24870
|
+
} else
|
|
24871
|
+
result += digitText;
|
|
24872
|
+
result += units[position];
|
|
24873
|
+
}
|
|
24874
|
+
return result;
|
|
24875
|
+
}
|
|
24876
|
+
};
|
|
24877
|
+
__name(_Bahttext, "Bahttext");
|
|
24878
|
+
let Bahttext = _Bahttext;
|
|
24879
|
+
const filterCodeArray$1 = Object.values(DataStreamTreeTokenType).filter((value) => [
|
|
24880
|
+
DataStreamTreeTokenType.TABLE_START,
|
|
24881
|
+
DataStreamTreeTokenType.TABLE_ROW_START,
|
|
24882
|
+
DataStreamTreeTokenType.TABLE_CELL_START,
|
|
24883
|
+
DataStreamTreeTokenType.TABLE_CELL_END,
|
|
24884
|
+
DataStreamTreeTokenType.TABLE_ROW_END,
|
|
24885
|
+
DataStreamTreeTokenType.TABLE_END,
|
|
24886
|
+
DataStreamTreeTokenType.CUSTOM_RANGE_START,
|
|
24887
|
+
DataStreamTreeTokenType.CUSTOM_RANGE_END,
|
|
24888
|
+
DataStreamTreeTokenType.CUSTOM_BLOCK
|
|
24889
|
+
].includes(value)), _Char = class _Char extends BaseFunction {
|
|
24890
|
+
constructor() {
|
|
24891
|
+
super(...arguments);
|
|
24892
|
+
__publicField(this, "minParams", 1);
|
|
24893
|
+
__publicField(this, "maxParams", 1);
|
|
24894
|
+
}
|
|
24895
|
+
calculate(number) {
|
|
24896
|
+
if (number.isArray()) {
|
|
24897
|
+
const resultArray = number.mapValue((numberObject) => this._handleSingleObject(numberObject));
|
|
24898
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24899
|
+
}
|
|
24900
|
+
return this._handleSingleObject(number);
|
|
24901
|
+
}
|
|
24902
|
+
_handleSingleObject(number) {
|
|
24903
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number);
|
|
24904
|
+
if (isError)
|
|
24905
|
+
return errorObject;
|
|
24906
|
+
const [numberObject] = variants, numberValue = Math.floor(+numberObject.getValue());
|
|
24907
|
+
if (numberValue <= 0)
|
|
24908
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
24909
|
+
let result = String.fromCharCode(numberValue);
|
|
24910
|
+
return filterCodeArray$1.some((value) => value === result) && (result = ""), StringValueObject.create(result);
|
|
24911
|
+
}
|
|
24912
|
+
};
|
|
24913
|
+
__name(_Char, "Char");
|
|
24914
|
+
let Char = _Char;
|
|
24915
|
+
const _Clean = class _Clean extends BaseFunction {
|
|
24916
|
+
constructor() {
|
|
24917
|
+
super(...arguments);
|
|
24918
|
+
__publicField(this, "minParams", 1);
|
|
24919
|
+
__publicField(this, "maxParams", 1);
|
|
24920
|
+
}
|
|
24921
|
+
calculate(text) {
|
|
24922
|
+
if (text.isArray()) {
|
|
24923
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
24924
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24925
|
+
}
|
|
24926
|
+
return this._handleSingleObject(text);
|
|
24927
|
+
}
|
|
24928
|
+
_handleSingleObject(text) {
|
|
24929
|
+
if (text.isError() || text.isBoolean() || text.isNumber())
|
|
24930
|
+
return text;
|
|
24931
|
+
if (text.isNull())
|
|
24932
|
+
return StringValueObject.create("");
|
|
24933
|
+
const result = `${text.getValue()}`.replace(/[\0-\x1F]/g, "");
|
|
24934
|
+
return StringValueObject.create(result);
|
|
24935
|
+
}
|
|
24936
|
+
};
|
|
24937
|
+
__name(_Clean, "Clean");
|
|
24938
|
+
let Clean = _Clean;
|
|
24939
|
+
const _Code = class _Code extends BaseFunction {
|
|
24940
|
+
constructor() {
|
|
24941
|
+
super(...arguments);
|
|
24942
|
+
__publicField(this, "minParams", 1);
|
|
24943
|
+
__publicField(this, "maxParams", 1);
|
|
24944
|
+
}
|
|
24945
|
+
calculate(text) {
|
|
24946
|
+
if (text.isArray()) {
|
|
24947
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
24948
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
24949
|
+
}
|
|
24950
|
+
return this._handleSingleObject(text);
|
|
24951
|
+
}
|
|
24952
|
+
_handleSingleObject(text) {
|
|
24953
|
+
if (text.isError())
|
|
24954
|
+
return text;
|
|
24955
|
+
if (text.isNull())
|
|
24956
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
24957
|
+
let textValue = text.getValue().toLocaleString();
|
|
24958
|
+
if (text.isBoolean() && (textValue = textValue.toLocaleUpperCase()), textValue === "")
|
|
24959
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
24960
|
+
const result = textValue.charCodeAt(0);
|
|
24961
|
+
return NumberValueObject.create(result);
|
|
24962
|
+
}
|
|
24963
|
+
};
|
|
24964
|
+
__name(_Code, "Code");
|
|
24965
|
+
let Code = _Code;
|
|
24966
|
+
const _Concat = class _Concat extends BaseFunction {
|
|
23951
24967
|
constructor() {
|
|
23952
24968
|
super(...arguments);
|
|
23953
24969
|
__publicField(this, "minParams", 1);
|
|
@@ -24004,17 +25020,189 @@ const _Concatenate = class _Concatenate extends BaseFunction {
|
|
|
24004
25020
|
};
|
|
24005
25021
|
__name(_Concatenate, "Concatenate");
|
|
24006
25022
|
let Concatenate = _Concatenate;
|
|
24007
|
-
|
|
24008
|
-
|
|
24009
|
-
|
|
24010
|
-
|
|
24011
|
-
|
|
24012
|
-
|
|
24013
|
-
|
|
25023
|
+
const _Dbcs = class _Dbcs extends BaseFunction {
|
|
25024
|
+
constructor() {
|
|
25025
|
+
super(...arguments);
|
|
25026
|
+
__publicField(this, "minParams", 1);
|
|
25027
|
+
__publicField(this, "maxParams", 1);
|
|
25028
|
+
}
|
|
25029
|
+
calculate(text) {
|
|
25030
|
+
if (text.isArray()) {
|
|
25031
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
25032
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25033
|
+
}
|
|
25034
|
+
return this._handleSingleObject(text);
|
|
25035
|
+
}
|
|
25036
|
+
_handleSingleObject(text) {
|
|
25037
|
+
if (text.isError())
|
|
25038
|
+
return text;
|
|
25039
|
+
if (text.isNull())
|
|
25040
|
+
return StringValueObject.create("");
|
|
25041
|
+
let textValue = `${text.getValue()}`;
|
|
25042
|
+
text.isBoolean() && (textValue = textValue.toLocaleUpperCase());
|
|
25043
|
+
let result = "";
|
|
25044
|
+
for (let i = 0; i < textValue.length; i++) {
|
|
25045
|
+
const char = textValue.charCodeAt(i);
|
|
25046
|
+
char >= 33 && char <= 126 ? result += String.fromCharCode(char + 65248) : char === 32 ? result += " " : result += textValue.charAt(i);
|
|
25047
|
+
}
|
|
25048
|
+
return StringValueObject.create(result);
|
|
25049
|
+
}
|
|
25050
|
+
};
|
|
25051
|
+
__name(_Dbcs, "Dbcs");
|
|
25052
|
+
let Dbcs = _Dbcs;
|
|
25053
|
+
const _Dollar = class _Dollar extends BaseFunction {
|
|
25054
|
+
constructor() {
|
|
25055
|
+
super(...arguments);
|
|
25056
|
+
__publicField(this, "minParams", 1);
|
|
25057
|
+
__publicField(this, "maxParams", 2);
|
|
25058
|
+
__publicField(this, "needsLocale", !0);
|
|
25059
|
+
}
|
|
25060
|
+
calculate(number, decimals) {
|
|
25061
|
+
let _decimals = decimals != null ? decimals : NumberValueObject.create(2);
|
|
25062
|
+
_decimals.isNull() && (_decimals = NumberValueObject.create(2));
|
|
25063
|
+
const maxRowLength = Math.max(
|
|
25064
|
+
number.isArray() ? number.getRowCount() : 1,
|
|
25065
|
+
_decimals.isArray() ? _decimals.getRowCount() : 1
|
|
25066
|
+
), maxColumnLength = Math.max(
|
|
25067
|
+
number.isArray() ? number.getColumnCount() : 1,
|
|
25068
|
+
_decimals.isArray() ? _decimals.getColumnCount() : 1
|
|
25069
|
+
), numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType$1.NA)), decimalsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _decimals, ErrorValueObject.create(ErrorType$1.NA)), resultArray = numberArray.mapValue((numberObject, rowIndex, columnIndex) => {
|
|
25070
|
+
const decimalsObject = decimalsArray.get(rowIndex, columnIndex);
|
|
25071
|
+
return numberObject.isError() ? numberObject : decimalsObject.isError() ? decimalsObject : this._handleSingleObject(numberObject, decimalsObject);
|
|
25072
|
+
});
|
|
25073
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25074
|
+
}
|
|
25075
|
+
_handleSingleObject(number, decimals) {
|
|
25076
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number, decimals);
|
|
25077
|
+
if (isError)
|
|
25078
|
+
return errorObject;
|
|
25079
|
+
const [numberObject, decimalsObject] = variants;
|
|
25080
|
+
let numberValue = +numberObject.getValue(), decimalsValue = Math.trunc(+decimalsObject.getValue());
|
|
25081
|
+
if (decimalsValue > 127)
|
|
25082
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25083
|
+
decimalsValue < 0 && (`${numberValue}`.length < Math.abs(decimalsValue) ? numberValue = 0 : numberValue = numberValue < 0 ? -round(Math.abs(numberValue), decimalsValue) : round(numberValue, decimalsValue), decimalsValue = 0);
|
|
25084
|
+
const result = applyCurrencyFormat(this.getLocale(), numberValue, decimalsValue);
|
|
25085
|
+
return StringValueObject.create(result);
|
|
24014
25086
|
}
|
|
25087
|
+
};
|
|
25088
|
+
__name(_Dollar, "Dollar");
|
|
25089
|
+
let Dollar = _Dollar;
|
|
25090
|
+
const _Exact = class _Exact extends BaseFunction {
|
|
25091
|
+
constructor() {
|
|
25092
|
+
super(...arguments);
|
|
25093
|
+
__publicField(this, "minParams", 2);
|
|
25094
|
+
__publicField(this, "maxParams", 2);
|
|
25095
|
+
}
|
|
25096
|
+
calculate(text1, text2) {
|
|
25097
|
+
const maxRowLength = Math.max(
|
|
25098
|
+
text1.isArray() ? text1.getRowCount() : 1,
|
|
25099
|
+
text2.isArray() ? text2.getRowCount() : 1
|
|
25100
|
+
), maxColumnLength = Math.max(
|
|
25101
|
+
text1.isArray() ? text1.getColumnCount() : 1,
|
|
25102
|
+
text2.isArray() ? text2.getColumnCount() : 1
|
|
25103
|
+
), text1Array = expandArrayValueObject(maxRowLength, maxColumnLength, text1, NullValueObject.create()), text2Array = expandArrayValueObject(maxRowLength, maxColumnLength, text2, NullValueObject.create()), resultArray = text1Array.mapValue((text1Object, rowIndex, columnIndex) => {
|
|
25104
|
+
const text2Object = text2Array.get(rowIndex, columnIndex);
|
|
25105
|
+
return text1Object.isError() ? text1Object : text2Object.isError() ? text2Object : this._handleSingleObject(text1Object, text2Object);
|
|
25106
|
+
});
|
|
25107
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25108
|
+
}
|
|
25109
|
+
_handleSingleObject(text1, text2) {
|
|
25110
|
+
if (text1.isNull() || text2.isNull()) {
|
|
25111
|
+
const result2 = text1.isNull() && text2.isNull();
|
|
25112
|
+
return BooleanValueObject.create(result2);
|
|
25113
|
+
}
|
|
25114
|
+
let text1Value = `${text1.getValue()}`;
|
|
25115
|
+
text1.isBoolean() && (text1Value = text1Value.toLocaleUpperCase());
|
|
25116
|
+
let text2Value = `${text2.getValue()}`;
|
|
25117
|
+
text2.isBoolean() && (text2Value = text2Value.toLocaleUpperCase());
|
|
25118
|
+
const result = text1Value === text2Value;
|
|
25119
|
+
return BooleanValueObject.create(result);
|
|
25120
|
+
}
|
|
25121
|
+
};
|
|
25122
|
+
__name(_Exact, "Exact");
|
|
25123
|
+
let Exact = _Exact;
|
|
25124
|
+
const getFormatPreview = /* @__PURE__ */ __name((pattern, value) => numfmt.format(pattern, value, { throws: !1 }), "getFormatPreview"), _Fixed = class _Fixed extends BaseFunction {
|
|
25125
|
+
constructor() {
|
|
25126
|
+
super(...arguments);
|
|
25127
|
+
__publicField(this, "minParams", 1);
|
|
25128
|
+
__publicField(this, "maxParams", 3);
|
|
25129
|
+
}
|
|
25130
|
+
calculate(number, decimals, noCommas) {
|
|
25131
|
+
let _decimals = decimals != null ? decimals : NumberValueObject.create(2);
|
|
25132
|
+
_decimals.isNull() && (_decimals = NumberValueObject.create(2));
|
|
25133
|
+
let _noCommas = noCommas != null ? noCommas : BooleanValueObject.create(!1);
|
|
25134
|
+
_noCommas.isNull() && (_noCommas = BooleanValueObject.create(!1));
|
|
25135
|
+
const maxRowLength = Math.max(
|
|
25136
|
+
number.isArray() ? number.getRowCount() : 1,
|
|
25137
|
+
_decimals.isArray() ? _decimals.getRowCount() : 1,
|
|
25138
|
+
_noCommas.isArray() ? _noCommas.getRowCount() : 1
|
|
25139
|
+
), maxColumnLength = Math.max(
|
|
25140
|
+
number.isArray() ? number.getColumnCount() : 1,
|
|
25141
|
+
_decimals.isArray() ? _decimals.getColumnCount() : 1,
|
|
25142
|
+
_noCommas.isArray() ? _noCommas.getColumnCount() : 1
|
|
25143
|
+
), numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create(ErrorType$1.NA)), decimalsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _decimals, ErrorValueObject.create(ErrorType$1.NA)), noCommasArray = expandArrayValueObject(maxRowLength, maxColumnLength, _noCommas, ErrorValueObject.create(ErrorType$1.NA)), resultArray = numberArray.mapValue((numberObject, rowIndex, columnIndex) => {
|
|
25144
|
+
const decimalsObject = decimalsArray.get(rowIndex, columnIndex), noCommasObject = noCommasArray.get(rowIndex, columnIndex);
|
|
25145
|
+
return numberObject.isError() ? numberObject : decimalsObject.isError() ? decimalsObject : noCommasObject.isError() ? noCommasObject : this._handleSingleObject(numberObject, decimalsObject, noCommasObject);
|
|
25146
|
+
});
|
|
25147
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25148
|
+
}
|
|
25149
|
+
_handleSingleObject(number, decimals, noCommas) {
|
|
25150
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number, decimals, noCommas);
|
|
25151
|
+
if (isError)
|
|
25152
|
+
return errorObject;
|
|
25153
|
+
const [numberObject, decimalsObject, noCommasObject] = variants;
|
|
25154
|
+
let numberValue = +numberObject.getValue(), decimalsValue = Math.trunc(+decimalsObject.getValue());
|
|
25155
|
+
const noCommasValue = +noCommasObject.getValue();
|
|
25156
|
+
if (decimalsValue > 127)
|
|
25157
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25158
|
+
decimalsValue < 0 && (`${numberValue}`.length < Math.abs(decimalsValue) ? numberValue = 0 : numberValue = numberValue < 0 ? -round(Math.abs(numberValue), decimalsValue) : round(numberValue, decimalsValue), decimalsValue = 0);
|
|
25159
|
+
let pattern = noCommasValue ? "###0" : "#,##0";
|
|
25160
|
+
decimalsValue > 0 && (pattern += `.${"0".repeat(decimalsValue)}`);
|
|
25161
|
+
const result = getFormatPreview(pattern, numberValue);
|
|
25162
|
+
return StringValueObject.create(result);
|
|
25163
|
+
}
|
|
25164
|
+
};
|
|
25165
|
+
__name(_Fixed, "Fixed");
|
|
25166
|
+
let Fixed = _Fixed;
|
|
25167
|
+
function charLenByte(text) {
|
|
25168
|
+
let byteCount = 0;
|
|
25169
|
+
for (let i = 0; i < text.length; i++)
|
|
25170
|
+
byteCount += getCharLenByteInText(text, i);
|
|
24015
25171
|
return byteCount;
|
|
24016
25172
|
}
|
|
24017
25173
|
__name(charLenByte, "charLenByte");
|
|
25174
|
+
function getCharLenByteInText(text, charIndex, direction = "ltr") {
|
|
25175
|
+
return getCodePoint(text, charIndex, direction) > 255 ? 2 : 1;
|
|
25176
|
+
}
|
|
25177
|
+
__name(getCharLenByteInText, "getCharLenByteInText");
|
|
25178
|
+
function highSurrogate(charCode) {
|
|
25179
|
+
return charCode >= 55296 && charCode <= 56319;
|
|
25180
|
+
}
|
|
25181
|
+
__name(highSurrogate, "highSurrogate");
|
|
25182
|
+
function lowSurrogate(charCode) {
|
|
25183
|
+
return charCode >= 56320 && charCode <= 57343;
|
|
25184
|
+
}
|
|
25185
|
+
__name(lowSurrogate, "lowSurrogate");
|
|
25186
|
+
function surrogatePair(highSurrogate2, lowSurrogate2) {
|
|
25187
|
+
const highBits = (highSurrogate2 & 1023) << 10, lowBits = lowSurrogate2 & 1023;
|
|
25188
|
+
return highBits + lowBits + 65536;
|
|
25189
|
+
}
|
|
25190
|
+
__name(surrogatePair, "surrogatePair");
|
|
25191
|
+
function getCodePoint(str, index, direction = "ltr") {
|
|
25192
|
+
const charCode = str.charCodeAt(index);
|
|
25193
|
+
if (direction === "ltr" && highSurrogate(charCode) && index + 1 < str.length) {
|
|
25194
|
+
const nextCharCode = str.charCodeAt(index + 1);
|
|
25195
|
+
if (lowSurrogate(nextCharCode))
|
|
25196
|
+
return surrogatePair(charCode, nextCharCode);
|
|
25197
|
+
}
|
|
25198
|
+
if (direction === "rtl" && lowSurrogate(charCode) && index - 1 >= 0) {
|
|
25199
|
+
const prevCharCode = str.charCodeAt(index - 1);
|
|
25200
|
+
if (highSurrogate(prevCharCode))
|
|
25201
|
+
return surrogatePair(prevCharCode, charCode);
|
|
25202
|
+
}
|
|
25203
|
+
return charCode;
|
|
25204
|
+
}
|
|
25205
|
+
__name(getCodePoint, "getCodePoint");
|
|
24018
25206
|
const _Leftb = class _Leftb extends BaseFunction {
|
|
24019
25207
|
constructor() {
|
|
24020
25208
|
super(...arguments);
|
|
@@ -24022,38 +25210,33 @@ const _Leftb = class _Leftb extends BaseFunction {
|
|
|
24022
25210
|
__publicField(this, "maxParams", 2);
|
|
24023
25211
|
}
|
|
24024
25212
|
calculate(text, numBytes) {
|
|
24025
|
-
|
|
24026
|
-
return text;
|
|
24027
|
-
if (numBytes != null && numBytes.isError())
|
|
24028
|
-
return numBytes;
|
|
24029
|
-
const _numBytes = numBytes || NumberValueObject.create(1), maxRowLength = Math.max(
|
|
25213
|
+
const _numBytes = numBytes != null ? numBytes : NumberValueObject.create(1), maxRowLength = Math.max(
|
|
24030
25214
|
text.isArray() ? text.getRowCount() : 1,
|
|
24031
|
-
_numBytes
|
|
25215
|
+
_numBytes.isArray() ? _numBytes.getRowCount() : 1
|
|
24032
25216
|
), maxColumnLength = Math.max(
|
|
24033
25217
|
text.isArray() ? text.getColumnCount() : 1,
|
|
24034
|
-
_numBytes
|
|
24035
|
-
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text), numBytesArray = expandArrayValueObject(maxRowLength, maxColumnLength, _numBytes)
|
|
24036
|
-
|
|
24037
|
-
|
|
24038
|
-
|
|
24039
|
-
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
let
|
|
24043
|
-
|
|
24044
|
-
|
|
24045
|
-
|
|
24046
|
-
|
|
24047
|
-
|
|
24048
|
-
|
|
24049
|
-
|
|
24050
|
-
|
|
24051
|
-
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
return [...text].slice(0, sliceIndex).join("");
|
|
25218
|
+
_numBytes.isArray() ? _numBytes.getColumnCount() : 1
|
|
25219
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create()), numBytesArray = expandArrayValueObject(maxRowLength, maxColumnLength, _numBytes, NullValueObject.create()), resultArray = textArray.mapValue((textObject, rowIndex, columnIndex) => {
|
|
25220
|
+
const numBytesObject = numBytesArray.get(rowIndex, columnIndex);
|
|
25221
|
+
return textObject.isError() ? textObject : numBytesObject.isError() ? numBytesObject : this._handleSingleObject(textObject, numBytesObject);
|
|
25222
|
+
});
|
|
25223
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25224
|
+
}
|
|
25225
|
+
_handleSingleObject(text, numBytes) {
|
|
25226
|
+
let textValue = `${text.getValue()}`;
|
|
25227
|
+
text.isBoolean() && (textValue = textValue.toLocaleUpperCase());
|
|
25228
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(numBytes);
|
|
25229
|
+
if (isError)
|
|
25230
|
+
return errorObject;
|
|
25231
|
+
const [numBytesObject] = variants, numBytesValue = Math.floor(+numBytesObject.getValue());
|
|
25232
|
+
if (numBytesValue < 0)
|
|
25233
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25234
|
+
if (text.isNull() || numBytesValue === 0)
|
|
25235
|
+
return StringValueObject.create("");
|
|
25236
|
+
let index = 0, lenByte = 0, result = "";
|
|
25237
|
+
for (; lenByte < numBytesValue && index < textValue.length; )
|
|
25238
|
+
lenByte += getCharLenByteInText(textValue, index), result += textValue.charAt(index), index++;
|
|
25239
|
+
return StringValueObject.create(result);
|
|
24057
25240
|
}
|
|
24058
25241
|
};
|
|
24059
25242
|
__name(_Leftb, "Leftb");
|
|
@@ -24100,7 +25283,7 @@ const _Lenb = class _Lenb extends BaseFunction {
|
|
|
24100
25283
|
if (text.isNull())
|
|
24101
25284
|
return NumberValueObject.create(0);
|
|
24102
25285
|
if (text.isString() || text.isBoolean() || text.isNumber()) {
|
|
24103
|
-
const textValue = text.getValue()
|
|
25286
|
+
const textValue = `${text.getValue()}`, textByteLen = charLenByte(textValue);
|
|
24104
25287
|
return NumberValueObject.create(textByteLen);
|
|
24105
25288
|
}
|
|
24106
25289
|
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
@@ -24703,6 +25886,90 @@ const _Regexreplace = class _Regexreplace extends BaseFunction {
|
|
|
24703
25886
|
};
|
|
24704
25887
|
__name(_Regexreplace, "Regexreplace");
|
|
24705
25888
|
let Regexreplace = _Regexreplace;
|
|
25889
|
+
const _Numbervalue = class _Numbervalue extends BaseFunction {
|
|
25890
|
+
constructor() {
|
|
25891
|
+
super(...arguments);
|
|
25892
|
+
__publicField(this, "minParams", 1);
|
|
25893
|
+
__publicField(this, "maxParams", 3);
|
|
25894
|
+
}
|
|
25895
|
+
calculate(text, decimalSeparator, groupSeparator) {
|
|
25896
|
+
const _decimalSeparator = decimalSeparator != null ? decimalSeparator : StringValueObject.create("."), maxRowLength = Math.max(
|
|
25897
|
+
text.isArray() ? text.getRowCount() : 1,
|
|
25898
|
+
_decimalSeparator.isArray() ? _decimalSeparator.getRowCount() : 1,
|
|
25899
|
+
groupSeparator != null && groupSeparator.isArray() ? groupSeparator.getRowCount() : 1
|
|
25900
|
+
), maxColumnLength = Math.max(
|
|
25901
|
+
text.isArray() ? text.getColumnCount() : 1,
|
|
25902
|
+
_decimalSeparator.isArray() ? _decimalSeparator.getColumnCount() : 1,
|
|
25903
|
+
groupSeparator != null && groupSeparator.isArray() ? groupSeparator.getColumnCount() : 1
|
|
25904
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), decimalSeparatorArray = expandArrayValueObject(maxRowLength, maxColumnLength, _decimalSeparator, ErrorValueObject.create(ErrorType$1.NA)), groupSeparatorArray = groupSeparator ? expandArrayValueObject(maxRowLength, maxColumnLength, groupSeparator, ErrorValueObject.create(ErrorType$1.NA)) : void 0, resultArray = textArray.mapValue((textObject, rowIndex, columnIndex) => {
|
|
25905
|
+
const decimalSeparatorObject = decimalSeparatorArray.get(rowIndex, columnIndex), groupSeparatorObject = groupSeparator ? groupSeparatorArray.get(rowIndex, columnIndex) : void 0;
|
|
25906
|
+
return textObject.isError() ? textObject : decimalSeparatorObject.isError() ? decimalSeparatorObject : groupSeparatorObject != null && groupSeparatorObject.isError() ? groupSeparatorObject : decimalSeparatorObject.isNull() || groupSeparatorObject != null && groupSeparatorObject.isNull() ? ErrorValueObject.create(ErrorType$1.VALUE) : textObject.isNull() ? NumberValueObject.create(0) : this._handleSingleObject(textObject, decimalSeparatorObject, groupSeparatorObject);
|
|
25907
|
+
});
|
|
25908
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25909
|
+
}
|
|
25910
|
+
// eslint-disable-next-line
|
|
25911
|
+
_handleSingleObject(text, decimalSeparator, groupSeparator) {
|
|
25912
|
+
let textValue = `${text.getValue()}`;
|
|
25913
|
+
textValue = textValue.replace(/\s+/g, "");
|
|
25914
|
+
let decimalSeparatorValue = `${decimalSeparator.getValue()}`;
|
|
25915
|
+
decimalSeparator.isBoolean() && (decimalSeparatorValue = decimalSeparatorValue.toLocaleUpperCase()), decimalSeparatorValue = decimalSeparatorValue.charAt(0);
|
|
25916
|
+
let groupSeparatorValue;
|
|
25917
|
+
if (groupSeparator && (groupSeparatorValue = `${groupSeparator.getValue()}`, groupSeparator.isBoolean() && (groupSeparatorValue = groupSeparatorValue.toLocaleUpperCase()), groupSeparatorValue = groupSeparatorValue.charAt(0), decimalSeparatorValue === groupSeparatorValue))
|
|
25918
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25919
|
+
if (textValue.trim() === "")
|
|
25920
|
+
return NumberValueObject.create(0);
|
|
25921
|
+
if (!textValue.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))
|
|
25922
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25923
|
+
const splitText = textValue.split(decimalSeparatorValue);
|
|
25924
|
+
if (splitText.length > 2)
|
|
25925
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25926
|
+
let integerPart = splitText[0].replace(/,/g, "");
|
|
25927
|
+
groupSeparator && (integerPart = integerPart.split(groupSeparatorValue).join(""));
|
|
25928
|
+
let result = 0;
|
|
25929
|
+
if (splitText.length === 1) {
|
|
25930
|
+
decimalSeparatorValue === "," && (integerPart = integerPart.replace(/\./g, ""));
|
|
25931
|
+
let percentageCount = 0;
|
|
25932
|
+
for (; integerPart.endsWith("%"); )
|
|
25933
|
+
integerPart = integerPart.slice(0, -1), percentageCount++;
|
|
25934
|
+
percentageCount > 0 ? result = +integerPart / 100 ** percentageCount : result = +integerPart;
|
|
25935
|
+
} else {
|
|
25936
|
+
if (!isRealNum(integerPart))
|
|
25937
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25938
|
+
let decimalPart = splitText[1], percentageCount = 0;
|
|
25939
|
+
for (; decimalPart.endsWith("%"); )
|
|
25940
|
+
decimalPart = decimalPart.slice(0, -1), percentageCount++;
|
|
25941
|
+
const resultText = `${integerPart}.${decimalPart}`;
|
|
25942
|
+
if (!isRealNum(resultText))
|
|
25943
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
25944
|
+
percentageCount > 0 ? result = +resultText / 100 ** percentageCount : result = +resultText;
|
|
25945
|
+
}
|
|
25946
|
+
return Number.isNaN(result) ? ErrorValueObject.create(ErrorType$1.VALUE) : NumberValueObject.create(result);
|
|
25947
|
+
}
|
|
25948
|
+
};
|
|
25949
|
+
__name(_Numbervalue, "Numbervalue");
|
|
25950
|
+
let Numbervalue = _Numbervalue;
|
|
25951
|
+
const _Proper = class _Proper extends BaseFunction {
|
|
25952
|
+
constructor() {
|
|
25953
|
+
super(...arguments);
|
|
25954
|
+
__publicField(this, "minParams", 1);
|
|
25955
|
+
__publicField(this, "maxParams", 1);
|
|
25956
|
+
}
|
|
25957
|
+
calculate(text) {
|
|
25958
|
+
if (text.isArray()) {
|
|
25959
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
25960
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
25961
|
+
}
|
|
25962
|
+
return this._handleSingleObject(text);
|
|
25963
|
+
}
|
|
25964
|
+
_handleSingleObject(text) {
|
|
25965
|
+
if (text.isError() || text.isNull() || text.isBoolean() || text.isNumber())
|
|
25966
|
+
return text;
|
|
25967
|
+
const result = text.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g, (txt) => txt.toLocaleUpperCase());
|
|
25968
|
+
return StringValueObject.create(result);
|
|
25969
|
+
}
|
|
25970
|
+
};
|
|
25971
|
+
__name(_Proper, "Proper");
|
|
25972
|
+
let Proper = _Proper;
|
|
24706
25973
|
const _Rept = class _Rept extends BaseFunction {
|
|
24707
25974
|
constructor() {
|
|
24708
25975
|
super(...arguments);
|
|
@@ -24738,7 +26005,147 @@ const _Rept = class _Rept extends BaseFunction {
|
|
|
24738
26005
|
};
|
|
24739
26006
|
__name(_Rept, "Rept");
|
|
24740
26007
|
let Rept = _Rept;
|
|
24741
|
-
const
|
|
26008
|
+
const _Right = class _Right extends BaseFunction {
|
|
26009
|
+
constructor() {
|
|
26010
|
+
super(...arguments);
|
|
26011
|
+
__publicField(this, "minParams", 1);
|
|
26012
|
+
__publicField(this, "maxParams", 2);
|
|
26013
|
+
}
|
|
26014
|
+
calculate(text, numChars) {
|
|
26015
|
+
const _numChars = numChars != null ? numChars : NumberValueObject.create(1), maxRowLength = Math.max(
|
|
26016
|
+
text.isArray() ? text.getRowCount() : 1,
|
|
26017
|
+
_numChars.isArray() ? _numChars.getRowCount() : 1
|
|
26018
|
+
), maxColumnLength = Math.max(
|
|
26019
|
+
text.isArray() ? text.getColumnCount() : 1,
|
|
26020
|
+
_numChars.isArray() ? _numChars.getColumnCount() : 1
|
|
26021
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create()), numCharsArray = expandArrayValueObject(maxRowLength, maxColumnLength, _numChars, NullValueObject.create()), resultArray = textArray.mapValue((textObject, rowIndex, columnIndex) => {
|
|
26022
|
+
const numCharsObject = numCharsArray.get(rowIndex, columnIndex);
|
|
26023
|
+
return textObject.isError() ? textObject : numCharsObject.isError() ? numCharsObject : this._handleSingleObject(textObject, numCharsObject);
|
|
26024
|
+
});
|
|
26025
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26026
|
+
}
|
|
26027
|
+
_handleSingleObject(text, numChars) {
|
|
26028
|
+
let textValue = `${text.getValue()}`;
|
|
26029
|
+
text.isBoolean() && (textValue = textValue.toLocaleUpperCase());
|
|
26030
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(numChars);
|
|
26031
|
+
if (isError)
|
|
26032
|
+
return errorObject;
|
|
26033
|
+
const [numCharsObject] = variants, numCharsValue = Math.floor(+numCharsObject.getValue());
|
|
26034
|
+
if (numCharsValue < 0)
|
|
26035
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26036
|
+
if (text.isNull() || numCharsValue === 0)
|
|
26037
|
+
return StringValueObject.create("");
|
|
26038
|
+
if (numCharsValue >= textValue.length)
|
|
26039
|
+
return StringValueObject.create(textValue);
|
|
26040
|
+
const result = textValue.substring(textValue.length - numCharsValue);
|
|
26041
|
+
return StringValueObject.create(result);
|
|
26042
|
+
}
|
|
26043
|
+
};
|
|
26044
|
+
__name(_Right, "Right");
|
|
26045
|
+
let Right = _Right;
|
|
26046
|
+
const _Rightb = class _Rightb extends BaseFunction {
|
|
26047
|
+
constructor() {
|
|
26048
|
+
super(...arguments);
|
|
26049
|
+
__publicField(this, "minParams", 1);
|
|
26050
|
+
__publicField(this, "maxParams", 2);
|
|
26051
|
+
}
|
|
26052
|
+
calculate(text, numBytes) {
|
|
26053
|
+
const _numBytes = numBytes != null ? numBytes : NumberValueObject.create(1), maxRowLength = Math.max(
|
|
26054
|
+
text.isArray() ? text.getRowCount() : 1,
|
|
26055
|
+
_numBytes.isArray() ? _numBytes.getRowCount() : 1
|
|
26056
|
+
), maxColumnLength = Math.max(
|
|
26057
|
+
text.isArray() ? text.getColumnCount() : 1,
|
|
26058
|
+
_numBytes.isArray() ? _numBytes.getColumnCount() : 1
|
|
26059
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create()), numBytesArray = expandArrayValueObject(maxRowLength, maxColumnLength, _numBytes, NullValueObject.create()), resultArray = textArray.mapValue((textObject, rowIndex, columnIndex) => {
|
|
26060
|
+
const numBytesObject = numBytesArray.get(rowIndex, columnIndex);
|
|
26061
|
+
return textObject.isError() ? textObject : numBytesObject.isError() ? numBytesObject : this._handleSingleObject(textObject, numBytesObject);
|
|
26062
|
+
});
|
|
26063
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26064
|
+
}
|
|
26065
|
+
_handleSingleObject(text, numBytes) {
|
|
26066
|
+
let textValue = `${text.getValue()}`;
|
|
26067
|
+
text.isBoolean() && (textValue = textValue.toLocaleUpperCase());
|
|
26068
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(numBytes);
|
|
26069
|
+
if (isError)
|
|
26070
|
+
return errorObject;
|
|
26071
|
+
const [numBytesObject] = variants, numBytesValue = Math.floor(+numBytesObject.getValue());
|
|
26072
|
+
if (numBytesValue < 0)
|
|
26073
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26074
|
+
if (text.isNull() || numBytesValue === 0)
|
|
26075
|
+
return StringValueObject.create("");
|
|
26076
|
+
let index = textValue.length - 1, lenByte = 0, result = "";
|
|
26077
|
+
for (; lenByte < numBytesValue && index >= 0; )
|
|
26078
|
+
lenByte += getCharLenByteInText(textValue, index, "rtl"), result = textValue.charAt(index) + result, index--;
|
|
26079
|
+
return StringValueObject.create(result);
|
|
26080
|
+
}
|
|
26081
|
+
};
|
|
26082
|
+
__name(_Rightb, "Rightb");
|
|
26083
|
+
let Rightb = _Rightb;
|
|
26084
|
+
const _Substitute = class _Substitute extends BaseFunction {
|
|
26085
|
+
constructor() {
|
|
26086
|
+
super(...arguments);
|
|
26087
|
+
__publicField(this, "minParams", 3);
|
|
26088
|
+
__publicField(this, "maxParams", 4);
|
|
26089
|
+
}
|
|
26090
|
+
calculate(text, oldText, newText, instanceNum) {
|
|
26091
|
+
const maxRowLength = Math.max(
|
|
26092
|
+
text.isArray() ? text.getRowCount() : 1,
|
|
26093
|
+
oldText.isArray() ? oldText.getRowCount() : 1,
|
|
26094
|
+
newText.isArray() ? newText.getRowCount() : 1,
|
|
26095
|
+
instanceNum != null && instanceNum.isArray() ? instanceNum.getRowCount() : 1
|
|
26096
|
+
), maxColumnLength = Math.max(
|
|
26097
|
+
text.isArray() ? text.getColumnCount() : 1,
|
|
26098
|
+
oldText.isArray() ? oldText.getColumnCount() : 1,
|
|
26099
|
+
newText.isArray() ? newText.getColumnCount() : 1,
|
|
26100
|
+
instanceNum != null && instanceNum.isArray() ? instanceNum.getColumnCount() : 1
|
|
26101
|
+
), textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create(ErrorType$1.NA)), oldTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, oldText, ErrorValueObject.create(ErrorType$1.NA)), newTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, newText, ErrorValueObject.create(ErrorType$1.NA)), instanceNumArray = instanceNum ? expandArrayValueObject(maxRowLength, maxColumnLength, instanceNum, ErrorValueObject.create(ErrorType$1.NA)) : void 0, resultArray = textArray.mapValue((textObject, rowIndex, columnIndex) => {
|
|
26102
|
+
const oldTextObject = oldTextArray.get(rowIndex, columnIndex), newTextObject = newTextArray.get(rowIndex, columnIndex);
|
|
26103
|
+
let instanceNumObject = instanceNum ? instanceNumArray.get(rowIndex, columnIndex) : void 0;
|
|
26104
|
+
return textObject.isError() ? textObject : oldTextObject.isError() ? oldTextObject : newTextObject.isError() ? newTextObject : instanceNumObject != null && instanceNumObject.isError() ? instanceNumObject : instanceNumObject != null && instanceNumObject.isNull() || instanceNumObject != null && instanceNumObject.isBoolean() ? ErrorValueObject.create(ErrorType$1.VALUE) : (instanceNumObject != null && instanceNumObject.isString() && (instanceNumObject = instanceNumObject.convertToNumberObjectValue()), instanceNumObject != null && instanceNumObject.isError() ? instanceNumObject : this._handleSingleObject(textObject, oldTextObject, newTextObject, instanceNumObject));
|
|
26105
|
+
});
|
|
26106
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26107
|
+
}
|
|
26108
|
+
_handleSingleObject(text, oldText, newText, instanceNum) {
|
|
26109
|
+
const textValue = this._getObjectString(text), oldTextValue = this._getObjectString(oldText), newTextValue = this._getObjectString(newText), instanceNumValue = instanceNum ? Math.floor(+instanceNum.getValue()) : void 0;
|
|
26110
|
+
if (instanceNum && instanceNumValue <= 0)
|
|
26111
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26112
|
+
if (oldTextValue === "")
|
|
26113
|
+
return StringValueObject.create(textValue);
|
|
26114
|
+
let result = "", num = 0;
|
|
26115
|
+
for (let i = 0; i < textValue.length; i++) {
|
|
26116
|
+
const str = textValue.substr(i, oldTextValue.length);
|
|
26117
|
+
if (str === oldTextValue || str.length === oldTextValue.length && str.trim() === oldTextValue.trim()) {
|
|
26118
|
+
if (num++, num === instanceNumValue) {
|
|
26119
|
+
result = textValue.substr(0, i) + newTextValue + textValue.substr(i + oldTextValue.length);
|
|
26120
|
+
break;
|
|
26121
|
+
}
|
|
26122
|
+
instanceNumValue === void 0 && (result += newTextValue), i += oldTextValue.length - 1;
|
|
26123
|
+
} else
|
|
26124
|
+
instanceNumValue === void 0 && (result += textValue[i]);
|
|
26125
|
+
}
|
|
26126
|
+
return instanceNumValue && num < instanceNumValue && (result = textValue), StringValueObject.create(result);
|
|
26127
|
+
}
|
|
26128
|
+
_getObjectString(variant) {
|
|
26129
|
+
let value = `${variant.getValue()}`;
|
|
26130
|
+
return variant.isNull() && (value = ""), variant.isBoolean() && (value = value.toLocaleUpperCase()), value;
|
|
26131
|
+
}
|
|
26132
|
+
};
|
|
26133
|
+
__name(_Substitute, "Substitute");
|
|
26134
|
+
let Substitute = _Substitute;
|
|
26135
|
+
const _T = class _T extends BaseFunction {
|
|
26136
|
+
constructor() {
|
|
26137
|
+
super(...arguments);
|
|
26138
|
+
__publicField(this, "minParams", 1);
|
|
26139
|
+
__publicField(this, "maxParams", 1);
|
|
26140
|
+
}
|
|
26141
|
+
calculate(value) {
|
|
26142
|
+
let _value = value;
|
|
26143
|
+
return value.isArray() && (_value = value.get(0, 0)), _value.isError() ? _value : _value.isNull() || _value.isBoolean() || _value.isNumber() ? StringValueObject.create("") : _value;
|
|
26144
|
+
}
|
|
26145
|
+
};
|
|
26146
|
+
__name(_T, "T");
|
|
26147
|
+
let T = _T;
|
|
26148
|
+
const _Text = class _Text extends BaseFunction {
|
|
24742
26149
|
constructor() {
|
|
24743
26150
|
super(...arguments);
|
|
24744
26151
|
__publicField(this, "minParams", 2);
|
|
@@ -25115,9 +26522,149 @@ const _Textsplit = class _Textsplit extends BaseFunction {
|
|
|
25115
26522
|
};
|
|
25116
26523
|
__name(_Textsplit, "Textsplit");
|
|
25117
26524
|
let Textsplit = _Textsplit;
|
|
26525
|
+
const filterCodeArray = Object.values(DataStreamTreeTokenType).filter((value) => [
|
|
26526
|
+
DataStreamTreeTokenType.TABLE_START,
|
|
26527
|
+
DataStreamTreeTokenType.TABLE_ROW_START,
|
|
26528
|
+
DataStreamTreeTokenType.TABLE_CELL_START,
|
|
26529
|
+
DataStreamTreeTokenType.TABLE_CELL_END,
|
|
26530
|
+
DataStreamTreeTokenType.TABLE_ROW_END,
|
|
26531
|
+
DataStreamTreeTokenType.TABLE_END,
|
|
26532
|
+
DataStreamTreeTokenType.CUSTOM_RANGE_START,
|
|
26533
|
+
DataStreamTreeTokenType.CUSTOM_RANGE_END,
|
|
26534
|
+
DataStreamTreeTokenType.CUSTOM_BLOCK
|
|
26535
|
+
].includes(value)), _Unichar = class _Unichar extends BaseFunction {
|
|
26536
|
+
constructor() {
|
|
26537
|
+
super(...arguments);
|
|
26538
|
+
__publicField(this, "minParams", 1);
|
|
26539
|
+
__publicField(this, "maxParams", 1);
|
|
26540
|
+
}
|
|
26541
|
+
calculate(number) {
|
|
26542
|
+
if (number.isArray()) {
|
|
26543
|
+
const resultArray = number.mapValue((numberObject) => this._handleSingleObject(numberObject));
|
|
26544
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26545
|
+
}
|
|
26546
|
+
return this._handleSingleObject(number);
|
|
26547
|
+
}
|
|
26548
|
+
_handleSingleObject(number) {
|
|
26549
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(number);
|
|
26550
|
+
if (isError)
|
|
26551
|
+
return errorObject;
|
|
26552
|
+
const [numberObject] = variants, numberValue = Math.floor(+numberObject.getValue());
|
|
26553
|
+
if (numberValue < 1 || numberValue > 1114111)
|
|
26554
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26555
|
+
if (numberValue === 1114111 || numberValue === 1114110)
|
|
26556
|
+
return ErrorValueObject.create(ErrorType$1.NA);
|
|
26557
|
+
let result = String.fromCharCode(numberValue);
|
|
26558
|
+
return filterCodeArray.some((value) => value === result) && (result = ""), StringValueObject.create(result);
|
|
26559
|
+
}
|
|
26560
|
+
};
|
|
26561
|
+
__name(_Unichar, "Unichar");
|
|
26562
|
+
let Unichar = _Unichar;
|
|
26563
|
+
const _Unicode = class _Unicode extends BaseFunction {
|
|
26564
|
+
constructor() {
|
|
26565
|
+
super(...arguments);
|
|
26566
|
+
__publicField(this, "minParams", 1);
|
|
26567
|
+
__publicField(this, "maxParams", 1);
|
|
26568
|
+
}
|
|
26569
|
+
calculate(text) {
|
|
26570
|
+
if (text.isArray()) {
|
|
26571
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
26572
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26573
|
+
}
|
|
26574
|
+
return this._handleSingleObject(text);
|
|
26575
|
+
}
|
|
26576
|
+
_handleSingleObject(text) {
|
|
26577
|
+
if (text.isError())
|
|
26578
|
+
return text;
|
|
26579
|
+
if (text.isNull())
|
|
26580
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26581
|
+
let textValue = text.getValue().toLocaleString();
|
|
26582
|
+
text.isBoolean() && (textValue = textValue.toLocaleUpperCase());
|
|
26583
|
+
const result = textValue.charCodeAt(0);
|
|
26584
|
+
return NumberValueObject.create(result);
|
|
26585
|
+
}
|
|
26586
|
+
};
|
|
26587
|
+
__name(_Unicode, "Unicode");
|
|
26588
|
+
let Unicode = _Unicode;
|
|
26589
|
+
const _Value = class _Value extends BaseFunction {
|
|
26590
|
+
constructor() {
|
|
26591
|
+
super(...arguments);
|
|
26592
|
+
__publicField(this, "minParams", 1);
|
|
26593
|
+
__publicField(this, "maxParams", 1);
|
|
26594
|
+
}
|
|
26595
|
+
calculate(text) {
|
|
26596
|
+
if (text.isArray()) {
|
|
26597
|
+
const resultArray = text.mapValue((textObject) => this._handleSingleObject(textObject));
|
|
26598
|
+
return resultArray.getRowCount() === 1 && resultArray.getColumnCount() === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26599
|
+
}
|
|
26600
|
+
return this._handleSingleObject(text);
|
|
26601
|
+
}
|
|
26602
|
+
_handleSingleObject(text) {
|
|
26603
|
+
if (text.isError())
|
|
26604
|
+
return text;
|
|
26605
|
+
if (text.isBoolean())
|
|
26606
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26607
|
+
let _text = text;
|
|
26608
|
+
if (text.isString() && (_text = _text.convertToNumberObjectValue(), _text.isError()))
|
|
26609
|
+
return _text;
|
|
26610
|
+
const textValue = +_text.getValue();
|
|
26611
|
+
return NumberValueObject.create(textValue);
|
|
26612
|
+
}
|
|
26613
|
+
};
|
|
26614
|
+
__name(_Value, "Value");
|
|
26615
|
+
let Value = _Value;
|
|
26616
|
+
const _Valuetotext = class _Valuetotext extends BaseFunction {
|
|
26617
|
+
constructor() {
|
|
26618
|
+
super(...arguments);
|
|
26619
|
+
__publicField(this, "minParams", 1);
|
|
26620
|
+
__publicField(this, "maxParams", 2);
|
|
26621
|
+
}
|
|
26622
|
+
calculate(value, format) {
|
|
26623
|
+
const _format = format != null ? format : NumberValueObject.create(0), maxRowLength = Math.max(
|
|
26624
|
+
value.isArray() ? value.getRowCount() : 1,
|
|
26625
|
+
_format.isArray() ? _format.getRowCount() : 1
|
|
26626
|
+
), maxColumnLength = Math.max(
|
|
26627
|
+
value.isArray() ? value.getColumnCount() : 1,
|
|
26628
|
+
_format.isArray() ? _format.getColumnCount() : 1
|
|
26629
|
+
), valueArray = expandArrayValueObject(maxRowLength, maxColumnLength, value, ErrorValueObject.create(ErrorType$1.NA)), formatArray = expandArrayValueObject(maxRowLength, maxColumnLength, _format, ErrorValueObject.create(ErrorType$1.NA)), resultArray = valueArray.mapValue((valueObject, rowIndex, columnIndex) => {
|
|
26630
|
+
const formatObject = formatArray.get(rowIndex, columnIndex);
|
|
26631
|
+
return valueObject.isError() ? valueObject : formatObject.isError() ? formatObject : this._handleSingleObject(valueObject, formatObject);
|
|
26632
|
+
});
|
|
26633
|
+
return maxRowLength === 1 && maxColumnLength === 1 ? resultArray.get(0, 0) : resultArray;
|
|
26634
|
+
}
|
|
26635
|
+
_handleSingleObject(value, format) {
|
|
26636
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsStringToNumber(format);
|
|
26637
|
+
if (isError)
|
|
26638
|
+
return errorObject;
|
|
26639
|
+
const [formatObject] = variants, formatValue = Math.floor(+formatObject.getValue());
|
|
26640
|
+
if (formatValue < 0 || formatValue > 1)
|
|
26641
|
+
return ErrorValueObject.create(ErrorType$1.VALUE);
|
|
26642
|
+
if (value.isNull())
|
|
26643
|
+
return StringValueObject.create("");
|
|
26644
|
+
if (value.isBoolean())
|
|
26645
|
+
return value;
|
|
26646
|
+
if (value.isNumber())
|
|
26647
|
+
return NumberValueObject.create(value.getValue());
|
|
26648
|
+
const result = formatValue ? `"${value.getValue()}"` : `${value.getValue()}`;
|
|
26649
|
+
return StringValueObject.create(result);
|
|
26650
|
+
}
|
|
26651
|
+
};
|
|
26652
|
+
__name(_Valuetotext, "Valuetotext");
|
|
26653
|
+
let Valuetotext = _Valuetotext;
|
|
25118
26654
|
const functionText = [
|
|
26655
|
+
[Asc, FUNCTION_NAMES_TEXT.ASC],
|
|
26656
|
+
[Arraytotext, FUNCTION_NAMES_TEXT.ARRAYTOTEXT],
|
|
26657
|
+
[Bahttext, FUNCTION_NAMES_TEXT.BAHTTEXT],
|
|
26658
|
+
[Char, FUNCTION_NAMES_TEXT.CHAR],
|
|
26659
|
+
[Clean, FUNCTION_NAMES_TEXT.CLEAN],
|
|
26660
|
+
[Code, FUNCTION_NAMES_TEXT.CODE],
|
|
25119
26661
|
[Concat, FUNCTION_NAMES_TEXT.CONCAT],
|
|
25120
26662
|
[Concatenate, FUNCTION_NAMES_TEXT.CONCATENATE],
|
|
26663
|
+
[Dbcs, FUNCTION_NAMES_TEXT.DBCS],
|
|
26664
|
+
[Dollar, FUNCTION_NAMES_TEXT.DOLLAR],
|
|
26665
|
+
[Exact, FUNCTION_NAMES_TEXT.EXACT],
|
|
26666
|
+
[Fixed, FUNCTION_NAMES_TEXT.FIXED],
|
|
26667
|
+
[Leftb, FUNCTION_NAMES_TEXT.LEFTB],
|
|
25121
26668
|
[Len, FUNCTION_NAMES_TEXT.LEN],
|
|
25122
26669
|
[Lenb, FUNCTION_NAMES_TEXT.LENB],
|
|
25123
26670
|
[Lower, FUNCTION_NAMES_TEXT.LOWER],
|
|
@@ -25125,12 +26672,21 @@ const functionText = [
|
|
|
25125
26672
|
[Regexextract, FUNCTION_NAMES_TEXT.REGEXEXTRACT],
|
|
25126
26673
|
[Regexmatch, FUNCTION_NAMES_TEXT.REGEXMATCH],
|
|
25127
26674
|
[Regexreplace, FUNCTION_NAMES_TEXT.REGEXREPLACE],
|
|
26675
|
+
[Numbervalue, FUNCTION_NAMES_TEXT.NUMBERVALUE],
|
|
26676
|
+
[Proper, FUNCTION_NAMES_TEXT.PROPER],
|
|
25128
26677
|
[Rept, FUNCTION_NAMES_TEXT.REPT],
|
|
26678
|
+
[Right, FUNCTION_NAMES_TEXT.RIGHT],
|
|
26679
|
+
[Rightb, FUNCTION_NAMES_TEXT.RIGHTB],
|
|
26680
|
+
[Substitute, FUNCTION_NAMES_TEXT.SUBSTITUTE],
|
|
26681
|
+
[T, FUNCTION_NAMES_TEXT.T],
|
|
25129
26682
|
[Text, FUNCTION_NAMES_TEXT.TEXT],
|
|
25130
26683
|
[Textafter, FUNCTION_NAMES_TEXT.TEXTAFTER],
|
|
25131
26684
|
[Textbefore, FUNCTION_NAMES_TEXT.TEXTBEFORE],
|
|
25132
26685
|
[Textsplit, FUNCTION_NAMES_TEXT.TEXTSPLIT],
|
|
25133
|
-
[
|
|
26686
|
+
[Unichar, FUNCTION_NAMES_TEXT.UNICHAR],
|
|
26687
|
+
[Unicode, FUNCTION_NAMES_TEXT.UNICODE],
|
|
26688
|
+
[Value, FUNCTION_NAMES_TEXT.VALUE],
|
|
26689
|
+
[Valuetotext, FUNCTION_NAMES_TEXT.VALUETOTEXT]
|
|
25134
26690
|
], functionUniver = [];
|
|
25135
26691
|
var FUNCTION_NAMES_UNIVER = /* @__PURE__ */ ((FUNCTION_NAMES_UNIVER2) => FUNCTION_NAMES_UNIVER2)(FUNCTION_NAMES_UNIVER || {});
|
|
25136
26692
|
const functionWeb = [];
|