@odoo/o-spreadsheet 18.0.43 → 18.0.45

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 18.0.43
6
- * @date 2025-09-05T07:38:36.406Z
7
- * @hash 0f02dde
5
+ * @version 18.0.45
6
+ * @date 2025-09-19T07:24:19.143Z
7
+ * @hash 54e799a
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -855,8 +855,19 @@
855
855
  },
856
856
  }[funcName];
857
857
  }
858
+ /**
859
+ * Removes the specified indexes from the array.
860
+ * Sparse (empty) elements are transformed to undefined (unless their index is explicitly removed).
861
+ */
858
862
  function removeIndexesFromArray(array, indexes) {
859
- return array.filter((_, index) => !indexes.includes(index));
863
+ const toRemove = new Set(indexes);
864
+ const newArray = [];
865
+ for (let i = 0; i < array.length; i++) {
866
+ if (!toRemove.has(i)) {
867
+ newArray.push(array[i]);
868
+ }
869
+ }
870
+ return newArray;
860
871
  }
861
872
  function insertItemsAtIndex(array, items, index) {
862
873
  const newArray = [...array];
@@ -6740,7 +6751,7 @@
6740
6751
  this.getters = getters;
6741
6752
  this.dispatch = dispatch;
6742
6753
  }
6743
- copy(data) {
6754
+ copy(data, mode = "copyPaste") {
6744
6755
  return;
6745
6756
  }
6746
6757
  paste(target, clippedContent, options) { }
@@ -6759,7 +6770,7 @@
6759
6770
  }
6760
6771
 
6761
6772
  class AbstractCellClipboardHandler extends ClipboardHandler {
6762
- copy(data) {
6773
+ copy(data, mode = "copyPaste") {
6763
6774
  return;
6764
6775
  }
6765
6776
  pasteFromCopy(sheetId, target, content, options) {
@@ -8428,7 +8439,7 @@
8428
8439
  }
8429
8440
  return "Success" /* CommandResult.Success */;
8430
8441
  }
8431
- copy(data) {
8442
+ copy(data, mode = "copyPaste") {
8432
8443
  const sheetId = data.sheetId;
8433
8444
  const { clippedZones, rowsIndexes, columnsIndexes } = data;
8434
8445
  const clippedCells = [];
@@ -8441,7 +8452,7 @@
8441
8452
  const evaluatedCell = this.getters.getEvaluatedCell(position);
8442
8453
  const pivotId = this.getters.getPivotIdFromPosition(position);
8443
8454
  const spreader = this.getters.getArrayFormulaSpreadingOn(position);
8444
- if (pivotId && spreader) {
8455
+ if (mode !== "shiftCells" && pivotId && spreader) {
8445
8456
  const pivotZone = this.getters.getSpreadZone(spreader);
8446
8457
  if ((!deepEquals(spreader, position) || !isCopyingOneCell) &&
8447
8458
  pivotZone &&
@@ -8459,7 +8470,7 @@
8459
8470
  };
8460
8471
  }
8461
8472
  }
8462
- else {
8473
+ else if (mode !== "shiftCells") {
8463
8474
  if (spreader && !deepEquals(spreader, position)) {
8464
8475
  const isSpreaderCopied = rowsIndexes.includes(spreader.row) && columnsIndexes.includes(spreader.col);
8465
8476
  const content = isSpreaderCopied
@@ -9152,7 +9163,7 @@
9152
9163
  }
9153
9164
 
9154
9165
  class TableClipboardHandler extends AbstractCellClipboardHandler {
9155
- copy(data) {
9166
+ copy(data, mode = "copyPaste") {
9156
9167
  const sheetId = data.sheetId;
9157
9168
  const { rowsIndexes, columnsIndexes, zones } = data;
9158
9169
  const copiedTablesIds = new Set();
@@ -9186,11 +9197,13 @@
9186
9197
  type: coreTable.type,
9187
9198
  };
9188
9199
  }
9189
- tableCellsInRow.push({
9190
- table: copiedTable,
9191
- style: this.getTableStyleToCopy(position),
9192
- isWholeTableCopied: copiedTablesIds.has(table.id),
9193
- });
9200
+ if (mode !== "shiftCells") {
9201
+ tableCellsInRow.push({
9202
+ table: copiedTable,
9203
+ style: this.getTableStyleToCopy(position),
9204
+ isWholeTableCopied: copiedTablesIds.has(table.id),
9205
+ });
9206
+ }
9194
9207
  }
9195
9208
  }
9196
9209
  return {
@@ -15096,8 +15109,9 @@ stores.inject(MyMetaStore, storeInstance);
15096
15109
  }
15097
15110
 
15098
15111
  function sortMatrix(matrix, locale, ...criteria) {
15099
- for (const [i, value] of criteria.entries()) {
15100
- assert(() => value !== undefined, _t("Value for parameter %d is missing, while the function [[FUNCTION_NAME]] expect a number or a range.", i + 1));
15112
+ for (let i = 0; i < criteria.length; i++) {
15113
+ const param = i % 2 === 0 ? "sort_column" : "is_ascending";
15114
+ assert(() => criteria[i] !== undefined, _t("Value for parameter %s is missing in [[FUNCTION_NAME]].", param));
15101
15115
  }
15102
15116
  const sortingOrders = [];
15103
15117
  const sortColumns = [];
@@ -20788,7 +20802,7 @@ stores.inject(MyMetaStore, storeInstance);
20788
20802
  ];
20789
20803
  const SUPPORTED_VERTICAL_ALIGNMENTS = ["top", "center", "bottom"];
20790
20804
  const SUPPORTED_FONTS = ["Arial"];
20791
- const SUPPORTED_FILL_PATTERNS = ["solid"];
20805
+ const SUPPORTED_FILL_PATTERNS = ["solid", "none"];
20792
20806
  const SUPPORTED_CF_TYPES = [
20793
20807
  "expression",
20794
20808
  "cellIs",
@@ -20973,7 +20987,7 @@ stores.inject(MyMetaStore, storeInstance);
20973
20987
  };
20974
20988
  /** Mapping between Excel format indexes (see XLSX_FORMAT_MAP) and some supported formats */
20975
20989
  const XLSX_FORMATS_CONVERSION_MAP = {
20976
- 0: "",
20990
+ 0: "General",
20977
20991
  1: "0",
20978
20992
  2: "0.00",
20979
20993
  3: "#,#00",
@@ -21299,11 +21313,11 @@ stores.inject(MyMetaStore, storeInstance);
21299
21313
  * Excel format are defined in openXML §18.8.31
21300
21314
  */
21301
21315
  function convertXlsxFormat(numFmtId, formats, warningManager) {
21302
- if (numFmtId === 0) {
21303
- return undefined;
21304
- }
21305
21316
  // Format is either defined in the imported data, or the formatId is defined in openXML §18.8.30
21306
21317
  let format = XLSX_FORMATS_CONVERSION_MAP[numFmtId] || formats.find((f) => f.id === numFmtId)?.format;
21318
+ if (format === "General") {
21319
+ return undefined;
21320
+ }
21307
21321
  if (format) {
21308
21322
  try {
21309
21323
  let convertedFormat = format.replace(/\[(.*)-[A-Z0-9]{3}\]/g, "[$1]"); // remove currency and locale/date system/number system info (ECMA §18.8.31)
@@ -24261,10 +24275,11 @@ stores.inject(MyMetaStore, storeInstance);
24261
24275
  });
24262
24276
  }
24263
24277
  extractRows(worksheet) {
24278
+ const spilledCells = new Set();
24264
24279
  return this.mapOnElements({ parent: worksheet, query: "sheetData row" }, (rowElement) => {
24265
24280
  return {
24266
24281
  index: this.extractAttr(rowElement, "r", { required: true })?.asNum(),
24267
- cells: this.extractCells(rowElement),
24282
+ cells: this.extractCells(rowElement, spilledCells),
24268
24283
  height: this.extractAttr(rowElement, "ht")?.asNum(),
24269
24284
  customHeight: this.extractAttr(rowElement, "customHeight")?.asBool(),
24270
24285
  hidden: this.extractAttr(rowElement, "hidden")?.asBool(),
@@ -24274,14 +24289,26 @@ stores.inject(MyMetaStore, storeInstance);
24274
24289
  };
24275
24290
  });
24276
24291
  }
24277
- extractCells(row) {
24292
+ extractCells(row, spilledCells) {
24278
24293
  return this.mapOnElements({ parent: row, query: "c" }, (cellElement) => {
24294
+ const xc = this.extractAttr(cellElement, "r", { required: true })?.asString();
24295
+ const formula = this.extractCellFormula(cellElement);
24296
+ if (formula?.ref && formula.sharedIndex === undefined) {
24297
+ const zone = toZone(formula.ref);
24298
+ for (const { col, row } of positions(zone)) {
24299
+ const followerXc = toXC(col, row);
24300
+ if (followerXc !== xc) {
24301
+ spilledCells.add(followerXc);
24302
+ }
24303
+ }
24304
+ }
24305
+ const isSpilled = spilledCells.has(xc);
24279
24306
  return {
24280
- xc: this.extractAttr(cellElement, "r", { required: true })?.asString(),
24307
+ xc,
24281
24308
  styleIndex: this.extractAttr(cellElement, "s")?.asNum(),
24282
24309
  type: CELL_TYPE_CONVERSION_MAP[this.extractAttr(cellElement, "t", { default: "n" })?.asString()],
24283
- value: this.extractChildTextContent(cellElement, "v"),
24284
- formula: this.extractCellFormula(cellElement),
24310
+ value: isSpilled ? undefined : this.extractChildTextContent(cellElement, "v") ?? undefined,
24311
+ formula: isSpilled ? undefined : formula,
24285
24312
  };
24286
24313
  });
24287
24314
  }
@@ -24289,11 +24316,14 @@ stores.inject(MyMetaStore, storeInstance);
24289
24316
  const formulaElement = this.querySelector(cellElement, "f");
24290
24317
  if (!formulaElement)
24291
24318
  return undefined;
24292
- return {
24293
- content: this.extractTextContent(formulaElement),
24294
- sharedIndex: this.extractAttr(formulaElement, "si")?.asNum(),
24295
- ref: this.extractAttr(formulaElement, "ref")?.asString(),
24296
- };
24319
+ const content = this.extractTextContent(formulaElement);
24320
+ const sharedIndex = this.extractAttr(formulaElement, "si")?.asNum();
24321
+ const ref = this.extractAttr(formulaElement, "ref")?.asString();
24322
+ // This is the case of spilled cells of array formulas where <f> is empty
24323
+ if ((content === undefined || content.trim() === "") && sharedIndex === undefined) {
24324
+ return undefined;
24325
+ }
24326
+ return { content, sharedIndex, ref };
24297
24327
  }
24298
24328
  extractHyperLinks(worksheet) {
24299
24329
  return this.mapOnElements({ parent: worksheet, query: "hyperlink" }, (linkElement) => {
@@ -43446,7 +43476,7 @@ stores.inject(MyMetaStore, storeInstance);
43446
43476
  });
43447
43477
  }
43448
43478
  get isCalculatedMeasureInvalid() {
43449
- return this.env.model.getters.getMeasureCompiledFormula(this.props.measure).isBadExpression;
43479
+ return compile(this.props.measure.computedBy?.formula ?? "").isBadExpression;
43450
43480
  }
43451
43481
  }
43452
43482
 
@@ -43641,12 +43671,13 @@ stores.inject(MyMetaStore, storeInstance);
43641
43671
  addCalculatedMeasure() {
43642
43672
  const { measures } = this.props.definition;
43643
43673
  const measureName = this.env.model.getters.generateNewCalculatedMeasureName(measures);
43674
+ const aggregator = "sum";
43644
43675
  this.props.onDimensionsUpdated({
43645
43676
  measures: measures.concat([
43646
43677
  {
43647
- id: this.getMeasureId(measureName),
43678
+ id: this.getMeasureId(measureName, aggregator),
43648
43679
  fieldName: measureName,
43649
- aggregator: "sum",
43680
+ aggregator,
43650
43681
  computedBy: {
43651
43682
  sheetId: this.env.model.getters.getActiveSheetId(),
43652
43683
  formula: "=0",
@@ -60709,7 +60740,7 @@ stores.inject(MyMetaStore, storeInstance);
60709
60740
  return { value: 0 };
60710
60741
  }
60711
60742
  const { columns, rows } = super.definition;
60712
- if (columns.length + rows.length !== domain.length) {
60743
+ if (measure.aggregator && columns.length + rows.length !== domain.length) {
60713
60744
  const values = this.getValuesToAggregate(measure, domain);
60714
60745
  const aggregator = AGGREGATORS_FN[measure.aggregator];
60715
60746
  if (!aggregator) {
@@ -60728,11 +60759,17 @@ stores.inject(MyMetaStore, storeInstance);
60728
60759
  if (columns.find((col) => col.nameWithGranularity === symbolName)) {
60729
60760
  const { colDomain } = domainToColRowDomain(this, domain);
60730
60761
  const symbolIndex = colDomain.findIndex((node) => node.field === symbolName);
60762
+ if (symbolIndex === -1) {
60763
+ return new NotAvailableError();
60764
+ }
60731
60765
  return this.getPivotHeaderValueAndFormat(colDomain.slice(0, symbolIndex + 1));
60732
60766
  }
60733
60767
  if (rows.find((row) => row.nameWithGranularity === symbolName)) {
60734
60768
  const { rowDomain } = domainToColRowDomain(this, domain);
60735
60769
  const symbolIndex = rowDomain.findIndex((row) => row.field === symbolName);
60770
+ if (symbolIndex === -1) {
60771
+ return new NotAvailableError();
60772
+ }
60736
60773
  return this.getPivotHeaderValueAndFormat(rowDomain.slice(0, symbolIndex + 1));
60737
60774
  }
60738
60775
  return this.getPivotCellValueAndFormat(symbolName, domain);
@@ -65167,12 +65204,12 @@ stores.inject(MyMetaStore, storeInstance);
65167
65204
  }
65168
65205
  case "INSERT_CELL": {
65169
65206
  const { cut, paste } = this.getInsertCellsTargets(cmd.zone, cmd.shiftDimension);
65170
- const copiedData = this.copy(cut);
65207
+ const copiedData = this.copy(cut, "shiftCells");
65171
65208
  return this.isPasteAllowed(paste, copiedData, { isCutOperation: true });
65172
65209
  }
65173
65210
  case "DELETE_CELL": {
65174
65211
  const { cut, paste } = this.getDeleteCellsTargets(cmd.zone, cmd.shiftDimension);
65175
- const copiedData = this.copy(cut);
65212
+ const copiedData = this.copy(cut, "shiftCells");
65176
65213
  return this.isPasteAllowed(paste, copiedData, { isCutOperation: true });
65177
65214
  }
65178
65215
  }
@@ -65262,13 +65299,13 @@ stores.inject(MyMetaStore, storeInstance);
65262
65299
  });
65263
65300
  break;
65264
65301
  }
65265
- const copiedData = this.copy(cut);
65302
+ const copiedData = this.copy(cut, "shiftCells");
65266
65303
  this.paste(paste, copiedData, { isCutOperation: true });
65267
65304
  break;
65268
65305
  }
65269
65306
  case "INSERT_CELL": {
65270
65307
  const { cut, paste } = this.getInsertCellsTargets(cmd.zone, cmd.shiftDimension);
65271
- const copiedData = this.copy(cut);
65308
+ const copiedData = this.copy(cut, "shiftCells");
65272
65309
  this.paste(paste, copiedData, { isCutOperation: true });
65273
65310
  break;
65274
65311
  }
@@ -65383,11 +65420,11 @@ stores.inject(MyMetaStore, storeInstance);
65383
65420
  }
65384
65421
  return false;
65385
65422
  }
65386
- copy(zones) {
65423
+ copy(zones, mode = "copyPaste") {
65387
65424
  let copiedData = {};
65388
65425
  const clipboardData = this.getClipboardData(zones);
65389
65426
  for (const { handlerName, handler } of this.selectClipboardHandlers(clipboardData)) {
65390
- const data = handler.copy(clipboardData);
65427
+ const data = handler.copy(clipboardData, mode);
65391
65428
  copiedData[handlerName] = data;
65392
65429
  const minimalKeys = ["sheetId", "cells", "zones", "figureId"];
65393
65430
  for (const key of minimalKeys) {
@@ -66258,7 +66295,7 @@ stores.inject(MyMetaStore, storeInstance);
66258
66295
  ];
66259
66296
  for (const Handler of clipboardHandlersRegistries.cellHandlers.getAll()) {
66260
66297
  const handler = new Handler(this.getters, this.dispatch);
66261
- const data = handler.copy(getClipboardDataPositions(sheetId, target));
66298
+ const data = handler.copy(getClipboardDataPositions(sheetId, target), "shiftCells");
66262
66299
  if (!data) {
66263
66300
  continue;
66264
66301
  }
@@ -73997,7 +74034,7 @@ stores.inject(MyMetaStore, storeInstance);
73997
74034
  handlers = [];
73998
74035
  uiHandlers = [];
73999
74036
  coreHandlers = [];
74000
- constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
74037
+ constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = false) {
74001
74038
  const start = performance.now();
74002
74039
  console.debug("##### Model creation #####");
74003
74040
  super();
@@ -74710,9 +74747,9 @@ stores.inject(MyMetaStore, storeInstance);
74710
74747
  exports.tokenize = tokenize;
74711
74748
 
74712
74749
 
74713
- __info__.version = "18.0.43";
74714
- __info__.date = "2025-09-05T07:38:36.406Z";
74715
- __info__.hash = "0f02dde";
74750
+ __info__.version = "18.0.45";
74751
+ __info__.date = "2025-09-19T07:24:19.143Z";
74752
+ __info__.hash = "54e799a";
74716
74753
 
74717
74754
 
74718
74755
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);