@univerjs/sheets-formula 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +4 -9
- package/lib/cjs/index.js +328 -450
- package/lib/cjs/locale/ar-SA.js +1 -2
- package/lib/cjs/locale/ca-ES.js +1 -2
- package/lib/cjs/locale/de-DE.js +1 -2
- package/lib/cjs/locale/en-US.js +1 -2
- package/lib/cjs/locale/es-ES.js +1 -2
- package/lib/cjs/locale/fa-IR.js +1 -2
- package/lib/cjs/locale/fr-FR.js +1 -2
- package/lib/cjs/locale/id-ID.js +1 -2
- package/lib/cjs/locale/it-IT.js +1 -2
- package/lib/cjs/locale/ja-JP.js +1 -2
- package/lib/cjs/locale/ko-KR.js +1 -2
- package/lib/cjs/locale/pl-PL.js +1 -2
- package/lib/cjs/locale/pt-BR.js +1 -2
- package/lib/cjs/locale/ru-RU.js +1 -2
- package/lib/cjs/locale/sk-SK.js +1 -2
- package/lib/cjs/locale/vi-VN.js +1 -2
- package/lib/cjs/locale/zh-CN.js +1 -2
- package/lib/cjs/locale/zh-HK.js +1 -2
- package/lib/cjs/locale/zh-TW.js +1 -2
- package/lib/cjs/worker-Ds9TzMsD.js +248 -0
- package/lib/cjs/worker.js +9 -0
- package/lib/es/facade.js +4 -8
- package/lib/es/index.js +243 -365
- package/lib/es/locale/ar-SA.js +1 -2
- package/lib/es/locale/ca-ES.js +1 -2
- package/lib/es/locale/de-DE.js +1 -2
- package/lib/es/locale/en-US.js +1 -2
- package/lib/es/locale/es-ES.js +1 -2
- package/lib/es/locale/fa-IR.js +1 -2
- package/lib/es/locale/fr-FR.js +1 -2
- package/lib/es/locale/id-ID.js +1 -2
- package/lib/es/locale/it-IT.js +1 -2
- package/lib/es/locale/ja-JP.js +1 -2
- package/lib/es/locale/ko-KR.js +1 -2
- package/lib/es/locale/pl-PL.js +1 -2
- package/lib/es/locale/pt-BR.js +1 -2
- package/lib/es/locale/ru-RU.js +1 -2
- package/lib/es/locale/sk-SK.js +1 -2
- package/lib/es/locale/vi-VN.js +1 -2
- package/lib/es/locale/zh-CN.js +1 -2
- package/lib/es/locale/zh-HK.js +1 -2
- package/lib/es/locale/zh-TW.js +1 -2
- package/lib/es/worker-m5XIUFq5.js +177 -0
- package/lib/es/worker.js +3 -0
- package/lib/facade.js +4 -8
- package/lib/index.js +243 -365
- package/lib/locale/ar-SA.js +1 -2
- package/lib/locale/ca-ES.js +1 -2
- package/lib/locale/de-DE.js +1 -2
- package/lib/locale/en-US.js +1 -2
- package/lib/locale/es-ES.js +1 -2
- package/lib/locale/fa-IR.js +1 -2
- package/lib/locale/fr-FR.js +1 -2
- package/lib/locale/id-ID.js +1 -2
- package/lib/locale/it-IT.js +1 -2
- package/lib/locale/ja-JP.js +1 -2
- package/lib/locale/ko-KR.js +1 -2
- package/lib/locale/pl-PL.js +1 -2
- package/lib/locale/pt-BR.js +1 -2
- package/lib/locale/ru-RU.js +1 -2
- package/lib/locale/sk-SK.js +1 -2
- package/lib/locale/vi-VN.js +1 -2
- package/lib/locale/zh-CN.js +1 -2
- package/lib/locale/zh-HK.js +1 -2
- package/lib/locale/zh-TW.js +1 -2
- package/lib/types/controllers/update-formula.controller.d.ts +4 -0
- package/lib/types/index.d.ts +4 -1
- package/lib/types/plugin.d.ts +1 -12
- package/lib/types/services/remote/remote-register-function.service.d.ts +1 -1
- package/lib/types/worker.d.ts +28 -0
- package/lib/umd/index.js +1 -1
- package/lib/worker-m5XIUFq5.js +177 -0
- package/lib/worker.js +3 -0
- package/package.json +17 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_worker = require("./worker-Ds9TzMsD.js");
|
|
2
3
|
let _univerjs_core = require("@univerjs/core");
|
|
3
4
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
4
5
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
@@ -6,7 +7,7 @@ let _univerjs_docs = require("@univerjs/docs");
|
|
|
6
7
|
let rxjs = require("rxjs");
|
|
7
8
|
let _univerjs_rpc = require("@univerjs/rpc");
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
// src/commands/commands/insert-function.command.ts
|
|
10
11
|
const InsertFunctionCommand = {
|
|
11
12
|
id: "formula.command.insert-function",
|
|
12
13
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -34,60 +35,7 @@ const InsertFunctionCommand = {
|
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
//#region src/config/config.ts
|
|
39
|
-
/**
|
|
40
|
-
* Base configuration for the plugin.
|
|
41
|
-
*/
|
|
42
|
-
const PLUGIN_CONFIG_KEY_BASE = "sheets-formula.base.config";
|
|
43
|
-
const configSymbolBase = Symbol(PLUGIN_CONFIG_KEY_BASE);
|
|
44
|
-
let CalculationMode = /* @__PURE__ */ function(CalculationMode) {
|
|
45
|
-
/**
|
|
46
|
-
* Force calculation of all formulas
|
|
47
|
-
*/
|
|
48
|
-
CalculationMode[CalculationMode["FORCED"] = 0] = "FORCED";
|
|
49
|
-
/**
|
|
50
|
-
* Partial calculation, only cells with formulas but no v values are calculated
|
|
51
|
-
*/
|
|
52
|
-
CalculationMode[CalculationMode["WHEN_EMPTY"] = 1] = "WHEN_EMPTY";
|
|
53
|
-
/**
|
|
54
|
-
* All formulas are not calculated
|
|
55
|
-
*/
|
|
56
|
-
CalculationMode[CalculationMode["NO_CALCULATION"] = 2] = "NO_CALCULATION";
|
|
57
|
-
return CalculationMode;
|
|
58
|
-
}({});
|
|
59
|
-
const defaultPluginBaseConfig = {};
|
|
60
|
-
/**
|
|
61
|
-
* Remote configuration for the plugin.
|
|
62
|
-
*/
|
|
63
|
-
const PLUGIN_CONFIG_KEY_REMOTE = "sheets-formula.remote.config";
|
|
64
|
-
const configSymbolRemote = Symbol(PLUGIN_CONFIG_KEY_REMOTE);
|
|
65
|
-
const defaultPluginRemoteConfig = {};
|
|
66
|
-
/**
|
|
67
|
-
* Mobile configuration for the plugin.
|
|
68
|
-
*/
|
|
69
|
-
const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
|
|
70
|
-
const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
74
|
-
function __decorateParam(paramIndex, decorator) {
|
|
75
|
-
return function(target, key) {
|
|
76
|
-
decorator(target, key, paramIndex);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
82
|
-
function __decorate(decorators, target, key, desc) {
|
|
83
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
84
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
85
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
86
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/controllers/formula-auto-fill.controller.ts
|
|
38
|
+
// src/controllers/formula-auto-fill.controller.ts
|
|
91
39
|
let FormulaAutoFillController = class FormulaAutoFillController extends _univerjs_core.Disposable {
|
|
92
40
|
constructor(_autoFillService, _lexerTreeBuilder) {
|
|
93
41
|
super();
|
|
@@ -157,7 +105,7 @@ let FormulaAutoFillController = class FormulaAutoFillController extends _univerj
|
|
|
157
105
|
return applyData;
|
|
158
106
|
}
|
|
159
107
|
};
|
|
160
|
-
FormulaAutoFillController = __decorate([__decorateParam(0, _univerjs_sheets.IAutoFillService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))], FormulaAutoFillController);
|
|
108
|
+
FormulaAutoFillController = require_worker.__decorate([require_worker.__decorateParam(0, _univerjs_sheets.IAutoFillService), require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))], FormulaAutoFillController);
|
|
161
109
|
function directionToOffset(step, len, direction, location, sourceIndex) {
|
|
162
110
|
const { source, target } = location;
|
|
163
111
|
const { rows: targetRows } = target;
|
|
@@ -189,8 +137,7 @@ function getDataLength(copyDataPiece) {
|
|
|
189
137
|
return length;
|
|
190
138
|
}
|
|
191
139
|
|
|
192
|
-
|
|
193
|
-
//#region src/controllers/formula-reorder.controller.ts
|
|
140
|
+
// src/controllers/formula-reorder.controller.ts
|
|
194
141
|
let FormulaReorderController = class FormulaReorderController extends _univerjs_core.Disposable {
|
|
195
142
|
constructor(_sheetInterceptorService, _univerInstanceService, _formulaDataModel, _lexerTreeBuilder) {
|
|
196
143
|
super();
|
|
@@ -264,68 +211,25 @@ let FormulaReorderController = class FormulaReorderController extends _univerjs_
|
|
|
264
211
|
};
|
|
265
212
|
}
|
|
266
213
|
};
|
|
267
|
-
FormulaReorderController = __decorate([
|
|
268
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
269
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
270
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
271
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
214
|
+
FormulaReorderController = require_worker.__decorate([
|
|
215
|
+
require_worker.__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
216
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
217
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
218
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
272
219
|
], FormulaReorderController);
|
|
273
220
|
|
|
274
|
-
|
|
275
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
276
|
-
function _typeof(o) {
|
|
277
|
-
"@babel/helpers - typeof";
|
|
278
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
279
|
-
return typeof o;
|
|
280
|
-
} : function(o) {
|
|
281
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
282
|
-
}, _typeof(o);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
287
|
-
function toPrimitive(t, r) {
|
|
288
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
289
|
-
var e = t[Symbol.toPrimitive];
|
|
290
|
-
if (void 0 !== e) {
|
|
291
|
-
var i = e.call(t, r || "default");
|
|
292
|
-
if ("object" != _typeof(i)) return i;
|
|
293
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
294
|
-
}
|
|
295
|
-
return ("string" === r ? String : Number)(t);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
300
|
-
function toPropertyKey(t) {
|
|
301
|
-
var i = toPrimitive(t, "string");
|
|
302
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
//#endregion
|
|
306
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
307
|
-
function _defineProperty(e, r, t) {
|
|
308
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
309
|
-
value: t,
|
|
310
|
-
enumerable: !0,
|
|
311
|
-
configurable: !0,
|
|
312
|
-
writable: !0
|
|
313
|
-
}) : e[r] = t, e;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/controllers/image-formula-cell-interceptor.controller.ts
|
|
221
|
+
// src/controllers/image-formula-cell-interceptor.controller.ts
|
|
318
222
|
let ImageFormulaCellInterceptorController = class ImageFormulaCellInterceptorController extends _univerjs_core.Disposable {
|
|
319
223
|
constructor(_commandService, _sheetInterceptorService, _formulaDataModel) {
|
|
320
224
|
super();
|
|
321
225
|
this._commandService = _commandService;
|
|
322
226
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
323
227
|
this._formulaDataModel = _formulaDataModel;
|
|
324
|
-
_defineProperty(this, "_errorValueCell", {
|
|
228
|
+
require_worker._defineProperty(this, "_errorValueCell", {
|
|
325
229
|
v: _univerjs_engine_formula.ErrorType.VALUE,
|
|
326
230
|
t: _univerjs_core.CellValueType.STRING
|
|
327
231
|
});
|
|
328
|
-
_defineProperty(this, "_refreshRender", void 0);
|
|
232
|
+
require_worker._defineProperty(this, "_refreshRender", void 0);
|
|
329
233
|
this._initialize();
|
|
330
234
|
}
|
|
331
235
|
_initialize() {
|
|
@@ -451,14 +355,13 @@ let ImageFormulaCellInterceptorController = class ImageFormulaCellInterceptorCon
|
|
|
451
355
|
this._refreshRender = refreshRender;
|
|
452
356
|
}
|
|
453
357
|
};
|
|
454
|
-
ImageFormulaCellInterceptorController = __decorate([
|
|
455
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
456
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
457
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
358
|
+
ImageFormulaCellInterceptorController = require_worker.__decorate([
|
|
359
|
+
require_worker.__decorateParam(0, _univerjs_core.ICommandService),
|
|
360
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
361
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
458
362
|
], ImageFormulaCellInterceptorController);
|
|
459
363
|
|
|
460
|
-
|
|
461
|
-
//#region src/controllers/trigger-calculation.controller.ts
|
|
364
|
+
// src/controllers/trigger-calculation.controller.ts
|
|
462
365
|
const NilProgress = {
|
|
463
366
|
done: 0,
|
|
464
367
|
count: 0
|
|
@@ -505,12 +408,12 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
505
408
|
this._configService = _configService;
|
|
506
409
|
this._formulaDataModel = _formulaDataModel;
|
|
507
410
|
this._localeService = _localeService;
|
|
508
|
-
_defineProperty(this, "_startExecutionTime", 0);
|
|
509
|
-
_defineProperty(this, "_totalCalculationTaskCount", 0);
|
|
510
|
-
_defineProperty(this, "_doneCalculationTaskCount", 0);
|
|
511
|
-
_defineProperty(this, "_executionInProgressParams", null);
|
|
512
|
-
_defineProperty(this, "_progress$", new rxjs.BehaviorSubject(NilProgress));
|
|
513
|
-
_defineProperty(this, "progress$", this._progress$.asObservable());
|
|
411
|
+
require_worker._defineProperty(this, "_startExecutionTime", 0);
|
|
412
|
+
require_worker._defineProperty(this, "_totalCalculationTaskCount", 0);
|
|
413
|
+
require_worker._defineProperty(this, "_doneCalculationTaskCount", 0);
|
|
414
|
+
require_worker._defineProperty(this, "_executionInProgressParams", null);
|
|
415
|
+
require_worker._defineProperty(this, "_progress$", new rxjs.BehaviorSubject(NilProgress));
|
|
416
|
+
require_worker._defineProperty(this, "progress$", this._progress$.asObservable());
|
|
514
417
|
this._commandExecutedListener();
|
|
515
418
|
this._initialExecuteFormulaProcessListener();
|
|
516
419
|
this._initialExecuteFormula();
|
|
@@ -524,7 +427,7 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
524
427
|
this._progress$.complete();
|
|
525
428
|
}
|
|
526
429
|
_getCalculationMode() {
|
|
527
|
-
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
430
|
+
const config = this._configService.getConfig(require_worker.PLUGIN_CONFIG_KEY_BASE);
|
|
528
431
|
return (config === null || config === void 0 ? void 0 : config.initialFormulaComputing) ?? 1;
|
|
529
432
|
}
|
|
530
433
|
_commandExecutedListener() {
|
|
@@ -630,17 +533,16 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
630
533
|
};
|
|
631
534
|
}
|
|
632
535
|
};
|
|
633
|
-
TriggerCalculationController = __decorate([
|
|
634
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
635
|
-
__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
636
|
-
__decorateParam(2, _univerjs_core.ILogService),
|
|
637
|
-
__decorateParam(3, _univerjs_core.IConfigService),
|
|
638
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
639
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
536
|
+
TriggerCalculationController = require_worker.__decorate([
|
|
537
|
+
require_worker.__decorateParam(0, _univerjs_core.ICommandService),
|
|
538
|
+
require_worker.__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
539
|
+
require_worker.__decorateParam(2, _univerjs_core.ILogService),
|
|
540
|
+
require_worker.__decorateParam(3, _univerjs_core.IConfigService),
|
|
541
|
+
require_worker.__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
542
|
+
require_worker.__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
640
543
|
], TriggerCalculationController);
|
|
641
544
|
|
|
642
|
-
|
|
643
|
-
//#region src/controllers/unit-qualifier-rename.controller.ts
|
|
545
|
+
// src/controllers/unit-qualifier-rename.controller.ts
|
|
644
546
|
function collectUnitQualifierFormulaPatches(workbook, oldName, newName) {
|
|
645
547
|
const unitId = workbook.getUnitId();
|
|
646
548
|
return workbook.getSheets().flatMap((sheet) => {
|
|
@@ -665,7 +567,7 @@ let UnitQualifierRenameController = class UnitQualifierRenameController extends
|
|
|
665
567
|
this._undoRedoService = _undoRedoService;
|
|
666
568
|
this._univerInstanceService = _univerInstanceService;
|
|
667
569
|
this._definedNamesService = _definedNamesService;
|
|
668
|
-
_defineProperty(this, "_names", /* @__PURE__ */ new Map());
|
|
570
|
+
require_worker._defineProperty(this, "_names", /* @__PURE__ */ new Map());
|
|
669
571
|
this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_BASE).forEach((unit) => this._watch(unit));
|
|
670
572
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_BASE).subscribe(({ unit }) => this._watch(unit)));
|
|
671
573
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_BASE).subscribe((unit) => this._names.delete(unit.getUnitId())));
|
|
@@ -732,15 +634,14 @@ let UnitQualifierRenameController = class UnitQualifierRenameController extends
|
|
|
732
634
|
});
|
|
733
635
|
}
|
|
734
636
|
};
|
|
735
|
-
UnitQualifierRenameController = __decorate([
|
|
736
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
737
|
-
__decorateParam(1, _univerjs_core.IUndoRedoService),
|
|
738
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
739
|
-
__decorateParam(3, _univerjs_engine_formula.IDefinedNamesService)
|
|
637
|
+
UnitQualifierRenameController = require_worker.__decorate([
|
|
638
|
+
require_worker.__decorateParam(0, _univerjs_core.ICommandService),
|
|
639
|
+
require_worker.__decorateParam(1, _univerjs_core.IUndoRedoService),
|
|
640
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
641
|
+
require_worker.__decorateParam(3, _univerjs_engine_formula.IDefinedNamesService)
|
|
740
642
|
], UnitQualifierRenameController);
|
|
741
643
|
|
|
742
|
-
|
|
743
|
-
//#region src/controllers/utils/offset-formula-data.ts
|
|
644
|
+
// src/controllers/utils/offset-formula-data.ts
|
|
744
645
|
function checkFormulaDataNull(formulaData, unitId, sheetId) {
|
|
745
646
|
var _formulaData$unitId;
|
|
746
647
|
if (formulaData == null || formulaData[unitId] == null || ((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) == null) return true;
|
|
@@ -759,8 +660,7 @@ function removeFormulaData(formulaData, unitId, sheetId) {
|
|
|
759
660
|
}
|
|
760
661
|
}
|
|
761
662
|
|
|
762
|
-
|
|
763
|
-
//#region src/controllers/utils/ref-range-formula.ts
|
|
663
|
+
// src/controllers/utils/ref-range-formula.ts
|
|
764
664
|
const formulaReferenceSheetList = [
|
|
765
665
|
11,
|
|
766
666
|
12,
|
|
@@ -1231,8 +1131,7 @@ function updateRefOffset(sequenceNodes, refChangeIds, refOffsetX = 0, refOffsetY
|
|
|
1231
1131
|
return newSequenceNodes;
|
|
1232
1132
|
}
|
|
1233
1133
|
|
|
1234
|
-
|
|
1235
|
-
//#region src/controllers/utils/ref-range-move.ts
|
|
1134
|
+
// src/controllers/utils/ref-range-move.ts
|
|
1236
1135
|
function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam, currentFormulaUnitId, currentFormulaSheetId, options = {}) {
|
|
1237
1136
|
const { type, unitId: userUnitId, sheetId: userSheetId, targetUnitId, targetSheetId, targetSheetName, range, from, to, rangeFilteredRows } = formulaReferenceMoveParam;
|
|
1238
1137
|
const { range: unitRange, sheetId: sequenceRangeSheetId, unitId: sequenceRangeUnitId, sheetName: sequenceRangeSheetName, refOffsetX, refOffsetY } = unitRangeWidthOffset;
|
|
@@ -1557,8 +1456,7 @@ function getStartEndValue(range) {
|
|
|
1557
1456
|
};
|
|
1558
1457
|
}
|
|
1559
1458
|
|
|
1560
|
-
|
|
1561
|
-
//#region src/controllers/utils/ref-range-param.ts
|
|
1459
|
+
// src/controllers/utils/ref-range-param.ts
|
|
1562
1460
|
const SET_SHEET_TABLE_COMMAND_ID = "sheet.command.set-table-config";
|
|
1563
1461
|
const DELETE_SHEET_TABLE_COMMAND_ID = "sheet.command.delete-table";
|
|
1564
1462
|
const REMOVE_SHEET_TABLE_COLUMN_AT_COMMAND_ID = "sheet.command.table-remove-column-at";
|
|
@@ -1912,8 +1810,7 @@ function handleRefRemoveSheetTableColumn(command, workbook) {
|
|
|
1912
1810
|
};
|
|
1913
1811
|
}
|
|
1914
1812
|
|
|
1915
|
-
|
|
1916
|
-
//#region src/controllers/update-defined-name.controller.ts
|
|
1813
|
+
// src/controllers/update-defined-name.controller.ts
|
|
1917
1814
|
let UpdateDefinedNameController = class UpdateDefinedNameController extends _univerjs_core.Disposable {
|
|
1918
1815
|
constructor(_definedNamesService, _univerInstanceService, _sheetInterceptorService, _lexerTreeBuilder) {
|
|
1919
1816
|
super();
|
|
@@ -2055,15 +1952,14 @@ let UpdateDefinedNameController = class UpdateDefinedNameController extends _uni
|
|
|
2055
1952
|
return null;
|
|
2056
1953
|
}
|
|
2057
1954
|
};
|
|
2058
|
-
UpdateDefinedNameController = __decorate([
|
|
2059
|
-
__decorateParam(0, _univerjs_engine_formula.IDefinedNamesService),
|
|
2060
|
-
__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
2061
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2062
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
1955
|
+
UpdateDefinedNameController = require_worker.__decorate([
|
|
1956
|
+
require_worker.__decorateParam(0, _univerjs_engine_formula.IDefinedNamesService),
|
|
1957
|
+
require_worker.__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
1958
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
1959
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
2063
1960
|
], UpdateDefinedNameController);
|
|
2064
1961
|
|
|
2065
|
-
|
|
2066
|
-
//#region src/controllers/update-formula.controller.ts
|
|
1962
|
+
// src/controllers/update-formula.controller.ts
|
|
2067
1963
|
let UpdateFormulaController = class UpdateFormulaController extends _univerjs_core.Disposable {
|
|
2068
1964
|
constructor(_univerInstanceService, _commandService, _lexerTreeBuilder, _formulaDataModel, _sheetInterceptorService, _definedNamesService, _configService, _injector) {
|
|
2069
1965
|
super();
|
|
@@ -2096,12 +1992,30 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2096
1992
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe((event) => this._handleWorkbookAdded(event.unit)));
|
|
2097
1993
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.map)((unit) => unit.getUnitId())).subscribe((unitId) => this._handleWorkbookDisposed(unitId)));
|
|
2098
1994
|
}
|
|
1995
|
+
_getEditedArrayFormulaDirtyRanges(params) {
|
|
1996
|
+
var _this$_formulaDataMod;
|
|
1997
|
+
const { subUnitId: sheetId, unitId, cellValue } = params;
|
|
1998
|
+
const previousRanges = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaRange()[unitId]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[sheetId];
|
|
1999
|
+
const dirtyRanges = [];
|
|
2000
|
+
if (previousRanges) new _univerjs_core.ObjectMatrix(cellValue).forValue((row, column) => {
|
|
2001
|
+
var _previousRanges$row;
|
|
2002
|
+
const range = (_previousRanges$row = previousRanges[row]) === null || _previousRanges$row === void 0 ? void 0 : _previousRanges$row[column];
|
|
2003
|
+
if (range && (range.startRow !== range.endRow || range.startColumn !== range.endColumn)) dirtyRanges.push({
|
|
2004
|
+
unitId,
|
|
2005
|
+
sheetId,
|
|
2006
|
+
range
|
|
2007
|
+
});
|
|
2008
|
+
});
|
|
2009
|
+
return dirtyRanges;
|
|
2010
|
+
}
|
|
2099
2011
|
_handleSetRangeValuesMutation(params) {
|
|
2100
2012
|
const { subUnitId: sheetId, unitId, cellValue } = params;
|
|
2101
2013
|
if (cellValue == null) return;
|
|
2014
|
+
const dirtyRanges = this._getEditedArrayFormulaDirtyRanges(params);
|
|
2102
2015
|
const newSheetFormulaData = this._formulaDataModel.updateFormulaData(unitId, sheetId, cellValue);
|
|
2103
2016
|
const arrayFormulaCellDataChanged = this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2104
2017
|
const arrayFormulaRangeChanged = this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2018
|
+
if (dirtyRanges.length > 0) this._commandService.syncExecuteCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, { dirtyRanges }, { onlyLocal: true });
|
|
2105
2019
|
if (Object.keys(newSheetFormulaData).length === 0) {
|
|
2106
2020
|
if (arrayFormulaCellDataChanged || arrayFormulaRangeChanged) this._commandService.executeCommand(_univerjs_engine_formula.SetArrayFormulaDataMutation.id, {
|
|
2107
2021
|
arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
|
|
@@ -2165,7 +2079,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2165
2079
|
newFormulaData[unitId][sheetId] = (_currentSheetData$uni = currentSheetData[unitId]) === null || _currentSheetData$uni === void 0 ? void 0 : _currentSheetData$uni[sheetId];
|
|
2166
2080
|
});
|
|
2167
2081
|
this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2168
|
-
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
2082
|
+
const config = this._configService.getConfig(require_worker.PLUGIN_CONFIG_KEY_BASE);
|
|
2169
2083
|
const calculationMode = (config === null || config === void 0 ? void 0 : config.initialFormulaComputing) ?? 1;
|
|
2170
2084
|
if (calculationMode === 2) return;
|
|
2171
2085
|
const params = this._getDirtyDataByCalculationMode(calculationMode);
|
|
@@ -2213,7 +2127,6 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2213
2127
|
const formulaDataKeys = Object.keys(formulaData);
|
|
2214
2128
|
if (formulaDataKeys.length === 0) return { newFormulaData: {} };
|
|
2215
2129
|
const newFormulaData = Object.create(null);
|
|
2216
|
-
const { unitId: fromUnitId, sheetId: fromSheetId, sheetName: fromSheetName, targetUnitId, targetSheetId, type, from, to } = formulaReferenceMoveParam;
|
|
2217
2130
|
const inCrossSheetCutRangeNewFormulas = [];
|
|
2218
2131
|
for (const unitId of formulaDataKeys) {
|
|
2219
2132
|
const sheetData = formulaData[unitId];
|
|
@@ -2223,177 +2136,209 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2223
2136
|
for (const sheetId of sheetDataKeys) {
|
|
2224
2137
|
const matrixData = new _univerjs_core.ObjectMatrix(sheetData[sheetId] || {});
|
|
2225
2138
|
const newFormulaDataItem = new _univerjs_core.ObjectMatrix();
|
|
2226
|
-
const
|
|
2139
|
+
const context = {
|
|
2140
|
+
unitId,
|
|
2141
|
+
sheetId,
|
|
2142
|
+
unitSheetNameMap,
|
|
2143
|
+
params: formulaReferenceMoveParam,
|
|
2144
|
+
modifiedSharedFormulaIds: []
|
|
2145
|
+
};
|
|
2227
2146
|
matrixData.forValue((row, column, formulaDataItem) => {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
if (type === 12) {
|
|
2231
|
-
const { oldUnitName, unitName } = formulaReferenceMoveParam;
|
|
2232
|
-
if (!oldUnitName || !unitName) return true;
|
|
2233
|
-
const nextFormula = (0, _univerjs_engine_formula.refactorFormulaUnitQualifier)(formulaString, oldUnitName, unitName);
|
|
2234
|
-
if (nextFormula !== formulaString) newFormulaDataItem.setValue(row, column, { f: nextFormula });
|
|
2235
|
-
return true;
|
|
2236
|
-
}
|
|
2237
|
-
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
2238
|
-
if (sequenceNodes == null) return true;
|
|
2239
|
-
let shouldModify = false;
|
|
2240
|
-
const refChangeIds = [];
|
|
2241
|
-
const inCrossSheetCutRange = type === 0 && (targetUnitId !== fromUnitId || targetSheetId !== fromSheetId) && unitId === fromUnitId && sheetId === fromSheetId && from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn;
|
|
2242
|
-
const inCrossSheetCutRangeSequenceNodes = [...sequenceNodes];
|
|
2243
|
-
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2244
|
-
var _unitSheetNameMap$map;
|
|
2245
|
-
const node = sequenceNodes[i];
|
|
2246
|
-
if (typeof node === "string") continue;
|
|
2247
|
-
const { token, nodeType } = node;
|
|
2248
|
-
if ((type === 14 || type === 15) && (nodeType === _univerjs_engine_formula.sequenceNodeType.DEFINED_NAME || nodeType === _univerjs_engine_formula.sequenceNodeType.FUNCTION)) {
|
|
2249
|
-
const { definedNameId, definedName } = formulaReferenceMoveParam;
|
|
2250
|
-
if (definedNameId === void 0 || definedName === void 0) continue;
|
|
2251
|
-
const oldDefinedName = this._definedNamesService.getValueById(unitId, definedNameId);
|
|
2252
|
-
if (oldDefinedName === void 0 || oldDefinedName === null) continue;
|
|
2253
|
-
if (oldDefinedName.name !== token) continue;
|
|
2254
|
-
sequenceNodes[i] = {
|
|
2255
|
-
...node,
|
|
2256
|
-
token: type === 14 ? definedName : _univerjs_engine_formula.ErrorType.REF
|
|
2257
|
-
};
|
|
2258
|
-
shouldModify = true;
|
|
2259
|
-
refChangeIds.push(i);
|
|
2260
|
-
continue;
|
|
2261
|
-
} else if ((type === 16 || type === 17 || type === 18) && (nodeType === _univerjs_engine_formula.sequenceNodeType.TABLE || nodeType === _univerjs_engine_formula.sequenceNodeType.FUNCTION)) {
|
|
2262
|
-
const { oldTableName, tableName, tableColumnNames } = formulaReferenceMoveParam;
|
|
2263
|
-
if (oldTableName === void 0 || type === 16 && tableName === void 0) continue;
|
|
2264
|
-
const { tableName: tokenTableName, columnStruct = "" } = (0, _univerjs_engine_formula.splitTableStructuredRef)(token);
|
|
2265
|
-
if (tokenTableName !== oldTableName) continue;
|
|
2266
|
-
if (type === 18 && !tableReferenceContainsColumn(columnStruct, tableColumnNames)) continue;
|
|
2267
|
-
sequenceNodes[i] = {
|
|
2268
|
-
...node,
|
|
2269
|
-
token: type === 16 ? `${tableName}${columnStruct}` : _univerjs_engine_formula.ErrorType.REF
|
|
2270
|
-
};
|
|
2271
|
-
const nextNode = sequenceNodes[i + 1];
|
|
2272
|
-
if ((type === 17 || type === 18) && typeof nextNode === "string" && nextNode.startsWith("]")) sequenceNodes[i + 1] = nextNode.slice(1);
|
|
2273
|
-
shouldModify = true;
|
|
2274
|
-
refChangeIds.push(i);
|
|
2275
|
-
continue;
|
|
2276
|
-
} else if (nodeType !== _univerjs_engine_formula.sequenceNodeType.REFERENCE) continue;
|
|
2277
|
-
const { range, sheetName, unitId: sequenceUnitId } = (0, _univerjs_engine_formula.deserializeRangeWithSheetWithCache)(token);
|
|
2278
|
-
const mapUnitId = sequenceUnitId == null || sequenceUnitId.length === 0 ? unitId : sequenceUnitId;
|
|
2279
|
-
const sequenceSheetId = (unitSheetNameMap === null || unitSheetNameMap === void 0 || (_unitSheetNameMap$map = unitSheetNameMap[mapUnitId]) === null || _unitSheetNameMap$map === void 0 ? void 0 : _unitSheetNameMap$map[sheetName]) || "";
|
|
2280
|
-
if (!checkIsSameUnitAndSheet(formulaReferenceMoveParam.unitId, formulaReferenceMoveParam.sheetId, unitId, sheetId, sequenceUnitId, sequenceSheetId)) continue;
|
|
2281
|
-
const sequenceUnitRangeWidthOffset = {
|
|
2282
|
-
range,
|
|
2283
|
-
sheetId: sequenceSheetId,
|
|
2284
|
-
unitId: sequenceUnitId,
|
|
2285
|
-
sheetName,
|
|
2286
|
-
refOffsetX: x || 0,
|
|
2287
|
-
refOffsetY: y || 0
|
|
2288
|
-
};
|
|
2289
|
-
let newRefString = null;
|
|
2290
|
-
if (type === 11) {
|
|
2291
|
-
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2292
|
-
if (newSheetName == null) continue;
|
|
2293
|
-
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
2294
|
-
if (userSheetId !== sequenceSheetId) continue;
|
|
2295
|
-
newRefString = (0, _univerjs_engine_formula.serializeRangeToRefString)({
|
|
2296
|
-
range,
|
|
2297
|
-
sheetName: newSheetName,
|
|
2298
|
-
unitId: sequenceUnitId
|
|
2299
|
-
});
|
|
2300
|
-
} else if (type === 13) {
|
|
2301
|
-
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2302
|
-
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
2303
|
-
if (userSheetId !== sequenceSheetId) continue;
|
|
2304
|
-
newRefString = _univerjs_engine_formula.ErrorType.REF;
|
|
2305
|
-
} else if (type !== 14) newRefString = getNewRangeByMoveParam(sequenceUnitRangeWidthOffset, formulaReferenceMoveParam, unitId, sheetId, { inCrossSheetCutRange });
|
|
2306
|
-
if (newRefString != null) {
|
|
2307
|
-
sequenceNodes[i] = {
|
|
2308
|
-
...node,
|
|
2309
|
-
token: newRefString
|
|
2310
|
-
};
|
|
2311
|
-
shouldModify = true;
|
|
2312
|
-
refChangeIds.push(i);
|
|
2313
|
-
if (si && (x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* If the reference sequence range is not affected by the move, and the move is a cross-worksheet cut operation, it may be necessary to rewrite the sheet name in the ref string after move, to make sure the ref still works after move.
|
|
2317
|
-
* For example, if a formula cell is `=SUM(A1:A5)` in Sheet1, and formula cell cut to Sheet2, the formula should be rewritten to `=SUM(Sheet1!A1:A5)`, otherwise it will become `=SUM(A1:A5)` and reference the wrong range in Sheet2.
|
|
2318
|
-
*/
|
|
2319
|
-
if (inCrossSheetCutRange) {
|
|
2320
|
-
if (newRefString != null) inCrossSheetCutRangeSequenceNodes[i] = {
|
|
2321
|
-
...node,
|
|
2322
|
-
token: newRefString
|
|
2323
|
-
};
|
|
2324
|
-
else if ((!sequenceUnitId || sequenceUnitId === fromUnitId) && (!sequenceSheetId || sequenceSheetId === fromSheetId)) {
|
|
2325
|
-
/**
|
|
2326
|
-
* Only the reference range is in the from worksheet need to rewrite the sheet name, otherwise the ref string will be rewritten unnecessarily when moving between other worksheets.
|
|
2327
|
-
* For example, if a formula cell is `=SUM(Sheet3!A1:A5)` in Sheet1, and formula cell cut to Sheet2, the formula should not be rewritten, otherwise it will become `=SUM(Sheet1!A1:A5)` and reference the wrong range in Sheet1, while the original ref is referencing Sheet3 and should not be affected by the move between Sheet1 and Sheet2.
|
|
2328
|
-
*/
|
|
2329
|
-
const sequenceRange = _univerjs_core.Rectangle.moveOffset(range, x || 0, y || 0);
|
|
2330
|
-
inCrossSheetCutRangeSequenceNodes[i] = {
|
|
2331
|
-
...node,
|
|
2332
|
-
token: (0, _univerjs_engine_formula.serializeRangeToRefString)({
|
|
2333
|
-
range: sequenceRange,
|
|
2334
|
-
sheetName: fromSheetName || sheetName,
|
|
2335
|
-
unitId: targetUnitId !== fromUnitId ? fromUnitId : ""
|
|
2336
|
-
})
|
|
2337
|
-
};
|
|
2338
|
-
shouldModify = true;
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
if (!shouldModify) {
|
|
2343
|
-
/**
|
|
2344
|
-
* If the operation is a move type, and the formula cell has si and is the same as the current shouldModifySi, unpack the si to f.
|
|
2345
|
-
* Or the source formula cell is in the moved range.
|
|
2346
|
-
* This is to ensure that the si formula can be recalculated correctly after the move.
|
|
2347
|
-
*/
|
|
2348
|
-
if (si && [
|
|
2349
|
-
1,
|
|
2350
|
-
2,
|
|
2351
|
-
0
|
|
2352
|
-
].includes(type)) {
|
|
2353
|
-
if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
|
|
2354
|
-
if ((x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
|
|
2355
|
-
} else if (!shouldModifySi.includes(si)) return true;
|
|
2356
|
-
} else return true;
|
|
2357
|
-
}
|
|
2358
|
-
if (inCrossSheetCutRange) {
|
|
2359
|
-
const newSequenceNodes = updateRefOffset(inCrossSheetCutRangeSequenceNodes, refChangeIds, x, y);
|
|
2360
|
-
inCrossSheetCutRangeNewFormulas.push({
|
|
2361
|
-
fromRow: row,
|
|
2362
|
-
fromColumn: column,
|
|
2363
|
-
formulaString: `=${(0, _univerjs_engine_formula.generateStringWithSequence)(newSequenceNodes)}`
|
|
2364
|
-
});
|
|
2365
|
-
return true;
|
|
2366
|
-
}
|
|
2367
|
-
const newSequenceNodes = updateRefOffset(sequenceNodes, refChangeIds, x, y);
|
|
2368
|
-
newFormulaDataItem.setValue(row, column, { f: `=${(0, _univerjs_engine_formula.generateStringWithSequence)(newSequenceNodes)}` });
|
|
2147
|
+
const formula = this._getMovedFormula(formulaDataItem, row, column, context, inCrossSheetCutRangeNewFormulas);
|
|
2148
|
+
if (formula != null) newFormulaDataItem.setValue(row, column, { f: formula });
|
|
2369
2149
|
});
|
|
2370
2150
|
if (newFormulaData[unitId]) newFormulaData[unitId][sheetId] = newFormulaDataItem.clone();
|
|
2371
2151
|
}
|
|
2372
2152
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2153
|
+
appendCrossSheetCutFormulas(newFormulaData, inCrossSheetCutRangeNewFormulas, formulaReferenceMoveParam);
|
|
2154
|
+
return { newFormulaData };
|
|
2155
|
+
}
|
|
2156
|
+
_getMovedFormula(item, row, column, context, crossSheetFormulas) {
|
|
2157
|
+
if (!item) return null;
|
|
2158
|
+
const { f: formulaString, x, y } = item;
|
|
2159
|
+
const { unitId, sheetId, params, modifiedSharedFormulaIds } = context;
|
|
2160
|
+
if (params.type === 12) {
|
|
2161
|
+
const { oldUnitName, unitName } = params;
|
|
2162
|
+
if (!oldUnitName || !unitName) return null;
|
|
2163
|
+
const nextFormula = (0, _univerjs_engine_formula.refactorFormulaUnitQualifier)(formulaString, oldUnitName, unitName);
|
|
2164
|
+
return nextFormula !== formulaString ? nextFormula : null;
|
|
2165
|
+
}
|
|
2166
|
+
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
2167
|
+
if (sequenceNodes == null) return null;
|
|
2168
|
+
const refChangeIds = [];
|
|
2169
|
+
const inCrossSheetCutRange = isInCrossSheetCutRange(unitId, sheetId, row, column, params);
|
|
2170
|
+
const crossSheetNodes = [...sequenceNodes];
|
|
2171
|
+
if (!this._updateFormulaReferenceNodes(sequenceNodes, item, context, refChangeIds, inCrossSheetCutRange ? crossSheetNodes : null) && !shouldUnpackSharedFormula(item, row, column, params, modifiedSharedFormulaIds)) return null;
|
|
2172
|
+
const newSequenceNodes = updateRefOffset(inCrossSheetCutRange ? crossSheetNodes : sequenceNodes, refChangeIds, x, y);
|
|
2173
|
+
const formula = `=${(0, _univerjs_engine_formula.generateStringWithSequence)(newSequenceNodes)}`;
|
|
2174
|
+
if (inCrossSheetCutRange) {
|
|
2175
|
+
crossSheetFormulas.push({
|
|
2176
|
+
fromRow: row,
|
|
2177
|
+
fromColumn: column,
|
|
2178
|
+
formulaString: formula
|
|
2179
|
+
});
|
|
2180
|
+
return null;
|
|
2181
|
+
}
|
|
2182
|
+
return formula;
|
|
2183
|
+
}
|
|
2184
|
+
_updateFormulaReferenceNodes(sequenceNodes, item, context, refChangeIds, crossSheetNodes) {
|
|
2185
|
+
const { unitId, sheetId, params, modifiedSharedFormulaIds } = context;
|
|
2186
|
+
const { x, y, si } = item;
|
|
2187
|
+
let shouldModify = false;
|
|
2188
|
+
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2189
|
+
const node = sequenceNodes[i];
|
|
2190
|
+
if (typeof node === "string") continue;
|
|
2191
|
+
const definedNameToken = this._getDefinedNameReferenceToken(node, unitId, params);
|
|
2192
|
+
if (definedNameToken != null) {
|
|
2193
|
+
sequenceNodes[i] = {
|
|
2194
|
+
...node,
|
|
2195
|
+
token: definedNameToken
|
|
2196
|
+
};
|
|
2197
|
+
shouldModify = true;
|
|
2198
|
+
refChangeIds.push(i);
|
|
2199
|
+
continue;
|
|
2200
|
+
}
|
|
2201
|
+
if (updateTableReference(sequenceNodes, i, node, params)) {
|
|
2202
|
+
shouldModify = true;
|
|
2203
|
+
refChangeIds.push(i);
|
|
2204
|
+
continue;
|
|
2205
|
+
}
|
|
2206
|
+
if (node.nodeType !== _univerjs_engine_formula.sequenceNodeType.REFERENCE) continue;
|
|
2207
|
+
const reference = getReferenceWithOffset(node.token, item, context);
|
|
2208
|
+
if (reference == null) continue;
|
|
2209
|
+
const newRefString = getMovedReferenceToken(reference, params, unitId, sheetId, crossSheetNodes != null);
|
|
2210
|
+
if (newRefString != null) {
|
|
2211
|
+
sequenceNodes[i] = {
|
|
2212
|
+
...node,
|
|
2213
|
+
token: newRefString
|
|
2214
|
+
};
|
|
2215
|
+
shouldModify = true;
|
|
2216
|
+
refChangeIds.push(i);
|
|
2217
|
+
if (si && (x ?? 0) === 0 && (y ?? 0) === 0) modifiedSharedFormulaIds.push(si);
|
|
2218
|
+
}
|
|
2219
|
+
if (crossSheetNodes != null) {
|
|
2220
|
+
const movedNode = getCrossSheetCutReference(node, reference, newRefString, params);
|
|
2221
|
+
if (movedNode != null) {
|
|
2222
|
+
crossSheetNodes[i] = movedNode;
|
|
2223
|
+
shouldModify = true;
|
|
2224
|
+
}
|
|
2382
2225
|
}
|
|
2383
2226
|
}
|
|
2384
|
-
return
|
|
2227
|
+
return shouldModify;
|
|
2228
|
+
}
|
|
2229
|
+
_getDefinedNameReferenceToken(node, unitId, params) {
|
|
2230
|
+
const { type, definedNameId, definedName } = params;
|
|
2231
|
+
if (type !== 14 && type !== 15) return null;
|
|
2232
|
+
if (node.nodeType !== _univerjs_engine_formula.sequenceNodeType.DEFINED_NAME && node.nodeType !== _univerjs_engine_formula.sequenceNodeType.FUNCTION) return null;
|
|
2233
|
+
if (definedNameId === void 0 || definedName === void 0) return null;
|
|
2234
|
+
const oldDefinedName = this._definedNamesService.getValueById(unitId, definedNameId);
|
|
2235
|
+
if (oldDefinedName == null || oldDefinedName.name !== node.token) return null;
|
|
2236
|
+
return type === 14 ? definedName : _univerjs_engine_formula.ErrorType.REF;
|
|
2385
2237
|
}
|
|
2386
2238
|
};
|
|
2387
|
-
UpdateFormulaController = __decorate([
|
|
2388
|
-
__decorateParam(0, _univerjs_core.IUniverInstanceService),
|
|
2389
|
-
__decorateParam(1, _univerjs_core.ICommandService),
|
|
2390
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder)),
|
|
2391
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
2392
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2393
|
-
__decorateParam(5, _univerjs_engine_formula.IDefinedNamesService),
|
|
2394
|
-
__decorateParam(6, _univerjs_core.IConfigService),
|
|
2395
|
-
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
2239
|
+
UpdateFormulaController = require_worker.__decorate([
|
|
2240
|
+
require_worker.__decorateParam(0, _univerjs_core.IUniverInstanceService),
|
|
2241
|
+
require_worker.__decorateParam(1, _univerjs_core.ICommandService),
|
|
2242
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder)),
|
|
2243
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
2244
|
+
require_worker.__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2245
|
+
require_worker.__decorateParam(5, _univerjs_engine_formula.IDefinedNamesService),
|
|
2246
|
+
require_worker.__decorateParam(6, _univerjs_core.IConfigService),
|
|
2247
|
+
require_worker.__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
2396
2248
|
], UpdateFormulaController);
|
|
2249
|
+
function getReferenceWithOffset(token, item, context) {
|
|
2250
|
+
var _unitSheetNameMap$map;
|
|
2251
|
+
const { unitId, sheetId, unitSheetNameMap, params } = context;
|
|
2252
|
+
const { range, sheetName, unitId: sequenceUnitId } = (0, _univerjs_engine_formula.deserializeRangeWithSheetWithCache)(token);
|
|
2253
|
+
const mapUnitId = sequenceUnitId == null || sequenceUnitId.length === 0 ? unitId : sequenceUnitId;
|
|
2254
|
+
const sequenceSheetId = (unitSheetNameMap === null || unitSheetNameMap === void 0 || (_unitSheetNameMap$map = unitSheetNameMap[mapUnitId]) === null || _unitSheetNameMap$map === void 0 ? void 0 : _unitSheetNameMap$map[sheetName]) || "";
|
|
2255
|
+
if (!checkIsSameUnitAndSheet(params.unitId, params.sheetId, unitId, sheetId, sequenceUnitId, sequenceSheetId)) return null;
|
|
2256
|
+
return {
|
|
2257
|
+
range,
|
|
2258
|
+
sheetId: sequenceSheetId,
|
|
2259
|
+
unitId: sequenceUnitId,
|
|
2260
|
+
sheetName,
|
|
2261
|
+
refOffsetX: item.x || 0,
|
|
2262
|
+
refOffsetY: item.y || 0
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
function appendCrossSheetCutFormulas(data, formulas, params) {
|
|
2266
|
+
const { targetUnitId, targetSheetId, from, to } = params;
|
|
2267
|
+
if (formulas.length === 0 || !targetUnitId || !targetSheetId) return;
|
|
2268
|
+
if (!data[targetUnitId]) data[targetUnitId] = Object.create(null);
|
|
2269
|
+
if (!data[targetUnitId][targetSheetId]) data[targetUnitId][targetSheetId] = Object.create(null);
|
|
2270
|
+
for (const { fromRow, fromColumn, formulaString } of formulas) {
|
|
2271
|
+
const targetRow = fromRow + (((to === null || to === void 0 ? void 0 : to.startRow) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startRow) ?? 0));
|
|
2272
|
+
const targetColumn = fromColumn + (((to === null || to === void 0 ? void 0 : to.startColumn) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startColumn) ?? 0));
|
|
2273
|
+
if (!data[targetUnitId][targetSheetId][targetRow]) data[targetUnitId][targetSheetId][targetRow] = Object.create(null);
|
|
2274
|
+
data[targetUnitId][targetSheetId][targetRow][targetColumn] = { f: formulaString };
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
function isInCrossSheetCutRange(unitId, sheetId, row, column, params) {
|
|
2278
|
+
const { type, unitId: fromUnitId, sheetId: fromSheetId, targetUnitId, targetSheetId, from } = params;
|
|
2279
|
+
return type === 0 && (targetUnitId !== fromUnitId || targetSheetId !== fromSheetId) && unitId === fromUnitId && sheetId === fromSheetId && from != null && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn;
|
|
2280
|
+
}
|
|
2281
|
+
function updateTableReference(sequenceNodes, index, node, params) {
|
|
2282
|
+
const { type, oldTableName, tableName, tableColumnNames } = params;
|
|
2283
|
+
if (type !== 16 && type !== 17 && type !== 18) return false;
|
|
2284
|
+
if (node.nodeType !== _univerjs_engine_formula.sequenceNodeType.TABLE && node.nodeType !== _univerjs_engine_formula.sequenceNodeType.FUNCTION) return false;
|
|
2285
|
+
if (oldTableName === void 0 || type === 16 && tableName === void 0) return false;
|
|
2286
|
+
const { tableName: tokenTableName, columnStruct = "" } = (0, _univerjs_engine_formula.splitTableStructuredRef)(node.token);
|
|
2287
|
+
if (tokenTableName !== oldTableName) return false;
|
|
2288
|
+
if (type === 18 && !tableReferenceContainsColumn(columnStruct, tableColumnNames)) return false;
|
|
2289
|
+
sequenceNodes[index] = {
|
|
2290
|
+
...node,
|
|
2291
|
+
token: type === 16 ? `${tableName}${columnStruct}` : _univerjs_engine_formula.ErrorType.REF
|
|
2292
|
+
};
|
|
2293
|
+
const nextNode = sequenceNodes[index + 1];
|
|
2294
|
+
if ((type === 17 || type === 18) && typeof nextNode === "string" && nextNode.startsWith("]")) sequenceNodes[index + 1] = nextNode.slice(1);
|
|
2295
|
+
return true;
|
|
2296
|
+
}
|
|
2297
|
+
function getMovedReferenceToken(reference, params, unitId, sheetId, inCrossSheetCutRange) {
|
|
2298
|
+
const { type, sheetId: affectedSheetId, sheetName } = params;
|
|
2299
|
+
if (type === 11 || type === 13) {
|
|
2300
|
+
if (!reference.sheetId || affectedSheetId !== reference.sheetId) return null;
|
|
2301
|
+
if (type === 13) return _univerjs_engine_formula.ErrorType.REF;
|
|
2302
|
+
if (sheetName == null) return null;
|
|
2303
|
+
return (0, _univerjs_engine_formula.serializeRangeToRefString)({
|
|
2304
|
+
range: reference.range,
|
|
2305
|
+
sheetName,
|
|
2306
|
+
unitId: reference.unitId
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
if (type === 14) return null;
|
|
2310
|
+
return getNewRangeByMoveParam(reference, params, unitId, sheetId, { inCrossSheetCutRange });
|
|
2311
|
+
}
|
|
2312
|
+
function getCrossSheetCutReference(node, reference, newRefString, params) {
|
|
2313
|
+
if (newRefString != null) return {
|
|
2314
|
+
...node,
|
|
2315
|
+
token: newRefString
|
|
2316
|
+
};
|
|
2317
|
+
const { unitId, sheetId, targetUnitId, sheetName } = params;
|
|
2318
|
+
if (reference.unitId && reference.unitId !== unitId || reference.sheetId && reference.sheetId !== sheetId) return null;
|
|
2319
|
+
return {
|
|
2320
|
+
...node,
|
|
2321
|
+
token: (0, _univerjs_engine_formula.serializeRangeToRefString)({
|
|
2322
|
+
range: _univerjs_core.Rectangle.moveOffset(reference.range, reference.refOffsetX || 0, reference.refOffsetY || 0),
|
|
2323
|
+
sheetName: sheetName || reference.sheetName,
|
|
2324
|
+
unitId: targetUnitId !== unitId ? unitId : ""
|
|
2325
|
+
})
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
function shouldUnpackSharedFormula(item, row, column, params, modifiedIds) {
|
|
2329
|
+
const { si, x, y } = item;
|
|
2330
|
+
const { type, from } = params;
|
|
2331
|
+
if (!si || ![
|
|
2332
|
+
1,
|
|
2333
|
+
2,
|
|
2334
|
+
0
|
|
2335
|
+
].includes(type)) return false;
|
|
2336
|
+
if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
|
|
2337
|
+
if ((x ?? 0) === 0 && (y ?? 0) === 0) modifiedIds.push(si);
|
|
2338
|
+
return true;
|
|
2339
|
+
}
|
|
2340
|
+
return modifiedIds.includes(si);
|
|
2341
|
+
}
|
|
2397
2342
|
/**
|
|
2398
2343
|
* Whether to skip the formula update when the setRangeValues mutation is executed.
|
|
2399
2344
|
* The style-only cell value does not affect the formula calculation, so it can be skipped.
|
|
@@ -2439,13 +2384,7 @@ function tableReferenceContainsColumn(columnStruct, columnNames) {
|
|
|
2439
2384
|
return false;
|
|
2440
2385
|
}
|
|
2441
2386
|
|
|
2442
|
-
|
|
2443
|
-
//#region package.json
|
|
2444
|
-
var name = "@univerjs/sheets-formula";
|
|
2445
|
-
var version = "1.3.0";
|
|
2446
|
-
|
|
2447
|
-
//#endregion
|
|
2448
|
-
//#region src/common/plugin-name.ts
|
|
2387
|
+
// src/common/plugin-name.ts
|
|
2449
2388
|
/**
|
|
2450
2389
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2451
2390
|
*
|
|
@@ -2463,8 +2402,7 @@ var version = "1.3.0";
|
|
|
2463
2402
|
*/
|
|
2464
2403
|
const SHEETS_FORMULA_PLUGIN_NAME = "SHEETS_FORMULA_PLUGIN";
|
|
2465
2404
|
|
|
2466
|
-
|
|
2467
|
-
//#region src/controllers/active-dirty.controller.ts
|
|
2405
|
+
// src/controllers/active-dirty.controller.ts
|
|
2468
2406
|
let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.Disposable {
|
|
2469
2407
|
constructor(_activeDirtyManagerService, _univerInstanceService, _formulaDataModel) {
|
|
2470
2408
|
super();
|
|
@@ -2547,6 +2485,10 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
|
|
|
2547
2485
|
});
|
|
2548
2486
|
}
|
|
2549
2487
|
_initialRowAndColumn() {
|
|
2488
|
+
for (const mutation of [_univerjs_sheets.SetWorksheetRowCountMutation, _univerjs_sheets.SetWorksheetColumnCountMutation]) this._activeDirtyManagerService.register(mutation.id, {
|
|
2489
|
+
commandId: mutation.id,
|
|
2490
|
+
getDirtyData: (command) => ({ dirtyReferenceUnits: [command.params.unitId] })
|
|
2491
|
+
});
|
|
2550
2492
|
this._activeDirtyManagerService.register(_univerjs_sheets.RemoveRowMutation.id, {
|
|
2551
2493
|
commandId: _univerjs_sheets.RemoveRowMutation.id,
|
|
2552
2494
|
getDirtyData: (command) => {
|
|
@@ -2605,6 +2547,13 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
|
|
|
2605
2547
|
});
|
|
2606
2548
|
}
|
|
2607
2549
|
_initialSheet() {
|
|
2550
|
+
this._activeDirtyManagerService.register(_univerjs_sheets.SetWorksheetOrderMutation.id, {
|
|
2551
|
+
commandId: _univerjs_sheets.SetWorksheetOrderMutation.id,
|
|
2552
|
+
getDirtyData: (command) => {
|
|
2553
|
+
const { unitId, fromOrder, toOrder } = command.params;
|
|
2554
|
+
return { dirtyReferenceUnits: fromOrder === toOrder ? [] : [unitId] };
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2608
2557
|
this._activeDirtyManagerService.register(_univerjs_sheets.RemoveSheetMutation.id, {
|
|
2609
2558
|
commandId: _univerjs_sheets.RemoveSheetMutation.id,
|
|
2610
2559
|
getDirtyData: (command) => {
|
|
@@ -2782,14 +2731,13 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
|
|
|
2782
2731
|
return dirtyRanges;
|
|
2783
2732
|
}
|
|
2784
2733
|
};
|
|
2785
|
-
ActiveDirtyController = __decorate([
|
|
2786
|
-
__decorateParam(0, _univerjs_engine_formula.IActiveDirtyManagerService),
|
|
2787
|
-
__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
2788
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
2734
|
+
ActiveDirtyController = require_worker.__decorate([
|
|
2735
|
+
require_worker.__decorateParam(0, _univerjs_engine_formula.IActiveDirtyManagerService),
|
|
2736
|
+
require_worker.__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
2737
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
2789
2738
|
], ActiveDirtyController);
|
|
2790
2739
|
|
|
2791
|
-
|
|
2792
|
-
//#region src/controllers/array-formula-cell-interceptor.controller.ts
|
|
2740
|
+
// src/controllers/array-formula-cell-interceptor.controller.ts
|
|
2793
2741
|
let ArrayFormulaCellInterceptorController = class ArrayFormulaCellInterceptorController extends _univerjs_core.Disposable {
|
|
2794
2742
|
constructor(_commandService, _sheetInterceptorService, _formulaDataModel) {
|
|
2795
2743
|
super();
|
|
@@ -2842,14 +2790,13 @@ let ArrayFormulaCellInterceptorController = class ArrayFormulaCellInterceptorCon
|
|
|
2842
2790
|
}));
|
|
2843
2791
|
}
|
|
2844
2792
|
};
|
|
2845
|
-
ArrayFormulaCellInterceptorController = __decorate([
|
|
2846
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
2847
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2848
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
2793
|
+
ArrayFormulaCellInterceptorController = require_worker.__decorate([
|
|
2794
|
+
require_worker.__decorateParam(0, _univerjs_core.ICommandService),
|
|
2795
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2796
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
2849
2797
|
], ArrayFormulaCellInterceptorController);
|
|
2850
2798
|
|
|
2851
|
-
|
|
2852
|
-
//#region src/controllers/defined-name.controller.ts
|
|
2799
|
+
// src/controllers/defined-name.controller.ts
|
|
2853
2800
|
let DefinedNameController = class DefinedNameController extends _univerjs_core.Disposable {
|
|
2854
2801
|
constructor(_descriptionService, _definedNamesService, _univerInstanceService, _commandService) {
|
|
2855
2802
|
super();
|
|
@@ -2857,7 +2804,7 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
2857
2804
|
this._definedNamesService = _definedNamesService;
|
|
2858
2805
|
this._univerInstanceService = _univerInstanceService;
|
|
2859
2806
|
this._commandService = _commandService;
|
|
2860
|
-
_defineProperty(this, "_preUnitId", null);
|
|
2807
|
+
require_worker._defineProperty(this, "_preUnitId", null);
|
|
2861
2808
|
this._initialize();
|
|
2862
2809
|
}
|
|
2863
2810
|
_initialize() {
|
|
@@ -2984,15 +2931,14 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
2984
2931
|
this._descriptionService.unregisterDescriptions(functionList);
|
|
2985
2932
|
}
|
|
2986
2933
|
};
|
|
2987
|
-
DefinedNameController = __decorate([
|
|
2988
|
-
__decorateParam(0, _univerjs_engine_formula.IDescriptionService),
|
|
2989
|
-
__decorateParam(1, _univerjs_engine_formula.IDefinedNamesService),
|
|
2990
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
2991
|
-
__decorateParam(3, _univerjs_core.ICommandService)
|
|
2934
|
+
DefinedNameController = require_worker.__decorate([
|
|
2935
|
+
require_worker.__decorateParam(0, _univerjs_engine_formula.IDescriptionService),
|
|
2936
|
+
require_worker.__decorateParam(1, _univerjs_engine_formula.IDefinedNamesService),
|
|
2937
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
2938
|
+
require_worker.__decorateParam(3, _univerjs_core.ICommandService)
|
|
2992
2939
|
], DefinedNameController);
|
|
2993
2940
|
|
|
2994
|
-
|
|
2995
|
-
//#region src/controllers/formula.controller.ts
|
|
2941
|
+
// src/controllers/formula.controller.ts
|
|
2996
2942
|
/**
|
|
2997
2943
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2998
2944
|
*
|
|
@@ -3015,10 +2961,9 @@ let FormulaController = class FormulaController extends _univerjs_core.Disposabl
|
|
|
3015
2961
|
this._commandService.registerCommand(InsertFunctionCommand);
|
|
3016
2962
|
}
|
|
3017
2963
|
};
|
|
3018
|
-
FormulaController = __decorate([__decorateParam(0, _univerjs_core.ICommandService)], FormulaController);
|
|
2964
|
+
FormulaController = require_worker.__decorate([require_worker.__decorateParam(0, _univerjs_core.ICommandService)], FormulaController);
|
|
3019
2965
|
|
|
3020
|
-
|
|
3021
|
-
//#region src/controllers/sheet-formula-calculation-result-apply.controller.ts
|
|
2966
|
+
// src/controllers/sheet-formula-calculation-result-apply.controller.ts
|
|
3022
2967
|
/**
|
|
3023
2968
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3024
2969
|
*
|
|
@@ -3044,10 +2989,9 @@ let SheetFormulaCalculationResultApplyController = class SheetFormulaCalculation
|
|
|
3044
2989
|
}));
|
|
3045
2990
|
}
|
|
3046
2991
|
};
|
|
3047
|
-
SheetFormulaCalculationResultApplyController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaCalculationSessionService))], SheetFormulaCalculationResultApplyController);
|
|
2992
|
+
SheetFormulaCalculationResultApplyController = require_worker.__decorate([require_worker.__decorateParam(0, _univerjs_core.ICommandService), require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaCalculationSessionService))], SheetFormulaCalculationResultApplyController);
|
|
3048
2993
|
|
|
3049
|
-
|
|
3050
|
-
//#region src/controllers/super-table.controller.ts
|
|
2994
|
+
// src/controllers/super-table.controller.ts
|
|
3051
2995
|
let SuperTableController = class SuperTableController extends _univerjs_core.Disposable {
|
|
3052
2996
|
constructor(_descriptionService, _univerInstanceService, _commandService, _superTableService) {
|
|
3053
2997
|
super();
|
|
@@ -3055,7 +2999,7 @@ let SuperTableController = class SuperTableController extends _univerjs_core.Dis
|
|
|
3055
2999
|
this._univerInstanceService = _univerInstanceService;
|
|
3056
3000
|
this._commandService = _commandService;
|
|
3057
3001
|
this._superTableService = _superTableService;
|
|
3058
|
-
_defineProperty(this, "_preUnitId", null);
|
|
3002
|
+
require_worker._defineProperty(this, "_preUnitId", null);
|
|
3059
3003
|
this._initialize();
|
|
3060
3004
|
}
|
|
3061
3005
|
_initialize() {
|
|
@@ -3168,15 +3112,14 @@ let SuperTableController = class SuperTableController extends _univerjs_core.Dis
|
|
|
3168
3112
|
this._descriptionService.unregisterDescriptions(functionList);
|
|
3169
3113
|
}
|
|
3170
3114
|
};
|
|
3171
|
-
SuperTableController = __decorate([
|
|
3172
|
-
__decorateParam(0, _univerjs_engine_formula.IDescriptionService),
|
|
3173
|
-
__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
3174
|
-
__decorateParam(2, _univerjs_core.ICommandService),
|
|
3175
|
-
__decorateParam(3, _univerjs_engine_formula.ISuperTableService)
|
|
3115
|
+
SuperTableController = require_worker.__decorate([
|
|
3116
|
+
require_worker.__decorateParam(0, _univerjs_engine_formula.IDescriptionService),
|
|
3117
|
+
require_worker.__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
3118
|
+
require_worker.__decorateParam(2, _univerjs_core.ICommandService),
|
|
3119
|
+
require_worker.__decorateParam(3, _univerjs_engine_formula.ISuperTableService)
|
|
3176
3120
|
], SuperTableController);
|
|
3177
3121
|
|
|
3178
|
-
|
|
3179
|
-
//#region src/services/formula-ref-range.service.ts
|
|
3122
|
+
// src/services/formula-ref-range.service.ts
|
|
3180
3123
|
function getFormulaKeyOffset(lexerTreeBuilder, formulaString, refOffsetX, refOffsetY) {
|
|
3181
3124
|
const sequenceNodes = lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
3182
3125
|
if (sequenceNodes == null) return formulaString;
|
|
@@ -3450,87 +3393,22 @@ let FormulaRefRangeService = class FormulaRefRangeService extends _univerjs_core
|
|
|
3450
3393
|
return disposableCollection;
|
|
3451
3394
|
}
|
|
3452
3395
|
};
|
|
3453
|
-
FormulaRefRangeService = __decorate([
|
|
3454
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.RefRangeService)),
|
|
3455
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder)),
|
|
3456
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
3457
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
3396
|
+
FormulaRefRangeService = require_worker.__decorate([
|
|
3397
|
+
require_worker.__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.RefRangeService)),
|
|
3398
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder)),
|
|
3399
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
3400
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
3458
3401
|
], FormulaRefRangeService);
|
|
3459
3402
|
|
|
3460
|
-
|
|
3461
|
-
//#region src/services/remote/remote-register-function.service.ts
|
|
3462
|
-
/**
|
|
3463
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3464
|
-
*
|
|
3465
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3466
|
-
* you may not use this file except in compliance with the License.
|
|
3467
|
-
* You may obtain a copy of the License at
|
|
3468
|
-
*
|
|
3469
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3470
|
-
*
|
|
3471
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3472
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3473
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3474
|
-
* See the License for the specific language governing permissions and
|
|
3475
|
-
* limitations under the License.
|
|
3476
|
-
*/
|
|
3477
|
-
const RemoteRegisterFunctionServiceName = "sheets-formula.remote-register-function.service";
|
|
3478
|
-
const IRemoteRegisterFunctionService = (0, _univerjs_core.createIdentifier)(RemoteRegisterFunctionServiceName);
|
|
3479
|
-
let RemoteRegisterFunctionService = class RemoteRegisterFunctionService {
|
|
3480
|
-
constructor(_functionService) {
|
|
3481
|
-
this._functionService = _functionService;
|
|
3482
|
-
}
|
|
3483
|
-
async registerFunctions(serializedFuncs) {
|
|
3484
|
-
rejectRemoteCustomFunctionRegistration(serializedFuncs);
|
|
3485
|
-
}
|
|
3486
|
-
async registerAsyncFunctions(serializedFuncs) {
|
|
3487
|
-
rejectRemoteCustomFunctionRegistration(serializedFuncs);
|
|
3488
|
-
}
|
|
3489
|
-
async unregisterFunctions(names) {
|
|
3490
|
-
this._functionService.unregisterExecutors(...names);
|
|
3491
|
-
this._functionService.unregisterDescriptions(...names);
|
|
3492
|
-
this._functionService.deleteFormulaAstCacheKey(...names);
|
|
3493
|
-
}
|
|
3494
|
-
};
|
|
3495
|
-
RemoteRegisterFunctionService = __decorate([__decorateParam(0, _univerjs_engine_formula.IFunctionService)], RemoteRegisterFunctionService);
|
|
3496
|
-
function rejectRemoteCustomFunctionRegistration(serializedFuncs) {
|
|
3497
|
-
if (serializedFuncs.length === 0) return;
|
|
3498
|
-
throw new Error("Remote custom function registration is disabled because function deserialization over RPC is unsafe.");
|
|
3499
|
-
}
|
|
3500
|
-
|
|
3501
|
-
//#endregion
|
|
3502
|
-
//#region src/plugin.ts
|
|
3503
|
-
let UniverRemoteSheetsFormulaPlugin = class UniverRemoteSheetsFormulaPlugin extends _univerjs_core.Plugin {
|
|
3504
|
-
constructor(_config = defaultPluginRemoteConfig, _injector, _configService) {
|
|
3505
|
-
super();
|
|
3506
|
-
this._config = _config;
|
|
3507
|
-
this._injector = _injector;
|
|
3508
|
-
this._configService = _configService;
|
|
3509
|
-
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginRemoteConfig, this._config);
|
|
3510
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_REMOTE, rest);
|
|
3511
|
-
}
|
|
3512
|
-
onStarting() {
|
|
3513
|
-
this._injector.add([RemoteRegisterFunctionService]);
|
|
3514
|
-
this._injector.get(_univerjs_rpc.IRPCChannelService).registerChannel(RemoteRegisterFunctionServiceName, (0, _univerjs_rpc.fromModule)(this._injector.get(RemoteRegisterFunctionService)));
|
|
3515
|
-
}
|
|
3516
|
-
};
|
|
3517
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "pluginName", "SHEET_FORMULA_REMOTE_PLUGIN");
|
|
3518
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "packageName", name);
|
|
3519
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "version", version);
|
|
3520
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3521
|
-
UniverRemoteSheetsFormulaPlugin = __decorate([
|
|
3522
|
-
(0, _univerjs_core.DependentOn)(_univerjs_engine_formula.UniverFormulaEnginePlugin),
|
|
3523
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3524
|
-
__decorateParam(2, _univerjs_core.IConfigService)
|
|
3525
|
-
], UniverRemoteSheetsFormulaPlugin);
|
|
3403
|
+
// src/plugin.ts
|
|
3526
3404
|
let UniverSheetsFormulaPlugin = class UniverSheetsFormulaPlugin extends _univerjs_core.Plugin {
|
|
3527
|
-
constructor(_config = defaultPluginBaseConfig, _injector, _configService) {
|
|
3405
|
+
constructor(_config = require_worker.defaultPluginBaseConfig, _injector, _configService) {
|
|
3528
3406
|
super();
|
|
3529
3407
|
this._config = _config;
|
|
3530
3408
|
this._injector = _injector;
|
|
3531
3409
|
this._configService = _configService;
|
|
3532
|
-
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginBaseConfig, this._config);
|
|
3533
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest, { merge: true });
|
|
3410
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, require_worker.defaultPluginBaseConfig, this._config);
|
|
3411
|
+
this._configService.setConfig(require_worker.PLUGIN_CONFIG_KEY_BASE, rest, { merge: true });
|
|
3534
3412
|
}
|
|
3535
3413
|
onStarting() {
|
|
3536
3414
|
var _this$_config$descrip;
|
|
@@ -3553,7 +3431,9 @@ let UniverSheetsFormulaPlugin = class UniverSheetsFormulaPlugin extends _univerj
|
|
|
3553
3431
|
];
|
|
3554
3432
|
if (this._config.notExecuteFormula) {
|
|
3555
3433
|
const rpcChannelService = j.get(_univerjs_rpc.IRPCChannelService);
|
|
3556
|
-
dependencies.push([IRemoteRegisterFunctionService, { useFactory:
|
|
3434
|
+
dependencies.push([require_worker.IRemoteRegisterFunctionService, { useFactory: function createChannelService() {
|
|
3435
|
+
return (0, _univerjs_rpc.toModule)(rpcChannelService.requestChannel(require_worker.RemoteRegisterFunctionServiceName));
|
|
3436
|
+
} }]);
|
|
3557
3437
|
}
|
|
3558
3438
|
dependencies.forEach((dependency) => j.add(dependency));
|
|
3559
3439
|
if ((_this$_config$descrip = this._config.description) === null || _this$_config$descrip === void 0 ? void 0 : _this$_config$descrip.length) this.disposeWithMe(j.get(_univerjs_engine_formula.IDescriptionService).registerDescriptions(this._config.description));
|
|
@@ -3578,18 +3458,17 @@ let UniverSheetsFormulaPlugin = class UniverSheetsFormulaPlugin extends _univerj
|
|
|
3578
3458
|
if (!(0, _univerjs_core.isNodeEnv)()) (0, _univerjs_core.touchDependencies)(this._injector, [[TriggerCalculationController]]);
|
|
3579
3459
|
}
|
|
3580
3460
|
};
|
|
3581
|
-
_defineProperty(UniverSheetsFormulaPlugin, "pluginName", SHEETS_FORMULA_PLUGIN_NAME);
|
|
3582
|
-
_defineProperty(UniverSheetsFormulaPlugin, "packageName", name);
|
|
3583
|
-
_defineProperty(UniverSheetsFormulaPlugin, "version", version);
|
|
3584
|
-
_defineProperty(UniverSheetsFormulaPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3585
|
-
UniverSheetsFormulaPlugin = __decorate([
|
|
3461
|
+
require_worker._defineProperty(UniverSheetsFormulaPlugin, "pluginName", SHEETS_FORMULA_PLUGIN_NAME);
|
|
3462
|
+
require_worker._defineProperty(UniverSheetsFormulaPlugin, "packageName", require_worker.name);
|
|
3463
|
+
require_worker._defineProperty(UniverSheetsFormulaPlugin, "version", require_worker.version);
|
|
3464
|
+
require_worker._defineProperty(UniverSheetsFormulaPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3465
|
+
UniverSheetsFormulaPlugin = require_worker.__decorate([
|
|
3586
3466
|
(0, _univerjs_core.DependentOn)(_univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_sheets.UniverSheetsPlugin),
|
|
3587
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3588
|
-
__decorateParam(2, _univerjs_core.IConfigService)
|
|
3467
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3468
|
+
require_worker.__decorateParam(2, _univerjs_core.IConfigService)
|
|
3589
3469
|
], UniverSheetsFormulaPlugin);
|
|
3590
3470
|
|
|
3591
|
-
|
|
3592
|
-
//#region src/util/calculate.ts
|
|
3471
|
+
// src/util/calculate.ts
|
|
3593
3472
|
function calculateFormula(inject, formulaString, unitId, sheetData) {
|
|
3594
3473
|
const formulaCurrentConfigService = inject.get(_univerjs_engine_formula.IFormulaCurrentConfigService);
|
|
3595
3474
|
const lexer = inject.get(_univerjs_engine_formula.Lexer);
|
|
@@ -3614,8 +3493,7 @@ function calculateFormula(inject, formulaString, unitId, sheetData) {
|
|
|
3614
3493
|
return (0, _univerjs_engine_formula.getObjectValue)(result);
|
|
3615
3494
|
}
|
|
3616
3495
|
|
|
3617
|
-
|
|
3618
|
-
exports.CalculationMode = CalculationMode;
|
|
3496
|
+
exports.CalculationMode = require_worker.CalculationMode;
|
|
3619
3497
|
Object.defineProperty(exports, "FormulaAutoFillController", {
|
|
3620
3498
|
enumerable: true,
|
|
3621
3499
|
get: function () {
|
|
@@ -3634,7 +3512,7 @@ Object.defineProperty(exports, "FormulaReorderController", {
|
|
|
3634
3512
|
return FormulaReorderController;
|
|
3635
3513
|
}
|
|
3636
3514
|
});
|
|
3637
|
-
exports.IRemoteRegisterFunctionService = IRemoteRegisterFunctionService;
|
|
3515
|
+
exports.IRemoteRegisterFunctionService = require_worker.IRemoteRegisterFunctionService;
|
|
3638
3516
|
Object.defineProperty(exports, "ImageFormulaCellInterceptorController", {
|
|
3639
3517
|
enumerable: true,
|
|
3640
3518
|
get: function () {
|
|
@@ -3642,11 +3520,11 @@ Object.defineProperty(exports, "ImageFormulaCellInterceptorController", {
|
|
|
3642
3520
|
}
|
|
3643
3521
|
});
|
|
3644
3522
|
exports.InsertFunctionCommand = InsertFunctionCommand;
|
|
3645
|
-
exports.PLUGIN_CONFIG_KEY_BASE = PLUGIN_CONFIG_KEY_BASE;
|
|
3523
|
+
exports.PLUGIN_CONFIG_KEY_BASE = require_worker.PLUGIN_CONFIG_KEY_BASE;
|
|
3646
3524
|
Object.defineProperty(exports, "RemoteRegisterFunctionService", {
|
|
3647
3525
|
enumerable: true,
|
|
3648
3526
|
get: function () {
|
|
3649
|
-
return RemoteRegisterFunctionService;
|
|
3527
|
+
return require_worker.RemoteRegisterFunctionService;
|
|
3650
3528
|
}
|
|
3651
3529
|
});
|
|
3652
3530
|
Object.defineProperty(exports, "TriggerCalculationController", {
|
|
@@ -3664,7 +3542,7 @@ Object.defineProperty(exports, "UnitQualifierRenameController", {
|
|
|
3664
3542
|
Object.defineProperty(exports, "UniverRemoteSheetsFormulaPlugin", {
|
|
3665
3543
|
enumerable: true,
|
|
3666
3544
|
get: function () {
|
|
3667
|
-
return UniverRemoteSheetsFormulaPlugin;
|
|
3545
|
+
return require_worker.UniverRemoteSheetsFormulaPlugin;
|
|
3668
3546
|
}
|
|
3669
3547
|
});
|
|
3670
3548
|
Object.defineProperty(exports, "UniverSheetsFormulaPlugin", {
|