@odoo/o-spreadsheet 18.1.20 → 18.1.21

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.1.20
6
- * @date 2025-05-13T17:52:28.174Z
7
- * @hash 3e43a46
5
+ * @version 18.1.21
6
+ * @date 2025-05-20T05:54:45.398Z
7
+ * @hash 89ed6a9
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1607,18 +1607,53 @@
1607
1607
  let result = 0;
1608
1608
  const l = letters.length;
1609
1609
  for (let i = 0; i < l; i++) {
1610
- const charCode = letters.charCodeAt(i);
1611
- const colIndex = charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1610
+ const colIndex = charToNumber(letters[i]);
1612
1611
  result = result * 26 + colIndex;
1613
1612
  }
1614
1613
  return result - 1;
1615
1614
  }
1615
+ function charToNumber(char) {
1616
+ const charCode = char.charCodeAt(0);
1617
+ return charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1618
+ }
1616
1619
  function isCharALetter(char) {
1617
1620
  return (char >= "A" && char <= "Z") || (char >= "a" && char <= "z");
1618
1621
  }
1619
1622
  function isCharADigit(char) {
1620
1623
  return char >= "0" && char <= "9";
1621
1624
  }
1625
+ // we limit the max column to 3 letters and max row to 7 digits for performance reasons
1626
+ const MAX_COL = lettersToNumber("ZZZ");
1627
+ const MAX_ROW = 9999998;
1628
+ function consumeSpaces(chars) {
1629
+ while (chars.current === " ") {
1630
+ chars.advanceBy(1);
1631
+ }
1632
+ }
1633
+ function consumeLetters(chars) {
1634
+ if (chars.current === "$")
1635
+ chars.advanceBy(1);
1636
+ if (!chars.current || !isCharALetter(chars.current)) {
1637
+ return -1;
1638
+ }
1639
+ let colCoordinate = 0;
1640
+ while (chars.current && isCharALetter(chars.current)) {
1641
+ colCoordinate = colCoordinate * 26 + charToNumber(chars.shift());
1642
+ }
1643
+ return colCoordinate;
1644
+ }
1645
+ function consumeDigits(chars) {
1646
+ if (chars.current === "$")
1647
+ chars.advanceBy(1);
1648
+ if (!chars.current || !isCharADigit(chars.current)) {
1649
+ return -1;
1650
+ }
1651
+ let num = 0;
1652
+ while (chars.current && isCharADigit(chars.current)) {
1653
+ num = num * 10 + Number(chars.shift());
1654
+ }
1655
+ return num;
1656
+ }
1622
1657
  /**
1623
1658
  * Convert a "XC" coordinate to cartesian coordinates.
1624
1659
  *
@@ -1629,33 +1664,17 @@
1629
1664
  * Note: it also accepts lowercase coordinates, but not fixed references
1630
1665
  */
1631
1666
  function toCartesian(xc) {
1632
- xc = xc.trim();
1633
- let letterPart = "";
1634
- let numberPart = "";
1635
- let i = 0;
1636
- // Process letter part
1637
- if (xc[i] === "$")
1638
- i++;
1639
- while (i < xc.length && isCharALetter(xc[i])) {
1640
- letterPart += xc[i++];
1641
- }
1642
- if (letterPart.length === 0 || letterPart.length > 3) {
1643
- // limit to max 3 letters for performance reasons
1667
+ const chars = new TokenizingChars(xc);
1668
+ consumeSpaces(chars);
1669
+ const letterPart = consumeLetters(chars);
1670
+ if (letterPart === -1 || !chars.current) {
1644
1671
  throw new Error(`Invalid cell description: ${xc}`);
1645
1672
  }
1646
- // Process number part
1647
- if (xc[i] === "$")
1648
- i++;
1649
- while (i < xc.length && isCharADigit(xc[i])) {
1650
- numberPart += xc[i++];
1651
- }
1652
- if (i !== xc.length || numberPart.length === 0 || numberPart.length > 7) {
1653
- // limit to max 7 numbers for performance reasons
1654
- throw new Error(`Invalid cell description: ${xc}`);
1655
- }
1656
- const col = lettersToNumber(letterPart);
1657
- const row = Number(numberPart) - 1;
1658
- if (isNaN(row)) {
1673
+ const num = consumeDigits(chars);
1674
+ consumeSpaces(chars);
1675
+ const col = letterPart - 1;
1676
+ const row = num - 1;
1677
+ if (!chars.isOver() || col > MAX_COL || row > MAX_ROW) {
1659
1678
  throw new Error(`Invalid cell description: ${xc}`);
1660
1679
  }
1661
1680
  return { col, row };
@@ -2067,67 +2086,6 @@
2067
2086
  }
2068
2087
  }
2069
2088
 
2070
- /** Reference of a cell (eg. A1, $B$5) */
2071
- const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
2072
- // Same as above, but matches the exact string (nothing before or after)
2073
- const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
2074
- /** Reference of a column header (eg. A, AB, $A) */
2075
- const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
2076
- /** Reference of a row header (eg. 1, $1) */
2077
- const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
2078
- /** Reference of a column (eg. A, $CA, Sheet1!B) */
2079
- const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
2080
- /** Reference of a row (eg. 1, 59, Sheet1!9) */
2081
- const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
2082
- /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
2083
- const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
2084
- /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
2085
- const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
2086
- /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
2087
- const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
2088
- "(" +
2089
- [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
2090
- ")" +
2091
- /$/.source, "i");
2092
- /**
2093
- * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
2094
- */
2095
- function isColReference(xc) {
2096
- return colReference.test(xc);
2097
- }
2098
- /**
2099
- * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
2100
- */
2101
- function isRowReference(xc) {
2102
- return rowReference.test(xc);
2103
- }
2104
- function isColHeader(str) {
2105
- return colHeader.test(str);
2106
- }
2107
- function isRowHeader(str) {
2108
- return rowHeader.test(str);
2109
- }
2110
- /**
2111
- * Return true if the given xc is the reference of a single cell,
2112
- * without any specified sheet (e.g. A1)
2113
- */
2114
- function isSingleCellReference(xc) {
2115
- return singleCellReference.test(xc);
2116
- }
2117
- function splitReference(ref) {
2118
- if (!ref.includes("!")) {
2119
- return { xc: ref };
2120
- }
2121
- const parts = ref.split("!");
2122
- const xc = parts.pop();
2123
- const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
2124
- return { sheetName, xc };
2125
- }
2126
- /** Return a reference SheetName!xc from the given arguments */
2127
- function getFullReference(sheetName, xc) {
2128
- return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
2129
- }
2130
-
2131
2089
  /**
2132
2090
  * Convert from a cartesian reference to a Zone
2133
2091
  * The range boundaries will be kept in the same order as the
@@ -2145,63 +2103,55 @@
2145
2103
  *
2146
2104
  */
2147
2105
  function toZoneWithoutBoundaryChanges(xc) {
2148
- if (xc.includes("!")) {
2149
- xc = xc.split("!").at(-1);
2150
- }
2151
- if (xc.includes("$")) {
2152
- xc = xc.replaceAll("$", "");
2153
- }
2154
- let firstRangePart = "";
2155
- let secondRangePart;
2156
- if (xc.includes(":")) {
2157
- [firstRangePart, secondRangePart] = xc.split(":");
2158
- firstRangePart = firstRangePart.trim();
2159
- secondRangePart = secondRangePart.trim();
2160
- }
2161
- else {
2162
- firstRangePart = xc.trim();
2163
- }
2106
+ const chars = new TokenizingChars(xc);
2107
+ consumeSpaces(chars);
2108
+ const sheetSeparatorIndex = xc.indexOf("!");
2109
+ if (sheetSeparatorIndex !== -1) {
2110
+ chars.advanceBy(sheetSeparatorIndex + 1);
2111
+ }
2112
+ const leftLetters = consumeLetters(chars);
2113
+ const leftNumbers = consumeDigits(chars);
2164
2114
  let top, bottom, left, right;
2165
2115
  let fullCol = false;
2166
2116
  let fullRow = false;
2167
2117
  let hasHeader = false;
2168
- if (isColReference(firstRangePart)) {
2169
- left = right = lettersToNumber(firstRangePart);
2118
+ if (leftNumbers === -1) {
2119
+ left = right = leftLetters - 1;
2170
2120
  top = bottom = 0;
2171
2121
  fullCol = true;
2172
2122
  }
2173
- else if (isRowReference(firstRangePart)) {
2174
- top = bottom = parseInt(firstRangePart, 10) - 1;
2123
+ else if (leftLetters === -1) {
2124
+ top = bottom = leftNumbers - 1;
2175
2125
  left = right = 0;
2176
2126
  fullRow = true;
2177
2127
  }
2178
2128
  else {
2179
- const c = toCartesian(firstRangePart);
2180
- left = right = c.col;
2181
- top = bottom = c.row;
2129
+ left = right = leftLetters - 1;
2130
+ top = bottom = leftNumbers - 1;
2182
2131
  hasHeader = true;
2183
2132
  }
2184
- if (secondRangePart) {
2185
- if (isColReference(secondRangePart)) {
2186
- right = lettersToNumber(secondRangePart);
2133
+ consumeSpaces(chars);
2134
+ if (chars.current === ":") {
2135
+ chars.advanceBy(1);
2136
+ consumeSpaces(chars);
2137
+ const rightLetters = consumeLetters(chars);
2138
+ const rightNumbers = consumeDigits(chars);
2139
+ if (rightNumbers === -1) {
2140
+ right = rightLetters - 1;
2187
2141
  fullCol = true;
2188
2142
  }
2189
- else if (isRowReference(secondRangePart)) {
2190
- bottom = parseInt(secondRangePart, 10) - 1;
2143
+ else if (rightLetters === -1) {
2144
+ bottom = rightNumbers - 1;
2191
2145
  fullRow = true;
2192
2146
  }
2193
2147
  else {
2194
- const c = toCartesian(secondRangePart);
2195
- right = c.col;
2196
- bottom = c.row;
2148
+ right = rightLetters - 1;
2149
+ bottom = rightNumbers - 1;
2197
2150
  top = fullCol ? bottom : top;
2198
2151
  left = fullRow ? right : left;
2199
2152
  hasHeader = true;
2200
2153
  }
2201
2154
  }
2202
- if (fullCol && fullRow) {
2203
- throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2204
- }
2205
2155
  const zone = {
2206
2156
  top,
2207
2157
  left,
@@ -2230,7 +2180,16 @@
2230
2180
  */
2231
2181
  function toUnboundedZone(xc) {
2232
2182
  const zone = toZoneWithoutBoundaryChanges(xc);
2233
- return reorderZone(zone);
2183
+ const orderedZone = reorderZone(zone);
2184
+ const bottom = orderedZone.bottom;
2185
+ const right = orderedZone.right;
2186
+ if ((bottom !== undefined && bottom > MAX_ROW) || (right !== undefined && right > MAX_COL)) {
2187
+ throw new Error(`Range string out of bounds: ${xc}`); // limit the size of the zone for performance
2188
+ }
2189
+ if (bottom === undefined && right === undefined) {
2190
+ throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2191
+ }
2192
+ return orderedZone;
2234
2193
  }
2235
2194
  /**
2236
2195
  * Convert from a cartesian reference to a Zone.
@@ -5966,6 +5925,67 @@
5966
5925
  return MIN_DELAY + (MAX_DELAY - MIN_DELAY) * Math.exp(-ACCELERATION * (value - 1));
5967
5926
  }
5968
5927
 
5928
+ /** Reference of a cell (eg. A1, $B$5) */
5929
+ const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
5930
+ // Same as above, but matches the exact string (nothing before or after)
5931
+ const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
5932
+ /** Reference of a column header (eg. A, AB, $A) */
5933
+ const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
5934
+ /** Reference of a row header (eg. 1, $1) */
5935
+ const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
5936
+ /** Reference of a column (eg. A, $CA, Sheet1!B) */
5937
+ const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
5938
+ /** Reference of a row (eg. 1, 59, Sheet1!9) */
5939
+ const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
5940
+ /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
5941
+ const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
5942
+ /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
5943
+ const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
5944
+ /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
5945
+ const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
5946
+ "(" +
5947
+ [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
5948
+ ")" +
5949
+ /$/.source, "i");
5950
+ /**
5951
+ * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
5952
+ */
5953
+ function isColReference(xc) {
5954
+ return colReference.test(xc);
5955
+ }
5956
+ /**
5957
+ * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
5958
+ */
5959
+ function isRowReference(xc) {
5960
+ return rowReference.test(xc);
5961
+ }
5962
+ function isColHeader(str) {
5963
+ return colHeader.test(str);
5964
+ }
5965
+ function isRowHeader(str) {
5966
+ return rowHeader.test(str);
5967
+ }
5968
+ /**
5969
+ * Return true if the given xc is the reference of a single cell,
5970
+ * without any specified sheet (e.g. A1)
5971
+ */
5972
+ function isSingleCellReference(xc) {
5973
+ return singleCellReference.test(xc);
5974
+ }
5975
+ function splitReference(ref) {
5976
+ if (!ref.includes("!")) {
5977
+ return { xc: ref };
5978
+ }
5979
+ const parts = ref.split("!");
5980
+ const xc = parts.pop();
5981
+ const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
5982
+ return { sheetName, xc };
5983
+ }
5984
+ /** Return a reference SheetName!xc from the given arguments */
5985
+ function getFullReference(sheetName, xc) {
5986
+ return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
5987
+ }
5988
+
5969
5989
  class RangeImpl {
5970
5990
  getSheetSize;
5971
5991
  _zone;
@@ -41345,12 +41365,13 @@ stores.inject(MyMetaStore, storeInstance);
41345
41365
  return providersDefinitions;
41346
41366
  }
41347
41367
  getComposerContent() {
41368
+ let content = this._currentContent;
41348
41369
  if (this.editionMode === "inactive") {
41349
41370
  // References in the content might not be linked to the current active sheet
41350
41371
  // We here force the sheet name prefix for all references that are not in
41351
41372
  // the current active sheet
41352
41373
  const defaultRangeSheetId = this.args().defaultRangeSheetId;
41353
- return rangeTokenize(this.args().content)
41374
+ content = rangeTokenize(this.args().content)
41354
41375
  .map((token) => {
41355
41376
  if (token.type === "REFERENCE") {
41356
41377
  const range = this.getters.getRangeFromSheetXC(defaultRangeSheetId, token.value);
@@ -41360,7 +41381,7 @@ stores.inject(MyMetaStore, storeInstance);
41360
41381
  })
41361
41382
  .join("");
41362
41383
  }
41363
- return this._currentContent;
41384
+ return localizeContent(content, this.getters.getLocale());
41364
41385
  }
41365
41386
  stopEdition() {
41366
41387
  this._stopEdition();
@@ -45106,6 +45127,9 @@ stores.inject(MyMetaStore, storeInstance);
45106
45127
  }
45107
45128
  return undefined;
45108
45129
  }
45130
+ get isCalculatedMeasureInvalid() {
45131
+ return this.env.model.getters.getMeasureCompiledFormula(this.props.measure).isBadExpression;
45132
+ }
45109
45133
  }
45110
45134
 
45111
45135
  css /* scss */ `
@@ -60478,10 +60502,9 @@ stores.inject(MyMetaStore, storeInstance);
60478
60502
  return this.evaluatedCells.keysForSheet(sheetId);
60479
60503
  }
60480
60504
  getArrayFormulaSpreadingOn(position) {
60481
- const hasArrayFormulaResult = this.getEvaluatedCell(position).type !== CellValueType.empty &&
60482
- !this.getters.getCell(position)?.isFormula;
60483
- if (!hasArrayFormulaResult) {
60484
- return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
60505
+ const isEmpty = this.getEvaluatedCell(position).type === CellValueType.empty;
60506
+ if (isEmpty) {
60507
+ return undefined;
60485
60508
  }
60486
60509
  const arrayFormulas = this.spreadingRelations.searchFormulaPositionsSpreadingOn(position.sheetId, positionToZone(position));
60487
60510
  return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
@@ -76325,9 +76348,9 @@ stores.inject(MyMetaStore, storeInstance);
76325
76348
  exports.tokenize = tokenize;
76326
76349
 
76327
76350
 
76328
- __info__.version = "18.1.20";
76329
- __info__.date = "2025-05-13T17:52:28.174Z";
76330
- __info__.hash = "3e43a46";
76351
+ __info__.version = "18.1.21";
76352
+ __info__.date = "2025-05-20T05:54:45.398Z";
76353
+ __info__.hash = "89ed6a9";
76331
76354
 
76332
76355
 
76333
76356
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);