@odoo/o-spreadsheet 17.2.19 → 17.2.20

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.19
7
- * @date 2024-08-02T08:22:56.367Z
8
- * @hash c5ae261
6
+ * @version 17.2.20
7
+ * @date 2024-08-09T12:24:12.002Z
8
+ * @hash d667a15
9
9
  */
10
10
 
11
11
  'use strict';
@@ -44140,7 +44140,7 @@ class RangeAdapter {
44140
44140
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
44141
44141
  */
44142
44142
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
44143
- if (!rangeReference.test(sheetXC)) {
44143
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
44144
44144
  return new RangeImpl({
44145
44145
  sheetId: "",
44146
44146
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -47729,18 +47729,23 @@ class Evaluator {
47729
47729
  this.evaluatedCells = new PositionMap();
47730
47730
  this.evaluate(this.getAllCells());
47731
47731
  }
47732
- evaluateFormula(sheetId, formulaString) {
47733
- const compiledFormula = compile(formulaString);
47734
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47735
- this.updateCompilationParameters();
47736
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47737
- if (isMatrix(result)) {
47738
- return matrixMap(result, (cell) => cell.value);
47732
+ evaluateFormulaResult(sheetId, formulaString) {
47733
+ try {
47734
+ const compiledFormula = compile(formulaString);
47735
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47736
+ this.updateCompilationParameters();
47737
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47738
+ if (isMatrix(result)) {
47739
+ return result;
47740
+ }
47741
+ if (result.value === null) {
47742
+ return { value: 0, format: result.format };
47743
+ }
47744
+ return result;
47739
47745
  }
47740
- if (result.value === null) {
47741
- return 0;
47746
+ catch (error) {
47747
+ return handleError(error, "");
47742
47748
  }
47743
- return result.value;
47744
47749
  }
47745
47750
  getAllCells() {
47746
47751
  const positions = this.createEmptyPositionSet();
@@ -48084,6 +48089,7 @@ function updateEvalContextAndExecute(compiledFormula, compilationParams, sheetId
48084
48089
  class EvaluationPlugin extends UIPlugin {
48085
48090
  static getters = [
48086
48091
  "evaluateFormula",
48092
+ "evaluateFormulaResult",
48087
48093
  "getCorrespondingFormulaCell",
48088
48094
  "getRangeFormattedValues",
48089
48095
  "getRangeValues",
@@ -48146,12 +48152,14 @@ class EvaluationPlugin extends UIPlugin {
48146
48152
  // Getters
48147
48153
  // ---------------------------------------------------------------------------
48148
48154
  evaluateFormula(sheetId, formulaString) {
48149
- try {
48150
- return this.evaluator.evaluateFormula(sheetId, formulaString);
48151
- }
48152
- catch (error) {
48153
- return error.value || CellErrorType.GenericError;
48155
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
48156
+ if (isMatrix(result)) {
48157
+ return matrixMap(result, (cell) => cell.value);
48154
48158
  }
48159
+ return result.value;
48160
+ }
48161
+ evaluateFormulaResult(sheetId, formulaString) {
48162
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
48155
48163
  }
48156
48164
  /**
48157
48165
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -51010,6 +51018,7 @@ class FormatPlugin extends UIPlugin {
51010
51018
  * evaluated and updated with the number type.
51011
51019
  */
51012
51020
  setDecimal(sheetId, zones, step) {
51021
+ const positionsByFormat = {};
51013
51022
  // Find the each cell with a number value and get the format
51014
51023
  for (const zone of zones) {
51015
51024
  for (const position of positions(zone)) {
@@ -51019,15 +51028,20 @@ class FormatPlugin extends UIPlugin {
51019
51028
  // of the format
51020
51029
  this.getters.getLocale();
51021
51030
  const newFormat = changeDecimalPlaces(numberFormat, step);
51022
- // Apply the new format on the whole zone
51023
- this.dispatch("SET_FORMATTING", {
51024
- sheetId,
51025
- target: [positionToZone(position)],
51026
- format: newFormat,
51027
- });
51031
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
51032
+ positionsByFormat[newFormat].push(position);
51028
51033
  }
51029
51034
  }
51030
51035
  }
51036
+ // consolidate all positions with the same format in bigger zones
51037
+ for (const newFormat in positionsByFormat) {
51038
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
51039
+ this.dispatch("SET_FORMATTING", {
51040
+ sheetId,
51041
+ format: newFormat,
51042
+ target: zones,
51043
+ });
51044
+ }
51031
51045
  }
51032
51046
  /**
51033
51047
  * Take a range of cells and return the format of the first cell containing a
@@ -60885,6 +60899,6 @@ exports.tokenColors = tokenColors;
60885
60899
  exports.tokenize = tokenize;
60886
60900
 
60887
60901
 
60888
- __info__.version = "17.2.19";
60889
- __info__.date = "2024-08-02T08:22:56.367Z";
60890
- __info__.hash = "c5ae261";
60902
+ __info__.version = "17.2.20";
60903
+ __info__.date = "2024-08-09T12:24:12.002Z";
60904
+ __info__.hash = "d667a15";
@@ -3559,7 +3559,7 @@ declare class UIPlugin<State = any> extends BasePlugin<State, Command> {
3559
3559
  }
3560
3560
 
3561
3561
  declare class EvaluationPlugin extends UIPlugin {
3562
- static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf", "getArrayFormulaSpreadingOn", "isEmpty"];
3562
+ static getters: readonly ["evaluateFormula", "evaluateFormulaResult", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf", "getArrayFormulaSpreadingOn", "isEmpty"];
3563
3563
  private shouldRebuildDependenciesGraph;
3564
3564
  private evaluator;
3565
3565
  private positionsToUpdate;
@@ -3568,6 +3568,7 @@ declare class EvaluationPlugin extends UIPlugin {
3568
3568
  handle(cmd: CoreViewCommand): void;
3569
3569
  finalize(): void;
3570
3570
  evaluateFormula(sheetId: UID, formulaString: string): CellValue | Matrix<CellValue>;
3571
+ evaluateFormulaResult(sheetId: UID, formulaString: string): Matrix<FPayload> | FPayload;
3571
3572
  /**
3572
3573
  * Return the value of each cell in the range as they are displayed in the grid.
3573
3574
  */
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.19
7
- * @date 2024-08-02T08:22:56.367Z
8
- * @hash c5ae261
6
+ * @version 17.2.20
7
+ * @date 2024-08-09T12:24:12.002Z
8
+ * @hash d667a15
9
9
  */
10
10
 
11
11
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw } from '@odoo/owl';
@@ -44138,7 +44138,7 @@ class RangeAdapter {
44138
44138
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
44139
44139
  */
44140
44140
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
44141
- if (!rangeReference.test(sheetXC)) {
44141
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
44142
44142
  return new RangeImpl({
44143
44143
  sheetId: "",
44144
44144
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -47727,18 +47727,23 @@ class Evaluator {
47727
47727
  this.evaluatedCells = new PositionMap();
47728
47728
  this.evaluate(this.getAllCells());
47729
47729
  }
47730
- evaluateFormula(sheetId, formulaString) {
47731
- const compiledFormula = compile(formulaString);
47732
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47733
- this.updateCompilationParameters();
47734
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47735
- if (isMatrix(result)) {
47736
- return matrixMap(result, (cell) => cell.value);
47730
+ evaluateFormulaResult(sheetId, formulaString) {
47731
+ try {
47732
+ const compiledFormula = compile(formulaString);
47733
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47734
+ this.updateCompilationParameters();
47735
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47736
+ if (isMatrix(result)) {
47737
+ return result;
47738
+ }
47739
+ if (result.value === null) {
47740
+ return { value: 0, format: result.format };
47741
+ }
47742
+ return result;
47737
47743
  }
47738
- if (result.value === null) {
47739
- return 0;
47744
+ catch (error) {
47745
+ return handleError(error, "");
47740
47746
  }
47741
- return result.value;
47742
47747
  }
47743
47748
  getAllCells() {
47744
47749
  const positions = this.createEmptyPositionSet();
@@ -48082,6 +48087,7 @@ function updateEvalContextAndExecute(compiledFormula, compilationParams, sheetId
48082
48087
  class EvaluationPlugin extends UIPlugin {
48083
48088
  static getters = [
48084
48089
  "evaluateFormula",
48090
+ "evaluateFormulaResult",
48085
48091
  "getCorrespondingFormulaCell",
48086
48092
  "getRangeFormattedValues",
48087
48093
  "getRangeValues",
@@ -48144,12 +48150,14 @@ class EvaluationPlugin extends UIPlugin {
48144
48150
  // Getters
48145
48151
  // ---------------------------------------------------------------------------
48146
48152
  evaluateFormula(sheetId, formulaString) {
48147
- try {
48148
- return this.evaluator.evaluateFormula(sheetId, formulaString);
48149
- }
48150
- catch (error) {
48151
- return error.value || CellErrorType.GenericError;
48153
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
48154
+ if (isMatrix(result)) {
48155
+ return matrixMap(result, (cell) => cell.value);
48152
48156
  }
48157
+ return result.value;
48158
+ }
48159
+ evaluateFormulaResult(sheetId, formulaString) {
48160
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
48153
48161
  }
48154
48162
  /**
48155
48163
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -51008,6 +51016,7 @@ class FormatPlugin extends UIPlugin {
51008
51016
  * evaluated and updated with the number type.
51009
51017
  */
51010
51018
  setDecimal(sheetId, zones, step) {
51019
+ const positionsByFormat = {};
51011
51020
  // Find the each cell with a number value and get the format
51012
51021
  for (const zone of zones) {
51013
51022
  for (const position of positions(zone)) {
@@ -51017,15 +51026,20 @@ class FormatPlugin extends UIPlugin {
51017
51026
  // of the format
51018
51027
  this.getters.getLocale();
51019
51028
  const newFormat = changeDecimalPlaces(numberFormat, step);
51020
- // Apply the new format on the whole zone
51021
- this.dispatch("SET_FORMATTING", {
51022
- sheetId,
51023
- target: [positionToZone(position)],
51024
- format: newFormat,
51025
- });
51029
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
51030
+ positionsByFormat[newFormat].push(position);
51026
51031
  }
51027
51032
  }
51028
51033
  }
51034
+ // consolidate all positions with the same format in bigger zones
51035
+ for (const newFormat in positionsByFormat) {
51036
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
51037
+ this.dispatch("SET_FORMATTING", {
51038
+ sheetId,
51039
+ format: newFormat,
51040
+ target: zones,
51041
+ });
51042
+ }
51029
51043
  }
51030
51044
  /**
51031
51045
  * Take a range of cells and return the format of the first cell containing a
@@ -60842,6 +60856,6 @@ const constants = {
60842
60856
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
60843
60857
 
60844
60858
 
60845
- __info__.version = "17.2.19";
60846
- __info__.date = "2024-08-02T08:22:56.367Z";
60847
- __info__.hash = "c5ae261";
60859
+ __info__.version = "17.2.20";
60860
+ __info__.date = "2024-08-09T12:24:12.002Z";
60861
+ __info__.hash = "d667a15";
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.2.19
7
- * @date 2024-08-02T08:22:56.367Z
8
- * @hash c5ae261
6
+ * @version 17.2.20
7
+ * @date 2024-08-09T12:24:12.002Z
8
+ * @hash d667a15
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -44139,7 +44139,7 @@ stores.inject(MyMetaStore, storeInstance);
44139
44139
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
44140
44140
  */
44141
44141
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
44142
- if (!rangeReference.test(sheetXC)) {
44142
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
44143
44143
  return new RangeImpl({
44144
44144
  sheetId: "",
44145
44145
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -47728,18 +47728,23 @@ stores.inject(MyMetaStore, storeInstance);
47728
47728
  this.evaluatedCells = new PositionMap();
47729
47729
  this.evaluate(this.getAllCells());
47730
47730
  }
47731
- evaluateFormula(sheetId, formulaString) {
47732
- const compiledFormula = compile(formulaString);
47733
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47734
- this.updateCompilationParameters();
47735
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47736
- if (isMatrix(result)) {
47737
- return matrixMap(result, (cell) => cell.value);
47731
+ evaluateFormulaResult(sheetId, formulaString) {
47732
+ try {
47733
+ const compiledFormula = compile(formulaString);
47734
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
47735
+ this.updateCompilationParameters();
47736
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
47737
+ if (isMatrix(result)) {
47738
+ return result;
47739
+ }
47740
+ if (result.value === null) {
47741
+ return { value: 0, format: result.format };
47742
+ }
47743
+ return result;
47738
47744
  }
47739
- if (result.value === null) {
47740
- return 0;
47745
+ catch (error) {
47746
+ return handleError(error, "");
47741
47747
  }
47742
- return result.value;
47743
47748
  }
47744
47749
  getAllCells() {
47745
47750
  const positions = this.createEmptyPositionSet();
@@ -48083,6 +48088,7 @@ stores.inject(MyMetaStore, storeInstance);
48083
48088
  class EvaluationPlugin extends UIPlugin {
48084
48089
  static getters = [
48085
48090
  "evaluateFormula",
48091
+ "evaluateFormulaResult",
48086
48092
  "getCorrespondingFormulaCell",
48087
48093
  "getRangeFormattedValues",
48088
48094
  "getRangeValues",
@@ -48145,12 +48151,14 @@ stores.inject(MyMetaStore, storeInstance);
48145
48151
  // Getters
48146
48152
  // ---------------------------------------------------------------------------
48147
48153
  evaluateFormula(sheetId, formulaString) {
48148
- try {
48149
- return this.evaluator.evaluateFormula(sheetId, formulaString);
48150
- }
48151
- catch (error) {
48152
- return error.value || CellErrorType.GenericError;
48154
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
48155
+ if (isMatrix(result)) {
48156
+ return matrixMap(result, (cell) => cell.value);
48153
48157
  }
48158
+ return result.value;
48159
+ }
48160
+ evaluateFormulaResult(sheetId, formulaString) {
48161
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
48154
48162
  }
48155
48163
  /**
48156
48164
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -51009,6 +51017,7 @@ stores.inject(MyMetaStore, storeInstance);
51009
51017
  * evaluated and updated with the number type.
51010
51018
  */
51011
51019
  setDecimal(sheetId, zones, step) {
51020
+ const positionsByFormat = {};
51012
51021
  // Find the each cell with a number value and get the format
51013
51022
  for (const zone of zones) {
51014
51023
  for (const position of positions(zone)) {
@@ -51018,15 +51027,20 @@ stores.inject(MyMetaStore, storeInstance);
51018
51027
  // of the format
51019
51028
  this.getters.getLocale();
51020
51029
  const newFormat = changeDecimalPlaces(numberFormat, step);
51021
- // Apply the new format on the whole zone
51022
- this.dispatch("SET_FORMATTING", {
51023
- sheetId,
51024
- target: [positionToZone(position)],
51025
- format: newFormat,
51026
- });
51030
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
51031
+ positionsByFormat[newFormat].push(position);
51027
51032
  }
51028
51033
  }
51029
51034
  }
51035
+ // consolidate all positions with the same format in bigger zones
51036
+ for (const newFormat in positionsByFormat) {
51037
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
51038
+ this.dispatch("SET_FORMATTING", {
51039
+ sheetId,
51040
+ format: newFormat,
51041
+ target: zones,
51042
+ });
51043
+ }
51030
51044
  }
51031
51045
  /**
51032
51046
  * Take a range of cells and return the format of the first cell containing a
@@ -60884,9 +60898,9 @@ stores.inject(MyMetaStore, storeInstance);
60884
60898
  exports.tokenize = tokenize;
60885
60899
 
60886
60900
 
60887
- __info__.version = "17.2.19";
60888
- __info__.date = "2024-08-02T08:22:56.367Z";
60889
- __info__.hash = "c5ae261";
60901
+ __info__.version = "17.2.20";
60902
+ __info__.date = "2024-08-09T12:24:12.002Z";
60903
+ __info__.hash = "d667a15";
60890
60904
 
60891
60905
 
60892
60906
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);