@odoo/o-spreadsheet 16.4.9 → 16.4.10

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.
@@ -13047,6 +13047,35 @@ const HLOOKUP = {
13047
13047
  isExported: true,
13048
13048
  };
13049
13049
  // -----------------------------------------------------------------------------
13050
+ // INDEX
13051
+ // -----------------------------------------------------------------------------
13052
+ const INDEX = {
13053
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
13054
+ args: [
13055
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
13056
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
13057
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
13058
+ ],
13059
+ returns: ["ANY"],
13060
+ computeFormat: function (reference, row, column) {
13061
+ const _row = toNumber(row.value, this.locale);
13062
+ const _column = toNumber(column.value, this.locale);
13063
+ return reference.format[_column - 1][_row - 1];
13064
+ },
13065
+ compute: function (reference, row, column) {
13066
+ const _reference = isMatrix(reference) ? reference : [[reference]];
13067
+ const _row = toNumber(row, this.locale);
13068
+ const _column = toNumber(column, this.locale);
13069
+ assert(() => _column >= 0 &&
13070
+ _column - 1 < _reference.length &&
13071
+ _row >= 0 &&
13072
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
13073
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
13074
+ return _reference[_column - 1][_row - 1];
13075
+ },
13076
+ isExported: true,
13077
+ };
13078
+ // -----------------------------------------------------------------------------
13050
13079
  // LOOKUP
13051
13080
  // -----------------------------------------------------------------------------
13052
13081
  const LOOKUP = {
@@ -13244,6 +13273,7 @@ var lookup = /*#__PURE__*/Object.freeze({
13244
13273
  COLUMN: COLUMN,
13245
13274
  COLUMNS: COLUMNS,
13246
13275
  HLOOKUP: HLOOKUP,
13276
+ INDEX: INDEX,
13247
13277
  LOOKUP: LOOKUP,
13248
13278
  MATCH: MATCH,
13249
13279
  ROW: ROW,
@@ -21815,7 +21845,7 @@ class ChartPanel extends owl.Component {
21815
21845
  });
21816
21846
  }
21817
21847
  canUpdateChart(figureId, updateDefinition) {
21818
- if (figureId !== this.figureId) {
21848
+ if (figureId !== this.figureId || !this.env.model.getters.isChartDefined(figureId)) {
21819
21849
  return;
21820
21850
  }
21821
21851
  const definition = {
@@ -25683,7 +25713,14 @@ class AbstractResizer extends owl.Component {
25683
25713
  return;
25684
25714
  }
25685
25715
  if (this.state.waitingForMove === true) {
25686
- this.startMovement(ev);
25716
+ if (!this.env.model.getters.isGridSelectionActive()) {
25717
+ this._selectElement(index, false);
25718
+ }
25719
+ else {
25720
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
25721
+ // a way to have the grid selection follow the other selections evolution
25722
+ this.startMovement(ev);
25723
+ }
25687
25724
  return;
25688
25725
  }
25689
25726
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -29109,12 +29146,15 @@ function createXMLFile(doc, path, contentType) {
29109
29146
  };
29110
29147
  }
29111
29148
  function xmlEscape(str) {
29112
- return String(str)
29149
+ return (String(str)
29113
29150
  .replace(/\&/g, "&amp;")
29114
29151
  .replace(/\</g, "&lt;")
29115
29152
  .replace(/\>/g, "&gt;")
29116
29153
  .replace(/\"/g, "&quot;")
29117
- .replace(/\'/g, "&apos;");
29154
+ .replace(/\'/g, "&apos;")
29155
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
29156
+ // They are not valid at all in XML 1.0 (even escaped)
29157
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
29118
29158
  }
29119
29159
  function formatAttributes(attrs) {
29120
29160
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -41714,6 +41754,10 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41714
41754
  if (!newRangesXC) {
41715
41755
  return;
41716
41756
  }
41757
+ if (newRangesXC.length === 0) {
41758
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
41759
+ return;
41760
+ }
41717
41761
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
41718
41762
  cf: {
41719
41763
  id: cf.id,
@@ -43219,6 +43263,7 @@ class GridSelectionPlugin extends UIPlugin {
43219
43263
  "isSingleColSelected",
43220
43264
  "getElementsFromSelection",
43221
43265
  "tryGetActiveSheetId",
43266
+ "isGridSelectionActive",
43222
43267
  ];
43223
43268
  gridSelection = {
43224
43269
  anchor: {
@@ -43428,6 +43473,9 @@ class GridSelectionPlugin extends UIPlugin {
43428
43473
  // ---------------------------------------------------------------------------
43429
43474
  // Getters
43430
43475
  // ---------------------------------------------------------------------------
43476
+ isGridSelectionActive() {
43477
+ return this.selection.isListening(this);
43478
+ }
43431
43479
  getActiveSheet() {
43432
43480
  return this.activeSheet;
43433
43481
  }
@@ -48243,6 +48291,9 @@ class SelectionStreamProcessorImpl {
48243
48291
  },
48244
48292
  });
48245
48293
  }
48294
+ isListening(owner) {
48295
+ return this.stream.isListening(owner);
48296
+ }
48246
48297
  /**
48247
48298
  * Process a new anchor selection event. If the new anchor is inside
48248
48299
  * the sheet boundaries, the event is pushed to the event stream to
@@ -50711,6 +50762,6 @@ exports.setTranslationMethod = setTranslationMethod;
50711
50762
  exports.tokenize = tokenize;
50712
50763
 
50713
50764
 
50714
- __info__.version = '16.4.9';
50715
- __info__.date = '2023-10-10T07:28:12.772Z';
50716
- __info__.hash = '998c612';
50765
+ __info__.version = '16.4.10';
50766
+ __info__.date = '2023-10-19T14:23:58.054Z';
50767
+ __info__.hash = 'bc7546f';
@@ -1057,6 +1057,7 @@ interface SelectionProcessor {
1057
1057
  selectAll(): DispatchResult;
1058
1058
  loopSelection(): DispatchResult;
1059
1059
  selectTableAroundSelection(): DispatchResult;
1060
+ isListening(owner: unknown): boolean;
1060
1061
  }
1061
1062
  type SelectionStreamProcessor = SelectionProcessor & StatefulStream<SelectionEvent, AnchorZone>;
1062
1063
 
@@ -4508,7 +4509,7 @@ declare class FilterEvaluationPlugin extends UIPlugin {
4508
4509
  */
4509
4510
  declare class GridSelectionPlugin extends UIPlugin {
4510
4511
  static layers: LAYERS[];
4511
- static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getSelectedCells", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "isSingleColSelected", "getElementsFromSelection", "tryGetActiveSheetId"];
4512
+ static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getSelectedCells", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "isSingleColSelected", "getElementsFromSelection", "tryGetActiveSheetId", "isGridSelectionActive"];
4512
4513
  private gridSelection;
4513
4514
  private selectedFigureId;
4514
4515
  private sheetsData;
@@ -4518,6 +4519,7 @@ declare class GridSelectionPlugin extends UIPlugin {
4518
4519
  allowDispatch(cmd: LocalCommand): CommandResult;
4519
4520
  private handleEvent;
4520
4521
  handle(cmd: Command): void;
4522
+ isGridSelectionActive(): boolean;
4521
4523
  getActiveSheet(): Readonly<Sheet>;
4522
4524
  getActiveSheetId(): UID;
4523
4525
  tryGetActiveSheetId(): UID | undefined;
@@ -13043,6 +13043,35 @@ const HLOOKUP = {
13043
13043
  isExported: true,
13044
13044
  };
13045
13045
  // -----------------------------------------------------------------------------
13046
+ // INDEX
13047
+ // -----------------------------------------------------------------------------
13048
+ const INDEX = {
13049
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
13050
+ args: [
13051
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
13052
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
13053
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
13054
+ ],
13055
+ returns: ["ANY"],
13056
+ computeFormat: function (reference, row, column) {
13057
+ const _row = toNumber(row.value, this.locale);
13058
+ const _column = toNumber(column.value, this.locale);
13059
+ return reference.format[_column - 1][_row - 1];
13060
+ },
13061
+ compute: function (reference, row, column) {
13062
+ const _reference = isMatrix(reference) ? reference : [[reference]];
13063
+ const _row = toNumber(row, this.locale);
13064
+ const _column = toNumber(column, this.locale);
13065
+ assert(() => _column >= 0 &&
13066
+ _column - 1 < _reference.length &&
13067
+ _row >= 0 &&
13068
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
13069
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
13070
+ return _reference[_column - 1][_row - 1];
13071
+ },
13072
+ isExported: true,
13073
+ };
13074
+ // -----------------------------------------------------------------------------
13046
13075
  // LOOKUP
13047
13076
  // -----------------------------------------------------------------------------
13048
13077
  const LOOKUP = {
@@ -13240,6 +13269,7 @@ var lookup = /*#__PURE__*/Object.freeze({
13240
13269
  COLUMN: COLUMN,
13241
13270
  COLUMNS: COLUMNS,
13242
13271
  HLOOKUP: HLOOKUP,
13272
+ INDEX: INDEX,
13243
13273
  LOOKUP: LOOKUP,
13244
13274
  MATCH: MATCH,
13245
13275
  ROW: ROW,
@@ -21811,7 +21841,7 @@ class ChartPanel extends Component {
21811
21841
  });
21812
21842
  }
21813
21843
  canUpdateChart(figureId, updateDefinition) {
21814
- if (figureId !== this.figureId) {
21844
+ if (figureId !== this.figureId || !this.env.model.getters.isChartDefined(figureId)) {
21815
21845
  return;
21816
21846
  }
21817
21847
  const definition = {
@@ -25679,7 +25709,14 @@ class AbstractResizer extends Component {
25679
25709
  return;
25680
25710
  }
25681
25711
  if (this.state.waitingForMove === true) {
25682
- this.startMovement(ev);
25712
+ if (!this.env.model.getters.isGridSelectionActive()) {
25713
+ this._selectElement(index, false);
25714
+ }
25715
+ else {
25716
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
25717
+ // a way to have the grid selection follow the other selections evolution
25718
+ this.startMovement(ev);
25719
+ }
25683
25720
  return;
25684
25721
  }
25685
25722
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -29105,12 +29142,15 @@ function createXMLFile(doc, path, contentType) {
29105
29142
  };
29106
29143
  }
29107
29144
  function xmlEscape(str) {
29108
- return String(str)
29145
+ return (String(str)
29109
29146
  .replace(/\&/g, "&amp;")
29110
29147
  .replace(/\</g, "&lt;")
29111
29148
  .replace(/\>/g, "&gt;")
29112
29149
  .replace(/\"/g, "&quot;")
29113
- .replace(/\'/g, "&apos;");
29150
+ .replace(/\'/g, "&apos;")
29151
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
29152
+ // They are not valid at all in XML 1.0 (even escaped)
29153
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
29114
29154
  }
29115
29155
  function formatAttributes(attrs) {
29116
29156
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -41710,6 +41750,10 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
41710
41750
  if (!newRangesXC) {
41711
41751
  return;
41712
41752
  }
41753
+ if (newRangesXC.length === 0) {
41754
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
41755
+ return;
41756
+ }
41713
41757
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
41714
41758
  cf: {
41715
41759
  id: cf.id,
@@ -43215,6 +43259,7 @@ class GridSelectionPlugin extends UIPlugin {
43215
43259
  "isSingleColSelected",
43216
43260
  "getElementsFromSelection",
43217
43261
  "tryGetActiveSheetId",
43262
+ "isGridSelectionActive",
43218
43263
  ];
43219
43264
  gridSelection = {
43220
43265
  anchor: {
@@ -43424,6 +43469,9 @@ class GridSelectionPlugin extends UIPlugin {
43424
43469
  // ---------------------------------------------------------------------------
43425
43470
  // Getters
43426
43471
  // ---------------------------------------------------------------------------
43472
+ isGridSelectionActive() {
43473
+ return this.selection.isListening(this);
43474
+ }
43427
43475
  getActiveSheet() {
43428
43476
  return this.activeSheet;
43429
43477
  }
@@ -48239,6 +48287,9 @@ class SelectionStreamProcessorImpl {
48239
48287
  },
48240
48288
  });
48241
48289
  }
48290
+ isListening(owner) {
48291
+ return this.stream.isListening(owner);
48292
+ }
48242
48293
  /**
48243
48294
  * Process a new anchor selection event. If the new anchor is inside
48244
48295
  * the sheet boundaries, the event is pushed to the event stream to
@@ -50675,6 +50726,6 @@ const constants = {
50675
50726
  export { AbstractChart, CommandResult, CorePlugin, DispatchResult, EvaluationError, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, __info__, addFunction, astToFormula, compile, components, constants, convertAstNodes, coreTypes, findCellInNewZone, functionCache, helpers, invalidateCFEvaluationCommands, invalidateDependenciesCommands, invalidateEvaluationCommands, iterateAstNodes, links, load, parse, readonlyAllowedCommands, registries, setDefaultSheetViewSize, setTranslationMethod, tokenize };
50676
50727
 
50677
50728
 
50678
- __info__.version = '16.4.9';
50679
- __info__.date = '2023-10-10T07:28:12.772Z';
50680
- __info__.hash = '998c612';
50729
+ __info__.version = '16.4.10';
50730
+ __info__.date = '2023-10-19T14:23:58.054Z';
50731
+ __info__.hash = 'bc7546f';
@@ -13044,6 +13044,35 @@
13044
13044
  isExported: true,
13045
13045
  };
13046
13046
  // -----------------------------------------------------------------------------
13047
+ // INDEX
13048
+ // -----------------------------------------------------------------------------
13049
+ const INDEX = {
13050
+ description: _lt(`Returns the content of a cell, specified by row and column offset.`),
13051
+ args: [
13052
+ arg("reference (any, range)", _lt("The range of cells from which the values are returned.")),
13053
+ arg("row (number)", _lt("The index of the row to be returned from within the reference range of cells.")),
13054
+ arg("column (number)", _lt("The index of the column to be returned from within the reference range of cells.")),
13055
+ ],
13056
+ returns: ["ANY"],
13057
+ computeFormat: function (reference, row, column) {
13058
+ const _row = toNumber(row.value, this.locale);
13059
+ const _column = toNumber(column.value, this.locale);
13060
+ return reference.format[_column - 1][_row - 1];
13061
+ },
13062
+ compute: function (reference, row, column) {
13063
+ const _reference = isMatrix(reference) ? reference : [[reference]];
13064
+ const _row = toNumber(row, this.locale);
13065
+ const _column = toNumber(column, this.locale);
13066
+ assert(() => _column >= 0 &&
13067
+ _column - 1 < _reference.length &&
13068
+ _row >= 0 &&
13069
+ _row - 1 < _reference[0].length, _lt("Index out of range."));
13070
+ assert(() => row !== 0 && column !== 0, _lt("This function can only return a single cell value, not an array. Provide valid row and column indices."));
13071
+ return _reference[_column - 1][_row - 1];
13072
+ },
13073
+ isExported: true,
13074
+ };
13075
+ // -----------------------------------------------------------------------------
13047
13076
  // LOOKUP
13048
13077
  // -----------------------------------------------------------------------------
13049
13078
  const LOOKUP = {
@@ -13241,6 +13270,7 @@
13241
13270
  COLUMN: COLUMN,
13242
13271
  COLUMNS: COLUMNS,
13243
13272
  HLOOKUP: HLOOKUP,
13273
+ INDEX: INDEX,
13244
13274
  LOOKUP: LOOKUP,
13245
13275
  MATCH: MATCH,
13246
13276
  ROW: ROW,
@@ -21812,7 +21842,7 @@
21812
21842
  });
21813
21843
  }
21814
21844
  canUpdateChart(figureId, updateDefinition) {
21815
- if (figureId !== this.figureId) {
21845
+ if (figureId !== this.figureId || !this.env.model.getters.isChartDefined(figureId)) {
21816
21846
  return;
21817
21847
  }
21818
21848
  const definition = {
@@ -25680,7 +25710,14 @@
25680
25710
  return;
25681
25711
  }
25682
25712
  if (this.state.waitingForMove === true) {
25683
- this.startMovement(ev);
25713
+ if (!this.env.model.getters.isGridSelectionActive()) {
25714
+ this._selectElement(index, false);
25715
+ }
25716
+ else {
25717
+ // FIXME: Consider reintroducing this feature for all type of selection if we find
25718
+ // a way to have the grid selection follow the other selections evolution
25719
+ this.startMovement(ev);
25720
+ }
25684
25721
  return;
25685
25722
  }
25686
25723
  if (this.env.model.getters.getEditionMode() === "editing") {
@@ -29106,12 +29143,15 @@
29106
29143
  };
29107
29144
  }
29108
29145
  function xmlEscape(str) {
29109
- return String(str)
29146
+ return (String(str)
29110
29147
  .replace(/\&/g, "&amp;")
29111
29148
  .replace(/\</g, "&lt;")
29112
29149
  .replace(/\>/g, "&gt;")
29113
29150
  .replace(/\"/g, "&quot;")
29114
- .replace(/\'/g, "&apos;");
29151
+ .replace(/\'/g, "&apos;")
29152
+ // Delete all ASCII control characters except for TAB (\x09), LF (\x0A) and CR (\x0D)
29153
+ // They are not valid at all in XML 1.0 (even escaped)
29154
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ""));
29115
29155
  }
29116
29156
  function formatAttributes(attrs) {
29117
29157
  return new XMLString(attrs.map(([key, val]) => `${key}="${xmlEscape(val)}"`).join(" "));
@@ -41711,6 +41751,10 @@
41711
41751
  if (!newRangesXC) {
41712
41752
  return;
41713
41753
  }
41754
+ if (newRangesXC.length === 0) {
41755
+ this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
41756
+ return;
41757
+ }
41714
41758
  this.dispatch("ADD_CONDITIONAL_FORMAT", {
41715
41759
  cf: {
41716
41760
  id: cf.id,
@@ -43216,6 +43260,7 @@
43216
43260
  "isSingleColSelected",
43217
43261
  "getElementsFromSelection",
43218
43262
  "tryGetActiveSheetId",
43263
+ "isGridSelectionActive",
43219
43264
  ];
43220
43265
  gridSelection = {
43221
43266
  anchor: {
@@ -43425,6 +43470,9 @@
43425
43470
  // ---------------------------------------------------------------------------
43426
43471
  // Getters
43427
43472
  // ---------------------------------------------------------------------------
43473
+ isGridSelectionActive() {
43474
+ return this.selection.isListening(this);
43475
+ }
43428
43476
  getActiveSheet() {
43429
43477
  return this.activeSheet;
43430
43478
  }
@@ -48240,6 +48288,9 @@
48240
48288
  },
48241
48289
  });
48242
48290
  }
48291
+ isListening(owner) {
48292
+ return this.stream.isListening(owner);
48293
+ }
48243
48294
  /**
48244
48295
  * Process a new anchor selection event. If the new anchor is inside
48245
48296
  * the sheet boundaries, the event is pushed to the event stream to
@@ -50710,9 +50761,9 @@
50710
50761
  Object.defineProperty(exports, '__esModule', { value: true });
50711
50762
 
50712
50763
 
50713
- __info__.version = '16.4.9';
50714
- __info__.date = '2023-10-10T07:28:12.772Z';
50715
- __info__.hash = '998c612';
50764
+ __info__.version = '16.4.10';
50765
+ __info__.date = '2023-10-19T14:23:58.054Z';
50766
+ __info__.hash = 'bc7546f';
50716
50767
 
50717
50768
 
50718
50769
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);