@odoo/o-spreadsheet 16.0.24 → 16.0.26

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.
@@ -621,13 +621,6 @@
621
621
  }
622
622
 
623
623
  //------------------------------------------------------------------------------
624
- /**
625
- * Stringify an object, like JSON.stringify, except that the first level of keys
626
- * is ordered.
627
- */
628
- function stringify(obj) {
629
- return JSON.stringify(obj, Object.keys(obj).sort());
630
- }
631
624
  /**
632
625
  * Remove quotes from a quoted string
633
626
  * ```js
@@ -929,7 +922,7 @@
929
922
  */
930
923
  function getItemId(item, itemsDic) {
931
924
  for (let [key, value] of Object.entries(itemsDic)) {
932
- if (stringify(value) === stringify(item)) {
925
+ if (deepEquals(value, item)) {
933
926
  return parseInt(key, 10);
934
927
  }
935
928
  }
@@ -1065,6 +1058,22 @@
1065
1058
  if (!matrix.length)
1066
1059
  return matrix;
1067
1060
  return matrix[0].map((_, i) => matrix.map((row) => row[i]));
1061
+ }
1062
+ /**
1063
+ * Creates a version of the function that's memoized on the value of its first
1064
+ * argument, if any.
1065
+ */
1066
+ function memoize(func) {
1067
+ const cache = new Map();
1068
+ const funcName = func.name ? func.name + " (memoized)" : "memoized";
1069
+ return {
1070
+ [funcName](...args) {
1071
+ if (!cache.has(args[0])) {
1072
+ cache.set(args[0], func(...args));
1073
+ }
1074
+ return cache.get(args[0]);
1075
+ },
1076
+ }[funcName];
1068
1077
  }
1069
1078
 
1070
1079
  const RBA_REGEX = /rgba?\(|\s+|\)/gi;
@@ -1344,8 +1353,10 @@
1344
1353
  const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
1345
1354
  // Same as above, but matches the exact string (nothing before or after)
1346
1355
  const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
1347
- /** Reference of a column header (eg. A, AB) */
1348
- const colHeader = new RegExp(/^([A-Z]{1,3})+$/, "i");
1356
+ /** Reference of a column header (eg. A, AB, $A) */
1357
+ const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
1358
+ /** Reference of a row header (eg. 1, $1) */
1359
+ const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
1349
1360
  /** Reference of a column (eg. A, $CA, Sheet1!B) */
1350
1361
  const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
1351
1362
  /** Reference of a row (eg. 1, 59, Sheet1!9) */
@@ -1375,6 +1386,9 @@
1375
1386
  function isColHeader(str) {
1376
1387
  return colHeader.test(str);
1377
1388
  }
1389
+ function isRowHeader(str) {
1390
+ return rowHeader.test(str);
1391
+ }
1378
1392
  /**
1379
1393
  * Return true if the given xc is the reference of a single cell,
1380
1394
  * without any specified sheet (e.g. A1)
@@ -2075,18 +2089,10 @@
2075
2089
  if (isFullCol) {
2076
2090
  parts[0].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2077
2091
  parts[1].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2078
- if (zone.left === zone.right) {
2079
- parts[0].colFixed = parts[0].colFixed || parts[1].colFixed;
2080
- parts[1].colFixed = parts[0].colFixed || parts[1].colFixed;
2081
- }
2082
2092
  }
2083
2093
  if (isFullRow) {
2084
2094
  parts[0].colFixed = parts[0].colFixed || parts[1].colFixed;
2085
2095
  parts[1].colFixed = parts[0].colFixed || parts[1].colFixed;
2086
- if (zone.top === zone.bottom) {
2087
- parts[0].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2088
- parts[1].rowFixed = parts[0].rowFixed || parts[1].rowFixed;
2089
- }
2090
2096
  }
2091
2097
  return parts;
2092
2098
  }
@@ -3302,6 +3308,7 @@
3302
3308
  CommandResult[CommandResult["ChartDoesNotExist"] = 84] = "ChartDoesNotExist";
3303
3309
  CommandResult[CommandResult["InvalidHeaderIndex"] = 85] = "InvalidHeaderIndex";
3304
3310
  CommandResult[CommandResult["InvalidQuantity"] = 86] = "InvalidQuantity";
3311
+ CommandResult[CommandResult["NoChanges"] = 87] = "NoChanges";
3305
3312
  })(exports.CommandResult || (exports.CommandResult = {}));
3306
3313
 
3307
3314
  function isMatrix(x) {
@@ -3894,6 +3901,9 @@
3894
3901
  }
3895
3902
  function getOpenedMenus() {
3896
3903
  return Array.from(document.querySelectorAll(".o-spreadsheet .o-menu"));
3904
+ }
3905
+ function isMacOS() {
3906
+ return navigator.userAgent.toUpperCase().indexOf("MAC") >= 0;
3897
3907
  }
3898
3908
 
3899
3909
  /**
@@ -10977,12 +10987,12 @@
10977
10987
  }
10978
10988
  }
10979
10989
  /** Normalize string by setting it to lowercase and replacing accent letters with plain letters */
10980
- function normalizeString(str) {
10990
+ const normalizeString = memoize(function normalizeString(str) {
10981
10991
  return str
10982
10992
  .toLowerCase()
10983
10993
  .normalize("NFD")
10984
10994
  .replace(/[\u0300-\u036f]/g, "");
10985
- }
10995
+ });
10986
10996
  /**
10987
10997
  * Normalize a value.
10988
10998
  * If the cell value is a string, this will set it to lowercase and replacing accent letters with plain letters
@@ -18557,7 +18567,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18557
18567
  SPACE: goTo(State.RightRef),
18558
18568
  NUMBER: goTo(State.Found),
18559
18569
  REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18560
- SYMBOL: goTo(State.Found, (token) => isColHeader(token.value)),
18570
+ SYMBOL: goTo(State.Found, (token) => isColHeader(token.value) || isRowHeader(token.value)),
18561
18571
  },
18562
18572
  [State.RightColumnRef]: {
18563
18573
  SPACE: goTo(State.RightColumnRef),
@@ -18568,6 +18578,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18568
18578
  SPACE: goTo(State.RightRowRef),
18569
18579
  NUMBER: goTo(State.Found),
18570
18580
  REFERENCE: goTo(State.Found, (token) => isSingleCellReference(token.value)),
18581
+ SYMBOL: goTo(State.Found, (token) => isRowHeader(token.value)),
18571
18582
  },
18572
18583
  [State.Found]: {},
18573
18584
  };
@@ -19077,6 +19088,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19077
19088
  return xc.slice(0, indexOfNumber) + "$" + xc.slice(indexOfNumber);
19078
19089
  case "colrow":
19079
19090
  indexOfNumber = xc.search(/[0-9]/);
19091
+ if (indexOfNumber === -1 || indexOfNumber === 0) {
19092
+ // no row number (eg. A) or no column (eg. 1)
19093
+ return "$" + xc;
19094
+ }
19080
19095
  xc = xc.slice(0, indexOfNumber) + "$" + xc.slice(indexOfNumber);
19081
19096
  return "$" + xc;
19082
19097
  case "none":
@@ -21530,6 +21545,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21530
21545
  draggerShadowThickness: 0,
21531
21546
  delta: 0,
21532
21547
  base: 0,
21548
+ position: "before",
21533
21549
  });
21534
21550
  }
21535
21551
  _computeHandleDisplay(ev) {
@@ -21655,11 +21671,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21655
21671
  this.state.draggerLinePosition = dimensions.start;
21656
21672
  this.state.draggerShadowPosition = dimensions.start;
21657
21673
  this.state.base = elementIndex;
21674
+ this.state.position = "before";
21658
21675
  }
21659
21676
  else if (this._getSelectedZoneEnd() < elementIndex) {
21660
21677
  this.state.draggerLinePosition = dimensions.end;
21661
21678
  this.state.draggerShadowPosition = dimensions.end - this.state.draggerShadowThickness;
21662
- this.state.base = elementIndex + 1;
21679
+ this.state.base = elementIndex;
21680
+ this.state.position = "after";
21663
21681
  }
21664
21682
  else {
21665
21683
  this.state.draggerLinePosition = startDimensions.start;
@@ -21837,6 +21855,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
21837
21855
  dimension: "COL",
21838
21856
  base: this.state.base,
21839
21857
  elements,
21858
+ position: this.state.position,
21840
21859
  });
21841
21860
  if (!result.isSuccessful && result.reasons.includes(2 /* CommandResult.WillRemoveExistingMerge */)) {
21842
21861
  this.env.raiseError(MergeErrorMessage);
@@ -22006,6 +22025,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22006
22025
  dimension: "ROW",
22007
22026
  base: this.state.base,
22008
22027
  elements,
22028
+ position: this.state.position,
22009
22029
  });
22010
22030
  if (!result.isSuccessful && result.reasons.includes(2 /* CommandResult.WillRemoveExistingMerge */)) {
22011
22031
  this.env.raiseError(MergeErrorMessage);
@@ -22108,8 +22128,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
22108
22128
  return val * (deltaMode === 0 ? 1 : DEFAULT_CELL_HEIGHT);
22109
22129
  }
22110
22130
  const onMouseWheel = (ev) => {
22111
- const deltaX = normalize(ev.shiftKey ? ev.deltaY : ev.deltaX, ev.deltaMode);
22112
- const deltaY = normalize(ev.shiftKey ? ev.deltaX : ev.deltaY, ev.deltaMode);
22131
+ const deltaX = normalize(ev.shiftKey && !isMacOS() ? ev.deltaY : ev.deltaX, ev.deltaMode);
22132
+ const deltaY = normalize(ev.shiftKey && !isMacOS() ? ev.deltaX : ev.deltaY, ev.deltaMode);
22113
22133
  handler(deltaX, deltaY);
22114
22134
  };
22115
22135
  return onMouseWheel;
@@ -27102,6 +27122,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27102
27122
  // ---------------------------------------------------------------------------
27103
27123
  // Command Handling
27104
27124
  // ---------------------------------------------------------------------------
27125
+ allowDispatch(cmd) {
27126
+ switch (cmd.type) {
27127
+ case "SET_BORDER":
27128
+ return this.checkBordersUnchanged(cmd);
27129
+ default:
27130
+ return 0 /* CommandResult.Success */;
27131
+ }
27132
+ }
27105
27133
  handle(cmd) {
27106
27134
  switch (cmd.type) {
27107
27135
  case "ADD_MERGE":
@@ -27497,6 +27525,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27497
27525
  this.setBorders(sheetId, [{ ...zone, left: right }], "right");
27498
27526
  }
27499
27527
  }
27528
+ checkBordersUnchanged(cmd) {
27529
+ var _a, _b, _c, _d;
27530
+ const currentBorder = this.getCellBorder(cmd.sheetId, cmd.col, cmd.row);
27531
+ const areAllNewBordersUndefined = !((_a = cmd.border) === null || _a === void 0 ? void 0 : _a.bottom) && !((_b = cmd.border) === null || _b === void 0 ? void 0 : _b.left) && !((_c = cmd.border) === null || _c === void 0 ? void 0 : _c.right) && !((_d = cmd.border) === null || _d === void 0 ? void 0 : _d.top);
27532
+ if ((!currentBorder && areAllNewBordersUndefined) || deepEquals(currentBorder, cmd.border)) {
27533
+ return 87 /* CommandResult.NoChanges */;
27534
+ }
27535
+ return 0 /* CommandResult.Success */;
27536
+ }
27500
27537
  // ---------------------------------------------------------------------------
27501
27538
  // Import/Export
27502
27539
  // ---------------------------------------------------------------------------
@@ -27532,7 +27569,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27532
27569
  */
27533
27570
  function getBorderId(border) {
27534
27571
  for (let [key, value] of Object.entries(borders)) {
27535
- if (stringify(value) === stringify(border)) {
27572
+ if (deepEquals(value, border)) {
27536
27573
  return parseInt(key, 10);
27537
27574
  }
27538
27575
  }
@@ -27575,6 +27612,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27575
27612
  class CellPlugin extends CorePlugin {
27576
27613
  constructor() {
27577
27614
  super(...arguments);
27615
+ this.nextId = 1;
27578
27616
  this.cells = {};
27579
27617
  this.createCell = cellFactory(this.getters);
27580
27618
  }
@@ -27600,8 +27638,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27600
27638
  allowDispatch(cmd) {
27601
27639
  switch (cmd.type) {
27602
27640
  case "UPDATE_CELL":
27641
+ return this.checkCellOutOfSheet(cmd);
27603
27642
  case "CLEAR_CELL":
27604
- return this.checkCellOutOfSheet(cmd.sheetId, cmd.col, cmd.row);
27643
+ return this.checkValidations(cmd, this.chainValidations(this.checkCellOutOfSheet, this.checkUselessClearCell));
27605
27644
  default:
27606
27645
  return 0 /* CommandResult.Success */;
27607
27646
  }
@@ -27742,7 +27781,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27742
27781
  importCell(sheetId, cellData, normalizedStyles, normalizedFormats) {
27743
27782
  const style = (cellData.style && normalizedStyles[cellData.style]) || undefined;
27744
27783
  const format = (cellData.format && normalizedFormats[cellData.format]) || undefined;
27745
- const cellId = this.uuidGenerator.uuidv4();
27784
+ const cellId = this.getNextUid();
27746
27785
  const properties = { format, style };
27747
27786
  return this.createCell(cellId, (cellData === null || cellData === void 0 ? void 0 : cellData.content) || "", properties, sheetId);
27748
27787
  }
@@ -27773,14 +27812,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27773
27812
  */
27774
27813
  getCellById(cellId) {
27775
27814
  // this must be as fast as possible
27776
- for (const sheetId in this.cells) {
27777
- const sheet = this.cells[sheetId];
27778
- const cell = sheet[cellId];
27779
- if (cell) {
27780
- return cell;
27781
- }
27782
- }
27783
- return undefined;
27815
+ const position = this.getters.getCellPosition(cellId);
27816
+ const sheet = this.cells[position.sheetId];
27817
+ return sheet[cellId];
27784
27818
  }
27785
27819
  /*
27786
27820
  * Reconstructs the original formula string based on a normalized form and its dependencies
@@ -27888,6 +27922,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27888
27922
  }
27889
27923
  return format;
27890
27924
  }
27925
+ getNextUid() {
27926
+ const id = this.nextId.toString();
27927
+ this.history.update("nextId", this.nextId + 1);
27928
+ return id;
27929
+ }
27891
27930
  updateCell(sheetId, col, row, after) {
27892
27931
  var _a;
27893
27932
  const before = this.getters.getCell(sheetId, col, row);
@@ -27926,7 +27965,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27926
27965
  }
27927
27966
  return;
27928
27967
  }
27929
- const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.uuidGenerator.uuidv4();
27968
+ const cellId = (before === null || before === void 0 ? void 0 : before.id) || this.getNextUid();
27930
27969
  const didContentChange = hasContent;
27931
27970
  const properties = { format, style };
27932
27971
  const cell = this.createCell(cellId, afterContent, properties, sheetId);
@@ -27940,13 +27979,23 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27940
27979
  this.history.update("cells", sheetId, cell.id, cell);
27941
27980
  this.dispatch("UPDATE_CELL_POSITION", { cellId: cell.id, col, row, sheetId });
27942
27981
  }
27943
- checkCellOutOfSheet(sheetId, col, row) {
27982
+ checkCellOutOfSheet(cmd) {
27983
+ const { sheetId, col, row } = cmd;
27944
27984
  const sheet = this.getters.tryGetSheet(sheetId);
27945
27985
  if (!sheet)
27946
27986
  return 27 /* CommandResult.InvalidSheetId */;
27947
27987
  const sheetZone = this.getters.getSheetZone(sheetId);
27948
27988
  return isInside(col, row, sheetZone) ? 0 /* CommandResult.Success */ : 18 /* CommandResult.TargetOutOfSheet */;
27949
27989
  }
27990
+ checkUselessClearCell(cmd) {
27991
+ const cell = this.getters.getCell(cmd.sheetId, cmd.col, cmd.row);
27992
+ if (!cell)
27993
+ return 87 /* CommandResult.NoChanges */;
27994
+ if (!cell.content && !cell.style && !cell.format) {
27995
+ return 87 /* CommandResult.NoChanges */;
27996
+ }
27997
+ return 0 /* CommandResult.Success */;
27998
+ }
27950
27999
  }
27951
28000
  CellPlugin.getters = [
27952
28001
  "zoneToXC",
@@ -29898,7 +29947,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29898
29947
  const elements = cmd.dimension === "COL"
29899
29948
  ? this.getNumberCols(cmd.sheetId)
29900
29949
  : this.getNumberRows(cmd.sheetId);
29901
- if (cmd.base < 0 || cmd.base > elements) {
29950
+ if (cmd.base < 0 || cmd.base >= elements) {
29902
29951
  return 85 /* CommandResult.InvalidHeaderIndex */;
29903
29952
  }
29904
29953
  else if (cmd.quantity <= 0) {
@@ -30511,10 +30560,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
30511
30560
  // begin with the end.
30512
30561
  rows.sort((a, b) => b - a);
30513
30562
  for (let group of groupConsecutive(rows)) {
30563
+ // indexes are sorted in the descending order
30564
+ const from = group[group.length - 1];
30565
+ const to = group[0];
30514
30566
  // Move the cells.
30515
- this.moveCellOnRowsDeletion(sheet, group[group.length - 1], group[0]);
30516
- // Effectively delete the element and recompute the left-right/top-bottom.
30517
- group.map((row) => this.updateRowsStructureOnDeletion(row, sheet));
30567
+ this.moveCellOnRowsDeletion(sheet, from, to);
30568
+ // Effectively delete the rows
30569
+ this.updateRowsStructureOnDeletion(sheet, from, to);
30518
30570
  }
30519
30571
  const count = rows.filter((row) => row < sheet.panes.ySplit).length;
30520
30572
  if (count) {
@@ -30536,8 +30588,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
30536
30588
  this.addEmptyRows(sheet, quantity);
30537
30589
  // Move the cells.
30538
30590
  this.moveCellsOnAddition(sheet, index, quantity, "rows");
30539
- // Recompute the left-right/top-bottom.
30540
- this.updateRowsStructureOnAddition(sheet, row, quantity);
30541
30591
  if (index < sheet.panes.ySplit) {
30542
30592
  this.setPaneDivisions(sheet.id, sheet.panes.ySplit + quantity, "ROW");
30543
30593
  }
@@ -30638,35 +30688,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
30638
30688
  }
30639
30689
  }
30640
30690
  }
30641
- updateRowsStructureOnDeletion(index, sheet) {
30691
+ updateRowsStructureOnDeletion(sheet, deleteFromRow, deleteToRow) {
30642
30692
  const rows = [];
30643
- const cellsQueue = sheet.rows.map((row) => row.cells);
30693
+ const cellsQueue = sheet.rows.map((row) => row.cells).reverse();
30644
30694
  for (let i in sheet.rows) {
30645
- if (Number(i) === index) {
30695
+ const row = Number(i);
30696
+ if (row >= deleteFromRow && row <= deleteToRow) {
30646
30697
  continue;
30647
30698
  }
30648
30699
  rows.push({
30649
- cells: cellsQueue.shift(),
30700
+ cells: cellsQueue.pop(),
30650
30701
  });
30651
30702
  }
30652
30703
  this.history.update("sheets", sheet.id, "rows", rows);
30653
30704
  }
30654
- /**
30655
- * Update the rows of the sheet after an addition:
30656
- * - Rename the rows
30657
- *
30658
- * @param sheet Sheet on which the deletion occurs
30659
- * @param addedRow Index of the added row
30660
- * @param rowsToAdd Number of the rows to add
30661
- */
30662
- updateRowsStructureOnAddition(sheet, addedRow, rowsToAdd) {
30663
- const rows = [];
30664
- const cellsQueue = sheet.rows.map((row) => row.cells);
30665
- sheet.rows.forEach(() => rows.push({
30666
- cells: cellsQueue.shift(),
30667
- }));
30668
- this.history.update("sheets", sheet.id, "rows", rows);
30669
- }
30670
30705
  /**
30671
30706
  * Add empty rows at the end of the rows
30672
30707
  *
@@ -32655,6 +32690,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32655
32690
  }
32656
32691
  return cell.evaluated;
32657
32692
  }
32693
+ const rangeCache = {};
32658
32694
  /**
32659
32695
  * Return the values of the cell(s) used in reference, but always in the format of a range even
32660
32696
  * if a single cell is referenced. It is a list of col values. This is useful for the formulas that describe parameters as
@@ -32671,21 +32707,26 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32671
32707
  // Performance issue: Avoid fetching data on positions that are out of the spreadsheet
32672
32708
  // e.g. A1:ZZZ9999 in a sheet with 10 cols and 10 rows should ignore everything past J10 and return a 10x10 array
32673
32709
  const sheetZone = getters.getSheetZone(sheetId);
32674
- const result = [];
32675
32710
  const zone = intersection(range.zone, sheetZone);
32676
32711
  if (!zone) {
32677
- result.push([]);
32678
- return result;
32712
+ return [[]];
32713
+ }
32714
+ const { top, left, bottom, right } = zone;
32715
+ const cacheKey = `${sheetId}-${top}-${left}-${bottom}-${right}`;
32716
+ if (cacheKey in rangeCache) {
32717
+ return rangeCache[cacheKey];
32679
32718
  }
32719
+ const result = new Array(right - left + 1);
32680
32720
  // Performance issue: nested loop is faster than a map here
32681
- for (let col = zone.left; col <= zone.right; col++) {
32682
- const rowValues = [];
32683
- for (let row = zone.top; row <= zone.bottom; row++) {
32721
+ for (let col = left; col <= right; col++) {
32722
+ const rowValues = new Array(bottom - top + 1);
32723
+ for (let row = top; row <= bottom; row++) {
32684
32724
  const cell = evalContext.getters.getCell(range.sheetId, col, row);
32685
- rowValues.push(cell ? getEvaluatedCell(cell) : undefined);
32725
+ rowValues[row - top] = cell ? getEvaluatedCell(cell) : undefined;
32686
32726
  }
32687
- result.push(rowValues);
32727
+ result[col - left] = rowValues;
32688
32728
  }
32729
+ rangeCache[cacheKey] = result;
32689
32730
  return result;
32690
32731
  }
32691
32732
  /**
@@ -34939,7 +34980,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34939
34980
  sheetId: cmd.sheetId,
34940
34981
  base: cmd.base,
34941
34982
  quantity: thickness,
34942
- position: "before",
34983
+ position: cmd.position,
34943
34984
  });
34944
34985
  const isCol = cmd.dimension === "COL";
34945
34986
  const start = cmd.elements[0];
@@ -34956,12 +34997,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34956
34997
  },
34957
34998
  ];
34958
34999
  const state = new ClipboardCellsState(target, "CUT", this.getters, this.dispatch, this.selection);
35000
+ const base = isBasedBefore ? cmd.base : cmd.base + 1;
34959
35001
  const pasteTarget = [
34960
35002
  {
34961
- left: isCol ? cmd.base : 0,
34962
- right: isCol ? cmd.base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
34963
- top: !isCol ? cmd.base : 0,
34964
- bottom: !isCol ? cmd.base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
35003
+ left: isCol ? base : 0,
35004
+ right: isCol ? base + thickness - 1 : this.getters.getNumberCols(cmd.sheetId) - 1,
35005
+ top: !isCol ? base : 0,
35006
+ bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
34965
35007
  },
34966
35008
  ];
34967
35009
  state.paste(pasteTarget, { selectTarget: true });
@@ -34998,6 +35040,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34998
35040
  doesElementsHaveCommonMerges(id, cmd.base - 1, cmd.base)) {
34999
35041
  return 2 /* CommandResult.WillRemoveExistingMerge */;
35000
35042
  }
35043
+ const headers = [cmd.base, ...cmd.elements];
35044
+ const maxHeaderValue = isCol ? this.getters.getNumberCols(id) : this.getters.getNumberRows(id);
35045
+ if (headers.some((h) => h < 0 || h >= maxHeaderValue)) {
35046
+ return 85 /* CommandResult.InvalidHeaderIndex */;
35047
+ }
35001
35048
  return 0 /* CommandResult.Success */;
35002
35049
  }
35003
35050
  //-------------------------------------------
@@ -39908,9 +39955,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
39908
39955
  * Apply the changes of the given HistoryChange to the state
39909
39956
  */
39910
39957
  function applyChange(change, target) {
39911
- let val = change.root;
39912
- let key = change.path[change.path.length - 1];
39913
- for (let pathIndex = 0; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
39958
+ let val = change.path[0];
39959
+ const key = change.path[change.path.length - 1];
39960
+ for (let pathIndex = 1; pathIndex < change.path.slice(0, -1).length; pathIndex++) {
39914
39961
  const p = change.path[pathIndex];
39915
39962
  if (val[p] === undefined) {
39916
39963
  const nextPath = change.path[pathIndex + 1];
@@ -41040,13 +41087,14 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41040
41087
  }
41041
41088
  addChange(...args) {
41042
41089
  const val = args.pop();
41043
- const [root, ...path] = args;
41090
+ const root = args[0];
41044
41091
  let value = root;
41045
- let key = path[path.length - 1];
41046
- for (let pathIndex = 0; pathIndex <= path.length - 2; pathIndex++) {
41047
- const p = path[pathIndex];
41092
+ let key = args[args.length - 1];
41093
+ const pathLength = args.length - 2;
41094
+ for (let pathIndex = 1; pathIndex <= pathLength; pathIndex++) {
41095
+ const p = args[pathIndex];
41048
41096
  if (value[p] === undefined) {
41049
- const nextPath = path[pathIndex + 1];
41097
+ const nextPath = args[pathIndex + 1];
41050
41098
  value[p] = createEmptyStructure(nextPath);
41051
41099
  }
41052
41100
  value = value[p];
@@ -41055,8 +41103,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
41055
41103
  return;
41056
41104
  }
41057
41105
  this.changes.push({
41058
- root,
41059
- path,
41106
+ path: args,
41060
41107
  before: value[key],
41061
41108
  after: val,
41062
41109
  });
@@ -42790,7 +42837,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
42790
42837
  */
42791
42838
  checkDispatchAllowed(command) {
42792
42839
  const results = this.handlers.map((handler) => handler.allowDispatch(command));
42793
- return new DispatchResult(results.flat());
42840
+ if (results.some((r) => r !== 0 /* CommandResult.Success */)) {
42841
+ return new DispatchResult(results.flat());
42842
+ }
42843
+ return DispatchResult.Success;
42794
42844
  }
42795
42845
  finalize() {
42796
42846
  this.status = 3 /* Status.Finalizing */;
@@ -43010,9 +43060,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43010
43060
  Object.defineProperty(exports, '__esModule', { value: true });
43011
43061
 
43012
43062
 
43013
- __info__.version = '16.0.24';
43014
- __info__.date = '2023-11-16T11:56:55.435Z';
43015
- __info__.hash = 'e0d7313';
43063
+ __info__.version = '16.0.26';
43064
+ __info__.date = '2023-12-05T09:37:20.450Z';
43065
+ __info__.hash = '10de093';
43016
43066
 
43017
43067
 
43018
43068
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);