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