@odoo/o-spreadsheet 17.4.25 → 17.4.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.4.25
6
- * @date 2025-03-07T10:33:20.607Z
7
- * @hash 765f110
5
+ * @version 17.4.27
6
+ * @date 2025-03-19T08:27:27.414Z
7
+ * @hash a87c1da
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -5198,11 +5198,13 @@
5198
5198
  if (!cell || (!cell.isFormula && !cell.content)) {
5199
5199
  return DEFAULT_CELL_HEIGHT;
5200
5200
  }
5201
- const maxWidth = cell.style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5202
- const numberOfLines = cell.isFormula
5203
- ? 1
5204
- : splitTextToWidth(ctx, cell.content, cell.style, maxWidth).length;
5205
- const fontSize = computeTextFontSizeInPixels(cell.style);
5201
+ const content = cell.isFormula ? "" : cell.content;
5202
+ return getCellContentHeight(ctx, content, cell.style, colSize);
5203
+ }
5204
+ function getCellContentHeight(ctx, content, style, colSize) {
5205
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5206
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
5207
+ const fontSize = computeTextFontSizeInPixels(style);
5206
5208
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
5207
5209
  }
5208
5210
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -6788,13 +6790,6 @@
6788
6790
  this.clearClippedZones(content);
6789
6791
  const selection = target[0];
6790
6792
  this.pasteZone(sheetId, selection.left, selection.top, content.cells, options);
6791
- this.dispatch("MOVE_RANGES", {
6792
- target: content.zones,
6793
- sheetId: content.sheetId,
6794
- targetSheetId: sheetId,
6795
- col: selection.left,
6796
- row: selection.top,
6797
- });
6798
6793
  }
6799
6794
  /**
6800
6795
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -7255,14 +7250,15 @@
7255
7250
  }
7256
7251
  merges.push(mergesInRow);
7257
7252
  }
7258
- return { merges };
7253
+ return { merges, sheetId };
7259
7254
  }
7260
7255
  /**
7261
7256
  * Paste the clipboard content in the given target
7262
7257
  */
7263
7258
  paste(target, content, options) {
7264
7259
  if (options.isCutOperation) {
7265
- return;
7260
+ const copiedMerges = content.merges.flat().filter(isDefined);
7261
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
7266
7262
  }
7267
7263
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
7268
7264
  }
@@ -7297,6 +7293,27 @@
7297
7293
  }
7298
7294
  }
7299
7295
 
7296
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
7297
+ copy(data) {
7298
+ return {
7299
+ zones: data.clippedZones,
7300
+ sheetId: data.sheetId,
7301
+ };
7302
+ }
7303
+ paste(target, content, options) {
7304
+ if (options.isCutOperation) {
7305
+ const selection = target.zones[0];
7306
+ this.dispatch("MOVE_RANGES", {
7307
+ target: content.zones,
7308
+ sheetId: content.sheetId,
7309
+ targetSheetId: target.sheetId,
7310
+ col: selection.left,
7311
+ row: selection.top,
7312
+ });
7313
+ }
7314
+ }
7315
+ }
7316
+
7300
7317
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
7301
7318
  isPasteAllowed(sheetId, target, content, options) {
7302
7319
  if (!("cells" in content)) {
@@ -7464,7 +7481,8 @@
7464
7481
  .add("merge", MergeClipboardHandler)
7465
7482
  .add("border", BorderClipboardHandler)
7466
7483
  .add("table", TableClipboardHandler)
7467
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
7484
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
7485
+ .add("references", ReferenceClipboardHandler);
7468
7486
 
7469
7487
  function transformZone(zone, executed) {
7470
7488
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -9621,8 +9639,8 @@ stores.inject(MyMetaStore, storeInstance);
9621
9639
  this.colorIndexByRange = {};
9622
9640
  }
9623
9641
  cancelEdition() {
9624
- this.cancelEditionAndActivateSheet();
9625
9642
  this.resetContent();
9643
+ this.cancelEditionAndActivateSheet();
9626
9644
  this.colorIndexByRange = {};
9627
9645
  }
9628
9646
  setCurrentContent(content, selection) {
@@ -9639,8 +9657,8 @@ stores.inject(MyMetaStore, storeInstance);
9639
9657
  switch (cmd.type) {
9640
9658
  case "SELECT_FIGURE":
9641
9659
  if (cmd.id) {
9642
- this.cancelEditionAndActivateSheet();
9643
9660
  this.resetContent();
9661
+ this.cancelEditionAndActivateSheet();
9644
9662
  }
9645
9663
  break;
9646
9664
  case "SET_FORMATTING":
@@ -9690,8 +9708,8 @@ stores.inject(MyMetaStore, storeInstance);
9690
9708
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
9691
9709
  if (!sheetIdExists && this.editionMode !== "inactive") {
9692
9710
  this.sheetId = this.getters.getActiveSheetId();
9693
- this.cancelEditionAndActivateSheet();
9694
9711
  this.resetContent();
9712
+ this.cancelEditionAndActivateSheet();
9695
9713
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
9696
9714
  }
9697
9715
  break;
@@ -10186,6 +10204,15 @@ stores.inject(MyMetaStore, storeInstance);
10186
10204
  const exactMatch = proposals?.find((p) => p.text === tokenAtCursor.value);
10187
10205
  // remove tokens that are likely to be other parts of the formula that slipped in the token if it's a string
10188
10206
  const searchTerm = tokenAtCursor.value.replace(/[ ,\(\)]/g, "");
10207
+ if (this._currentContent === this.initialContent &&
10208
+ provider.displayAllOnInitialContent &&
10209
+ proposals?.length) {
10210
+ return {
10211
+ proposals,
10212
+ selectProposal: provider.selectProposal,
10213
+ autoSelectFirstProposal: provider.autoSelectFirstProposal ?? false,
10214
+ };
10215
+ }
10189
10216
  if (exactMatch && this._currentContent !== this.initialContent) {
10190
10217
  // this means the user has chosen a proposal
10191
10218
  return;
@@ -12226,6 +12253,7 @@ stores.inject(MyMetaStore, storeInstance);
12226
12253
  }
12227
12254
 
12228
12255
  autoCompleteProviders.add("dataValidation", {
12256
+ displayAllOnInitialContent: true,
12229
12257
  getProposals(tokenAtCursor, content) {
12230
12258
  if (content.startsWith("=")) {
12231
12259
  return [];
@@ -37665,6 +37693,7 @@ stores.inject(MyMetaStore, storeInstance);
37665
37693
  columns: {},
37666
37694
  });
37667
37695
  setup() {
37696
+ this.updateColumns();
37668
37697
  owl.onWillUpdateProps(() => this.updateColumns());
37669
37698
  }
37670
37699
  toggleHasHeader() {
@@ -45813,7 +45842,7 @@ stores.inject(MyMetaStore, storeInstance);
45813
45842
  title: { text: chartTitle },
45814
45843
  type: CHART_TYPE_CONVERSION_MAP[chartType],
45815
45844
  dataSets: this.extractChartDatasets(this.querySelectorAll(rootChartElement, `c:${chartType}`), chartType),
45816
- labelRange: this.extractChildTextContent(rootChartElement, `c:ser ${chartType === "scatterChart" ? "c:numRef" : "c:cat"} c:f`),
45845
+ labelRange: this.extractLabelRange(chartType, rootChartElement),
45817
45846
  backgroundColor: this.extractChildAttr(rootChartElement, "c:chartSpace > c:spPr a:srgbClr", "val", {
45818
45847
  default: "ffffff",
45819
45848
  }).asString(),
@@ -45825,6 +45854,13 @@ stores.inject(MyMetaStore, storeInstance);
45825
45854
  };
45826
45855
  })[0];
45827
45856
  }
45857
+ extractLabelRange(chartType, rootChartElement) {
45858
+ if (chartType === "scatterChart") {
45859
+ return (this.extractChildTextContent(rootChartElement, `c:ser c:strRef c:f`) ||
45860
+ this.extractChildTextContent(rootChartElement, `c:ser c:numRef c:f`));
45861
+ }
45862
+ return this.extractChildTextContent(rootChartElement, `c:ser c:cat c:f`);
45863
+ }
45828
45864
  extractComboChart(chartElement) {
45829
45865
  // Title can be separated into multiple xml elements (for styling and such), we only import the text
45830
45866
  const chartTitle = this.mapOnElements({ parent: chartElement, query: "c:title a:t" }, (textElement) => {
@@ -58745,12 +58781,7 @@ stores.inject(MyMetaStore, storeInstance);
58745
58781
  }
58746
58782
  break;
58747
58783
  case "AUTORESIZE_ROWS":
58748
- this.dispatch("RESIZE_COLUMNS_ROWS", {
58749
- elements: cmd.rows,
58750
- dimension: "ROW",
58751
- size: null,
58752
- sheetId: cmd.sheetId,
58753
- });
58784
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
58754
58785
  break;
58755
58786
  }
58756
58787
  }
@@ -58900,6 +58931,48 @@ stores.inject(MyMetaStore, storeInstance);
58900
58931
  }
58901
58932
  return "Success" /* CommandResult.Success */;
58902
58933
  }
58934
+ autoResizeRows(sheetId, rows) {
58935
+ const rowSizes = [];
58936
+ for (const row of rows) {
58937
+ let evaluatedRowSize = 0;
58938
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
58939
+ const cell = this.getters.getCellById(cellId);
58940
+ if (!cell) {
58941
+ continue;
58942
+ }
58943
+ const position = this.getters.getCellPosition(cell.id);
58944
+ const colSize = this.getters.getColSize(sheetId, position.col);
58945
+ if (cell.isFormula) {
58946
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
58947
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58948
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
58949
+ evaluatedRowSize = evaluatedSize;
58950
+ }
58951
+ }
58952
+ else {
58953
+ const content = cell.content;
58954
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58955
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
58956
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
58957
+ evaluatedRowSize = 0;
58958
+ }
58959
+ }
58960
+ }
58961
+ rowSizes.push(evaluatedRowSize || null);
58962
+ }
58963
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
58964
+ for (let i = 0; i < rowSizes.length; i++) {
58965
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
58966
+ }
58967
+ for (const [size, rows] of groupedSizes) {
58968
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
58969
+ elements: rows,
58970
+ dimension: "ROW",
58971
+ size,
58972
+ sheetId,
58973
+ });
58974
+ }
58975
+ }
58903
58976
  }
58904
58977
 
58905
58978
  class TableComputedStylePlugin extends UIPlugin {
@@ -67715,7 +67788,7 @@ stores.inject(MyMetaStore, storeInstance);
67715
67788
  }
67716
67789
  if (alignAttrs.length > 0) {
67717
67790
  attributes.push(["applyAlignment", "1"]); // for Libre Office
67718
- styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)}>${escapeXml /*xml*/ `<alignment ${formatAttributes(alignAttrs)} />`}</xf> `);
67791
+ styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)}><alignment ${formatAttributes(alignAttrs)} /></xf> `);
67719
67792
  }
67720
67793
  else {
67721
67794
  styleNodes.push(escapeXml /*xml*/ `<xf ${formatAttributes(attributes)} />`);
@@ -69155,9 +69228,9 @@ stores.inject(MyMetaStore, storeInstance);
69155
69228
  exports.tokenize = tokenize;
69156
69229
 
69157
69230
 
69158
- __info__.version = "17.4.25";
69159
- __info__.date = "2025-03-07T10:33:20.607Z";
69160
- __info__.hash = "765f110";
69231
+ __info__.version = "17.4.27";
69232
+ __info__.date = "2025-03-19T08:27:27.414Z";
69233
+ __info__.hash = "a87c1da";
69161
69234
 
69162
69235
 
69163
69236
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);