@odoo/o-spreadsheet 16.3.22 → 16.3.25

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.
@@ -1746,6 +1746,9 @@ function parseFormat(formatString) {
1746
1746
  function formatValue(value, format) {
1747
1747
  switch (typeof value) {
1748
1748
  case "string":
1749
+ if (value.includes('\\"')) {
1750
+ return value.replace(/\\"/g, '"');
1751
+ }
1749
1752
  return value;
1750
1753
  case "boolean":
1751
1754
  return value ? "TRUE" : "FALSE";
@@ -2077,27 +2080,30 @@ function detectFormat(content) {
2077
2080
  }
2078
2081
  function createLargeNumberFormat(format, magnitude, postFix) {
2079
2082
  const internalFormat = parseFormat(format || "#,##0");
2080
- const largeNumberFormat = internalFormat
2081
- .map((formatPart) => {
2082
- if (formatPart.type === "NUMBER") {
2083
- return [
2084
- {
2085
- ...formatPart,
2086
- format: {
2087
- ...formatPart.format,
2088
- magnitude,
2089
- decimalPart: undefined,
2090
- },
2091
- },
2092
- {
2093
- type: "STRING",
2094
- format: postFix,
2095
- },
2096
- ];
2083
+ const largeNumberFormat = [];
2084
+ for (let i = 0; i < internalFormat.length; i++) {
2085
+ const formatPart = internalFormat[i];
2086
+ if (formatPart.type !== "NUMBER") {
2087
+ largeNumberFormat.push(formatPart);
2088
+ continue;
2097
2089
  }
2098
- return formatPart;
2099
- })
2100
- .flat();
2090
+ largeNumberFormat.push({
2091
+ ...formatPart,
2092
+ format: {
2093
+ ...formatPart.format,
2094
+ magnitude,
2095
+ decimalPart: undefined,
2096
+ },
2097
+ });
2098
+ largeNumberFormat.push({
2099
+ type: "STRING",
2100
+ format: postFix,
2101
+ });
2102
+ const nextFormatPart = internalFormat[i + 1];
2103
+ if (nextFormatPart?.type === "STRING" && ["k", "m", "b"].includes(nextFormatPart.format)) {
2104
+ i++;
2105
+ }
2106
+ }
2101
2107
  return convertInternalFormatToFormat(largeNumberFormat);
2102
2108
  }
2103
2109
  function changeDecimalPlaces(format, step) {
@@ -4439,69 +4445,70 @@ exports.CommandResult = void 0;
4439
4445
  CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
4440
4446
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
4441
4447
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
4442
- CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
4443
- CommandResult[CommandResult["InvalidDataSet"] = 32] = "InvalidDataSet";
4444
- CommandResult[CommandResult["InvalidLabelRange"] = 33] = "InvalidLabelRange";
4445
- CommandResult[CommandResult["InvalidScorecardKeyValue"] = 34] = "InvalidScorecardKeyValue";
4446
- CommandResult[CommandResult["InvalidScorecardBaseline"] = 35] = "InvalidScorecardBaseline";
4447
- CommandResult[CommandResult["InvalidGaugeDataRange"] = 36] = "InvalidGaugeDataRange";
4448
- CommandResult[CommandResult["EmptyGaugeRangeMin"] = 37] = "EmptyGaugeRangeMin";
4449
- CommandResult[CommandResult["GaugeRangeMinNaN"] = 38] = "GaugeRangeMinNaN";
4450
- CommandResult[CommandResult["EmptyGaugeRangeMax"] = 39] = "EmptyGaugeRangeMax";
4451
- CommandResult[CommandResult["GaugeRangeMaxNaN"] = 40] = "GaugeRangeMaxNaN";
4452
- CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 41] = "GaugeRangeMinBiggerThanRangeMax";
4453
- CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 42] = "GaugeLowerInflectionPointNaN";
4454
- CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 43] = "GaugeUpperInflectionPointNaN";
4455
- CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 44] = "GaugeLowerBiggerThanUpper";
4456
- CommandResult[CommandResult["InvalidAutofillSelection"] = 45] = "InvalidAutofillSelection";
4457
- CommandResult[CommandResult["WrongComposerSelection"] = 46] = "WrongComposerSelection";
4458
- CommandResult[CommandResult["MinBiggerThanMax"] = 47] = "MinBiggerThanMax";
4459
- CommandResult[CommandResult["LowerBiggerThanUpper"] = 48] = "LowerBiggerThanUpper";
4460
- CommandResult[CommandResult["MidBiggerThanMax"] = 49] = "MidBiggerThanMax";
4461
- CommandResult[CommandResult["MinBiggerThanMid"] = 50] = "MinBiggerThanMid";
4462
- CommandResult[CommandResult["FirstArgMissing"] = 51] = "FirstArgMissing";
4463
- CommandResult[CommandResult["SecondArgMissing"] = 52] = "SecondArgMissing";
4464
- CommandResult[CommandResult["MinNaN"] = 53] = "MinNaN";
4465
- CommandResult[CommandResult["MidNaN"] = 54] = "MidNaN";
4466
- CommandResult[CommandResult["MaxNaN"] = 55] = "MaxNaN";
4467
- CommandResult[CommandResult["ValueUpperInflectionNaN"] = 56] = "ValueUpperInflectionNaN";
4468
- CommandResult[CommandResult["ValueLowerInflectionNaN"] = 57] = "ValueLowerInflectionNaN";
4469
- CommandResult[CommandResult["MinInvalidFormula"] = 58] = "MinInvalidFormula";
4470
- CommandResult[CommandResult["MidInvalidFormula"] = 59] = "MidInvalidFormula";
4471
- CommandResult[CommandResult["MaxInvalidFormula"] = 60] = "MaxInvalidFormula";
4472
- CommandResult[CommandResult["ValueUpperInvalidFormula"] = 61] = "ValueUpperInvalidFormula";
4473
- CommandResult[CommandResult["ValueLowerInvalidFormula"] = 62] = "ValueLowerInvalidFormula";
4474
- CommandResult[CommandResult["InvalidSortZone"] = 63] = "InvalidSortZone";
4475
- CommandResult[CommandResult["WaitingSessionConfirmation"] = 64] = "WaitingSessionConfirmation";
4476
- CommandResult[CommandResult["MergeOverlap"] = 65] = "MergeOverlap";
4477
- CommandResult[CommandResult["TooManyHiddenElements"] = 66] = "TooManyHiddenElements";
4478
- CommandResult[CommandResult["Readonly"] = 67] = "Readonly";
4479
- CommandResult[CommandResult["InvalidViewportSize"] = 68] = "InvalidViewportSize";
4480
- CommandResult[CommandResult["InvalidScrollingDirection"] = 69] = "InvalidScrollingDirection";
4481
- CommandResult[CommandResult["FigureDoesNotExist"] = 70] = "FigureDoesNotExist";
4482
- CommandResult[CommandResult["InvalidConditionalFormatId"] = 71] = "InvalidConditionalFormatId";
4483
- CommandResult[CommandResult["InvalidCellPopover"] = 72] = "InvalidCellPopover";
4484
- CommandResult[CommandResult["EmptyTarget"] = 73] = "EmptyTarget";
4485
- CommandResult[CommandResult["InvalidFreezeQuantity"] = 74] = "InvalidFreezeQuantity";
4486
- CommandResult[CommandResult["FrozenPaneOverlap"] = 75] = "FrozenPaneOverlap";
4487
- CommandResult[CommandResult["ValuesNotChanged"] = 76] = "ValuesNotChanged";
4488
- CommandResult[CommandResult["InvalidFilterZone"] = 77] = "InvalidFilterZone";
4489
- CommandResult[CommandResult["FilterOverlap"] = 78] = "FilterOverlap";
4490
- CommandResult[CommandResult["FilterNotFound"] = 79] = "FilterNotFound";
4491
- CommandResult[CommandResult["MergeInFilter"] = 80] = "MergeInFilter";
4492
- CommandResult[CommandResult["NonContinuousTargets"] = 81] = "NonContinuousTargets";
4493
- CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
4494
- CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
4495
- CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
4496
- CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
4497
- CommandResult[CommandResult["InvalidHeaderIndex"] = 86] = "InvalidHeaderIndex";
4498
- CommandResult[CommandResult["InvalidQuantity"] = 87] = "InvalidQuantity";
4499
- CommandResult[CommandResult["MoreThanOneColumnSelected"] = 88] = "MoreThanOneColumnSelected";
4500
- CommandResult[CommandResult["EmptySplitSeparator"] = 89] = "EmptySplitSeparator";
4501
- CommandResult[CommandResult["SplitWillOverwriteContent"] = 90] = "SplitWillOverwriteContent";
4502
- CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 91] = "NoSplitSeparatorInSelection";
4503
- CommandResult[CommandResult["NoActiveSheet"] = 92] = "NoActiveSheet";
4504
- CommandResult[CommandResult["NoChanges"] = 93] = "NoChanges";
4448
+ CommandResult[CommandResult["InvalidInputId"] = 31] = "InvalidInputId";
4449
+ CommandResult[CommandResult["InvalidChartDefinition"] = 32] = "InvalidChartDefinition";
4450
+ CommandResult[CommandResult["InvalidDataSet"] = 33] = "InvalidDataSet";
4451
+ CommandResult[CommandResult["InvalidLabelRange"] = 34] = "InvalidLabelRange";
4452
+ CommandResult[CommandResult["InvalidScorecardKeyValue"] = 35] = "InvalidScorecardKeyValue";
4453
+ CommandResult[CommandResult["InvalidScorecardBaseline"] = 36] = "InvalidScorecardBaseline";
4454
+ CommandResult[CommandResult["InvalidGaugeDataRange"] = 37] = "InvalidGaugeDataRange";
4455
+ CommandResult[CommandResult["EmptyGaugeRangeMin"] = 38] = "EmptyGaugeRangeMin";
4456
+ CommandResult[CommandResult["GaugeRangeMinNaN"] = 39] = "GaugeRangeMinNaN";
4457
+ CommandResult[CommandResult["EmptyGaugeRangeMax"] = 40] = "EmptyGaugeRangeMax";
4458
+ CommandResult[CommandResult["GaugeRangeMaxNaN"] = 41] = "GaugeRangeMaxNaN";
4459
+ CommandResult[CommandResult["GaugeRangeMinBiggerThanRangeMax"] = 42] = "GaugeRangeMinBiggerThanRangeMax";
4460
+ CommandResult[CommandResult["GaugeLowerInflectionPointNaN"] = 43] = "GaugeLowerInflectionPointNaN";
4461
+ CommandResult[CommandResult["GaugeUpperInflectionPointNaN"] = 44] = "GaugeUpperInflectionPointNaN";
4462
+ CommandResult[CommandResult["GaugeLowerBiggerThanUpper"] = 45] = "GaugeLowerBiggerThanUpper";
4463
+ CommandResult[CommandResult["InvalidAutofillSelection"] = 46] = "InvalidAutofillSelection";
4464
+ CommandResult[CommandResult["WrongComposerSelection"] = 47] = "WrongComposerSelection";
4465
+ CommandResult[CommandResult["MinBiggerThanMax"] = 48] = "MinBiggerThanMax";
4466
+ CommandResult[CommandResult["LowerBiggerThanUpper"] = 49] = "LowerBiggerThanUpper";
4467
+ CommandResult[CommandResult["MidBiggerThanMax"] = 50] = "MidBiggerThanMax";
4468
+ CommandResult[CommandResult["MinBiggerThanMid"] = 51] = "MinBiggerThanMid";
4469
+ CommandResult[CommandResult["FirstArgMissing"] = 52] = "FirstArgMissing";
4470
+ CommandResult[CommandResult["SecondArgMissing"] = 53] = "SecondArgMissing";
4471
+ CommandResult[CommandResult["MinNaN"] = 54] = "MinNaN";
4472
+ CommandResult[CommandResult["MidNaN"] = 55] = "MidNaN";
4473
+ CommandResult[CommandResult["MaxNaN"] = 56] = "MaxNaN";
4474
+ CommandResult[CommandResult["ValueUpperInflectionNaN"] = 57] = "ValueUpperInflectionNaN";
4475
+ CommandResult[CommandResult["ValueLowerInflectionNaN"] = 58] = "ValueLowerInflectionNaN";
4476
+ CommandResult[CommandResult["MinInvalidFormula"] = 59] = "MinInvalidFormula";
4477
+ CommandResult[CommandResult["MidInvalidFormula"] = 60] = "MidInvalidFormula";
4478
+ CommandResult[CommandResult["MaxInvalidFormula"] = 61] = "MaxInvalidFormula";
4479
+ CommandResult[CommandResult["ValueUpperInvalidFormula"] = 62] = "ValueUpperInvalidFormula";
4480
+ CommandResult[CommandResult["ValueLowerInvalidFormula"] = 63] = "ValueLowerInvalidFormula";
4481
+ CommandResult[CommandResult["InvalidSortZone"] = 64] = "InvalidSortZone";
4482
+ CommandResult[CommandResult["WaitingSessionConfirmation"] = 65] = "WaitingSessionConfirmation";
4483
+ CommandResult[CommandResult["MergeOverlap"] = 66] = "MergeOverlap";
4484
+ CommandResult[CommandResult["TooManyHiddenElements"] = 67] = "TooManyHiddenElements";
4485
+ CommandResult[CommandResult["Readonly"] = 68] = "Readonly";
4486
+ CommandResult[CommandResult["InvalidViewportSize"] = 69] = "InvalidViewportSize";
4487
+ CommandResult[CommandResult["InvalidScrollingDirection"] = 70] = "InvalidScrollingDirection";
4488
+ CommandResult[CommandResult["FigureDoesNotExist"] = 71] = "FigureDoesNotExist";
4489
+ CommandResult[CommandResult["InvalidConditionalFormatId"] = 72] = "InvalidConditionalFormatId";
4490
+ CommandResult[CommandResult["InvalidCellPopover"] = 73] = "InvalidCellPopover";
4491
+ CommandResult[CommandResult["EmptyTarget"] = 74] = "EmptyTarget";
4492
+ CommandResult[CommandResult["InvalidFreezeQuantity"] = 75] = "InvalidFreezeQuantity";
4493
+ CommandResult[CommandResult["FrozenPaneOverlap"] = 76] = "FrozenPaneOverlap";
4494
+ CommandResult[CommandResult["ValuesNotChanged"] = 77] = "ValuesNotChanged";
4495
+ CommandResult[CommandResult["InvalidFilterZone"] = 78] = "InvalidFilterZone";
4496
+ CommandResult[CommandResult["FilterOverlap"] = 79] = "FilterOverlap";
4497
+ CommandResult[CommandResult["FilterNotFound"] = 80] = "FilterNotFound";
4498
+ CommandResult[CommandResult["MergeInFilter"] = 81] = "MergeInFilter";
4499
+ CommandResult[CommandResult["NonContinuousTargets"] = 82] = "NonContinuousTargets";
4500
+ CommandResult[CommandResult["DuplicatedFigureId"] = 83] = "DuplicatedFigureId";
4501
+ CommandResult[CommandResult["InvalidSelectionStep"] = 84] = "InvalidSelectionStep";
4502
+ CommandResult[CommandResult["DuplicatedChartId"] = 85] = "DuplicatedChartId";
4503
+ CommandResult[CommandResult["ChartDoesNotExist"] = 86] = "ChartDoesNotExist";
4504
+ CommandResult[CommandResult["InvalidHeaderIndex"] = 87] = "InvalidHeaderIndex";
4505
+ CommandResult[CommandResult["InvalidQuantity"] = 88] = "InvalidQuantity";
4506
+ CommandResult[CommandResult["MoreThanOneColumnSelected"] = 89] = "MoreThanOneColumnSelected";
4507
+ CommandResult[CommandResult["EmptySplitSeparator"] = 90] = "EmptySplitSeparator";
4508
+ CommandResult[CommandResult["SplitWillOverwriteContent"] = 91] = "SplitWillOverwriteContent";
4509
+ CommandResult[CommandResult["NoSplitSeparatorInSelection"] = 92] = "NoSplitSeparatorInSelection";
4510
+ CommandResult[CommandResult["NoActiveSheet"] = 93] = "NoActiveSheet";
4511
+ CommandResult[CommandResult["NoChanges"] = 94] = "NoChanges";
4505
4512
  })(exports.CommandResult || (exports.CommandResult = {}));
4506
4513
 
4507
4514
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
@@ -6461,14 +6468,8 @@ function createDataSets(getters, dataSetsString, sheetId, dataSetsHaveTitle) {
6461
6468
  : undefined));
6462
6469
  }
6463
6470
  }
6464
- else if (zone.left === zone.right && zone.top === zone.bottom) {
6465
- // A single cell. If it's only the title, the dataset is not added.
6466
- if (!dataSetsHaveTitle) {
6467
- dataSets.push(createDataSet(getters, dataSetSheetId, zone, undefined));
6468
- }
6469
- }
6470
6471
  else {
6471
- /* 1 row or 1 column */
6472
+ /* 1 cell, 1 row or 1 column */
6472
6473
  dataSets.push(createDataSet(getters, dataSetSheetId, zone, dataSetsHaveTitle
6473
6474
  ? {
6474
6475
  top: zone.top,
@@ -6517,8 +6518,10 @@ function toExcelDataset(getters, ds) {
6517
6518
  }
6518
6519
  const dataRange = ds.dataRange.clone({ zone: dataZone });
6519
6520
  return {
6520
- label: ds.labelCell ? getters.getRangeString(ds.labelCell, "forceSheetReference") : undefined,
6521
- range: getters.getRangeString(dataRange, "forceSheetReference"),
6521
+ label: ds.labelCell
6522
+ ? getters.getRangeString(ds.labelCell, "forceSheetReference", true)
6523
+ : undefined,
6524
+ range: getters.getRangeString(dataRange, "forceSheetReference", true),
6522
6525
  };
6523
6526
  }
6524
6527
  function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
@@ -6531,7 +6534,7 @@ function toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel) {
6531
6534
  zone.top = zone.top + 1;
6532
6535
  }
6533
6536
  const range = labelRange.clone({ zone });
6534
- return getters.getRangeString(range, "forceSheetReference");
6537
+ return getters.getRangeString(range, "forceSheetReference", true);
6535
6538
  }
6536
6539
  /**
6537
6540
  * Transform a chart definition which supports dataSets (dataSets and LabelRange)
@@ -6597,11 +6600,11 @@ function checkDataset(definition) {
6597
6600
  if (definition.dataSets) {
6598
6601
  const invalidRanges = definition.dataSets.find((range) => !rangeReference.test(range)) !== undefined;
6599
6602
  if (invalidRanges) {
6600
- return 32 /* CommandResult.InvalidDataSet */;
6603
+ return 33 /* CommandResult.InvalidDataSet */;
6601
6604
  }
6602
6605
  const zones = definition.dataSets.map(toUnboundedZone);
6603
6606
  if (zones.some((zone) => zone.top !== zone.bottom && isFullRow(zone))) {
6604
- return 32 /* CommandResult.InvalidDataSet */;
6607
+ return 33 /* CommandResult.InvalidDataSet */;
6605
6608
  }
6606
6609
  }
6607
6610
  return 0 /* CommandResult.Success */;
@@ -6610,7 +6613,7 @@ function checkLabelRange(definition) {
6610
6613
  if (definition.labelRange) {
6611
6614
  const invalidLabels = !rangeReference.test(definition.labelRange || "");
6612
6615
  if (invalidLabels) {
6613
- return 33 /* CommandResult.InvalidLabelRange */;
6616
+ return 34 /* CommandResult.InvalidLabelRange */;
6614
6617
  }
6615
6618
  }
6616
6619
  return 0 /* CommandResult.Success */;
@@ -6697,22 +6700,22 @@ function getChartPositionAtCenterOfViewport(getters, chartSize) {
6697
6700
  const CfTerms = {
6698
6701
  Errors: {
6699
6702
  [25 /* CommandResult.InvalidRange */]: _lt("The range is invalid"),
6700
- [51 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6701
- [52 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6702
- [53 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6703
- [54 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6704
- [55 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6705
- [56 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6706
- [57 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6707
- [47 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6708
- [50 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6709
- [49 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6710
- [48 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6711
- [58 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6712
- [60 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6713
- [59 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6714
- [61 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6715
- [62 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6703
+ [52 /* CommandResult.FirstArgMissing */]: _lt("The argument is missing. Please provide a value"),
6704
+ [53 /* CommandResult.SecondArgMissing */]: _lt("The second argument is missing. Please provide a value"),
6705
+ [54 /* CommandResult.MinNaN */]: _lt("The minpoint must be a number"),
6706
+ [55 /* CommandResult.MidNaN */]: _lt("The midpoint must be a number"),
6707
+ [56 /* CommandResult.MaxNaN */]: _lt("The maxpoint must be a number"),
6708
+ [57 /* CommandResult.ValueUpperInflectionNaN */]: _lt("The first value must be a number"),
6709
+ [58 /* CommandResult.ValueLowerInflectionNaN */]: _lt("The second value must be a number"),
6710
+ [48 /* CommandResult.MinBiggerThanMax */]: _lt("Minimum must be smaller then Maximum"),
6711
+ [51 /* CommandResult.MinBiggerThanMid */]: _lt("Minimum must be smaller then Midpoint"),
6712
+ [50 /* CommandResult.MidBiggerThanMax */]: _lt("Midpoint must be smaller then Maximum"),
6713
+ [49 /* CommandResult.LowerBiggerThanUpper */]: _lt("Lower inflection point must be smaller than upper inflection point"),
6714
+ [59 /* CommandResult.MinInvalidFormula */]: _lt("Invalid Minpoint formula"),
6715
+ [61 /* CommandResult.MaxInvalidFormula */]: _lt("Invalid Maxpoint formula"),
6716
+ [60 /* CommandResult.MidInvalidFormula */]: _lt("Invalid Midpoint formula"),
6717
+ [62 /* CommandResult.ValueUpperInvalidFormula */]: _lt("Invalid upper inflection point formula"),
6718
+ [63 /* CommandResult.ValueLowerInvalidFormula */]: _lt("Invalid lower inflection point formula"),
6716
6719
  [24 /* CommandResult.EmptyRange */]: _lt("A range needs to be defined"),
6717
6720
  Unexpected: _lt("The rule is invalid for an unknown reason"),
6718
6721
  },
@@ -6740,20 +6743,20 @@ const ChartTerms = {
6740
6743
  Errors: {
6741
6744
  Unexpected: _lt("The chart definition is invalid for an unknown reason"),
6742
6745
  // BASIC CHART ERRORS (LINE | BAR | PIE)
6743
- [32 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6744
- [33 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6746
+ [33 /* CommandResult.InvalidDataSet */]: _lt("The dataset is invalid"),
6747
+ [34 /* CommandResult.InvalidLabelRange */]: _lt("Labels are invalid"),
6745
6748
  // SCORECARD CHART ERRORS
6746
- [34 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6747
- [35 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6749
+ [35 /* CommandResult.InvalidScorecardKeyValue */]: _lt("The key value is invalid"),
6750
+ [36 /* CommandResult.InvalidScorecardBaseline */]: _lt("The baseline value is invalid"),
6748
6751
  // GAUGE CHART ERRORS
6749
- [36 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6750
- [37 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6751
- [38 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6752
- [39 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6753
- [40 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6754
- [41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6755
- [42 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6756
- [43 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6752
+ [37 /* CommandResult.InvalidGaugeDataRange */]: _lt("The data range is invalid"),
6753
+ [38 /* CommandResult.EmptyGaugeRangeMin */]: _lt("A minimum range limit value is needed"),
6754
+ [39 /* CommandResult.GaugeRangeMinNaN */]: _lt("The minimum range limit value must be a number"),
6755
+ [40 /* CommandResult.EmptyGaugeRangeMax */]: _lt("A maximum range limit value is needed"),
6756
+ [41 /* CommandResult.GaugeRangeMaxNaN */]: _lt("The maximum range limit value must be a number"),
6757
+ [42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */]: _lt("Minimum range limit must be smaller than maximum range limit"),
6758
+ [43 /* CommandResult.GaugeLowerInflectionPointNaN */]: _lt("The lower inflection point value must be a number"),
6759
+ [44 /* CommandResult.GaugeUpperInflectionPointNaN */]: _lt("The upper inflection point value must be a number"),
6757
6760
  },
6758
6761
  };
6759
6762
  const CustomCurrencyTerms = {
@@ -6763,9 +6766,9 @@ const MergeErrorMessage = _lt("Merged cells are preventing this operation. Unmer
6763
6766
  const SplitToColumnsTerms = {
6764
6767
  Errors: {
6765
6768
  Unexpected: _lt("Cannot split the selection for an unknown reason"),
6766
- [91 /* CommandResult.NoSplitSeparatorInSelection */]: _lt("There is no match for the selected separator in the selection"),
6767
- [88 /* CommandResult.MoreThanOneColumnSelected */]: _lt("Only a selection from a single column can be split"),
6768
- [90 /* CommandResult.SplitWillOverwriteContent */]: _lt("Splitting will overwrite existing content"),
6769
+ [92 /* CommandResult.NoSplitSeparatorInSelection */]: _lt("There is no match for the selected separator in the selection"),
6770
+ [89 /* CommandResult.MoreThanOneColumnSelected */]: _lt("Only a selection from a single column can be split"),
6771
+ [91 /* CommandResult.SplitWillOverwriteContent */]: _lt("Splitting will overwrite existing content"),
6769
6772
  },
6770
6773
  };
6771
6774
 
@@ -7068,7 +7071,7 @@ class BarChart extends AbstractChart {
7068
7071
  return undefined;
7069
7072
  const dataSets = this.dataSets
7070
7073
  .map((ds) => toExcelDataset(this.getters, ds))
7071
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7074
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7072
7075
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7073
7076
  return {
7074
7077
  ...this.getDefinition(),
@@ -7169,7 +7172,7 @@ function createBarChartRuntime(chart, getters) {
7169
7172
 
7170
7173
  function isDataRangeValid(definition) {
7171
7174
  return definition.dataRange && !rangeReference.test(definition.dataRange)
7172
- ? 36 /* CommandResult.InvalidGaugeDataRange */
7175
+ ? 37 /* CommandResult.InvalidGaugeDataRange */
7173
7176
  : 0 /* CommandResult.Success */;
7174
7177
  }
7175
7178
  function checkRangeLimits(check, batchValidations) {
@@ -7201,7 +7204,7 @@ function checkInflectionPointsValue(check, batchValidations) {
7201
7204
  function checkRangeMinBiggerThanRangeMax(definition) {
7202
7205
  if (definition.sectionRule) {
7203
7206
  if (Number(definition.sectionRule.rangeMin) >= Number(definition.sectionRule.rangeMax)) {
7204
- return 41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7207
+ return 42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */;
7205
7208
  }
7206
7209
  }
7207
7210
  return 0 /* CommandResult.Success */;
@@ -7210,9 +7213,9 @@ function checkEmpty(value, valueName) {
7210
7213
  if (value === "") {
7211
7214
  switch (valueName) {
7212
7215
  case "rangeMin":
7213
- return 37 /* CommandResult.EmptyGaugeRangeMin */;
7216
+ return 38 /* CommandResult.EmptyGaugeRangeMin */;
7214
7217
  case "rangeMax":
7215
- return 39 /* CommandResult.EmptyGaugeRangeMax */;
7218
+ return 40 /* CommandResult.EmptyGaugeRangeMax */;
7216
7219
  }
7217
7220
  }
7218
7221
  return 0 /* CommandResult.Success */;
@@ -7221,13 +7224,13 @@ function checkNaN(value, valueName) {
7221
7224
  if (isNaN(value)) {
7222
7225
  switch (valueName) {
7223
7226
  case "rangeMin":
7224
- return 38 /* CommandResult.GaugeRangeMinNaN */;
7227
+ return 39 /* CommandResult.GaugeRangeMinNaN */;
7225
7228
  case "rangeMax":
7226
- return 40 /* CommandResult.GaugeRangeMaxNaN */;
7229
+ return 41 /* CommandResult.GaugeRangeMaxNaN */;
7227
7230
  case "lowerInflectionPointValue":
7228
- return 42 /* CommandResult.GaugeLowerInflectionPointNaN */;
7231
+ return 43 /* CommandResult.GaugeLowerInflectionPointNaN */;
7229
7232
  case "upperInflectionPointValue":
7230
- return 43 /* CommandResult.GaugeUpperInflectionPointNaN */;
7233
+ return 44 /* CommandResult.GaugeUpperInflectionPointNaN */;
7231
7234
  }
7232
7235
  }
7233
7236
  return 0 /* CommandResult.Success */;
@@ -7652,7 +7655,7 @@ class LineChart extends AbstractChart {
7652
7655
  return undefined;
7653
7656
  const dataSets = this.dataSets
7654
7657
  .map((ds) => toExcelDataset(this.getters, ds))
7655
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7658
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7656
7659
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7657
7660
  return {
7658
7661
  ...this.getDefinition(),
@@ -7937,7 +7940,7 @@ class PieChart extends AbstractChart {
7937
7940
  return undefined;
7938
7941
  const dataSets = this.dataSets
7939
7942
  .map((ds) => toExcelDataset(this.getters, ds))
7940
- .filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
7943
+ .filter((ds) => ds.range !== "" && ds.range !== INCORRECT_RANGE_STRING);
7941
7944
  const labelRange = toExcelLabelRange(this.getters, this.labelRange, shouldRemoveFirstLabel(this.labelRange, this.dataSets[0], this.dataSetsHaveTitle));
7942
7945
  return {
7943
7946
  ...this.getDefinition(),
@@ -8017,12 +8020,12 @@ function createPieChartRuntime(chart, getters) {
8017
8020
 
8018
8021
  function checkKeyValue(definition) {
8019
8022
  return definition.keyValue && !rangeReference.test(definition.keyValue)
8020
- ? 34 /* CommandResult.InvalidScorecardKeyValue */
8023
+ ? 35 /* CommandResult.InvalidScorecardKeyValue */
8021
8024
  : 0 /* CommandResult.Success */;
8022
8025
  }
8023
8026
  function checkBaseline(definition) {
8024
8027
  return definition.baseline && !rangeReference.test(definition.baseline)
8025
- ? 35 /* CommandResult.InvalidScorecardBaseline */
8028
+ ? 36 /* CommandResult.InvalidScorecardBaseline */
8026
8029
  : 0 /* CommandResult.Success */;
8027
8030
  }
8028
8031
  class ScorecardChart extends AbstractChart {
@@ -8528,7 +8531,7 @@ const AddMergeInteractiveContent = {
8528
8531
  };
8529
8532
  function interactiveAddMerge(env, sheetId, target) {
8530
8533
  const result = env.model.dispatch("ADD_MERGE", { sheetId, target });
8531
- if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
8534
+ if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
8532
8535
  env.raiseError(AddMergeInteractiveContent.MergeInFilter);
8533
8536
  }
8534
8537
  else if (result.isCancelledBecause(3 /* CommandResult.MergeIsDestructive */)) {
@@ -8778,7 +8781,7 @@ function interactiveSortSelection(env, sheetId, anchor, zone, sortDirection) {
8778
8781
  });
8779
8782
  }
8780
8783
  }
8781
- if (result.isCancelledBecause(63 /* CommandResult.InvalidSortZone */)) {
8784
+ if (result.isCancelledBecause(64 /* CommandResult.InvalidSortZone */)) {
8782
8785
  const { col, row } = anchor;
8783
8786
  env.model.selection.selectZone({ cell: { col, row }, zone });
8784
8787
  env.raiseError(_lt("Cannot sort. To sort, select only cells or only merges that have the same size."));
@@ -8801,13 +8804,13 @@ const AddFilterInteractiveContent = {
8801
8804
  };
8802
8805
  function interactiveAddFilter(env, sheetId, target) {
8803
8806
  const result = env.model.dispatch("CREATE_FILTER_TABLE", { target, sheetId });
8804
- if (result.isCancelledBecause(78 /* CommandResult.FilterOverlap */)) {
8807
+ if (result.isCancelledBecause(79 /* CommandResult.FilterOverlap */)) {
8805
8808
  env.raiseError(AddFilterInteractiveContent.filterOverlap);
8806
8809
  }
8807
- else if (result.isCancelledBecause(80 /* CommandResult.MergeInFilter */)) {
8810
+ else if (result.isCancelledBecause(81 /* CommandResult.MergeInFilter */)) {
8808
8811
  env.raiseError(AddFilterInteractiveContent.mergeInFilter);
8809
8812
  }
8810
- else if (result.isCancelledBecause(81 /* CommandResult.NonContinuousTargets */)) {
8813
+ else if (result.isCancelledBecause(82 /* CommandResult.NonContinuousTargets */)) {
8811
8814
  env.raiseError(AddFilterInteractiveContent.nonContinuousTargets);
8812
8815
  }
8813
8816
  }
@@ -8829,7 +8832,7 @@ function handlePasteResult(env, result) {
8829
8832
  else if (result.reasons.includes(22 /* CommandResult.WrongFigurePasteOption */)) {
8830
8833
  env.raiseError(PasteInteractiveContent.wrongFigurePasteOption);
8831
8834
  }
8832
- else if (result.reasons.includes(75 /* CommandResult.FrozenPaneOverlap */)) {
8835
+ else if (result.reasons.includes(76 /* CommandResult.FrozenPaneOverlap */)) {
8833
8836
  env.raiseError(PasteInteractiveContent.frozenPaneOverlap);
8834
8837
  }
8835
8838
  }
@@ -16987,7 +16990,7 @@ function interactiveFreezeColumnsRows(env, dimension, base) {
16987
16990
  const sheetId = env.model.getters.getActiveSheetId();
16988
16991
  const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
16989
16992
  const result = env.model.dispatch(cmd, { sheetId, quantity: base });
16990
- if (result.isCancelledBecause(65 /* CommandResult.MergeOverlap */)) {
16993
+ if (result.isCancelledBecause(66 /* CommandResult.MergeOverlap */)) {
16991
16994
  env.raiseError(MergeErrorMessage);
16992
16995
  }
16993
16996
  }
@@ -18010,10 +18013,10 @@ class LineBarPieConfigPanel extends owl.Component {
18010
18013
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18011
18014
  }
18012
18015
  get isDatasetInvalid() {
18013
- return !!this.state.datasetDispatchResult?.isCancelledBecause(32 /* CommandResult.InvalidDataSet */);
18016
+ return !!this.state.datasetDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidDataSet */);
18014
18017
  }
18015
18018
  get isLabelInvalid() {
18016
- return !!this.state.labelsDispatchResult?.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */);
18019
+ return !!this.state.labelsDispatchResult?.isCancelledBecause(34 /* CommandResult.InvalidLabelRange */);
18017
18020
  }
18018
18021
  onUpdateDataSetsHaveTitle(ev) {
18019
18022
  this.props.updateChart(this.props.figureId, {
@@ -18455,7 +18458,7 @@ class GaugeChartConfigPanel extends owl.Component {
18455
18458
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18456
18459
  }
18457
18460
  get isDataRangeInvalid() {
18458
- return !!this.state.dataRangeDispatchResult?.isCancelledBecause(36 /* CommandResult.InvalidGaugeDataRange */);
18461
+ return !!this.state.dataRangeDispatchResult?.isCancelledBecause(37 /* CommandResult.InvalidGaugeDataRange */);
18459
18462
  }
18460
18463
  onDataRangeChanged(ranges) {
18461
18464
  this.dataRange = ranges[0];
@@ -18529,25 +18532,25 @@ class GaugeChartDesignPanel extends owl.Component {
18529
18532
  });
18530
18533
  }
18531
18534
  isRangeMinInvalid() {
18532
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(37 /* CommandResult.EmptyGaugeRangeMin */) ||
18533
- this.state.sectionRuleDispatchResult?.isCancelledBecause(38 /* CommandResult.GaugeRangeMinNaN */) ||
18534
- this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18535
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(38 /* CommandResult.EmptyGaugeRangeMin */) ||
18536
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(39 /* CommandResult.GaugeRangeMinNaN */) ||
18537
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18535
18538
  }
18536
18539
  isRangeMaxInvalid() {
18537
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(39 /* CommandResult.EmptyGaugeRangeMax */) ||
18538
- this.state.sectionRuleDispatchResult?.isCancelledBecause(40 /* CommandResult.GaugeRangeMaxNaN */) ||
18539
- this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18540
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(40 /* CommandResult.EmptyGaugeRangeMax */) ||
18541
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(41 /* CommandResult.GaugeRangeMaxNaN */) ||
18542
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeRangeMinBiggerThanRangeMax */));
18540
18543
  }
18541
18544
  // ---------------------------------------------------------------------------
18542
18545
  // COLOR_SECTION_TEMPLATE
18543
18546
  // ---------------------------------------------------------------------------
18544
18547
  get isLowerInflectionPointInvalid() {
18545
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(42 /* CommandResult.GaugeLowerInflectionPointNaN */) ||
18546
- this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */));
18548
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(43 /* CommandResult.GaugeLowerInflectionPointNaN */) ||
18549
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */));
18547
18550
  }
18548
18551
  get isUpperInflectionPointInvalid() {
18549
- return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(43 /* CommandResult.GaugeUpperInflectionPointNaN */) ||
18550
- this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeLowerBiggerThanUpper */));
18552
+ return !!(this.state.sectionRuleDispatchResult?.isCancelledBecause(44 /* CommandResult.GaugeUpperInflectionPointNaN */) ||
18553
+ this.state.sectionRuleDispatchResult?.isCancelledBecause(45 /* CommandResult.GaugeLowerBiggerThanUpper */));
18551
18554
  }
18552
18555
  updateInflectionPointValue(attr, ev) {
18553
18556
  const sectionRule = deepCopy(this.props.definition.sectionRule);
@@ -18655,10 +18658,10 @@ class ScorecardChartConfigPanel extends owl.Component {
18655
18658
  return cancelledReasons.map((error) => ChartTerms.Errors[error] || ChartTerms.Errors.Unexpected);
18656
18659
  }
18657
18660
  get isKeyValueInvalid() {
18658
- return !!this.state.keyValueDispatchResult?.isCancelledBecause(34 /* CommandResult.InvalidScorecardKeyValue */);
18661
+ return !!this.state.keyValueDispatchResult?.isCancelledBecause(35 /* CommandResult.InvalidScorecardKeyValue */);
18659
18662
  }
18660
18663
  get isBaselineInvalid() {
18661
- return !!this.state.keyValueDispatchResult?.isCancelledBecause(35 /* CommandResult.InvalidScorecardBaseline */);
18664
+ return !!this.state.keyValueDispatchResult?.isCancelledBecause(36 /* CommandResult.InvalidScorecardBaseline */);
18662
18665
  }
18663
18666
  onKeyValueRangeChanged(ranges) {
18664
18667
  this.keyValue = ranges[0];
@@ -19518,10 +19521,10 @@ class ConditionalFormattingPanel extends owl.Component {
19518
19521
  * Cell Is Rule
19519
19522
  ****************************************************************************/
19520
19523
  get isValue1Invalid() {
19521
- return !!this.state.errors?.includes(51 /* CommandResult.FirstArgMissing */);
19524
+ return !!this.state.errors?.includes(52 /* CommandResult.FirstArgMissing */);
19522
19525
  }
19523
19526
  get isValue2Invalid() {
19524
- return !!this.state.errors?.includes(52 /* CommandResult.SecondArgMissing */);
19527
+ return !!this.state.errors?.includes(53 /* CommandResult.SecondArgMissing */);
19525
19528
  }
19526
19529
  toggleStyle(tool) {
19527
19530
  const style = this.state.rules.cellIs.style;
@@ -19538,17 +19541,17 @@ class ConditionalFormattingPanel extends owl.Component {
19538
19541
  isValueInvalid(threshold) {
19539
19542
  switch (threshold) {
19540
19543
  case "minimum":
19541
- return (this.state.errors.includes(58 /* CommandResult.MinInvalidFormula */) ||
19542
- this.state.errors.includes(50 /* CommandResult.MinBiggerThanMid */) ||
19543
- this.state.errors.includes(47 /* CommandResult.MinBiggerThanMax */) ||
19544
- this.state.errors.includes(53 /* CommandResult.MinNaN */));
19544
+ return (this.state.errors.includes(59 /* CommandResult.MinInvalidFormula */) ||
19545
+ this.state.errors.includes(51 /* CommandResult.MinBiggerThanMid */) ||
19546
+ this.state.errors.includes(48 /* CommandResult.MinBiggerThanMax */) ||
19547
+ this.state.errors.includes(54 /* CommandResult.MinNaN */));
19545
19548
  case "midpoint":
19546
- return (this.state.errors.includes(59 /* CommandResult.MidInvalidFormula */) ||
19547
- this.state.errors.includes(54 /* CommandResult.MidNaN */) ||
19548
- this.state.errors.includes(49 /* CommandResult.MidBiggerThanMax */));
19549
+ return (this.state.errors.includes(60 /* CommandResult.MidInvalidFormula */) ||
19550
+ this.state.errors.includes(55 /* CommandResult.MidNaN */) ||
19551
+ this.state.errors.includes(50 /* CommandResult.MidBiggerThanMax */));
19549
19552
  case "maximum":
19550
- return (this.state.errors.includes(60 /* CommandResult.MaxInvalidFormula */) ||
19551
- this.state.errors.includes(55 /* CommandResult.MaxNaN */));
19553
+ return (this.state.errors.includes(61 /* CommandResult.MaxInvalidFormula */) ||
19554
+ this.state.errors.includes(56 /* CommandResult.MaxNaN */));
19552
19555
  default:
19553
19556
  return false;
19554
19557
  }
@@ -19596,13 +19599,13 @@ class ConditionalFormattingPanel extends owl.Component {
19596
19599
  isInflectionPointInvalid(inflectionPoint) {
19597
19600
  switch (inflectionPoint) {
19598
19601
  case "lowerInflectionPoint":
19599
- return (this.state.errors.includes(57 /* CommandResult.ValueLowerInflectionNaN */) ||
19600
- this.state.errors.includes(62 /* CommandResult.ValueLowerInvalidFormula */) ||
19601
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
19602
+ return (this.state.errors.includes(58 /* CommandResult.ValueLowerInflectionNaN */) ||
19603
+ this.state.errors.includes(63 /* CommandResult.ValueLowerInvalidFormula */) ||
19604
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
19602
19605
  case "upperInflectionPoint":
19603
- return (this.state.errors.includes(56 /* CommandResult.ValueUpperInflectionNaN */) ||
19604
- this.state.errors.includes(61 /* CommandResult.ValueUpperInvalidFormula */) ||
19605
- this.state.errors.includes(48 /* CommandResult.LowerBiggerThanUpper */));
19606
+ return (this.state.errors.includes(57 /* CommandResult.ValueUpperInflectionNaN */) ||
19607
+ this.state.errors.includes(62 /* CommandResult.ValueUpperInvalidFormula */) ||
19608
+ this.state.errors.includes(49 /* CommandResult.LowerBiggerThanUpper */));
19606
19609
  default:
19607
19610
  return true;
19608
19611
  }
@@ -19913,7 +19916,7 @@ const SplitToColumnsInteractiveContent = {
19913
19916
  };
19914
19917
  function interactiveSplitToColumns(env, separator, addNewColumns) {
19915
19918
  let result = env.model.dispatch("SPLIT_TEXT_INTO_COLUMNS", { separator, addNewColumns });
19916
- if (result.isCancelledBecause(90 /* CommandResult.SplitWillOverwriteContent */)) {
19919
+ if (result.isCancelledBecause(91 /* CommandResult.SplitWillOverwriteContent */)) {
19917
19920
  env.askConfirmation(SplitToColumnsInteractiveContent.SplitIsDestructive, () => {
19918
19921
  result = env.model.dispatch("SPLIT_TEXT_INTO_COLUMNS", {
19919
19922
  separator,
@@ -19976,8 +19979,8 @@ class SplitIntoColumnsPanel extends owl.Component {
19976
19979
  const errors = new Set();
19977
19980
  for (const reason of cancelledReasons) {
19978
19981
  switch (reason) {
19979
- case 90 /* CommandResult.SplitWillOverwriteContent */:
19980
- case 89 /* CommandResult.EmptySplitSeparator */:
19982
+ case 91 /* CommandResult.SplitWillOverwriteContent */:
19983
+ case 90 /* CommandResult.EmptySplitSeparator */:
19981
19984
  break;
19982
19985
  default:
19983
19986
  errors.add(SplitToColumnsTerms.Errors[reason] || SplitToColumnsTerms.Errors.Unexpected);
@@ -19992,8 +19995,8 @@ class SplitIntoColumnsPanel extends owl.Component {
19992
19995
  addNewColumns: this.state.addNewColumns,
19993
19996
  force: false,
19994
19997
  }).reasons;
19995
- if (cancelledReasons.includes(90 /* CommandResult.SplitWillOverwriteContent */)) {
19996
- warnings.push(SplitToColumnsTerms.Errors[90 /* CommandResult.SplitWillOverwriteContent */]);
19998
+ if (cancelledReasons.includes(91 /* CommandResult.SplitWillOverwriteContent */)) {
19999
+ warnings.push(SplitToColumnsTerms.Errors[91 /* CommandResult.SplitWillOverwriteContent */]);
19997
20000
  }
19998
20001
  return warnings;
19999
20002
  }
@@ -20984,6 +20987,7 @@ class Composer extends owl.Component {
20984
20987
  static components = { TextValueProvider, FunctionDescriptionProvider };
20985
20988
  static defaultProps = {
20986
20989
  inputStyle: "",
20990
+ isDefaultFocus: false,
20987
20991
  };
20988
20992
  composerRef = owl.useRef("o_composer");
20989
20993
  contentHelper = new ContentEditableHelper(this.composerRef.el);
@@ -21041,13 +21045,13 @@ class Composer extends owl.Component {
21041
21045
  setup() {
21042
21046
  owl.onMounted(() => {
21043
21047
  const el = this.composerRef.el;
21048
+ if (this.props.isDefaultFocus) {
21049
+ this.env.focusableElement.setFocusableElement(el);
21050
+ }
21044
21051
  this.contentHelper.updateEl(el);
21045
21052
  this.processContent();
21046
21053
  this.contentHelper.scrollSelectionIntoView();
21047
21054
  });
21048
- owl.onWillUnmount(() => {
21049
- this.props.onComposerUnmounted?.();
21050
- });
21051
21055
  owl.onPatched(() => {
21052
21056
  if (!this.isKeyStillDown) {
21053
21057
  this.processContent();
@@ -21058,7 +21062,8 @@ class Composer extends owl.Component {
21058
21062
  // Handlers
21059
21063
  // ---------------------------------------------------------------------------
21060
21064
  processArrowKeys(ev) {
21061
- if (this.env.model.getters.isSelectingForComposer()) {
21065
+ if (this.env.model.getters.isSelectingForComposer() ||
21066
+ this.env.model.getters.getEditionMode() === "inactive") {
21062
21067
  this.functionDescriptionState.showDescription = false;
21063
21068
  // Prevent the default content editable behavior which moves the cursor
21064
21069
  ev.preventDefault();
@@ -21098,21 +21103,23 @@ class Composer extends owl.Component {
21098
21103
  processTabKey(ev) {
21099
21104
  ev.preventDefault();
21100
21105
  ev.stopPropagation();
21101
- if (this.autoCompleteState.showProvider) {
21102
- const autoCompleteValue = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;
21103
- if (autoCompleteValue) {
21104
- this.autoComplete(autoCompleteValue);
21105
- return;
21106
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
21107
+ if (this.autoCompleteState.showProvider) {
21108
+ const autoCompleteValue = this.autoCompleteState.values[this.autoCompleteState.selectedIndex]?.text;
21109
+ if (autoCompleteValue) {
21110
+ this.autoComplete(autoCompleteValue);
21111
+ return;
21112
+ }
21106
21113
  }
21107
- }
21108
- else {
21109
- // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
21110
- // we can't let the model think that it is for a ref selection.
21111
- // todo: check if this can be removed someday
21112
- this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21114
+ else {
21115
+ // when completing with tab, if there is no value to complete, the active cell will be moved to the right.
21116
+ // we can't let the model think that it is for a ref selection.
21117
+ // todo: check if this can be removed someday
21118
+ this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21119
+ }
21120
+ this.env.model.dispatch("STOP_EDITION");
21113
21121
  }
21114
21122
  const direction = ev.shiftKey ? "left" : "right";
21115
- this.env.model.dispatch("STOP_EDITION");
21116
21123
  this.env.model.selection.moveAnchorCell(direction, 1);
21117
21124
  }
21118
21125
  processEnterKey(ev) {
@@ -21156,6 +21163,9 @@ class Composer extends owl.Component {
21156
21163
  this.compositionActive = false;
21157
21164
  }
21158
21165
  onKeydown(ev) {
21166
+ if (this.env.model.getters.getEditionMode() === "inactive") {
21167
+ return;
21168
+ }
21159
21169
  let handler = this.keyMapping[ev.key];
21160
21170
  if (handler) {
21161
21171
  handler.call(this, ev);
@@ -21166,22 +21176,44 @@ class Composer extends owl.Component {
21166
21176
  }
21167
21177
  }
21168
21178
  updateCursorIfNeeded() {
21169
- if (!this.env.model.getters.isSelectingForComposer()) {
21179
+ const moveCursor = !this.env.model.getters.isSelectingForComposer() &&
21180
+ !(this.env.model.getters.getEditionMode() === "inactive");
21181
+ if (moveCursor) {
21170
21182
  const { start, end } = this.contentHelper.getCurrentSelection();
21171
21183
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", { start, end });
21172
21184
  this.isKeyStillDown = true;
21173
21185
  }
21174
21186
  }
21187
+ onPaste(ev) {
21188
+ if (this.env.model.getters.getEditionMode() !== "inactive") {
21189
+ ev.stopPropagation();
21190
+ }
21191
+ }
21175
21192
  /*
21176
21193
  * Triggered automatically by the content-editable between the keydown and key up
21177
21194
  * */
21178
- onInput() {
21179
- if (this.props.focus === "inactive" || !this.shouldProcessInputEvents) {
21195
+ onInput(ev) {
21196
+ if (!this.shouldProcessInputEvents) {
21180
21197
  return;
21181
21198
  }
21199
+ if (ev.inputType === "insertFromPaste" &&
21200
+ this.env.model.getters.getEditionMode() === "inactive") {
21201
+ return;
21202
+ }
21203
+ ev.stopPropagation();
21204
+ let content;
21205
+ if (this.env.model.getters.getEditionMode() === "inactive") {
21206
+ content = ev.data || "";
21207
+ }
21208
+ else {
21209
+ content = this.contentHelper.getText();
21210
+ }
21211
+ if (this.props.focus === "inactive") {
21212
+ return this.props.onComposerCellFocused?.(content);
21213
+ }
21182
21214
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21183
21215
  this.env.model.dispatch("SET_CURRENT_CONTENT", {
21184
- content: this.contentHelper.getText(),
21216
+ content,
21185
21217
  selection: this.contentHelper.getCurrentSelection(),
21186
21218
  });
21187
21219
  }
@@ -21252,9 +21284,8 @@ class Composer extends owl.Component {
21252
21284
  }
21253
21285
  const newSelection = this.contentHelper.getCurrentSelection();
21254
21286
  this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");
21255
- if (this.props.focus === "inactive") {
21256
- this.props.onComposerContentFocused(newSelection);
21257
- }
21287
+ this.props.onComposerContentFocused();
21288
+ if (this.props.focus === "inactive") ;
21258
21289
  this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION", newSelection);
21259
21290
  this.processTokenAtCursor();
21260
21291
  }
@@ -21398,7 +21429,7 @@ class Composer extends owl.Component {
21398
21429
  const highlights = this.env.model.getters.getHighlights();
21399
21430
  const refSheet = sheetName
21400
21431
  ? this.env.model.getters.getSheetIdByName(sheetName)
21401
- : this.env.model.getters.getCurrentEditedCell().sheetId;
21432
+ : this.env.model.getters.getCurrentEditedCell()?.sheetId;
21402
21433
  const highlight = highlights.find((highlight) => {
21403
21434
  if (highlight.sheetId !== refSheet)
21404
21435
  return false;
@@ -21475,12 +21506,13 @@ class Composer extends owl.Component {
21475
21506
  }
21476
21507
  }
21477
21508
  Composer.props = {
21478
- focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21479
- onComposerContentFocused: Function,
21480
21509
  inputStyle: { type: String, optional: true },
21481
21510
  rect: { type: Object, optional: true },
21482
21511
  delimitation: { type: Object, optional: true },
21483
- onComposerUnmounted: { type: Function, optional: true },
21512
+ focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21513
+ onComposerCellFocused: { type: Function, optional: true },
21514
+ onComposerContentFocused: Function,
21515
+ isDefaultFocus: { type: Boolean, optional: true },
21484
21516
  };
21485
21517
 
21486
21518
  const COMPOSER_BORDER_WIDTH = 3 * 0.4 * window.devicePixelRatio || 1;
@@ -21514,51 +21546,26 @@ css /* scss */ `
21514
21546
  class GridComposer extends owl.Component {
21515
21547
  static template = "o-spreadsheet-GridComposer";
21516
21548
  static components = { Composer };
21517
- gridComposerRef;
21518
- zone;
21519
- rect;
21549
+ // TODORAR see if we can keep it undefined
21550
+ rect = this.defaultRect;
21551
+ isEditing = false;
21520
21552
  isCellReferenceVisible;
21521
- composerState;
21553
+ get defaultRect() {
21554
+ return { x: 0, y: 0, width: 0, height: 0 };
21555
+ }
21522
21556
  setup() {
21523
- this.gridComposerRef = owl.useRef("gridComposer");
21524
- this.composerState = owl.useState({
21525
- rect: undefined,
21526
- delimitation: undefined,
21527
- });
21528
- const { sheetId, col, row } = this.env.model.getters.getActivePosition();
21529
- this.zone = this.env.model.getters.expandZone(sheetId, positionToZone({ col, row }));
21530
- this.rect = this.env.model.getters.getVisibleRect(this.zone);
21531
- this.isCellReferenceVisible = false;
21532
- owl.onMounted(() => {
21533
- const el = this.gridComposerRef.el;
21534
- this.composerState.rect = {
21535
- x: this.rect.x,
21536
- y: this.rect.y,
21537
- width: el.clientWidth,
21538
- height: el.clientHeight,
21539
- };
21540
- this.composerState.delimitation = {
21541
- width: el.parentElement.clientWidth,
21542
- height: el.parentElement.clientHeight,
21543
- };
21544
- });
21545
21557
  owl.onWillUpdateProps(() => {
21546
- if (this.isCellReferenceVisible) {
21547
- return;
21548
- }
21549
- const sheetId = this.env.model.getters.getActiveSheetId();
21550
- const zone = this.env.model.getters.getSelectedZone();
21551
- const rect = this.env.model.getters.getVisibleRect(zone);
21552
- if (!deepEquals(rect, this.rect) ||
21553
- sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
21554
- this.isCellReferenceVisible = true;
21555
- }
21558
+ this.updateComponentPosition();
21559
+ this.updateCellReferenceVisibility();
21556
21560
  });
21557
21561
  }
21558
21562
  get shouldDisplayCellReference() {
21559
21563
  return this.isCellReferenceVisible;
21560
21564
  }
21561
21565
  get cellReference() {
21566
+ if (!this.env.model.getters.getCurrentEditedCell()) {
21567
+ return "";
21568
+ }
21562
21569
  const { col, row, sheetId } = this.env.model.getters.getCurrentEditedCell();
21563
21570
  const prefixSheet = sheetId !== this.env.model.getters.getActiveSheetId();
21564
21571
  return `${prefixSheet ? getCanonicalSheetName(this.env.model.getters.getSheetName(sheetId)) + "!" : ""}${toXC(col, row)}`;
@@ -21570,7 +21577,27 @@ class GridComposer extends owl.Component {
21570
21577
  top: `${top - GRID_CELL_REFERENCE_TOP_OFFSET}px`,
21571
21578
  });
21572
21579
  }
21580
+ get composerProps() {
21581
+ const { width, height } = this.env.model.getters.getSheetViewDimensionWithHeaders();
21582
+ return {
21583
+ rect: { ...this.rect },
21584
+ delimitation: {
21585
+ width,
21586
+ height,
21587
+ },
21588
+ focus: this.props.focus,
21589
+ isDefaultFocus: true,
21590
+ onComposerContentFocused: this.props.onComposerContentFocused,
21591
+ onComposerCellFocused: this.props.onComposerCellFocused,
21592
+ };
21593
+ }
21573
21594
  get containerStyle() {
21595
+ if (this.env.model.getters.getEditionMode() === "inactive" || !this.rect) {
21596
+ return `
21597
+ position: absolute;
21598
+ z-index: -1000;
21599
+ `;
21600
+ }
21574
21601
  const isFormula = this.env.model.getters.getCurrentContent().startsWith("=");
21575
21602
  const cell = this.env.model.getters.getActiveCell();
21576
21603
  const position = this.env.model.getters.getActivePosition();
@@ -21590,6 +21617,8 @@ class GridComposer extends owl.Component {
21590
21617
  if (!isFormula) {
21591
21618
  textAlign = style.align || cell.defaultAlign;
21592
21619
  }
21620
+ const maxHeight = this.props.gridDims.height - this.rect.y;
21621
+ const maxWidth = this.props.gridDims.width - this.rect.x;
21593
21622
  /**
21594
21623
  * min-size is on the container, not the composer element, because we want to have the same size as the cell by default,
21595
21624
  * including all the paddings/margins of the composer
@@ -21601,6 +21630,8 @@ class GridComposer extends owl.Component {
21601
21630
  top: `${top}px`,
21602
21631
  "min-width": `${width + 1}px`,
21603
21632
  "min-height": `${height + 1}px`,
21633
+ "max-width": `${maxWidth}px`,
21634
+ "max-height": `${maxHeight}px`,
21604
21635
  background,
21605
21636
  color,
21606
21637
  "font-size": `${fontSizeInPixels(fontSize)}px`,
@@ -21610,20 +21641,38 @@ class GridComposer extends owl.Component {
21610
21641
  "text-align": textAlign,
21611
21642
  });
21612
21643
  }
21613
- get composerStyle() {
21614
- const maxHeight = this.props.gridDims.height - this.rect.y;
21615
- const maxWidth = this.props.gridDims.width - this.rect.x;
21616
- return cssPropertiesToCss({
21617
- "max-width": `${maxWidth}px`,
21618
- "max-height": `${maxHeight}px`,
21619
- });
21644
+ updateComponentPosition() {
21645
+ const isEditing = this.env.model.getters.getEditionMode() !== "inactive";
21646
+ if (this.isEditing !== isEditing) {
21647
+ this.isEditing = isEditing;
21648
+ if (!isEditing) {
21649
+ this.rect = this.defaultRect;
21650
+ this.env.focusableElement.focus();
21651
+ return;
21652
+ }
21653
+ const position = this.env.model.getters.getActivePosition();
21654
+ const zone = this.env.model.getters.expandZone(position.sheetId, positionToZone(position));
21655
+ this.rect = this.env.model.getters.getVisibleRect(zone);
21656
+ }
21657
+ }
21658
+ updateCellReferenceVisibility() {
21659
+ if (this.isCellReferenceVisible || this.env.model.getters.getEditionMode() === "inactive") {
21660
+ return;
21661
+ }
21662
+ const sheetId = this.env.model.getters.getActiveSheetId();
21663
+ const zone = this.env.model.getters.getSelectedZone();
21664
+ const rect = this.env.model.getters.getVisibleRect(zone);
21665
+ if (!deepEquals(rect, this.rect) ||
21666
+ sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
21667
+ this.isCellReferenceVisible = true;
21668
+ }
21620
21669
  }
21621
21670
  }
21622
21671
  GridComposer.props = {
21623
21672
  focus: { validate: (value) => ["inactive", "cellFocus", "contentFocus"].includes(value) },
21624
- onComposerUnmounted: Function,
21625
21673
  onComposerContentFocused: Function,
21626
21674
  gridDims: Object,
21675
+ onComposerCellFocused: Function,
21627
21676
  };
21628
21677
 
21629
21678
  const CSS$1 = css /* scss */ `
@@ -22492,7 +22541,6 @@ class GridOverlay extends owl.Component {
22492
22541
  this.props.onCellDoubleClicked(col, row);
22493
22542
  }
22494
22543
  onContextMenu(ev) {
22495
- ev.preventDefault();
22496
22544
  const [col, row] = this.getCartesianCoordinates(ev);
22497
22545
  this.props.onCellRightClicked(col, row, { x: ev.clientX, y: ev.clientY });
22498
22546
  }
@@ -23586,7 +23634,6 @@ class Grid extends owl.Component {
23586
23634
  HEADER_WIDTH = HEADER_WIDTH;
23587
23635
  menuState;
23588
23636
  gridRef;
23589
- hiddenInput;
23590
23637
  onMouseWheel;
23591
23638
  canvasPosition;
23592
23639
  hoveredCell;
@@ -23597,17 +23644,16 @@ class Grid extends owl.Component {
23597
23644
  menuItems: [],
23598
23645
  });
23599
23646
  this.gridRef = owl.useRef("grid");
23600
- this.hiddenInput = owl.useRef("hiddenInput");
23601
23647
  this.canvasPosition = useAbsoluteBoundingRect(this.gridRef);
23602
23648
  this.hoveredCell = owl.useState({ col: undefined, row: undefined });
23603
23649
  owl.useChildSubEnv({ getPopoverContainerRect: () => this.getGridRect() });
23604
23650
  owl.useExternalListener(document.body, "cut", this.copy.bind(this, true));
23605
23651
  owl.useExternalListener(document.body, "copy", this.copy.bind(this, false));
23606
23652
  owl.useExternalListener(document.body, "paste", this.paste);
23607
- owl.onMounted(() => this.focus());
23608
- this.props.exposeFocus(() => this.focus());
23653
+ owl.onMounted(() => this.focusDefaultElement());
23654
+ this.props.exposeFocus(() => this.focusDefaultElement());
23609
23655
  useGridDrawing("canvas", this.env.model, () => this.env.model.getters.getSheetViewDimensionWithHeaders());
23610
- owl.useEffect(() => this.focus(), () => [this.env.model.getters.getActiveSheetId()]);
23656
+ owl.useEffect(() => this.focusDefaultElement(), () => [this.env.model.getters.getActiveSheetId()]);
23611
23657
  this.onMouseWheel = useWheelHandler((deltaX, deltaY) => {
23612
23658
  this.moveCanvas(deltaX, deltaY);
23613
23659
  this.hoveredCell.col = undefined;
@@ -23630,7 +23676,7 @@ class Grid extends owl.Component {
23630
23676
  if (this.env.model.getters.hasOpenedPopover()) {
23631
23677
  this.closeOpenedPopover();
23632
23678
  }
23633
- this.focus();
23679
+ this.focusDefaultElement();
23634
23680
  }
23635
23681
  // this map will handle most of the actions that should happen on key down. The arrow keys are managed in the key
23636
23682
  // down itself
@@ -23800,10 +23846,10 @@ class Grid extends owl.Component {
23800
23846
  PAGEUP: () => this.env.model.dispatch("SHIFT_VIEWPORT_UP"),
23801
23847
  "CTRL+K": () => INSERT_LINK(this.env),
23802
23848
  };
23803
- focus() {
23849
+ focusDefaultElement() {
23804
23850
  if (!this.env.model.getters.getSelectedFigureId() &&
23805
23851
  this.env.model.getters.getEditionMode() === "inactive") {
23806
- this.hiddenInput.el?.focus();
23852
+ this.env.focusableElement.focus();
23807
23853
  }
23808
23854
  }
23809
23855
  get gridEl() {
@@ -23947,19 +23993,6 @@ class Grid extends owl.Component {
23947
23993
  return;
23948
23994
  }
23949
23995
  }
23950
- onInput(ev) {
23951
- // the user meant to paste in the sheet, not open the composer with the pasted content
23952
- if (!ev.isComposing && ev.inputType === "insertFromPaste") {
23953
- return;
23954
- }
23955
- if (ev.data) {
23956
- // if the user types a character on the grid, it means he wants to start composing the selected cell with that
23957
- // character
23958
- ev.preventDefault();
23959
- ev.stopPropagation();
23960
- this.props.onGridComposerCellFocused(ev.data);
23961
- }
23962
- }
23963
23996
  // ---------------------------------------------------------------------------
23964
23997
  // Context Menu
23965
23998
  // ---------------------------------------------------------------------------
@@ -24069,7 +24102,7 @@ class Grid extends owl.Component {
24069
24102
  }
24070
24103
  closeMenu() {
24071
24104
  this.menuState.isOpen = false;
24072
- this.focus();
24105
+ this.focusDefaultElement();
24073
24106
  }
24074
24107
  }
24075
24108
  Grid.props = {
@@ -28729,6 +28762,31 @@ const MIGRATIONS = [
28729
28762
  return data;
28730
28763
  },
28731
28764
  },
28765
+ {
28766
+ description: "Fix datafilter duplication",
28767
+ from: 12,
28768
+ to: 12.5,
28769
+ applyMigration(data) {
28770
+ for (let sheet of data.sheets || []) {
28771
+ let knownDataFilterZones = [];
28772
+ for (let filterTable of sheet.filterTables || []) {
28773
+ const zone = toZone(filterTable.range);
28774
+ // See commit message for the details
28775
+ const intersectZoneIndex = knownDataFilterZones.findIndex((knownZone) => overlap(knownZone, zone));
28776
+ if (intersectZoneIndex !== -1) {
28777
+ knownDataFilterZones[intersectZoneIndex] = zone;
28778
+ }
28779
+ else {
28780
+ knownDataFilterZones.push(zone);
28781
+ }
28782
+ }
28783
+ sheet.filterTables = knownDataFilterZones.map((zone) => ({
28784
+ range: zoneToXc(zone),
28785
+ }));
28786
+ }
28787
+ return data;
28788
+ },
28789
+ },
28732
28790
  {
28733
28791
  description: "Change Border description structure",
28734
28792
  from: 12,
@@ -29519,7 +29577,7 @@ class BordersPlugin extends CorePlugin {
29519
29577
  const currentBorder = this.getCellBorder(cmd);
29520
29578
  const areAllNewBordersUndefined = !cmd.border?.bottom && !cmd.border?.left && !cmd.border?.right && !cmd.border?.top;
29521
29579
  if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
29522
- return 93 /* CommandResult.NoChanges */;
29580
+ return 94 /* CommandResult.NoChanges */;
29523
29581
  }
29524
29582
  return 0 /* CommandResult.Success */;
29525
29583
  }
@@ -29798,13 +29856,13 @@ class CellPlugin extends CorePlugin {
29798
29856
  /*
29799
29857
  * Reconstructs the original formula string based on a normalized form and its dependencies
29800
29858
  */
29801
- buildFormulaContent(sheetId, cell, dependencies) {
29859
+ buildFormulaContent(sheetId, cell, dependencies, useFixedZone = false) {
29802
29860
  const ranges = dependencies || cell.dependencies;
29803
29861
  let rangeIndex = 0;
29804
29862
  return concat(cell.compiledFormula.tokens.map((token) => {
29805
29863
  if (token.type === "REFERENCE") {
29806
29864
  const range = ranges[rangeIndex++];
29807
- return this.getters.getRangeString(range, sheetId);
29865
+ return this.getters.getRangeString(range, sheetId, useFixedZone);
29808
29866
  }
29809
29867
  return token.value;
29810
29868
  }));
@@ -30041,9 +30099,9 @@ class CellPlugin extends CorePlugin {
30041
30099
  checkUselessClearCell(cmd) {
30042
30100
  const cell = this.getters.getCell(cmd);
30043
30101
  if (!cell)
30044
- return 93 /* CommandResult.NoChanges */;
30102
+ return 94 /* CommandResult.NoChanges */;
30045
30103
  if (!cell.content && !cell.style && !cell.format) {
30046
- return 93 /* CommandResult.NoChanges */;
30104
+ return 94 /* CommandResult.NoChanges */;
30047
30105
  }
30048
30106
  return 0 /* CommandResult.Success */;
30049
30107
  }
@@ -30243,13 +30301,13 @@ class ChartPlugin extends CorePlugin {
30243
30301
  }
30244
30302
  checkChartDuplicate(cmd) {
30245
30303
  return this.getters.getFigureSheetId(cmd.id)
30246
- ? 84 /* CommandResult.DuplicatedChartId */
30304
+ ? 85 /* CommandResult.DuplicatedChartId */
30247
30305
  : 0 /* CommandResult.Success */;
30248
30306
  }
30249
30307
  checkChartExists(cmd) {
30250
30308
  return this.getters.getFigureSheetId(cmd.id)
30251
30309
  ? 0 /* CommandResult.Success */
30252
- : 85 /* CommandResult.ChartDoesNotExist */;
30310
+ : 86 /* CommandResult.ChartDoesNotExist */;
30253
30311
  }
30254
30312
  }
30255
30313
 
@@ -30354,7 +30412,13 @@ class ConditionalFormatPlugin extends CorePlugin {
30354
30412
  }
30355
30413
  }
30356
30414
  exportForExcel(data) {
30357
- this.export(data);
30415
+ if (data.sheets) {
30416
+ for (let sheet of data.sheets) {
30417
+ if (this.cfRules[sheet.id]) {
30418
+ sheet.conditionalFormats = this.cfRules[sheet.id].map((rule) => this.mapToConditionalFormat(sheet.id, rule, { useFixedReference: true }));
30419
+ }
30420
+ }
30421
+ }
30358
30422
  }
30359
30423
  // ---------------------------------------------------------------------------
30360
30424
  // Getters
@@ -30403,11 +30467,11 @@ class ConditionalFormatPlugin extends CorePlugin {
30403
30467
  // ---------------------------------------------------------------------------
30404
30468
  // Private
30405
30469
  // ---------------------------------------------------------------------------
30406
- mapToConditionalFormat(sheetId, cf) {
30470
+ mapToConditionalFormat(sheetId, cf, options = { useFixedReference: false }) {
30407
30471
  return {
30408
30472
  ...cf,
30409
30473
  ranges: cf.ranges.map((range) => {
30410
- return this.getters.getRangeString(range, sheetId);
30474
+ return this.getters.getRangeString(range, sheetId, options.useFixedReference);
30411
30475
  }),
30412
30476
  };
30413
30477
  }
@@ -30440,10 +30504,10 @@ class ConditionalFormatPlugin extends CorePlugin {
30440
30504
  return 27 /* CommandResult.InvalidSheetId */;
30441
30505
  const ruleIndex = this.cfRules[sheetId].findIndex((cf) => cf.id === cfId);
30442
30506
  if (ruleIndex === -1)
30443
- return 71 /* CommandResult.InvalidConditionalFormatId */;
30507
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
30444
30508
  const cfIndex2 = direction === "up" ? ruleIndex - 1 : ruleIndex + 1;
30445
30509
  if (cfIndex2 < 0 || cfIndex2 >= this.cfRules[sheetId].length) {
30446
- return 71 /* CommandResult.InvalidConditionalFormatId */;
30510
+ return 72 /* CommandResult.InvalidConditionalFormatId */;
30447
30511
  }
30448
30512
  return 0 /* CommandResult.Success */;
30449
30513
  }
@@ -30484,10 +30548,10 @@ class ConditionalFormatPlugin extends CorePlugin {
30484
30548
  const errors = [];
30485
30549
  const isEmpty = (value) => value === undefined || value === "";
30486
30550
  if (expectedNumber >= 1 && isEmpty(rule.values[0])) {
30487
- errors.push(51 /* CommandResult.FirstArgMissing */);
30551
+ errors.push(52 /* CommandResult.FirstArgMissing */);
30488
30552
  }
30489
30553
  if (expectedNumber >= 2 && isEmpty(rule.values[1])) {
30490
- errors.push(52 /* CommandResult.SecondArgMissing */);
30554
+ errors.push(53 /* CommandResult.SecondArgMissing */);
30491
30555
  }
30492
30556
  return errors.length ? errors : 0 /* CommandResult.Success */;
30493
30557
  }
@@ -30499,15 +30563,15 @@ class ConditionalFormatPlugin extends CorePlugin {
30499
30563
  (threshold.value === "" || isNaN(threshold.value))) {
30500
30564
  switch (thresholdName) {
30501
30565
  case "min":
30502
- return 53 /* CommandResult.MinNaN */;
30566
+ return 54 /* CommandResult.MinNaN */;
30503
30567
  case "max":
30504
- return 55 /* CommandResult.MaxNaN */;
30568
+ return 56 /* CommandResult.MaxNaN */;
30505
30569
  case "mid":
30506
- return 54 /* CommandResult.MidNaN */;
30570
+ return 55 /* CommandResult.MidNaN */;
30507
30571
  case "upperInflectionPoint":
30508
- return 56 /* CommandResult.ValueUpperInflectionNaN */;
30572
+ return 57 /* CommandResult.ValueUpperInflectionNaN */;
30509
30573
  case "lowerInflectionPoint":
30510
- return 57 /* CommandResult.ValueLowerInflectionNaN */;
30574
+ return 58 /* CommandResult.ValueLowerInflectionNaN */;
30511
30575
  }
30512
30576
  }
30513
30577
  return 0 /* CommandResult.Success */;
@@ -30521,15 +30585,15 @@ class ConditionalFormatPlugin extends CorePlugin {
30521
30585
  catch (error) {
30522
30586
  switch (thresholdName) {
30523
30587
  case "min":
30524
- return 58 /* CommandResult.MinInvalidFormula */;
30588
+ return 59 /* CommandResult.MinInvalidFormula */;
30525
30589
  case "max":
30526
- return 60 /* CommandResult.MaxInvalidFormula */;
30590
+ return 61 /* CommandResult.MaxInvalidFormula */;
30527
30591
  case "mid":
30528
- return 59 /* CommandResult.MidInvalidFormula */;
30592
+ return 60 /* CommandResult.MidInvalidFormula */;
30529
30593
  case "upperInflectionPoint":
30530
- return 61 /* CommandResult.ValueUpperInvalidFormula */;
30594
+ return 62 /* CommandResult.ValueUpperInvalidFormula */;
30531
30595
  case "lowerInflectionPoint":
30532
- return 62 /* CommandResult.ValueLowerInvalidFormula */;
30596
+ return 63 /* CommandResult.ValueLowerInvalidFormula */;
30533
30597
  }
30534
30598
  }
30535
30599
  return 0 /* CommandResult.Success */;
@@ -30546,7 +30610,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30546
30610
  if (["number", "percentage", "percentile"].includes(rule.lowerInflectionPoint.type) &&
30547
30611
  rule.lowerInflectionPoint.type === rule.upperInflectionPoint.type &&
30548
30612
  Number(minValue) > Number(maxValue)) {
30549
- return 48 /* CommandResult.LowerBiggerThanUpper */;
30613
+ return 49 /* CommandResult.LowerBiggerThanUpper */;
30550
30614
  }
30551
30615
  return 0 /* CommandResult.Success */;
30552
30616
  }
@@ -30556,7 +30620,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30556
30620
  if (["number", "percentage", "percentile"].includes(rule.minimum.type) &&
30557
30621
  rule.minimum.type === rule.maximum.type &&
30558
30622
  stringToNumber(minValue) >= stringToNumber(maxValue)) {
30559
- return 47 /* CommandResult.MinBiggerThanMax */;
30623
+ return 48 /* CommandResult.MinBiggerThanMax */;
30560
30624
  }
30561
30625
  return 0 /* CommandResult.Success */;
30562
30626
  }
@@ -30567,7 +30631,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30567
30631
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
30568
30632
  rule.midpoint.type === rule.maximum.type &&
30569
30633
  stringToNumber(midValue) >= stringToNumber(maxValue)) {
30570
- return 49 /* CommandResult.MidBiggerThanMax */;
30634
+ return 50 /* CommandResult.MidBiggerThanMax */;
30571
30635
  }
30572
30636
  return 0 /* CommandResult.Success */;
30573
30637
  }
@@ -30578,7 +30642,7 @@ class ConditionalFormatPlugin extends CorePlugin {
30578
30642
  ["number", "percentage", "percentile"].includes(rule.midpoint.type) &&
30579
30643
  rule.minimum.type === rule.midpoint.type &&
30580
30644
  stringToNumber(minValue) >= stringToNumber(midValue)) {
30581
- return 50 /* CommandResult.MinBiggerThanMid */;
30645
+ return 51 /* CommandResult.MinBiggerThanMid */;
30582
30646
  }
30583
30647
  return 0 /* CommandResult.Success */;
30584
30648
  }
@@ -30708,13 +30772,13 @@ class FigurePlugin extends CorePlugin {
30708
30772
  }
30709
30773
  checkFigureExists(sheetId, figureId) {
30710
30774
  if (this.figures[sheetId]?.[figureId] === undefined) {
30711
- return 70 /* CommandResult.FigureDoesNotExist */;
30775
+ return 71 /* CommandResult.FigureDoesNotExist */;
30712
30776
  }
30713
30777
  return 0 /* CommandResult.Success */;
30714
30778
  }
30715
30779
  checkFigureDuplicate(figureId) {
30716
30780
  if (Object.values(this.figures).find((sheet) => sheet?.[figureId])) {
30717
- return 82 /* CommandResult.DuplicatedFigureId */;
30781
+ return 83 /* CommandResult.DuplicatedFigureId */;
30718
30782
  }
30719
30783
  return 0 /* CommandResult.Success */;
30720
30784
  }
@@ -30824,12 +30888,12 @@ class FiltersPlugin extends CorePlugin {
30824
30888
  switch (cmd.type) {
30825
30889
  case "CREATE_FILTER_TABLE":
30826
30890
  if (!areZonesContinuous(...cmd.target)) {
30827
- return 81 /* CommandResult.NonContinuousTargets */;
30891
+ return 82 /* CommandResult.NonContinuousTargets */;
30828
30892
  }
30829
30893
  const zone = union(...cmd.target);
30830
30894
  const checkFilterOverlap = () => {
30831
30895
  if (this.getFilterTables(cmd.sheetId).some((filter) => overlap(filter.zone, zone))) {
30832
- return 78 /* CommandResult.FilterOverlap */;
30896
+ return 79 /* CommandResult.FilterOverlap */;
30833
30897
  }
30834
30898
  return 0 /* CommandResult.Success */;
30835
30899
  };
@@ -30837,7 +30901,7 @@ class FiltersPlugin extends CorePlugin {
30837
30901
  const mergesInTarget = this.getters.getMergesInZone(cmd.sheetId, zone);
30838
30902
  for (let merge of mergesInTarget) {
30839
30903
  if (overlap(zone, merge)) {
30840
- return 80 /* CommandResult.MergeInFilter */;
30904
+ return 81 /* CommandResult.MergeInFilter */;
30841
30905
  }
30842
30906
  }
30843
30907
  return 0 /* CommandResult.Success */;
@@ -30847,7 +30911,7 @@ class FiltersPlugin extends CorePlugin {
30847
30911
  for (let merge of cmd.target) {
30848
30912
  for (let filterTable of this.getFilterTables(cmd.sheetId)) {
30849
30913
  if (overlap(filterTable.zone, merge)) {
30850
- return 80 /* CommandResult.MergeInFilter */;
30914
+ return 81 /* CommandResult.MergeInFilter */;
30851
30915
  }
30852
30916
  }
30853
30917
  }
@@ -31332,10 +31396,10 @@ class HeaderVisibilityPlugin extends CorePlugin {
31332
31396
  : this.getters.getNumberRows(cmd.sheetId);
31333
31397
  const hiddenElements = new Set((hiddenGroup || []).flat().concat(cmd.elements));
31334
31398
  if (hiddenElements.size >= elements) {
31335
- return 66 /* CommandResult.TooManyHiddenElements */;
31399
+ return 67 /* CommandResult.TooManyHiddenElements */;
31336
31400
  }
31337
31401
  else if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
31338
- return 86 /* CommandResult.InvalidHeaderIndex */;
31402
+ return 87 /* CommandResult.InvalidHeaderIndex */;
31339
31403
  }
31340
31404
  else {
31341
31405
  return 0 /* CommandResult.Success */;
@@ -31878,7 +31942,7 @@ class MergePlugin extends CorePlugin {
31878
31942
  for (const zone of target) {
31879
31943
  for (const zone2 of target) {
31880
31944
  if (zone !== zone2 && overlap(zone, zone2)) {
31881
- return 65 /* CommandResult.MergeOverlap */;
31945
+ return 66 /* CommandResult.MergeOverlap */;
31882
31946
  }
31883
31947
  }
31884
31948
  }
@@ -31892,7 +31956,7 @@ class MergePlugin extends CorePlugin {
31892
31956
  for (const zone of target) {
31893
31957
  if ((zone.left < xSplit && zone.right >= xSplit) ||
31894
31958
  (zone.top < ySplit && zone.bottom >= ySplit)) {
31895
- return 75 /* CommandResult.FrozenPaneOverlap */;
31959
+ return 76 /* CommandResult.FrozenPaneOverlap */;
31896
31960
  }
31897
31961
  }
31898
31962
  return 0 /* CommandResult.Success */;
@@ -32350,8 +32414,9 @@ class RangeAdapter {
32350
32414
  *
32351
32415
  * @param range the range (received from getRangeFromXC or getRangeFromZone)
32352
32416
  * @param forSheetId the id of the sheet where the range string is supposed to be used.
32417
+ * @param [useFixedZone=false] if true, the range will be returned with fixed row and column
32353
32418
  */
32354
- getRangeString(range, forSheetId) {
32419
+ getRangeString(range, forSheetId, useFixedZone = false) {
32355
32420
  if (!range) {
32356
32421
  return INCORRECT_RANGE_STRING;
32357
32422
  }
@@ -32378,7 +32443,7 @@ class RangeAdapter {
32378
32443
  if (prefixSheet && !sheetName) {
32379
32444
  return INCORRECT_RANGE_STRING;
32380
32445
  }
32381
- let rangeString = this.getRangePartString(rangeImpl, 0);
32446
+ let rangeString = this.getRangePartString(rangeImpl, 0, useFixedZone);
32382
32447
  if (rangeImpl.parts && rangeImpl.parts.length === 2) {
32383
32448
  // this if converts A2:A2 into A2 except if any part of the original range had fixed row or column (with $)
32384
32449
  if (rangeImpl.zone.top !== rangeImpl.zone.bottom ||
@@ -32388,7 +32453,7 @@ class RangeAdapter {
32388
32453
  rangeImpl.parts[1].rowFixed ||
32389
32454
  rangeImpl.parts[1].colFixed) {
32390
32455
  rangeString += ":";
32391
- rangeString += this.getRangePartString(rangeImpl, 1);
32456
+ rangeString += this.getRangePartString(rangeImpl, 1, useFixedZone);
32392
32457
  }
32393
32458
  }
32394
32459
  return `${prefixSheet ? sheetName + "!" : ""}${rangeString}`;
@@ -32418,13 +32483,13 @@ class RangeAdapter {
32418
32483
  /**
32419
32484
  * Get a Xc string that represent a part of a range
32420
32485
  */
32421
- getRangePartString(range, part) {
32422
- const colFixed = range.parts && range.parts[part].colFixed ? "$" : "";
32486
+ getRangePartString(range, part, useFixedZone = false) {
32487
+ const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
32423
32488
  const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
32424
- const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
32489
+ const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
32425
32490
  const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
32426
32491
  let str = "";
32427
- if (range.isFullCol) {
32492
+ if (range.isFullCol && !useFixedZone) {
32428
32493
  if (part === 0 && range.unboundedZone.hasHeader) {
32429
32494
  str = colFixed + col + rowFixed + row;
32430
32495
  }
@@ -32432,7 +32497,7 @@ class RangeAdapter {
32432
32497
  str = colFixed + col;
32433
32498
  }
32434
32499
  }
32435
- else if (range.isFullRow) {
32500
+ else if (range.isFullRow && !useFixedZone) {
32436
32501
  if (part === 0 && range.unboundedZone.hasHeader) {
32437
32502
  str = colFixed + col + rowFixed + row;
32438
32503
  }
@@ -32528,10 +32593,10 @@ class SheetPlugin extends CorePlugin {
32528
32593
  ? this.getNumberCols(cmd.sheetId)
32529
32594
  : this.getNumberRows(cmd.sheetId);
32530
32595
  if (cmd.base < 0 || cmd.base >= elements) {
32531
- return 86 /* CommandResult.InvalidHeaderIndex */;
32596
+ return 87 /* CommandResult.InvalidHeaderIndex */;
32532
32597
  }
32533
32598
  else if (cmd.quantity <= 0) {
32534
- return 87 /* CommandResult.InvalidQuantity */;
32599
+ return 88 /* CommandResult.InvalidQuantity */;
32535
32600
  }
32536
32601
  return 0 /* CommandResult.Success */;
32537
32602
  case "REMOVE_COLUMNS_ROWS": {
@@ -32539,7 +32604,7 @@ class SheetPlugin extends CorePlugin {
32539
32604
  ? this.getNumberCols(cmd.sheetId)
32540
32605
  : this.getNumberRows(cmd.sheetId);
32541
32606
  if (Math.min(...cmd.elements) < 0 || Math.max(...cmd.elements) > elements) {
32542
- return 86 /* CommandResult.InvalidHeaderIndex */;
32607
+ return 87 /* CommandResult.InvalidHeaderIndex */;
32543
32608
  }
32544
32609
  else if (this.checkElementsIncludeAllNonFrozenHeaders(cmd.sheetId, cmd.dimension, cmd.elements)) {
32545
32610
  return 8 /* CommandResult.NotEnoughElements */;
@@ -33005,18 +33070,18 @@ class SheetPlugin extends CorePlugin {
33005
33070
  checkRowFreezeQuantity(cmd) {
33006
33071
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberRows(cmd.sheetId)
33007
33072
  ? 0 /* CommandResult.Success */
33008
- : 74 /* CommandResult.InvalidFreezeQuantity */;
33073
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
33009
33074
  }
33010
33075
  checkColFreezeQuantity(cmd) {
33011
33076
  return cmd.quantity >= 1 && cmd.quantity < this.getNumberCols(cmd.sheetId)
33012
33077
  ? 0 /* CommandResult.Success */
33013
- : 74 /* CommandResult.InvalidFreezeQuantity */;
33078
+ : 75 /* CommandResult.InvalidFreezeQuantity */;
33014
33079
  }
33015
33080
  checkRowFreezeOverlapMerge(cmd) {
33016
33081
  const merges = this.getters.getMerges(cmd.sheetId);
33017
33082
  for (let merge of merges) {
33018
33083
  if (merge.top < cmd.quantity && cmd.quantity <= merge.bottom) {
33019
- return 65 /* CommandResult.MergeOverlap */;
33084
+ return 66 /* CommandResult.MergeOverlap */;
33020
33085
  }
33021
33086
  }
33022
33087
  return 0 /* CommandResult.Success */;
@@ -33025,7 +33090,7 @@ class SheetPlugin extends CorePlugin {
33025
33090
  const merges = this.getters.getMerges(cmd.sheetId);
33026
33091
  for (let merge of merges) {
33027
33092
  if (merge.left < cmd.quantity && cmd.quantity <= merge.right) {
33028
- return 65 /* CommandResult.MergeOverlap */;
33093
+ return 66 /* CommandResult.MergeOverlap */;
33029
33094
  }
33030
33095
  }
33031
33096
  return 0 /* CommandResult.Success */;
@@ -33756,10 +33821,8 @@ class EvaluationPlugin extends UIPlugin {
33756
33821
  * that are actually present in the grid.
33757
33822
  */
33758
33823
  function range(range) {
33824
+ assertRangeValid(range);
33759
33825
  const sheetId = range.sheetId;
33760
- if (!isZoneValid(range.zone)) {
33761
- throw new InvalidReferenceError();
33762
- }
33763
33826
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
33764
33827
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
33765
33828
  const sheetZone = getters.getSheetZone(sheetId);
@@ -33794,23 +33857,26 @@ class EvaluationPlugin extends UIPlugin {
33794
33857
  * The `compute` of the formula's function must process it completely
33795
33858
  */
33796
33859
  function refFn(range, isMeta, functionName, paramNumber) {
33860
+ assertRangeValid(range);
33797
33861
  if (isMeta) {
33798
33862
  // Use zoneToXc of zone instead of getRangeString to avoid sending unbounded ranges
33799
33863
  return { value: zoneToXc(range.zone) };
33800
33864
  }
33801
- if (!isZoneValid(range.zone)) {
33802
- throw new InvalidReferenceError();
33803
- }
33804
33865
  // if the formula definition could have accepted a range, we would pass through the _range function and not here
33805
33866
  if (range.zone.bottom !== range.zone.top || range.zone.left !== range.zone.right) {
33806
33867
  throw new Error(paramNumber
33807
33868
  ? _lt("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.", functionName.toString(), paramNumber.toString())
33808
33869
  : _lt("Function %s expects its parameters to be single values or single cell references, not ranges.", functionName.toString()));
33809
33870
  }
33871
+ return readCell(range);
33872
+ }
33873
+ function assertRangeValid(range) {
33874
+ if (!isZoneValid(range.zone)) {
33875
+ throw new InvalidReferenceError();
33876
+ }
33810
33877
  if (range.invalidSheetName) {
33811
33878
  throw new Error(_lt("Invalid sheet name: %s", range.invalidSheetName));
33812
33879
  }
33813
- return readCell(range);
33814
33880
  }
33815
33881
  return [refFn, range, evalContext];
33816
33882
  }
@@ -33830,6 +33896,10 @@ class EvaluationPlugin extends UIPlugin {
33830
33896
  if (cell.format !== evaluatedCell.format) {
33831
33897
  exportedCellData.computedFormat = evaluatedCell.format;
33832
33898
  }
33899
+ // if there is a formula but no dependencies (maybe because the cell is in error), no need to recompute the formula text
33900
+ if (cell.isFormula && cell.dependencies.length) {
33901
+ exportedCellData.content = this.getters.buildFormulaContent(sheet.id, cell, cell.dependencies, true);
33902
+ }
33833
33903
  }
33834
33904
  }
33835
33905
  }
@@ -34295,7 +34365,7 @@ class FilterEvaluationPlugin extends UIPlugin {
34295
34365
  switch (cmd.type) {
34296
34366
  case "UPDATE_FILTER":
34297
34367
  if (!this.getters.getFilterId(cmd)) {
34298
- return 79 /* CommandResult.FilterNotFound */;
34368
+ return 80 /* CommandResult.FilterNotFound */;
34299
34369
  }
34300
34370
  break;
34301
34371
  }
@@ -35265,7 +35335,7 @@ class SheetViewPlugin extends UIPlugin {
35265
35335
  }
35266
35336
  checkPositiveDimension(cmd) {
35267
35337
  if (cmd.width < 0 || cmd.height < 0) {
35268
- return 68 /* CommandResult.InvalidViewportSize */;
35338
+ return 69 /* CommandResult.InvalidViewportSize */;
35269
35339
  }
35270
35340
  return 0 /* CommandResult.Success */;
35271
35341
  }
@@ -35275,7 +35345,7 @@ class SheetViewPlugin extends UIPlugin {
35275
35345
  cmd.gridOffsetY === this.gridOffsetY &&
35276
35346
  cmd.width === width &&
35277
35347
  cmd.height === height) {
35278
- return 76 /* CommandResult.ValuesNotChanged */;
35348
+ return 77 /* CommandResult.ValuesNotChanged */;
35279
35349
  }
35280
35350
  return 0 /* CommandResult.Success */;
35281
35351
  }
@@ -35283,7 +35353,7 @@ class SheetViewPlugin extends UIPlugin {
35283
35353
  const pane = this.getMainInternalViewport(this.getters.getActiveSheetId());
35284
35354
  if ((!pane.canScrollHorizontally && offsetX > 0) ||
35285
35355
  (!pane.canScrollVertically && offsetY > 0)) {
35286
- return 69 /* CommandResult.InvalidScrollingDirection */;
35356
+ return 70 /* CommandResult.InvalidScrollingDirection */;
35287
35357
  }
35288
35358
  return 0 /* CommandResult.Success */;
35289
35359
  }
@@ -35538,7 +35608,7 @@ class AutofillPlugin extends UIPlugin {
35538
35608
  if (this.lastCellSelected.col !== undefined && this.lastCellSelected.row !== undefined) {
35539
35609
  return 0 /* CommandResult.Success */;
35540
35610
  }
35541
- return 45 /* CommandResult.InvalidAutofillSelection */;
35611
+ return 46 /* CommandResult.InvalidAutofillSelection */;
35542
35612
  case "AUTOFILL_AUTO":
35543
35613
  const zone = this.getters.getSelectedZone();
35544
35614
  return zone.top === zone.bottom
@@ -36142,7 +36212,7 @@ class CellPopoverPlugin extends UIPlugin {
36142
36212
  cellPopoverRegistry.get(cmd.popoverType);
36143
36213
  }
36144
36214
  catch (error) {
36145
- return 72 /* CommandResult.InvalidCellPopover */;
36215
+ return 73 /* CommandResult.InvalidCellPopover */;
36146
36216
  }
36147
36217
  return 0 /* CommandResult.Success */;
36148
36218
  default:
@@ -38278,21 +38348,6 @@ class SelectionInputPlugin extends UIPlugin {
38278
38348
  // ---------------------------------------------------------------------------
38279
38349
  // Command Handling
38280
38350
  // ---------------------------------------------------------------------------
38281
- allowDispatch(cmd) {
38282
- switch (cmd.type) {
38283
- case "ADD_EMPTY_RANGE":
38284
- if (this.inputHasSingleRange && this.ranges.length === 1) {
38285
- return 30 /* CommandResult.MaximumRangesReached */;
38286
- }
38287
- break;
38288
- case "CHANGE_RANGE":
38289
- if (this.inputHasSingleRange && cmd.value.split(",").length > 1) {
38290
- return 30 /* CommandResult.MaximumRangesReached */;
38291
- }
38292
- break;
38293
- }
38294
- return 0 /* CommandResult.Success */;
38295
- }
38296
38351
  handleEvent(event) {
38297
38352
  const xc = zoneToXc(event.anchor.zone);
38298
38353
  const inputSheetId = this.activeSheet;
@@ -38508,6 +38563,15 @@ class SelectionInputsManagerPlugin extends UIPlugin {
38508
38563
  // Command Handling
38509
38564
  // ---------------------------------------------------------------------------
38510
38565
  allowDispatch(cmd) {
38566
+ switch (cmd.type) {
38567
+ case "FOCUS_RANGE":
38568
+ case "CHANGE_RANGE":
38569
+ case "ADD_EMPTY_RANGE":
38570
+ case "REMOVE_RANGE":
38571
+ if (!this.inputs[cmd.id]) {
38572
+ return 31 /* CommandResult.InvalidInputId */;
38573
+ }
38574
+ }
38511
38575
  switch (cmd.type) {
38512
38576
  case "FOCUS_RANGE":
38513
38577
  const index = this.currentInput?.getIndex(cmd.rangeId);
@@ -38515,9 +38579,19 @@ class SelectionInputsManagerPlugin extends UIPlugin {
38515
38579
  return 29 /* CommandResult.InputAlreadyFocused */;
38516
38580
  }
38517
38581
  break;
38518
- }
38519
- if (this.currentInput) {
38520
- return this.currentInput.allowDispatch(cmd);
38582
+ case "ADD_EMPTY_RANGE":
38583
+ const input = this.inputs[cmd.id];
38584
+ if (input.inputHasSingleRange && input.ranges.length === 1) {
38585
+ return 30 /* CommandResult.MaximumRangesReached */;
38586
+ }
38587
+ break;
38588
+ case "CHANGE_RANGE": {
38589
+ const input = this.inputs[cmd.id];
38590
+ if (input.inputHasSingleRange && cmd.value.split(",").length > 1) {
38591
+ return 30 /* CommandResult.MaximumRangesReached */;
38592
+ }
38593
+ break;
38594
+ }
38521
38595
  }
38522
38596
  return 0 /* CommandResult.Success */;
38523
38597
  }
@@ -38641,7 +38715,7 @@ class SortPlugin extends UIPlugin {
38641
38715
  /*Test the presence of single cells*/
38642
38716
  const singleCells = positions(zone).some(({ col, row }) => !this.getters.isInMerge({ sheetId, col, row }));
38643
38717
  if (singleCells) {
38644
- return 63 /* CommandResult.InvalidSortZone */;
38718
+ return 64 /* CommandResult.InvalidSortZone */;
38645
38719
  }
38646
38720
  return 0 /* CommandResult.Success */;
38647
38721
  }
@@ -38660,7 +38734,7 @@ class SortPlugin extends UIPlugin {
38660
38734
  ];
38661
38735
  return widthCurrent === widthFirst && heightCurrent === heightFirst;
38662
38736
  })) {
38663
- return 63 /* CommandResult.InvalidSortZone */;
38737
+ return 64 /* CommandResult.InvalidSortZone */;
38664
38738
  }
38665
38739
  return 0 /* CommandResult.Success */;
38666
38740
  }
@@ -39163,7 +39237,7 @@ class SheetUIPlugin extends UIPlugin {
39163
39237
  const sheetId = "sheetId" in cmd ? cmd.sheetId : this.getters.tryGetActiveSheetId();
39164
39238
  const zones = this.getters.getCommandZones(cmd);
39165
39239
  if (!sheetId && zones.length > 0) {
39166
- return 92 /* CommandResult.NoActiveSheet */;
39240
+ return 93 /* CommandResult.NoActiveSheet */;
39167
39241
  }
39168
39242
  if (sheetId && zones.length > 0) {
39169
39243
  return this.getters.checkZonesExistInSheet(sheetId, zones);
@@ -39645,13 +39719,13 @@ class SplitToColumnsPlugin extends UIPlugin {
39645
39719
  }
39646
39720
  checkSingleColSelected() {
39647
39721
  if (!this.getters.isSingleColSelected()) {
39648
- return 88 /* CommandResult.MoreThanOneColumnSelected */;
39722
+ return 89 /* CommandResult.MoreThanOneColumnSelected */;
39649
39723
  }
39650
39724
  return 0 /* CommandResult.Success */;
39651
39725
  }
39652
39726
  checkNonEmptySelector(cmd) {
39653
39727
  if (cmd.separator === "") {
39654
- return 89 /* CommandResult.EmptySplitSeparator */;
39728
+ return 90 /* CommandResult.EmptySplitSeparator */;
39655
39729
  }
39656
39730
  return 0 /* CommandResult.Success */;
39657
39731
  }
@@ -39662,7 +39736,7 @@ class SplitToColumnsPlugin extends UIPlugin {
39662
39736
  const selection = this.getters.getSelectedZones()[0];
39663
39737
  const splitted = this.getSplittedCols(selection, cmd.separator);
39664
39738
  if (this.willSplittedColsOverwriteContent(selection, splitted)) {
39665
- return 90 /* CommandResult.SplitWillOverwriteContent */;
39739
+ return 91 /* CommandResult.SplitWillOverwriteContent */;
39666
39740
  }
39667
39741
  return 0 /* CommandResult.Success */;
39668
39742
  }
@@ -39673,7 +39747,7 @@ class SplitToColumnsPlugin extends UIPlugin {
39673
39747
  return 0 /* CommandResult.Success */;
39674
39748
  }
39675
39749
  }
39676
- return 91 /* CommandResult.NoSplitSeparatorInSelection */;
39750
+ return 92 /* CommandResult.NoSplitSeparatorInSelection */;
39677
39751
  }
39678
39752
  }
39679
39753
 
@@ -39820,7 +39894,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
39820
39894
  for (const zone of this.getPasteZones(target)) {
39821
39895
  if ((zone.left < xSplit && zone.right >= xSplit) ||
39822
39896
  (zone.top < ySplit && zone.bottom >= ySplit)) {
39823
- return 75 /* CommandResult.FrozenPaneOverlap */;
39897
+ return 76 /* CommandResult.FrozenPaneOverlap */;
39824
39898
  }
39825
39899
  }
39826
39900
  return 0 /* CommandResult.Success */;
@@ -40214,7 +40288,7 @@ class ClipboardFigureState {
40214
40288
  }
40215
40289
  isPasteAllowed(target, option) {
40216
40290
  if (target.length === 0) {
40217
- return 73 /* CommandResult.EmptyTarget */;
40291
+ return 74 /* CommandResult.EmptyTarget */;
40218
40292
  }
40219
40293
  if (option?.pasteOption !== undefined) {
40220
40294
  return 22 /* CommandResult.WrongFigurePasteOption */;
@@ -40955,7 +41029,7 @@ class EditionPlugin extends UIPlugin {
40955
41029
  validateSelection(length, start, end) {
40956
41030
  return start >= 0 && start <= length && end >= 0 && end <= length
40957
41031
  ? 0 /* CommandResult.Success */
40958
- : 46 /* CommandResult.WrongComposerSelection */;
41032
+ : 47 /* CommandResult.WrongComposerSelection */;
40959
41033
  }
40960
41034
  onColumnsRemoved(cmd) {
40961
41035
  if (cmd.elements.includes(this.col) && this.mode !== "inactive") {
@@ -41170,7 +41244,7 @@ class EditionPlugin extends UIPlugin {
41170
41244
  getZoneReference(zone, fixedParts = [{ colFixed: false, rowFixed: false }]) {
41171
41245
  const sheetId = this.getters.getActiveSheetId();
41172
41246
  let selectedXc = this.getters.zoneToXC(sheetId, zone, fixedParts);
41173
- if (this.getters.getCurrentEditedCell().sheetId !== this.getters.getActiveSheetId()) {
41247
+ if (this.getters.getCurrentEditedCell()?.sheetId !== this.getters.getActiveSheetId()) {
41174
41248
  const sheetName = getCanonicalSheetName(this.getters.getSheetName(this.getters.getActiveSheetId()));
41175
41249
  selectedXc = `${sheetName}!${selectedXc}`;
41176
41250
  }
@@ -41185,7 +41259,7 @@ class EditionPlugin extends UIPlugin {
41185
41259
  _fixedParts.pop();
41186
41260
  }
41187
41261
  const newRange = range.clone({ parts: _fixedParts });
41188
- return this.getters.getSelectionRangeString(newRange, this.getters.getCurrentEditedCell().sheetId);
41262
+ return this.getters.getSelectionRangeString(newRange, this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId());
41189
41263
  }
41190
41264
  /**
41191
41265
  * Replace the current selection by a new text.
@@ -41218,7 +41292,7 @@ class EditionPlugin extends UIPlugin {
41218
41292
  if (!this.currentContent.startsWith("=") || this.mode === "inactive") {
41219
41293
  return;
41220
41294
  }
41221
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41295
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41222
41296
  const XCs = this.getReferencedRanges().map((range) => this.getters.getRangeString(range, editionSheetId));
41223
41297
  const colorsToKeep = {};
41224
41298
  for (const xc of XCs) {
@@ -41247,7 +41321,7 @@ class EditionPlugin extends UIPlugin {
41247
41321
  if (!this.currentContent.startsWith("=") || this.mode === "inactive") {
41248
41322
  return [];
41249
41323
  }
41250
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41324
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41251
41325
  const rangeColor = (rangeString) => {
41252
41326
  const colorIndex = this.colorIndexByRange[rangeString];
41253
41327
  return colors$1[colorIndex % colors$1.length];
@@ -41265,10 +41339,11 @@ class EditionPlugin extends UIPlugin {
41265
41339
  * Return ranges currently referenced in the composer
41266
41340
  */
41267
41341
  getReferencedRanges() {
41268
- const editionSheetId = this.getters.getCurrentEditedCell().sheetId;
41269
- return this.currentTokens
41342
+ const editionSheetId = this.getters.getCurrentEditedCell()?.sheetId || this.getters.getActiveSheetId();
41343
+ const referenceRanges = this.currentTokens
41270
41344
  .filter((token) => token.type === "REFERENCE")
41271
41345
  .map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
41346
+ return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
41272
41347
  }
41273
41348
  /**
41274
41349
  * Function used to determine when composer selection can start.
@@ -41907,7 +41982,7 @@ class GridSelectionPlugin extends UIPlugin {
41907
41982
  const headers = [cmd.base, ...cmd.elements];
41908
41983
  const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
41909
41984
  if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
41910
- return 86 /* CommandResult.InvalidHeaderIndex */;
41985
+ return 87 /* CommandResult.InvalidHeaderIndex */;
41911
41986
  }
41912
41987
  return 0 /* CommandResult.Success */;
41913
41988
  }
@@ -42075,6 +42150,16 @@ class ImageProvider {
42075
42150
  }
42076
42151
  }
42077
42152
 
42153
+ class FocusableElement {
42154
+ focusableElement = undefined;
42155
+ setFocusableElement(element) {
42156
+ this.focusableElement = element;
42157
+ }
42158
+ focus() {
42159
+ this.focusableElement?.focus();
42160
+ }
42161
+ }
42162
+
42078
42163
  const RIPPLE_KEY_FRAMES = [
42079
42164
  { transform: "scale(0)" },
42080
42165
  { transform: "scale(0.8)", offset: 0.33 },
@@ -44103,6 +44188,7 @@ class Spreadsheet extends owl.Component {
44103
44188
  _t: Spreadsheet._t,
44104
44189
  clipboard: this.env.clipboard || instantiateClipboard(),
44105
44190
  startCellEdition: (content) => this.onGridComposerCellFocused(content),
44191
+ focusableElement: new FocusableElement(),
44106
44192
  });
44107
44193
  owl.useExternalListener(window, "resize", () => this.render(true));
44108
44194
  owl.useExternalListener(window, "beforeunload", this.unbindModelEvents.bind(this));
@@ -44209,17 +44295,18 @@ class Spreadsheet extends owl.Component {
44209
44295
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
44210
44296
  this.composer.topBarFocus = "contentFocus";
44211
44297
  this.composer.gridFocusMode = "inactive";
44212
- this.setComposerContent({ selection } || {});
44298
+ this.setComposerContent({ selection });
44213
44299
  }
44214
- onGridComposerContentFocused() {
44300
+ onGridComposerContentFocused(selection) {
44215
44301
  if (this.model.getters.isReadonly()) {
44216
44302
  return;
44217
44303
  }
44218
44304
  this.model.dispatch("UNFOCUS_SELECTION_INPUT");
44219
44305
  this.composer.topBarFocus = "inactive";
44220
44306
  this.composer.gridFocusMode = "contentFocus";
44221
- this.setComposerContent({});
44307
+ this.setComposerContent({ selection });
44222
44308
  }
44309
+ // TODO: either both are defined or none of them. change those args to an object
44223
44310
  onGridComposerCellFocused(content, selection) {
44224
44311
  if (this.model.getters.isReadonly()) {
44225
44312
  return;
@@ -45256,7 +45343,7 @@ class SelectionStreamProcessorImpl {
45256
45343
  */
45257
45344
  moveAnchorCell(direction, step = 1) {
45258
45345
  if (step !== "end" && step <= 0) {
45259
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
45346
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
45260
45347
  }
45261
45348
  const { col, row } = this.getNextAvailablePosition(direction, step);
45262
45349
  return this.selectCell(col, row);
@@ -45302,7 +45389,7 @@ class SelectionStreamProcessorImpl {
45302
45389
  */
45303
45390
  resizeAnchorZone(direction, step = 1) {
45304
45391
  if (step !== "end" && step <= 0) {
45305
- return new DispatchResult(83 /* CommandResult.InvalidSelectionStep */);
45392
+ return new DispatchResult(84 /* CommandResult.InvalidSelectionStep */);
45306
45393
  }
45307
45394
  const sheetId = this.getters.getActiveSheetId();
45308
45395
  const anchor = this.anchor;
@@ -46129,12 +46216,7 @@ function addFormula(cell) {
46129
46216
  attrs.push(["t", "str"]);
46130
46217
  cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
46131
46218
  }
46132
- node = escapeXml /*xml*/ `
46133
- <f>
46134
- ${XlsxFormula}
46135
- </f>
46136
- ${cycle}
46137
- `;
46219
+ node = escapeXml /*xml*/ `<f> ${XlsxFormula} </f> ${cycle}`;
46138
46220
  return { attrs, node };
46139
46221
  }
46140
46222
  else {
@@ -46956,11 +47038,10 @@ function addRows(construct, data, sheet) {
46956
47038
  ({ attrs: additionalAttrs, node: cellNode } = addContent(cell.content, construct.sharedStrings, isTableHeader));
46957
47039
  }
46958
47040
  attributes.push(...additionalAttrs);
46959
- cellNodes.push(escapeXml /*xml*/ `
46960
- <c ${formatAttributes(attributes)}>
46961
- ${cellNode}
46962
- </c>
46963
- `);
47041
+ // prettier-ignore
47042
+ cellNodes.push(escapeXml /*xml*/ `<c ${formatAttributes(attributes)}>
47043
+ ${cellNode}
47044
+ </c>`);
46964
47045
  }
46965
47046
  }
46966
47047
  if (cellNodes.length || row.size !== DEFAULT_CELL_HEIGHT || row.isHidden) {
@@ -47645,10 +47726,10 @@ class Model extends EventBus {
47645
47726
  const command = createCommand(type, payload);
47646
47727
  let status = this.status;
47647
47728
  if (this.getters.isReadonly() && !canExecuteInReadonly(command)) {
47648
- return new DispatchResult(67 /* CommandResult.Readonly */);
47729
+ return new DispatchResult(68 /* CommandResult.Readonly */);
47649
47730
  }
47650
47731
  if (!this.session.canApplyOptimisticUpdate()) {
47651
- return new DispatchResult(64 /* CommandResult.WaitingSessionConfirmation */);
47732
+ return new DispatchResult(65 /* CommandResult.WaitingSessionConfirmation */);
47652
47733
  }
47653
47734
  switch (status) {
47654
47735
  case 0 /* Status.Ready */:
@@ -47927,6 +48008,6 @@ exports.setTranslationMethod = setTranslationMethod;
47927
48008
  exports.tokenize = tokenize;
47928
48009
 
47929
48010
 
47930
- __info__.version = '16.3.22';
47931
- __info__.date = '2024-01-17T10:24:07.652Z';
47932
- __info__.hash = '2c1b136';
48011
+ __info__.version = '16.3.25';
48012
+ __info__.date = '2024-02-09T13:07:06.947Z';
48013
+ __info__.hash = 'b53bf1b';