@univerjs/engine-formula 0.1.5 → 0.1.7

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.
Files changed (28) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +3790 -3528
  3. package/lib/types/basics/common.d.ts +6 -0
  4. package/lib/types/basics/function.d.ts +5 -1
  5. package/lib/types/commands/mutations/set-array-formula-data.mutation.d.ts +3 -2
  6. package/lib/types/commands/mutations/set-defined-name.mutation.d.ts +6 -2
  7. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +2 -1
  8. package/lib/types/commands/mutations/set-formula-data.mutation.d.ts +3 -0
  9. package/lib/types/engine/analysis/lexer-node.d.ts +4 -0
  10. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +5 -2
  11. package/lib/types/engine/analysis/lexer.d.ts +7 -4
  12. package/lib/types/engine/ast-node/base-ast-node.d.ts +3 -0
  13. package/lib/types/engine/ast-node/reference-node.d.ts +1 -3
  14. package/lib/types/engine/dependency/formula-dependency.d.ts +1 -0
  15. package/lib/types/engine/utils/relative-formula.d.ts +4 -0
  16. package/lib/types/engine/value-object/array-value-object.d.ts +5 -0
  17. package/lib/types/functions/information/isref/index.d.ts +1 -1
  18. package/lib/types/functions/math/subtotal/index.d.ts +1 -1
  19. package/lib/types/functions/statistical/maxifs/__tests__/index.spec.d.ts +16 -0
  20. package/lib/types/functions/statistical/maxifs/index.d.ts +7 -0
  21. package/lib/types/index.d.ts +7 -5
  22. package/lib/types/models/formula-data.model.d.ts +12 -7
  23. package/lib/types/models/utils/formula-data-util.d.ts +10 -0
  24. package/lib/types/services/active-dirty-manager.service.d.ts +2 -1
  25. package/lib/types/services/current-data.service.d.ts +15 -2
  26. package/lib/types/services/defined-names.service.d.ts +50 -8
  27. package/lib/umd/index.js +1 -1
  28. package/package.json +6 -6
@@ -61,6 +61,11 @@ export interface IDirtyUnitSheetNameMap {
61
61
  [sheetId: string]: string;
62
62
  }>;
63
63
  }
64
+ export interface IDirtyUnitSheetDefinedNameMap {
65
+ [unitId: string]: Nullable<{
66
+ [name: string]: string;
67
+ }>;
68
+ }
64
69
  export interface IDirtyUnitFeatureMap {
65
70
  [unitId: string]: Nullable<{
66
71
  [sheetId: string]: {
@@ -137,6 +142,7 @@ export interface IFormulaDatasetConfig {
137
142
  forceCalculate: boolean;
138
143
  dirtyRanges: IUnitRange[];
139
144
  dirtyNameMap: IDirtyUnitSheetNameMap;
145
+ dirtyDefinedNameMap: IDirtyUnitSheetNameMap;
140
146
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
141
147
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
142
148
  numfmtItemMap: INumfmtItemMap;
@@ -83,7 +83,11 @@ export declare enum FunctionType {
83
83
  /**
84
84
  * User-defined functions
85
85
  */
86
- User = 15
86
+ User = 15,
87
+ /**
88
+ * Defined name
89
+ */
90
+ DefinedName = 16
87
91
  }
88
92
  export interface IFunctionParam {
89
93
  /**
@@ -1,10 +1,11 @@
1
1
  import { IArrayFormulaRangeType, IArrayFormulaUnitCellType } from '../../basics/common';
2
- import { IAccessor } from '@wendellhu/redi';
3
2
  import { IMutation } from '@univerjs/core';
4
3
 
5
4
  export interface ISetArrayFormulaDataMutationParams {
6
5
  arrayFormulaRange: IArrayFormulaRangeType;
7
6
  arrayFormulaCellData: IArrayFormulaUnitCellType;
8
7
  }
9
- export declare const SetArrayFormulaDataUndoMutationFactory: (accessor: IAccessor) => ISetArrayFormulaDataMutationParams;
8
+ /**
9
+ * There is no need to process data here, it is used as the main thread to send data to the worker. The main thread has already updated the data in advance, and there is no need to update it again here.
10
+ */
10
11
  export declare const SetArrayFormulaDataMutation: IMutation<ISetArrayFormulaDataMutationParams>;
@@ -2,14 +2,18 @@ import { IMutation } from '@univerjs/core';
2
2
 
3
3
  export interface ISetDefinedNameMutationSearchParam {
4
4
  unitId: string;
5
- name: string;
5
+ id: string;
6
6
  }
7
7
  export interface ISetDefinedNameMutationParam extends ISetDefinedNameMutationSearchParam {
8
+ name: string;
8
9
  formulaOrRefString: string;
10
+ comment?: string;
11
+ localSheetId?: string;
12
+ hidden?: boolean;
9
13
  }
10
14
  /**
11
15
  * In the formula engine, the mutation is solely responsible for communication between the worker and the main thread.
12
16
  * It requires setting local to true during execution.
13
17
  */
14
18
  export declare const SetDefinedNameMutation: IMutation<ISetDefinedNameMutationParam>;
15
- export declare const RemoveDefinedNameMutation: IMutation<ISetDefinedNameMutationSearchParam>;
19
+ export declare const RemoveDefinedNameMutation: IMutation<ISetDefinedNameMutationParam>;
@@ -1,10 +1,11 @@
1
1
  import { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
2
- import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
2
+ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
3
3
  import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
4
4
 
5
5
  export interface ISetFormulaCalculationStartMutation {
6
6
  dirtyRanges: IUnitRange[];
7
7
  dirtyNameMap: IDirtyUnitSheetNameMap;
8
+ dirtyDefinedNameMap: IDirtyUnitSheetDefinedNameMap;
8
9
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
9
10
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
10
11
  options: Nullable<IExecutionOptions>;
@@ -4,4 +4,7 @@ import { IMutation } from '@univerjs/core';
4
4
  export interface ISetFormulaDataMutationParams {
5
5
  formulaData: IFormulaData;
6
6
  }
7
+ /**
8
+ * There is no need to process data here, it is used as the main thread to send data to the worker. The main thread has already updated the data in advance, and there is no need to update it again here.
9
+ */
7
10
  export declare const SetFormulaDataMutation: IMutation<ISetFormulaDataMutationParams>;
@@ -18,7 +18,9 @@ export declare class LexerNode {
18
18
  private _lambdaParameter;
19
19
  private _startIndex;
20
20
  private _endIndex;
21
+ private _definedNames;
21
22
  dispose(): void;
23
+ getDefinedNames(): string[];
22
24
  getStartIndex(): number;
23
25
  getLambdaId(): Nullable<string>;
24
26
  setLambdaId(lambdaId: string): void;
@@ -35,6 +37,8 @@ export declare class LexerNode {
35
37
  getToken(): string;
36
38
  setToken(token: string): void;
37
39
  setIndex(st: number, ed: number): void;
40
+ setDefinedNames(definedNames: Array<string>): void;
41
+ hasDefinedNames(): boolean;
38
42
  replaceChild(lexerNode: LexerNode, newLexerNode: LexerNode): void;
39
43
  changeToParent(newParentLexerNode: LexerNode): void;
40
44
  removeChild(lexerNode: LexerNode): void;
@@ -2,7 +2,7 @@ import { LexerNode } from './lexer-node';
2
2
  import { ISequenceArray, ISequenceNode } from '../utils/sequence';
3
3
  import { ErrorType } from '../../basics/error-type';
4
4
  import { FormulaAstLRU } from '../../basics/cache-lru';
5
- import { Disposable } from '@univerjs/core';
5
+ import { AbsoluteRefType, Disposable } from '@univerjs/core';
6
6
 
7
7
  export declare const FormulaLexerNodeCache: FormulaAstLRU<LexerNode>;
8
8
  export declare const FormulaSequenceNodeCache: FormulaAstLRU<(string | ISequenceNode)[]>;
@@ -40,6 +40,7 @@ export declare class LexerTreeBuilder extends Disposable {
40
40
  * @param formulaString
41
41
  */
42
42
  checkIfAddBracket(formulaString: string): number;
43
+ convertRefersToAbsolute(formulaString: string, startAbsoluteRefType: AbsoluteRefType, endAbsoluteRefType: AbsoluteRefType): string;
43
44
  sequenceNodesBuilder(formulaString: string): (string | ISequenceNode)[] | undefined;
44
45
  getSequenceNode(sequenceArray: ISequenceArray[]): (string | ISequenceNode)[];
45
46
  private _getCurrentParamIndex;
@@ -55,7 +56,8 @@ export declare class LexerTreeBuilder extends Disposable {
55
56
  treeBuilder(formulaString: string, transformSuffix?: boolean, injectDefinedName?: (sequenceArray: ISequenceArray[]) => {
56
57
  sequenceString: string;
57
58
  hasDefinedName: boolean;
58
- }): ErrorType.VALUE | LexerNode | (string | LexerNode)[] | undefined;
59
+ definedNames: string[];
60
+ }, simpleCheckDefinedName?: (formulaString: string) => boolean): ErrorType.VALUE | LexerNode | (string | LexerNode)[] | undefined;
59
61
  private _suffixExpressionHandler;
60
62
  private _checkCloseBracket;
61
63
  private _checkOpenBracket;
@@ -99,4 +101,5 @@ export declare class LexerTreeBuilder extends Disposable {
99
101
  private _resetTemp;
100
102
  private _checkSimilarErrorToken;
101
103
  private _nodeMaker;
104
+ private _addSequenceArray;
102
105
  }
@@ -1,13 +1,16 @@
1
1
  import { LexerTreeBuilder } from './lexer-tree-builder';
2
- import { IFormulaRuntimeService } from '../../services/runtime.service';
2
+ import { ErrorType } from '../../basics/error-type';
3
+ import { IFormulaCurrentConfigService } from '../../services/current-data.service';
3
4
  import { IDefinedNamesService } from '../../services/defined-names.service';
4
5
  import { Disposable } from '@univerjs/core';
5
6
 
6
7
  export declare class Lexer extends Disposable {
7
8
  private readonly _definedNamesService;
8
- private readonly _runtimeService;
9
9
  private readonly _lexerTreeBuilder;
10
- constructor(_definedNamesService: IDefinedNamesService, _runtimeService: IFormulaRuntimeService, _lexerTreeBuilder: LexerTreeBuilder);
11
- treeBuilder(formulaString: string, transformSuffix?: boolean): import("../..").ErrorType.VALUE | import('./lexer-node').LexerNode | (string | import('./lexer-node').LexerNode)[] | undefined;
10
+ private readonly _formulaCurrentConfigService;
11
+ constructor(_definedNamesService: IDefinedNamesService, _lexerTreeBuilder: LexerTreeBuilder, _formulaCurrentConfigService: IFormulaCurrentConfigService);
12
+ treeBuilder(formulaString: string, transformSuffix?: boolean): ErrorType.VALUE | import('./lexer-node').LexerNode | (string | import('./lexer-node').LexerNode)[] | undefined;
13
+ private _simpleCheckDefinedName;
14
+ private _checkDefinedNameDirty;
12
15
  private _injectDefinedName;
13
16
  }
@@ -14,6 +14,7 @@ export type LambdaPrivacyVarType = Map<string, Nullable<BaseAstNode>>;
14
14
  export declare class BaseAstNode extends Disposable {
15
15
  private _token;
16
16
  private _children;
17
+ private _definedNames;
17
18
  private _parent;
18
19
  private _valueObject;
19
20
  private _calculateState;
@@ -46,6 +47,8 @@ export declare class BaseAstNode extends Disposable {
46
47
  };
47
48
  executeAsync(): Promise<AstNodePromiseType>;
48
49
  serialize(): IAstNodeNodeJson;
50
+ hasDefinedName(definedName: string): boolean;
51
+ setDefinedNames(definedNames: Array<string>): void;
49
52
  }
50
53
  export declare class ErrorNode extends BaseAstNode {
51
54
  private _errorValueObject;
@@ -6,7 +6,6 @@ import { BaseReferenceObject } from '../reference-object/base-reference-object';
6
6
  import { LexerNode } from '../analysis/lexer-node';
7
7
  import { ISuperTableService } from '../../services/super-table.service';
8
8
  import { IFormulaRuntimeService } from '../../services/runtime.service';
9
- import { IDefinedNamesService } from '../../services/defined-names.service';
10
9
  import { IAccessor, Injector } from '@wendellhu/redi';
11
10
 
12
11
  export declare class ReferenceNode extends BaseAstNode {
@@ -19,12 +18,11 @@ export declare class ReferenceNode extends BaseAstNode {
19
18
  execute(): void;
20
19
  }
21
20
  export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
22
- private readonly _definedNamesService;
23
21
  private readonly _superTableService;
24
22
  private readonly _formulaRuntimeService;
25
23
  private readonly _functionService;
26
24
  private readonly _injector;
27
- constructor(_definedNamesService: IDefinedNamesService, _superTableService: ISuperTableService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _injector: Injector);
25
+ constructor(_superTableService: ISuperTableService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _injector: Injector);
28
26
  get zIndex(): number;
29
27
  checkAndCreateNodeType(param: LexerNode | string): ReferenceNode | undefined;
30
28
  }
@@ -47,6 +47,7 @@ export declare class FormulaDependencyGenerator extends Disposable {
47
47
  * @param node
48
48
  */
49
49
  private _getRangeListByNode;
50
+ private _isDirtyDefinedForNode;
50
51
  /**
51
52
  * Build a formula dependency tree based on the dependency relationships.
52
53
  * @param treeList
@@ -0,0 +1,4 @@
1
+ import { LexerTreeBuilder } from '../analysis/lexer-tree-builder';
2
+
3
+ export declare function isFormulaTransformable(lexerTreeBuilder: LexerTreeBuilder, formula: string): boolean;
4
+ export declare function transformFormula(lexerTreeBuilder: LexerTreeBuilder, formula: string, originRow: number, originCol: number, targetRow: number, targetCol: number): string;
@@ -18,6 +18,10 @@ export declare class ArrayValueObject extends BaseValueObject {
18
18
  private _currentColumn;
19
19
  private _sliceCache;
20
20
  private _flattenCache;
21
+ /**
22
+ * The default value of the array, null values in comparison results support setting to false
23
+ */
24
+ private _defaultValue;
21
25
  private _flattenPosition;
22
26
  constructor(rawValue: string | IArrayValueObject);
23
27
  dispose(): void;
@@ -36,6 +40,7 @@ export declare class ArrayValueObject extends BaseValueObject {
36
40
  getArrayValue(): Nullable<BaseValueObject>[][];
37
41
  setArrayValue(value: BaseValueObject[][]): void;
38
42
  isArray(): boolean;
43
+ setDefaultValue(value: Nullable<BaseValueObject>): void;
39
44
  get(row: number, column: number): BaseValueObject | null;
40
45
  getRealValue(row: number, column: number): BaseValueObject | null;
41
46
  set(row: number, column: number, value: Nullable<BaseValueObject>): void;
@@ -1,6 +1,6 @@
1
1
  import { BaseFunction } from '../../base-function';
2
+ import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
2
3
  import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
3
- import { BooleanValueObject } from '../../..';
4
4
 
5
5
  export declare class Isref extends BaseFunction {
6
6
  needsReferenceObject: boolean;
@@ -1,4 +1,4 @@
1
- import { ArrayValueObject } from '../../..';
1
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
2
2
  import { BaseFunction } from '../../base-function';
3
3
  import { FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
4
4
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
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
+ export {};
@@ -0,0 +1,7 @@
1
+ import { BaseFunction } from '../../base-function';
2
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
3
+ import { ArrayValueObject } from '../../../engine/value-object/array-value-object';
4
+
5
+ export declare class Maxifs extends BaseFunction {
6
+ calculate(maxRange: BaseValueObject, ...variants: BaseValueObject[]): ErrorValueObject | ArrayValueObject;
7
+ }
@@ -13,17 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, INumfmtItemMap, IDirtyUnitOtherFormulaMap, } from './basics/common';
16
+ export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, INumfmtItemMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, } from './basics/common';
17
17
  export { isInDirtyRange } from './basics/dirty';
18
- export { ErrorType } from './basics/error-type';
18
+ export { ErrorType, ERROR_TYPE_SET } from './basics/error-type';
19
19
  export { FunctionType, type IFunctionInfo, type IFunctionParam } from './basics/function';
20
20
  export { type IFunctionNames } from './basics/function';
21
21
  export { includeFormulaLexerToken, isFormulaLexerToken, normalizeSheetName } from './basics/match-token';
22
22
  export { convertUnitDataToRuntime } from './basics/runtime';
23
23
  export { matchToken, compareToken, operatorToken } from './basics/token';
24
24
  export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
25
- export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation, SetArrayFormulaDataUndoMutationFactory, } from './commands/mutations/set-array-formula-data.mutation';
26
- export { RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
25
+ export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation, } from './commands/mutations/set-array-formula-data.mutation';
26
+ export { RemoveDefinedNameMutation, SetDefinedNameMutation, type ISetDefinedNameMutationSearchParam, type ISetDefinedNameMutationParam } from './commands/mutations/set-defined-name.mutation';
27
27
  export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation, } from './commands/mutations/set-feature-calculation.mutation';
28
28
  export { type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, } from './commands/mutations/set-formula-calculation.mutation';
29
29
  export { type ISetFormulaDataMutationParams, SetFormulaDataMutation, } from './commands/mutations/set-formula-data.mutation';
@@ -90,7 +90,9 @@ export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-fo
90
90
  export type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';
91
91
  export { isReferenceString } from './basics/regex';
92
92
  export { matchRefDrawToken } from './basics/match-token';
93
- export { IDefinedNamesService, DefinedNamesService } from './services/defined-names.service';
93
+ export { IDefinedNamesService, DefinedNamesService, type IDefinedNamesServiceParam, type IDefinedNameMapItem } from './services/defined-names.service';
94
+ export { isFormulaTransformable, transformFormula } from './engine/utils/relative-formula';
94
95
  export { IFormulaRuntimeService, FormulaRuntimeService } from './services/runtime.service';
95
96
  export { IFormulaCurrentConfigService, FormulaCurrentConfigService } from './services/current-data.service';
96
97
  export { IActiveDirtyManagerService } from './services/active-dirty-manager.service';
98
+ export type { IRangeChange } from './models/formula-data.model';
@@ -1,11 +1,11 @@
1
+ import { IFormulaIdMap } from './utils/formula-data-util';
1
2
  import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
2
3
  import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem, INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../basics/common';
3
- import { ICellData, IObjectMatrixPrimitiveType, Nullable, Disposable, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
4
+ import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, Disposable, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
4
5
 
5
- export interface IFormulaIdMap {
6
- f: string;
7
- r: number;
8
- c: number;
6
+ export interface IRangeChange {
7
+ oldCell: IRange;
8
+ newCell: IRange;
9
9
  }
10
10
  export declare class FormulaDataModel extends Disposable {
11
11
  private readonly _currentUniverService;
@@ -28,13 +28,14 @@ export declare class FormulaDataModel extends Disposable {
28
28
  setNumfmtItemMap(value: INumfmtItemMap): void;
29
29
  updateNumfmtItemMap(value: INumfmtItemMap): void;
30
30
  mergeArrayFormulaRange(formulaData: IArrayFormulaRangeType): void;
31
+ mergeFormulaData(formulaData: IFormulaData): void;
31
32
  deleteArrayFormulaRange(unitId: string, sheetId: string, row: number, column: number): void;
32
33
  initFormulaData(): void;
33
34
  getCalculateData(): {
34
35
  allUnitData: IUnitData;
35
36
  unitSheetNameMap: IUnitSheetNameMap;
36
37
  };
37
- updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
38
+ updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): IObjectMatrixPrimitiveType<IFormulaDataItem | null>;
38
39
  updateArrayFormulaRange(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
39
40
  updateArrayFormulaCellData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
40
41
  updateNumfmtData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
@@ -42,4 +43,8 @@ export declare class FormulaDataModel extends Disposable {
42
43
  getFormulaDataItem(row: number, column: number, sheetId: string, unitId: string): IFormulaDataItem | undefined;
43
44
  getFormulaIdMap(unitId: string, sheetId: string): Map<string, IFormulaIdMap>;
44
45
  }
45
- export declare function initSheetFormulaData(formulaData: IFormulaData, unitId: string, sheetId: string, cellMatrix: ObjectMatrix<Nullable<ICellData>>): void;
46
+ export declare function initSheetFormulaData(formulaData: IFormulaData, unitId: string, sheetId: string, cellMatrix: ObjectMatrix<Nullable<ICellData>>): {
47
+ [x: string]: {
48
+ [x: string]: IObjectMatrixPrimitiveType<IFormulaDataItem>;
49
+ };
50
+ };
@@ -0,0 +1,10 @@
1
+ import { IFormulaDataItem } from '../../basics/common';
2
+ import { ICellData, IRange, Nullable, ObjectMatrix } from '@univerjs/core';
3
+
4
+ export interface IFormulaIdMap {
5
+ f: string;
6
+ r: number;
7
+ c: number;
8
+ }
9
+ export declare function updateFormulaDataByCellValue(sheetFormulaDataMatrix: ObjectMatrix<IFormulaDataItem>, newSheetFormulaDataMatrix: ObjectMatrix<IFormulaDataItem | null>, formulaIdMap: Map<string, IFormulaIdMap>, deleteFormulaIdMap: Map<string, string | IFormulaIdMap>, r: number, c: number, cell: Nullable<ICellData>): void;
10
+ export declare function clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix: ObjectMatrix<IRange>, arrayFormulaCellDataMatrix: ObjectMatrix<Nullable<ICellData>>, r: number, c: number): true | undefined;
@@ -1,4 +1,4 @@
1
- import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap } from '@univerjs/engine-formula';
1
+ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap } from '../basics/common';
2
2
  import { ICommandInfo, IUnitRange, Nullable, Disposable } from '@univerjs/core';
3
3
 
4
4
  export interface IDirtyConversionManagerParams {
@@ -6,6 +6,7 @@ export interface IDirtyConversionManagerParams {
6
6
  getDirtyData: (command: ICommandInfo) => {
7
7
  dirtyRanges?: IUnitRange[];
8
8
  dirtyNameMap?: IDirtyUnitSheetNameMap;
9
+ dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
9
10
  dirtyUnitFeatureMap?: IDirtyUnitFeatureMap;
10
11
  dirtyUnitOtherFormulaMap?: IDirtyUnitOtherFormulaMap;
11
12
  };
@@ -1,4 +1,4 @@
1
- import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap } from '../basics/common';
1
+ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap } from '../basics/common';
2
2
  import { IUnitRange, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
3
3
 
4
4
  export declare const DEFAULT_DOCUMENT_SUB_COMPONENT_ID = "__default_document_sub_component_id20231101__";
@@ -10,6 +10,7 @@ export interface IFormulaCurrentConfigService {
10
10
  isForceCalculate(): boolean;
11
11
  getDirtyRanges(): IUnitRange[];
12
12
  getDirtyNameMap(): IDirtyUnitSheetNameMap;
13
+ getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
13
14
  getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
14
15
  registerUnitData(unitData: IUnitData): void;
15
16
  registerFormulaData(formulaData: IFormulaData): void;
@@ -19,6 +20,10 @@ export interface IFormulaCurrentConfigService {
19
20
  getArrayFormulaCellData(): IRuntimeUnitDataType;
20
21
  getSheetName(unitId: string, sheetId: string): string;
21
22
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
23
+ getExecuteUnitId(): Nullable<string>;
24
+ getExecuteSubUnitId(): Nullable<string>;
25
+ setExecuteUnitId(unitId: string): void;
26
+ setExecuteSubUnitId(subUnitId: string): void;
22
27
  }
23
28
  export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
24
29
  private readonly _currentUniverService;
@@ -29,13 +34,20 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
29
34
  private _forceCalculate;
30
35
  private _dirtyRanges;
31
36
  private _dirtyNameMap;
37
+ private _dirtyDefinedNameMap;
32
38
  private _numfmtItemMap;
33
39
  private _dirtyUnitFeatureMap;
34
40
  private _dirtyUnitOtherFormulaMap;
35
41
  private _excludedCell;
36
42
  private _sheetIdToNameMap;
43
+ private _executeUnitId;
44
+ private _executeSubUnitId;
37
45
  constructor(_currentUniverService: IUniverInstanceService);
38
46
  dispose(): void;
47
+ getExecuteUnitId(): Nullable<string>;
48
+ getExecuteSubUnitId(): Nullable<string>;
49
+ setExecuteUnitId(unitId: string): void;
50
+ setExecuteSubUnitId(subUnitId: string): void;
39
51
  getExcludedRange(): Nullable<IUnitExcludedCell>;
40
52
  getUnitData(): IUnitData;
41
53
  getFormulaData(): IFormulaData;
@@ -44,10 +56,11 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
44
56
  isForceCalculate(): boolean;
45
57
  getDirtyRanges(): IUnitRange[];
46
58
  getDirtyNameMap(): IDirtyUnitSheetNameMap;
59
+ getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
47
60
  getNumfmtItemMap(): INumfmtItemMap;
48
61
  getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
49
- getSheetName(unitId: string, sheetId: string): string;
50
62
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
63
+ getSheetName(unitId: string, sheetId: string): string;
51
64
  load(config: IFormulaDatasetConfig): void;
52
65
  loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
53
66
  registerUnitData(unitData: IUnitData): void;
@@ -1,19 +1,61 @@
1
- import { Nullable, Disposable } from '@univerjs/core';
1
+ import { Observable } from 'rxjs';
2
+ import { IUnitRange, Nullable, Disposable } from '@univerjs/core';
2
3
 
4
+ export interface IDefinedNamesServiceParam {
5
+ id: string;
6
+ name: string;
7
+ formulaOrRefString: string;
8
+ comment?: string;
9
+ localSheetId?: string;
10
+ hidden?: boolean;
11
+ }
12
+ export interface IDefinedNamesServiceFocusParam extends IDefinedNamesServiceParam {
13
+ unitId: string;
14
+ }
15
+ export interface IDefinedNameMap {
16
+ [unitId: string]: IDefinedNameMapItem;
17
+ }
18
+ export interface IDefinedNameMapItem {
19
+ [id: string]: IDefinedNamesServiceParam;
20
+ }
3
21
  export interface IDefinedNamesService {
4
- registerDefinedName(unitId: string, name: string, formulaOrRefString: string): void;
5
- getDefinedNameMap(unitId: string): Nullable<Map<string, string>>;
6
- getValue(unitId: string, name: string): Nullable<string>;
22
+ registerDefinedName(unitId: string, param: IDefinedNamesServiceParam): void;
23
+ registerDefinedNames(unitId: string, params: IDefinedNameMapItem): void;
24
+ getDefinedNameMap(unitId: string): Nullable<IDefinedNameMapItem>;
25
+ getValueByName(unitId: string, name: string): Nullable<IDefinedNamesServiceParam>;
26
+ getValueById(unitId: string, id: string): Nullable<IDefinedNamesServiceParam>;
7
27
  removeDefinedName(unitId: string, name: string): void;
8
28
  hasDefinedName(unitId: string): boolean;
29
+ setCurrentRange(range: IUnitRange): void;
30
+ getCurrentRange(): IUnitRange;
31
+ getCurrentRangeForString(): string;
32
+ currentRange$: Observable<IUnitRange>;
33
+ update$: Observable<unknown>;
34
+ focusRange$: Observable<IDefinedNamesServiceFocusParam>;
35
+ focusRange(unitId: string, id: string): void;
9
36
  }
10
37
  export declare class DefinedNamesService extends Disposable implements IDefinedNamesService {
11
38
  private _definedNameMap;
39
+ private readonly _update$;
40
+ readonly update$: Observable<unknown>;
41
+ private _currentRange;
42
+ private readonly _currentRange$;
43
+ readonly currentRange$: Observable<IUnitRange>;
44
+ private readonly _focusRange$;
45
+ readonly focusRange$: Observable<IDefinedNamesServiceFocusParam>;
46
+ constructor();
12
47
  dispose(): void;
13
- registerDefinedName(unitId: string, name: string, formulaOrRefString: string): void;
14
- removeDefinedName(unitId: string, name: string): void;
15
- getDefinedNameMap(unitId: string): Map<string, string> | undefined;
16
- getValue(unitId: string, name: string): string | undefined;
48
+ focusRange(unitId: string, id: string): void;
49
+ setCurrentRange(range: IUnitRange): void;
50
+ getCurrentRange(): IUnitRange;
51
+ getCurrentRangeForString(): string;
52
+ registerDefinedNames(unitId: string, params: IDefinedNameMapItem): void;
53
+ registerDefinedName(unitId: string, param: IDefinedNamesServiceParam): void;
54
+ removeDefinedName(unitId: string, id: string): void;
55
+ getDefinedNameMap(unitId: string): IDefinedNameMapItem;
56
+ getValueByName(unitId: string, name: string): IDefinedNamesServiceParam | null;
57
+ getValueById(unitId: string, id: string): IDefinedNamesServiceParam;
17
58
  hasDefinedName(unitId: string): boolean;
59
+ private _update;
18
60
  }
19
61
  export declare const IDefinedNamesService: import('@wendellhu/redi').IdentifierDecorator<DefinedNamesService>;