@odoo/o-spreadsheet 16.3.13 → 16.3.14

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.
@@ -4433,6 +4433,9 @@ exports.CommandResult = void 0;
4433
4433
  })(exports.CommandResult || (exports.CommandResult = {}));
4434
4434
 
4435
4435
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4436
+ function isMatrix(x) {
4437
+ return Array.isArray(x) && Array.isArray(x[0]);
4438
+ }
4436
4439
  var DIRECTION;
4437
4440
  (function (DIRECTION) {
4438
4441
  DIRECTION["UP"] = "up";
@@ -15358,6 +15361,35 @@ const HLOOKUP = {
15358
15361
  isExported: true,
15359
15362
  };
15360
15363
  // -----------------------------------------------------------------------------
15364
+ // INDEX
15365
+ // -----------------------------------------------------------------------------
15366
+ const INDEX = {
15367
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15368
+ args: [
15369
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15370
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15371
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15372
+ ],
15373
+ returns: ["ANY"],
15374
+ computeFormat: (reference, row, column) => {
15375
+ const _row = toNumber(row.value);
15376
+ const _column = toNumber(column.value);
15377
+ return reference[_column - 1][_row - 1]?.format;
15378
+ },
15379
+ compute: function (reference, row, column) {
15380
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15381
+ const _row = toNumber(row);
15382
+ const _column = toNumber(column);
15383
+ assert(() => _column >= 0 &&
15384
+ _column - 1 < _reference.length &&
15385
+ _row >= 0 &&
15386
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15387
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15388
+ return _reference[_column - 1][_row - 1];
15389
+ },
15390
+ isExported: true,
15391
+ };
15392
+ // -----------------------------------------------------------------------------
15361
15393
  // LOOKUP
15362
15394
  // -----------------------------------------------------------------------------
15363
15395
  const LOOKUP = {
@@ -15552,6 +15584,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15552
15584
  COLUMN: COLUMN,
15553
15585
  COLUMNS: COLUMNS,
15554
15586
  HLOOKUP: HLOOKUP,
15587
+ INDEX: INDEX,
15555
15588
  LOOKUP: LOOKUP,
15556
15589
  MATCH: MATCH,
15557
15590
  ROW: ROW,
@@ -26989,12 +27022,15 @@ function createXMLFile(doc, path, contentType) {
26989
27022
  };
26990
27023
  }
26991
27024
  function xmlEscape(str) {
26992
- return String(str)
27025
+ return (String(str)
26993
27026
  .replace(/\&/g, "&amp;")
26994
27027
  .replace(/\</g, "&lt;")
26995
27028
  .replace(/\>/g, "&gt;")
26996
27029
  .replace(/\"/g, "&quot;")
26997
- .replace(/\'/g, "&apos;");
27030
+ .replace(/\'/g, "&apos;")
27031
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27032
+ // They are not valid at all in XML 1.0 (even escaped)
27033
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26998
27034
  }
26999
27035
  function formatAttributes(attrs) {
27000
27036
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34084,6 +34120,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34084
34120
  }
34085
34121
  currentRanges = currentRanges.concat(toAdd);
34086
34122
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34123
+ if (newRangesXC.length === 0) {
34124
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34125
+ return;
34126
+ }
34087
34127
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34088
34128
  cf: {
34089
34129
  id: cf.id,
@@ -47746,6 +47786,6 @@ exports.setTranslationMethod = setTranslationMethod;
47746
47786
  exports.tokenize = tokenize;
47747
47787
 
47748
47788
 
47749
- __info__.version = '16.3.13';
47750
- __info__.date = '2023-10-10T07:28:39.702Z';
47751
- __info__.hash = '67b6363';
47789
+ __info__.version = '16.3.14';
47790
+ __info__.date = '2023-10-19T14:21:33.996Z';
47791
+ __info__.hash = '7b90b3d';
@@ -4429,6 +4429,9 @@ var CommandResult;
4429
4429
  })(CommandResult || (CommandResult = {}));
4430
4430
 
4431
4431
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4432
+ function isMatrix(x) {
4433
+ return Array.isArray(x) && Array.isArray(x[0]);
4434
+ }
4432
4435
  var DIRECTION;
4433
4436
  (function (DIRECTION) {
4434
4437
  DIRECTION["UP"] = "up";
@@ -15354,6 +15357,35 @@ const HLOOKUP = {
15354
15357
  isExported: true,
15355
15358
  };
15356
15359
  // -----------------------------------------------------------------------------
15360
+ // INDEX
15361
+ // -----------------------------------------------------------------------------
15362
+ const INDEX = {
15363
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15364
+ args: [
15365
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15366
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15367
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15368
+ ],
15369
+ returns: ["ANY"],
15370
+ computeFormat: (reference, row, column) => {
15371
+ const _row = toNumber(row.value);
15372
+ const _column = toNumber(column.value);
15373
+ return reference[_column - 1][_row - 1]?.format;
15374
+ },
15375
+ compute: function (reference, row, column) {
15376
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15377
+ const _row = toNumber(row);
15378
+ const _column = toNumber(column);
15379
+ assert(() => _column >= 0 &&
15380
+ _column - 1 < _reference.length &&
15381
+ _row >= 0 &&
15382
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15383
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15384
+ return _reference[_column - 1][_row - 1];
15385
+ },
15386
+ isExported: true,
15387
+ };
15388
+ // -----------------------------------------------------------------------------
15357
15389
  // LOOKUP
15358
15390
  // -----------------------------------------------------------------------------
15359
15391
  const LOOKUP = {
@@ -15548,6 +15580,7 @@ var lookup = /*#__PURE__*/Object.freeze({
15548
15580
  COLUMN: COLUMN,
15549
15581
  COLUMNS: COLUMNS,
15550
15582
  HLOOKUP: HLOOKUP,
15583
+ INDEX: INDEX,
15551
15584
  LOOKUP: LOOKUP,
15552
15585
  MATCH: MATCH,
15553
15586
  ROW: ROW,
@@ -26985,12 +27018,15 @@ function createXMLFile(doc, path, contentType) {
26985
27018
  };
26986
27019
  }
26987
27020
  function xmlEscape(str) {
26988
- return String(str)
27021
+ return (String(str)
26989
27022
  .replace(/\&/g, "&amp;")
26990
27023
  .replace(/\</g, "&lt;")
26991
27024
  .replace(/\>/g, "&gt;")
26992
27025
  .replace(/\"/g, "&quot;")
26993
- .replace(/\'/g, "&apos;");
27026
+ .replace(/\'/g, "&apos;")
27027
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27028
+ // They are not valid at all in XML 1.0 (even escaped)
27029
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26994
27030
  }
26995
27031
  function formatAttributes(attrs) {
26996
27032
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34080,6 +34116,10 @@ class EvaluationConditionalFormatPlugin extends UIPlugin {
34080
34116
  }
34081
34117
  currentRanges = currentRanges.concat(toAdd);
34082
34118
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34119
+ if (newRangesXC.length === 0) {
34120
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34121
+ return;
34122
+ }
34083
34123
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34084
34124
  cf: {
34085
34125
  id: cf.id,
@@ -47714,6 +47754,6 @@ function addFunction(functionName, functionDescription) {
47714
47754
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateEvaluationCommands, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
47715
47755
 
47716
47756
 
47717
- __info__.version = '16.3.13';
47718
- __info__.date = '2023-10-10T07:28:39.702Z';
47719
- __info__.hash = '67b6363';
47757
+ __info__.version = '16.3.14';
47758
+ __info__.date = '2023-10-19T14:21:33.996Z';
47759
+ __info__.hash = '7b90b3d';
@@ -4430,6 +4430,9 @@
4430
4430
  })(exports.CommandResult || (exports.CommandResult = {}));
4431
4431
 
4432
4432
  const borderStyles = ["thin", "medium", "thick", "dashed", "dotted"];
4433
+ function isMatrix(x) {
4434
+ return Array.isArray(x) && Array.isArray(x[0]);
4435
+ }
4433
4436
  var DIRECTION;
4434
4437
  (function (DIRECTION) {
4435
4438
  DIRECTION["UP"] = "up";
@@ -15355,6 +15358,35 @@
15355
15358
  isExported: true,
15356
15359
  };
15357
15360
  // -----------------------------------------------------------------------------
15361
+ // INDEX
15362
+ // -----------------------------------------------------------------------------
15363
+ const INDEX = {
15364
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
15365
+ args: [
15366
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
15367
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
15368
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
15369
+ ],
15370
+ returns: ["ANY"],
15371
+ computeFormat: (reference, row, column) => {
15372
+ const _row = toNumber(row.value);
15373
+ const _column = toNumber(column.value);
15374
+ return reference[_column - 1][_row - 1]?.format;
15375
+ },
15376
+ compute: function (reference, row, column) {
15377
+ const _reference = isMatrix(reference) ? reference : [[reference]];
15378
+ const _row = toNumber(row);
15379
+ const _column = toNumber(column);
15380
+ assert(() => _column >= 0 &&
15381
+ _column - 1 < _reference.length &&
15382
+ _row >= 0 &&
15383
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
15384
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
15385
+ return _reference[_column - 1][_row - 1];
15386
+ },
15387
+ isExported: true,
15388
+ };
15389
+ // -----------------------------------------------------------------------------
15358
15390
  // LOOKUP
15359
15391
  // -----------------------------------------------------------------------------
15360
15392
  const LOOKUP = {
@@ -15549,6 +15581,7 @@
15549
15581
  COLUMN: COLUMN,
15550
15582
  COLUMNS: COLUMNS,
15551
15583
  HLOOKUP: HLOOKUP,
15584
+ INDEX: INDEX,
15552
15585
  LOOKUP: LOOKUP,
15553
15586
  MATCH: MATCH,
15554
15587
  ROW: ROW,
@@ -26986,12 +27019,15 @@
26986
27019
  };
26987
27020
  }
26988
27021
  function xmlEscape(str) {
26989
- return String(str)
27022
+ return (String(str)
26990
27023
  .replace(/\&/g, "&amp;")
26991
27024
  .replace(/\</g, "&lt;")
26992
27025
  .replace(/\>/g, "&gt;")
26993
27026
  .replace(/\"/g, "&quot;")
26994
- .replace(/\'/g, "&apos;");
27027
+ .replace(/\'/g, "&apos;")
27028
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
27029
+ // They are not valid at all in XML 1.0 (even escaped)
27030
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
26995
27031
  }
26996
27032
  function formatAttributes(attrs) {
26997
27033
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -34081,6 +34117,10 @@
34081
34117
  }
34082
34118
  currentRanges = currentRanges.concat(toAdd);
34083
34119
  const newRangesXC = recomputeZones(currentRanges, toRemove);
34120
+ if (newRangesXC.length === 0) {
34121
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
34122
+ return;
34123
+ }
34084
34124
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
34085
34125
  cf: {
34086
34126
  id: cf.id,
@@ -47745,9 +47785,9 @@
47745
47785
  Object.defineProperty(exports, '__esModule', { value: true });
47746
47786
 
47747
47787
 
47748
- __info__.version = '16.3.13';
47749
- __info__.date = '2023-10-10T07:28:39.702Z';
47750
- __info__.hash = '67b6363';
47788
+ __info__.version = '16.3.14';
47789
+ __info__.date = '2023-10-19T14:21:33.996Z';
47790
+ __info__.hash = '7b90b3d';
47751
47791
 
47752
47792
 
47753
47793
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);