@odoo/o-spreadsheet 17.1.26 → 17.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.1.26
6
- * @date 2024-08-02T08:23:08.499Z
7
- * @hash 4ba7e55
5
+ * @version 17.1.27
6
+ * @date 2024-08-09T12:20:52.051Z
7
+ * @hash c626332
8
8
  */
9
9
 
10
10
  'use strict';
@@ -39126,7 +39126,7 @@ class RangeAdapter {
39126
39126
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
39127
39127
  */
39128
39128
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
39129
- if (!rangeReference.test(sheetXC)) {
39129
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
39130
39130
  return new RangeImpl({
39131
39131
  sheetId: "",
39132
39132
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -42060,18 +42060,30 @@ class Evaluator {
42060
42060
  this.evaluate(this.getAllCells());
42061
42061
  }
42062
42062
  evaluateFormula(sheetId, formulaString) {
42063
- const compiledFormula = compile(formulaString);
42064
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42065
- this.updateCompilationParameters();
42066
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42063
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42067
42064
  if (isMatrix(result)) {
42068
42065
  return matrixMap(result, (cell) => cell.value);
42069
42066
  }
42070
- if (result.value === null) {
42071
- return 0;
42072
- }
42073
42067
  return result.value;
42074
42068
  }
42069
+ evaluateFormulaResult(sheetId, formulaString) {
42070
+ try {
42071
+ const compiledFormula = compile(formulaString);
42072
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42073
+ this.updateCompilationParameters();
42074
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42075
+ if (isMatrix(result)) {
42076
+ return result;
42077
+ }
42078
+ if (result.value === null) {
42079
+ return { value: 0, format: result.format };
42080
+ }
42081
+ return result;
42082
+ }
42083
+ catch (error) {
42084
+ return handleError(error, "");
42085
+ }
42086
+ }
42075
42087
  getAllCells() {
42076
42088
  const positionIds = new JetSet();
42077
42089
  for (const sheetId of this.getters.getSheetIds()) {
@@ -42496,6 +42508,7 @@ function updateEvalContextAndExecute(compiledFormula, compilationParams, sheetId
42496
42508
  class EvaluationPlugin extends UIPlugin {
42497
42509
  static getters = [
42498
42510
  "evaluateFormula",
42511
+ "evaluateFormulaResult",
42499
42512
  "getCorrespondingFormulaCell",
42500
42513
  "getRangeFormattedValues",
42501
42514
  "getRangeValues",
@@ -42554,12 +42567,14 @@ class EvaluationPlugin extends UIPlugin {
42554
42567
  // Getters
42555
42568
  // ---------------------------------------------------------------------------
42556
42569
  evaluateFormula(sheetId, formulaString) {
42557
- try {
42558
- return this.evaluator.evaluateFormula(sheetId, formulaString);
42559
- }
42560
- catch (error) {
42561
- return error.value || CellErrorType.GenericError;
42570
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42571
+ if (isMatrix(result)) {
42572
+ return matrixMap(result, (cell) => cell.value);
42562
42573
  }
42574
+ return result.value;
42575
+ }
42576
+ evaluateFormulaResult(sheetId, formulaString) {
42577
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
42563
42578
  }
42564
42579
  /**
42565
42580
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -46434,6 +46449,7 @@ class FormatPlugin extends UIPlugin {
46434
46449
  * evaluated and updated with the number type.
46435
46450
  */
46436
46451
  setDecimal(sheetId, zones, step) {
46452
+ const positionsByFormat = {};
46437
46453
  // Find the each cell with a number value and get the format
46438
46454
  for (const zone of zones) {
46439
46455
  for (const position of positions(zone)) {
@@ -46443,15 +46459,20 @@ class FormatPlugin extends UIPlugin {
46443
46459
  // of the format
46444
46460
  this.getters.getLocale();
46445
46461
  const newFormat = changeDecimalPlaces(numberFormat, step);
46446
- // Apply the new format on the whole zone
46447
- this.dispatch("SET_FORMATTING", {
46448
- sheetId,
46449
- target: [positionToZone(position)],
46450
- format: newFormat,
46451
- });
46462
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
46463
+ positionsByFormat[newFormat].push(position);
46452
46464
  }
46453
46465
  }
46454
46466
  }
46467
+ // consolidate all positions with the same format in bigger zones
46468
+ for (const newFormat in positionsByFormat) {
46469
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
46470
+ this.dispatch("SET_FORMATTING", {
46471
+ sheetId,
46472
+ format: newFormat,
46473
+ target: zones,
46474
+ });
46475
+ }
46455
46476
  }
46456
46477
  /**
46457
46478
  * Take a range of cells and return the format of the first cell containing a
@@ -57882,6 +57903,6 @@ exports.setTranslationMethod = setTranslationMethod;
57882
57903
  exports.tokenize = tokenize;
57883
57904
 
57884
57905
 
57885
- __info__.version = "17.1.26";
57886
- __info__.date = "2024-08-02T08:23:08.499Z";
57887
- __info__.hash = "4ba7e55";
57906
+ __info__.version = "17.1.27";
57907
+ __info__.date = "2024-08-09T12:20:52.051Z";
57908
+ __info__.hash = "c626332";
@@ -4006,7 +4006,7 @@ declare class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
4006
4006
  }
4007
4007
 
4008
4008
  declare class EvaluationPlugin extends UIPlugin {
4009
- static getters: readonly ["evaluateFormula", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf", "getArrayFormulaSpreadingOn", "isEmpty"];
4009
+ static getters: readonly ["evaluateFormula", "evaluateFormulaResult", "getCorrespondingFormulaCell", "getRangeFormattedValues", "getRangeValues", "getRangeFormats", "getEvaluatedCell", "getEvaluatedCells", "getEvaluatedCellsInZone", "getSpreadPositionsOf", "getArrayFormulaSpreadingOn", "isEmpty"];
4010
4010
  private shouldRebuildDependenciesGraph;
4011
4011
  private evaluator;
4012
4012
  private positionsToUpdate;
@@ -4015,6 +4015,7 @@ declare class EvaluationPlugin extends UIPlugin {
4015
4015
  handle(cmd: CoreViewCommand): void;
4016
4016
  finalize(): void;
4017
4017
  evaluateFormula(sheetId: UID, formulaString: string): CellValue | Matrix<CellValue>;
4018
+ evaluateFormulaResult(sheetId: UID, formulaString: string): Matrix<FPayload> | FPayload;
4018
4019
  /**
4019
4020
  * Return the value of each cell in the range as they are displayed in the grid.
4020
4021
  */
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.1.26
6
- * @date 2024-08-02T08:23:08.499Z
7
- * @hash 4ba7e55
5
+ * @version 17.1.27
6
+ * @date 2024-08-09T12:20:52.051Z
7
+ * @hash c626332
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, onWillUnmount, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -39124,7 +39124,7 @@ class RangeAdapter {
39124
39124
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
39125
39125
  */
39126
39126
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
39127
- if (!rangeReference.test(sheetXC)) {
39127
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
39128
39128
  return new RangeImpl({
39129
39129
  sheetId: "",
39130
39130
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -42058,18 +42058,30 @@ class Evaluator {
42058
42058
  this.evaluate(this.getAllCells());
42059
42059
  }
42060
42060
  evaluateFormula(sheetId, formulaString) {
42061
- const compiledFormula = compile(formulaString);
42062
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42063
- this.updateCompilationParameters();
42064
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42061
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42065
42062
  if (isMatrix(result)) {
42066
42063
  return matrixMap(result, (cell) => cell.value);
42067
42064
  }
42068
- if (result.value === null) {
42069
- return 0;
42070
- }
42071
42065
  return result.value;
42072
42066
  }
42067
+ evaluateFormulaResult(sheetId, formulaString) {
42068
+ try {
42069
+ const compiledFormula = compile(formulaString);
42070
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42071
+ this.updateCompilationParameters();
42072
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42073
+ if (isMatrix(result)) {
42074
+ return result;
42075
+ }
42076
+ if (result.value === null) {
42077
+ return { value: 0, format: result.format };
42078
+ }
42079
+ return result;
42080
+ }
42081
+ catch (error) {
42082
+ return handleError(error, "");
42083
+ }
42084
+ }
42073
42085
  getAllCells() {
42074
42086
  const positionIds = new JetSet();
42075
42087
  for (const sheetId of this.getters.getSheetIds()) {
@@ -42494,6 +42506,7 @@ function updateEvalContextAndExecute(compiledFormula, compilationParams, sheetId
42494
42506
  class EvaluationPlugin extends UIPlugin {
42495
42507
  static getters = [
42496
42508
  "evaluateFormula",
42509
+ "evaluateFormulaResult",
42497
42510
  "getCorrespondingFormulaCell",
42498
42511
  "getRangeFormattedValues",
42499
42512
  "getRangeValues",
@@ -42552,12 +42565,14 @@ class EvaluationPlugin extends UIPlugin {
42552
42565
  // Getters
42553
42566
  // ---------------------------------------------------------------------------
42554
42567
  evaluateFormula(sheetId, formulaString) {
42555
- try {
42556
- return this.evaluator.evaluateFormula(sheetId, formulaString);
42557
- }
42558
- catch (error) {
42559
- return error.value || CellErrorType.GenericError;
42568
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42569
+ if (isMatrix(result)) {
42570
+ return matrixMap(result, (cell) => cell.value);
42560
42571
  }
42572
+ return result.value;
42573
+ }
42574
+ evaluateFormulaResult(sheetId, formulaString) {
42575
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
42561
42576
  }
42562
42577
  /**
42563
42578
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -46432,6 +46447,7 @@ class FormatPlugin extends UIPlugin {
46432
46447
  * evaluated and updated with the number type.
46433
46448
  */
46434
46449
  setDecimal(sheetId, zones, step) {
46450
+ const positionsByFormat = {};
46435
46451
  // Find the each cell with a number value and get the format
46436
46452
  for (const zone of zones) {
46437
46453
  for (const position of positions(zone)) {
@@ -46441,15 +46457,20 @@ class FormatPlugin extends UIPlugin {
46441
46457
  // of the format
46442
46458
  this.getters.getLocale();
46443
46459
  const newFormat = changeDecimalPlaces(numberFormat, step);
46444
- // Apply the new format on the whole zone
46445
- this.dispatch("SET_FORMATTING", {
46446
- sheetId,
46447
- target: [positionToZone(position)],
46448
- format: newFormat,
46449
- });
46460
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
46461
+ positionsByFormat[newFormat].push(position);
46450
46462
  }
46451
46463
  }
46452
46464
  }
46465
+ // consolidate all positions with the same format in bigger zones
46466
+ for (const newFormat in positionsByFormat) {
46467
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
46468
+ this.dispatch("SET_FORMATTING", {
46469
+ sheetId,
46470
+ format: newFormat,
46471
+ target: zones,
46472
+ });
46473
+ }
46453
46474
  }
46454
46475
  /**
46455
46476
  * Take a range of cells and return the format of the first cell containing a
@@ -57844,6 +57865,6 @@ const constants = {
57844
57865
  export { AbstractChart, CellErrorType, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
57845
57866
 
57846
57867
 
57847
- __info__.version = "17.1.26";
57848
- __info__.date = "2024-08-02T08:23:08.499Z";
57849
- __info__.hash = "4ba7e55";
57868
+ __info__.version = "17.1.27";
57869
+ __info__.date = "2024-08-09T12:20:52.051Z";
57870
+ __info__.hash = "c626332";
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.1.26
6
- * @date 2024-08-02T08:23:08.499Z
7
- * @hash 4ba7e55
5
+ * @version 17.1.27
6
+ * @date 2024-08-09T12:20:52.051Z
7
+ * @hash c626332
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -39125,7 +39125,7 @@
39125
39125
  * @param sheetXC the string description of a range, in the form SheetName!XC:XC
39126
39126
  */
39127
39127
  getRangeFromSheetXC(defaultSheetId, sheetXC) {
39128
- if (!rangeReference.test(sheetXC)) {
39128
+ if (!rangeReference.test(sheetXC) || !this.getters.tryGetSheet(defaultSheetId)) {
39129
39129
  return new RangeImpl({
39130
39130
  sheetId: "",
39131
39131
  zone: { left: -1, top: -1, right: -1, bottom: -1 },
@@ -42059,18 +42059,30 @@
42059
42059
  this.evaluate(this.getAllCells());
42060
42060
  }
42061
42061
  evaluateFormula(sheetId, formulaString) {
42062
- const compiledFormula = compile(formulaString);
42063
- const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42064
- this.updateCompilationParameters();
42065
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42062
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42066
42063
  if (isMatrix(result)) {
42067
42064
  return matrixMap(result, (cell) => cell.value);
42068
42065
  }
42069
- if (result.value === null) {
42070
- return 0;
42071
- }
42072
42066
  return result.value;
42073
42067
  }
42068
+ evaluateFormulaResult(sheetId, formulaString) {
42069
+ try {
42070
+ const compiledFormula = compile(formulaString);
42071
+ const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
42072
+ this.updateCompilationParameters();
42073
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId);
42074
+ if (isMatrix(result)) {
42075
+ return result;
42076
+ }
42077
+ if (result.value === null) {
42078
+ return { value: 0, format: result.format };
42079
+ }
42080
+ return result;
42081
+ }
42082
+ catch (error) {
42083
+ return handleError(error, "");
42084
+ }
42085
+ }
42074
42086
  getAllCells() {
42075
42087
  const positionIds = new JetSet();
42076
42088
  for (const sheetId of this.getters.getSheetIds()) {
@@ -42495,6 +42507,7 @@
42495
42507
  class EvaluationPlugin extends UIPlugin {
42496
42508
  static getters = [
42497
42509
  "evaluateFormula",
42510
+ "evaluateFormulaResult",
42498
42511
  "getCorrespondingFormulaCell",
42499
42512
  "getRangeFormattedValues",
42500
42513
  "getRangeValues",
@@ -42553,12 +42566,14 @@
42553
42566
  // Getters
42554
42567
  // ---------------------------------------------------------------------------
42555
42568
  evaluateFormula(sheetId, formulaString) {
42556
- try {
42557
- return this.evaluator.evaluateFormula(sheetId, formulaString);
42558
- }
42559
- catch (error) {
42560
- return error.value || CellErrorType.GenericError;
42569
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
42570
+ if (isMatrix(result)) {
42571
+ return matrixMap(result, (cell) => cell.value);
42561
42572
  }
42573
+ return result.value;
42574
+ }
42575
+ evaluateFormulaResult(sheetId, formulaString) {
42576
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
42562
42577
  }
42563
42578
  /**
42564
42579
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -46433,6 +46448,7 @@
46433
46448
  * evaluated and updated with the number type.
46434
46449
  */
46435
46450
  setDecimal(sheetId, zones, step) {
46451
+ const positionsByFormat = {};
46436
46452
  // Find the each cell with a number value and get the format
46437
46453
  for (const zone of zones) {
46438
46454
  for (const position of positions(zone)) {
@@ -46442,15 +46458,20 @@
46442
46458
  // of the format
46443
46459
  this.getters.getLocale();
46444
46460
  const newFormat = changeDecimalPlaces(numberFormat, step);
46445
- // Apply the new format on the whole zone
46446
- this.dispatch("SET_FORMATTING", {
46447
- sheetId,
46448
- target: [positionToZone(position)],
46449
- format: newFormat,
46450
- });
46461
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
46462
+ positionsByFormat[newFormat].push(position);
46451
46463
  }
46452
46464
  }
46453
46465
  }
46466
+ // consolidate all positions with the same format in bigger zones
46467
+ for (const newFormat in positionsByFormat) {
46468
+ const zones = futureRecomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
46469
+ this.dispatch("SET_FORMATTING", {
46470
+ sheetId,
46471
+ format: newFormat,
46472
+ target: zones,
46473
+ });
46474
+ }
46454
46475
  }
46455
46476
  /**
46456
46477
  * Take a range of cells and return the format of the first cell containing a
@@ -57881,9 +57902,9 @@
57881
57902
  exports.tokenize = tokenize;
57882
57903
 
57883
57904
 
57884
- __info__.version = "17.1.26";
57885
- __info__.date = "2024-08-02T08:23:08.499Z";
57886
- __info__.hash = "4ba7e55";
57905
+ __info__.version = "17.1.27";
57906
+ __info__.date = "2024-08-09T12:20:52.051Z";
57907
+ __info__.hash = "c626332";
57887
57908
 
57888
57909
 
57889
57910
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);