@odoo/o-spreadsheet 16.1.2 → 16.1.3

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.
@@ -2824,7 +2824,7 @@
2824
2824
  return `background-color: ${this.background}`;
2825
2825
  }
2826
2826
  get chartRuntime() {
2827
- const runtime = this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
2827
+ const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
2828
2828
  if (!("chartJsConfig" in runtime)) {
2829
2829
  throw new Error("Unsupported chart runtime");
2830
2830
  }
@@ -3078,7 +3078,7 @@
3078
3078
  this.ctx = document.createElement("canvas").getContext("2d");
3079
3079
  }
3080
3080
  get runtime() {
3081
- return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
3081
+ return this.env.model.getters.getChartRuntime(this.props.figure.id);
3082
3082
  }
3083
3083
  get title() {
3084
3084
  return this.runtime.title;
@@ -3469,7 +3469,7 @@
3469
3469
  CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
3470
3470
  CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
3471
3471
  CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
3472
- CommandResult[CommandResult["DuplicatedImageId"] = 28] = "DuplicatedImageId";
3472
+ CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
3473
3473
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3474
3474
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3475
3475
  CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
@@ -3526,6 +3526,7 @@
3526
3526
  CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3527
3527
  CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3528
3528
  CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3529
+ CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3529
3530
  })(exports.CommandResult || (exports.CommandResult = {}));
3530
3531
 
3531
3532
  var DIRECTION;
@@ -6066,7 +6067,7 @@
6066
6067
  return registry;
6067
6068
  }
6068
6069
  get chartType() {
6069
- return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
6070
+ return this.env.model.getters.getChartType(this.props.figure.id);
6070
6071
  }
6071
6072
  onContextMenu(ev) {
6072
6073
  const position = {
@@ -18801,7 +18802,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18801
18802
  name: _lt("Reset size"),
18802
18803
  sequence: 3,
18803
18804
  action: () => {
18804
- const size = this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId).size;
18805
+ const size = this.env.model.getters.getImageSize(this.figureId);
18805
18806
  const { height, width } = getMaxFigureSize(this.env.model.getters, size);
18806
18807
  this.env.model.dispatch("UPDATE_FIGURE", {
18807
18808
  sheetId: this.env.model.getters.getActiveSheetId(),
@@ -18852,8 +18853,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18852
18853
  return this.props.figure.id;
18853
18854
  }
18854
18855
  get getImagePath() {
18855
- return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId)
18856
- .path;
18856
+ return this.env.model.getters.getImagePath(this.figureId);
18857
18857
  }
18858
18858
  }
18859
18859
  ImageFigure.template = "o-spreadsheet-ImageFigure";
@@ -19808,7 +19808,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19808
19808
  LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
19809
19809
  LineBarPieConfigPanel.components = { SelectionInput };
19810
19810
  LineBarPieConfigPanel.props = {
19811
- sheetId: String,
19812
19811
  figureId: String,
19813
19812
  definition: Object,
19814
19813
  updateChart: Function,
@@ -20138,7 +20137,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20138
20137
  GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
20139
20138
  GaugeChartConfigPanel.components = { SelectionInput };
20140
20139
  GaugeChartConfigPanel.props = {
20141
- sheetId: String,
20142
20140
  figureId: String,
20143
20141
  definition: Object,
20144
20142
  updateChart: Function,
@@ -20292,7 +20290,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20292
20290
 
20293
20291
  class LineConfigPanel extends LineBarPieConfigPanel {
20294
20292
  get canTreatLabelsAsText() {
20295
- const chart = this.env.model.getters.getChart(this.props.sheetId, this.props.figureId);
20293
+ const chart = this.env.model.getters.getChart(this.props.figureId);
20296
20294
  if (chart && chart instanceof LineChart) {
20297
20295
  return canChartParseLabels(chart.labelRange, this.env.model.getters);
20298
20296
  }
@@ -20369,7 +20367,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20369
20367
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
20370
20368
  ScorecardChartConfigPanel.components = { SelectionInput };
20371
20369
  ScorecardChartConfigPanel.props = {
20372
- sheetId: String,
20373
20370
  figureId: String,
20374
20371
  definition: Object,
20375
20372
  updateChart: Function,
@@ -20501,7 +20498,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20501
20498
  else {
20502
20499
  this.shouldUpdateChart = true;
20503
20500
  }
20504
- if (!this.env.model.getters.isChartDefined(this.sheetId, this.figureId)) {
20501
+ if (!this.env.model.getters.isChartDefined(this.figureId)) {
20505
20502
  this.props.onCloseSidePanel();
20506
20503
  return;
20507
20504
  }
@@ -20522,7 +20519,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20522
20519
  });
20523
20520
  }
20524
20521
  onTypeChange(type) {
20525
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
20522
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
20526
20523
  if (!context) {
20527
20524
  throw new Error("Chart not defined.");
20528
20525
  }
@@ -20534,7 +20531,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20534
20531
  });
20535
20532
  }
20536
20533
  get chartPanel() {
20537
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
20534
+ const type = this.env.model.getters.getChartType(this.figureId);
20538
20535
  if (!type) {
20539
20536
  throw new Error("Chart not defined.");
20540
20537
  }
@@ -20544,8 +20541,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20544
20541
  }
20545
20542
  return chartPanel;
20546
20543
  }
20547
- getChartDefinition() {
20548
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
20544
+ getChartDefinition(figureId = this.figureId) {
20545
+ return this.env.model.getters.getChartDefinition(figureId);
20549
20546
  }
20550
20547
  get chartTypes() {
20551
20548
  return getChartTypes();
@@ -27104,13 +27101,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27104
27101
  data = migrate(data);
27105
27102
  }
27106
27103
  }
27107
- // sanity check: try to fix missing fields/corrupted state by providing
27108
- // sensible default values
27109
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27110
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
27111
- if (data.sheets.length === 0) {
27112
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27113
- }
27104
+ data = repairData(data);
27114
27105
  return data;
27115
27106
  }
27116
27107
  function migrate(data) {
@@ -27348,6 +27339,48 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27348
27339
  },
27349
27340
  },
27350
27341
  ];
27342
+ /**
27343
+ * This function is used to repair faulty data independently of the migration.
27344
+ */
27345
+ function repairData(data) {
27346
+ data = forceUnicityOfFigure(data);
27347
+ data = setDefaults(data);
27348
+ return data;
27349
+ }
27350
+ /**
27351
+ * Force the unicity of figure ids accross sheets
27352
+ */
27353
+ function forceUnicityOfFigure(data) {
27354
+ if (data.uniqueFigureIds) {
27355
+ return data;
27356
+ }
27357
+ const figureIds = new Set();
27358
+ const uuidGenerator = new UuidGenerator();
27359
+ for (const sheet of data.sheets || []) {
27360
+ for (const figure of sheet.figures || []) {
27361
+ if (figureIds.has(figure.id)) {
27362
+ figure.id += uuidGenerator.uuidv4();
27363
+ }
27364
+ figureIds.add(figure.id);
27365
+ }
27366
+ }
27367
+ data.uniqueFigureIds = true;
27368
+ return data;
27369
+ }
27370
+ /**
27371
+ * sanity check: try to fix missing fields/corrupted state by providing
27372
+ * sensible default values
27373
+ */
27374
+ function setDefaults(data) {
27375
+ data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27376
+ data.sheets = data.sheets
27377
+ ? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
27378
+ : [];
27379
+ if (data.sheets.length === 0) {
27380
+ data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27381
+ }
27382
+ return data;
27383
+ }
27351
27384
  /**
27352
27385
  * The goal of this function is to repair corrupted/wrong initial messages caused by
27353
27386
  * a bug.
@@ -27486,6 +27519,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27486
27519
  formats: {},
27487
27520
  borders: {},
27488
27521
  revisionId: DEFAULT_REVISION_ID,
27522
+ uniqueFigureIds: true,
27489
27523
  };
27490
27524
  return data;
27491
27525
  }
@@ -28483,10 +28517,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28483
28517
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
28484
28518
  }
28485
28519
  adaptRanges(applyChange) {
28486
- for (const sheetId of Object.keys(this.charts)) {
28487
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
28488
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28489
- }
28520
+ for (const [chartId, chart] of Object.entries(this.charts)) {
28521
+ this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28490
28522
  }
28491
28523
  }
28492
28524
  // ---------------------------------------------------------------------------
@@ -28497,20 +28529,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28497
28529
  case "CREATE_CHART":
28498
28530
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
28499
28531
  case "UPDATE_CHART":
28500
- return this.validateChartDefinition(cmd);
28532
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
28501
28533
  default:
28502
28534
  return 0 /* CommandResult.Success */;
28503
28535
  }
28504
28536
  }
28505
28537
  handle(cmd) {
28506
- var _a, _b;
28538
+ var _a;
28507
28539
  switch (cmd.type) {
28508
28540
  case "CREATE_CHART":
28509
28541
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
28510
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28542
+ this.addChart(cmd.id, cmd.definition);
28511
28543
  break;
28512
28544
  case "UPDATE_CHART": {
28513
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28545
+ this.addChart(cmd.id, cmd.definition);
28514
28546
  break;
28515
28547
  }
28516
28548
  case "DUPLICATE_SHEET": {
@@ -28519,7 +28551,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28519
28551
  if (fig.tag === "chart") {
28520
28552
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
28521
28553
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
28522
- const chart = (_b = (_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[fig.id]) === null || _b === void 0 ? void 0 : _b.copyForSheetId(cmd.sheetIdTo);
28554
+ const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
28523
28555
  if (chart) {
28524
28556
  this.dispatch("CREATE_CHART", {
28525
28557
  id: duplicatedFigureId,
@@ -28534,41 +28566,44 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28534
28566
  break;
28535
28567
  }
28536
28568
  case "DELETE_FIGURE":
28537
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
28569
+ this.history.update("charts", cmd.id, undefined);
28538
28570
  break;
28539
28571
  case "DELETE_SHEET":
28540
- this.history.update("charts", cmd.sheetId, undefined);
28572
+ for (let id of this.getChartIds(cmd.sheetId)) {
28573
+ this.history.update("charts", id, undefined);
28574
+ }
28541
28575
  break;
28542
28576
  }
28543
28577
  }
28544
28578
  // ---------------------------------------------------------------------------
28545
28579
  // Getters
28546
28580
  // ---------------------------------------------------------------------------
28547
- getContextCreationChart(sheetId, figureId) {
28548
- var _a, _b;
28549
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
28550
- }
28551
- getChart(sheetId, figureId) {
28581
+ getContextCreationChart(figureId) {
28552
28582
  var _a;
28553
- return (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
28583
+ return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
28554
28584
  }
28555
- getChartType(sheetId, figureId) {
28556
- var _a, _b;
28557
- const type = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.type;
28585
+ getChart(figureId) {
28586
+ return this.charts[figureId];
28587
+ }
28588
+ getChartType(figureId) {
28589
+ var _a;
28590
+ const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
28558
28591
  if (!type) {
28559
28592
  throw new Error("Chart not defined.");
28560
28593
  }
28561
28594
  return type;
28562
28595
  }
28563
- isChartDefined(sheetId, figureId) {
28564
- return figureId in (this.charts[sheetId] || {});
28596
+ isChartDefined(figureId) {
28597
+ return figureId in this.charts && this.charts !== undefined;
28565
28598
  }
28566
28599
  getChartIds(sheetId) {
28567
- return Object.keys(this.charts[sheetId] || {});
28600
+ return Object.entries(this.charts)
28601
+ .filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
28602
+ .map(([id]) => id);
28568
28603
  }
28569
- getChartDefinition(sheetId, figureId) {
28570
- var _a, _b;
28571
- const definition = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getDefinition();
28604
+ getChartDefinition(figureId) {
28605
+ var _a;
28606
+ const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28572
28607
  if (!definition) {
28573
28608
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
28574
28609
  }
@@ -28580,28 +28615,35 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28580
28615
  import(data) {
28581
28616
  for (let sheet of data.sheets) {
28582
28617
  if (sheet.figures) {
28583
- const charts = {};
28584
28618
  for (let figure of sheet.figures) {
28585
28619
  // TODO:
28586
28620
  // figure data should be external IMO => chart should be in sheet.chart
28587
28621
  // instead of in figure.data
28588
28622
  if (figure.tag === "chart") {
28589
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28623
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28590
28624
  }
28591
28625
  }
28592
- this.charts[sheet.id] = charts;
28593
28626
  }
28594
28627
  }
28595
28628
  }
28596
28629
  export(data) {
28630
+ var _a;
28597
28631
  if (data.sheets) {
28598
28632
  for (let sheet of data.sheets) {
28599
28633
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
28600
28634
  const sheetFigures = this.getters.getFigures(sheet.id);
28601
- const figures = sheetFigures;
28602
- for (let figure of figures) {
28635
+ const figures = [];
28636
+ for (let sheetFigure of sheetFigures) {
28637
+ const figure = sheetFigure;
28603
28638
  if (figure && figure.tag === "chart") {
28604
- figure.data = this.getChartDefinition(sheet.id, figure.id);
28639
+ const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28640
+ if (data) {
28641
+ figure.data = data;
28642
+ figures.push(figure);
28643
+ }
28644
+ }
28645
+ else {
28646
+ figures.push(figure);
28605
28647
  }
28606
28648
  }
28607
28649
  sheet.figures = figures;
@@ -28609,13 +28651,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28609
28651
  }
28610
28652
  }
28611
28653
  exportForExcel(data) {
28612
- var _a, _b;
28654
+ var _a;
28613
28655
  for (let sheet of data.sheets) {
28614
28656
  const sheetFigures = this.getters.getFigures(sheet.id);
28615
28657
  const figures = [];
28616
28658
  for (let figure of sheetFigures) {
28617
28659
  if (figure && figure.tag === "chart") {
28618
- const figureData = (_b = (_a = this.charts[sheet.id]) === null || _a === void 0 ? void 0 : _a[figure.id]) === null || _b === void 0 ? void 0 : _b.getDefinitionForExcel();
28660
+ const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
28619
28661
  if (figureData) {
28620
28662
  figures.push({
28621
28663
  ...figure,
@@ -28654,15 +28696,21 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28654
28696
  * Add a chart in the local state. If a chart already exists, this chart is
28655
28697
  * replaced
28656
28698
  */
28657
- addChart(id, sheetId, definition) {
28658
- this.history.update("charts", sheetId, id, this.createChart(id, definition, sheetId));
28699
+ addChart(id, definition) {
28700
+ const sheetId = this.getters.getFigureSheetId(id);
28701
+ if (sheetId) {
28702
+ this.history.update("charts", id, this.createChart(id, definition, sheetId));
28703
+ }
28659
28704
  }
28660
28705
  checkChartDuplicate(cmd) {
28661
- var _a;
28662
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
28663
- return 84 /* CommandResult.DuplicatedChartId */;
28664
- }
28665
- return 0 /* CommandResult.Success */;
28706
+ return this.getters.getFigureSheetId(cmd.id)
28707
+ ? 84 /* CommandResult.DuplicatedChartId */
28708
+ : 0 /* CommandResult.Success */;
28709
+ }
28710
+ checkChartExists(cmd) {
28711
+ return this.getters.getFigureSheetId(cmd.id)
28712
+ ? 0 /* CommandResult.Success */
28713
+ : 85 /* CommandResult.ChartDoesNotExist */;
28666
28714
  }
28667
28715
  }
28668
28716
  ChartPlugin.getters = [
@@ -29043,7 +29091,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29043
29091
  allowDispatch(cmd) {
29044
29092
  switch (cmd.type) {
29045
29093
  case "CREATE_FIGURE":
29046
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
29094
+ return this.checkFigureDuplicate(cmd.figure.id);
29047
29095
  case "UPDATE_FIGURE":
29048
29096
  case "DELETE_FIGURE":
29049
29097
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -29109,9 +29157,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29109
29157
  }
29110
29158
  return 0 /* CommandResult.Success */;
29111
29159
  }
29112
- checkFigureDuplicate(sheetId, figureId) {
29113
- var _a;
29114
- if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
29160
+ checkFigureDuplicate(figureId) {
29161
+ if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29115
29162
  return 82 /* CommandResult.DuplicatedFigureId */;
29116
29163
  }
29117
29164
  return 0 /* CommandResult.Success */;
@@ -29126,6 +29173,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29126
29173
  var _a;
29127
29174
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29128
29175
  }
29176
+ getFigureSheetId(figureId) {
29177
+ return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
29178
+ }
29129
29179
  // ---------------------------------------------------------------------------
29130
29180
  // Import/Export
29131
29181
  // ---------------------------------------------------------------------------
@@ -29150,7 +29200,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29150
29200
  this.export(data);
29151
29201
  }
29152
29202
  }
29153
- FigurePlugin.getters = ["getFigures", "getFigure"];
29203
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
29154
29204
 
29155
29205
  class FilterTable {
29156
29206
  constructor(zone) {
@@ -29877,7 +29927,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29877
29927
  switch (cmd.type) {
29878
29928
  case "CREATE_IMAGE":
29879
29929
  if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
29880
- return 28 /* CommandResult.DuplicatedImageId */;
29930
+ return 28 /* CommandResult.InvalidFigureId */;
29881
29931
  }
29882
29932
  return 0 /* CommandResult.Success */;
29883
29933
  default:
@@ -29897,7 +29947,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29897
29947
  if (fig.tag === "image") {
29898
29948
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
29899
29949
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
29900
- const image = this.getImage(cmd.sheetId, fig.id);
29950
+ const image = this.getImage(fig.id);
29901
29951
  if (image) {
29902
29952
  const size = { width: fig.width, height: fig.height };
29903
29953
  this.dispatch("CREATE_IMAGE", {
@@ -29935,13 +29985,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29935
29985
  // ---------------------------------------------------------------------------
29936
29986
  // Getters
29937
29987
  // ---------------------------------------------------------------------------
29938
- getImage(sheetId, figureId) {
29939
- var _a;
29940
- const image = (_a = this.images[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29941
- if (!image) {
29942
- throw new Error(`There is no image with the given figureId: ${figureId}`);
29988
+ getImage(figureId) {
29989
+ for (const sheet of Object.values(this.images)) {
29990
+ if (sheet && sheet[figureId]) {
29991
+ return sheet[figureId];
29992
+ }
29943
29993
  }
29944
- return image;
29994
+ throw new Error(`There is no image with the given figureId: ${figureId}`);
29995
+ }
29996
+ getImagePath(figureId) {
29997
+ return this.getImage(figureId).path;
29998
+ }
29999
+ getImageSize(figureId) {
30000
+ return this.getImage(figureId).size;
29945
30001
  }
29946
30002
  // ---------------------------------------------------------------------------
29947
30003
  // Private
@@ -29983,7 +30039,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29983
30039
  return images;
29984
30040
  }
29985
30041
  }
29986
- ImagePlugin.getters = ["getImage"];
30042
+ ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
29987
30043
 
29988
30044
  class MergePlugin extends CorePlugin {
29989
30045
  constructor() {
@@ -31784,9 +31840,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
31784
31840
  return formatColors.filter(isDefined$1);
31785
31841
  }
31786
31842
  getChartColors(sheetId) {
31787
- const charts = this.getters
31788
- .getChartIds(sheetId)
31789
- .map((cid) => this.getters.getChart(sheetId, cid));
31843
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31790
31844
  let chartsColors = new Set();
31791
31845
  for (let chart of charts) {
31792
31846
  if (chart === undefined) {
@@ -32142,37 +32196,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32142
32196
  invalidateCFEvaluationCommands.has(cmd.type) ||
32143
32197
  cmd.type === "EVALUATE_CELLS" ||
32144
32198
  cmd.type === "UPDATE_CELL") {
32145
- for (const sheetId in this.charts) {
32146
- for (const chartId in this.charts[sheetId]) {
32147
- this.charts[sheetId][chartId] = undefined;
32148
- }
32199
+ for (const chartId in this.charts) {
32200
+ this.charts[chartId] = undefined;
32149
32201
  }
32150
32202
  }
32151
32203
  switch (cmd.type) {
32152
32204
  case "UPDATE_CHART":
32153
32205
  case "CREATE_CHART":
32154
32206
  case "DELETE_FIGURE":
32155
- if (this.charts[cmd.sheetId]) {
32156
- this.charts[cmd.sheetId][cmd.id] = undefined;
32157
- }
32207
+ this.charts[cmd.id] = undefined;
32158
32208
  break;
32159
32209
  case "DELETE_SHEET":
32160
- delete this.charts[cmd.sheetId];
32210
+ for (let chartId in this.charts) {
32211
+ if (!this.getters.isChartDefined(chartId)) {
32212
+ this.charts[chartId] = undefined;
32213
+ }
32214
+ }
32161
32215
  break;
32162
32216
  }
32163
32217
  }
32164
- getChartRuntime(sheetId, figureId) {
32165
- var _a;
32166
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32167
- const chart = this.getters.getChart(sheetId, figureId);
32218
+ getChartRuntime(figureId) {
32219
+ if (!this.charts[figureId]) {
32220
+ const chart = this.getters.getChart(figureId);
32168
32221
  if (!chart) {
32169
32222
  throw new Error(`No chart for the given id: ${figureId}`);
32170
32223
  }
32171
- if (!this.charts[sheetId])
32172
- this.charts[sheetId] = {};
32173
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32224
+ this.charts[figureId] = this.createRuntimeChart(chart);
32174
32225
  }
32175
- return this.charts[sheetId][figureId];
32226
+ return this.charts[figureId];
32176
32227
  }
32177
32228
  /**
32178
32229
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -37816,7 +37867,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37816
37867
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37817
37868
  this.dispatch = dispatch;
37818
37869
  this.sheetId = sheetId;
37819
- const chart = getters.getChart(sheetId, copiedFigureId);
37870
+ const chart = getters.getChart(copiedFigureId);
37820
37871
  if (!chart) {
37821
37872
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
37822
37873
  }
@@ -37837,7 +37888,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37837
37888
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37838
37889
  this.dispatch = dispatch;
37839
37890
  this.sheetId = sheetId;
37840
- const image = getters.getImage(sheetId, copiedFigureId);
37891
+ const image = getters.getImage(copiedFigureId);
37841
37892
  this.copiedImage = deepCopy(image);
37842
37893
  }
37843
37894
  paste(sheetId, figureId, position, size) {
@@ -43847,9 +43898,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43847
43898
  Object.defineProperty(exports, '__esModule', { value: true });
43848
43899
 
43849
43900
 
43850
- __info__.version = '16.1.2';
43851
- __info__.date = '2023-03-01T14:43:45.667Z';
43852
- __info__.hash = '59bec2d';
43901
+ __info__.version = '16.1.3';
43902
+ __info__.date = '2023-03-06T07:18:06.669Z';
43903
+ __info__.hash = '7e26a7c';
43853
43904
 
43854
43905
 
43855
43906
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);