@odoo/o-spreadsheet 17.0.45 → 17.0.47

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.0.45
6
- * @date 2025-01-14T11:30:44.730Z
7
- * @hash 94f8ef9
5
+ * @version 17.0.47
6
+ * @date 2025-01-31T07:56:50.980Z
7
+ * @hash a22bce2
8
8
  */
9
9
 
10
10
  import { Component, useRef, onMounted, useEffect, onWillPatch, useState, onWillUpdateProps, onPatched, useComponent, useExternalListener, onWillUnmount, onWillStart, xml, useChildSubEnv, useSubEnv, markRaw } from '@odoo/owl';
@@ -1845,11 +1845,11 @@ const getInvaluableSymbolsRegexp = memoize(function getInvaluableSymbolsRegexp(l
1845
1845
  * number from the point of view of the isNumber function.
1846
1846
  */
1847
1847
  function parseNumber(str, locale) {
1848
+ // remove invaluable characters
1849
+ str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1848
1850
  if (locale.decimalSeparator !== ".") {
1849
1851
  str = str.replace(locale.decimalSeparator, ".");
1850
1852
  }
1851
- // remove invaluable characters
1852
- str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1853
1853
  let n = Number(str);
1854
1854
  if (isNaN(n) && str.includes("%")) {
1855
1855
  n = Number(str.split("%")[0]);
@@ -2695,15 +2695,18 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2695
2695
  let currentIndex;
2696
2696
  let currentVal;
2697
2697
  let currentType;
2698
+ const getValue = sortOrder === "desc"
2699
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2700
+ : (i) => normalizeValue(getValueInData(data, i));
2698
2701
  while (indexRight - indexLeft >= 0) {
2699
2702
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2700
2703
  currentIndex = indexMedian;
2701
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2704
+ currentVal = getValue(currentIndex);
2702
2705
  currentType = typeof currentVal;
2703
2706
  // 1 - linear search to find value with the same type
2704
2707
  while (indexLeft < currentIndex && targetType !== currentType) {
2705
2708
  currentIndex--;
2706
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2709
+ currentVal = getValue(currentIndex);
2707
2710
  currentType = typeof currentVal;
2708
2711
  }
2709
2712
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2719,8 +2722,7 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2719
2722
  if (matchVal === undefined ||
2720
2723
  matchVal === null ||
2721
2724
  matchVal < currentVal ||
2722
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2723
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2725
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2724
2726
  matchVal = currentVal;
2725
2727
  matchValIndex = currentIndex;
2726
2728
  }
@@ -2728,15 +2730,13 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2728
2730
  else if (mode === "nextGreater" && currentVal >= _target) {
2729
2731
  if (matchVal === undefined ||
2730
2732
  matchVal > currentVal ||
2731
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2732
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2733
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2733
2734
  matchVal = currentVal;
2734
2735
  matchValIndex = currentIndex;
2735
2736
  }
2736
2737
  }
2737
2738
  // 3 - give new indexes for the Binary search
2738
- if ((sortOrder === "asc" && currentVal > _target) ||
2739
- (sortOrder === "desc" && currentVal <= _target)) {
2739
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2740
2740
  indexRight = currentIndex - 1;
2741
2741
  }
2742
2742
  else {
@@ -2744,7 +2744,10 @@ function dichotomicSearch(data, target, mode, sortOrder, rangeLength, getValueIn
2744
2744
  }
2745
2745
  }
2746
2746
  // note that valMinIndex could be 0
2747
- return matchValIndex !== undefined ? matchValIndex : -1;
2747
+ if (matchValIndex === undefined) {
2748
+ return -1;
2749
+ }
2750
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2748
2751
  }
2749
2752
  /**
2750
2753
  * Perform a linear search and return the index of the match.
@@ -6938,6 +6941,10 @@ class Popover extends Component {
6938
6941
  this.currentDisplayValue = newDisplay;
6939
6942
  if (!anchor)
6940
6943
  return;
6944
+ el.style.top = "";
6945
+ el.style.left = "";
6946
+ el.style["max-height"] = "";
6947
+ el.style["max-width"] = "";
6941
6948
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6942
6949
  let elDims = {
6943
6950
  width: el.getBoundingClientRect().width,
@@ -27452,7 +27459,7 @@ class GridComposer extends Component {
27452
27459
  return;
27453
27460
  }
27454
27461
  const sheetId = this.env.model.getters.getActiveSheetId();
27455
- const zone = this.env.model.getters.getSelectedZone();
27462
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
27456
27463
  const rect = this.env.model.getters.getVisibleRect(zone);
27457
27464
  if (!deepEquals(rect, this.rect) ||
27458
27465
  sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
@@ -46259,13 +46266,23 @@ class RendererPlugin extends UIPlugin {
46259
46266
  drawGrid(renderingContext, layer) {
46260
46267
  switch (layer) {
46261
46268
  case 0 /* LAYERS.Background */:
46262
- this.boxes = this.getGridBoxes();
46263
- this.drawBackground(renderingContext);
46264
- this.drawOverflowingCellBackground(renderingContext);
46265
- this.drawCellBackground(renderingContext);
46266
- this.drawBorders(renderingContext);
46267
- this.drawTexts(renderingContext);
46268
- this.drawIcon(renderingContext);
46269
+ this.drawGlobalBackground(renderingContext);
46270
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
46271
+ const { ctx } = renderingContext;
46272
+ ctx.save();
46273
+ ctx.beginPath();
46274
+ const rect = this.getters.getVisibleRect(zone);
46275
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
46276
+ ctx.clip();
46277
+ this.boxes = this.getGridBoxes(zone);
46278
+ this.drawBackground(renderingContext);
46279
+ this.drawOverflowingCellBackground(renderingContext);
46280
+ this.drawCellBackground(renderingContext);
46281
+ this.drawBorders(renderingContext);
46282
+ this.drawTexts(renderingContext);
46283
+ this.drawIcon(renderingContext);
46284
+ ctx.restore();
46285
+ }
46269
46286
  this.drawFrozenPanes(renderingContext);
46270
46287
  break;
46271
46288
  case 7 /* LAYERS.Headers */:
@@ -46276,12 +46293,15 @@ class RendererPlugin extends UIPlugin {
46276
46293
  break;
46277
46294
  }
46278
46295
  }
46279
- drawBackground(renderingContext) {
46280
- const { ctx, thinLineWidth } = renderingContext;
46296
+ drawGlobalBackground(renderingContext) {
46297
+ const { ctx } = renderingContext;
46281
46298
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
46282
46299
  // white background
46283
46300
  ctx.fillStyle = "#ffffff";
46284
46301
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
46302
+ }
46303
+ drawBackground(renderingContext) {
46304
+ const { ctx, thinLineWidth } = renderingContext;
46285
46305
  const areGridLinesVisible = !this.getters.isDashboard() &&
46286
46306
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
46287
46307
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -46712,7 +46732,7 @@ class RendererPlugin extends UIPlugin {
46712
46732
  const position = { sheetId, col, row };
46713
46733
  const cell = this.getters.getEvaluatedCell(position);
46714
46734
  const showFormula = this.getters.shouldShowFormulas();
46715
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
46735
+ const { x, y, width, height } = this.getters.getRect(zone);
46716
46736
  const { verticalAlign } = this.getters.getCellStyle(position);
46717
46737
  const box = {
46718
46738
  x,
@@ -46827,12 +46847,16 @@ class RendererPlugin extends UIPlugin {
46827
46847
  }
46828
46848
  return box;
46829
46849
  }
46830
- getGridBoxes() {
46850
+ getGridBoxes(zone) {
46831
46851
  const boxes = [];
46832
- const visibleCols = this.getters.getSheetViewVisibleCols();
46852
+ const visibleCols = this.getters
46853
+ .getSheetViewVisibleCols()
46854
+ .filter((col) => col >= zone.left && col <= zone.right);
46833
46855
  const left = visibleCols[0];
46834
46856
  const right = visibleCols[visibleCols.length - 1];
46835
- const visibleRows = this.getters.getSheetViewVisibleRows();
46857
+ const visibleRows = this.getters
46858
+ .getSheetViewVisibleRows()
46859
+ .filter((row) => row >= zone.top && row <= zone.bottom);
46836
46860
  const top = visibleRows[0];
46837
46861
  const bottom = visibleRows[visibleRows.length - 1];
46838
46862
  const viewport = { left, right, top, bottom };
@@ -47625,14 +47649,12 @@ class SheetUIPlugin extends UIPlugin {
47625
47649
  }
47626
47650
  break;
47627
47651
  case "AUTORESIZE_ROWS":
47628
- for (let row of cmd.rows) {
47629
- this.dispatch("RESIZE_COLUMNS_ROWS", {
47630
- elements: [row],
47631
- dimension: "ROW",
47632
- size: null,
47633
- sheetId: cmd.sheetId,
47634
- });
47635
- }
47652
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
47653
+ elements: cmd.rows,
47654
+ dimension: "ROW",
47655
+ size: null,
47656
+ sheetId: cmd.sheetId,
47657
+ });
47636
47658
  break;
47637
47659
  }
47638
47660
  }
@@ -50359,7 +50381,7 @@ class GridSelectionPlugin extends UIPlugin {
50359
50381
  ];
50360
50382
  state.paste(pasteTarget, { selectTarget: true });
50361
50383
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50362
- let currentIndex = cmd.base;
50384
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50363
50385
  for (const element of toRemove) {
50364
50386
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50365
50387
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -50650,7 +50672,7 @@ class InternalViewport {
50650
50672
  * @param zone
50651
50673
  * @returns Computes the absolute coordinate of a given zone inside the viewport
50652
50674
  */
50653
- getRect(zone) {
50675
+ getVisibleRect(zone) {
50654
50676
  const targetZone = intersection(zone, this.zone);
50655
50677
  if (targetZone) {
50656
50678
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -50658,12 +50680,20 @@ class InternalViewport {
50658
50680
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
50659
50681
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
50660
50682
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
50661
- return {
50662
- x,
50663
- y,
50664
- width,
50665
- height,
50666
- };
50683
+ return { x, y, width, height };
50684
+ }
50685
+ else {
50686
+ return undefined;
50687
+ }
50688
+ }
50689
+ getFullRect(zone) {
50690
+ const targetZone = intersection(zone, this.zone);
50691
+ if (targetZone) {
50692
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
50693
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
50694
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
50695
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
50696
+ return { x, y, width, height };
50667
50697
  }
50668
50698
  else {
50669
50699
  return undefined;
@@ -50847,6 +50877,8 @@ class SheetViewPlugin extends UIPlugin {
50847
50877
  "getSheetViewVisibleRows",
50848
50878
  "getFrozenSheetViewRatio",
50849
50879
  "isPositionVisible",
50880
+ "getAllActiveViewportsZones",
50881
+ "getRect",
50850
50882
  ];
50851
50883
  viewports = {};
50852
50884
  /**
@@ -51234,16 +51266,27 @@ class SheetViewPlugin extends UIPlugin {
51234
51266
  getVisibleRectWithoutHeaders(zone) {
51235
51267
  const sheetId = this.getters.getActiveSheetId();
51236
51268
  const viewportRects = this.getSubViewports(sheetId)
51237
- .map((viewport) => viewport.getRect(zone))
51269
+ .map((viewport) => viewport.getVisibleRect(zone))
51238
51270
  .filter(isDefined$1);
51239
51271
  if (viewportRects.length === 0) {
51240
51272
  return { x: 0, y: 0, width: 0, height: 0 };
51241
51273
  }
51242
- const x = Math.min(...viewportRects.map((rect) => rect.x));
51243
- const y = Math.min(...viewportRects.map((rect) => rect.y));
51244
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51245
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51246
- return { x, y, width, height };
51274
+ return this.recomposeRect(viewportRects);
51275
+ }
51276
+ /**
51277
+ * Computes the actual size and position (:Rect) of the zone on the canvas
51278
+ * regardless of the viewport dimensions.
51279
+ */
51280
+ getRect(zone) {
51281
+ const sheetId = this.getters.getActiveSheetId();
51282
+ const viewportRects = this.getSubViewports(sheetId)
51283
+ .map((viewport) => viewport.getFullRect(zone))
51284
+ .filter(isDefined$1);
51285
+ if (viewportRects.length === 0) {
51286
+ return { x: 0, y: 0, width: 0, height: 0 };
51287
+ }
51288
+ const rect = this.recomposeRect(viewportRects);
51289
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
51247
51290
  }
51248
51291
  /**
51249
51292
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -51257,6 +51300,10 @@ class SheetViewPlugin extends UIPlugin {
51257
51300
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
51258
51301
  return { x, y };
51259
51302
  }
51303
+ getAllActiveViewportsZones() {
51304
+ const sheetId = this.getters.getActiveSheetId();
51305
+ return this.getSubViewports(sheetId);
51306
+ }
51260
51307
  // ---------------------------------------------------------------------------
51261
51308
  // Private
51262
51309
  // ---------------------------------------------------------------------------
@@ -51441,6 +51488,13 @@ class SheetViewPlugin extends UIPlugin {
51441
51488
  const height = this.sheetViewHeight + this.gridOffsetY;
51442
51489
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
51443
51490
  }
51491
+ recomposeRect(viewportRects) {
51492
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
51493
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
51494
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51495
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51496
+ return { x, y, width, height };
51497
+ }
51444
51498
  }
51445
51499
 
51446
51500
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -57713,6 +57767,6 @@ const constants = {
57713
57767
  export { AbstractChart, 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 };
57714
57768
 
57715
57769
 
57716
- __info__.version = "17.0.45";
57717
- __info__.date = "2025-01-14T11:30:44.730Z";
57718
- __info__.hash = "94f8ef9";
57770
+ __info__.version = "17.0.47";
57771
+ __info__.date = "2025-01-31T07:56:50.980Z";
57772
+ __info__.hash = "a22bce2";
@@ -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.0.45
6
- * @date 2025-01-14T11:30:44.730Z
7
- * @hash 94f8ef9
5
+ * @version 17.0.47
6
+ * @date 2025-01-31T07:56:50.980Z
7
+ * @hash a22bce2
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1846,11 +1846,11 @@
1846
1846
  * number from the point of view of the isNumber function.
1847
1847
  */
1848
1848
  function parseNumber(str, locale) {
1849
+ // remove invaluable characters
1850
+ str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1849
1851
  if (locale.decimalSeparator !== ".") {
1850
1852
  str = str.replace(locale.decimalSeparator, ".");
1851
1853
  }
1852
- // remove invaluable characters
1853
- str = str.replace(getInvaluableSymbolsRegexp(locale), "");
1854
1854
  let n = Number(str);
1855
1855
  if (isNaN(n) && str.includes("%")) {
1856
1856
  n = Number(str.split("%")[0]);
@@ -2696,15 +2696,18 @@
2696
2696
  let currentIndex;
2697
2697
  let currentVal;
2698
2698
  let currentType;
2699
+ const getValue = sortOrder === "desc"
2700
+ ? (i) => normalizeValue(getValueInData(data, rangeLength - i - 1))
2701
+ : (i) => normalizeValue(getValueInData(data, i));
2699
2702
  while (indexRight - indexLeft >= 0) {
2700
2703
  indexMedian = Math.floor((indexLeft + indexRight) / 2);
2701
2704
  currentIndex = indexMedian;
2702
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2705
+ currentVal = getValue(currentIndex);
2703
2706
  currentType = typeof currentVal;
2704
2707
  // 1 - linear search to find value with the same type
2705
2708
  while (indexLeft < currentIndex && targetType !== currentType) {
2706
2709
  currentIndex--;
2707
- currentVal = normalizeValue(getValueInData(data, currentIndex));
2710
+ currentVal = getValue(currentIndex);
2708
2711
  currentType = typeof currentVal;
2709
2712
  }
2710
2713
  if (currentType !== targetType || currentVal === undefined || currentVal === null) {
@@ -2720,8 +2723,7 @@
2720
2723
  if (matchVal === undefined ||
2721
2724
  matchVal === null ||
2722
2725
  matchVal < currentVal ||
2723
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2724
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2726
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2725
2727
  matchVal = currentVal;
2726
2728
  matchValIndex = currentIndex;
2727
2729
  }
@@ -2729,15 +2731,13 @@
2729
2731
  else if (mode === "nextGreater" && currentVal >= _target) {
2730
2732
  if (matchVal === undefined ||
2731
2733
  matchVal > currentVal ||
2732
- (matchVal === currentVal && sortOrder === "asc" && matchValIndex < currentIndex) ||
2733
- (matchVal === currentVal && sortOrder === "desc" && matchValIndex > currentIndex)) {
2734
+ (matchVal === currentVal && matchValIndex < currentIndex)) {
2734
2735
  matchVal = currentVal;
2735
2736
  matchValIndex = currentIndex;
2736
2737
  }
2737
2738
  }
2738
2739
  // 3 - give new indexes for the Binary search
2739
- if ((sortOrder === "asc" && currentVal > _target) ||
2740
- (sortOrder === "desc" && currentVal <= _target)) {
2740
+ if (currentVal > _target || (mode === "strict" && currentVal === _target)) {
2741
2741
  indexRight = currentIndex - 1;
2742
2742
  }
2743
2743
  else {
@@ -2745,7 +2745,10 @@
2745
2745
  }
2746
2746
  }
2747
2747
  // note that valMinIndex could be 0
2748
- return matchValIndex !== undefined ? matchValIndex : -1;
2748
+ if (matchValIndex === undefined) {
2749
+ return -1;
2750
+ }
2751
+ return sortOrder === "desc" ? rangeLength - matchValIndex - 1 : matchValIndex;
2749
2752
  }
2750
2753
  /**
2751
2754
  * Perform a linear search and return the index of the match.
@@ -6939,6 +6942,10 @@
6939
6942
  this.currentDisplayValue = newDisplay;
6940
6943
  if (!anchor)
6941
6944
  return;
6945
+ el.style.top = "";
6946
+ el.style.left = "";
6947
+ el.style["max-height"] = "";
6948
+ el.style["max-width"] = "";
6942
6949
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
6943
6950
  let elDims = {
6944
6951
  width: el.getBoundingClientRect().width,
@@ -27453,7 +27460,7 @@
27453
27460
  return;
27454
27461
  }
27455
27462
  const sheetId = this.env.model.getters.getActiveSheetId();
27456
- const zone = this.env.model.getters.getSelectedZone();
27463
+ const zone = positionToZone(this.env.model.getters.getSelection().anchor.cell);
27457
27464
  const rect = this.env.model.getters.getVisibleRect(zone);
27458
27465
  if (!deepEquals(rect, this.rect) ||
27459
27466
  sheetId !== this.env.model.getters.getCurrentEditedCell().sheetId) {
@@ -46260,13 +46267,23 @@
46260
46267
  drawGrid(renderingContext, layer) {
46261
46268
  switch (layer) {
46262
46269
  case 0 /* LAYERS.Background */:
46263
- this.boxes = this.getGridBoxes();
46264
- this.drawBackground(renderingContext);
46265
- this.drawOverflowingCellBackground(renderingContext);
46266
- this.drawCellBackground(renderingContext);
46267
- this.drawBorders(renderingContext);
46268
- this.drawTexts(renderingContext);
46269
- this.drawIcon(renderingContext);
46270
+ this.drawGlobalBackground(renderingContext);
46271
+ for (const zone of this.getters.getAllActiveViewportsZones()) {
46272
+ const { ctx } = renderingContext;
46273
+ ctx.save();
46274
+ ctx.beginPath();
46275
+ const rect = this.getters.getVisibleRect(zone);
46276
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
46277
+ ctx.clip();
46278
+ this.boxes = this.getGridBoxes(zone);
46279
+ this.drawBackground(renderingContext);
46280
+ this.drawOverflowingCellBackground(renderingContext);
46281
+ this.drawCellBackground(renderingContext);
46282
+ this.drawBorders(renderingContext);
46283
+ this.drawTexts(renderingContext);
46284
+ this.drawIcon(renderingContext);
46285
+ ctx.restore();
46286
+ }
46270
46287
  this.drawFrozenPanes(renderingContext);
46271
46288
  break;
46272
46289
  case 7 /* LAYERS.Headers */:
@@ -46277,12 +46294,15 @@
46277
46294
  break;
46278
46295
  }
46279
46296
  }
46280
- drawBackground(renderingContext) {
46281
- const { ctx, thinLineWidth } = renderingContext;
46297
+ drawGlobalBackground(renderingContext) {
46298
+ const { ctx } = renderingContext;
46282
46299
  const { width, height } = this.getters.getSheetViewDimensionWithHeaders();
46283
46300
  // white background
46284
46301
  ctx.fillStyle = "#ffffff";
46285
46302
  ctx.fillRect(0, 0, width + CANVAS_SHIFT, height + CANVAS_SHIFT);
46303
+ }
46304
+ drawBackground(renderingContext) {
46305
+ const { ctx, thinLineWidth } = renderingContext;
46286
46306
  const areGridLinesVisible = !this.getters.isDashboard() &&
46287
46307
  this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());
46288
46308
  const inset = areGridLinesVisible ? 0.1 * thinLineWidth : 0;
@@ -46713,7 +46733,7 @@
46713
46733
  const position = { sheetId, col, row };
46714
46734
  const cell = this.getters.getEvaluatedCell(position);
46715
46735
  const showFormula = this.getters.shouldShowFormulas();
46716
- const { x, y, width, height } = this.getters.getVisibleRect(zone);
46736
+ const { x, y, width, height } = this.getters.getRect(zone);
46717
46737
  const { verticalAlign } = this.getters.getCellStyle(position);
46718
46738
  const box = {
46719
46739
  x,
@@ -46828,12 +46848,16 @@
46828
46848
  }
46829
46849
  return box;
46830
46850
  }
46831
- getGridBoxes() {
46851
+ getGridBoxes(zone) {
46832
46852
  const boxes = [];
46833
- const visibleCols = this.getters.getSheetViewVisibleCols();
46853
+ const visibleCols = this.getters
46854
+ .getSheetViewVisibleCols()
46855
+ .filter((col) => col >= zone.left && col <= zone.right);
46834
46856
  const left = visibleCols[0];
46835
46857
  const right = visibleCols[visibleCols.length - 1];
46836
- const visibleRows = this.getters.getSheetViewVisibleRows();
46858
+ const visibleRows = this.getters
46859
+ .getSheetViewVisibleRows()
46860
+ .filter((row) => row >= zone.top && row <= zone.bottom);
46837
46861
  const top = visibleRows[0];
46838
46862
  const bottom = visibleRows[visibleRows.length - 1];
46839
46863
  const viewport = { left, right, top, bottom };
@@ -47626,14 +47650,12 @@
47626
47650
  }
47627
47651
  break;
47628
47652
  case "AUTORESIZE_ROWS":
47629
- for (let row of cmd.rows) {
47630
- this.dispatch("RESIZE_COLUMNS_ROWS", {
47631
- elements: [row],
47632
- dimension: "ROW",
47633
- size: null,
47634
- sheetId: cmd.sheetId,
47635
- });
47636
- }
47653
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
47654
+ elements: cmd.rows,
47655
+ dimension: "ROW",
47656
+ size: null,
47657
+ sheetId: cmd.sheetId,
47658
+ });
47637
47659
  break;
47638
47660
  }
47639
47661
  }
@@ -50360,7 +50382,7 @@
50360
50382
  ];
50361
50383
  state.paste(pasteTarget, { selectTarget: true });
50362
50384
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
50363
- let currentIndex = cmd.base;
50385
+ let currentIndex = isBasedBefore ? cmd.base : cmd.base + 1;
50364
50386
  for (const element of toRemove) {
50365
50387
  const size = this.getters.getHeaderSize(cmd.sheetId, cmd.dimension, element);
50366
50388
  this.dispatch("RESIZE_COLUMNS_ROWS", {
@@ -50651,7 +50673,7 @@
50651
50673
  * @param zone
50652
50674
  * @returns Computes the absolute coordinate of a given zone inside the viewport
50653
50675
  */
50654
- getRect(zone) {
50676
+ getVisibleRect(zone) {
50655
50677
  const targetZone = intersection(zone, this.zone);
50656
50678
  if (targetZone) {
50657
50679
  const x = this.getters.getColRowOffset("COL", this.zone.left, targetZone.left) +
@@ -50659,12 +50681,20 @@
50659
50681
  const y = this.getters.getColRowOffset("ROW", this.zone.top, targetZone.top) + this.offsetCorrectionY;
50660
50682
  const width = Math.min(this.getters.getColRowOffset("COL", targetZone.left, targetZone.right + 1), this.viewportWidth);
50661
50683
  const height = Math.min(this.getters.getColRowOffset("ROW", targetZone.top, targetZone.bottom + 1), this.viewportHeight);
50662
- return {
50663
- x,
50664
- y,
50665
- width,
50666
- height,
50667
- };
50684
+ return { x, y, width, height };
50685
+ }
50686
+ else {
50687
+ return undefined;
50688
+ }
50689
+ }
50690
+ getFullRect(zone) {
50691
+ const targetZone = intersection(zone, this.zone);
50692
+ if (targetZone) {
50693
+ const x = this.getters.getColRowOffset("COL", this.zone.left, zone.left) + this.offsetCorrectionX;
50694
+ const y = this.getters.getColRowOffset("ROW", this.zone.top, zone.top) + this.offsetCorrectionY;
50695
+ const width = this.getters.getColRowOffset("COL", zone.left, zone.right + 1);
50696
+ const height = this.getters.getColRowOffset("ROW", zone.top, zone.bottom + 1);
50697
+ return { x, y, width, height };
50668
50698
  }
50669
50699
  else {
50670
50700
  return undefined;
@@ -50848,6 +50878,8 @@
50848
50878
  "getSheetViewVisibleRows",
50849
50879
  "getFrozenSheetViewRatio",
50850
50880
  "isPositionVisible",
50881
+ "getAllActiveViewportsZones",
50882
+ "getRect",
50851
50883
  ];
50852
50884
  viewports = {};
50853
50885
  /**
@@ -51235,16 +51267,27 @@
51235
51267
  getVisibleRectWithoutHeaders(zone) {
51236
51268
  const sheetId = this.getters.getActiveSheetId();
51237
51269
  const viewportRects = this.getSubViewports(sheetId)
51238
- .map((viewport) => viewport.getRect(zone))
51270
+ .map((viewport) => viewport.getVisibleRect(zone))
51239
51271
  .filter(isDefined$1);
51240
51272
  if (viewportRects.length === 0) {
51241
51273
  return { x: 0, y: 0, width: 0, height: 0 };
51242
51274
  }
51243
- const x = Math.min(...viewportRects.map((rect) => rect.x));
51244
- const y = Math.min(...viewportRects.map((rect) => rect.y));
51245
- const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51246
- const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51247
- return { x, y, width, height };
51275
+ return this.recomposeRect(viewportRects);
51276
+ }
51277
+ /**
51278
+ * Computes the actual size and position (:Rect) of the zone on the canvas
51279
+ * regardless of the viewport dimensions.
51280
+ */
51281
+ getRect(zone) {
51282
+ const sheetId = this.getters.getActiveSheetId();
51283
+ const viewportRects = this.getSubViewports(sheetId)
51284
+ .map((viewport) => viewport.getFullRect(zone))
51285
+ .filter(isDefined$1);
51286
+ if (viewportRects.length === 0) {
51287
+ return { x: 0, y: 0, width: 0, height: 0 };
51288
+ }
51289
+ const rect = this.recomposeRect(viewportRects);
51290
+ return { ...rect, x: rect.x + this.gridOffsetX, y: rect.y + this.gridOffsetY };
51248
51291
  }
51249
51292
  /**
51250
51293
  * Returns the position of the MainViewport relatively to the start of the grid (without headers)
@@ -51258,6 +51301,10 @@
51258
51301
  const y = this.getters.getRowDimensions(sheetId, ySplit).start;
51259
51302
  return { x, y };
51260
51303
  }
51304
+ getAllActiveViewportsZones() {
51305
+ const sheetId = this.getters.getActiveSheetId();
51306
+ return this.getSubViewports(sheetId);
51307
+ }
51261
51308
  // ---------------------------------------------------------------------------
51262
51309
  // Private
51263
51310
  // ---------------------------------------------------------------------------
@@ -51442,6 +51489,13 @@
51442
51489
  const height = this.sheetViewHeight + this.gridOffsetY;
51443
51490
  return { xRatio: offsetCorrectionX / width, yRatio: offsetCorrectionY / height };
51444
51491
  }
51492
+ recomposeRect(viewportRects) {
51493
+ const x = Math.min(...viewportRects.map((rect) => rect.x));
51494
+ const y = Math.min(...viewportRects.map((rect) => rect.y));
51495
+ const width = Math.max(...viewportRects.map((rect) => rect.x + rect.width)) - x;
51496
+ const height = Math.max(...viewportRects.map((rect) => rect.y + rect.height)) - y;
51497
+ return { x, y, width, height };
51498
+ }
51445
51499
  }
51446
51500
 
51447
51501
  class HeaderPositionsUIPlugin extends UIPlugin {
@@ -57749,9 +57803,9 @@
57749
57803
  exports.tokenize = tokenize;
57750
57804
 
57751
57805
 
57752
- __info__.version = "17.0.45";
57753
- __info__.date = "2025-01-14T11:30:44.730Z";
57754
- __info__.hash = "94f8ef9";
57806
+ __info__.version = "17.0.47";
57807
+ __info__.date = "2025-01-31T07:56:50.980Z";
57808
+ __info__.hash = "a22bce2";
57755
57809
 
57756
57810
 
57757
57811
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);