@odoo/o-spreadsheet 18.3.3 → 18.3.4

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.3.3
6
- * @date 2025-05-13T17:54:43.312Z
7
- * @hash b79924a
5
+ * @version 18.3.4
6
+ * @date 2025-05-20T05:57:03.751Z
7
+ * @hash 28f4521
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -1624,18 +1624,53 @@
1624
1624
  let result = 0;
1625
1625
  const l = letters.length;
1626
1626
  for (let i = 0; i < l; i++) {
1627
- const charCode = letters.charCodeAt(i);
1628
- const colIndex = charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1627
+ const colIndex = charToNumber(letters[i]);
1629
1628
  result = result * 26 + colIndex;
1630
1629
  }
1631
1630
  return result - 1;
1632
1631
  }
1632
+ function charToNumber(char) {
1633
+ const charCode = char.charCodeAt(0);
1634
+ return charCode >= 65 && charCode <= 90 ? charCode - 64 : charCode - 96;
1635
+ }
1633
1636
  function isCharALetter(char) {
1634
1637
  return (char >= "A" && char <= "Z") || (char >= "a" && char <= "z");
1635
1638
  }
1636
1639
  function isCharADigit(char) {
1637
1640
  return char >= "0" && char <= "9";
1638
1641
  }
1642
+ // we limit the max column to 3 letters and max row to 7 digits for performance reasons
1643
+ const MAX_COL = lettersToNumber("ZZZ");
1644
+ const MAX_ROW = 9999998;
1645
+ function consumeSpaces(chars) {
1646
+ while (chars.current === " ") {
1647
+ chars.advanceBy(1);
1648
+ }
1649
+ }
1650
+ function consumeLetters(chars) {
1651
+ if (chars.current === "$")
1652
+ chars.advanceBy(1);
1653
+ if (!chars.current || !isCharALetter(chars.current)) {
1654
+ return -1;
1655
+ }
1656
+ let colCoordinate = 0;
1657
+ while (chars.current && isCharALetter(chars.current)) {
1658
+ colCoordinate = colCoordinate * 26 + charToNumber(chars.shift());
1659
+ }
1660
+ return colCoordinate;
1661
+ }
1662
+ function consumeDigits(chars) {
1663
+ if (chars.current === "$")
1664
+ chars.advanceBy(1);
1665
+ if (!chars.current || !isCharADigit(chars.current)) {
1666
+ return -1;
1667
+ }
1668
+ let num = 0;
1669
+ while (chars.current && isCharADigit(chars.current)) {
1670
+ num = num * 10 + Number(chars.shift());
1671
+ }
1672
+ return num;
1673
+ }
1639
1674
  /**
1640
1675
  * Convert a "XC" coordinate to cartesian coordinates.
1641
1676
  *
@@ -1646,33 +1681,17 @@
1646
1681
  * Note: it also accepts lowercase coordinates, but not fixed references
1647
1682
  */
1648
1683
  function toCartesian(xc) {
1649
- xc = xc.trim();
1650
- let letterPart = "";
1651
- let numberPart = "";
1652
- let i = 0;
1653
- // Process letter part
1654
- if (xc[i] === "$")
1655
- i++;
1656
- while (i < xc.length && isCharALetter(xc[i])) {
1657
- letterPart += xc[i++];
1658
- }
1659
- if (letterPart.length === 0 || letterPart.length > 3) {
1660
- // limit to max 3 letters for performance reasons
1684
+ const chars = new TokenizingChars(xc);
1685
+ consumeSpaces(chars);
1686
+ const letterPart = consumeLetters(chars);
1687
+ if (letterPart === -1 || !chars.current) {
1661
1688
  throw new Error(`Invalid cell description: ${xc}`);
1662
1689
  }
1663
- // Process number part
1664
- if (xc[i] === "$")
1665
- i++;
1666
- while (i < xc.length && isCharADigit(xc[i])) {
1667
- numberPart += xc[i++];
1668
- }
1669
- if (i !== xc.length || numberPart.length === 0 || numberPart.length > 7) {
1670
- // limit to max 7 numbers for performance reasons
1671
- throw new Error(`Invalid cell description: ${xc}`);
1672
- }
1673
- const col = lettersToNumber(letterPart);
1674
- const row = Number(numberPart) - 1;
1675
- if (isNaN(row)) {
1690
+ const num = consumeDigits(chars);
1691
+ consumeSpaces(chars);
1692
+ const col = letterPart - 1;
1693
+ const row = num - 1;
1694
+ if (!chars.isOver() || col > MAX_COL || row > MAX_ROW) {
1676
1695
  throw new Error(`Invalid cell description: ${xc}`);
1677
1696
  }
1678
1697
  return { col, row };
@@ -2027,67 +2046,6 @@
2027
2046
  return result;
2028
2047
  }
2029
2048
 
2030
- /** Reference of a cell (eg. A1, $B$5) */
2031
- const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
2032
- // Same as above, but matches the exact string (nothing before or after)
2033
- const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
2034
- /** Reference of a column header (eg. A, AB, $A) */
2035
- const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
2036
- /** Reference of a row header (eg. 1, $1) */
2037
- const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
2038
- /** Reference of a column (eg. A, $CA, Sheet1!B) */
2039
- const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
2040
- /** Reference of a row (eg. 1, 59, Sheet1!9) */
2041
- const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
2042
- /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
2043
- const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
2044
- /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
2045
- const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
2046
- /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
2047
- const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
2048
- "(" +
2049
- [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
2050
- ")" +
2051
- /$/.source, "i");
2052
- /**
2053
- * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
2054
- */
2055
- function isColReference(xc) {
2056
- return colReference.test(xc);
2057
- }
2058
- /**
2059
- * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
2060
- */
2061
- function isRowReference(xc) {
2062
- return rowReference.test(xc);
2063
- }
2064
- function isColHeader(str) {
2065
- return colHeader.test(str);
2066
- }
2067
- function isRowHeader(str) {
2068
- return rowHeader.test(str);
2069
- }
2070
- /**
2071
- * Return true if the given xc is the reference of a single cell,
2072
- * without any specified sheet (e.g. A1)
2073
- */
2074
- function isSingleCellReference(xc) {
2075
- return singleCellReference.test(xc);
2076
- }
2077
- function splitReference(ref) {
2078
- if (!ref.includes("!")) {
2079
- return { xc: ref };
2080
- }
2081
- const parts = ref.split("!");
2082
- const xc = parts.pop();
2083
- const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
2084
- return { sheetName, xc };
2085
- }
2086
- /** Return a reference SheetName!xc from the given arguments */
2087
- function getFullReference(sheetName, xc) {
2088
- return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
2089
- }
2090
-
2091
2049
  /**
2092
2050
  * Convert from a cartesian reference to a Zone
2093
2051
  * The range boundaries will be kept in the same order as the
@@ -2105,63 +2063,55 @@
2105
2063
  *
2106
2064
  */
2107
2065
  function toZoneWithoutBoundaryChanges(xc) {
2108
- if (xc.includes("!")) {
2109
- xc = xc.split("!").at(-1);
2110
- }
2111
- if (xc.includes("$")) {
2112
- xc = xc.replaceAll("$", "");
2113
- }
2114
- let firstRangePart = "";
2115
- let secondRangePart;
2116
- if (xc.includes(":")) {
2117
- [firstRangePart, secondRangePart] = xc.split(":");
2118
- firstRangePart = firstRangePart.trim();
2119
- secondRangePart = secondRangePart.trim();
2120
- }
2121
- else {
2122
- firstRangePart = xc.trim();
2123
- }
2066
+ const chars = new TokenizingChars(xc);
2067
+ consumeSpaces(chars);
2068
+ const sheetSeparatorIndex = xc.indexOf("!");
2069
+ if (sheetSeparatorIndex !== -1) {
2070
+ chars.advanceBy(sheetSeparatorIndex + 1);
2071
+ }
2072
+ const leftLetters = consumeLetters(chars);
2073
+ const leftNumbers = consumeDigits(chars);
2124
2074
  let top, bottom, left, right;
2125
2075
  let fullCol = false;
2126
2076
  let fullRow = false;
2127
2077
  let hasHeader = false;
2128
- if (isColReference(firstRangePart)) {
2129
- left = right = lettersToNumber(firstRangePart);
2078
+ if (leftNumbers === -1) {
2079
+ left = right = leftLetters - 1;
2130
2080
  top = bottom = 0;
2131
2081
  fullCol = true;
2132
2082
  }
2133
- else if (isRowReference(firstRangePart)) {
2134
- top = bottom = parseInt(firstRangePart, 10) - 1;
2083
+ else if (leftLetters === -1) {
2084
+ top = bottom = leftNumbers - 1;
2135
2085
  left = right = 0;
2136
2086
  fullRow = true;
2137
2087
  }
2138
2088
  else {
2139
- const c = toCartesian(firstRangePart);
2140
- left = right = c.col;
2141
- top = bottom = c.row;
2089
+ left = right = leftLetters - 1;
2090
+ top = bottom = leftNumbers - 1;
2142
2091
  hasHeader = true;
2143
2092
  }
2144
- if (secondRangePart) {
2145
- if (isColReference(secondRangePart)) {
2146
- right = lettersToNumber(secondRangePart);
2093
+ consumeSpaces(chars);
2094
+ if (chars.current === ":") {
2095
+ chars.advanceBy(1);
2096
+ consumeSpaces(chars);
2097
+ const rightLetters = consumeLetters(chars);
2098
+ const rightNumbers = consumeDigits(chars);
2099
+ if (rightNumbers === -1) {
2100
+ right = rightLetters - 1;
2147
2101
  fullCol = true;
2148
2102
  }
2149
- else if (isRowReference(secondRangePart)) {
2150
- bottom = parseInt(secondRangePart, 10) - 1;
2103
+ else if (rightLetters === -1) {
2104
+ bottom = rightNumbers - 1;
2151
2105
  fullRow = true;
2152
2106
  }
2153
2107
  else {
2154
- const c = toCartesian(secondRangePart);
2155
- right = c.col;
2156
- bottom = c.row;
2108
+ right = rightLetters - 1;
2109
+ bottom = rightNumbers - 1;
2157
2110
  top = fullCol ? bottom : top;
2158
2111
  left = fullRow ? right : left;
2159
2112
  hasHeader = true;
2160
2113
  }
2161
2114
  }
2162
- if (fullCol && fullRow) {
2163
- throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2164
- }
2165
2115
  const zone = {
2166
2116
  top,
2167
2117
  left,
@@ -2190,7 +2140,16 @@
2190
2140
  */
2191
2141
  function toUnboundedZone(xc) {
2192
2142
  const zone = toZoneWithoutBoundaryChanges(xc);
2193
- return reorderZone(zone);
2143
+ const orderedZone = reorderZone(zone);
2144
+ const bottom = orderedZone.bottom;
2145
+ const right = orderedZone.right;
2146
+ if ((bottom !== undefined && bottom > MAX_ROW) || (right !== undefined && right > MAX_COL)) {
2147
+ throw new Error(`Range string out of bounds: ${xc}`); // limit the size of the zone for performance
2148
+ }
2149
+ if (bottom === undefined && right === undefined) {
2150
+ throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");
2151
+ }
2152
+ return orderedZone;
2194
2153
  }
2195
2154
  /**
2196
2155
  * Convert from a cartesian reference to a Zone.
@@ -6001,6 +5960,67 @@
6001
5960
  return MIN_DELAY + (MAX_DELAY - MIN_DELAY) * Math.exp(-ACCELERATION * (value - 1));
6002
5961
  }
6003
5962
 
5963
+ /** Reference of a cell (eg. A1, $B$5) */
5964
+ const cellReference = new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/, "i");
5965
+ // Same as above, but matches the exact string (nothing before or after)
5966
+ const singleCellReference = new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/, "i");
5967
+ /** Reference of a column header (eg. A, AB, $A) */
5968
+ const colHeader = new RegExp(/^\$?([A-Z]{1,3})+$/, "i");
5969
+ /** Reference of a row header (eg. 1, $1) */
5970
+ const rowHeader = new RegExp(/^\$?([0-9]{1,7})+$/, "i");
5971
+ /** Reference of a column (eg. A, $CA, Sheet1!B) */
5972
+ const colReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/, "i");
5973
+ /** Reference of a row (eg. 1, 59, Sheet1!9) */
5974
+ const rowReference = new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/, "i");
5975
+ /** Reference of a normal range or a full row range (eg. A1:B1, 1:$5, $A2:5) */
5976
+ const fullRowXc = /(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*:\s*(\$?[A-Z]{1,3})?\$?[0-9]{1,7}\s*/i;
5977
+ /** Reference of a normal range or a column row range (eg. A1:B1, A:$B, $A1:C) */
5978
+ const fullColXc = /\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*:\s*\$?[A-Z]{1,3}(\$?[0-9]{1,7})?\s*/i;
5979
+ /** Reference of a cell or a range, it can be a bounded range, a full row or a full column */
5980
+ const rangeReference = new RegExp(/^\s*('.+'!|[^']+!)?/.source +
5981
+ "(" +
5982
+ [cellReference.source, fullRowXc.source, fullColXc.source].join("|") +
5983
+ ")" +
5984
+ /$/.source, "i");
5985
+ /**
5986
+ * Return true if the given xc is the reference of a column (e.g. A or AC or Sheet1!A)
5987
+ */
5988
+ function isColReference(xc) {
5989
+ return colReference.test(xc);
5990
+ }
5991
+ /**
5992
+ * Return true if the given xc is the reference of a column (e.g. 1 or Sheet1!1)
5993
+ */
5994
+ function isRowReference(xc) {
5995
+ return rowReference.test(xc);
5996
+ }
5997
+ function isColHeader(str) {
5998
+ return colHeader.test(str);
5999
+ }
6000
+ function isRowHeader(str) {
6001
+ return rowHeader.test(str);
6002
+ }
6003
+ /**
6004
+ * Return true if the given xc is the reference of a single cell,
6005
+ * without any specified sheet (e.g. A1)
6006
+ */
6007
+ function isSingleCellReference(xc) {
6008
+ return singleCellReference.test(xc);
6009
+ }
6010
+ function splitReference(ref) {
6011
+ if (!ref.includes("!")) {
6012
+ return { xc: ref };
6013
+ }
6014
+ const parts = ref.split("!");
6015
+ const xc = parts.pop();
6016
+ const sheetName = getUnquotedSheetName(parts.join("!")) || undefined;
6017
+ return { sheetName, xc };
6018
+ }
6019
+ /** Return a reference SheetName!xc from the given arguments */
6020
+ function getFullReference(sheetName, xc) {
6021
+ return sheetName !== undefined ? `${getCanonicalSymbolName(sheetName)}!${xc}` : xc;
6022
+ }
6023
+
6004
6024
  function createDefaultRows(rowNumber) {
6005
6025
  const rows = [];
6006
6026
  for (let i = 0; i < rowNumber; i++) {
@@ -43609,12 +43629,13 @@ stores.inject(MyMetaStore, storeInstance);
43609
43629
  return res;
43610
43630
  }
43611
43631
  getComposerContent() {
43632
+ let content = this._currentContent;
43612
43633
  if (this.editionMode === "inactive") {
43613
43634
  // References in the content might not be linked to the current active sheet
43614
43635
  // We here force the sheet name prefix for all references that are not in
43615
43636
  // the current active sheet
43616
43637
  const defaultRangeSheetId = this.args().defaultRangeSheetId;
43617
- return rangeTokenize(this.args().content)
43638
+ content = rangeTokenize(this.args().content)
43618
43639
  .map((token) => {
43619
43640
  if (token.type === "REFERENCE") {
43620
43641
  const range = this.getters.getRangeFromSheetXC(defaultRangeSheetId, token.value);
@@ -43624,7 +43645,7 @@ stores.inject(MyMetaStore, storeInstance);
43624
43645
  })
43625
43646
  .join("");
43626
43647
  }
43627
- return this._currentContent;
43648
+ return localizeContent(content, this.getters.getLocale());
43628
43649
  }
43629
43650
  stopEdition() {
43630
43651
  this._stopEdition();
@@ -48089,6 +48110,9 @@ stores.inject(MyMetaStore, storeInstance);
48089
48110
  }
48090
48111
  return undefined;
48091
48112
  }
48113
+ get isCalculatedMeasureInvalid() {
48114
+ return this.env.model.getters.getMeasureCompiledFormula(this.props.measure).isBadExpression;
48115
+ }
48092
48116
  }
48093
48117
 
48094
48118
  css /* scss */ `
@@ -52526,14 +52550,14 @@ stores.inject(MyMetaStore, storeInstance);
52526
52550
  const deltaX = Math.min(dirX * (mouseInitialX - mouseX + scrollX - initialScrollX), width - minFigSize);
52527
52551
  const deltaY = Math.min(dirY * (mouseInitialY - mouseY + scrollY - initialScrollY), height - minFigSize);
52528
52552
  const fraction = Math.min(deltaX / width, deltaY / height);
52529
- width = width * (1 - fraction);
52530
- height = height * (1 - fraction);
52531
52553
  if (dirX < 0) {
52532
52554
  x = x + width * fraction;
52533
52555
  }
52534
52556
  if (dirY < 0) {
52535
52557
  y = y + height * fraction;
52536
52558
  }
52559
+ width = width * (1 - fraction);
52560
+ height = height * (1 - fraction);
52537
52561
  }
52538
52562
  else {
52539
52563
  const deltaX = Math.max(dirX * (mouseX - mouseInitialX + scrollX - initialScrollX), minFigSize - width);
@@ -63775,10 +63799,9 @@ stores.inject(MyMetaStore, storeInstance);
63775
63799
  return this.evaluatedCells.keysForSheet(sheetId);
63776
63800
  }
63777
63801
  getArrayFormulaSpreadingOn(position) {
63778
- const hasArrayFormulaResult = this.getEvaluatedCell(position).type !== CellValueType.empty &&
63779
- !this.getters.getCell(position)?.isFormula;
63780
- if (!hasArrayFormulaResult) {
63781
- return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
63802
+ const isEmpty = this.getEvaluatedCell(position).type === CellValueType.empty;
63803
+ if (isEmpty) {
63804
+ return undefined;
63782
63805
  }
63783
63806
  const arrayFormulas = this.spreadingRelations.searchFormulaPositionsSpreadingOn(position.sheetId, positionToZone(position));
63784
63807
  return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
@@ -80438,9 +80461,9 @@ stores.inject(MyMetaStore, storeInstance);
80438
80461
  exports.tokenize = tokenize;
80439
80462
 
80440
80463
 
80441
- __info__.version = "18.3.3";
80442
- __info__.date = "2025-05-13T17:54:43.312Z";
80443
- __info__.hash = "b79924a";
80464
+ __info__.version = "18.3.4";
80465
+ __info__.date = "2025-05-20T05:57:03.751Z";
80466
+ __info__.hash = "28f4521";
80444
80467
 
80445
80468
 
80446
80469
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);