@univerjs/engine-formula 1.0.0-alpha.2 → 1.0.0-alpha.4
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/facade.js +9 -5
- package/lib/cjs/index.js +2017 -356
- package/lib/es/facade.js +9 -5
- package/lib/es/index.js +1999 -359
- package/lib/facade.js +9 -5
- package/lib/index.js +1999 -359
- package/lib/types/basics/common.d.ts +16 -1
- package/lib/types/basics/date.d.ts +2 -2
- package/lib/types/basics/regex.d.ts +4 -4
- package/lib/types/commands/mutations/set-super-table.mutation.d.ts +4 -1
- package/lib/types/controllers/formula-calculation-trigger.controller.d.ts +20 -0
- package/lib/types/controllers/super-table-active-dirty.controller.d.ts +22 -0
- package/lib/types/engine/analysis/lexer-node.d.ts +3 -3
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -1
- package/lib/types/engine/analysis/lexer.d.ts +2 -1
- package/lib/types/engine/analysis/parser.d.ts +2 -1
- package/lib/types/engine/ast-node/function-node.d.ts +9 -2
- package/lib/types/engine/ast-node/operator-node.d.ts +1 -0
- package/lib/types/engine/ast-node/prefix-node.d.ts +1 -0
- package/lib/types/engine/ast-node/reference-node.d.ts +14 -4
- package/lib/types/engine/interpreter/interpreter.d.ts +11 -0
- package/lib/types/engine/reference-object/base-reference-object.d.ts +3 -0
- package/lib/types/engine/reference-object/cell-reference-object.d.ts +1 -0
- package/lib/types/engine/reference-object/table-reference-object.d.ts +2 -0
- package/lib/types/engine/utils/generate-ast-node.d.ts +1 -1
- package/lib/types/engine/utils/math-kit.d.ts +5 -0
- package/lib/types/engine/utils/reference.d.ts +3 -5
- package/lib/types/engine/utils/unit-qualifier.d.ts +32 -0
- package/lib/types/engine/value-object/array-value-object.d.ts +5 -0
- package/lib/types/engine/value-object/base-value-object.d.ts +6 -0
- package/lib/types/facade/f-formula.d.ts +9 -5
- package/lib/types/functions/base-function.d.ts +21 -1
- package/lib/types/functions/cube/cubekpimember/index.d.ts +20 -0
- package/lib/types/functions/cube/cubemember/index.d.ts +20 -0
- package/lib/types/functions/cube/cubememberproperty/index.d.ts +20 -0
- package/lib/types/functions/cube/cuberankedmember/index.d.ts +20 -0
- package/lib/types/functions/cube/cubeset/index.d.ts +20 -0
- package/lib/types/functions/cube/cubesetcount/index.d.ts +20 -0
- package/lib/types/functions/cube/cubevalue/index.d.ts +20 -0
- package/lib/types/functions/financial/amordegrc/index.d.ts +20 -0
- package/lib/types/functions/information/info/index.d.ts +20 -0
- package/lib/types/functions/information/isomitted/index.d.ts +20 -0
- package/lib/types/functions/logical/function-map.d.ts +3 -2
- package/lib/types/functions/logical/function-names.d.ts +2 -0
- package/lib/types/functions/logical/groupby/index.d.ts +46 -0
- package/lib/types/functions/logical/if/index.d.ts +5 -0
- package/lib/types/functions/logical/iferror/index.d.ts +4 -1
- package/lib/types/functions/logical/percentof/index.d.ts +27 -0
- package/lib/types/functions/lookup/anchorarray/index.d.ts +23 -0
- package/lib/types/functions/lookup/function-names.d.ts +1 -0
- package/lib/types/functions/lookup/getpivotdata/index.d.ts +20 -0
- package/lib/types/functions/lookup/hlookup/index.d.ts +1 -0
- package/lib/types/functions/lookup/indirect/index.d.ts +2 -0
- package/lib/types/functions/lookup/rtd/index.d.ts +20 -0
- package/lib/types/functions/lookup/vlookup/index.d.ts +2 -0
- package/lib/types/functions/lookup/xlookup/index.d.ts +2 -0
- package/lib/types/functions/math/iso-ceiling/index.d.ts +20 -0
- package/lib/types/functions/math/sum/index.d.ts +1 -0
- package/lib/types/functions/meta/compare/index.d.ts +1 -0
- package/lib/types/functions/not-implemented-function.d.ts +23 -0
- package/lib/types/functions/statistical/average/index.d.ts +1 -0
- package/lib/types/functions/statistical/countifs/index.d.ts +1 -0
- package/lib/types/functions/statistical/forecast-ets/index.d.ts +20 -0
- package/lib/types/functions/statistical/forecast-ets-confint/index.d.ts +20 -0
- package/lib/types/functions/statistical/forecast-ets-seasonality/index.d.ts +20 -0
- package/lib/types/functions/statistical/forecast-ets-stat/index.d.ts +20 -0
- package/lib/types/functions/statistical/linest/index.d.ts +1 -0
- package/lib/types/functions/text/call/index.d.ts +20 -0
- package/lib/types/functions/text/euroconvert/index.d.ts +20 -0
- package/lib/types/functions/text/function-names.d.ts +1 -0
- package/lib/types/functions/text/phonetic/index.d.ts +20 -0
- package/lib/types/functions/text/register-id/index.d.ts +20 -0
- package/lib/types/functions/text/textsplit/index.d.ts +1 -0
- package/lib/types/functions/web/filterxml/index.d.ts +22 -0
- package/lib/types/functions/web/function-map.d.ts +2 -2
- package/lib/types/functions/web/webservice/index.d.ts +20 -0
- package/lib/types/index.d.ts +7 -2
- package/lib/types/models/formula-data.model.d.ts +4 -2
- package/lib/types/services/active-dirty-manager.service.d.ts +2 -1
- package/lib/types/services/calculate-formula.service.d.ts +2 -2
- package/lib/types/services/current-data.service.d.ts +6 -1
- package/lib/types/services/defined-names.service.d.ts +2 -2
- package/lib/types/services/formula-calculation-trigger.service.d.ts +43 -0
- package/lib/types/services/runtime.service.d.ts +6 -0
- package/lib/types/services/unit-reference-resolver.service.d.ts +39 -0
- package/lib/umd/index.js +5 -2
- package/package.json +5 -5
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
|
|
16
|
+
import type { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles, UniverInstanceType } from '@univerjs/core';
|
|
17
17
|
import type { sequenceNodeType } from '../engine/utils/sequence';
|
|
18
18
|
import type { IImageFormulaInfo } from '../engine/value-object/primitive-object';
|
|
19
19
|
export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
|
|
@@ -75,6 +75,15 @@ export interface IUnitSheetNameMap {
|
|
|
75
75
|
[sheetName: string]: string;
|
|
76
76
|
}>;
|
|
77
77
|
}
|
|
78
|
+
export type FormulaUnitType = UniverInstanceType.UNIVER_SHEET | UniverInstanceType.UNIVER_BASE;
|
|
79
|
+
export interface IFormulaUnitNameMapItem {
|
|
80
|
+
name: string;
|
|
81
|
+
unitType: FormulaUnitType;
|
|
82
|
+
}
|
|
83
|
+
/** Runtime Unit metadata keyed by stable unitId. */
|
|
84
|
+
export interface IFormulaUnitNameMap {
|
|
85
|
+
[unitId: string]: IFormulaUnitNameMapItem;
|
|
86
|
+
}
|
|
78
87
|
export interface IUnitSheetIdToNameMap {
|
|
79
88
|
[unitId: string]: Nullable<{
|
|
80
89
|
[sheetId: string]: string;
|
|
@@ -193,6 +202,11 @@ export interface ISuperTable {
|
|
|
193
202
|
sheetId: string;
|
|
194
203
|
titleMap: Map<string, number>;
|
|
195
204
|
range: IRange;
|
|
205
|
+
/**
|
|
206
|
+
* Whether the projected range contains a physical header row.
|
|
207
|
+
* Sheet tables default to true; Base virtual tables store records from row 0.
|
|
208
|
+
*/
|
|
209
|
+
showHeader?: boolean;
|
|
196
210
|
}
|
|
197
211
|
export declare enum TableOptionType {
|
|
198
212
|
ALL = "#All",
|
|
@@ -227,6 +241,7 @@ export interface IFormulaDatasetConfig {
|
|
|
227
241
|
allUnitData?: IUnitData;
|
|
228
242
|
unitStylesData?: IUnitStylesData;
|
|
229
243
|
unitSheetNameMap?: IUnitSheetNameMap;
|
|
244
|
+
unitNameMap?: IFormulaUnitNameMap;
|
|
230
245
|
maxIteration?: number;
|
|
231
246
|
isCalculateTreeModel?: boolean;
|
|
232
247
|
rowData?: IUnitRowData;
|
|
@@ -42,8 +42,8 @@ export declare function formatDateDefault(date: Date): string;
|
|
|
42
42
|
* TODO @Dushusir: Internationalization and more format support, can be reused when editing and saving cells, like "2020年1月1日"
|
|
43
43
|
*/
|
|
44
44
|
export declare function isValidDateStr(dateStr: string): boolean;
|
|
45
|
-
export declare function parseFormattedDate(value: string): numfmt.ParseData | null;
|
|
46
|
-
export declare function parseFormattedTime(value: string): numfmt.ParseData | null;
|
|
45
|
+
export declare function parseFormattedDate(value: string): numfmt.ParseData<number> | null;
|
|
46
|
+
export declare function parseFormattedTime(value: string): numfmt.ParseData<number> | null;
|
|
47
47
|
export declare function isDate(format: string): boolean;
|
|
48
48
|
export declare function isValidWeekend(weekend: number | string): boolean;
|
|
49
49
|
export declare function getWeekendArray(weekend: number | string): number[];
|
|
@@ -32,10 +32,10 @@ export declare const REFERENCE_REGEX_SINGLE_ROW = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\
|
|
|
32
32
|
export declare const REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING: RegExp;
|
|
33
33
|
export declare const REFERENCE_REGEX_SINGLE_COLUMN = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\s*?\\$?[A-Za-z]+$";
|
|
34
34
|
export declare const REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING: RegExp;
|
|
35
|
-
export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+$";
|
|
36
|
-
export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[((?<!#)
|
|
37
|
-
export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[((?<!#)
|
|
38
|
-
export declare const REFERENCE_TABLE_TITLE_ONLY_ANY_HASH_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+\\[\\s*#([^\\]]+)\\s*\\]$";
|
|
35
|
+
export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX = "^(?:(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+$";
|
|
36
|
+
export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = "^(?:(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[((?<!#)[\\s\\S])*\\]|\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#)[\\s\\S])*\\]\\])+$";
|
|
37
|
+
export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = "^(?:(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[((?<!#)[\\s\\S])*\\]\\s*?:\\s*?\\[((?<!#)[\\s\\S])*\\]\\])?$|^(?:(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#)[\\s\\S])*\\]\\s*?:\\s*?\\[((?<!#)[\\s\\S])*\\]\\])?$";
|
|
38
|
+
export declare const REFERENCE_TABLE_TITLE_ONLY_ANY_HASH_REGEX = "^(?:(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+\\[\\s*#([^\\]]+)\\s*\\]$";
|
|
39
39
|
export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX_PRECOMPILING: RegExp;
|
|
40
40
|
export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX_PRECOMPILING: RegExp;
|
|
41
41
|
export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX_PRECOMPILING: RegExp;
|
|
@@ -20,6 +20,9 @@ export interface ISetSuperTableMutationSearchParam {
|
|
|
20
20
|
unitId: string;
|
|
21
21
|
tableName: string;
|
|
22
22
|
}
|
|
23
|
+
export interface IRemoveSuperTableMutationParam extends ISetSuperTableMutationSearchParam {
|
|
24
|
+
reference?: Pick<ISuperTable, 'sheetId' | 'range'>;
|
|
25
|
+
}
|
|
23
26
|
export interface ISetSuperTableMutationParam extends ISetSuperTableMutationSearchParam {
|
|
24
27
|
oldTableName?: string;
|
|
25
28
|
reference: ISuperTable;
|
|
@@ -29,5 +32,5 @@ export interface ISetSuperTableMutationParam extends ISetSuperTableMutationSearc
|
|
|
29
32
|
* It requires setting local to true during execution.
|
|
30
33
|
*/
|
|
31
34
|
export declare const SetSuperTableMutation: IMutation<ISetSuperTableMutationParam>;
|
|
32
|
-
export declare const RemoveSuperTableMutation: IMutation<
|
|
35
|
+
export declare const RemoveSuperTableMutation: IMutation<IRemoveSuperTableMutationParam>;
|
|
33
36
|
export declare const SetSuperTableOptionMutation: IMutation<ISuperTableOptionParam>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Disposable, LifecycleService } from '@univerjs/core';
|
|
17
|
+
import { FormulaCalculationTriggerService } from '../services/formula-calculation-trigger.service';
|
|
18
|
+
export declare class FormulaCalculationTriggerController extends Disposable {
|
|
19
|
+
constructor(formulaCalculationTriggerService: FormulaCalculationTriggerService, lifecycleService: LifecycleService);
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Disposable } from '@univerjs/core';
|
|
17
|
+
import { IActiveDirtyManagerService } from '../services/active-dirty-manager.service';
|
|
18
|
+
export declare class SuperTableActiveDirtyController extends Disposable {
|
|
19
|
+
private readonly _activeDirtyManagerService;
|
|
20
|
+
constructor(_activeDirtyManagerService: IActiveDirtyManagerService);
|
|
21
|
+
private _initialize;
|
|
22
|
+
}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
17
|
import type { LambdaPrivacyVarType } from '../ast-node/base-ast-node';
|
|
18
|
-
interface
|
|
18
|
+
interface ILexerNodeJson {
|
|
19
19
|
token: string;
|
|
20
|
-
children: Array<
|
|
20
|
+
children: Array<ILexerNodeJson | string>;
|
|
21
21
|
}
|
|
22
22
|
export declare class LexerNode {
|
|
23
23
|
private _parent;
|
|
@@ -56,7 +56,7 @@ export declare class LexerNode {
|
|
|
56
56
|
token: string;
|
|
57
57
|
st: number;
|
|
58
58
|
ed: number;
|
|
59
|
-
children: (string |
|
|
59
|
+
children: (string | ILexerNodeJson)[];
|
|
60
60
|
};
|
|
61
61
|
private _getIndexInParent;
|
|
62
62
|
}
|
|
@@ -26,7 +26,8 @@ export declare const FormulaLexerNodeCache: FormulaAstLRU<LexerNode>;
|
|
|
26
26
|
export declare const FormulaSequenceNodeCache: FormulaAstLRU<(string | ISequenceNode)[]>;
|
|
27
27
|
interface IInjectDefinedNameParam {
|
|
28
28
|
unitId: Nullable<string>;
|
|
29
|
-
|
|
29
|
+
sheetId?: Nullable<string>;
|
|
30
|
+
getValueByName(unitId: string, name: string, sheetId?: Nullable<string>): Nullable<IDefinedNamesServiceParam>;
|
|
30
31
|
getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
|
|
31
32
|
getSheetName: (unitId: string, sheetId: string) => string;
|
|
32
33
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
16
17
|
import { Disposable } from '@univerjs/core';
|
|
17
18
|
import { IFormulaCurrentConfigService } from '../../services/current-data.service';
|
|
18
19
|
import { IDefinedNamesService } from '../../services/defined-names.service';
|
|
@@ -22,5 +23,5 @@ export declare class Lexer extends Disposable {
|
|
|
22
23
|
private readonly _lexerTreeBuilder;
|
|
23
24
|
private readonly _formulaCurrentConfigService;
|
|
24
25
|
constructor(_definedNamesService: IDefinedNamesService, _lexerTreeBuilder: LexerTreeBuilder, _formulaCurrentConfigService: IFormulaCurrentConfigService);
|
|
25
|
-
treeBuilder(formulaString: string, transformSuffix?: boolean): import("../..").ErrorType.VALUE | import("./lexer-node").LexerNode | (string | import("./lexer-node").LexerNode)[] | undefined;
|
|
26
|
+
treeBuilder(formulaString: string, transformSuffix?: boolean, unitId?: Nullable<string>): import("../..").ErrorType.VALUE | import("./lexer-node").LexerNode | (string | import("./lexer-node").LexerNode)[] | undefined;
|
|
26
27
|
}
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
-
import type { BaseAstNode } from '../ast-node/base-ast-node';
|
|
18
17
|
import { Disposable } from '@univerjs/core';
|
|
19
18
|
import { IFormulaRuntimeService } from '../../services/runtime.service';
|
|
20
19
|
import { AstRootNodeFactory } from '../ast-node/ast-root-node';
|
|
20
|
+
import { BaseAstNode } from '../ast-node/base-ast-node';
|
|
21
21
|
import { FunctionNodeFactory } from '../ast-node/function-node';
|
|
22
22
|
import { LambdaNodeFactory } from '../ast-node/lambda-node';
|
|
23
23
|
import { LambdaParameterNodeFactory } from '../ast-node/lambda-parameter-node';
|
|
@@ -48,5 +48,6 @@ export declare class AstTreeBuilder extends Disposable {
|
|
|
48
48
|
private _changeLetToLambda;
|
|
49
49
|
private _parse;
|
|
50
50
|
private _checkAstNode;
|
|
51
|
+
private _createGroupByAggregatorTokenNode;
|
|
51
52
|
private _initializeAstNode;
|
|
52
53
|
}
|
|
@@ -22,6 +22,7 @@ import { IFormulaCurrentConfigService } from '../../services/current-data.servic
|
|
|
22
22
|
import { IDefinedNamesService } from '../../services/defined-names.service';
|
|
23
23
|
import { IFunctionService } from '../../services/function.service';
|
|
24
24
|
import { IFormulaRuntimeService } from '../../services/runtime.service';
|
|
25
|
+
import { IFormulaUnitReferenceResolver } from '../../services/unit-reference-resolver.service';
|
|
25
26
|
import { BaseAstNode } from './base-ast-node';
|
|
26
27
|
import { BaseAstNodeFactory } from './base-ast-node-factory';
|
|
27
28
|
import { NodeType } from './node-type';
|
|
@@ -31,15 +32,19 @@ export declare class FunctionNode extends BaseAstNode {
|
|
|
31
32
|
private _runtimeService;
|
|
32
33
|
private _definedNamesService;
|
|
33
34
|
private _formulaDataModel;
|
|
34
|
-
|
|
35
|
+
private _unitReferenceResolver;
|
|
36
|
+
constructor(token: string, _functionExecutor: BaseFunction, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _definedNamesService: IDefinedNamesService, _formulaDataModel: FormulaDataModel, _unitReferenceResolver: IFormulaUnitReferenceResolver);
|
|
35
37
|
get nodeType(): NodeType;
|
|
36
38
|
executeAsync(): Promise<AstNodePromiseType>;
|
|
37
39
|
execute(): void;
|
|
40
|
+
private _collectVariants;
|
|
41
|
+
private _getChildVariant;
|
|
38
42
|
isFunctionExecutorArgumentsIgnoreNumberPattern(): boolean;
|
|
39
43
|
/**
|
|
40
44
|
* If it contains an array formula, set the current cell to the cache and send itself as a ref outward
|
|
41
45
|
*/
|
|
42
46
|
private _setEmbeddedArrayFormulaToResult;
|
|
47
|
+
private _normalizeTopLevelLegacyArrayResult;
|
|
43
48
|
/**
|
|
44
49
|
* Compatibility handling for special functions.
|
|
45
50
|
*/
|
|
@@ -59,6 +64,7 @@ export declare class FunctionNode extends BaseAstNode {
|
|
|
59
64
|
private _handleAddressFunction;
|
|
60
65
|
private _mapVariantsToValues;
|
|
61
66
|
private _calculate;
|
|
67
|
+
private _calculateAst;
|
|
62
68
|
private _calculateAsync;
|
|
63
69
|
private _setDefinedNamesForFunction;
|
|
64
70
|
private _setRefInfo;
|
|
@@ -80,7 +86,8 @@ export declare class FunctionNodeFactory extends BaseAstNodeFactory {
|
|
|
80
86
|
private readonly _definedNamesService;
|
|
81
87
|
private readonly _injector;
|
|
82
88
|
private readonly _formulaDataModel;
|
|
83
|
-
|
|
89
|
+
private readonly _unitReferenceResolver;
|
|
90
|
+
constructor(_functionService: IFunctionService, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _definedNamesService: IDefinedNamesService, _injector: Injector, _formulaDataModel: FormulaDataModel, _unitReferenceResolver: IFormulaUnitReferenceResolver);
|
|
84
91
|
get zIndex(): number;
|
|
85
92
|
create(token: string): BaseAstNode;
|
|
86
93
|
checkAndCreateNodeType(param: LexerNode | string): BaseAstNode | undefined;
|
|
@@ -26,6 +26,7 @@ export declare class OperatorNode extends BaseAstNode {
|
|
|
26
26
|
constructor(operatorString: string, _functionExecutor: BaseFunction, _runtimeService: IFormulaRuntimeService);
|
|
27
27
|
get nodeType(): NodeType;
|
|
28
28
|
execute(): void;
|
|
29
|
+
private _referenceToOperatorValue;
|
|
29
30
|
/**
|
|
30
31
|
* If it contains an array formula, set the current cell to the cache and send itself as a ref outward
|
|
31
32
|
*/
|
|
@@ -29,6 +29,7 @@ export declare class PrefixNode extends BaseAstNode {
|
|
|
29
29
|
get nodeType(): NodeType;
|
|
30
30
|
execute(): void;
|
|
31
31
|
private _handlerAT;
|
|
32
|
+
private _preserveAtRangeForFormula2LookupArray;
|
|
32
33
|
}
|
|
33
34
|
export declare class PrefixNodeFactory extends BaseAstNodeFactory {
|
|
34
35
|
private readonly _functionService;
|
|
@@ -17,23 +17,31 @@ import { IFormulaCurrentConfigService } from '../../services/current-data.servic
|
|
|
17
17
|
import { IFunctionService } from '../../services/function.service';
|
|
18
18
|
import { IFormulaRuntimeService } from '../../services/runtime.service';
|
|
19
19
|
import { ISuperTableService } from '../../services/super-table.service';
|
|
20
|
+
import { IFormulaUnitReferenceResolver } from '../../services/unit-reference-resolver.service';
|
|
20
21
|
import { LexerNode } from '../analysis/lexer-node';
|
|
21
|
-
import { TableReferenceObject } from '../reference-object/table-reference-object';
|
|
22
22
|
import { ReferenceObjectType } from '../utils/value-object';
|
|
23
23
|
import { BaseAstNode } from './base-ast-node';
|
|
24
24
|
import { BaseAstNodeFactory } from './base-ast-node-factory';
|
|
25
25
|
import { NodeType } from './node-type';
|
|
26
|
+
interface ITableReferenceDescriptor {
|
|
27
|
+
unitQualifier: string;
|
|
28
|
+
tableName: string;
|
|
29
|
+
columnStruct: string | undefined;
|
|
30
|
+
}
|
|
26
31
|
export declare class ReferenceNode extends BaseAstNode {
|
|
27
32
|
private _currentConfigService;
|
|
28
33
|
private _runtimeService;
|
|
29
34
|
private _referenceObjectType;
|
|
35
|
+
private _unitReferenceResolver;
|
|
36
|
+
private _superTableService;
|
|
30
37
|
private _isPrepareMerge;
|
|
31
|
-
private
|
|
38
|
+
private _tableReference?;
|
|
32
39
|
private _refOffsetX;
|
|
33
40
|
private _refOffsetY;
|
|
34
|
-
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, operatorString: string, _referenceObjectType: ReferenceObjectType, _isPrepareMerge?: boolean,
|
|
41
|
+
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, operatorString: string, _referenceObjectType: ReferenceObjectType, _unitReferenceResolver: IFormulaUnitReferenceResolver, _superTableService: ISuperTableService, _isPrepareMerge?: boolean, _tableReference?: ITableReferenceDescriptor | undefined);
|
|
35
42
|
get nodeType(): NodeType;
|
|
36
43
|
execute(): void;
|
|
44
|
+
private _configureReferenceObject;
|
|
37
45
|
setRefOffset(x?: number, y?: number): void;
|
|
38
46
|
getRefOffset(): {
|
|
39
47
|
x: number;
|
|
@@ -45,7 +53,8 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
45
53
|
private readonly _formulaRuntimeService;
|
|
46
54
|
private readonly _functionService;
|
|
47
55
|
private readonly _superTableService;
|
|
48
|
-
|
|
56
|
+
private readonly _unitReferenceResolver;
|
|
57
|
+
constructor(_currentConfigService: IFormulaCurrentConfigService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _superTableService: ISuperTableService, _unitReferenceResolver: IFormulaUnitReferenceResolver);
|
|
49
58
|
get zIndex(): number;
|
|
50
59
|
checkAndCreateNodeType(param: LexerNode | string): ReferenceNode | undefined;
|
|
51
60
|
private _getTableMap;
|
|
@@ -54,3 +63,4 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
54
63
|
private _checkTokenIsTableReference;
|
|
55
64
|
private _checkParentIsUnionOperator;
|
|
56
65
|
}
|
|
66
|
+
export {};
|
|
@@ -30,4 +30,15 @@ export declare class Interpreter extends Disposable {
|
|
|
30
30
|
private _checkAsyncNode;
|
|
31
31
|
private _executeAsync;
|
|
32
32
|
private _execute;
|
|
33
|
+
private _executeLazyFunctionAsync;
|
|
34
|
+
private _executeLazyFunction;
|
|
35
|
+
private _executeLazyIfAsync;
|
|
36
|
+
private _executeLazyIf;
|
|
37
|
+
private _executeLazyIfErrorAsync;
|
|
38
|
+
private _executeLazyIfError;
|
|
39
|
+
private _toLazyIfErrorValue;
|
|
40
|
+
private _toLazyIfSelectedValue;
|
|
41
|
+
private _implicitLazyIfReferenceValue;
|
|
42
|
+
private _preserveLazyIfSelectedReferenceArray;
|
|
43
|
+
private _implicitLazyIfArrayValue;
|
|
33
44
|
}
|
|
@@ -34,6 +34,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
34
34
|
private _filteredOutRows;
|
|
35
35
|
private _defaultUnitId;
|
|
36
36
|
private _forcedUnitId;
|
|
37
|
+
private _unitQualifier;
|
|
37
38
|
private _runtimeData;
|
|
38
39
|
private _arrayFormulaCellData;
|
|
39
40
|
private _arrayFormulaRange;
|
|
@@ -63,6 +64,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
63
64
|
getUnitId(): string;
|
|
64
65
|
getSheetId(): string;
|
|
65
66
|
setForcedUnitIdDirect(unitId: string): void;
|
|
67
|
+
setUnitQualifier(unitQualifier: string): void;
|
|
68
|
+
getUnitQualifier(): string;
|
|
66
69
|
getForcedUnitId(): string;
|
|
67
70
|
setForcedSheetId(sheetNameMap: IUnitSheetNameMap): void;
|
|
68
71
|
setForcedSheetIdDirect(sheetId: string): void;
|
|
@@ -20,6 +20,7 @@ import { RangeReferenceObject } from './range-reference-object';
|
|
|
20
20
|
export declare class CellReferenceObject extends BaseReferenceObject {
|
|
21
21
|
constructor(token: string);
|
|
22
22
|
isCell(): boolean;
|
|
23
|
+
isExceedRange(): boolean;
|
|
23
24
|
unionBy(referenceObject: BaseReferenceObject): ErrorValueObject | RangeReferenceObject;
|
|
24
25
|
unionRange(rangeData1: IRange, rangeData2: IRange): IRange;
|
|
25
26
|
private _createRange;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { ICellData, Nullable } from '@univerjs/core';
|
|
16
17
|
import type { ISuperTable, IUnitSheetNameMap } from '../../basics/common';
|
|
17
18
|
import { TableOptionType } from '../../basics/common';
|
|
18
19
|
import { BaseReferenceObject } from './base-reference-object';
|
|
@@ -55,6 +56,7 @@ export declare class TableReferenceObject extends BaseReferenceObject {
|
|
|
55
56
|
/** Section text to enum mapping ('#All', '#Data', '#Headers', '#Totals', '#This Row') */
|
|
56
57
|
_tableOptionMap: Map<string, TableOptionType>);
|
|
57
58
|
getRangeData(): import("@univerjs/core").IRange;
|
|
59
|
+
getCellData(row: number, column: number): Nullable<ICellData>;
|
|
58
60
|
getRefOffset(): {
|
|
59
61
|
x: number;
|
|
60
62
|
y: number;
|
|
@@ -21,5 +21,5 @@ import type { AstRootNode } from '../ast-node/ast-root-node';
|
|
|
21
21
|
import type { IFormulaDependencyTree } from '../dependency/dependency-tree';
|
|
22
22
|
import { FormulaAstLRU } from '../../basics/cache-lru';
|
|
23
23
|
export declare const FORMULA_AST_CACHE: FormulaAstLRU<AstRootNode>;
|
|
24
|
-
export declare function generateAstNode(unitId: string, formulaString: string, lexer: Lexer, astTreeBuilder: AstTreeBuilder, currentConfigService: IFormulaCurrentConfigService): AstRootNode;
|
|
24
|
+
export declare function generateAstNode(unitId: string, formulaString: string, lexer: Lexer, astTreeBuilder: AstTreeBuilder, currentConfigService: IFormulaCurrentConfigService, subUnitId?: string): AstRootNode;
|
|
25
25
|
export declare function includeDefinedName(tree: IFormulaDependencyTree, node: Nullable<AstRootNode>, currentConfigService: IFormulaCurrentConfigService): boolean;
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Since Excel follows the IEEE 754 specification, it only handles precision issues when displaying cells. For example, =0.1+0.2, the stored value in XML is 0.30000000000000004, and the displayed value is 0.3. The accuracy of the calculation process does not need to be considered. We only focus on the accuracy of the calculation results. Any result is processed within 15 digits.
|
|
18
|
+
|
|
19
|
+
Reference https://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft_Excel
|
|
20
|
+
*/
|
|
16
21
|
export declare function plus(a: number, b: number): number;
|
|
17
22
|
export declare function minus(a: number, b: number): number;
|
|
18
23
|
export declare function multiply(a: number, b: number): number;
|
|
@@ -56,6 +56,8 @@ export declare function singleReferenceToGrid(refBody: string): {
|
|
|
56
56
|
export declare function handleRefStringInfo(refString: string): {
|
|
57
57
|
refBody: string;
|
|
58
58
|
sheetName: string;
|
|
59
|
+
unitQualifier: string;
|
|
60
|
+
/** @deprecated Use unitQualifier. Kept for reference-grid compatibility. */
|
|
59
61
|
unitId: string;
|
|
60
62
|
};
|
|
61
63
|
export declare function deserializeRangeWithSheet(refString: string): IUnitRangeName;
|
|
@@ -102,11 +104,7 @@ export declare function quoteSheetName(name: string): string;
|
|
|
102
104
|
*/
|
|
103
105
|
export declare function unquoteSheetName(name: string): string;
|
|
104
106
|
export declare function splitTableStructuredRef(ref: string): {
|
|
105
|
-
|
|
106
|
-
struct: string;
|
|
107
|
-
columnStruct?: undefined;
|
|
108
|
-
} | {
|
|
107
|
+
unitQualifier: string;
|
|
109
108
|
tableName: string;
|
|
110
109
|
columnStruct: string;
|
|
111
|
-
struct?: undefined;
|
|
112
110
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/** Refactors only parsed reference qualifiers and INDIRECT literal references, never arbitrary text. */
|
|
17
|
+
export declare function refactorFormulaUnitQualifier(formula: string, oldName: string, newName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
@@ -41,6 +41,8 @@ export declare class ArrayValueObject extends BaseValueObject {
|
|
|
41
41
|
private _sheetId;
|
|
42
42
|
private _currentRow;
|
|
43
43
|
private _currentColumn;
|
|
44
|
+
private _useInvertedIndexCache;
|
|
45
|
+
private _legacyImplicitForAggregate;
|
|
44
46
|
private _sliceCache;
|
|
45
47
|
private _flattenCache;
|
|
46
48
|
/**
|
|
@@ -62,6 +64,9 @@ export declare class ArrayValueObject extends BaseValueObject {
|
|
|
62
64
|
getSheetId(): string;
|
|
63
65
|
getCurrentRow(): number;
|
|
64
66
|
getCurrentColumn(): number;
|
|
67
|
+
usesInvertedIndexCache(): boolean;
|
|
68
|
+
usesLegacyImplicitForAggregate(): boolean;
|
|
69
|
+
setLegacyImplicitForAggregate(value: boolean): void;
|
|
65
70
|
getArrayValue(): Nullable<BaseValueObject>[][];
|
|
66
71
|
setArrayValue(value: BaseValueObject[][]): void;
|
|
67
72
|
isArray(): boolean;
|
|
@@ -28,6 +28,8 @@ export interface IArrayValueObject {
|
|
|
28
28
|
sheetId: string;
|
|
29
29
|
row: number;
|
|
30
30
|
column: number;
|
|
31
|
+
legacyImplicitForAggregate?: boolean;
|
|
32
|
+
useInvertedIndexCache?: boolean;
|
|
31
33
|
}
|
|
32
34
|
export declare class BaseValueObject extends ObjectClassType {
|
|
33
35
|
private _rawValue;
|
|
@@ -158,6 +160,8 @@ export declare class BaseValueObject extends ObjectClassType {
|
|
|
158
160
|
convertToNumberObjectValue(): BaseValueObject;
|
|
159
161
|
convertToBooleanObjectValue(): BaseValueObject;
|
|
160
162
|
}
|
|
163
|
+
export declare function formatValueForFormulaText(value: string | number | boolean | null): string;
|
|
164
|
+
export declare function formatNumberForFormulaText(value: number): string;
|
|
161
165
|
export declare const ErrorValueObjectCache: FormulaAstLRU<ErrorValueObject>;
|
|
162
166
|
export declare class ErrorValueObject extends BaseValueObject {
|
|
163
167
|
private _errorType;
|
|
@@ -169,4 +173,6 @@ export declare class ErrorValueObject extends BaseValueObject {
|
|
|
169
173
|
getErrorContent(): string;
|
|
170
174
|
isEqualType(object: ObjectClassType): boolean;
|
|
171
175
|
isError(): boolean;
|
|
176
|
+
concatenateFront(_valueObject: BaseValueObject): BaseValueObject;
|
|
177
|
+
concatenateBack(_valueObject: BaseValueObject): BaseValueObject;
|
|
172
178
|
}
|
|
@@ -119,10 +119,13 @@ export declare class FFormula extends FBase {
|
|
|
119
119
|
calculationEnd(callback: (functionsExecutedState: FormulaExecutedStateType) => void): IDisposable;
|
|
120
120
|
/**
|
|
121
121
|
* @deprecated Use `onCalculationResultApplied` instead.
|
|
122
|
+
* @param {number} [timeout] The timeout in milliseconds. Defaults to 30000.
|
|
123
|
+
* @returns {Promise<boolean>} Whether computing completed before timeout.
|
|
122
124
|
*/
|
|
123
125
|
whenComputingCompleteAsync(timeout?: number): Promise<boolean>;
|
|
124
126
|
/**
|
|
125
127
|
* @deprecated Use `onCalculationResultApplied` instead.
|
|
128
|
+
* @returns {Promise<void>} A promise that resolves when calculation ends.
|
|
126
129
|
*/
|
|
127
130
|
onCalculationEnd(): Promise<void>;
|
|
128
131
|
/**
|
|
@@ -249,11 +252,11 @@ export declare class FFormula extends FBase {
|
|
|
249
252
|
* dependency-calculation command for the given unit, sheet, and cell location,
|
|
250
253
|
* and returns the computed dependency tree when the calculation is completed.
|
|
251
254
|
*
|
|
252
|
-
* @param param The target cell location
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
255
|
+
* @param {object} param The target cell location.
|
|
256
|
+
* @param {string} param.unitId The workbook ID.
|
|
257
|
+
* @param {string} param.sheetId The sheet ID.
|
|
258
|
+
* @param {number} param.row The zero-based row index.
|
|
259
|
+
* @param {number} param.column The zero-based column index.
|
|
257
260
|
*
|
|
258
261
|
* @param {number} [timeout]
|
|
259
262
|
* Optional timeout in milliseconds. If no result is received within this
|
|
@@ -462,6 +465,7 @@ export declare class FFormula extends FBase {
|
|
|
462
465
|
* ```
|
|
463
466
|
*
|
|
464
467
|
* @param formulaString The formula string to parse (with or without leading `=`)
|
|
468
|
+
* @param unitId The workbook unit id used to resolve defined names and tables.
|
|
465
469
|
* @returns A formula expression tree describing the hierarchical structure of the formula
|
|
466
470
|
*/
|
|
467
471
|
getFormulaExpressTree(formulaString: string, unitId: string): IExprTreeNode | null;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IRange, LocaleType, Nullable } from '@univerjs/core';
|
|
17
17
|
import type { IFunctionNames } from '../basics/function';
|
|
18
|
+
import type { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
18
19
|
import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
|
|
19
20
|
import type { ArrayBinarySearchType } from '../engine/utils/compare';
|
|
20
21
|
import type { ArrayValueObject } from '../engine/value-object/array-value-object';
|
|
@@ -22,6 +23,7 @@ import type { BaseValueObject } from '../engine/value-object/base-value-object';
|
|
|
22
23
|
import type { FormulaFunctionResultValueType, FormulaFunctionValueType } from '../engine/value-object/primitive-object';
|
|
23
24
|
import type { FormulaDataModel } from '../models/formula-data.model';
|
|
24
25
|
import type { IDefinedNameMapItem } from '../services/defined-names.service';
|
|
26
|
+
import type { IFormulaUnitReferenceResolver } from '../services/unit-reference-resolver.service';
|
|
25
27
|
import { ArrayOrderSearchType } from '../engine/utils/compare';
|
|
26
28
|
import { ErrorValueObject } from '../engine/value-object/base-value-object';
|
|
27
29
|
export declare class BaseFunction {
|
|
@@ -30,11 +32,14 @@ export declare class BaseFunction {
|
|
|
30
32
|
private _subUnitId;
|
|
31
33
|
private _row;
|
|
32
34
|
private _column;
|
|
35
|
+
private _currentFormulaRowCount;
|
|
36
|
+
private _currentFormulaColumnCount;
|
|
33
37
|
private _definedNames;
|
|
34
38
|
private _locale;
|
|
35
39
|
private _sheetOrder;
|
|
36
40
|
private _sheetNameMap;
|
|
37
41
|
protected _formulaDataModel: Nullable<FormulaDataModel>;
|
|
42
|
+
protected _unitReferenceResolver: Nullable<IFormulaUnitReferenceResolver>;
|
|
38
43
|
protected _rowCount: number;
|
|
39
44
|
protected _columnCount: number;
|
|
40
45
|
/**
|
|
@@ -57,6 +62,8 @@ export declare class BaseFunction {
|
|
|
57
62
|
* Whether the function needs function methods in FormulaDataModel
|
|
58
63
|
*/
|
|
59
64
|
needsFormulaDataModel: boolean;
|
|
65
|
+
/** Whether the function resolves external Unit qualifiers. */
|
|
66
|
+
needsUnitReferenceResolver: boolean;
|
|
60
67
|
/**
|
|
61
68
|
* Whether the function needs the number of rows and columns in the sheet
|
|
62
69
|
*/
|
|
@@ -65,6 +72,15 @@ export declare class BaseFunction {
|
|
|
65
72
|
* Whether the function needs to filter out rows
|
|
66
73
|
*/
|
|
67
74
|
needsFilteredOutRows: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the function needs unevaluated AST children.
|
|
77
|
+
*/
|
|
78
|
+
needsAstChildren: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Legacy CSE-style array functions should write only the first result cell
|
|
81
|
+
* when they are used as a top-level normal formula.
|
|
82
|
+
*/
|
|
83
|
+
returnsLegacyArrayAsScalar: boolean;
|
|
68
84
|
/**
|
|
69
85
|
* Minimum number of parameters
|
|
70
86
|
*/
|
|
@@ -79,6 +95,8 @@ export declare class BaseFunction {
|
|
|
79
95
|
get subUnitId(): Nullable<string>;
|
|
80
96
|
get row(): number;
|
|
81
97
|
get column(): number;
|
|
98
|
+
get currentFormulaRowCount(): number;
|
|
99
|
+
get currentFormulaColumnCount(): number;
|
|
82
100
|
dispose(): void;
|
|
83
101
|
/**
|
|
84
102
|
* In Excel, to inject a defined name into a function that has positioning capabilities,
|
|
@@ -103,14 +121,16 @@ export declare class BaseFunction {
|
|
|
103
121
|
};
|
|
104
122
|
}): void;
|
|
105
123
|
setFormulaDataModel(_formulaDataModel: FormulaDataModel): void;
|
|
124
|
+
setUnitReferenceResolver(unitReferenceResolver: IFormulaUnitReferenceResolver): void;
|
|
106
125
|
setSheetRowColumnCount(rowCount: number, columnCount: number): void;
|
|
107
126
|
isAsync(): boolean;
|
|
108
127
|
isAddress(): boolean;
|
|
109
128
|
isCustom(): boolean;
|
|
110
129
|
isArgumentsIgnoreNumberPattern(): boolean;
|
|
111
|
-
setRefInfo(unitId: string, subUnitId: string, row: number, column: number): void;
|
|
130
|
+
setRefInfo(unitId: string, subUnitId: string, row: number, column: number, rowCount?: number, columnCount?: number): void;
|
|
112
131
|
calculateCustom(...arg: Array<FormulaFunctionValueType>): FormulaFunctionResultValueType | Promise<FormulaFunctionResultValueType>;
|
|
113
132
|
calculate(...arg: BaseValueObject[]): NodeValueType;
|
|
133
|
+
calculateAst(_children: BaseAstNode[], _getVariant: (node: BaseAstNode) => Nullable<FunctionVariantType>): NodeValueType;
|
|
114
134
|
checkArrayType(variant: FunctionVariantType): boolean;
|
|
115
135
|
/**
|
|
116
136
|
* Starting with 1
|