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