Skip to content

Commit

Permalink
[IMP] plugins: remove unused getters
Browse files Browse the repository at this point in the history
As the library evolved, some getters that were created for specific
purpose became completely obsolete (sometimes the features evolved and
theyr were replaces by better alternatives, sometimes, due to a
conceptual evolution, like a finer split between plugins
responsibilities). Some of those getters were not removed at the time
and can be safely removed.

closes #3892

Task: 3825311
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
  • Loading branch information
rrahir committed Mar 25, 2024
1 parent f1a14a3 commit c14269c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 51 deletions.
9 changes: 0 additions & 9 deletions src/plugins/core/merge.ts
Expand Up @@ -47,7 +47,6 @@ export class MergePlugin extends CorePlugin<MergeState> implements MergeState {
"isInSameMerge",
"isMergeHidden",
"getMainCellPosition",
"getBottomLeftCell",
"expandZone",
"doesIntersectMerge",
"doesColumnsHaveCommonMerges",
Expand Down Expand Up @@ -262,14 +261,6 @@ export class MergePlugin extends CorePlugin<MergeState> implements MergeState {
return { sheetId: position.sheetId, col: mergeTopLeftPos.col, row: mergeTopLeftPos.row };
}

getBottomLeftCell(position: CellPosition): CellPosition {
if (!this.isInMerge(position)) {
return position;
}
const { bottom, left } = this.getMerge(position)!;
return { sheetId: position.sheetId, col: left, row: bottom };
}

isMergeHidden(sheetId: UID, merge: Merge): boolean {
const hiddenColsGroups = this.getters.getHiddenColsGroups(sheetId);
const hiddenRowsGroups = this.getters.getHiddenRowsGroups(sheetId);
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/core/sheet.ts
Expand Up @@ -55,7 +55,6 @@ export class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
"getSheetIds",
"getVisibleSheetIds",
"isSheetVisible",
"getEvaluationSheets",
"doesHeaderExist",
"doesHeadersExist",
"getCell",
Expand Down Expand Up @@ -352,10 +351,6 @@ export class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
return this.orderedSheetIds.filter(this.isSheetVisible.bind(this));
}

getEvaluationSheets(): Record<UID, Sheet | undefined> {
return this.sheets;
}

doesHeaderExist(sheetId: UID, dimension: Dimension, index: number) {
return dimension === "COL"
? index >= 0 && index < this.getNumberCols(sheetId)
Expand All @@ -366,14 +361,6 @@ export class SheetPlugin extends CorePlugin<SheetState> implements SheetState {
return headerIndexes.every((index) => this.doesHeaderExist(sheetId, dimension, index));
}

getRow(sheetId: UID, index: HeaderIndex): Row {
const row = this.getSheet(sheetId).rows[index];
if (!row) {
throw new Error(`Row ${row} not found.`);
}
return row;
}

getCell({ sheetId, col, row }: CellPosition): Cell | undefined {
const sheet = this.tryGetSheet(sheetId);
const cellId = sheet?.rows[row]?.cells[col];
Expand Down
18 changes: 0 additions & 18 deletions src/plugins/ui_stateful/selection.ts
Expand Up @@ -6,7 +6,6 @@ import { getClipboardDataPositions } from "../../helpers/clipboard/clipboard_hel
import {
clip,
deepCopy,
formatValue,
isEqual,
positionToZone,
positions,
Expand Down Expand Up @@ -99,7 +98,6 @@ export class GridSelectionPlugin extends UIPlugin {
"getSelectedZone",
"getSelectedCells",
"getStatisticFnResults",
"getAggregate",
"getSelectedFigureId",
"getSelection",
"getActivePosition",
Expand Down Expand Up @@ -458,22 +456,6 @@ export class GridSelectionPlugin extends UIPlugin {
return statisticFnResults;
}

getAggregate(): string | null {
let aggregate = 0;
let n = 0;
const sheetId = this.getters.getActiveSheetId();
const cellPositions = this.gridSelection.zones.map(positions).flat();
for (const { col, row } of cellPositions) {
const cell = this.getters.getEvaluatedCell({ sheetId, col, row });
if (cell.type === CellValueType.number) {
n++;
aggregate += cell.value;
}
}
const locale = this.getters.getLocale();
return n < 2 ? null : formatValue(aggregate, { locale });
}

isSelected(zone: Zone): boolean {
return !!this.getters.getSelectedZones().find((z) => isEqual(z, zone));
}
Expand Down
11 changes: 0 additions & 11 deletions src/types/commands.ts
Expand Up @@ -12,7 +12,6 @@ import {
Border,
BorderData,
CellPosition,
Color,
Dimension,
HeaderIndex,
Pixel,
Expand Down Expand Up @@ -689,15 +688,6 @@ export interface ActivateSheetCommand {
sheetIdTo: UID;
}

/**
* Set a color to be used for the next selection to highlight.
* The color is only used when selection highlight is enabled.
*/
export interface SetColorCommand {
type: "SET_HIGHLIGHT_COLOR";
color: Color;
}

export interface EvaluateCellsCommand {
type: "EVALUATE_CELLS";
}
Expand Down Expand Up @@ -965,7 +955,6 @@ export type LocalCommand =
| ActivateSheetCommand
| EvaluateCellsCommand
| StartChangeHighlightCommand
| SetColorCommand
| StartCommand
| AutofillCommand
| AutofillSelectCommand
Expand Down

0 comments on commit c14269c

Please sign in to comment.