@odoo/o-spreadsheet 19.0.16 → 19.0.18

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.0.16
6
- * @date 2026-01-07T16:21:15.857Z
7
- * @hash 9f3f13a
5
+ * @version 19.0.18
6
+ * @date 2026-01-21T11:06:57.346Z
7
+ * @hash bd44f59
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -41,7 +41,8 @@
41
41
  return children
42
42
  .map((child) => (typeof child === "function" ? child(env) : child))
43
43
  .flat()
44
- .map(createAction);
44
+ .map(createAction)
45
+ .sort((a, b) => a.sequence - b.sequence);
45
46
  }
46
47
  : () => [],
47
48
  isReadonlyAllowed: item.isReadonlyAllowed || false,
@@ -781,6 +782,7 @@
781
782
  fillColor: "",
782
783
  textColor: "",
783
784
  };
785
+ const DEFAULT_NUMBER_STYLE = { ...DEFAULT_STYLE, align: "right" };
784
786
  const DEFAULT_VERTICAL_ALIGN = DEFAULT_STYLE.verticalAlign;
785
787
  const DEFAULT_WRAPPING_MODE = DEFAULT_STYLE.wrapping;
786
788
  // Fonts
@@ -5027,7 +5029,11 @@
5027
5029
  if (operator === "<>" || operator === "=") {
5028
5030
  let result;
5029
5031
  if (typeof value === typeof operand) {
5030
- if (typeof value === "string" && typeof operand === "string") {
5032
+ if (value === "" && operand === "") {
5033
+ // fast path to avoid regex evaluation
5034
+ result = true;
5035
+ }
5036
+ else if (typeof value === "string" && typeof operand === "string") {
5031
5037
  result = wildcardToRegExp(operand).test(value);
5032
5038
  }
5033
5039
  else {
@@ -7053,7 +7059,7 @@
7053
7059
  const groups = groupConsecutive(elements);
7054
7060
  return (range) => {
7055
7061
  if (range.sheetId !== cmd.sheetId) {
7056
- return { changeType: "NONE" };
7062
+ return { changeType: "NONE", range };
7057
7063
  }
7058
7064
  let newRange = range;
7059
7065
  let changeType = "NONE";
@@ -7080,10 +7086,7 @@
7080
7086
  newRange = createAdaptedRange(newRange, dimension, changeType, -(max - min + 1));
7081
7087
  }
7082
7088
  }
7083
- if (changeType !== "NONE") {
7084
- return { changeType, range: newRange };
7085
- }
7086
- return { changeType: "NONE" };
7089
+ return { changeType, range: newRange };
7087
7090
  };
7088
7091
  }
7089
7092
  function getApplyRangeChangeAddColRow(cmd) {
@@ -7092,7 +7095,7 @@
7092
7095
  const dimension = cmd.dimension === "COL" ? "columns" : "rows";
7093
7096
  return (range) => {
7094
7097
  if (range.sheetId !== cmd.sheetId) {
7095
- return { changeType: "NONE" };
7098
+ return { changeType: "NONE", range };
7096
7099
  }
7097
7100
  if (cmd.position === "after") {
7098
7101
  if (range.zone[start] <= cmd.base && cmd.base < range.zone[end]) {
@@ -7122,13 +7125,13 @@
7122
7125
  };
7123
7126
  }
7124
7127
  }
7125
- return { changeType: "NONE" };
7128
+ return { changeType: "NONE", range };
7126
7129
  };
7127
7130
  }
7128
7131
  function getApplyRangeChangeDeleteSheet(cmd) {
7129
7132
  return (range) => {
7130
7133
  if (range.sheetId !== cmd.sheetId && range.invalidSheetName !== cmd.sheetName) {
7131
- return { changeType: "NONE" };
7134
+ return { changeType: "NONE", range };
7132
7135
  }
7133
7136
  const invalidSheetName = cmd.sheetName;
7134
7137
  range = {
@@ -7155,14 +7158,14 @@
7155
7158
  const newRange = { ...range, sheetId, invalidSheetName };
7156
7159
  return { changeType: "CHANGE", range: newRange };
7157
7160
  }
7158
- return { changeType: "NONE" };
7161
+ return { changeType: "NONE", range };
7159
7162
  };
7160
7163
  }
7161
7164
  function getApplyRangeChangeMoveRange(cmd) {
7162
7165
  const originZone = cmd.target[0];
7163
7166
  return (range) => {
7164
7167
  if (range.sheetId !== cmd.sheetId || !isZoneInside(range.zone, originZone)) {
7165
- return { changeType: "NONE" };
7168
+ return { changeType: "NONE", range };
7166
7169
  }
7167
7170
  const targetSheetId = cmd.targetSheetId;
7168
7171
  const offsetX = cmd.col - originZone.left;
@@ -7328,11 +7331,20 @@
7328
7331
  /**
7329
7332
  * Get the default height of the cell given its style.
7330
7333
  */
7331
- function getDefaultCellHeight(ctx, cell, colSize) {
7334
+ function getDefaultCellHeight(ctx, cell, locale, colSize) {
7332
7335
  if (!cell || (!cell.isFormula && !cell.content)) {
7333
7336
  return DEFAULT_CELL_HEIGHT;
7334
7337
  }
7335
- const content = cell.isFormula ? "" : cell.content;
7338
+ let content = "";
7339
+ try {
7340
+ if (!cell.isFormula) {
7341
+ const localeFormat = { format: cell.format, locale };
7342
+ content = formatValue(parseLiteral(cell.content, locale), localeFormat);
7343
+ }
7344
+ }
7345
+ catch {
7346
+ content = CellErrorType.GenericError;
7347
+ }
7336
7348
  return getCellContentHeight(ctx, content, cell.style, colSize);
7337
7349
  }
7338
7350
  function getCellContentHeight(ctx, content, style, colSize) {
@@ -20099,9 +20111,10 @@ stores.inject(MyMetaStore, storeInstance);
20099
20111
  throw new EvaluationError(_t("Function PIVOT takes an even number of arguments."));
20100
20112
  }
20101
20113
  }
20102
- function addPivotDependencies(evalContext, coreDefinition, forMeasures) {
20114
+ function addPivotDependencies(evalContext, pivotId, forMeasures) {
20103
20115
  //TODO This function can be very costly when used with PIVOT.VALUE and PIVOT.HEADER
20104
20116
  const dependencies = [];
20117
+ const coreDefinition = evalContext.getters.getPivotCoreDefinition(pivotId);
20105
20118
  if (coreDefinition.type === "SPREADSHEET" && coreDefinition.dataSet) {
20106
20119
  const { sheetId, zone } = coreDefinition.dataSet;
20107
20120
  const xc = zoneToXc(zone);
@@ -20118,8 +20131,7 @@ stores.inject(MyMetaStore, storeInstance);
20118
20131
  }
20119
20132
  for (const measure of forMeasures) {
20120
20133
  if (measure.computedBy) {
20121
- const formula = evalContext.getters.getMeasureCompiledFormula(measure);
20122
- dependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
20134
+ dependencies.push(...evalContext.getters.getMeasureFullDependencies(pivotId, measure));
20123
20135
  }
20124
20136
  }
20125
20137
  const originPosition = evalContext.__originCellPosition;
@@ -20616,7 +20628,7 @@ stores.inject(MyMetaStore, storeInstance);
20616
20628
  assertDomainLength(domainArgs);
20617
20629
  const pivot = this.getters.getPivot(pivotId);
20618
20630
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
20619
- addPivotDependencies(this, coreDefinition, coreDefinition.measures.filter((m) => m.id === _measure));
20631
+ addPivotDependencies(this, pivotId, coreDefinition.measures.filter((m) => m.id === _measure));
20620
20632
  pivot.init({ reload: pivot.needsReevaluation });
20621
20633
  const error = pivot.assertIsValid({ throwOnError: false });
20622
20634
  if (error) {
@@ -20649,8 +20661,7 @@ stores.inject(MyMetaStore, storeInstance);
20649
20661
  const _pivotId = getPivotId(_pivotFormulaId, this.getters);
20650
20662
  assertDomainLength(domainArgs);
20651
20663
  const pivot = this.getters.getPivot(_pivotId);
20652
- const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
20653
- addPivotDependencies(this, coreDefinition, []);
20664
+ addPivotDependencies(this, _pivotId, []);
20654
20665
  pivot.init({ reload: pivot.needsReevaluation });
20655
20666
  const error = pivot.assertIsValid({ throwOnError: false });
20656
20667
  if (error) {
@@ -20708,7 +20719,7 @@ stores.inject(MyMetaStore, storeInstance);
20708
20719
  const pivotId = getPivotId(_pivotFormulaId, this.getters);
20709
20720
  const pivot = this.getters.getPivot(pivotId);
20710
20721
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
20711
- addPivotDependencies(this, coreDefinition, coreDefinition.measures);
20722
+ addPivotDependencies(this, pivotId, coreDefinition.measures);
20712
20723
  pivot.init({ reload: pivot.needsReevaluation });
20713
20724
  const error = pivot.assertIsValid({ throwOnError: false });
20714
20725
  if (error) {
@@ -22227,7 +22238,16 @@ stores.inject(MyMetaStore, storeInstance);
22227
22238
  }
22228
22239
  acceptToVectorize.push(!argDefinition.acceptMatrix);
22229
22240
  }
22230
- return applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize);
22241
+ return replaceErrorPlaceholderInResult(applyVectorization(errorHandlingCompute.bind(this), args, acceptToVectorize));
22242
+ }
22243
+ function replaceErrorPlaceholderInResult(result) {
22244
+ if (!isMatrix(result)) {
22245
+ replaceFunctionNamePlaceholder(result, descr.name);
22246
+ }
22247
+ else {
22248
+ matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
22249
+ }
22250
+ return result;
22231
22251
  }
22232
22252
  function errorHandlingCompute(...args) {
22233
22253
  for (let i = 0; i < args.length; i++) {
@@ -22256,13 +22276,12 @@ stores.inject(MyMetaStore, storeInstance);
22256
22276
  const result = descr.compute.apply(this, args);
22257
22277
  if (!isMatrix(result)) {
22258
22278
  if (typeof result === "object" && result !== null && "value" in result) {
22259
- replaceFunctionNamePlaceholder(result, descr.name);
22260
22279
  return result;
22261
22280
  }
22281
+ descr.name;
22262
22282
  return { value: result };
22263
22283
  }
22264
22284
  if (typeof result[0][0] === "object" && result[0][0] !== null && "value" in result[0][0]) {
22265
- matrixForEach(result, (result) => replaceFunctionNamePlaceholder(result, descr.name));
22266
22285
  return result;
22267
22286
  }
22268
22287
  return matrixMap(result, (row) => ({ value: row }));
@@ -22775,7 +22794,7 @@ stores.inject(MyMetaStore, storeInstance);
22775
22794
  continue;
22776
22795
  }
22777
22796
  const sheetXC = tokens[tokenIdx].value;
22778
- const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange);
22797
+ const newSheetXC = adaptStringRange(defaultSheetId, sheetXC, applyChange).range;
22779
22798
  if (sheetXC !== newSheetXC) {
22780
22799
  tokens[tokenIdx] = {
22781
22800
  value: newSheetXC,
@@ -22785,23 +22804,30 @@ stores.inject(MyMetaStore, storeInstance);
22785
22804
  }
22786
22805
  return concat$1(tokens.map((token) => token.value));
22787
22806
  }
22788
- function adaptStringRange(defaultSheetId, sheetXC, applyChange) {
22807
+ function adaptStringRange(defaultSheetId, sheetXC, rangeAdapter) {
22789
22808
  const sheetName = splitReference(sheetXC).sheetName;
22790
22809
  if (sheetName
22791
- ? !isSheetNameEqual(sheetName, applyChange.sheetName.old)
22792
- : defaultSheetId !== applyChange.sheetId) {
22793
- return sheetXC;
22810
+ ? !isSheetNameEqual(sheetName, rangeAdapter.sheetName.old)
22811
+ : defaultSheetId !== rangeAdapter.sheetId) {
22812
+ return { changeType: "NONE", range: sheetXC };
22794
22813
  }
22795
- const sheetId = sheetName ? applyChange.sheetId : defaultSheetId;
22814
+ const sheetId = sheetName ? rangeAdapter.sheetId : defaultSheetId;
22796
22815
  const range = getRange(sheetXC, sheetId);
22797
22816
  if (range.invalidXc) {
22798
- return sheetXC;
22817
+ return { changeType: "NONE", range: sheetXC };
22799
22818
  }
22800
- const change = applyChange.applyChange(range);
22819
+ const change = rangeAdapter.applyChange(range);
22801
22820
  if (change.changeType === "NONE" || change.changeType === "REMOVE") {
22802
- return sheetXC;
22821
+ return { changeType: change.changeType, range: sheetXC };
22803
22822
  }
22804
- return getRangeString(change.range, defaultSheetId, getSheetNameGetter(applyChange));
22823
+ const rangeStr = getRangeString(change.range, defaultSheetId, getSheetNameGetter(rangeAdapter));
22824
+ if (rangeStr === CellErrorType.InvalidReference) {
22825
+ return { changeType: "REMOVE", range: rangeStr };
22826
+ }
22827
+ return {
22828
+ changeType: change.changeType,
22829
+ range: rangeStr,
22830
+ };
22805
22831
  }
22806
22832
  function getSheetNameGetter(applyChange) {
22807
22833
  return (sheetId) => {
@@ -22906,8 +22932,6 @@ stores.inject(MyMetaStore, storeInstance);
22906
22932
  }
22907
22933
  const change = applyChange(range);
22908
22934
  switch (change.changeType) {
22909
- case "NONE":
22910
- return range;
22911
22935
  case "REMOVE":
22912
22936
  return undefined;
22913
22937
  default:
@@ -23059,16 +23083,16 @@ stores.inject(MyMetaStore, storeInstance);
23059
23083
  function transformChartDefinitionWithDataSetsWithZone(chartSheetId, definition, applyChange) {
23060
23084
  let labelRange;
23061
23085
  if (definition.labelRange) {
23062
- const adaptedRange = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
23063
- if (adaptedRange !== CellErrorType.InvalidReference) {
23086
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.labelRange, applyChange);
23087
+ if (changeType !== "REMOVE") {
23064
23088
  labelRange = adaptedRange;
23065
23089
  }
23066
23090
  }
23067
23091
  const dataSets = [];
23068
23092
  for (const dataSet of definition.dataSets) {
23069
23093
  const newDataSet = { ...dataSet };
23070
- const adaptedRange = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
23071
- if (adaptedRange !== CellErrorType.InvalidReference) {
23094
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, dataSet.dataRange, applyChange);
23095
+ if (changeType !== "REMOVE") {
23072
23096
  newDataSet.dataRange = adaptedRange;
23073
23097
  dataSets.push(newDataSet);
23074
23098
  }
@@ -24467,14 +24491,14 @@ stores.inject(MyMetaStore, storeInstance);
24467
24491
  let baseline;
24468
24492
  let keyValue;
24469
24493
  if (definition.baseline) {
24470
- const adaptedRange = adaptStringRange(chartSheetId, definition.baseline, applyChange);
24471
- if (adaptedRange !== CellErrorType.InvalidReference) {
24494
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.baseline, applyChange);
24495
+ if (changeType !== "REMOVE") {
24472
24496
  baseline = adaptedRange;
24473
24497
  }
24474
24498
  }
24475
24499
  if (definition.keyValue) {
24476
- const adaptedRange = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
24477
- if (adaptedRange !== CellErrorType.InvalidReference) {
24500
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.keyValue, applyChange);
24501
+ if (changeType !== "REMOVE") {
24478
24502
  keyValue = adaptedRange;
24479
24503
  }
24480
24504
  }
@@ -24531,7 +24555,7 @@ stores.inject(MyMetaStore, storeInstance);
24531
24555
  // This kind of graph is not exportable in Excel
24532
24556
  return undefined;
24533
24557
  }
24534
- updateRanges(applyChange) {
24558
+ updateRanges({ applyChange }) {
24535
24559
  const baseline = adaptChartRange(this.baseline, applyChange);
24536
24560
  const keyValue = adaptChartRange(this.keyValue, applyChange);
24537
24561
  if (this.baseline === baseline && this.keyValue === keyValue) {
@@ -27697,7 +27721,7 @@ stores.inject(MyMetaStore, storeInstance);
27697
27721
  verticalAxis: getDefinedAxis(definition),
27698
27722
  };
27699
27723
  }
27700
- updateRanges(applyChange) {
27724
+ updateRanges({ applyChange }) {
27701
27725
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
27702
27726
  if (!isStale) {
27703
27727
  return this;
@@ -28903,7 +28927,7 @@ stores.inject(MyMetaStore, storeInstance);
28903
28927
  verticalAxis: getDefinedAxis(definition),
28904
28928
  };
28905
28929
  }
28906
- updateRanges(applyChange) {
28930
+ updateRanges({ applyChange }) {
28907
28931
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
28908
28932
  if (!isStale) {
28909
28933
  return this;
@@ -29079,7 +29103,7 @@ stores.inject(MyMetaStore, storeInstance);
29079
29103
  getDefinitionForExcel() {
29080
29104
  return undefined;
29081
29105
  }
29082
- updateRanges(applyChange) {
29106
+ updateRanges({ applyChange }) {
29083
29107
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29084
29108
  if (!isStale) {
29085
29109
  return this;
@@ -29190,8 +29214,8 @@ stores.inject(MyMetaStore, storeInstance);
29190
29214
  static transformDefinition(chartSheetId, definition, applyChange) {
29191
29215
  let dataRange;
29192
29216
  if (definition.dataRange) {
29193
- const adaptedRange = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
29194
- if (adaptedRange !== CellErrorType.InvalidReference) {
29217
+ const { changeType, range: adaptedRange } = adaptStringRange(chartSheetId, definition.dataRange, applyChange);
29218
+ if (changeType !== "REMOVE") {
29195
29219
  dataRange = adaptedRange;
29196
29220
  }
29197
29221
  }
@@ -29268,13 +29292,9 @@ stores.inject(MyMetaStore, storeInstance);
29268
29292
  : undefined,
29269
29293
  };
29270
29294
  }
29271
- updateRanges(applyChange, sheetId, adaptSheetName) {
29295
+ updateRanges({ applyChange, adaptFormulaString }) {
29272
29296
  const dataRange = adaptChartRange(this.dataRange, applyChange);
29273
- const adaptFormula = (formula) => adaptFormulaStringRanges(this.sheetId, formula, {
29274
- applyChange,
29275
- sheetId,
29276
- sheetName: adaptSheetName,
29277
- });
29297
+ const adaptFormula = (formula) => adaptFormulaString(this.sheetId, formula);
29278
29298
  const sectionRule = adaptSectionRuleFormulas(this.sectionRule, adaptFormula);
29279
29299
  const definition = this.getDefinitionWithSpecificRanges(dataRange, sectionRule);
29280
29300
  return new GaugeChart(definition, this.sheetId, this.getters);
@@ -29502,7 +29522,7 @@ stores.inject(MyMetaStore, storeInstance);
29502
29522
  getDefinitionForExcel() {
29503
29523
  return undefined;
29504
29524
  }
29505
- updateRanges(applyChange) {
29525
+ updateRanges({ applyChange }) {
29506
29526
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29507
29527
  if (!isStale) {
29508
29528
  return this;
@@ -29644,7 +29664,7 @@ stores.inject(MyMetaStore, storeInstance);
29644
29664
  : undefined,
29645
29665
  };
29646
29666
  }
29647
- updateRanges(applyChange) {
29667
+ updateRanges({ applyChange }) {
29648
29668
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29649
29669
  if (!isStale) {
29650
29670
  return this;
@@ -29801,7 +29821,7 @@ stores.inject(MyMetaStore, storeInstance);
29801
29821
  labelRange,
29802
29822
  };
29803
29823
  }
29804
- updateRanges(applyChange) {
29824
+ updateRanges({ applyChange }) {
29805
29825
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29806
29826
  if (!isStale) {
29807
29827
  return this;
@@ -29956,7 +29976,7 @@ stores.inject(MyMetaStore, storeInstance);
29956
29976
  maxValue,
29957
29977
  };
29958
29978
  }
29959
- updateRanges(applyChange) {
29979
+ updateRanges({ applyChange }) {
29960
29980
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
29961
29981
  if (!isStale) {
29962
29982
  return this;
@@ -30106,7 +30126,7 @@ stores.inject(MyMetaStore, storeInstance);
30106
30126
  labelRange,
30107
30127
  };
30108
30128
  }
30109
- updateRanges(applyChange) {
30129
+ updateRanges({ applyChange }) {
30110
30130
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
30111
30131
  if (!isStale) {
30112
30132
  return this;
@@ -30234,7 +30254,7 @@ stores.inject(MyMetaStore, storeInstance);
30234
30254
  : undefined,
30235
30255
  };
30236
30256
  }
30237
- updateRanges(applyChange) {
30257
+ updateRanges({ applyChange }) {
30238
30258
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
30239
30259
  if (!isStale) {
30240
30260
  return this;
@@ -30401,7 +30421,7 @@ stores.inject(MyMetaStore, storeInstance);
30401
30421
  getDefinitionForExcel() {
30402
30422
  return undefined;
30403
30423
  }
30404
- updateRanges(applyChange) {
30424
+ updateRanges({ applyChange }) {
30405
30425
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
30406
30426
  if (!isStale) {
30407
30427
  return this;
@@ -30551,7 +30571,7 @@ stores.inject(MyMetaStore, storeInstance);
30551
30571
  getDefinitionForExcel() {
30552
30572
  return undefined;
30553
30573
  }
30554
- updateRanges(applyChange) {
30574
+ updateRanges({ applyChange }) {
30555
30575
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
30556
30576
  if (!isStale) {
30557
30577
  return this;
@@ -30712,7 +30732,7 @@ stores.inject(MyMetaStore, storeInstance);
30712
30732
  // TODO: implement export excel
30713
30733
  return undefined;
30714
30734
  }
30715
- updateRanges(applyChange) {
30735
+ updateRanges({ applyChange }) {
30716
30736
  const { dataSets, labelRange, isStale } = updateChartRangesWithDataSets(this.getters, applyChange, this.dataSets, this.labelRange);
30717
30737
  if (!isStale) {
30718
30738
  return this;
@@ -35229,7 +35249,6 @@ stores.inject(MyMetaStore, storeInstance);
35229
35249
  });
35230
35250
  }
35231
35251
  handleEvent(event) {
35232
- this.hideHelp();
35233
35252
  const sheetId = this.getters.getActiveSheetId();
35234
35253
  let unboundedZone;
35235
35254
  if (event.options.unbounded) {
@@ -35483,7 +35502,7 @@ stores.inject(MyMetaStore, storeInstance);
35483
35502
  }
35484
35503
  captureSelection(zone, col, row) {
35485
35504
  this.model.selection.capture(this, {
35486
- cell: { col: col ?? zone.left, row: row ?? zone.right },
35505
+ cell: { col: col ?? zone.left, row: row ?? zone.top },
35487
35506
  zone,
35488
35507
  }, {
35489
35508
  handleEvent: this.handleEvent.bind(this),
@@ -35577,6 +35596,7 @@ stores.inject(MyMetaStore, storeInstance);
35577
35596
  this.colorIndexByRange = {};
35578
35597
  this.hoveredTokens = [];
35579
35598
  this.hoveredContentEvaluation = "";
35599
+ this.hideHelp();
35580
35600
  }
35581
35601
  /**
35582
35602
  * Reset the current content to the active cell content
@@ -40819,6 +40839,7 @@ stores.inject(MyMetaStore, storeInstance);
40819
40839
  ? V_ALIGNMENT_EXPORT_CONVERSION_MAP[style.verticalAlign]
40820
40840
  : undefined,
40821
40841
  wrapText: style.wrapping === "wrap" || content?.includes(NEWLINE) ? true : undefined,
40842
+ shrinkToFit: style.wrapping === "clip" ? true : undefined,
40822
40843
  },
40823
40844
  };
40824
40845
  styles.font["strike"] = !!style?.strikethrough || undefined;
@@ -40839,6 +40860,7 @@ stores.inject(MyMetaStore, storeInstance);
40839
40860
  vertical: styles.alignment.vertical,
40840
40861
  horizontal: styles.alignment.horizontal,
40841
40862
  wrapText: styles.alignment.wrapText,
40863
+ shrinkToFit: styles.alignment.shrinkToFit,
40842
40864
  },
40843
40865
  };
40844
40866
  return pushElement(style, construct.styles);
@@ -47889,8 +47911,6 @@ stores.inject(MyMetaStore, storeInstance);
47889
47911
  }
47890
47912
  const change = applyChange(range);
47891
47913
  switch (change.changeType) {
47892
- case "NONE":
47893
- return range;
47894
47914
  case "REMOVE":
47895
47915
  return undefined;
47896
47916
  default:
@@ -55456,7 +55476,7 @@ stores.inject(MyMetaStore, storeInstance);
55456
55476
  });
55457
55477
  dataRange = this.props.definition.dataRange;
55458
55478
  get configurationErrorMessages() {
55459
- const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])];
55479
+ const cancelledReasons = [...(this.state.dataRangeDispatchResult?.reasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
55460
55480
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
55461
55481
  }
55462
55482
  get isDataRangeInvalid() {
@@ -55542,7 +55562,7 @@ stores.inject(MyMetaStore, storeInstance);
55542
55562
  });
55543
55563
  }
55544
55564
  get designErrorMessages() {
55545
- const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])];
55565
+ const cancelledReasons = [...(this.state.sectionRuleCancelledReasons || [])].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
55546
55566
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
55547
55567
  }
55548
55568
  get isRangeMinInvalid() {
@@ -55914,7 +55934,7 @@ stores.inject(MyMetaStore, storeInstance);
55914
55934
  const cancelledReasons = [
55915
55935
  ...(this.state.keyValueDispatchResult?.reasons || []),
55916
55936
  ...(this.state.baselineDispatchResult?.reasons || []),
55917
- ];
55937
+ ].filter((reason) => reason !== "NoChanges" /* CommandResult.NoChanges */);
55918
55938
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
55919
55939
  }
55920
55940
  get isKeyValueInvalid() {
@@ -57876,6 +57896,12 @@ stores.inject(MyMetaStore, storeInstance);
57876
57896
  case "ACTIVATE_SHEET":
57877
57897
  this.isSearchDirty = true;
57878
57898
  this.shouldFinalizeUpdateSelection = true;
57899
+ if (this.searchOptions.specificRange) {
57900
+ this.searchOptions.specificRange = {
57901
+ ...this.searchOptions.specificRange,
57902
+ sheetId: this.getters.getActiveSheetId(),
57903
+ };
57904
+ }
57879
57905
  break;
57880
57906
  case "REPLACE_SEARCH":
57881
57907
  for (const match of cmd.matches) {
@@ -58295,9 +58321,20 @@ stores.inject(MyMetaStore, storeInstance);
58295
58321
  const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
58296
58322
  this.store.updateSearchOptions({ specificRange });
58297
58323
  }
58324
+ get specificRange() {
58325
+ const range = this.store.searchOptions.specificRange;
58326
+ return range ? this.env.model.getters.getRangeString(range, "forceSheetReference") : "";
58327
+ }
58298
58328
  get pendingSearch() {
58299
58329
  return this.updateSearchContent.isDebouncePending();
58300
58330
  }
58331
+ get selectionInputKey() {
58332
+ // Selections input are made to work with objects linked to a sheet id. They store the active sheet id at their creation,
58333
+ // and have specific behaviour linked to it (eg. go back to the initial sheet after confirmation).
58334
+ // We don't want all those behaviors here, so we force the recreation of the component when the active sheet changes.
58335
+ // The only drawback is that the input loses focus when changing sheet.
58336
+ return this.env.model.getters.getActiveSheetId();
58337
+ }
58301
58338
  }
58302
58339
 
58303
58340
  css /* scss */ `
@@ -62203,7 +62240,7 @@ stores.inject(MyMetaStore, storeInstance);
62203
62240
  * @param sheetId an sheetId to adapt either range of that sheet specifically, or ranges pointing to that sheet
62204
62241
  * @param sheetName couple of old and new sheet names to adapt ranges pointing to that sheet
62205
62242
  */
62206
- adaptRanges(applyChange, sheetId, sheetName) { }
62243
+ adaptRanges(rangeAdapterFunctions, sheetId, sheetName) { }
62207
62244
  /**
62208
62245
  * Implement this method to clean unused external resources, such as images
62209
62246
  * stored on a server which have been deleted.
@@ -62282,7 +62319,7 @@ stores.inject(MyMetaStore, storeInstance);
62282
62319
  }
62283
62320
  }
62284
62321
  }
62285
- adaptRanges(applyChange, sheetId) {
62322
+ adaptRanges({ applyChange }, sheetId) {
62286
62323
  const newBorders = [];
62287
62324
  for (const border of this.borders[sheetId] ?? []) {
62288
62325
  const change = applyChange(this.getters.getRangeFromZone(sheetId, border.zone));
@@ -62645,7 +62682,7 @@ stores.inject(MyMetaStore, storeInstance);
62645
62682
  ];
62646
62683
  nextId = 1;
62647
62684
  cells = {};
62648
- adaptRanges(applyChange, sheetId, sheetName) {
62685
+ adaptRanges({ applyChange }, sheetId, sheetName) {
62649
62686
  for (const sheet of Object.keys(this.cells)) {
62650
62687
  for (const cell of Object.values(this.cells[sheet] || {})) {
62651
62688
  if (cell.isFormula) {
@@ -62867,7 +62904,7 @@ stores.inject(MyMetaStore, storeInstance);
62867
62904
  for (const position of positions) {
62868
62905
  const cell = this.getters.getCell(position);
62869
62906
  const xc = toXC(position.col, position.row);
62870
- const style = this.removeDefaultStyleValues(cell.style);
62907
+ const style = this.extractCustomStyle(cell);
62871
62908
  if (Object.keys(style).length) {
62872
62909
  const styleId = getItemId(style, styles);
62873
62910
  positionsByStyle[styleId] ??= [];
@@ -62913,10 +62950,14 @@ stores.inject(MyMetaStore, storeInstance);
62913
62950
  }
62914
62951
  }
62915
62952
  }
62916
- removeDefaultStyleValues(style) {
62917
- const cleanedStyle = { ...style };
62918
- for (const property in DEFAULT_STYLE) {
62919
- if (cleanedStyle[property] === DEFAULT_STYLE[property]) {
62953
+ extractCustomStyle(cell) {
62954
+ const cleanedStyle = { ...cell.style };
62955
+ const defaultStyle = isNumber(cell.content, DEFAULT_LOCALE)
62956
+ ? DEFAULT_NUMBER_STYLE
62957
+ : DEFAULT_STYLE;
62958
+ for (const property in cleanedStyle) {
62959
+ if ((property !== "align" || !cell.isFormula) &&
62960
+ cleanedStyle[property] === defaultStyle[property]) {
62920
62961
  delete cleanedStyle[property];
62921
62962
  }
62922
62963
  }
@@ -63267,12 +63308,12 @@ stores.inject(MyMetaStore, storeInstance);
63267
63308
  charts = {};
63268
63309
  createChart = chartFactory(this.getters);
63269
63310
  validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
63270
- adaptRanges(applyChange, sheetId, adaptSheetName) {
63311
+ adaptRanges(rangeAdapters) {
63271
63312
  for (const [chartId, chart] of Object.entries(this.charts)) {
63272
63313
  if (!chart) {
63273
63314
  continue;
63274
63315
  }
63275
- const newChart = chart.chart.updateRanges(applyChange, sheetId, adaptSheetName);
63316
+ const newChart = chart.chart.updateRanges(rangeAdapters);
63276
63317
  this.history.update("charts", chartId, newChart ? { figureId: chart.figureId, chart: newChart } : undefined);
63277
63318
  }
63278
63319
  }
@@ -63527,7 +63568,7 @@ stores.inject(MyMetaStore, storeInstance);
63527
63568
  "getAdaptedCfRanges",
63528
63569
  ];
63529
63570
  cfRules = {};
63530
- adaptCFFormulas(applyChange) {
63571
+ adaptCFFormulas({ applyChange, adaptFormulaString }) {
63531
63572
  for (const sheetId in this.cfRules) {
63532
63573
  for (const rule of this.cfRules[sheetId]) {
63533
63574
  if (rule.rule.type === "DataBarRule" && rule.rule.rangeValues) {
@@ -63551,7 +63592,7 @@ stores.inject(MyMetaStore, storeInstance);
63551
63592
  for (let i = 0; i < rule.rule.values.length; i++) {
63552
63593
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
63553
63594
  //@ts-expect-error
63554
- "values", i, this.getters.adaptFormulaStringDependencies(sheetId, rule.rule.values[i], applyChange));
63595
+ "values", i, adaptFormulaString(sheetId, rule.rule.values[i]));
63555
63596
  }
63556
63597
  }
63557
63598
  else if (rule.rule.type === "IconSetRule") {
@@ -63559,7 +63600,7 @@ stores.inject(MyMetaStore, storeInstance);
63559
63600
  if (rule.rule[inflectionPoint].type === "formula") {
63560
63601
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
63561
63602
  //@ts-expect-error
63562
- inflectionPoint, "value", this.getters.adaptFormulaStringDependencies(sheetId, rule.rule[inflectionPoint].value, applyChange));
63603
+ inflectionPoint, "value", adaptFormulaString(sheetId, rule.rule[inflectionPoint].value));
63563
63604
  }
63564
63605
  }
63565
63606
  }
@@ -63569,14 +63610,14 @@ stores.inject(MyMetaStore, storeInstance);
63569
63610
  if (ruleValue?.type === "formula" && ruleValue?.value) {
63570
63611
  this.history.update("cfRules", sheetId, this.cfRules[sheetId].indexOf(rule), "rule",
63571
63612
  //@ts-expect-error
63572
- value, "value", this.getters.adaptFormulaStringDependencies(sheetId, ruleValue.value, applyChange));
63613
+ value, "value", adaptFormulaString(sheetId, ruleValue.value));
63573
63614
  }
63574
63615
  }
63575
63616
  }
63576
63617
  }
63577
63618
  }
63578
63619
  }
63579
- adaptCFRanges(sheetId, applyChange) {
63620
+ adaptCFRanges(sheetId, { applyChange }) {
63580
63621
  for (const rule of this.cfRules[sheetId]) {
63581
63622
  for (const range of rule.ranges) {
63582
63623
  const change = applyChange(range);
@@ -63600,12 +63641,12 @@ stores.inject(MyMetaStore, storeInstance);
63600
63641
  }
63601
63642
  }
63602
63643
  }
63603
- adaptRanges(applyChange, sheetId) {
63644
+ adaptRanges(rangeAdapters, sheetId) {
63604
63645
  const sheetIds = sheetId ? [sheetId] : Object.keys(this.cfRules);
63605
63646
  for (const sheetId of sheetIds) {
63606
- this.adaptCFRanges(sheetId, applyChange);
63647
+ this.adaptCFRanges(sheetId, rangeAdapters);
63607
63648
  }
63608
- this.adaptCFFormulas(applyChange);
63649
+ this.adaptCFFormulas(rangeAdapters);
63609
63650
  }
63610
63651
  // ---------------------------------------------------------------------------
63611
63652
  // Command Handling
@@ -63982,23 +64023,23 @@ stores.inject(MyMetaStore, storeInstance);
63982
64023
  "getValidationRuleForCell",
63983
64024
  ];
63984
64025
  rules = {};
63985
- adaptRanges(applyChange, sheetId) {
63986
- this.adaptDVRanges(sheetId, applyChange);
63987
- this.adaptDVFormulas(applyChange);
64026
+ adaptRanges(rangeAdapters, sheetId) {
64027
+ this.adaptDVRanges(sheetId, rangeAdapters);
64028
+ this.adaptDVFormulas(rangeAdapters);
63988
64029
  }
63989
- adaptDVFormulas(applyChange) {
64030
+ adaptDVFormulas({ adaptFormulaString }) {
63990
64031
  for (const sheetId in this.rules) {
63991
64032
  const rules = this.rules[sheetId];
63992
64033
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
63993
64034
  const rule = this.rules[sheetId][ruleIndex];
63994
64035
  for (let valueIndex = 0; valueIndex < rule.criterion.values.length; valueIndex++) {
63995
- const value = this.getters.adaptFormulaStringDependencies(sheetId, rule.criterion.values[valueIndex], applyChange);
64036
+ const value = adaptFormulaString(sheetId, rule.criterion.values[valueIndex]);
63996
64037
  this.history.update("rules", sheetId, ruleIndex, "criterion", "values", valueIndex, value);
63997
64038
  }
63998
64039
  }
63999
64040
  }
64000
64041
  }
64001
- adaptDVRanges(sheetId, applyChange) {
64042
+ adaptDVRanges(sheetId, { applyChange }) {
64002
64043
  const rules = this.rules[sheetId];
64003
64044
  for (let ruleIndex = rules.length - 1; ruleIndex >= 0; ruleIndex--) {
64004
64045
  const rule = this.rules[sheetId][ruleIndex];
@@ -64272,7 +64313,7 @@ stores.inject(MyMetaStore, storeInstance);
64272
64313
  // ---------------------------------------------------------------------------
64273
64314
  // Command Handling
64274
64315
  // ---------------------------------------------------------------------------
64275
- adaptRanges(applyChange, sheetId) {
64316
+ adaptRanges({ applyChange }, sheetId) {
64276
64317
  for (const figure of this.getFigures(sheetId)) {
64277
64318
  const change = applyChange(this.getters.getRangeFromZone(sheetId, {
64278
64319
  left: figure.col,
@@ -65103,8 +65144,8 @@ stores.inject(MyMetaStore, storeInstance);
65103
65144
  break;
65104
65145
  }
65105
65146
  }
65106
- adaptRanges(applyChange, sheetId) {
65107
- this.applyRangeChangeOnSheet(sheetId, applyChange);
65147
+ adaptRanges(rangeAdapters, sheetId) {
65148
+ this.applyRangeChangeOnSheet(sheetId, rangeAdapters);
65108
65149
  }
65109
65150
  // ---------------------------------------------------------------------------
65110
65151
  // Getters
@@ -65406,7 +65447,7 @@ stores.inject(MyMetaStore, storeInstance);
65406
65447
  /**
65407
65448
  * Apply a range change on merges of a particular sheet.
65408
65449
  */
65409
- applyRangeChangeOnSheet(sheetId, applyChange) {
65450
+ applyRangeChangeOnSheet(sheetId, { applyChange }) {
65410
65451
  const merges = Object.entries(this.merges[sheetId] || {});
65411
65452
  for (const [mergeId, range] of merges) {
65412
65453
  if (range) {
@@ -65480,7 +65521,7 @@ stores.inject(MyMetaStore, storeInstance);
65480
65521
  };
65481
65522
  }
65482
65523
 
65483
- class RangeAdapter {
65524
+ class RangeAdapterPlugin {
65484
65525
  getters;
65485
65526
  providers = [];
65486
65527
  isAdaptingRanges = false;
@@ -65488,7 +65529,6 @@ stores.inject(MyMetaStore, storeInstance);
65488
65529
  this.getters = getters;
65489
65530
  }
65490
65531
  static getters = [
65491
- "adaptFormulaStringDependencies",
65492
65532
  "copyFormulaStringForSheet",
65493
65533
  "extendRange",
65494
65534
  "getRangeString",
@@ -65519,8 +65559,8 @@ stores.inject(MyMetaStore, storeInstance);
65519
65559
  throw new Error("Plugins cannot dispatch commands during adaptRanges phase");
65520
65560
  }
65521
65561
  const rangeAdapter = getRangeAdapter(cmd);
65522
- if (rangeAdapter?.applyChange) {
65523
- this.executeOnAllRanges(rangeAdapter.applyChange, rangeAdapter.sheetId, rangeAdapter.sheetName);
65562
+ if (rangeAdapter) {
65563
+ this.executeOnAllRanges(rangeAdapter);
65524
65564
  }
65525
65565
  }
65526
65566
  finalize() { }
@@ -65539,11 +65579,15 @@ stores.inject(MyMetaStore, storeInstance);
65539
65579
  return result;
65540
65580
  };
65541
65581
  }
65542
- executeOnAllRanges(adaptRange, sheetId, sheetName) {
65582
+ executeOnAllRanges(rangeAdapter) {
65543
65583
  this.isAdaptingRanges = true;
65544
- const func = this.verifyRangeRemoved(adaptRange);
65584
+ const adapterFunctions = {
65585
+ applyChange: this.verifyRangeRemoved(rangeAdapter.applyChange),
65586
+ adaptRangeString: (defaultSheetId, sheetXC) => adaptStringRange(defaultSheetId, sheetXC, rangeAdapter),
65587
+ adaptFormulaString: (defaultSheetId, formula) => adaptFormulaStringRanges(defaultSheetId, formula, rangeAdapter),
65588
+ };
65545
65589
  for (const provider of this.providers) {
65546
- provider(func, sheetId, sheetName);
65590
+ provider(adapterFunctions, rangeAdapter.sheetId, rangeAdapter.sheetName);
65547
65591
  }
65548
65592
  this.isAdaptingRanges = false;
65549
65593
  }
@@ -65711,18 +65755,6 @@ stores.inject(MyMetaStore, storeInstance);
65711
65755
  const unionOfZones = unionUnboundedZones(...zones);
65712
65756
  return this.getRangeFromZone(ranges[0].sheetId, unionOfZones);
65713
65757
  }
65714
- adaptFormulaStringDependencies(sheetId, formula, applyChange) {
65715
- if (!formula.startsWith("=")) {
65716
- return formula;
65717
- }
65718
- const compiledFormula = compile(formula);
65719
- const updatedDependencies = compiledFormula.dependencies.map((dep) => {
65720
- const range = this.getters.getRangeFromSheetXC(sheetId, dep);
65721
- const changedRange = applyChange(range);
65722
- return changedRange.changeType === "NONE" ? range : changedRange.range;
65723
- });
65724
- return this.getters.getFormulaString(sheetId, compiledFormula.tokens, updatedDependencies);
65725
- }
65726
65758
  /**
65727
65759
  * Copy a formula string to another sheet.
65728
65760
  *
@@ -66610,7 +66642,7 @@ stores.inject(MyMetaStore, storeInstance);
66610
66642
  static getters = ["getCoreTable", "getCoreTables", "getCoreTableMatchingTopLeft"];
66611
66643
  tables = {};
66612
66644
  nextTableId = 1;
66613
- adaptRanges(applyChange, sheetId) {
66645
+ adaptRanges({ applyChange }, sheetId) {
66614
66646
  for (const table of this.getCoreTables(sheetId)) {
66615
66647
  this.applyRangeChangeOnTable(sheetId, table, applyChange);
66616
66648
  }
@@ -67607,6 +67639,7 @@ stores.inject(MyMetaStore, storeInstance);
67607
67639
  "getMeasureCompiledFormula",
67608
67640
  "getPivotName",
67609
67641
  "isExistingPivot",
67642
+ "getMeasureFullDependencies",
67610
67643
  ];
67611
67644
  nextFormulaId = 1;
67612
67645
  pivots = {};
@@ -67689,12 +67722,12 @@ stores.inject(MyMetaStore, storeInstance);
67689
67722
  }
67690
67723
  case "UPDATE_PIVOT": {
67691
67724
  this.history.update("pivots", cmd.pivotId, "definition", deepCopy(cmd.pivot));
67692
- this.compileCalculatedMeasures(cmd.pivot.measures);
67725
+ this.compileCalculatedMeasures(cmd.pivotId, cmd.pivot.measures);
67693
67726
  break;
67694
67727
  }
67695
67728
  }
67696
67729
  }
67697
- adaptRanges(applyChange) {
67730
+ adaptRanges({ applyChange, adaptFormulaString }) {
67698
67731
  for (const pivotId in this.pivots) {
67699
67732
  const definition = deepCopy(this.pivots[pivotId]?.definition);
67700
67733
  if (!definition) {
@@ -67707,22 +67740,22 @@ stores.inject(MyMetaStore, storeInstance);
67707
67740
  this.history.update("pivots", pivotId, "definition", newDefinition);
67708
67741
  }
67709
67742
  }
67710
- for (const sheetId in this.compiledMeasureFormulas) {
67711
- for (const formulaString in this.compiledMeasureFormulas[sheetId]) {
67712
- const compiledFormula = this.compiledMeasureFormulas[sheetId][formulaString];
67713
- const newDependencies = [];
67714
- for (const range of compiledFormula.dependencies) {
67715
- const change = applyChange(range);
67716
- if (change.changeType === "NONE") {
67717
- newDependencies.push(range);
67718
- }
67719
- else {
67720
- newDependencies.push(change.range);
67721
- }
67743
+ for (const pivotId in this.compiledMeasureFormulas) {
67744
+ for (const measureId in this.compiledMeasureFormulas[pivotId]) {
67745
+ const measure = this.pivots[pivotId]?.definition.measures.find((m) => m.id === measureId);
67746
+ if (!measure || !measure.computedBy) {
67747
+ continue;
67722
67748
  }
67723
- const newFormulaString = this.getters.getFormulaString(sheetId, compiledFormula.tokens, newDependencies);
67724
- if (newFormulaString !== formulaString) {
67725
- this.replaceMeasureFormula(sheetId, formulaString, newFormulaString);
67749
+ const sheetId = measure.computedBy.sheetId;
67750
+ const { formula: compiledFormula, dependencies: indirectDependencies } = this.compiledMeasureFormulas[pivotId][measureId];
67751
+ // adapt direct dependencies
67752
+ this.history.update("compiledMeasureFormulas", pivotId, measureId, "formula", "dependencies", compiledFormula.dependencies.map((range) => applyChange(range).range));
67753
+ // adapt all dependencies (including indirect)
67754
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", indirectDependencies.map((range) => applyChange(range).range));
67755
+ const oldFormulaString = measure.computedBy.formula;
67756
+ const newFormulaString = adaptFormulaString(sheetId, oldFormulaString);
67757
+ if (newFormulaString !== oldFormulaString) {
67758
+ this.replaceMeasureFormula(pivotId, measure, newFormulaString);
67726
67759
  }
67727
67760
  }
67728
67761
  }
@@ -67760,31 +67793,60 @@ stores.inject(MyMetaStore, storeInstance);
67760
67793
  isExistingPivot(pivotId) {
67761
67794
  return pivotId in this.pivots;
67762
67795
  }
67763
- getMeasureCompiledFormula(measure) {
67796
+ getMeasureCompiledFormula(pivotId, measure) {
67764
67797
  if (!measure.computedBy) {
67765
67798
  throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
67766
67799
  }
67767
- const sheetId = measure.computedBy.sheetId;
67768
- return this.compiledMeasureFormulas[sheetId][measure.computedBy.formula];
67800
+ return this.compiledMeasureFormulas[pivotId][measure.id].formula;
67801
+ }
67802
+ getMeasureFullDependencies(pivotId, measure) {
67803
+ if (!measure.computedBy) {
67804
+ throw new Error(`Measure ${measure.fieldName} is not computed by formula`);
67805
+ }
67806
+ return this.compiledMeasureFormulas[pivotId][measure.id].dependencies;
67769
67807
  }
67770
67808
  // -------------------------------------------------------------------------
67771
67809
  // Private
67772
67810
  // -------------------------------------------------------------------------
67773
67811
  addPivot(pivotId, pivot, formulaId = this.nextFormulaId.toString()) {
67774
67812
  this.history.update("pivots", pivotId, { definition: deepCopy(pivot), formulaId });
67775
- this.compileCalculatedMeasures(pivot.measures);
67813
+ this.compileCalculatedMeasures(pivotId, pivot.measures);
67776
67814
  this.history.update("formulaIds", formulaId, pivotId);
67777
67815
  this.history.update("nextFormulaId", this.nextFormulaId + 1);
67778
67816
  }
67779
- compileCalculatedMeasures(measures) {
67817
+ compileCalculatedMeasures(pivotId, measures) {
67780
67818
  for (const measure of measures) {
67781
67819
  if (measure.computedBy) {
67782
- const sheetId = measure.computedBy.sheetId;
67783
67820
  const compiledFormula = this.compileMeasureFormula(measure.computedBy.sheetId, measure.computedBy.formula);
67784
- this.history.update("compiledMeasureFormulas", sheetId, measure.computedBy.formula, compiledFormula);
67821
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "formula", compiledFormula);
67822
+ }
67823
+ }
67824
+ for (const measure of measures) {
67825
+ if (measure.computedBy) {
67826
+ const dependencies = this.computeMeasureFullDependencies(pivotId, measure);
67827
+ this.history.update("compiledMeasureFormulas", pivotId, measure.id, "dependencies", dependencies);
67785
67828
  }
67786
67829
  }
67787
67830
  }
67831
+ computeMeasureFullDependencies(pivotId, measure, exploredMeasures = new Set()) {
67832
+ const rangeDependencies = [];
67833
+ const definition = this.getPivotCoreDefinition(pivotId);
67834
+ const formula = this.getMeasureCompiledFormula(pivotId, measure);
67835
+ exploredMeasures.add(measure.id);
67836
+ for (const token of formula.tokens) {
67837
+ if (token.type !== "SYMBOL") {
67838
+ continue;
67839
+ }
67840
+ const otherMeasure = definition.measures.find((measureCandidate) => getCanonicalSymbolName(measureCandidate.id) === token.value &&
67841
+ measure.id !== measureCandidate.id);
67842
+ if (!otherMeasure || exploredMeasures.has(otherMeasure.id) || !otherMeasure.computedBy) {
67843
+ continue;
67844
+ }
67845
+ rangeDependencies.push(...this.computeMeasureFullDependencies(pivotId, otherMeasure, exploredMeasures));
67846
+ }
67847
+ rangeDependencies.push(...formula.dependencies.filter((range) => !range.invalidXc));
67848
+ return rangeDependencies;
67849
+ }
67788
67850
  insertPivot(position, formulaId, table) {
67789
67851
  this.resizeSheet(position.sheetId, position, table);
67790
67852
  const pivotCells = table.getPivotCells();
@@ -67843,21 +67905,16 @@ stores.inject(MyMetaStore, storeInstance);
67843
67905
  dependencies: rangeDependencies,
67844
67906
  };
67845
67907
  }
67846
- replaceMeasureFormula(sheetId, formulaString, newFormulaString) {
67847
- this.history.update("compiledMeasureFormulas", sheetId, formulaString, undefined);
67848
- this.history.update("compiledMeasureFormulas", sheetId, newFormulaString, this.compileMeasureFormula(sheetId, newFormulaString));
67849
- for (const pivotId in this.pivots) {
67850
- const pivot = this.pivots[pivotId];
67851
- if (!pivot) {
67852
- continue;
67853
- }
67854
- for (const measure of pivot.definition.measures) {
67855
- if (measure.computedBy?.formula === formulaString) {
67856
- const measureIndex = pivot.definition.measures.indexOf(measure);
67857
- this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", { formula: newFormulaString, sheetId });
67858
- }
67859
- }
67908
+ replaceMeasureFormula(pivotId, measure, newFormulaString) {
67909
+ const pivot = this.pivots[pivotId];
67910
+ if (!pivot) {
67911
+ return;
67860
67912
  }
67913
+ const measureIndex = pivot.definition.measures.indexOf(measure);
67914
+ this.history.update("pivots", pivotId, "definition", "measures", measureIndex, "computedBy", {
67915
+ formula: newFormulaString,
67916
+ sheetId: measure.computedBy.sheetId,
67917
+ });
67861
67918
  }
67862
67919
  checkSortedColumnInMeasures(definition) {
67863
67920
  const measures = definition.measures.map((measure) => measure.id);
@@ -69503,11 +69560,16 @@ stores.inject(MyMetaStore, storeInstance);
69503
69560
  return this.arrayFormulasToResults.get(formulasPosition);
69504
69561
  }
69505
69562
  /**
69506
- * Remove a node, also remove it from other nodes adjacency list
69563
+ * Remove a spreading relation for a given array formula position
69564
+ * and its result zone
69507
69565
  */
69508
69566
  removeNode(position) {
69567
+ const resultZone = this.arrayFormulasToResults.get(position);
69568
+ if (!resultZone) {
69569
+ return;
69570
+ }
69509
69571
  this.resultsToArrayFormulas.remove({
69510
- boundingBox: { sheetId: position.sheetId, zone: positionToZone(position) },
69572
+ boundingBox: { sheetId: position.sheetId, zone: resultZone },
69511
69573
  data: position,
69512
69574
  });
69513
69575
  this.arrayFormulasToResults.delete(position);
@@ -69820,6 +69882,10 @@ stores.inject(MyMetaStore, storeInstance);
69820
69882
  // empty matrix
69821
69883
  return createEvaluatedCell({ value: 0 }, this.getters.getLocale(), cellData);
69822
69884
  }
69885
+ if (nbRows === 1 && nbColumns === 1) {
69886
+ // single value matrix
69887
+ return createEvaluatedCell(nullValueToZeroValue(formulaReturn[0][0]), this.getters.getLocale(), cellData);
69888
+ }
69823
69889
  const resultZone = {
69824
69890
  top: formulaPosition.row,
69825
69891
  bottom: formulaPosition.row + nbRows - 1,
@@ -71539,6 +71605,7 @@ stores.inject(MyMetaStore, storeInstance);
71539
71605
  handle(cmd) {
71540
71606
  switch (cmd.type) {
71541
71607
  case "START":
71608
+ case "UPDATE_LOCALE":
71542
71609
  for (const sheetId of this.getters.getSheetIds()) {
71543
71610
  this.initializeSheet(sheetId);
71544
71611
  }
@@ -71660,7 +71727,7 @@ stores.inject(MyMetaStore, storeInstance);
71660
71727
  }
71661
71728
  const cell = this.getters.getCell(position);
71662
71729
  const colSize = this.getters.getColSize(position.sheetId, position.col);
71663
- return getDefaultCellHeight(this.ctx, cell, colSize);
71730
+ return getDefaultCellHeight(this.ctx, cell, this.getters.getLocale(), colSize);
71664
71731
  }
71665
71732
  isInMultiRowMerge(position) {
71666
71733
  const merge = this.getters.getMerge(position);
@@ -71707,14 +71774,16 @@ stores.inject(MyMetaStore, storeInstance);
71707
71774
  function withPivotPresentationLayer (PivotClass) {
71708
71775
  class PivotPresentationLayer extends PivotClass {
71709
71776
  getters;
71777
+ pivotId;
71710
71778
  cache = {};
71711
71779
  rankAsc = {};
71712
71780
  rankDesc = {};
71713
71781
  runningTotal = {};
71714
71782
  runningTotalInPercent = {};
71715
- constructor(custom, params) {
71783
+ constructor(pivotId, custom, params) {
71716
71784
  super(custom, params);
71717
71785
  this.getters = params.getters;
71786
+ this.pivotId = pivotId;
71718
71787
  }
71719
71788
  markAsDirtyForEvaluation() {
71720
71789
  this.cache = {};
@@ -71764,7 +71833,7 @@ stores.inject(MyMetaStore, storeInstance);
71764
71833
  return handleError(error, measure.aggregator.toUpperCase());
71765
71834
  }
71766
71835
  }
71767
- const formula = this.getters.getMeasureCompiledFormula(measure);
71836
+ const formula = this.getters.getMeasureCompiledFormula(this.pivotId, measure);
71768
71837
  const getSymbolValue = (symbolName) => {
71769
71838
  const { columns, rows } = this.definition;
71770
71839
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
@@ -72519,7 +72588,7 @@ stores.inject(MyMetaStore, storeInstance);
72519
72588
  const definition = deepCopy(this.getters.getPivotCoreDefinition(pivotId));
72520
72589
  if (!(pivotId in this.pivots)) {
72521
72590
  const Pivot = withPivotPresentationLayer(pivotRegistry.get(definition.type).ui);
72522
- this.pivots[pivotId] = new Pivot(this.custom, { definition, getters: this.getters });
72591
+ this.pivots[pivotId] = new Pivot(pivotId, this.custom, { definition, getters: this.getters });
72523
72592
  }
72524
72593
  else if (recreate) {
72525
72594
  this.pivots[pivotId].onDefinitionChange(definition);
@@ -73981,7 +74050,7 @@ stores.inject(MyMetaStore, storeInstance);
73981
74050
  cmd.cf.rule = {
73982
74051
  ...rule,
73983
74052
  rangeValues: rule.rangeValues
73984
- ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange)
74053
+ ? adaptStringRange(cmd.sheetId, rule.rangeValues, applyChange).range
73985
74054
  : undefined,
73986
74055
  };
73987
74056
  }
@@ -87601,6 +87670,9 @@ stores.inject(MyMetaStore, storeInstance);
87601
87670
  if (style.alignment && style.alignment.wrapText) {
87602
87671
  alignAttrs.push(["wrapText", "1"]);
87603
87672
  }
87673
+ if (style.alignment && style.alignment.shrinkToFit) {
87674
+ alignAttrs.push(["shrinkToFit", "1"]);
87675
+ }
87604
87676
  if (alignAttrs.length > 0) {
87605
87677
  attributes.push(["applyAlignment", "1"]); // for Libre Office
87606
87678
  styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)}><alignment ${formatAttributes(alignAttrs)} /></xf> `);
@@ -88371,7 +88443,7 @@ stores.inject(MyMetaStore, storeInstance);
88371
88443
  this.config = this.setupConfig(config);
88372
88444
  this.session = this.setupSession(workbookData.revisionId);
88373
88445
  this.coreGetters = {};
88374
- this.range = new RangeAdapter(this.coreGetters);
88446
+ this.range = new RangeAdapterPlugin(this.coreGetters);
88375
88447
  this.coreGetters.getRangeString = this.range.getRangeString.bind(this.range);
88376
88448
  this.coreGetters.getRangeFromSheetXC = this.range.getRangeFromSheetXC.bind(this.range);
88377
88449
  this.coreGetters.createAdaptedRanges = this.range.createAdaptedRanges.bind(this.range);
@@ -88385,8 +88457,6 @@ stores.inject(MyMetaStore, storeInstance);
88385
88457
  this.coreGetters.extendRange = this.range.extendRange.bind(this.range);
88386
88458
  this.coreGetters.getRangesUnion = this.range.getRangesUnion.bind(this.range);
88387
88459
  this.coreGetters.removeRangesSheetPrefix = this.range.removeRangesSheetPrefix.bind(this.range);
88388
- this.coreGetters.adaptFormulaStringDependencies =
88389
- this.range.adaptFormulaStringDependencies.bind(this.range);
88390
88460
  this.coreGetters.copyFormulaStringForSheet = this.range.copyFormulaStringForSheet.bind(this.range);
88391
88461
  this.getters = {
88392
88462
  isReadonly: () => this.config.mode === "readonly" || this.config.mode === "dashboard",
@@ -89124,9 +89194,9 @@ stores.inject(MyMetaStore, storeInstance);
89124
89194
  exports.tokenize = tokenize;
89125
89195
 
89126
89196
 
89127
- __info__.version = "19.0.16";
89128
- __info__.date = "2026-01-07T16:21:15.857Z";
89129
- __info__.hash = "9f3f13a";
89197
+ __info__.version = "19.0.18";
89198
+ __info__.date = "2026-01-21T11:06:57.346Z";
89199
+ __info__.hash = "bd44f59";
89130
89200
 
89131
89201
 
89132
89202
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);