@univerjs/engine-formula 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
|
@@ -10074,6 +10074,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10074
10074
|
_defineProperty(this, "_currentSubUnitId", "");
|
|
10075
10075
|
_defineProperty(this, "_currentUnitId", "");
|
|
10076
10076
|
_defineProperty(this, "_runtimeData", Object.create(null));
|
|
10077
|
+
_defineProperty(this, "_sourceFormulaData", Object.create(null));
|
|
10078
|
+
_defineProperty(this, "_currentSourceFormula", void 0);
|
|
10077
10079
|
_defineProperty(this, "_runtimeOtherData", Object.create(null));
|
|
10078
10080
|
_defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
|
|
10079
10081
|
_defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
|
|
@@ -10186,6 +10188,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10186
10188
|
reset() {
|
|
10187
10189
|
this._formulaExecuteStage = 0;
|
|
10188
10190
|
this._runtimeData = Object.create(null);
|
|
10191
|
+
this._sourceFormulaData = Object.create(null);
|
|
10192
|
+
this._currentSourceFormula = void 0;
|
|
10189
10193
|
this._runtimeOtherData = Object.create(null);
|
|
10190
10194
|
this._unitArrayFormulaRange = Object.create(null);
|
|
10191
10195
|
this._unitArrayFormulaEmbeddedMap = Object.create(null);
|
|
@@ -10207,6 +10211,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10207
10211
|
clearReferenceToRangeCache();
|
|
10208
10212
|
}
|
|
10209
10213
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
10214
|
+
var _this$_currentConfigS, _this$_currentConfigS2;
|
|
10210
10215
|
this._externalReferenceUnavailable = false;
|
|
10211
10216
|
this._currentRow = row;
|
|
10212
10217
|
this._currentColumn = column;
|
|
@@ -10214,6 +10219,18 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10214
10219
|
this._currentColumnCount = columnCount;
|
|
10215
10220
|
this._currentSubUnitId = sheetId;
|
|
10216
10221
|
this._currentUnitId = unitId;
|
|
10222
|
+
const cell = (_this$_currentConfigS = this._currentConfigService.getUnitData()[unitId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[sheetId]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS.cellData.getValue(row, column);
|
|
10223
|
+
const formula = (_this$_currentConfigS2 = this._currentConfigService.getFormulaData()[unitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[sheetId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[row]) === null || _this$_currentConfigS2 === void 0 ? void 0 : _this$_currentConfigS2[column];
|
|
10224
|
+
if (formula) {
|
|
10225
|
+
const isSharedFollower = (formula.x ?? 0) !== 0 || (formula.y ?? 0) !== 0;
|
|
10226
|
+
this._currentSourceFormula = {
|
|
10227
|
+
f: isSharedFollower ? "" : formula.f,
|
|
10228
|
+
si: formula.si
|
|
10229
|
+
};
|
|
10230
|
+
} else this._currentSourceFormula = (cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si) ? {
|
|
10231
|
+
f: cell.f ?? "",
|
|
10232
|
+
si: cell.si ?? void 0
|
|
10233
|
+
} : void 0;
|
|
10217
10234
|
}
|
|
10218
10235
|
setFunctionRefInfoOverride(rowCount, columnCount) {
|
|
10219
10236
|
this._functionRefInfoOverrideStack.push({
|
|
@@ -10264,9 +10281,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10264
10281
|
}
|
|
10265
10282
|
setRuntimeData(functionVariant) {
|
|
10266
10283
|
if (this._externalReferenceUnavailable) {
|
|
10267
|
-
var _this$
|
|
10268
|
-
const cell = (_this$
|
|
10269
|
-
const formula = (_this$
|
|
10284
|
+
var _this$_currentConfigS3, _this$_currentConfigS4;
|
|
10285
|
+
const cell = (_this$_currentConfigS3 = this._currentConfigService.getUnitData()[this._currentUnitId]) === null || _this$_currentConfigS3 === void 0 || (_this$_currentConfigS3 = _this$_currentConfigS3[this._currentSubUnitId]) === null || _this$_currentConfigS3 === void 0 ? void 0 : _this$_currentConfigS3.cellData.getValue(this._currentRow, this._currentColumn);
|
|
10286
|
+
const formula = (_this$_currentConfigS4 = this._currentConfigService.getFormulaData()[this._currentUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentSubUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentRow]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentColumn]) === null || _this$_currentConfigS4 === void 0 ? void 0 : _this$_currentConfigS4.f;
|
|
10270
10287
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) && cell.v != null && (formula == null || formula === cell.f)) return;
|
|
10271
10288
|
}
|
|
10272
10289
|
const row = this._currentRow;
|
|
@@ -10325,7 +10342,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10325
10342
|
const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
|
|
10326
10343
|
const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
|
|
10327
10344
|
if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
|
|
10328
|
-
var _this$
|
|
10345
|
+
var _this$_currentConfigS5;
|
|
10329
10346
|
const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
|
|
10330
10347
|
sheetData.setValue(row, column, errorObject);
|
|
10331
10348
|
clearArrayUnitData.setValue(row, column, errorObject);
|
|
@@ -10336,7 +10353,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10336
10353
|
*/
|
|
10337
10354
|
const unitData = this._currentConfigService.getUnitData();
|
|
10338
10355
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10339
|
-
const previousArrayFormulaRange = (_this$
|
|
10356
|
+
const previousArrayFormulaRange = (_this$_currentConfigS5 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[sheetId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[row]) === null || _this$_currentConfigS5 === void 0 ? void 0 : _this$_currentConfigS5[column];
|
|
10340
10357
|
objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
|
|
10341
10358
|
var _unitData$unitId, _arrayData$unitId;
|
|
10342
10359
|
const currentRow = rowIndex - startRow + row;
|
|
@@ -10376,6 +10393,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10376
10393
|
} else {
|
|
10377
10394
|
const valueObject = this._getValueObjectOfRuntimeData(functionVariant);
|
|
10378
10395
|
sheetData.setValue(row, column, valueObject);
|
|
10396
|
+
if (this._currentSourceFormula != null) {
|
|
10397
|
+
const unitFormulas = this._sourceFormulaData[unitId] ??= {};
|
|
10398
|
+
const sheetFormulas = unitFormulas[sheetId] ??= {};
|
|
10399
|
+
const rowFormulas = sheetFormulas[row] ??= {};
|
|
10400
|
+
rowFormulas[column] = { ...this._currentSourceFormula };
|
|
10401
|
+
}
|
|
10379
10402
|
if (functionVariant.isString() && functionVariant.isImage()) {
|
|
10380
10403
|
const imageInfo = functionVariant.getImageInfo();
|
|
10381
10404
|
if (imageInfo) this._runtimeImageFormulaData.push({
|
|
@@ -10447,6 +10470,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10447
10470
|
getAllRuntimeData() {
|
|
10448
10471
|
return {
|
|
10449
10472
|
unitData: this.getUnitData(),
|
|
10473
|
+
sourceFormulaData: this._sourceFormulaData,
|
|
10450
10474
|
arrayFormulaRange: this.getUnitArrayFormula(),
|
|
10451
10475
|
arrayFormulaEmbedded: this.getUnitArrayFormulaEmbeddedMap(),
|
|
10452
10476
|
unitOtherData: this.getRuntimeOtherData(),
|
|
@@ -10473,11 +10497,11 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10473
10497
|
FORMULA_REF_TO_ARRAY_CACHE.clear();
|
|
10474
10498
|
}
|
|
10475
10499
|
_checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
|
|
10476
|
-
var _this$
|
|
10500
|
+
var _this$_currentConfigS6;
|
|
10477
10501
|
const { startRow, startColumn, endRow, endColumn } = arrayRange;
|
|
10478
10502
|
const unitData = this._currentConfigService.getUnitData();
|
|
10479
10503
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10480
|
-
const previousArrayFormulaRange = (_this$
|
|
10504
|
+
const previousArrayFormulaRange = (_this$_currentConfigS6 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaSheetId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaRow]) === null || _this$_currentConfigS6 === void 0 ? void 0 : _this$_currentConfigS6[formulaColumn];
|
|
10481
10505
|
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
10482
10506
|
var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
|
|
10483
10507
|
if (r === formulaRow && formulaColumn === c) continue;
|
|
@@ -10513,8 +10537,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10513
10537
|
* @returns
|
|
10514
10538
|
*/
|
|
10515
10539
|
_isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
|
|
10516
|
-
var _this$
|
|
10517
|
-
const arrayFormulaRange = (_this$
|
|
10540
|
+
var _this$_currentConfigS7;
|
|
10541
|
+
const arrayFormulaRange = (_this$_currentConfigS7 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS7 === void 0 ? void 0 : _this$_currentConfigS7[formulaSheetId];
|
|
10518
10542
|
if (arrayFormulaRange == null) return false;
|
|
10519
10543
|
let isCellOverlapping = false;
|
|
10520
10544
|
new _univerjs_core.ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
|
|
@@ -10527,8 +10551,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10527
10551
|
return isCellOverlapping;
|
|
10528
10552
|
}
|
|
10529
10553
|
_isCurrentSingleCellArrayFormulaRange(unitId, sheetId, row, column) {
|
|
10530
|
-
var _this$
|
|
10531
|
-
const range = (_this$
|
|
10554
|
+
var _this$_currentConfigS8;
|
|
10555
|
+
const range = (_this$_currentConfigS8 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[sheetId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[row]) === null || _this$_currentConfigS8 === void 0 ? void 0 : _this$_currentConfigS8[column];
|
|
10532
10556
|
return range != null && range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
10533
10557
|
}
|
|
10534
10558
|
_isInArrayFormulaRange(range, r, c) {
|
|
@@ -14888,13 +14912,13 @@ let CalculateFormulaService = class CalculateFormulaService extends _univerjs_co
|
|
|
14888
14912
|
this._runtimeService.setRuntimeFeatureRange(featureId, featureRange);
|
|
14889
14913
|
}
|
|
14890
14914
|
async execute(formulaDatasetConfig) {
|
|
14891
|
-
this.
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14915
|
+
return this._executeLock.acquire("FORMULA_EXECUTION_LOCK", async () => {
|
|
14916
|
+
this._runtimeService.setFormulaExecuteStage(1);
|
|
14917
|
+
this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
|
|
14918
|
+
this._currentConfigService.load(formulaDatasetConfig);
|
|
14919
|
+
this._runtimeService.reset();
|
|
14920
|
+
const cycleReferenceCount = formulaDatasetConfig.maxIteration || 1;
|
|
14921
|
+
this._isCalculateTreeModel = formulaDatasetConfig.isCalculateTreeModel || false;
|
|
14898
14922
|
for (let i = 0; i < cycleReferenceCount; i++) {
|
|
14899
14923
|
this._runtimeService.setFormulaCycleIndex(i);
|
|
14900
14924
|
const executed = await this._executeStep();
|
|
@@ -15267,7 +15291,7 @@ let CalculateController = class CalculateController extends _univerjs_core.Dispo
|
|
|
15267
15291
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
15268
15292
|
}
|
|
15269
15293
|
async _applyResult(data) {
|
|
15270
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15294
|
+
const { unitData, sourceFormulaData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15271
15295
|
if (!unitData) {
|
|
15272
15296
|
this._applyTreeResult(data);
|
|
15273
15297
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15287,6 +15311,7 @@ let CalculateController = class CalculateController extends _univerjs_core.Dispo
|
|
|
15287
15311
|
this._applyTreeResult(data);
|
|
15288
15312
|
this._commandService.executeCommand(SetFormulaCalculationResultMutation.id, {
|
|
15289
15313
|
unitData: convertRuntimeToUnitData(unitData),
|
|
15314
|
+
sourceFormulaData,
|
|
15290
15315
|
unitOtherData
|
|
15291
15316
|
}, { onlyLocal: true });
|
|
15292
15317
|
}
|
|
@@ -43749,7 +43774,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
43749
43774
|
//#endregion
|
|
43750
43775
|
//#region package.json
|
|
43751
43776
|
var name = "@univerjs/engine-formula";
|
|
43752
|
-
var version = "1.0.
|
|
43777
|
+
var version = "1.0.4";
|
|
43753
43778
|
|
|
43754
43779
|
//#endregion
|
|
43755
43780
|
//#region src/services/global-computing-status.service.ts
|
package/lib/es/index.js
CHANGED
|
@@ -10044,6 +10044,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10044
10044
|
_defineProperty(this, "_currentSubUnitId", "");
|
|
10045
10045
|
_defineProperty(this, "_currentUnitId", "");
|
|
10046
10046
|
_defineProperty(this, "_runtimeData", Object.create(null));
|
|
10047
|
+
_defineProperty(this, "_sourceFormulaData", Object.create(null));
|
|
10048
|
+
_defineProperty(this, "_currentSourceFormula", void 0);
|
|
10047
10049
|
_defineProperty(this, "_runtimeOtherData", Object.create(null));
|
|
10048
10050
|
_defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
|
|
10049
10051
|
_defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
|
|
@@ -10156,6 +10158,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10156
10158
|
reset() {
|
|
10157
10159
|
this._formulaExecuteStage = 0;
|
|
10158
10160
|
this._runtimeData = Object.create(null);
|
|
10161
|
+
this._sourceFormulaData = Object.create(null);
|
|
10162
|
+
this._currentSourceFormula = void 0;
|
|
10159
10163
|
this._runtimeOtherData = Object.create(null);
|
|
10160
10164
|
this._unitArrayFormulaRange = Object.create(null);
|
|
10161
10165
|
this._unitArrayFormulaEmbeddedMap = Object.create(null);
|
|
@@ -10177,6 +10181,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10177
10181
|
clearReferenceToRangeCache();
|
|
10178
10182
|
}
|
|
10179
10183
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
10184
|
+
var _this$_currentConfigS, _this$_currentConfigS2;
|
|
10180
10185
|
this._externalReferenceUnavailable = false;
|
|
10181
10186
|
this._currentRow = row;
|
|
10182
10187
|
this._currentColumn = column;
|
|
@@ -10184,6 +10189,18 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10184
10189
|
this._currentColumnCount = columnCount;
|
|
10185
10190
|
this._currentSubUnitId = sheetId;
|
|
10186
10191
|
this._currentUnitId = unitId;
|
|
10192
|
+
const cell = (_this$_currentConfigS = this._currentConfigService.getUnitData()[unitId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[sheetId]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS.cellData.getValue(row, column);
|
|
10193
|
+
const formula = (_this$_currentConfigS2 = this._currentConfigService.getFormulaData()[unitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[sheetId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[row]) === null || _this$_currentConfigS2 === void 0 ? void 0 : _this$_currentConfigS2[column];
|
|
10194
|
+
if (formula) {
|
|
10195
|
+
const isSharedFollower = (formula.x ?? 0) !== 0 || (formula.y ?? 0) !== 0;
|
|
10196
|
+
this._currentSourceFormula = {
|
|
10197
|
+
f: isSharedFollower ? "" : formula.f,
|
|
10198
|
+
si: formula.si
|
|
10199
|
+
};
|
|
10200
|
+
} else this._currentSourceFormula = (cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si) ? {
|
|
10201
|
+
f: cell.f ?? "",
|
|
10202
|
+
si: cell.si ?? void 0
|
|
10203
|
+
} : void 0;
|
|
10187
10204
|
}
|
|
10188
10205
|
setFunctionRefInfoOverride(rowCount, columnCount) {
|
|
10189
10206
|
this._functionRefInfoOverrideStack.push({
|
|
@@ -10234,9 +10251,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10234
10251
|
}
|
|
10235
10252
|
setRuntimeData(functionVariant) {
|
|
10236
10253
|
if (this._externalReferenceUnavailable) {
|
|
10237
|
-
var _this$
|
|
10238
|
-
const cell = (_this$
|
|
10239
|
-
const formula = (_this$
|
|
10254
|
+
var _this$_currentConfigS3, _this$_currentConfigS4;
|
|
10255
|
+
const cell = (_this$_currentConfigS3 = this._currentConfigService.getUnitData()[this._currentUnitId]) === null || _this$_currentConfigS3 === void 0 || (_this$_currentConfigS3 = _this$_currentConfigS3[this._currentSubUnitId]) === null || _this$_currentConfigS3 === void 0 ? void 0 : _this$_currentConfigS3.cellData.getValue(this._currentRow, this._currentColumn);
|
|
10256
|
+
const formula = (_this$_currentConfigS4 = this._currentConfigService.getFormulaData()[this._currentUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentSubUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentRow]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentColumn]) === null || _this$_currentConfigS4 === void 0 ? void 0 : _this$_currentConfigS4.f;
|
|
10240
10257
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) && cell.v != null && (formula == null || formula === cell.f)) return;
|
|
10241
10258
|
}
|
|
10242
10259
|
const row = this._currentRow;
|
|
@@ -10295,7 +10312,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10295
10312
|
const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
|
|
10296
10313
|
const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
|
|
10297
10314
|
if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
|
|
10298
|
-
var _this$
|
|
10315
|
+
var _this$_currentConfigS5;
|
|
10299
10316
|
const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
|
|
10300
10317
|
sheetData.setValue(row, column, errorObject);
|
|
10301
10318
|
clearArrayUnitData.setValue(row, column, errorObject);
|
|
@@ -10306,7 +10323,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10306
10323
|
*/
|
|
10307
10324
|
const unitData = this._currentConfigService.getUnitData();
|
|
10308
10325
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10309
|
-
const previousArrayFormulaRange = (_this$
|
|
10326
|
+
const previousArrayFormulaRange = (_this$_currentConfigS5 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[sheetId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[row]) === null || _this$_currentConfigS5 === void 0 ? void 0 : _this$_currentConfigS5[column];
|
|
10310
10327
|
objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
|
|
10311
10328
|
var _unitData$unitId, _arrayData$unitId;
|
|
10312
10329
|
const currentRow = rowIndex - startRow + row;
|
|
@@ -10346,6 +10363,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10346
10363
|
} else {
|
|
10347
10364
|
const valueObject = this._getValueObjectOfRuntimeData(functionVariant);
|
|
10348
10365
|
sheetData.setValue(row, column, valueObject);
|
|
10366
|
+
if (this._currentSourceFormula != null) {
|
|
10367
|
+
const unitFormulas = this._sourceFormulaData[unitId] ??= {};
|
|
10368
|
+
const sheetFormulas = unitFormulas[sheetId] ??= {};
|
|
10369
|
+
const rowFormulas = sheetFormulas[row] ??= {};
|
|
10370
|
+
rowFormulas[column] = { ...this._currentSourceFormula };
|
|
10371
|
+
}
|
|
10349
10372
|
if (functionVariant.isString() && functionVariant.isImage()) {
|
|
10350
10373
|
const imageInfo = functionVariant.getImageInfo();
|
|
10351
10374
|
if (imageInfo) this._runtimeImageFormulaData.push({
|
|
@@ -10417,6 +10440,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10417
10440
|
getAllRuntimeData() {
|
|
10418
10441
|
return {
|
|
10419
10442
|
unitData: this.getUnitData(),
|
|
10443
|
+
sourceFormulaData: this._sourceFormulaData,
|
|
10420
10444
|
arrayFormulaRange: this.getUnitArrayFormula(),
|
|
10421
10445
|
arrayFormulaEmbedded: this.getUnitArrayFormulaEmbeddedMap(),
|
|
10422
10446
|
unitOtherData: this.getRuntimeOtherData(),
|
|
@@ -10443,11 +10467,11 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10443
10467
|
FORMULA_REF_TO_ARRAY_CACHE.clear();
|
|
10444
10468
|
}
|
|
10445
10469
|
_checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
|
|
10446
|
-
var _this$
|
|
10470
|
+
var _this$_currentConfigS6;
|
|
10447
10471
|
const { startRow, startColumn, endRow, endColumn } = arrayRange;
|
|
10448
10472
|
const unitData = this._currentConfigService.getUnitData();
|
|
10449
10473
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10450
|
-
const previousArrayFormulaRange = (_this$
|
|
10474
|
+
const previousArrayFormulaRange = (_this$_currentConfigS6 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaSheetId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaRow]) === null || _this$_currentConfigS6 === void 0 ? void 0 : _this$_currentConfigS6[formulaColumn];
|
|
10451
10475
|
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
10452
10476
|
var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
|
|
10453
10477
|
if (r === formulaRow && formulaColumn === c) continue;
|
|
@@ -10483,8 +10507,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10483
10507
|
* @returns
|
|
10484
10508
|
*/
|
|
10485
10509
|
_isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
|
|
10486
|
-
var _this$
|
|
10487
|
-
const arrayFormulaRange = (_this$
|
|
10510
|
+
var _this$_currentConfigS7;
|
|
10511
|
+
const arrayFormulaRange = (_this$_currentConfigS7 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS7 === void 0 ? void 0 : _this$_currentConfigS7[formulaSheetId];
|
|
10488
10512
|
if (arrayFormulaRange == null) return false;
|
|
10489
10513
|
let isCellOverlapping = false;
|
|
10490
10514
|
new ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
|
|
@@ -10497,8 +10521,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10497
10521
|
return isCellOverlapping;
|
|
10498
10522
|
}
|
|
10499
10523
|
_isCurrentSingleCellArrayFormulaRange(unitId, sheetId, row, column) {
|
|
10500
|
-
var _this$
|
|
10501
|
-
const range = (_this$
|
|
10524
|
+
var _this$_currentConfigS8;
|
|
10525
|
+
const range = (_this$_currentConfigS8 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[sheetId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[row]) === null || _this$_currentConfigS8 === void 0 ? void 0 : _this$_currentConfigS8[column];
|
|
10502
10526
|
return range != null && range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
10503
10527
|
}
|
|
10504
10528
|
_isInArrayFormulaRange(range, r, c) {
|
|
@@ -14858,13 +14882,13 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14858
14882
|
this._runtimeService.setRuntimeFeatureRange(featureId, featureRange);
|
|
14859
14883
|
}
|
|
14860
14884
|
async execute(formulaDatasetConfig) {
|
|
14861
|
-
this.
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14885
|
+
return this._executeLock.acquire("FORMULA_EXECUTION_LOCK", async () => {
|
|
14886
|
+
this._runtimeService.setFormulaExecuteStage(1);
|
|
14887
|
+
this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
|
|
14888
|
+
this._currentConfigService.load(formulaDatasetConfig);
|
|
14889
|
+
this._runtimeService.reset();
|
|
14890
|
+
const cycleReferenceCount = formulaDatasetConfig.maxIteration || 1;
|
|
14891
|
+
this._isCalculateTreeModel = formulaDatasetConfig.isCalculateTreeModel || false;
|
|
14868
14892
|
for (let i = 0; i < cycleReferenceCount; i++) {
|
|
14869
14893
|
this._runtimeService.setFormulaCycleIndex(i);
|
|
14870
14894
|
const executed = await this._executeStep();
|
|
@@ -15237,7 +15261,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
15237
15261
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
15238
15262
|
}
|
|
15239
15263
|
async _applyResult(data) {
|
|
15240
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15264
|
+
const { unitData, sourceFormulaData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15241
15265
|
if (!unitData) {
|
|
15242
15266
|
this._applyTreeResult(data);
|
|
15243
15267
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15257,6 +15281,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
15257
15281
|
this._applyTreeResult(data);
|
|
15258
15282
|
this._commandService.executeCommand(SetFormulaCalculationResultMutation.id, {
|
|
15259
15283
|
unitData: convertRuntimeToUnitData(unitData),
|
|
15284
|
+
sourceFormulaData,
|
|
15260
15285
|
unitOtherData
|
|
15261
15286
|
}, { onlyLocal: true });
|
|
15262
15287
|
}
|
|
@@ -43719,7 +43744,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
43719
43744
|
//#endregion
|
|
43720
43745
|
//#region package.json
|
|
43721
43746
|
var name = "@univerjs/engine-formula";
|
|
43722
|
-
var version = "1.0.
|
|
43747
|
+
var version = "1.0.4";
|
|
43723
43748
|
|
|
43724
43749
|
//#endregion
|
|
43725
43750
|
//#region src/services/global-computing-status.service.ts
|
package/lib/index.js
CHANGED
|
@@ -10044,6 +10044,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10044
10044
|
_defineProperty(this, "_currentSubUnitId", "");
|
|
10045
10045
|
_defineProperty(this, "_currentUnitId", "");
|
|
10046
10046
|
_defineProperty(this, "_runtimeData", Object.create(null));
|
|
10047
|
+
_defineProperty(this, "_sourceFormulaData", Object.create(null));
|
|
10048
|
+
_defineProperty(this, "_currentSourceFormula", void 0);
|
|
10047
10049
|
_defineProperty(this, "_runtimeOtherData", Object.create(null));
|
|
10048
10050
|
_defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
|
|
10049
10051
|
_defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
|
|
@@ -10156,6 +10158,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10156
10158
|
reset() {
|
|
10157
10159
|
this._formulaExecuteStage = 0;
|
|
10158
10160
|
this._runtimeData = Object.create(null);
|
|
10161
|
+
this._sourceFormulaData = Object.create(null);
|
|
10162
|
+
this._currentSourceFormula = void 0;
|
|
10159
10163
|
this._runtimeOtherData = Object.create(null);
|
|
10160
10164
|
this._unitArrayFormulaRange = Object.create(null);
|
|
10161
10165
|
this._unitArrayFormulaEmbeddedMap = Object.create(null);
|
|
@@ -10177,6 +10181,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10177
10181
|
clearReferenceToRangeCache();
|
|
10178
10182
|
}
|
|
10179
10183
|
setCurrent(row, column, rowCount, columnCount, sheetId, unitId) {
|
|
10184
|
+
var _this$_currentConfigS, _this$_currentConfigS2;
|
|
10180
10185
|
this._externalReferenceUnavailable = false;
|
|
10181
10186
|
this._currentRow = row;
|
|
10182
10187
|
this._currentColumn = column;
|
|
@@ -10184,6 +10189,18 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10184
10189
|
this._currentColumnCount = columnCount;
|
|
10185
10190
|
this._currentSubUnitId = sheetId;
|
|
10186
10191
|
this._currentUnitId = unitId;
|
|
10192
|
+
const cell = (_this$_currentConfigS = this._currentConfigService.getUnitData()[unitId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[sheetId]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS.cellData.getValue(row, column);
|
|
10193
|
+
const formula = (_this$_currentConfigS2 = this._currentConfigService.getFormulaData()[unitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[sheetId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[row]) === null || _this$_currentConfigS2 === void 0 ? void 0 : _this$_currentConfigS2[column];
|
|
10194
|
+
if (formula) {
|
|
10195
|
+
const isSharedFollower = (formula.x ?? 0) !== 0 || (formula.y ?? 0) !== 0;
|
|
10196
|
+
this._currentSourceFormula = {
|
|
10197
|
+
f: isSharedFollower ? "" : formula.f,
|
|
10198
|
+
si: formula.si
|
|
10199
|
+
};
|
|
10200
|
+
} else this._currentSourceFormula = (cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si) ? {
|
|
10201
|
+
f: cell.f ?? "",
|
|
10202
|
+
si: cell.si ?? void 0
|
|
10203
|
+
} : void 0;
|
|
10187
10204
|
}
|
|
10188
10205
|
setFunctionRefInfoOverride(rowCount, columnCount) {
|
|
10189
10206
|
this._functionRefInfoOverrideStack.push({
|
|
@@ -10234,9 +10251,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10234
10251
|
}
|
|
10235
10252
|
setRuntimeData(functionVariant) {
|
|
10236
10253
|
if (this._externalReferenceUnavailable) {
|
|
10237
|
-
var _this$
|
|
10238
|
-
const cell = (_this$
|
|
10239
|
-
const formula = (_this$
|
|
10254
|
+
var _this$_currentConfigS3, _this$_currentConfigS4;
|
|
10255
|
+
const cell = (_this$_currentConfigS3 = this._currentConfigService.getUnitData()[this._currentUnitId]) === null || _this$_currentConfigS3 === void 0 || (_this$_currentConfigS3 = _this$_currentConfigS3[this._currentSubUnitId]) === null || _this$_currentConfigS3 === void 0 ? void 0 : _this$_currentConfigS3.cellData.getValue(this._currentRow, this._currentColumn);
|
|
10256
|
+
const formula = (_this$_currentConfigS4 = this._currentConfigService.getFormulaData()[this._currentUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentSubUnitId]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentRow]) === null || _this$_currentConfigS4 === void 0 || (_this$_currentConfigS4 = _this$_currentConfigS4[this._currentColumn]) === null || _this$_currentConfigS4 === void 0 ? void 0 : _this$_currentConfigS4.f;
|
|
10240
10257
|
if ((cell === null || cell === void 0 ? void 0 : cell.f) && cell.v != null && (formula == null || formula === cell.f)) return;
|
|
10241
10258
|
}
|
|
10242
10259
|
const row = this._currentRow;
|
|
@@ -10295,7 +10312,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10295
10312
|
const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
|
|
10296
10313
|
const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
|
|
10297
10314
|
if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
|
|
10298
|
-
var _this$
|
|
10315
|
+
var _this$_currentConfigS5;
|
|
10299
10316
|
const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
|
|
10300
10317
|
sheetData.setValue(row, column, errorObject);
|
|
10301
10318
|
clearArrayUnitData.setValue(row, column, errorObject);
|
|
@@ -10306,7 +10323,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10306
10323
|
*/
|
|
10307
10324
|
const unitData = this._currentConfigService.getUnitData();
|
|
10308
10325
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10309
|
-
const previousArrayFormulaRange = (_this$
|
|
10326
|
+
const previousArrayFormulaRange = (_this$_currentConfigS5 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[sheetId]) === null || _this$_currentConfigS5 === void 0 || (_this$_currentConfigS5 = _this$_currentConfigS5[row]) === null || _this$_currentConfigS5 === void 0 ? void 0 : _this$_currentConfigS5[column];
|
|
10310
10327
|
objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
|
|
10311
10328
|
var _unitData$unitId, _arrayData$unitId;
|
|
10312
10329
|
const currentRow = rowIndex - startRow + row;
|
|
@@ -10346,6 +10363,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10346
10363
|
} else {
|
|
10347
10364
|
const valueObject = this._getValueObjectOfRuntimeData(functionVariant);
|
|
10348
10365
|
sheetData.setValue(row, column, valueObject);
|
|
10366
|
+
if (this._currentSourceFormula != null) {
|
|
10367
|
+
const unitFormulas = this._sourceFormulaData[unitId] ??= {};
|
|
10368
|
+
const sheetFormulas = unitFormulas[sheetId] ??= {};
|
|
10369
|
+
const rowFormulas = sheetFormulas[row] ??= {};
|
|
10370
|
+
rowFormulas[column] = { ...this._currentSourceFormula };
|
|
10371
|
+
}
|
|
10349
10372
|
if (functionVariant.isString() && functionVariant.isImage()) {
|
|
10350
10373
|
const imageInfo = functionVariant.getImageInfo();
|
|
10351
10374
|
if (imageInfo) this._runtimeImageFormulaData.push({
|
|
@@ -10417,6 +10440,7 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10417
10440
|
getAllRuntimeData() {
|
|
10418
10441
|
return {
|
|
10419
10442
|
unitData: this.getUnitData(),
|
|
10443
|
+
sourceFormulaData: this._sourceFormulaData,
|
|
10420
10444
|
arrayFormulaRange: this.getUnitArrayFormula(),
|
|
10421
10445
|
arrayFormulaEmbedded: this.getUnitArrayFormulaEmbeddedMap(),
|
|
10422
10446
|
unitOtherData: this.getRuntimeOtherData(),
|
|
@@ -10443,11 +10467,11 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10443
10467
|
FORMULA_REF_TO_ARRAY_CACHE.clear();
|
|
10444
10468
|
}
|
|
10445
10469
|
_checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
|
|
10446
|
-
var _this$
|
|
10470
|
+
var _this$_currentConfigS6;
|
|
10447
10471
|
const { startRow, startColumn, endRow, endColumn } = arrayRange;
|
|
10448
10472
|
const unitData = this._currentConfigService.getUnitData();
|
|
10449
10473
|
const arrayData = this._currentConfigService.getArrayFormulaCellData();
|
|
10450
|
-
const previousArrayFormulaRange = (_this$
|
|
10474
|
+
const previousArrayFormulaRange = (_this$_currentConfigS6 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaSheetId]) === null || _this$_currentConfigS6 === void 0 || (_this$_currentConfigS6 = _this$_currentConfigS6[formulaRow]) === null || _this$_currentConfigS6 === void 0 ? void 0 : _this$_currentConfigS6[formulaColumn];
|
|
10451
10475
|
for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
|
|
10452
10476
|
var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
|
|
10453
10477
|
if (r === formulaRow && formulaColumn === c) continue;
|
|
@@ -10483,8 +10507,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10483
10507
|
* @returns
|
|
10484
10508
|
*/
|
|
10485
10509
|
_isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
|
|
10486
|
-
var _this$
|
|
10487
|
-
const arrayFormulaRange = (_this$
|
|
10510
|
+
var _this$_currentConfigS7;
|
|
10511
|
+
const arrayFormulaRange = (_this$_currentConfigS7 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS7 === void 0 ? void 0 : _this$_currentConfigS7[formulaSheetId];
|
|
10488
10512
|
if (arrayFormulaRange == null) return false;
|
|
10489
10513
|
let isCellOverlapping = false;
|
|
10490
10514
|
new ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
|
|
@@ -10497,8 +10521,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
|
|
|
10497
10521
|
return isCellOverlapping;
|
|
10498
10522
|
}
|
|
10499
10523
|
_isCurrentSingleCellArrayFormulaRange(unitId, sheetId, row, column) {
|
|
10500
|
-
var _this$
|
|
10501
|
-
const range = (_this$
|
|
10524
|
+
var _this$_currentConfigS8;
|
|
10525
|
+
const range = (_this$_currentConfigS8 = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[sheetId]) === null || _this$_currentConfigS8 === void 0 || (_this$_currentConfigS8 = _this$_currentConfigS8[row]) === null || _this$_currentConfigS8 === void 0 ? void 0 : _this$_currentConfigS8[column];
|
|
10502
10526
|
return range != null && range.startRow === range.endRow && range.startColumn === range.endColumn;
|
|
10503
10527
|
}
|
|
10504
10528
|
_isInArrayFormulaRange(range, r, c) {
|
|
@@ -14858,13 +14882,13 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
|
|
|
14858
14882
|
this._runtimeService.setRuntimeFeatureRange(featureId, featureRange);
|
|
14859
14883
|
}
|
|
14860
14884
|
async execute(formulaDatasetConfig) {
|
|
14861
|
-
this.
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14885
|
+
return this._executeLock.acquire("FORMULA_EXECUTION_LOCK", async () => {
|
|
14886
|
+
this._runtimeService.setFormulaExecuteStage(1);
|
|
14887
|
+
this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
|
|
14888
|
+
this._currentConfigService.load(formulaDatasetConfig);
|
|
14889
|
+
this._runtimeService.reset();
|
|
14890
|
+
const cycleReferenceCount = formulaDatasetConfig.maxIteration || 1;
|
|
14891
|
+
this._isCalculateTreeModel = formulaDatasetConfig.isCalculateTreeModel || false;
|
|
14868
14892
|
for (let i = 0; i < cycleReferenceCount; i++) {
|
|
14869
14893
|
this._runtimeService.setFormulaCycleIndex(i);
|
|
14870
14894
|
const executed = await this._executeStep();
|
|
@@ -15237,7 +15261,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
15237
15261
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
15238
15262
|
}
|
|
15239
15263
|
async _applyResult(data) {
|
|
15240
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15264
|
+
const { unitData, sourceFormulaData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
15241
15265
|
if (!unitData) {
|
|
15242
15266
|
this._applyTreeResult(data);
|
|
15243
15267
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15257,6 +15281,7 @@ let CalculateController = class CalculateController extends Disposable {
|
|
|
15257
15281
|
this._applyTreeResult(data);
|
|
15258
15282
|
this._commandService.executeCommand(SetFormulaCalculationResultMutation.id, {
|
|
15259
15283
|
unitData: convertRuntimeToUnitData(unitData),
|
|
15284
|
+
sourceFormulaData,
|
|
15260
15285
|
unitOtherData
|
|
15261
15286
|
}, { onlyLocal: true });
|
|
15262
15287
|
}
|
|
@@ -43719,7 +43744,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
43719
43744
|
//#endregion
|
|
43720
43745
|
//#region package.json
|
|
43721
43746
|
var name = "@univerjs/engine-formula";
|
|
43722
|
-
var version = "1.0.
|
|
43747
|
+
var version = "1.0.4";
|
|
43723
43748
|
|
|
43724
43749
|
//#endregion
|
|
43725
43750
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
17
|
-
import type { IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
17
|
+
import type { IFormulaData, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
18
18
|
import type { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults } from '../../engine/dependency/dependency-tree';
|
|
19
19
|
import type { IFormulaDirtyData } from '../../services/current-data.service';
|
|
20
20
|
import type { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
|
|
@@ -73,6 +73,7 @@ export interface ISetFormulaCalculationNotificationMutation {
|
|
|
73
73
|
export declare const SetFormulaCalculationNotificationMutation: IMutation<ISetFormulaCalculationNotificationMutation>;
|
|
74
74
|
export interface ISetFormulaCalculationResultMutation {
|
|
75
75
|
unitData: IRuntimeUnitDataPrimitiveType;
|
|
76
|
+
sourceFormulaData?: IFormulaData;
|
|
76
77
|
unitOtherData: IRuntimeOtherUnitDataType;
|
|
77
78
|
}
|
|
78
79
|
export declare const SetFormulaCalculationResultMutation: IMutation<ISetFormulaCalculationResultMutation>;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
-
import type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IFeatureDirtyRangeType, IRuntimeImageFormulaDataType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
17
|
+
import type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IFeatureDirtyRangeType, IFormulaData, IRuntimeImageFormulaDataType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
18
18
|
import type { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
19
19
|
import type { IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
20
20
|
import type { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
@@ -44,6 +44,7 @@ export declare enum FormulaExecutedStateType {
|
|
|
44
44
|
}
|
|
45
45
|
export interface IAllRuntimeData {
|
|
46
46
|
unitData: IRuntimeUnitDataType;
|
|
47
|
+
sourceFormulaData?: IFormulaData;
|
|
47
48
|
arrayFormulaRange: IArrayFormulaRangeType;
|
|
48
49
|
arrayFormulaEmbedded: IArrayFormulaEmbeddedMap;
|
|
49
50
|
unitOtherData: IRuntimeOtherUnitDataType;
|
|
@@ -140,6 +141,8 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
140
141
|
private _currentSubUnitId;
|
|
141
142
|
private _currentUnitId;
|
|
142
143
|
private _runtimeData;
|
|
144
|
+
private _sourceFormulaData;
|
|
145
|
+
private _currentSourceFormula;
|
|
143
146
|
private _runtimeOtherData;
|
|
144
147
|
private _unitArrayFormulaRange;
|
|
145
148
|
private _unitArrayFormulaEmbeddedMap;
|