@odoo/o-spreadsheet 16.0.57 → 16.0.58

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.
@@ -11565,15 +11565,18 @@
11565
11565
  let currentIndex;
11566
11566
  let currentVal;
11567
11567
  let currentType;
11568
+ const getValue = sortOrder === "desc"
11569
+ ? (i) => getValueInData(data, rangeLength - i - 1)
11570
+ : (i) => getValueInData(data, i);
11568
11571
  while (indexRight - indexLeft >= 0) {
11569
11572
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
11570
11573
  currentIndex = indexMedian;
11571
- currentVal = getValueInData(data, currentIndex);
11574
+ currentVal = getValue(currentIndex);
11572
11575
  currentType = typeof currentVal;
11573
11576
  // 1 - linear search to find value with the same type
11574
11577
  while (indexLeft < currentIndex && targetType !== currentType) {
11575
11578
  currentIndex--;
11576
- currentVal = getValueInData(data, currentIndex);
11579
+ currentVal = getValue(currentIndex);
11577
11580
  currentType = typeof currentVal;
11578
11581
  }
11579
11582
  if (currentType !== targetType || currentVal === undefined) {
@@ -11588,8 +11591,7 @@
11588
11591
  else if (mode === "nextSmaller" && currentVal <= target) {
11589
11592
  if (matchVal === undefined ||
11590
11593
  matchVal < currentVal ||
11591
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11592
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11594
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11593
11595
  matchVal = currentVal;
11594
11596
  matchValIndex = currentIndex;
11595
11597
  }
@@ -11597,15 +11599,13 @@
11597
11599
  else if (mode === "nextGreater" && currentVal >= target) {
11598
11600
  if (matchVal === undefined ||
11599
11601
  matchVal > currentVal ||
11600
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
11601
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
11602
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
11602
11603
  matchVal = currentVal;
11603
11604
  matchValIndex = currentIndex;
11604
11605
  }
11605
11606
  }
11606
11607
  // 3 - give new indexes for the Binary search
11607
- if ((sortOrder === "asc" && currentVal > target) ||
11608
- (sortOrder === "desc" && currentVal <= target)) {
11608
+ if (currentVal > target || (mode === "strict" && currentVal === target)) {
11609
11609
  indexRight = currentIndex - 1;
11610
11610
  }
11611
11611
  else {
@@ -11613,7 +11613,10 @@
11613
11613
  }
11614
11614
  }
11615
11615
  // note that valMinIndex could be 0
11616
- return matchValIndex !== undefined ? matchValIndex : -1;
11616
+ if (matchValIndex === undefined) {
11617
+ return -1;
11618
+ }
11619
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
11617
11620
  }
11618
11621
  /**
11619
11622
  * Perform a linear search and return the index of the match.
@@ -34416,12 +34419,21 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34416
34419
  drawGrid(renderingContext, layer) {
34417
34420
  switch (layer) {
34418
34421
  case 0 /* LAYERS.Background */:
34419
- this.boxes = this.getGridBoxes();
34420
34422
  this.drawBackground(renderingContext);
34421
- this.drawCellBackground(renderingContext);
34422
- this.drawBorders(renderingContext);
34423
- this.drawTexts(renderingContext);
34424
- this.drawIcon(renderingContext);
34423
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
34424
+ const { ctx } = renderingContext;
34425
+ ctx.save();
34426
+ ctx.beginPath();
34427
+ const rect = this.getters.getVisibleRect(zone);
34428
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
34429
+ ctx.clip();
34430
+ this.boxes = this.getGridBoxes(zone);
34431
+ this.drawCellBackground(renderingContext);
34432
+ this.drawBorders(renderingContext);
34433
+ this.drawTexts(renderingContext);
34434
+ this.drawIcon(renderingContext);
34435
+ ctx.restore();
34436
+ }
34425
34437
  this.drawFrozenPanes(renderingContext);
34426
34438
  break;
34427
34439
  case 7 /* LAYERS.Headers */:
@@ -34786,7 +34798,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34786
34798
  const row = zone.top;
34787
34799
  const cell = this.getters.getCell(sheetId, col, row);
34788
34800
  const showFormula = this.getters.shouldShowFormulas();
34789
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
34801
+ const { x, y, width, height } = this.getters.getRect(zone);
34790
34802
  const box = {
34791
34803
  x,
34792
34804
  y,
@@ -34898,12 +34910,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
34898
34910
  }
34899
34911
  return box;
34900
34912
  }
34901
- getGridBoxes() {
34913
+ getGridBoxes(zone) {
34902
34914
  const boxes = [];
34903
- const visibleCols = this.getters.getSheetViewVisibleCols();
34915
+ const visibleCols = this.getters
34916
+ .getSheetViewVisibleCols()
34917
+ .filter((col) => col >= zone.left && col <= zone.right);
34904
34918
  const left = visibleCols[0];
34905
34919
  const right = visibleCols[visibleCols.length - 1];
34906
- const visibleRows = this.getters.getSheetViewVisibleRows();
34920
+ const visibleRows = this.getters
34921
+ .getSheetViewVisibleRows()
34922
+ .filter((row) => row >= zone.top && row <= zone.bottom);
34907
34923
  const top = visibleRows[0];
34908
34924
  const bottom = visibleRows[visibleRows.length - 1];
34909
34925
  const viewport = { left, right, top, bottom };
@@ -35433,7 +35449,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
35433
35449
  ];
35434
35450
  state.paste(pasteTarget, { selectTarget: true });
35435
35451
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
35436
- let currentIndex = cmd.base;
35452
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
35437
35453
  for (const element of toRemove) {
35438
35454
  const size = cmd.dimension === "COL"
35439
35455
  ? this.getters.getColSize(cmd.sheetId, element)
@@ -36940,7 +36956,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36940
36956
  * @param zone
36941
36957
  * @returns Computes the absolute coordinate of a given zone inside the viewport
36942
36958
  */
36943
- getRect(zone) {
36959
+ getVisibleRect(zone) {
36944
36960
  const targetZone = intersection(zone, this.zone);
36945
36961
  if (targetZone) {
36946
36962
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -36948,12 +36964,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
36948
36964
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
36949
36965
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
36950
36966
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
36951
- return {
36952
- x,
36953
- y,
36954
- width,
36955
- height,
36956
- };
36967
+ return { x, y, width, height };
36968
+ }
36969
+ else {
36970
+ return undefined;
36971
+ }
36972
+ }
36973
+ getFullRect(zone) {
36974
+ const targetZone = intersection(zone, this.zone);
36975
+ if (targetZone) {
36976
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
36977
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
36978
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
36979
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
36980
+ return { x, y, width, height };
36957
36981
  }
36958
36982
  else {
36959
36983
  return undefined;
@@ -37447,21 +37471,26 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37447
37471
  getVisibleRect(zone) {
37448
37472
  const sheetId = this.getters.getActiveSheetId();
37449
37473
  const viewportRects = this.getSubViewports(sheetId)
37450
- .map((viewport) => viewport.getRect(zone))
37474
+ .map((viewport) => viewport.getVisibleRect(zone))
37451
37475
  .filter(isDefined$1);
37452
37476
  if (viewportRects.length === 0) {
37453
37477
  return { x: 0, y: 0, width: 0, height: 0 };
37454
37478
  }
37455
- const x = Math.min(...viewportRects.map((rect) => rect.x));
37456
- const y = Math.min(...viewportRects.map((rect) => rect.y));
37457
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37458
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37459
- return {
37460
- x: x + this.gridOffsetX,
37461
- y: y + this.gridOffsetY,
37462
- width,
37463
- height,
37464
- };
37479
+ return this.recomposeRect(viewportRects);
37480
+ }
37481
+ /**
37482
+ * Computes the actual size and position (:Rect) of the zone on the canvas
37483
+ * regardless of the viewport dimensions.
37484
+ */
37485
+ getRect(zone) {
37486
+ const sheetId = this.getters.getActiveSheetId();
37487
+ const viewportRects = this.getSubViewports(sheetId)
37488
+ .map((viewport) => viewport.getFullRect(zone))
37489
+ .filter(isDefined$1);
37490
+ if (viewportRects.length === 0) {
37491
+ return { x: 0, y: 0, width: 0, height: 0 };
37492
+ }
37493
+ return this.recomposeRect(viewportRects);
37465
37494
  }
37466
37495
  /**
37467
37496
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -37475,6 +37504,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37475
37504
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
37476
37505
  return { x, y };
37477
37506
  }
37507
+ getAllActiveViewportsZones() {
37508
+ const sheetId = this.getters.getActiveSheetId();
37509
+ return this.getSubViewports(sheetId);
37510
+ }
37478
37511
  // ---------------------------------------------------------------------------
37479
37512
  // Private
37480
37513
  // ---------------------------------------------------------------------------
@@ -37657,6 +37690,18 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37657
37690
  const height = this.sheetViewHeight + this.gridOffsetY;
37658
37691
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
37659
37692
  }
37693
+ recomposeRect(viewportRects) {
37694
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
37695
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
37696
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
37697
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
37698
+ return {
37699
+ x: x + this.gridOffsetX,
37700
+ y: y + this.gridOffsetY,
37701
+ width,
37702
+ height,
37703
+ };
37704
+ }
37660
37705
  }
37661
37706
  SheetViewPlugin.getters = [
37662
37707
  "getColIndex",
@@ -37677,6 +37722,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37677
37722
  "getSheetViewVisibleCols",
37678
37723
  "getSheetViewVisibleRows",
37679
37724
  "getFrozenSheetViewRatio",
37725
+ "getAllActiveViewportsZones",
37726
+ "getRect",
37680
37727
  ];
37681
37728
 
37682
37729
  class SortPlugin extends UIPlugin {
@@ -43522,9 +43569,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43522
43569
  Object.defineProperty(exports, '__esModule', { value: true });
43523
43570
 
43524
43571
 
43525
- __info__.version = '16.0.57';
43526
- __info__.date = '2025-01-14T11:28:51.212Z';
43527
- __info__.hash = '5c7bf6e';
43572
+ __info__.version = '16.0.58';
43573
+ __info__.date = '2025-01-27T10:00:05.196Z';
43574
+ __info__.hash = '4886b0b';
43528
43575
 
43529
43576
 
43530
43577
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);