@odoo/o-spreadsheet 18.2.12 → 18.2.13

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.2.12
6
- * @date 2025-05-13T17:52:23.989Z
7
- * @hash ba2ba9b
5
+ * @version 18.2.13
6
+ * @date 2025-05-20T05:57:00.985Z
7
+ * @hash 9872529
8
8
  */
9
9
 
10
10
  import { useEnv, useSubEnv, onWillUnmount, useComponent, status, Component, useRef, onMounted, useEffect, App, blockDom, useState, onPatched, onWillPatch, onWillUpdateProps, useExternalListener, onWillStart, xml, useChildSubEnv, markRaw, toRaw } from '@odoo/owl';
@@ -1617,18 +1617,53 @@ function lettersToNumber(letters) {
1617
1617
  let result = 0;
1618
1618
  const l = letters.length;
1619
1619
  for (let i = 0; i < l; i++) {
1620
- const charCode = letters.charCodeAt(i);
1621
- const colIndex = charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1620
+ const colIndex = charToNumber(letters[i]);
1622
1621
  result = result * 26 + colIndex;
1623
1622
  }
1624
1623
  return result - 1;
1625
1624
  }
1625
+ function charToNumber(char) {
1626
+ const charCode = char.charCodeAt(0);
1627
+ return charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1628
+ }
1626
1629
  function isCharALetter(char) {
1627
1630
  return (char >= "A" && char <= "Z") || (char >= "a" && char <= "z");
1628
1631
  }
1629
1632
  function isCharADigit(char) {
1630
1633
  return char >= "0" && char <= "9";
1631
1634
  }
1635
+ // we limit the max column to 3 letters and max row to 7 digits for performance reasons
1636
+ const MAX_COL = lettersToNumber("ZZZ");
1637
+ const MAX_ROW = 9999998;
1638
+ function consumeSpaces(chars) {
1639
+ while (chars.current === " ") {
1640
+ chars.advanceBy(1);
1641
+ }
1642
+ }
1643
+ function consumeLetters(chars) {
1644
+ if (chars.current === "$")
1645
+ chars.advanceBy(1);
1646
+ if (!chars.current || !isCharALetter(chars.current)) {
1647
+ return -1;
1648
+ }
1649
+ let colCoordinate = 0;
1650
+ while (chars.current && isCharALetter(chars.current)) {
1651
+ colCoordinate = colCoordinate * 26 + charToNumber(chars.shift());
1652
+ }
1653
+ return colCoordinate;
1654
+ }
1655
+ function consumeDigits(chars) {
1656
+ if (chars.current === "$")
1657
+ chars.advanceBy(1);
1658
+ if (!chars.current || !isCharADigit(chars.current)) {
1659
+ return -1;
1660
+ }
1661
+ let num = 0;
1662
+ while (chars.current && isCharADigit(chars.current)) {
1663
+ num = num * 10 + Number(chars.shift());
1664
+ }
1665
+ return num;
1666
+ }
1632
1667
  /**
1633
1668
  * Convert a "XC" coordinate to cartesian coordinates.
1634
1669
  *
@@ -1639,33 +1674,17 @@ function isCharADigit(char) {
1639
1674
  * Note: it also accepts lowercase coordinates, but not fixed references
1640
1675
  */
1641
1676
  function toCartesian(xc) {
1642
- xc = xc.trim();
1643
- let letterPart = "";
1644
- let numberPart = "";
1645
- let i = 0;
1646
- // Process letter part
1647
- if (xc[i] === "$")
1648
- i++;
1649
- while (i < xc.length && isCharALetter(xc[i])) {
1650
- letterPart += xc[i++];
1651
- }
1652
- if (letterPart.length === 0 || letterPart.length > 3) {
1653
- // limit to max 3 letters for performance reasons
1677
+ const chars = new TokenizingChars(xc);
1678
+ consumeSpaces(chars);
1679
+ const letterPart = consumeLetters(chars);
1680
+ if (letterPart === -1 || !chars.current) {
1654
1681
  throw new Error(`Invalid cell description: ${xc}`);
1655
1682
  }
1656
- // Process number part
1657
- if (xc[i] === "$")
1658
- i++;
1659
- while (i < xc.length && isCharADigit(xc[i])) {
1660
- numberPart += xc[i++];
1661
- }
1662
- if (i !== xc.length || numberPart.length === 0 || numberPart.length > 7) {
1663
- // limit to max 7 numbers for performance reasons
1664
- throw new Error(`Invalid cell description: ${xc}`);
1665
- }
1666
- const col = lettersToNumber(letterPart);
1667
- const row = Number(numberPart) - 1;
1668
- if (isNaN(row)) {
1683
+ const num = consumeDigits(chars);
1684
+ consumeSpaces(chars);
1685
+ const col = letterPart - 1;
1686
+ const row = num - 1;
1687
+ if (!chars.isOver() || col > MAX_COL || row > MAX_ROW) {
1669
1688
  throw new Error(`Invalid cell description: ${xc}`);
1670
1689
  }
1671
1690
  return { col, row };
@@ -2077,67 +2096,6 @@ class LazyTranslatedString extends String {
2077
2096
  }
2078
2097
  }
2079
2098
 
2080
- /** Reference of a cell (eg. A1, $B$5) */
2081
- const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
2082
- // Same as above, but matches the exact string (nothing before or after)
2083
- const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
2084
- /** Reference of a column header (eg. A, AB, $A) */
2085
- const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
2086
- /** Reference of a row header (eg. 1, $1) */
2087
- const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
2088
- /** Reference of a column (eg. A, $CA, Sheet1!B) */
2089
- const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
2090
- /** Reference of a row (eg. 1, 59, Sheet1!9) */
2091
- const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
2092
- /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
2093
- const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
2094
- /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
2095
- const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
2096
- /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
2097
- const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
2098
- "(" +
2099
- [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
2100
- ")" +
2101
- /$/.source, "i");
2102
- /**
2103
- * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
2104
- */
2105
- function isColReference(xc) {
2106
- return colReference.test(xc);
2107
- }
2108
- /**
2109
- * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
2110
- */
2111
- function isRowReference(xc) {
2112
- return rowReference.test(xc);
2113
- }
2114
- function isColHeader(str) {
2115
- return colHeader.test(str);
2116
- }
2117
- function isRowHeader(str) {
2118
- return rowHeader.test(str);
2119
- }
2120
- /**
2121
- * Return true if the given xc is the reference of a single cell,
2122
- * without any specified sheet (e.g. A1)
2123
- */
2124
- function isSingleCellReference(xc) {
2125
- return singleCellReference.test(xc);
2126
- }
2127
- function splitReference(ref) {
2128
- if (!ref.includes("!")) {
2129
- return { xc: ref };
2130
- }
2131
- const parts = ref.split("!");
2132
- const xc = parts.pop();
2133
- const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
2134
- return { sheetName, xc };
2135
- }
2136
- /** Return a reference SheetName!xc from the given arguments */
2137
- function getFullReference(sheetName, xc) {
2138
- return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
2139
- }
2140
-
2141
2099
  /**
2142
2100
  * Convert from a cartesian reference to a Zone
2143
2101
  * The range boundaries will be kept in the same order as the
@@ -2155,63 +2113,55 @@ function getFullReference(sheetName, xc) {
2155
2113
  *
2156
2114
  */
2157
2115
  function toZoneWithoutBoundaryChanges(xc) {
2158
- if (xc.includes("!")) {
2159
- xc = xc.split("!").at(-1);
2160
- }
2161
- if (xc.includes("$")) {
2162
- xc = xc.replaceAll("$", "");
2163
- }
2164
- let firstRangePart = "";
2165
- let secondRangePart;
2166
- if (xc.includes(":")) {
2167
- [firstRangePart, secondRangePart] = xc.split(":");
2168
- firstRangePart = firstRangePart.trim();
2169
- secondRangePart = secondRangePart.trim();
2170
- }
2171
- else {
2172
- firstRangePart = xc.trim();
2173
- }
2116
+ const chars = new TokenizingChars(xc);
2117
+ consumeSpaces(chars);
2118
+ const sheetSeparatorIndex = xc.indexOf("!");
2119
+ if (sheetSeparatorIndex !== -1) {
2120
+ chars.advanceBy(sheetSeparatorIndex + 1);
2121
+ }
2122
+ const leftLetters = consumeLetters(chars);
2123
+ const leftNumbers = consumeDigits(chars);
2174
2124
  let top, bottom, left, right;
2175
2125
  let fullCol = false;
2176
2126
  let fullRow = false;
2177
2127
  let hasHeader = false;
2178
- if (isColReference(firstRangePart)) {
2179
- left = right = lettersToNumber(firstRangePart);
2128
+ if (leftNumbers === -1) {
2129
+ left = right = leftLetters - 1;
2180
2130
  top = bottom = 0;
2181
2131
  fullCol = true;
2182
2132
  }
2183
- else if (isRowReference(firstRangePart)) {
2184
- top = bottom = parseInt(firstRangePart, 10) - 1;
2133
+ else if (leftLetters === -1) {
2134
+ top = bottom = leftNumbers - 1;
2185
2135
  left = right = 0;
2186
2136
  fullRow = true;
2187
2137
  }
2188
2138
  else {
2189
- const c = toCartesian(firstRangePart);
2190
- left = right = c.col;
2191
- top = bottom = c.row;
2139
+ left = right = leftLetters - 1;
2140
+ top = bottom = leftNumbers - 1;
2192
2141
  hasHeader = true;
2193
2142
  }
2194
- if (secondRangePart) {
2195
- if (isColReference(secondRangePart)) {
2196
- right = lettersToNumber(secondRangePart);
2143
+ consumeSpaces(chars);
2144
+ if (chars.current === ":") {
2145
+ chars.advanceBy(1);
2146
+ consumeSpaces(chars);
2147
+ const rightLetters = consumeLetters(chars);
2148
+ const rightNumbers = consumeDigits(chars);
2149
+ if (rightNumbers === -1) {
2150
+ right = rightLetters - 1;
2197
2151
  fullCol = true;
2198
2152
  }
2199
- else if (isRowReference(secondRangePart)) {
2200
- bottom = parseInt(secondRangePart, 10) - 1;
2153
+ else if (rightLetters === -1) {
2154
+ bottom = rightNumbers - 1;
2201
2155
  fullRow = true;
2202
2156
  }
2203
2157
  else {
2204
- const c = toCartesian(secondRangePart);
2205
- right = c.col;
2206
- bottom = c.row;
2158
+ right = rightLetters - 1;
2159
+ bottom = rightNumbers - 1;
2207
2160
  top = fullCol ? bottom : top;
2208
2161
  left = fullRow ? right : left;
2209
2162
  hasHeader = true;
2210
2163
  }
2211
2164
  }
2212
- if (fullCol && fullRow) {
2213
- throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2214
- }
2215
2165
  const zone = {
2216
2166
  top,
2217
2167
  left,
@@ -2240,7 +2190,16 @@ function toZoneWithoutBoundaryChanges(xc) {
2240
2190
  */
2241
2191
  function toUnboundedZone(xc) {
2242
2192
  const zone = toZoneWithoutBoundaryChanges(xc);
2243
- return reorderZone(zone);
2193
+ const orderedZone = reorderZone(zone);
2194
+ const bottom = orderedZone.bottom;
2195
+ const right = orderedZone.right;
2196
+ if ((bottom !== undefined && bottom > MAX_ROW) || (right !== undefined && right > MAX_COL)) {
2197
+ throw new Error(`Range string out of bounds: ${xc}`); // limit the size of the zone for performance
2198
+ }
2199
+ if (bottom === undefined && right === undefined) {
2200
+ throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2201
+ }
2202
+ return orderedZone;
2244
2203
  }
2245
2204
  /**
2246
2205
  * Convert from a cartesian reference to a Zone.
@@ -5974,6 +5933,67 @@ function scrollDelay(value) {
5974
5933
  return MIN_DELAY + (MAX_DELAY - MIN_DELAY) * Math.exp(-ACCELERATION * (value - 1));
5975
5934
  }
5976
5935
 
5936
+ /** Reference of a cell (eg. A1, $B$5) */
5937
+ const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
5938
+ // Same as above, but matches the exact string (nothing before or after)
5939
+ const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
5940
+ /** Reference of a column header (eg. A, AB, $A) */
5941
+ const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
5942
+ /** Reference of a row header (eg. 1, $1) */
5943
+ const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
5944
+ /** Reference of a column (eg. A, $CA, Sheet1!B) */
5945
+ const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
5946
+ /** Reference of a row (eg. 1, 59, Sheet1!9) */
5947
+ const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
5948
+ /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
5949
+ const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
5950
+ /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
5951
+ const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
5952
+ /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
5953
+ const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
5954
+ "(" +
5955
+ [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
5956
+ ")" +
5957
+ /$/.source, "i");
5958
+ /**
5959
+ * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
5960
+ */
5961
+ function isColReference(xc) {
5962
+ return colReference.test(xc);
5963
+ }
5964
+ /**
5965
+ * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
5966
+ */
5967
+ function isRowReference(xc) {
5968
+ return rowReference.test(xc);
5969
+ }
5970
+ function isColHeader(str) {
5971
+ return colHeader.test(str);
5972
+ }
5973
+ function isRowHeader(str) {
5974
+ return rowHeader.test(str);
5975
+ }
5976
+ /**
5977
+ * Return true if the given xc is the reference of a single cell,
5978
+ * without any specified sheet (e.g. A1)
5979
+ */
5980
+ function isSingleCellReference(xc) {
5981
+ return singleCellReference.test(xc);
5982
+ }
5983
+ function splitReference(ref) {
5984
+ if (!ref.includes("!")) {
5985
+ return { xc: ref };
5986
+ }
5987
+ const parts = ref.split("!");
5988
+ const xc = parts.pop();
5989
+ const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
5990
+ return { sheetName, xc };
5991
+ }
5992
+ /** Return a reference SheetName!xc from the given arguments */
5993
+ function getFullReference(sheetName, xc) {
5994
+ return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
5995
+ }
5996
+
5977
5997
  class RangeImpl {
5978
5998
  getSheetSize;
5979
5999
  _zone;
@@ -41157,12 +41177,13 @@ class StandaloneComposerStore extends AbstractComposerStore {
41157
41177
  return res;
41158
41178
  }
41159
41179
  getComposerContent() {
41180
+ let content = this._currentContent;
41160
41181
  if (this.editionMode === "inactive") {
41161
41182
  // References in the content might not be linked to the current active sheet
41162
41183
  // We here force the sheet name prefix for all references that are not in
41163
41184
  // the current active sheet
41164
41185
  const defaultRangeSheetId = this.args().defaultRangeSheetId;
41165
- return rangeTokenize(this.args().content)
41186
+ content = rangeTokenize(this.args().content)
41166
41187
  .map((token) => {
41167
41188
  if (token.type === "REFERENCE") {
41168
41189
  const range = this.getters.getRangeFromSheetXC(defaultRangeSheetId, token.value);
@@ -41172,7 +41193,7 @@ class StandaloneComposerStore extends AbstractComposerStore {
41172
41193
  })
41173
41194
  .join("");
41174
41195
  }
41175
- return this._currentContent;
41196
+ return localizeContent(content, this.getters.getLocale());
41176
41197
  }
41177
41198
  stopEdition() {
41178
41199
  this._stopEdition();
@@ -45447,6 +45468,9 @@ class PivotMeasureEditor extends Component {
45447
45468
  }
45448
45469
  return undefined;
45449
45470
  }
45471
+ get isCalculatedMeasureInvalid() {
45472
+ return this.env.model.getters.getMeasureCompiledFormula(this.props.measure).isBadExpression;
45473
+ }
45450
45474
  }
45451
45475
 
45452
45476
  css /* scss */ `
@@ -60949,10 +60973,9 @@ class Evaluator {
60949
60973
  return this.evaluatedCells.keysForSheet(sheetId);
60950
60974
  }
60951
60975
  getArrayFormulaSpreadingOn(position) {
60952
- const hasArrayFormulaResult = this.getEvaluatedCell(position).type !== CellValueType.empty &&
60953
- !this.getters.getCell(position)?.isFormula;
60954
- if (!hasArrayFormulaResult) {
60955
- return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
60976
+ const isEmpty = this.getEvaluatedCell(position).type === CellValueType.empty;
60977
+ if (isEmpty) {
60978
+ return undefined;
60956
60979
  }
60957
60980
  const arrayFormulas = this.spreadingRelations.searchFormulaPositionsSpreadingOn(position.sheetId, positionToZone(position));
60958
60981
  return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
@@ -76757,6 +76780,6 @@ const chartHelpers = { ...CHART_HELPERS, ...CHART_RUNTIME_HELPERS };
76757
76780
  export { AbstractCellClipboardHandler, AbstractChart, AbstractFigureClipboardHandler, CellErrorType, CommandResult, CorePlugin, CoreViewPlugin, DispatchResult, EvaluationError, Model, PivotRuntimeDefinition, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, SpreadsheetPivotTable, UIPlugin, __info__, addFunction, addRenderingLayer, astToFormula, chartHelpers, compile, compileTokens, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, hooks, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, parseTokens, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, stores, tokenColors, tokenize };
76758
76781
 
76759
76782
 
76760
- __info__.version = "18.2.12";
76761
- __info__.date = "2025-05-13T17:52:23.989Z";
76762
- __info__.hash = "ba2ba9b";
76783
+ __info__.version = "18.2.13";
76784
+ __info__.date = "2025-05-20T05:57:00.985Z";
76785
+ __info__.hash = "9872529";