@odoo/o-spreadsheet 16.0.74 → 16.0.75

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.
@@ -25603,38 +25603,112 @@ function applyStyleToZone(appliedStyle, zone, cells, styles) {
25603
25603
  * In all the sheets, replace the table-only references in the formula cells with standard references.
25604
25604
  */
25605
25605
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
25606
+ let deconstructedSheets = null;
25606
25607
  for (let tableSheet of convertedSheets) {
25607
25608
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
25609
+ if (!tables || tables.length === 0) {
25610
+ continue;
25611
+ }
25612
+ // Only deconstruct sheets if we are sure there are tables to process
25613
+ if (!deconstructedSheets) {
25614
+ deconstructedSheets = deconstructSheets(convertedSheets);
25615
+ }
25608
25616
  for (let table of tables) {
25609
- const tabRef = table.name + "[";
25610
- for (let sheet of convertedSheets) {
25611
- for (let xc in sheet.cells) {
25612
- const cell = sheet.cells[xc];
25613
- if (cell && cell.content && cell.content.startsWith("=")) {
25614
- let refIndex;
25615
- while ((refIndex = cell.content.indexOf(tabRef)) !== -1) {
25616
- let endIndex = refIndex + tabRef.length;
25617
- let openBrackets = 1;
25618
- while (openBrackets > 0 && endIndex < cell.content.length) {
25619
- if (cell.content[endIndex] === "[") {
25620
- openBrackets++;
25621
- }
25622
- else if (cell.content[endIndex] === "]") {
25623
- openBrackets--;
25624
- }
25625
- endIndex++;
25626
- }
25627
- let reference = cell.content.slice(refIndex + tabRef.length, endIndex - 1);
25628
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25629
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
25630
- cell.content =
25631
- cell.content.slice(0, refIndex) + convertedRef + cell.content.slice(endIndex);
25617
+ for (let sheetId in deconstructedSheets) {
25618
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25619
+ for (let xc in deconstructedSheets[sheetId]) {
25620
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25621
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
25622
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
25623
+ if (!possibleTable.endsWith(table.name)) {
25624
+ continue;
25632
25625
  }
25626
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
25627
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25628
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
25629
+ deconstructedSheets[sheetId][xc][i + 2] =
25630
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
25631
+ convertedRef +
25632
+ deconstructedSheets[sheetId][xc][i + 2];
25633
+ deconstructedSheets[sheetId][xc].splice(i, 2);
25634
+ }
25635
+ }
25636
+ }
25637
+ }
25638
+ }
25639
+ if (!deconstructedSheets) {
25640
+ return;
25641
+ }
25642
+ for (let sheetId in deconstructedSheets) {
25643
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25644
+ for (let xc in deconstructedSheets[sheetId]) {
25645
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25646
+ if (deconstructedCell.length === 1) {
25647
+ sheet.cells[xc].content = deconstructedCell[0];
25648
+ continue;
25649
+ }
25650
+ let newContent = "";
25651
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
25652
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
25653
+ }
25654
+ newContent += deconstructedCell[deconstructedCell.length - 1];
25655
+ sheet.cells[xc].content = newContent;
25656
+ }
25657
+ }
25658
+ }
25659
+ /**
25660
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
25661
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
25662
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
25663
+ */
25664
+ function deconstructSheets(convertedSheets) {
25665
+ var _a;
25666
+ const deconstructedSheets = {};
25667
+ for (let sheet of convertedSheets) {
25668
+ for (let xc in sheet.cells) {
25669
+ const cellContent = (_a = sheet.cells[xc]) === null || _a === void 0 ? void 0 : _a.content;
25670
+ if (!cellContent || !cellContent.startsWith("=")) {
25671
+ continue;
25672
+ }
25673
+ const startIndex = cellContent.indexOf("[");
25674
+ if (startIndex === -1) {
25675
+ continue;
25676
+ }
25677
+ const deconstructedCell = [];
25678
+ let possibleTable = cellContent.slice(0, startIndex);
25679
+ let possibleRef = "";
25680
+ let openBrackets = 1;
25681
+ let mainPossibleTableIndex = 0;
25682
+ let mainOpenBracketIndex = startIndex;
25683
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
25684
+ if (cellContent[index] === "[") {
25685
+ if (openBrackets === 0) {
25686
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
25687
+ mainOpenBracketIndex = index;
25688
+ }
25689
+ openBrackets++;
25690
+ continue;
25691
+ }
25692
+ if (cellContent[index] === "]") {
25693
+ openBrackets--;
25694
+ if (openBrackets === 0) {
25695
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
25696
+ deconstructedCell.push(possibleTable);
25697
+ deconstructedCell.push(possibleRef);
25698
+ mainPossibleTableIndex = index + 1;
25633
25699
  }
25634
25700
  }
25635
25701
  }
25702
+ if (deconstructedCell.length) {
25703
+ if (!deconstructedSheets[sheet.id]) {
25704
+ deconstructedSheets[sheet.id] = {};
25705
+ }
25706
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
25707
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
25708
+ }
25636
25709
  }
25637
25710
  }
25711
+ return deconstructedSheets;
25638
25712
  }
25639
25713
  /**
25640
25714
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -43890,6 +43964,6 @@ exports.setTranslationMethod = setTranslationMethod;
43890
43964
  exports.tokenize = tokenize;
43891
43965
 
43892
43966
 
43893
- __info__.version = '16.0.74';
43894
- __info__.date = '2025-06-27T09:02:46.788Z';
43895
- __info__.hash = 'a1d6303';
43967
+ __info__.version = '16.0.75';
43968
+ __info__.date = '2025-07-11T11:06:44.633Z';
43969
+ __info__.hash = 'c6d8a41';
@@ -25599,38 +25599,112 @@ function applyStyleToZone(appliedStyle, zone, cells, styles) {
25599
25599
  * In all the sheets, replace the table-only references in the formula cells with standard references.
25600
25600
  */
25601
25601
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
25602
+ let deconstructedSheets = null;
25602
25603
  for (let tableSheet of convertedSheets) {
25603
25604
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
25605
+ if (!tables || tables.length === 0) {
25606
+ continue;
25607
+ }
25608
+ // Only deconstruct sheets if we are sure there are tables to process
25609
+ if (!deconstructedSheets) {
25610
+ deconstructedSheets = deconstructSheets(convertedSheets);
25611
+ }
25604
25612
  for (let table of tables) {
25605
- const tabRef = table.name + "[";
25606
- for (let sheet of convertedSheets) {
25607
- for (let xc in sheet.cells) {
25608
- const cell = sheet.cells[xc];
25609
- if (cell && cell.content && cell.content.startsWith("=")) {
25610
- let refIndex;
25611
- while ((refIndex = cell.content.indexOf(tabRef)) !== -1) {
25612
- let endIndex = refIndex + tabRef.length;
25613
- let openBrackets = 1;
25614
- while (openBrackets > 0 && endIndex < cell.content.length) {
25615
- if (cell.content[endIndex] === "[") {
25616
- openBrackets++;
25617
- }
25618
- else if (cell.content[endIndex] === "]") {
25619
- openBrackets--;
25620
- }
25621
- endIndex++;
25622
- }
25623
- let reference = cell.content.slice(refIndex + tabRef.length, endIndex - 1);
25624
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25625
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
25626
- cell.content =
25627
- cell.content.slice(0, refIndex) + convertedRef + cell.content.slice(endIndex);
25613
+ for (let sheetId in deconstructedSheets) {
25614
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25615
+ for (let xc in deconstructedSheets[sheetId]) {
25616
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25617
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
25618
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
25619
+ if (!possibleTable.endsWith(table.name)) {
25620
+ continue;
25628
25621
  }
25622
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
25623
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25624
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
25625
+ deconstructedSheets[sheetId][xc][i + 2] =
25626
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
25627
+ convertedRef +
25628
+ deconstructedSheets[sheetId][xc][i + 2];
25629
+ deconstructedSheets[sheetId][xc].splice(i, 2);
25630
+ }
25631
+ }
25632
+ }
25633
+ }
25634
+ }
25635
+ if (!deconstructedSheets) {
25636
+ return;
25637
+ }
25638
+ for (let sheetId in deconstructedSheets) {
25639
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25640
+ for (let xc in deconstructedSheets[sheetId]) {
25641
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25642
+ if (deconstructedCell.length === 1) {
25643
+ sheet.cells[xc].content = deconstructedCell[0];
25644
+ continue;
25645
+ }
25646
+ let newContent = "";
25647
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
25648
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
25649
+ }
25650
+ newContent += deconstructedCell[deconstructedCell.length - 1];
25651
+ sheet.cells[xc].content = newContent;
25652
+ }
25653
+ }
25654
+ }
25655
+ /**
25656
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
25657
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
25658
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
25659
+ */
25660
+ function deconstructSheets(convertedSheets) {
25661
+ var _a;
25662
+ const deconstructedSheets = {};
25663
+ for (let sheet of convertedSheets) {
25664
+ for (let xc in sheet.cells) {
25665
+ const cellContent = (_a = sheet.cells[xc]) === null || _a === void 0 ? void 0 : _a.content;
25666
+ if (!cellContent || !cellContent.startsWith("=")) {
25667
+ continue;
25668
+ }
25669
+ const startIndex = cellContent.indexOf("[");
25670
+ if (startIndex === -1) {
25671
+ continue;
25672
+ }
25673
+ const deconstructedCell = [];
25674
+ let possibleTable = cellContent.slice(0, startIndex);
25675
+ let possibleRef = "";
25676
+ let openBrackets = 1;
25677
+ let mainPossibleTableIndex = 0;
25678
+ let mainOpenBracketIndex = startIndex;
25679
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
25680
+ if (cellContent[index] === "[") {
25681
+ if (openBrackets === 0) {
25682
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
25683
+ mainOpenBracketIndex = index;
25684
+ }
25685
+ openBrackets++;
25686
+ continue;
25687
+ }
25688
+ if (cellContent[index] === "]") {
25689
+ openBrackets--;
25690
+ if (openBrackets === 0) {
25691
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
25692
+ deconstructedCell.push(possibleTable);
25693
+ deconstructedCell.push(possibleRef);
25694
+ mainPossibleTableIndex = index + 1;
25629
25695
  }
25630
25696
  }
25631
25697
  }
25698
+ if (deconstructedCell.length) {
25699
+ if (!deconstructedSheets[sheet.id]) {
25700
+ deconstructedSheets[sheet.id] = {};
25701
+ }
25702
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
25703
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
25704
+ }
25632
25705
  }
25633
25706
  }
25707
+ return deconstructedSheets;
25634
25708
  }
25635
25709
  /**
25636
25710
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -43858,6 +43932,6 @@ function addFunction(functionName, functionDescription) {
43858
43932
  export { AbstractChart, CommandResult, CorePlugin, DATETIME_FORMAT, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, cellTypes, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, load, parse, readonlyAllowedCommands, registries, setTranslationMethod, tokenize };
43859
43933
 
43860
43934
 
43861
- __info__.version = '16.0.74';
43862
- __info__.date = '2025-06-27T09:02:46.788Z';
43863
- __info__.hash = 'a1d6303';
43935
+ __info__.version = '16.0.75';
43936
+ __info__.date = '2025-07-11T11:06:44.633Z';
43937
+ __info__.hash = 'c6d8a41';
@@ -25600,38 +25600,112 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
25600
25600
  * In all the sheets, replace the table-only references in the formula cells with standard references.
25601
25601
  */
25602
25602
  function convertTableFormulaReferences(convertedSheets, xlsxSheets) {
25603
+ let deconstructedSheets = null;
25603
25604
  for (let tableSheet of convertedSheets) {
25604
25605
  const tables = xlsxSheets.find((s) => isSheetNameEqual(s.sheetName, tableSheet.name)).tables;
25606
+ if (!tables || tables.length === 0) {
25607
+ continue;
25608
+ }
25609
+ // Only deconstruct sheets if we are sure there are tables to process
25610
+ if (!deconstructedSheets) {
25611
+ deconstructedSheets = deconstructSheets(convertedSheets);
25612
+ }
25605
25613
  for (let table of tables) {
25606
- const tabRef = table.name + "[";
25607
- for (let sheet of convertedSheets) {
25608
- for (let xc in sheet.cells) {
25609
- const cell = sheet.cells[xc];
25610
- if (cell && cell.content && cell.content.startsWith("=")) {
25611
- let refIndex;
25612
- while ((refIndex = cell.content.indexOf(tabRef)) !== -1) {
25613
- let endIndex = refIndex + tabRef.length;
25614
- let openBrackets = 1;
25615
- while (openBrackets > 0 && endIndex < cell.content.length) {
25616
- if (cell.content[endIndex] === "[") {
25617
- openBrackets++;
25618
- }
25619
- else if (cell.content[endIndex] === "]") {
25620
- openBrackets--;
25621
- }
25622
- endIndex++;
25623
- }
25624
- let reference = cell.content.slice(refIndex + tabRef.length, endIndex - 1);
25625
- const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25626
- const convertedRef = convertTableReference(sheetPrefix, reference, table, xc);
25627
- cell.content =
25628
- cell.content.slice(0, refIndex) + convertedRef + cell.content.slice(endIndex);
25614
+ for (let sheetId in deconstructedSheets) {
25615
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25616
+ for (let xc in deconstructedSheets[sheetId]) {
25617
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25618
+ for (let i = deconstructedCell.length - 3; i >= 0; i -= 2) {
25619
+ const possibleTable = deconstructedSheets[sheetId][xc][i];
25620
+ if (!possibleTable.endsWith(table.name)) {
25621
+ continue;
25629
25622
  }
25623
+ const possibleRef = deconstructedSheets[sheetId][xc][i + 1];
25624
+ const sheetPrefix = tableSheet.id === sheet.id ? "" : tableSheet.name + "!";
25625
+ const convertedRef = convertTableReference(sheetPrefix, possibleRef, table, xc);
25626
+ deconstructedSheets[sheetId][xc][i + 2] =
25627
+ possibleTable.slice(0, possibleTable.indexOf(table.name)) +
25628
+ convertedRef +
25629
+ deconstructedSheets[sheetId][xc][i + 2];
25630
+ deconstructedSheets[sheetId][xc].splice(i, 2);
25631
+ }
25632
+ }
25633
+ }
25634
+ }
25635
+ }
25636
+ if (!deconstructedSheets) {
25637
+ return;
25638
+ }
25639
+ for (let sheetId in deconstructedSheets) {
25640
+ const sheet = convertedSheets.find((s) => s.id === sheetId);
25641
+ for (let xc in deconstructedSheets[sheetId]) {
25642
+ const deconstructedCell = deconstructedSheets[sheetId][xc];
25643
+ if (deconstructedCell.length === 1) {
25644
+ sheet.cells[xc].content = deconstructedCell[0];
25645
+ continue;
25646
+ }
25647
+ let newContent = "";
25648
+ for (let i = 0; i < deconstructedCell.length; i += 2) {
25649
+ newContent += deconstructedCell[i] + "[" + deconstructedCell[i + 1] + "]";
25650
+ }
25651
+ newContent += deconstructedCell[deconstructedCell.length - 1];
25652
+ sheet.cells[xc].content = newContent;
25653
+ }
25654
+ }
25655
+ }
25656
+ /**
25657
+ * Deconstruct the content of the cells in the sheets to extract possible table references.
25658
+ * Example from "=AVERAGE(Table1[colName1])-AVERAGE(Table2[colName2])":
25659
+ * return --> ["=AVERAGE(Table1", "colName1", ")-AVERAGE(Table2", "colName2", ")"]
25660
+ */
25661
+ function deconstructSheets(convertedSheets) {
25662
+ var _a;
25663
+ const deconstructedSheets = {};
25664
+ for (let sheet of convertedSheets) {
25665
+ for (let xc in sheet.cells) {
25666
+ const cellContent = (_a = sheet.cells[xc]) === null || _a === void 0 ? void 0 : _a.content;
25667
+ if (!cellContent || !cellContent.startsWith("=")) {
25668
+ continue;
25669
+ }
25670
+ const startIndex = cellContent.indexOf("[");
25671
+ if (startIndex === -1) {
25672
+ continue;
25673
+ }
25674
+ const deconstructedCell = [];
25675
+ let possibleTable = cellContent.slice(0, startIndex);
25676
+ let possibleRef = "";
25677
+ let openBrackets = 1;
25678
+ let mainPossibleTableIndex = 0;
25679
+ let mainOpenBracketIndex = startIndex;
25680
+ for (let index = startIndex + 1; index < cellContent.length; index++) {
25681
+ if (cellContent[index] === "[") {
25682
+ if (openBrackets === 0) {
25683
+ possibleTable = cellContent.slice(mainPossibleTableIndex, index);
25684
+ mainOpenBracketIndex = index;
25685
+ }
25686
+ openBrackets++;
25687
+ continue;
25688
+ }
25689
+ if (cellContent[index] === "]") {
25690
+ openBrackets--;
25691
+ if (openBrackets === 0) {
25692
+ possibleRef = cellContent.slice(mainOpenBracketIndex + 1, index);
25693
+ deconstructedCell.push(possibleTable);
25694
+ deconstructedCell.push(possibleRef);
25695
+ mainPossibleTableIndex = index + 1;
25630
25696
  }
25631
25697
  }
25632
25698
  }
25699
+ if (deconstructedCell.length) {
25700
+ if (!deconstructedSheets[sheet.id]) {
25701
+ deconstructedSheets[sheet.id] = {};
25702
+ }
25703
+ deconstructedCell.push(cellContent.slice(mainPossibleTableIndex));
25704
+ deconstructedSheets[sheet.id][xc] = [...deconstructedCell];
25705
+ }
25633
25706
  }
25634
25707
  }
25708
+ return deconstructedSheets;
25635
25709
  }
25636
25710
  /**
25637
25711
  * Convert table-specific references in formulas into standard references. A table reference is composed of columns names,
@@ -43889,9 +43963,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43889
43963
  Object.defineProperty(exports, '__esModule', { value: true });
43890
43964
 
43891
43965
 
43892
- __info__.version = '16.0.74';
43893
- __info__.date = '2025-06-27T09:02:46.788Z';
43894
- __info__.hash = 'a1d6303';
43966
+ __info__.version = '16.0.75';
43967
+ __info__.date = '2025-07-11T11:06:44.633Z';
43968
+ __info__.hash = 'c6d8a41';
43895
43969
 
43896
43970
 
43897
43971
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);