@odoo/o-spreadsheet 16.1.1 → 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
  }
@@ -20515,7 +20512,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20515
20512
  ...this.getChartDefinition(),
20516
20513
  ...updateDefinition,
20517
20514
  };
20518
- // TODORAR add a putain de test - c'est faux de nouveau ...
20519
20515
  return this.env.model.dispatch("UPDATE_CHART", {
20520
20516
  definition,
20521
20517
  id: this.figureId,
@@ -20523,12 +20519,11 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20523
20519
  });
20524
20520
  }
20525
20521
  onTypeChange(type) {
20526
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
20522
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
20527
20523
  if (!context) {
20528
20524
  throw new Error("Chart not defined.");
20529
20525
  }
20530
20526
  const definition = getChartDefinitionFromContextCreation(context, type);
20531
- // TODORAR add a putain de test - c'est faux de nouveau ...
20532
20527
  this.env.model.dispatch("UPDATE_CHART", {
20533
20528
  definition,
20534
20529
  id: this.figureId,
@@ -20536,7 +20531,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20536
20531
  });
20537
20532
  }
20538
20533
  get chartPanel() {
20539
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
20534
+ const type = this.env.model.getters.getChartType(this.figureId);
20540
20535
  if (!type) {
20541
20536
  throw new Error("Chart not defined.");
20542
20537
  }
@@ -20546,8 +20541,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20546
20541
  }
20547
20542
  return chartPanel;
20548
20543
  }
20549
- getChartDefinition() {
20550
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
20544
+ getChartDefinition(figureId = this.figureId) {
20545
+ return this.env.model.getters.getChartDefinition(figureId);
20551
20546
  }
20552
20547
  get chartTypes() {
20553
20548
  return getChartTypes();
@@ -27106,13 +27101,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27106
27101
  data = migrate(data);
27107
27102
  }
27108
27103
  }
27109
- // sanity check: try to fix missing fields/corrupted state by providing
27110
- // sensible default values
27111
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27112
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
27113
- if (data.sheets.length === 0) {
27114
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27115
- }
27104
+ data = repairData(data);
27116
27105
  return data;
27117
27106
  }
27118
27107
  function migrate(data) {
@@ -27350,6 +27339,48 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27350
27339
  },
27351
27340
  },
27352
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
+ }
27353
27384
  /**
27354
27385
  * The goal of this function is to repair corrupted/wrong initial messages caused by
27355
27386
  * a bug.
@@ -27488,6 +27519,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27488
27519
  formats: {},
27489
27520
  borders: {},
27490
27521
  revisionId: DEFAULT_REVISION_ID,
27522
+ uniqueFigureIds: true,
27491
27523
  };
27492
27524
  return data;
27493
27525
  }
@@ -28485,10 +28517,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28485
28517
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
28486
28518
  }
28487
28519
  adaptRanges(applyChange) {
28488
- for (const sheetId of Object.keys(this.charts)) {
28489
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
28490
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28491
- }
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));
28492
28522
  }
28493
28523
  }
28494
28524
  // ---------------------------------------------------------------------------
@@ -28499,20 +28529,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28499
28529
  case "CREATE_CHART":
28500
28530
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
28501
28531
  case "UPDATE_CHART":
28502
- return this.validateChartDefinition(cmd);
28532
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
28503
28533
  default:
28504
28534
  return 0 /* CommandResult.Success */;
28505
28535
  }
28506
28536
  }
28507
28537
  handle(cmd) {
28508
- var _a, _b;
28538
+ var _a;
28509
28539
  switch (cmd.type) {
28510
28540
  case "CREATE_CHART":
28511
28541
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
28512
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28542
+ this.addChart(cmd.id, cmd.definition);
28513
28543
  break;
28514
28544
  case "UPDATE_CHART": {
28515
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28545
+ this.addChart(cmd.id, cmd.definition);
28516
28546
  break;
28517
28547
  }
28518
28548
  case "DUPLICATE_SHEET": {
@@ -28521,7 +28551,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28521
28551
  if (fig.tag === "chart") {
28522
28552
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
28523
28553
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
28524
- 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);
28525
28555
  if (chart) {
28526
28556
  this.dispatch("CREATE_CHART", {
28527
28557
  id: duplicatedFigureId,
@@ -28536,44 +28566,44 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28536
28566
  break;
28537
28567
  }
28538
28568
  case "DELETE_FIGURE":
28539
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
28569
+ this.history.update("charts", cmd.id, undefined);
28540
28570
  break;
28541
28571
  case "DELETE_SHEET":
28542
- this.history.update("charts", cmd.sheetId, undefined);
28572
+ for (let id of this.getChartIds(cmd.sheetId)) {
28573
+ this.history.update("charts", id, undefined);
28574
+ }
28543
28575
  break;
28544
28576
  }
28545
28577
  }
28546
28578
  // ---------------------------------------------------------------------------
28547
28579
  // Getters
28548
28580
  // ---------------------------------------------------------------------------
28549
- getContextCreationChart(sheetId, figureId) {
28550
- var _a, _b;
28551
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
28552
- }
28553
- getChart(sheetId, figureId) {
28581
+ getContextCreationChart(figureId) {
28554
28582
  var _a;
28555
- 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();
28556
28584
  }
28557
- getChartType(sheetId, figureId) {
28558
- var _a, _b;
28559
- 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;
28560
28591
  if (!type) {
28561
28592
  throw new Error("Chart not defined.");
28562
28593
  }
28563
28594
  return type;
28564
28595
  }
28565
- isChartDefined(sheetId, figureId) {
28566
- return figureId in (this.charts[sheetId] || {});
28596
+ isChartDefined(figureId) {
28597
+ return figureId in this.charts && this.charts !== undefined;
28567
28598
  }
28568
28599
  getChartIds(sheetId) {
28569
- // TODORAR refaire ce shit truc
28570
- // on veut un truc du genre Object.keys(this.charts[sheetId] || {} a mon avis
28571
- // return (Object.values(this.charts[sheetId] || {}).filter(isDefined) as AbstractChart[]).map((chart) => chart.id);
28572
- 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);
28573
28603
  }
28574
- getChartDefinition(sheetId, figureId) {
28575
- var _a, _b;
28576
- 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();
28577
28607
  if (!definition) {
28578
28608
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
28579
28609
  }
@@ -28585,28 +28615,35 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28585
28615
  import(data) {
28586
28616
  for (let sheet of data.sheets) {
28587
28617
  if (sheet.figures) {
28588
- const charts = {};
28589
28618
  for (let figure of sheet.figures) {
28590
28619
  // TODO:
28591
28620
  // figure data should be external IMO => chart should be in sheet.chart
28592
28621
  // instead of in figure.data
28593
28622
  if (figure.tag === "chart") {
28594
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28623
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28595
28624
  }
28596
28625
  }
28597
- this.charts[sheet.id] = charts;
28598
28626
  }
28599
28627
  }
28600
28628
  }
28601
28629
  export(data) {
28630
+ var _a;
28602
28631
  if (data.sheets) {
28603
28632
  for (let sheet of data.sheets) {
28604
28633
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
28605
28634
  const sheetFigures = this.getters.getFigures(sheet.id);
28606
- const figures = sheetFigures;
28607
- for (let figure of figures) {
28635
+ const figures = [];
28636
+ for (let sheetFigure of sheetFigures) {
28637
+ const figure = sheetFigure;
28608
28638
  if (figure && figure.tag === "chart") {
28609
- 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);
28610
28647
  }
28611
28648
  }
28612
28649
  sheet.figures = figures;
@@ -28614,13 +28651,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28614
28651
  }
28615
28652
  }
28616
28653
  exportForExcel(data) {
28617
- var _a, _b;
28654
+ var _a;
28618
28655
  for (let sheet of data.sheets) {
28619
28656
  const sheetFigures = this.getters.getFigures(sheet.id);
28620
28657
  const figures = [];
28621
28658
  for (let figure of sheetFigures) {
28622
28659
  if (figure && figure.tag === "chart") {
28623
- 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();
28624
28661
  if (figureData) {
28625
28662
  figures.push({
28626
28663
  ...figure,
@@ -28659,15 +28696,21 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28659
28696
  * Add a chart in the local state. If a chart already exists, this chart is
28660
28697
  * replaced
28661
28698
  */
28662
- addChart(id, sheetId, definition) {
28663
- 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
+ }
28664
28704
  }
28665
28705
  checkChartDuplicate(cmd) {
28666
- var _a;
28667
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
28668
- return 84 /* CommandResult.DuplicatedChartId */;
28669
- }
28670
- 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 */;
28671
28714
  }
28672
28715
  }
28673
28716
  ChartPlugin.getters = [
@@ -29048,7 +29091,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29048
29091
  allowDispatch(cmd) {
29049
29092
  switch (cmd.type) {
29050
29093
  case "CREATE_FIGURE":
29051
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
29094
+ return this.checkFigureDuplicate(cmd.figure.id);
29052
29095
  case "UPDATE_FIGURE":
29053
29096
  case "DELETE_FIGURE":
29054
29097
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -29114,9 +29157,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29114
29157
  }
29115
29158
  return 0 /* CommandResult.Success */;
29116
29159
  }
29117
- checkFigureDuplicate(sheetId, figureId) {
29118
- var _a;
29119
- 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])) {
29120
29162
  return 82 /* CommandResult.DuplicatedFigureId */;
29121
29163
  }
29122
29164
  return 0 /* CommandResult.Success */;
@@ -29131,6 +29173,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29131
29173
  var _a;
29132
29174
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29133
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
+ }
29134
29179
  // ---------------------------------------------------------------------------
29135
29180
  // Import/Export
29136
29181
  // ---------------------------------------------------------------------------
@@ -29155,7 +29200,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29155
29200
  this.export(data);
29156
29201
  }
29157
29202
  }
29158
- FigurePlugin.getters = ["getFigures", "getFigure"];
29203
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
29159
29204
 
29160
29205
  class FilterTable {
29161
29206
  constructor(zone) {
@@ -29882,7 +29927,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29882
29927
  switch (cmd.type) {
29883
29928
  case "CREATE_IMAGE":
29884
29929
  if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
29885
- return 28 /* CommandResult.DuplicatedImageId */;
29930
+ return 28 /* CommandResult.InvalidFigureId */;
29886
29931
  }
29887
29932
  return 0 /* CommandResult.Success */;
29888
29933
  default:
@@ -29902,7 +29947,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29902
29947
  if (fig.tag === "image") {
29903
29948
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
29904
29949
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
29905
- const image = this.getImage(cmd.sheetId, fig.id);
29950
+ const image = this.getImage(fig.id);
29906
29951
  if (image) {
29907
29952
  const size = { width: fig.width, height: fig.height };
29908
29953
  this.dispatch("CREATE_IMAGE", {
@@ -29940,13 +29985,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29940
29985
  // ---------------------------------------------------------------------------
29941
29986
  // Getters
29942
29987
  // ---------------------------------------------------------------------------
29943
- getImage(sheetId, figureId) {
29944
- var _a;
29945
- const image = (_a = this.images[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29946
- if (!image) {
29947
- 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
+ }
29948
29993
  }
29949
- 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;
29950
30001
  }
29951
30002
  // ---------------------------------------------------------------------------
29952
30003
  // Private
@@ -29988,7 +30039,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29988
30039
  return images;
29989
30040
  }
29990
30041
  }
29991
- ImagePlugin.getters = ["getImage"];
30042
+ ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
29992
30043
 
29993
30044
  class MergePlugin extends CorePlugin {
29994
30045
  constructor() {
@@ -31789,9 +31840,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
31789
31840
  return formatColors.filter(isDefined$1);
31790
31841
  }
31791
31842
  getChartColors(sheetId) {
31792
- const charts = this.getters
31793
- .getChartIds(sheetId)
31794
- .map((cid) => this.getters.getChart(sheetId, cid));
31843
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31795
31844
  let chartsColors = new Set();
31796
31845
  for (let chart of charts) {
31797
31846
  if (chart === undefined) {
@@ -32147,37 +32196,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32147
32196
  invalidateCFEvaluationCommands.has(cmd.type) ||
32148
32197
  cmd.type === "EVALUATE_CELLS" ||
32149
32198
  cmd.type === "UPDATE_CELL") {
32150
- for (const sheetId in this.charts) {
32151
- for (const chartId in this.charts[sheetId]) {
32152
- this.charts[sheetId][chartId] = undefined;
32153
- }
32199
+ for (const chartId in this.charts) {
32200
+ this.charts[chartId] = undefined;
32154
32201
  }
32155
32202
  }
32156
32203
  switch (cmd.type) {
32157
32204
  case "UPDATE_CHART":
32158
32205
  case "CREATE_CHART":
32159
32206
  case "DELETE_FIGURE":
32160
- if (this.charts[cmd.sheetId]) {
32161
- this.charts[cmd.sheetId][cmd.id] = undefined;
32162
- }
32207
+ this.charts[cmd.id] = undefined;
32163
32208
  break;
32164
32209
  case "DELETE_SHEET":
32165
- 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
+ }
32166
32215
  break;
32167
32216
  }
32168
32217
  }
32169
- getChartRuntime(sheetId, figureId) {
32170
- var _a;
32171
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32172
- const chart = this.getters.getChart(sheetId, figureId);
32218
+ getChartRuntime(figureId) {
32219
+ if (!this.charts[figureId]) {
32220
+ const chart = this.getters.getChart(figureId);
32173
32221
  if (!chart) {
32174
32222
  throw new Error(`No chart for the given id: ${figureId}`);
32175
32223
  }
32176
- if (!this.charts[sheetId])
32177
- this.charts[sheetId] = {};
32178
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32224
+ this.charts[figureId] = this.createRuntimeChart(chart);
32179
32225
  }
32180
- return this.charts[sheetId][figureId];
32226
+ return this.charts[figureId];
32181
32227
  }
32182
32228
  /**
32183
32229
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -37821,7 +37867,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37821
37867
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37822
37868
  this.dispatch = dispatch;
37823
37869
  this.sheetId = sheetId;
37824
- const chart = getters.getChart(sheetId, copiedFigureId);
37870
+ const chart = getters.getChart(copiedFigureId);
37825
37871
  if (!chart) {
37826
37872
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
37827
37873
  }
@@ -37842,7 +37888,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37842
37888
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37843
37889
  this.dispatch = dispatch;
37844
37890
  this.sheetId = sheetId;
37845
- const image = getters.getImage(sheetId, copiedFigureId);
37891
+ const image = getters.getImage(copiedFigureId);
37846
37892
  this.copiedImage = deepCopy(image);
37847
37893
  }
37848
37894
  paste(sheetId, figureId, position, size) {
@@ -43852,9 +43898,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43852
43898
  Object.defineProperty(exports, '__esModule', { value: true });
43853
43899
 
43854
43900
 
43855
- __info__.version = '16.1.1';
43856
- __info__.date = '2023-02-28T09:39:22.910Z';
43857
- __info__.hash = '943d80d';
43901
+ __info__.version = '16.1.3';
43902
+ __info__.date = '2023-03-06T07:18:06.669Z';
43903
+ __info__.hash = '7e26a7c';
43858
43904
 
43859
43905
 
43860
43906
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);