@odoo/o-spreadsheet 17.4.26 → 17.4.28

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.26
6
- * @date 2025-03-12T15:31:45.184Z
7
- * @hash a18429e
5
+ * @version 17.4.28
6
+ * @date 2025-03-26T12:48:33.387Z
7
+ * @hash a81a8f4
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1008,7 +1008,10 @@
1008
1008
  }
1009
1009
  else if (stringVals.length === 4) {
1010
1010
  const alpha = parseFloat(stringVals.pop() || "1");
1011
- alphaHex = Math.round((alpha || 1) * 255);
1011
+ if (isNaN(alpha)) {
1012
+ throw new Error("invalid alpha value");
1013
+ }
1014
+ alphaHex = Math.round(alpha * 255);
1012
1015
  }
1013
1016
  const vals = stringVals.map((val) => parseInt(val, 10));
1014
1017
  if (alphaHex !== 255) {
@@ -5198,11 +5201,13 @@
5198
5201
  if (!cell || (!cell.isFormula && !cell.content)) {
5199
5202
  return DEFAULT_CELL_HEIGHT;
5200
5203
  }
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);
5204
+ const content = cell.isFormula ? "" : cell.content;
5205
+ return getCellContentHeight(ctx, content, cell.style, colSize);
5206
+ }
5207
+ function getCellContentHeight(ctx, content, style, colSize) {
5208
+ const maxWidth = style?.wrapping === "wrap" ? colSize - 2 * MIN_CELL_TEXT_MARGIN : undefined;
5209
+ const numberOfLines = splitTextToWidth(ctx, content, style, maxWidth).length;
5210
+ const fontSize = computeTextFontSizeInPixels(style);
5206
5211
  return computeTextLinesHeight(fontSize, numberOfLines) + 2 * PADDING_AUTORESIZE_VERTICAL;
5207
5212
  }
5208
5213
  function getDefaultContextFont(fontSize, bold = false, italic = false) {
@@ -5962,7 +5967,7 @@
5962
5967
  */
5963
5968
  function canonicalizeNumberContent(content, locale) {
5964
5969
  return content.startsWith("=")
5965
- ? canonicalizeFormula$1(content, locale)
5970
+ ? canonicalizeFormula(content, locale)
5966
5971
  : canonicalizeNumberLiteral(content, locale);
5967
5972
  }
5968
5973
  /**
@@ -5977,7 +5982,7 @@
5977
5982
  */
5978
5983
  function canonicalizeContent(content, locale) {
5979
5984
  return content.startsWith("=")
5980
- ? canonicalizeFormula$1(content, locale)
5985
+ ? canonicalizeFormula(content, locale)
5981
5986
  : canonicalizeLiteral(content, locale);
5982
5987
  }
5983
5988
  /**
@@ -5993,15 +5998,21 @@
5993
5998
  ? localizeFormula(content, locale)
5994
5999
  : localizeLiteral(content, locale);
5995
6000
  }
6001
+ /** Change a number string to its canonical form (en_US locale) */
6002
+ function canonicalizeNumberValue(content, locale) {
6003
+ return content.startsWith("=")
6004
+ ? canonicalizeFormula(content, locale)
6005
+ : canonicalizeNumberLiteral(content, locale);
6006
+ }
5996
6007
  /** Change a formula to its canonical form (en_US locale) */
5997
- function canonicalizeFormula$1(formula, locale) {
5998
- return _localizeFormula$1(formula, locale, DEFAULT_LOCALE);
6008
+ function canonicalizeFormula(formula, locale) {
6009
+ return _localizeFormula(formula, locale, DEFAULT_LOCALE);
5999
6010
  }
6000
6011
  /** Change a formula from the canonical form to the given locale */
6001
6012
  function localizeFormula(formula, locale) {
6002
- return _localizeFormula$1(formula, DEFAULT_LOCALE, locale);
6013
+ return _localizeFormula(formula, DEFAULT_LOCALE, locale);
6003
6014
  }
6004
- function _localizeFormula$1(formula, fromLocale, toLocale) {
6015
+ function _localizeFormula(formula, fromLocale, toLocale) {
6005
6016
  if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6006
6017
  fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6007
6018
  return formula;
@@ -6156,37 +6167,6 @@
6156
6167
  return locale.dateFormat + " " + locale.timeFormat;
6157
6168
  }
6158
6169
 
6159
- /** Change a number string to its canonical form (en_US locale) */
6160
- function canonicalizeNumberValue(content, locale) {
6161
- return content.startsWith("=")
6162
- ? canonicalizeFormula(content, locale)
6163
- : canonicalizeNumberLiteral(content, locale);
6164
- }
6165
- /** Change a formula to its canonical form (en_US locale) */
6166
- function canonicalizeFormula(formula, locale) {
6167
- return _localizeFormula(formula, locale, DEFAULT_LOCALE);
6168
- }
6169
- function _localizeFormula(formula, fromLocale, toLocale) {
6170
- if (fromLocale.formulaArgSeparator === toLocale.formulaArgSeparator &&
6171
- fromLocale.decimalSeparator === toLocale.decimalSeparator) {
6172
- return formula;
6173
- }
6174
- const tokens = tokenize(formula, fromLocale);
6175
- let localizedFormula = "";
6176
- for (const token of tokens) {
6177
- if (token.type === "NUMBER") {
6178
- localizedFormula += token.value.replace(fromLocale.decimalSeparator, toLocale.decimalSeparator);
6179
- }
6180
- else if (token.type === "ARG_SEPARATOR") {
6181
- localizedFormula += toLocale.formulaArgSeparator;
6182
- }
6183
- else {
6184
- localizedFormula += token.value;
6185
- }
6186
- }
6187
- return localizedFormula;
6188
- }
6189
-
6190
6170
  function boolAnd(args) {
6191
6171
  let foundBoolean = false;
6192
6172
  let acc = true;
@@ -6788,13 +6768,6 @@
6788
6768
  this.clearClippedZones(content);
6789
6769
  const selection = target[0];
6790
6770
  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
6771
  }
6799
6772
  /**
6800
6773
  * Clear the clipped zones: remove the cells and clear the formatting
@@ -7255,14 +7228,15 @@
7255
7228
  }
7256
7229
  merges.push(mergesInRow);
7257
7230
  }
7258
- return { merges };
7231
+ return { merges, sheetId };
7259
7232
  }
7260
7233
  /**
7261
7234
  * Paste the clipboard content in the given target
7262
7235
  */
7263
7236
  paste(target, content, options) {
7264
7237
  if (options.isCutOperation) {
7265
- return;
7238
+ const copiedMerges = content.merges.flat().filter(isDefined);
7239
+ this.dispatch("REMOVE_MERGE", { sheetId: content.sheetId, target: copiedMerges });
7266
7240
  }
7267
7241
  this.pasteFromCopy(target.sheetId, target.zones, content.merges, options);
7268
7242
  }
@@ -7297,6 +7271,27 @@
7297
7271
  }
7298
7272
  }
7299
7273
 
7274
+ class ReferenceClipboardHandler extends AbstractCellClipboardHandler {
7275
+ copy(data) {
7276
+ return {
7277
+ zones: data.clippedZones,
7278
+ sheetId: data.sheetId,
7279
+ };
7280
+ }
7281
+ paste(target, content, options) {
7282
+ if (options.isCutOperation) {
7283
+ const selection = target.zones[0];
7284
+ this.dispatch("MOVE_RANGES", {
7285
+ target: content.zones,
7286
+ sheetId: content.sheetId,
7287
+ targetSheetId: target.sheetId,
7288
+ col: selection.left,
7289
+ row: selection.top,
7290
+ });
7291
+ }
7292
+ }
7293
+ }
7294
+
7300
7295
  class SheetClipboardHandler extends AbstractCellClipboardHandler {
7301
7296
  isPasteAllowed(sheetId, target, content, options) {
7302
7297
  if (!("cells" in content)) {
@@ -7464,7 +7459,8 @@
7464
7459
  .add("merge", MergeClipboardHandler)
7465
7460
  .add("border", BorderClipboardHandler)
7466
7461
  .add("table", TableClipboardHandler)
7467
- .add("conditionalFormat", ConditionalFormatClipboardHandler);
7462
+ .add("conditionalFormat", ConditionalFormatClipboardHandler)
7463
+ .add("references", ReferenceClipboardHandler);
7468
7464
 
7469
7465
  function transformZone(zone, executed) {
7470
7466
  if (executed.type === "REMOVE_COLUMNS_ROWS") {
@@ -9621,8 +9617,8 @@ stores.inject(MyMetaStore, storeInstance);
9621
9617
  this.colorIndexByRange = {};
9622
9618
  }
9623
9619
  cancelEdition() {
9624
- this.cancelEditionAndActivateSheet();
9625
9620
  this.resetContent();
9621
+ this.cancelEditionAndActivateSheet();
9626
9622
  this.colorIndexByRange = {};
9627
9623
  }
9628
9624
  setCurrentContent(content, selection) {
@@ -9639,8 +9635,8 @@ stores.inject(MyMetaStore, storeInstance);
9639
9635
  switch (cmd.type) {
9640
9636
  case "SELECT_FIGURE":
9641
9637
  if (cmd.id) {
9642
- this.cancelEditionAndActivateSheet();
9643
9638
  this.resetContent();
9639
+ this.cancelEditionAndActivateSheet();
9644
9640
  }
9645
9641
  break;
9646
9642
  case "SET_FORMATTING":
@@ -9690,8 +9686,8 @@ stores.inject(MyMetaStore, storeInstance);
9690
9686
  const sheetIdExists = !!this.getters.tryGetSheet(this.sheetId);
9691
9687
  if (!sheetIdExists && this.editionMode !== "inactive") {
9692
9688
  this.sheetId = this.getters.getActiveSheetId();
9693
- this.cancelEditionAndActivateSheet();
9694
9689
  this.resetContent();
9690
+ this.cancelEditionAndActivateSheet();
9695
9691
  this.notificationStore.raiseError(CELL_DELETED_MESSAGE);
9696
9692
  }
9697
9693
  break;
@@ -12007,7 +12003,8 @@ stores.inject(MyMetaStore, storeInstance);
12007
12003
  }
12008
12004
  }
12009
12005
  else if (dataSets.length === 1) {
12010
- for (let i = 0; i < getData(getters, dataSets[0]).length; i++) {
12006
+ const dataLength = getData(getters, dataSets[0]).length;
12007
+ for (let i = 0; i < dataLength; i++) {
12011
12008
  labels.formattedValues.push("");
12012
12009
  labels.values.push("");
12013
12010
  }
@@ -37675,6 +37672,7 @@ stores.inject(MyMetaStore, storeInstance);
37675
37672
  columns: {},
37676
37673
  });
37677
37674
  setup() {
37675
+ this.updateColumns();
37678
37676
  owl.onWillUpdateProps(() => this.updateColumns());
37679
37677
  }
37680
37678
  toggleHasHeader() {
@@ -43161,9 +43159,9 @@ stores.inject(MyMetaStore, storeInstance);
43161
43159
  /** In XLSX color format (no #) */
43162
43160
  const AUTO_COLOR = "000000";
43163
43161
  const XLSX_ICONSET_MAP = {
43164
- arrow: "3Arrows",
43162
+ arrows: "3Arrows",
43165
43163
  smiley: "3Symbols",
43166
- dot: "3TrafficLights1",
43164
+ dots: "3TrafficLights1",
43167
43165
  };
43168
43166
  const NAMESPACE = {
43169
43167
  styleSheet: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
@@ -43579,6 +43577,7 @@ stores.inject(MyMetaStore, storeInstance);
43579
43577
  };
43580
43578
  /** Map between legend position in XLSX file and human readable position */
43581
43579
  const DRAWING_LEGEND_POSITION_CONVERSION_MAP = {
43580
+ none: "none",
43582
43581
  b: "bottom",
43583
43582
  t: "top",
43584
43583
  l: "left",
@@ -45828,7 +45827,7 @@ stores.inject(MyMetaStore, storeInstance);
45828
45827
  default: "ffffff",
45829
45828
  }).asString(),
45830
45829
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(rootChartElement, "c:legendPos", "val", {
45831
- default: "b",
45830
+ default: "none",
45832
45831
  }).asString()],
45833
45832
  stacked: barChartGrouping === "stacked",
45834
45833
  fontColor: "000000",
@@ -45862,7 +45861,7 @@ stores.inject(MyMetaStore, storeInstance);
45862
45861
  default: "ffffff",
45863
45862
  }).asString(),
45864
45863
  legendPosition: DRAWING_LEGEND_POSITION_CONVERSION_MAP[this.extractChildAttr(chartElement, "c:legendPos", "val", {
45865
- default: "b",
45864
+ default: "none",
45866
45865
  }).asString()],
45867
45866
  stacked: barChartGrouping === "stacked",
45868
45867
  fontColor: "000000",
@@ -58762,12 +58761,7 @@ stores.inject(MyMetaStore, storeInstance);
58762
58761
  }
58763
58762
  break;
58764
58763
  case "AUTORESIZE_ROWS":
58765
- this.dispatch("RESIZE_COLUMNS_ROWS", {
58766
- elements: cmd.rows,
58767
- dimension: "ROW",
58768
- size: null,
58769
- sheetId: cmd.sheetId,
58770
- });
58764
+ this.autoResizeRows(cmd.sheetId, cmd.rows);
58771
58765
  break;
58772
58766
  }
58773
58767
  }
@@ -58917,6 +58911,48 @@ stores.inject(MyMetaStore, storeInstance);
58917
58911
  }
58918
58912
  return "Success" /* CommandResult.Success */;
58919
58913
  }
58914
+ autoResizeRows(sheetId, rows) {
58915
+ const rowSizes = [];
58916
+ for (const row of rows) {
58917
+ let evaluatedRowSize = 0;
58918
+ for (const cellId of this.getters.getRowCells(sheetId, row)) {
58919
+ const cell = this.getters.getCellById(cellId);
58920
+ if (!cell) {
58921
+ continue;
58922
+ }
58923
+ const position = this.getters.getCellPosition(cell.id);
58924
+ const colSize = this.getters.getColSize(sheetId, position.col);
58925
+ if (cell.isFormula) {
58926
+ const content = this.getters.getEvaluatedCell(position).formattedValue;
58927
+ const evaluatedSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58928
+ if (evaluatedSize > evaluatedRowSize && evaluatedSize > DEFAULT_CELL_HEIGHT) {
58929
+ evaluatedRowSize = evaluatedSize;
58930
+ }
58931
+ }
58932
+ else {
58933
+ const content = cell.content;
58934
+ const dynamicRowSize = getCellContentHeight(this.ctx, content, cell?.style, colSize);
58935
+ // Only keep the size of evaluated cells if it's bigger than the dynamic row size
58936
+ if (dynamicRowSize >= evaluatedRowSize && dynamicRowSize > DEFAULT_CELL_HEIGHT) {
58937
+ evaluatedRowSize = 0;
58938
+ }
58939
+ }
58940
+ }
58941
+ rowSizes.push(evaluatedRowSize || null);
58942
+ }
58943
+ const groupedSizes = new Map(rowSizes.map((size) => [size, []]));
58944
+ for (let i = 0; i < rowSizes.length; i++) {
58945
+ groupedSizes.get(rowSizes[i])?.push(rows[i]);
58946
+ }
58947
+ for (const [size, rows] of groupedSizes) {
58948
+ this.dispatch("RESIZE_COLUMNS_ROWS", {
58949
+ elements: rows,
58950
+ dimension: "ROW",
58951
+ size,
58952
+ sheetId,
58953
+ });
58954
+ }
58955
+ }
58920
58956
  }
58921
58957
 
58922
58958
  class TableComputedStylePlugin extends UIPlugin {
@@ -64123,7 +64159,9 @@ stores.inject(MyMetaStore, storeInstance);
64123
64159
  margin-top: -1px;
64124
64160
  border: 1px solid;
64125
64161
 
64126
- .o-composer:empty:not(:focus):not(.active)::before {
64162
+ /* In readonly we always show the fx icon if the composer is empty, not matter the focus */
64163
+ .o-composer:empty:not(:focus):not(.active)::before,
64164
+ &.o-topbar-composer-readonly .o-composer:empty::before {
64127
64165
  content: url("data:image/svg+xml,${encodeURIComponent(FX_SVG)}");
64128
64166
  position: relative;
64129
64167
  top: 20%;
@@ -67367,10 +67405,14 @@ stores.inject(MyMetaStore, storeInstance);
67367
67405
  continue;
67368
67406
  }
67369
67407
  const cfValueObjectNodes = cfValueObject.map((attrs) => escapeXml /*xml*/ `<cfvo ${formatAttributes(attrs)} />`);
67408
+ const iconSetAttrs = [["iconSet", getIconSet(rule.icons)]];
67409
+ if (isIconSetReversed(rule.icons)) {
67410
+ iconSetAttrs.push(["reverse", "1"]);
67411
+ }
67370
67412
  conditionalFormats.push(escapeXml /*xml*/ `
67371
67413
  <conditionalFormatting sqref="${range}">
67372
67414
  <cfRule ${formatAttributes(ruleAttributes)}>
67373
- <iconSet iconSet="${getIconSet(rule.icons)}">
67415
+ <iconSet ${formatAttributes(iconSetAttrs)}>
67374
67416
  ${joinXmlNodes(cfValueObjectNodes)}
67375
67417
  </iconSet>
67376
67418
  </cfRule>
@@ -67388,9 +67430,21 @@ stores.inject(MyMetaStore, storeInstance);
67388
67430
  ["stopIfTrue", cf.stopIfTrue ? 1 : 0],
67389
67431
  ];
67390
67432
  }
67433
+ function isIconSetReversed(iconSet) {
67434
+ const defaultIconSet = ICON_SETS[detectIconsType(iconSet)];
67435
+ return iconSet.upper === defaultIconSet.bad && iconSet.lower === defaultIconSet.good;
67436
+ }
67391
67437
  function getIconSet(iconSet) {
67392
- return XLSX_ICONSET_MAP[Object.keys(XLSX_ICONSET_MAP).find((key) => iconSet.upper.toLowerCase().startsWith(key)) ||
67393
- "dots"];
67438
+ return XLSX_ICONSET_MAP[detectIconsType(iconSet)];
67439
+ }
67440
+ /**
67441
+ * Partial detection based on "upper" point only.
67442
+ * We support any arbitrary icon in the set, while excel doesn't allow
67443
+ * mixing icons from different types.
67444
+ */
67445
+ function detectIconsType(iconSet) {
67446
+ const type = Object.keys(ICON_SETS).find((type) => Object.values(ICON_SETS[type]).includes(iconSet.upper)) || "dots";
67447
+ return type;
67394
67448
  }
67395
67449
  function thresholdAttributes(threshold, position) {
67396
67450
  const type = getExcelThresholdType(threshold.type, position);
@@ -69172,9 +69226,9 @@ stores.inject(MyMetaStore, storeInstance);
69172
69226
  exports.tokenize = tokenize;
69173
69227
 
69174
69228
 
69175
- __info__.version = "17.4.26";
69176
- __info__.date = "2025-03-12T15:31:45.184Z";
69177
- __info__.hash = "a18429e";
69229
+ __info__.version = "17.4.28";
69230
+ __info__.date = "2025-03-26T12:48:33.387Z";
69231
+ __info__.hash = "a81a8f4";
69178
69232
 
69179
69233
 
69180
69234
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);