@odoo/o-spreadsheet 16.4.29 → 16.4.31
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.
- package/dist/o-spreadsheet.cjs.js +623 -282
- package/dist/o-spreadsheet.d.ts +4 -2
- package/dist/o-spreadsheet.esm.js +623 -282
- package/dist/o-spreadsheet.iife.js +623 -282
- package/dist/o-spreadsheet.iife.min.js +237 -237
- package/dist/o_spreadsheet.xml +4 -4
- package/package.json +1 -1
|
@@ -16382,7 +16382,7 @@ function truncateLabel(label) {
|
|
|
16382
16382
|
/**
|
|
16383
16383
|
* Get a default chart js configuration
|
|
16384
16384
|
*/
|
|
16385
|
-
function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }) {
|
|
16385
|
+
function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }, truncateLabels = true) {
|
|
16386
16386
|
return {
|
|
16387
16387
|
type: chart.type,
|
|
16388
16388
|
options: {
|
|
@@ -16435,7 +16435,7 @@ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale })
|
|
|
16435
16435
|
},
|
|
16436
16436
|
},
|
|
16437
16437
|
data: {
|
|
16438
|
-
labels: labels.map(truncateLabel),
|
|
16438
|
+
labels: truncateLabels ? labels.map(truncateLabel) : labels,
|
|
16439
16439
|
datasets: [],
|
|
16440
16440
|
},
|
|
16441
16441
|
};
|
|
@@ -17278,9 +17278,9 @@ function canBeLinearChart(labelRange, getters) {
|
|
|
17278
17278
|
}
|
|
17279
17279
|
return true;
|
|
17280
17280
|
}
|
|
17281
|
-
function getLineConfiguration(chart, labels, localeFormat) {
|
|
17281
|
+
function getLineConfiguration(chart, labels, localeFormat, truncateLabels = true) {
|
|
17282
17282
|
const fontColor = chartFontColor(chart.background);
|
|
17283
|
-
const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
|
|
17283
|
+
const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat, truncateLabels);
|
|
17284
17284
|
const legend = {
|
|
17285
17285
|
labels: {
|
|
17286
17286
|
fontColor,
|
|
@@ -17356,9 +17356,10 @@ function createLineChartRuntime(chart, getters) {
|
|
|
17356
17356
|
({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
|
|
17357
17357
|
}
|
|
17358
17358
|
const locale = getters.getLocale();
|
|
17359
|
+
const truncateLabels = axisType === "category";
|
|
17359
17360
|
const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
|
|
17360
17361
|
const localeFormat = { format: dataSetFormat, locale };
|
|
17361
|
-
const config = getLineConfiguration(chart, labels, localeFormat);
|
|
17362
|
+
const config = getLineConfiguration(chart, labels, localeFormat, truncateLabels);
|
|
17362
17363
|
const labelFormat = getChartLabelFormat(getters, chart.labelRange);
|
|
17363
17364
|
if (axisType === "time") {
|
|
17364
17365
|
config.options.scales.xAxes[0].type = "time";
|
|
@@ -19337,6 +19338,243 @@ function interactiveAddFilter(env, sheetId, target) {
|
|
|
19337
19338
|
}
|
|
19338
19339
|
}
|
|
19339
19340
|
|
|
19341
|
+
function interactiveFreezeColumnsRows(env, dimension, base) {
|
|
19342
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19343
|
+
const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
|
|
19344
|
+
const result = env.model.dispatch(cmd, { sheetId, quantity: base });
|
|
19345
|
+
if (result.isCancelledBecause(68 /* CommandResult.MergeOverlap */)) {
|
|
19346
|
+
env.raiseError(MergeErrorMessage);
|
|
19347
|
+
}
|
|
19348
|
+
}
|
|
19349
|
+
|
|
19350
|
+
const hideCols = {
|
|
19351
|
+
name: HIDE_COLUMNS_NAME,
|
|
19352
|
+
execute: (env) => {
|
|
19353
|
+
const columns = env.model.getters.getElementsFromSelection("COL");
|
|
19354
|
+
env.model.dispatch("HIDE_COLUMNS_ROWS", {
|
|
19355
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19356
|
+
dimension: "COL",
|
|
19357
|
+
elements: columns,
|
|
19358
|
+
});
|
|
19359
|
+
},
|
|
19360
|
+
isVisible: NOT_ALL_VISIBLE_COLS_SELECTED,
|
|
19361
|
+
icon: "o-spreadsheet-Icon.HIDE_COL",
|
|
19362
|
+
};
|
|
19363
|
+
const unhideCols = {
|
|
19364
|
+
name: _lt("Unhide columns"),
|
|
19365
|
+
execute: (env) => {
|
|
19366
|
+
const columns = env.model.getters.getElementsFromSelection("COL");
|
|
19367
|
+
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19368
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19369
|
+
dimension: "COL",
|
|
19370
|
+
elements: columns,
|
|
19371
|
+
});
|
|
19372
|
+
},
|
|
19373
|
+
isVisible: (env) => {
|
|
19374
|
+
const hiddenCols = env.model.getters
|
|
19375
|
+
.getHiddenColsGroups(env.model.getters.getActiveSheetId())
|
|
19376
|
+
.flat();
|
|
19377
|
+
const currentCols = env.model.getters.getElementsFromSelection("COL");
|
|
19378
|
+
return currentCols.some((col) => hiddenCols.includes(col));
|
|
19379
|
+
},
|
|
19380
|
+
};
|
|
19381
|
+
const unhideAllCols = {
|
|
19382
|
+
name: _lt("Unhide all columns"),
|
|
19383
|
+
execute: (env) => {
|
|
19384
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19385
|
+
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19386
|
+
sheetId,
|
|
19387
|
+
dimension: "COL",
|
|
19388
|
+
elements: Array.from(Array(env.model.getters.getNumberCols(sheetId)).keys()),
|
|
19389
|
+
});
|
|
19390
|
+
},
|
|
19391
|
+
isVisible: (env) => env.model.getters.getHiddenColsGroups(env.model.getters.getActiveSheetId()).length > 0,
|
|
19392
|
+
};
|
|
19393
|
+
const hideRows = {
|
|
19394
|
+
name: HIDE_ROWS_NAME,
|
|
19395
|
+
execute: (env) => {
|
|
19396
|
+
const rows = env.model.getters.getElementsFromSelection("ROW");
|
|
19397
|
+
env.model.dispatch("HIDE_COLUMNS_ROWS", {
|
|
19398
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19399
|
+
dimension: "ROW",
|
|
19400
|
+
elements: rows,
|
|
19401
|
+
});
|
|
19402
|
+
},
|
|
19403
|
+
isVisible: NOT_ALL_VISIBLE_ROWS_SELECTED,
|
|
19404
|
+
icon: "o-spreadsheet-Icon.HIDE_ROW",
|
|
19405
|
+
};
|
|
19406
|
+
const unhideRows = {
|
|
19407
|
+
name: _lt("Unhide rows"),
|
|
19408
|
+
execute: (env) => {
|
|
19409
|
+
const columns = env.model.getters.getElementsFromSelection("ROW");
|
|
19410
|
+
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19411
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19412
|
+
dimension: "ROW",
|
|
19413
|
+
elements: columns,
|
|
19414
|
+
});
|
|
19415
|
+
},
|
|
19416
|
+
isVisible: (env) => {
|
|
19417
|
+
const hiddenRows = env.model.getters
|
|
19418
|
+
.getHiddenRowsGroups(env.model.getters.getActiveSheetId())
|
|
19419
|
+
.flat();
|
|
19420
|
+
const currentRows = env.model.getters.getElementsFromSelection("ROW");
|
|
19421
|
+
return currentRows.some((col) => hiddenRows.includes(col));
|
|
19422
|
+
},
|
|
19423
|
+
};
|
|
19424
|
+
const unhideAllRows = {
|
|
19425
|
+
name: _lt("Unhide all rows"),
|
|
19426
|
+
execute: (env) => {
|
|
19427
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19428
|
+
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19429
|
+
sheetId,
|
|
19430
|
+
dimension: "ROW",
|
|
19431
|
+
elements: Array.from(Array(env.model.getters.getNumberRows(sheetId)).keys()),
|
|
19432
|
+
});
|
|
19433
|
+
},
|
|
19434
|
+
isVisible: (env) => env.model.getters.getHiddenRowsGroups(env.model.getters.getActiveSheetId()).length > 0,
|
|
19435
|
+
};
|
|
19436
|
+
const unFreezePane = {
|
|
19437
|
+
name: _lt("Unfreeze"),
|
|
19438
|
+
isVisible: (env) => {
|
|
19439
|
+
const { xSplit, ySplit } = env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId());
|
|
19440
|
+
return xSplit + ySplit > 0;
|
|
19441
|
+
},
|
|
19442
|
+
execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS_ROWS", {
|
|
19443
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19444
|
+
}),
|
|
19445
|
+
icon: "o-spreadsheet-Icon.UNFREEZE",
|
|
19446
|
+
};
|
|
19447
|
+
const freezePane = {
|
|
19448
|
+
name: _lt("Freeze"),
|
|
19449
|
+
icon: "o-spreadsheet-Icon.FREEZE",
|
|
19450
|
+
};
|
|
19451
|
+
const unFreezeRows = {
|
|
19452
|
+
name: _lt("No rows"),
|
|
19453
|
+
execute: (env) => env.model.dispatch("UNFREEZE_ROWS", {
|
|
19454
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19455
|
+
}),
|
|
19456
|
+
isReadonlyAllowed: true,
|
|
19457
|
+
isVisible: (env) => !!env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId()).ySplit,
|
|
19458
|
+
};
|
|
19459
|
+
const freezeFirstRow = {
|
|
19460
|
+
name: _lt("1 row"),
|
|
19461
|
+
execute: (env) => interactiveFreezeColumnsRows(env, "ROW", 1),
|
|
19462
|
+
isReadonlyAllowed: true,
|
|
19463
|
+
};
|
|
19464
|
+
const freezeSecondRow = {
|
|
19465
|
+
name: _lt("2 rows"),
|
|
19466
|
+
execute: (env) => interactiveFreezeColumnsRows(env, "ROW", 2),
|
|
19467
|
+
isReadonlyAllowed: true,
|
|
19468
|
+
};
|
|
19469
|
+
const freezeCurrentRow = {
|
|
19470
|
+
name: _lt("Up to current row"),
|
|
19471
|
+
execute: (env) => {
|
|
19472
|
+
const { bottom } = env.model.getters.getSelectedZone();
|
|
19473
|
+
interactiveFreezeColumnsRows(env, "ROW", bottom + 1);
|
|
19474
|
+
},
|
|
19475
|
+
isReadonlyAllowed: true,
|
|
19476
|
+
};
|
|
19477
|
+
const unFreezeCols = {
|
|
19478
|
+
name: _lt("No columns"),
|
|
19479
|
+
execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS", {
|
|
19480
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19481
|
+
}),
|
|
19482
|
+
isReadonlyAllowed: true,
|
|
19483
|
+
isVisible: (env) => !!env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId()).xSplit,
|
|
19484
|
+
};
|
|
19485
|
+
const freezeFirstCol = {
|
|
19486
|
+
name: _lt("1 column"),
|
|
19487
|
+
execute: (env) => interactiveFreezeColumnsRows(env, "COL", 1),
|
|
19488
|
+
isReadonlyAllowed: true,
|
|
19489
|
+
};
|
|
19490
|
+
const freezeSecondCol = {
|
|
19491
|
+
name: _lt("2 columns"),
|
|
19492
|
+
execute: (env) => interactiveFreezeColumnsRows(env, "COL", 2),
|
|
19493
|
+
isReadonlyAllowed: true,
|
|
19494
|
+
};
|
|
19495
|
+
const freezeCurrentCol = {
|
|
19496
|
+
name: _lt("Up to current column"),
|
|
19497
|
+
execute: (env) => {
|
|
19498
|
+
const { right } = env.model.getters.getSelectedZone();
|
|
19499
|
+
interactiveFreezeColumnsRows(env, "COL", right + 1);
|
|
19500
|
+
},
|
|
19501
|
+
isReadonlyAllowed: true,
|
|
19502
|
+
};
|
|
19503
|
+
const viewGridlines = {
|
|
19504
|
+
name: (env) => env.model.getters.getGridLinesVisibility(env.model.getters.getActiveSheetId())
|
|
19505
|
+
? _lt("Hide gridlines")
|
|
19506
|
+
: _lt("Show gridlines"),
|
|
19507
|
+
execute: (env) => {
|
|
19508
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19509
|
+
env.model.dispatch("SET_GRID_LINES_VISIBILITY", {
|
|
19510
|
+
sheetId,
|
|
19511
|
+
areGridLinesVisible: !env.model.getters.getGridLinesVisibility(sheetId),
|
|
19512
|
+
});
|
|
19513
|
+
},
|
|
19514
|
+
icon: "o-spreadsheet-Icon.SHOW_HIDE_GRID",
|
|
19515
|
+
};
|
|
19516
|
+
const viewFormulas = {
|
|
19517
|
+
name: (env) => env.model.getters.shouldShowFormulas() ? _lt("Hide formulas") : _lt("Show formulas"),
|
|
19518
|
+
execute: (env) => env.model.dispatch("SET_FORMULA_VISIBILITY", { show: !env.model.getters.shouldShowFormulas() }),
|
|
19519
|
+
isReadonlyAllowed: true,
|
|
19520
|
+
icon: "o-spreadsheet-Icon.SHOW_HIDE_FORMULA",
|
|
19521
|
+
};
|
|
19522
|
+
const createRemoveFilter = {
|
|
19523
|
+
name: (env) => selectionContainsFilter(env) ? _lt("Remove selected filters") : _lt("Create filter"),
|
|
19524
|
+
isActive: (env) => selectionContainsFilter(env),
|
|
19525
|
+
isEnabled: (env) => !cannotCreateFilter(env),
|
|
19526
|
+
execute: (env) => createRemoveFilterAction(env),
|
|
19527
|
+
icon: "o-spreadsheet-Icon.FILTER_ICON_INACTIVE",
|
|
19528
|
+
};
|
|
19529
|
+
function selectionContainsFilter(env) {
|
|
19530
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19531
|
+
const selectedZones = env.model.getters.getSelectedZones();
|
|
19532
|
+
return env.model.getters.doesZonesContainFilter(sheetId, selectedZones);
|
|
19533
|
+
}
|
|
19534
|
+
function cannotCreateFilter(env) {
|
|
19535
|
+
return !areZonesContinuous(...env.model.getters.getSelectedZones());
|
|
19536
|
+
}
|
|
19537
|
+
function createRemoveFilterAction(env) {
|
|
19538
|
+
if (selectionContainsFilter(env)) {
|
|
19539
|
+
env.model.dispatch("REMOVE_FILTER_TABLE", {
|
|
19540
|
+
sheetId: env.model.getters.getActiveSheetId(),
|
|
19541
|
+
target: env.model.getters.getSelectedZones(),
|
|
19542
|
+
});
|
|
19543
|
+
return;
|
|
19544
|
+
}
|
|
19545
|
+
if (cannotCreateFilter(env)) {
|
|
19546
|
+
return;
|
|
19547
|
+
}
|
|
19548
|
+
env.model.selection.selectTableAroundSelection();
|
|
19549
|
+
const sheetId = env.model.getters.getActiveSheetId();
|
|
19550
|
+
const selection = env.model.getters.getSelectedZones();
|
|
19551
|
+
interactiveAddFilter(env, sheetId, selection);
|
|
19552
|
+
}
|
|
19553
|
+
|
|
19554
|
+
var ACTION_VIEW = /*#__PURE__*/Object.freeze({
|
|
19555
|
+
__proto__: null,
|
|
19556
|
+
hideCols: hideCols,
|
|
19557
|
+
unhideCols: unhideCols,
|
|
19558
|
+
unhideAllCols: unhideAllCols,
|
|
19559
|
+
hideRows: hideRows,
|
|
19560
|
+
unhideRows: unhideRows,
|
|
19561
|
+
unhideAllRows: unhideAllRows,
|
|
19562
|
+
unFreezePane: unFreezePane,
|
|
19563
|
+
freezePane: freezePane,
|
|
19564
|
+
unFreezeRows: unFreezeRows,
|
|
19565
|
+
freezeFirstRow: freezeFirstRow,
|
|
19566
|
+
freezeSecondRow: freezeSecondRow,
|
|
19567
|
+
freezeCurrentRow: freezeCurrentRow,
|
|
19568
|
+
unFreezeCols: unFreezeCols,
|
|
19569
|
+
freezeFirstCol: freezeFirstCol,
|
|
19570
|
+
freezeSecondCol: freezeSecondCol,
|
|
19571
|
+
freezeCurrentCol: freezeCurrentCol,
|
|
19572
|
+
viewGridlines: viewGridlines,
|
|
19573
|
+
viewFormulas: viewFormulas,
|
|
19574
|
+
createRemoveFilter: createRemoveFilter,
|
|
19575
|
+
createRemoveFilterAction: createRemoveFilterAction
|
|
19576
|
+
});
|
|
19577
|
+
|
|
19340
19578
|
const sortRange = {
|
|
19341
19579
|
name: _lt("Sort range"),
|
|
19342
19580
|
isVisible: IS_ONLY_ONE_RANGE,
|
|
@@ -19360,32 +19598,15 @@ const sortDescending = {
|
|
|
19360
19598
|
},
|
|
19361
19599
|
icon: "o-spreadsheet-Icon.SORT_DESCENDING",
|
|
19362
19600
|
};
|
|
19363
|
-
const
|
|
19364
|
-
name: _lt("Create filter"),
|
|
19365
|
-
execute: (env) =>
|
|
19366
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19367
|
-
const selection = env.model.getters.getSelection().zones;
|
|
19368
|
-
interactiveAddFilter(env, sheetId, selection);
|
|
19369
|
-
},
|
|
19370
|
-
isVisible: (env) => !SELECTION_CONTAINS_FILTER(env),
|
|
19601
|
+
const addRemoveDataFilter = {
|
|
19602
|
+
name: (env) => SELECTION_CONTAINS_FILTER(env) ? _lt("Remove filter") : _lt("Create filter"),
|
|
19603
|
+
execute: (env) => createRemoveFilterAction(env),
|
|
19371
19604
|
isEnabled: (env) => {
|
|
19372
19605
|
const selectedZones = env.model.getters.getSelectedZones();
|
|
19373
19606
|
return areZonesContinuous(...selectedZones);
|
|
19374
19607
|
},
|
|
19375
19608
|
icon: "o-spreadsheet-Icon.MENU_FILTER_ICON",
|
|
19376
19609
|
};
|
|
19377
|
-
const removeDataFilter = {
|
|
19378
|
-
name: _lt("Remove filter"),
|
|
19379
|
-
execute: (env) => {
|
|
19380
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19381
|
-
env.model.dispatch("REMOVE_FILTER_TABLE", {
|
|
19382
|
-
sheetId,
|
|
19383
|
-
target: env.model.getters.getSelectedZones(),
|
|
19384
|
-
});
|
|
19385
|
-
},
|
|
19386
|
-
isVisible: SELECTION_CONTAINS_FILTER,
|
|
19387
|
-
icon: "o-spreadsheet-Icon.MENU_FILTER_ICON",
|
|
19388
|
-
};
|
|
19389
19610
|
const splitToColumns = {
|
|
19390
19611
|
name: _lt("Split text to columns"),
|
|
19391
19612
|
sequence: 1,
|
|
@@ -19765,242 +19986,6 @@ var ACTION_FORMAT = /*#__PURE__*/Object.freeze({
|
|
|
19765
19986
|
clearFormat: clearFormat
|
|
19766
19987
|
});
|
|
19767
19988
|
|
|
19768
|
-
function interactiveFreezeColumnsRows(env, dimension, base) {
|
|
19769
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19770
|
-
const cmd = dimension === "COL" ? "FREEZE_COLUMNS" : "FREEZE_ROWS";
|
|
19771
|
-
const result = env.model.dispatch(cmd, { sheetId, quantity: base });
|
|
19772
|
-
if (result.isCancelledBecause(68 /* CommandResult.MergeOverlap */)) {
|
|
19773
|
-
env.raiseError(MergeErrorMessage);
|
|
19774
|
-
}
|
|
19775
|
-
}
|
|
19776
|
-
|
|
19777
|
-
const hideCols = {
|
|
19778
|
-
name: HIDE_COLUMNS_NAME,
|
|
19779
|
-
execute: (env) => {
|
|
19780
|
-
const columns = env.model.getters.getElementsFromSelection("COL");
|
|
19781
|
-
env.model.dispatch("HIDE_COLUMNS_ROWS", {
|
|
19782
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19783
|
-
dimension: "COL",
|
|
19784
|
-
elements: columns,
|
|
19785
|
-
});
|
|
19786
|
-
},
|
|
19787
|
-
isVisible: NOT_ALL_VISIBLE_COLS_SELECTED,
|
|
19788
|
-
icon: "o-spreadsheet-Icon.HIDE_COL",
|
|
19789
|
-
};
|
|
19790
|
-
const unhideCols = {
|
|
19791
|
-
name: _lt("Unhide columns"),
|
|
19792
|
-
execute: (env) => {
|
|
19793
|
-
const columns = env.model.getters.getElementsFromSelection("COL");
|
|
19794
|
-
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19795
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19796
|
-
dimension: "COL",
|
|
19797
|
-
elements: columns,
|
|
19798
|
-
});
|
|
19799
|
-
},
|
|
19800
|
-
isVisible: (env) => {
|
|
19801
|
-
const hiddenCols = env.model.getters
|
|
19802
|
-
.getHiddenColsGroups(env.model.getters.getActiveSheetId())
|
|
19803
|
-
.flat();
|
|
19804
|
-
const currentCols = env.model.getters.getElementsFromSelection("COL");
|
|
19805
|
-
return currentCols.some((col) => hiddenCols.includes(col));
|
|
19806
|
-
},
|
|
19807
|
-
};
|
|
19808
|
-
const unhideAllCols = {
|
|
19809
|
-
name: _lt("Unhide all columns"),
|
|
19810
|
-
execute: (env) => {
|
|
19811
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19812
|
-
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19813
|
-
sheetId,
|
|
19814
|
-
dimension: "COL",
|
|
19815
|
-
elements: Array.from(Array(env.model.getters.getNumberCols(sheetId)).keys()),
|
|
19816
|
-
});
|
|
19817
|
-
},
|
|
19818
|
-
isVisible: (env) => env.model.getters.getHiddenColsGroups(env.model.getters.getActiveSheetId()).length > 0,
|
|
19819
|
-
};
|
|
19820
|
-
const hideRows = {
|
|
19821
|
-
name: HIDE_ROWS_NAME,
|
|
19822
|
-
execute: (env) => {
|
|
19823
|
-
const rows = env.model.getters.getElementsFromSelection("ROW");
|
|
19824
|
-
env.model.dispatch("HIDE_COLUMNS_ROWS", {
|
|
19825
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19826
|
-
dimension: "ROW",
|
|
19827
|
-
elements: rows,
|
|
19828
|
-
});
|
|
19829
|
-
},
|
|
19830
|
-
isVisible: NOT_ALL_VISIBLE_ROWS_SELECTED,
|
|
19831
|
-
icon: "o-spreadsheet-Icon.HIDE_ROW",
|
|
19832
|
-
};
|
|
19833
|
-
const unhideRows = {
|
|
19834
|
-
name: _lt("Unhide rows"),
|
|
19835
|
-
execute: (env) => {
|
|
19836
|
-
const columns = env.model.getters.getElementsFromSelection("ROW");
|
|
19837
|
-
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19838
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19839
|
-
dimension: "ROW",
|
|
19840
|
-
elements: columns,
|
|
19841
|
-
});
|
|
19842
|
-
},
|
|
19843
|
-
isVisible: (env) => {
|
|
19844
|
-
const hiddenRows = env.model.getters
|
|
19845
|
-
.getHiddenRowsGroups(env.model.getters.getActiveSheetId())
|
|
19846
|
-
.flat();
|
|
19847
|
-
const currentRows = env.model.getters.getElementsFromSelection("ROW");
|
|
19848
|
-
return currentRows.some((col) => hiddenRows.includes(col));
|
|
19849
|
-
},
|
|
19850
|
-
};
|
|
19851
|
-
const unhideAllRows = {
|
|
19852
|
-
name: _lt("Unhide all rows"),
|
|
19853
|
-
execute: (env) => {
|
|
19854
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19855
|
-
env.model.dispatch("UNHIDE_COLUMNS_ROWS", {
|
|
19856
|
-
sheetId,
|
|
19857
|
-
dimension: "ROW",
|
|
19858
|
-
elements: Array.from(Array(env.model.getters.getNumberRows(sheetId)).keys()),
|
|
19859
|
-
});
|
|
19860
|
-
},
|
|
19861
|
-
isVisible: (env) => env.model.getters.getHiddenRowsGroups(env.model.getters.getActiveSheetId()).length > 0,
|
|
19862
|
-
};
|
|
19863
|
-
const unFreezePane = {
|
|
19864
|
-
name: _lt("Unfreeze"),
|
|
19865
|
-
isVisible: (env) => {
|
|
19866
|
-
const { xSplit, ySplit } = env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId());
|
|
19867
|
-
return xSplit + ySplit > 0;
|
|
19868
|
-
},
|
|
19869
|
-
execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS_ROWS", {
|
|
19870
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19871
|
-
}),
|
|
19872
|
-
icon: "o-spreadsheet-Icon.UNFREEZE",
|
|
19873
|
-
};
|
|
19874
|
-
const freezePane = {
|
|
19875
|
-
name: _lt("Freeze"),
|
|
19876
|
-
icon: "o-spreadsheet-Icon.FREEZE",
|
|
19877
|
-
};
|
|
19878
|
-
const unFreezeRows = {
|
|
19879
|
-
name: _lt("No rows"),
|
|
19880
|
-
execute: (env) => env.model.dispatch("UNFREEZE_ROWS", {
|
|
19881
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19882
|
-
}),
|
|
19883
|
-
isReadonlyAllowed: true,
|
|
19884
|
-
isVisible: (env) => !!env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId()).ySplit,
|
|
19885
|
-
};
|
|
19886
|
-
const freezeFirstRow = {
|
|
19887
|
-
name: _lt("1 row"),
|
|
19888
|
-
execute: (env) => interactiveFreezeColumnsRows(env, "ROW", 1),
|
|
19889
|
-
isReadonlyAllowed: true,
|
|
19890
|
-
};
|
|
19891
|
-
const freezeSecondRow = {
|
|
19892
|
-
name: _lt("2 rows"),
|
|
19893
|
-
execute: (env) => interactiveFreezeColumnsRows(env, "ROW", 2),
|
|
19894
|
-
isReadonlyAllowed: true,
|
|
19895
|
-
};
|
|
19896
|
-
const freezeCurrentRow = {
|
|
19897
|
-
name: _lt("Up to current row"),
|
|
19898
|
-
execute: (env) => {
|
|
19899
|
-
const { bottom } = env.model.getters.getSelectedZone();
|
|
19900
|
-
interactiveFreezeColumnsRows(env, "ROW", bottom + 1);
|
|
19901
|
-
},
|
|
19902
|
-
isReadonlyAllowed: true,
|
|
19903
|
-
};
|
|
19904
|
-
const unFreezeCols = {
|
|
19905
|
-
name: _lt("No columns"),
|
|
19906
|
-
execute: (env) => env.model.dispatch("UNFREEZE_COLUMNS", {
|
|
19907
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19908
|
-
}),
|
|
19909
|
-
isReadonlyAllowed: true,
|
|
19910
|
-
isVisible: (env) => !!env.model.getters.getPaneDivisions(env.model.getters.getActiveSheetId()).xSplit,
|
|
19911
|
-
};
|
|
19912
|
-
const freezeFirstCol = {
|
|
19913
|
-
name: _lt("1 column"),
|
|
19914
|
-
execute: (env) => interactiveFreezeColumnsRows(env, "COL", 1),
|
|
19915
|
-
isReadonlyAllowed: true,
|
|
19916
|
-
};
|
|
19917
|
-
const freezeSecondCol = {
|
|
19918
|
-
name: _lt("2 columns"),
|
|
19919
|
-
execute: (env) => interactiveFreezeColumnsRows(env, "COL", 2),
|
|
19920
|
-
isReadonlyAllowed: true,
|
|
19921
|
-
};
|
|
19922
|
-
const freezeCurrentCol = {
|
|
19923
|
-
name: _lt("Up to current column"),
|
|
19924
|
-
execute: (env) => {
|
|
19925
|
-
const { right } = env.model.getters.getSelectedZone();
|
|
19926
|
-
interactiveFreezeColumnsRows(env, "COL", right + 1);
|
|
19927
|
-
},
|
|
19928
|
-
isReadonlyAllowed: true,
|
|
19929
|
-
};
|
|
19930
|
-
const viewGridlines = {
|
|
19931
|
-
name: (env) => env.model.getters.getGridLinesVisibility(env.model.getters.getActiveSheetId())
|
|
19932
|
-
? _lt("Hide gridlines")
|
|
19933
|
-
: _lt("Show gridlines"),
|
|
19934
|
-
execute: (env) => {
|
|
19935
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19936
|
-
env.model.dispatch("SET_GRID_LINES_VISIBILITY", {
|
|
19937
|
-
sheetId,
|
|
19938
|
-
areGridLinesVisible: !env.model.getters.getGridLinesVisibility(sheetId),
|
|
19939
|
-
});
|
|
19940
|
-
},
|
|
19941
|
-
icon: "o-spreadsheet-Icon.SHOW_HIDE_GRID",
|
|
19942
|
-
};
|
|
19943
|
-
const viewFormulas = {
|
|
19944
|
-
name: (env) => env.model.getters.shouldShowFormulas() ? _lt("Hide formulas") : _lt("Show formulas"),
|
|
19945
|
-
execute: (env) => env.model.dispatch("SET_FORMULA_VISIBILITY", { show: !env.model.getters.shouldShowFormulas() }),
|
|
19946
|
-
isReadonlyAllowed: true,
|
|
19947
|
-
icon: "o-spreadsheet-Icon.SHOW_HIDE_FORMULA",
|
|
19948
|
-
};
|
|
19949
|
-
const createRemoveFilter = {
|
|
19950
|
-
name: (env) => selectionContainsFilter(env) ? _lt("Remove selected filters") : _lt("Create filter"),
|
|
19951
|
-
isActive: (env) => selectionContainsFilter(env),
|
|
19952
|
-
isEnabled: (env) => !cannotCreateFilter(env),
|
|
19953
|
-
execute: (env) => createRemoveFilterAction(env),
|
|
19954
|
-
icon: "o-spreadsheet-Icon.FILTER_ICON_INACTIVE",
|
|
19955
|
-
};
|
|
19956
|
-
function selectionContainsFilter(env) {
|
|
19957
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19958
|
-
const selectedZones = env.model.getters.getSelectedZones();
|
|
19959
|
-
return env.model.getters.doesZonesContainFilter(sheetId, selectedZones);
|
|
19960
|
-
}
|
|
19961
|
-
function cannotCreateFilter(env) {
|
|
19962
|
-
return !areZonesContinuous(...env.model.getters.getSelectedZones());
|
|
19963
|
-
}
|
|
19964
|
-
function createRemoveFilterAction(env) {
|
|
19965
|
-
if (selectionContainsFilter(env)) {
|
|
19966
|
-
env.model.dispatch("REMOVE_FILTER_TABLE", {
|
|
19967
|
-
sheetId: env.model.getters.getActiveSheetId(),
|
|
19968
|
-
target: env.model.getters.getSelectedZones(),
|
|
19969
|
-
});
|
|
19970
|
-
return;
|
|
19971
|
-
}
|
|
19972
|
-
if (cannotCreateFilter(env)) {
|
|
19973
|
-
return;
|
|
19974
|
-
}
|
|
19975
|
-
env.model.selection.selectTableAroundSelection();
|
|
19976
|
-
const sheetId = env.model.getters.getActiveSheetId();
|
|
19977
|
-
const selection = env.model.getters.getSelectedZones();
|
|
19978
|
-
interactiveAddFilter(env, sheetId, selection);
|
|
19979
|
-
}
|
|
19980
|
-
|
|
19981
|
-
var ACTION_VIEW = /*#__PURE__*/Object.freeze({
|
|
19982
|
-
__proto__: null,
|
|
19983
|
-
hideCols: hideCols,
|
|
19984
|
-
unhideCols: unhideCols,
|
|
19985
|
-
unhideAllCols: unhideAllCols,
|
|
19986
|
-
hideRows: hideRows,
|
|
19987
|
-
unhideRows: unhideRows,
|
|
19988
|
-
unhideAllRows: unhideAllRows,
|
|
19989
|
-
unFreezePane: unFreezePane,
|
|
19990
|
-
freezePane: freezePane,
|
|
19991
|
-
unFreezeRows: unFreezeRows,
|
|
19992
|
-
freezeFirstRow: freezeFirstRow,
|
|
19993
|
-
freezeSecondRow: freezeSecondRow,
|
|
19994
|
-
freezeCurrentRow: freezeCurrentRow,
|
|
19995
|
-
unFreezeCols: unFreezeCols,
|
|
19996
|
-
freezeFirstCol: freezeFirstCol,
|
|
19997
|
-
freezeSecondCol: freezeSecondCol,
|
|
19998
|
-
freezeCurrentCol: freezeCurrentCol,
|
|
19999
|
-
viewGridlines: viewGridlines,
|
|
20000
|
-
viewFormulas: viewFormulas,
|
|
20001
|
-
createRemoveFilter: createRemoveFilter
|
|
20002
|
-
});
|
|
20003
|
-
|
|
20004
19989
|
const colMenuRegistry = new MenuItemRegistry();
|
|
20005
19990
|
colMenuRegistry
|
|
20006
19991
|
.add("cut", {
|
|
@@ -20575,12 +20560,8 @@ topbarMenuRegistry
|
|
|
20575
20560
|
sequence: 20,
|
|
20576
20561
|
separator: true,
|
|
20577
20562
|
})
|
|
20578
|
-
.addChild("
|
|
20579
|
-
...
|
|
20580
|
-
sequence: 30,
|
|
20581
|
-
})
|
|
20582
|
-
.addChild("remove_data_filter", ["data"], {
|
|
20583
|
-
...removeDataFilter,
|
|
20563
|
+
.addChild("add_remove_data_filter", ["data"], {
|
|
20564
|
+
...addRemoveDataFilter,
|
|
20584
20565
|
sequence: 30,
|
|
20585
20566
|
});
|
|
20586
20567
|
|
|
@@ -31418,7 +31399,7 @@ class BordersPlugin extends CorePlugin {
|
|
|
31418
31399
|
this.clearBorders(cmd.sheetId, cmd.target);
|
|
31419
31400
|
break;
|
|
31420
31401
|
case "REMOVE_COLUMNS_ROWS":
|
|
31421
|
-
for (let el of cmd.elements) {
|
|
31402
|
+
for (let el of [...cmd.elements].sort((a, b) => b - a)) {
|
|
31422
31403
|
if (cmd.dimension === "COL") {
|
|
31423
31404
|
this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
|
|
31424
31405
|
}
|
|
@@ -35789,6 +35770,353 @@ class CompilationParametersBuilder {
|
|
|
35789
35770
|
}
|
|
35790
35771
|
}
|
|
35791
35772
|
|
|
35773
|
+
/**
|
|
35774
|
+
* ####################################################
|
|
35775
|
+
* # INTRODUCTION
|
|
35776
|
+
* ####################################################
|
|
35777
|
+
*
|
|
35778
|
+
* This file contain the function recomputeZones.
|
|
35779
|
+
* This function try to recompute in a performant way
|
|
35780
|
+
* an ensemble of zones possibly overlapping to avoid
|
|
35781
|
+
* overlapping and to reduce the number of zones.
|
|
35782
|
+
*
|
|
35783
|
+
* It also allows to remove some zones from the ensemble.
|
|
35784
|
+
*
|
|
35785
|
+
* In the following example, 2 zones are overlapping.
|
|
35786
|
+
* Applying recomputeZones will return zones without
|
|
35787
|
+
* overlapping:
|
|
35788
|
+
*
|
|
35789
|
+
* ["B3:D4", "D2:E3"] ["B3:C4", "D2:D4", "E2:E3"]
|
|
35790
|
+
*
|
|
35791
|
+
* A B C D E A B C D E
|
|
35792
|
+
* 1 ___ 1 ___
|
|
35793
|
+
* 2 ___|_ | 2 ___| | |
|
|
35794
|
+
* 3 | |_|_| ---> 3 | | |_|
|
|
35795
|
+
* 4 |_____| 4 |___|_|
|
|
35796
|
+
* 6 6
|
|
35797
|
+
* 7 7
|
|
35798
|
+
*
|
|
35799
|
+
*
|
|
35800
|
+
* In the following example, 2 zones are contiguous.
|
|
35801
|
+
* Applying recomputeZones will return only one zone:
|
|
35802
|
+
*
|
|
35803
|
+
* ["B2:B3", "C2:D3"] ["B2:D3"]
|
|
35804
|
+
*
|
|
35805
|
+
* A B C D E A B C D E
|
|
35806
|
+
* 1 _ ___ 1 _____
|
|
35807
|
+
* 2 | | | ---> 2 | |
|
|
35808
|
+
* 3 |_|___| 3 |_____|
|
|
35809
|
+
* 4 4
|
|
35810
|
+
*
|
|
35811
|
+
*
|
|
35812
|
+
* In the following example, we want to remove a zone
|
|
35813
|
+
* from the ensemble. Applying recomputeZones will
|
|
35814
|
+
* return the ensemble without the zone to remove:
|
|
35815
|
+
*
|
|
35816
|
+
* remove ["C3:D3"] ["B2:B4", "C2:D2",
|
|
35817
|
+
* "C4:D4", "E2:E4"]
|
|
35818
|
+
*
|
|
35819
|
+
* A B C D E F A B C D E F
|
|
35820
|
+
* 1 _______ 1 _______
|
|
35821
|
+
* 2 | | ---> 2 | |___| |
|
|
35822
|
+
* 3 | xxx | 3 | |___| |
|
|
35823
|
+
* 4 |_______| 4 |_|___|_|
|
|
35824
|
+
* 5 5
|
|
35825
|
+
*
|
|
35826
|
+
*
|
|
35827
|
+
* The exercise seems simple when we have only 2 zones.
|
|
35828
|
+
* But with n zones and in a performant way, we want to
|
|
35829
|
+
* avoid comparing each zone with all the others.
|
|
35830
|
+
*
|
|
35831
|
+
*
|
|
35832
|
+
* ####################################################
|
|
35833
|
+
* # Methodological approach
|
|
35834
|
+
* ####################################################
|
|
35835
|
+
*
|
|
35836
|
+
* The methodological approach to avoid comparing each
|
|
35837
|
+
* zone with all the others is to use a data structure
|
|
35838
|
+
* that allow to quickly find which zones are
|
|
35839
|
+
* overlapping with any other given zone.
|
|
35840
|
+
*
|
|
35841
|
+
* Here the idea is to profile the zones at the columns level.
|
|
35842
|
+
*
|
|
35843
|
+
* To do that, we propose to use a data structure
|
|
35844
|
+
* composed of 2 parts:
|
|
35845
|
+
* - profilesStartingPosition: a sorted number array
|
|
35846
|
+
* indicating on which columns a new profile begins.
|
|
35847
|
+
* - profiles: a map where the key is a column
|
|
35848
|
+
* position (from profilesStartingPosition) and the
|
|
35849
|
+
* value is a sorted number array representing a
|
|
35850
|
+
* profile.
|
|
35851
|
+
*
|
|
35852
|
+
*
|
|
35853
|
+
* See the following example: here profileStartingPosition
|
|
35854
|
+
* corresponds to [A,C,E,G,K]
|
|
35855
|
+
* A B C D E F G H I J K so with number [0,2,4,6,10]
|
|
35856
|
+
* 1 ' ' ' '
|
|
35857
|
+
* 2 ' ' '_______' here profile correspond
|
|
35858
|
+
* 3 '___' |_______| for A to []
|
|
35859
|
+
* 4 | | for C to [3, 5]
|
|
35860
|
+
* 5 |___| for E to []
|
|
35861
|
+
* 6 for G to [2, 3]
|
|
35862
|
+
* 7 for K to []
|
|
35863
|
+
*
|
|
35864
|
+
*
|
|
35865
|
+
* Now we can easily find which zones are overlapping
|
|
35866
|
+
* with a given zone. Suppose we want to add a new zone
|
|
35867
|
+
* D5:H6 to the ensemble:
|
|
35868
|
+
*
|
|
35869
|
+
* With a binary search of left and right
|
|
35870
|
+
* A B C D E F G H I J K on profilesStartingPosition, we can
|
|
35871
|
+
* 1 ' ' ' ' find the indexes of the profiles on which
|
|
35872
|
+
* 2 ' ' '_______' to apply a modification.
|
|
35873
|
+
* 3 '___' |_______|
|
|
35874
|
+
* 4 | _|_______ Here we will:
|
|
35875
|
+
* 5 |_|_| | - add a new profile in D --> become [3, 6]
|
|
35876
|
+
* 6 |_________| - modify the profile in E --> become [4, 6]
|
|
35877
|
+
* 7 - modify the profile in G --> become [2, 3, 4, 6]
|
|
35878
|
+
* - add a new profile in I --> become [8, 10]
|
|
35879
|
+
*
|
|
35880
|
+
* See below the result:
|
|
35881
|
+
*
|
|
35882
|
+
* Note the particularity of the profile
|
|
35883
|
+
* A B C D E F G H I J K for G: it will correspond to [2, 3, 4, 6]
|
|
35884
|
+
* 1 ' ' ' ' ' '
|
|
35885
|
+
* 2 ' ' ' '___'___' To know how to modify the profile (add a
|
|
35886
|
+
* 3 '_'_' |___|___| zone or remove it) we do a binary
|
|
35887
|
+
* 4 | | |___ ___ search of the top and bottom value on the
|
|
35888
|
+
* 5 |_| | | | profile array. Depending on the result index
|
|
35889
|
+
* 6 |_|___|___| parity (odd or even), because zone boundaries
|
|
35890
|
+
* 7 go by pairs, we know if we are in a zone or
|
|
35891
|
+
* not and how operate.
|
|
35892
|
+
*/
|
|
35893
|
+
/**
|
|
35894
|
+
* Recompute the zone without the cells in toRemoveZones and avoid overlapping.
|
|
35895
|
+
* This compute is particularly useful because after this function:
|
|
35896
|
+
* - you will find coordinate of a cell only once among all the zones
|
|
35897
|
+
* - the number of zones will be reduced to the minimum
|
|
35898
|
+
*/
|
|
35899
|
+
function futureRecomputeZones(zones, zonesToRemove = []) {
|
|
35900
|
+
const profilesStartingPosition = [0];
|
|
35901
|
+
const profiles = new Map([[0, []]]);
|
|
35902
|
+
modifyProfiles(profilesStartingPosition, profiles, zones, false);
|
|
35903
|
+
modifyProfiles(profilesStartingPosition, profiles, zonesToRemove, true);
|
|
35904
|
+
return constructZonesFromProfiles(profilesStartingPosition, profiles);
|
|
35905
|
+
}
|
|
35906
|
+
function modifyProfiles(// export for testing only
|
|
35907
|
+
profilesStartingPosition, profiles, zones, toRemove = false) {
|
|
35908
|
+
for (const zone of zones) {
|
|
35909
|
+
const leftValue = zone.left;
|
|
35910
|
+
const rightValue = zone.right === undefined ? undefined : zone.right + 1;
|
|
35911
|
+
const leftIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, leftValue, true, 0);
|
|
35912
|
+
const rightIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, rightValue, false, leftIndex);
|
|
35913
|
+
for (let i = leftIndex; i <= rightIndex; i++) {
|
|
35914
|
+
const profile = profiles.get(profilesStartingPosition[i]);
|
|
35915
|
+
modifyProfile(profile, zone, toRemove);
|
|
35916
|
+
}
|
|
35917
|
+
// maybe this part cost in performance, and maybe it's not necessary (depending on the use case). To be checked
|
|
35918
|
+
removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex);
|
|
35919
|
+
}
|
|
35920
|
+
}
|
|
35921
|
+
function findIndexAndCreateProfile(profilesStartingPosition, profiles, value, searchLeft, startIndex) {
|
|
35922
|
+
if (value === undefined) {
|
|
35923
|
+
// this is only the case when the value correspond to a bottom value that could be undefined
|
|
35924
|
+
return profilesStartingPosition.length - 1;
|
|
35925
|
+
}
|
|
35926
|
+
const predecessorIndex = binaryPredecessorSearch(profilesStartingPosition, value, startIndex);
|
|
35927
|
+
if (value != profilesStartingPosition[predecessorIndex]) {
|
|
35928
|
+
// mean that the value is not ending/starting at the same position as the previous/next profile
|
|
35929
|
+
// --> it's a new profile
|
|
35930
|
+
// --> we need to add it
|
|
35931
|
+
profilesStartingPosition.splice(predecessorIndex + 1, 0, value);
|
|
35932
|
+
// suppose the we want to add the for the left value
|
|
35933
|
+
// following profile following zone: 'C', the predecessor index
|
|
35934
|
+
// for B: [1, 3] "C3:D4" correspond to 'B'.
|
|
35935
|
+
// The next line code will
|
|
35936
|
+
// A B C D A B C D copy the profile of 'B'
|
|
35937
|
+
// 1 '___' 1 '___' to 'C'. In the rest of the
|
|
35938
|
+
// 2 | | ---> 2 | _|_ process the 'modifyProfile'
|
|
35939
|
+
// 3 |___| 3 |_|_| | function will adapt the waiting
|
|
35940
|
+
// 4 4 |___| 'C' profile [1, 3] to the
|
|
35941
|
+
// correct 'C' profile [1, 4]
|
|
35942
|
+
profiles.set(value, [...profiles.get(profilesStartingPosition[predecessorIndex])]);
|
|
35943
|
+
return searchLeft ? predecessorIndex + 1 : predecessorIndex;
|
|
35944
|
+
}
|
|
35945
|
+
return searchLeft ? predecessorIndex : predecessorIndex - 1;
|
|
35946
|
+
}
|
|
35947
|
+
/**
|
|
35948
|
+
* Suppose the following Suppose we want to add We want to have the
|
|
35949
|
+
* profile: the following zone: following profile:
|
|
35950
|
+
*
|
|
35951
|
+
* A B C D E F A B C D E F A B C D E F
|
|
35952
|
+
* 1 '___' 1 ' ' 1 '___'
|
|
35953
|
+
* 2 |___| 2 '___' 2 | |
|
|
35954
|
+
* 3 ' ' 3 | | 3 | |
|
|
35955
|
+
* 4 '___' --> 4 | | --> 4 | |
|
|
35956
|
+
* 6 | | 6 |___| 6 | |
|
|
35957
|
+
* 7 |___| 7 7 |___|
|
|
35958
|
+
* 8 8 8
|
|
35959
|
+
*
|
|
35960
|
+
* the profile for 'C' the top zone correspond Here [2, 3, 5, 8] with [3, 7]
|
|
35961
|
+
* corresponds to: to 3 and the bottom zone would be merged into [2, 8]
|
|
35962
|
+
* ____ ____ correspond to 6
|
|
35963
|
+
* [2, 3, 5, 8] would be the profile: The difficulty of modify profile
|
|
35964
|
+
* ____ is to know what must be deleted
|
|
35965
|
+
* Note that the 'filled [3, 7] and what must be added to the
|
|
35966
|
+
* zone' are always between existing profile.
|
|
35967
|
+
* an even index and its
|
|
35968
|
+
* next index
|
|
35969
|
+
*
|
|
35970
|
+
*/
|
|
35971
|
+
function modifyProfile(profile, zone, toRemove = false) {
|
|
35972
|
+
const topValue = zone.top;
|
|
35973
|
+
const bottomValue = zone.bottom === undefined ? undefined : zone.bottom + 1;
|
|
35974
|
+
const newPoints = [];
|
|
35975
|
+
// Case we want to add a zone to the profile:
|
|
35976
|
+
// - If the top predecessor index `topPredIndex` is even, it means the top of the zone is already positioned on a filled zone
|
|
35977
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the predecessor.
|
|
35978
|
+
// - If it is odd, it means the top of the zone must be the beginning of a filled zone.
|
|
35979
|
+
// so we can keep the index of the top position
|
|
35980
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
35981
|
+
const topPredIndex = binaryPredecessorSearch(profile, topValue, 0, false);
|
|
35982
|
+
if ((topPredIndex % 2 !== 0 && !toRemove) || (topPredIndex % 2 === 0 && toRemove)) {
|
|
35983
|
+
newPoints.push(topValue);
|
|
35984
|
+
}
|
|
35985
|
+
if (bottomValue === undefined) {
|
|
35986
|
+
// The following two code lines will not impact the final result,
|
|
35987
|
+
// but they will impact the intermediate profile.
|
|
35988
|
+
// We keep them for performance reason
|
|
35989
|
+
profile.splice(topPredIndex + 1);
|
|
35990
|
+
profile.push(...newPoints);
|
|
35991
|
+
return;
|
|
35992
|
+
}
|
|
35993
|
+
// Case we want to add a zone to the profile:
|
|
35994
|
+
// - If the bottom successor index `bottomSuccIndex` is even, it means the bottom of the zone must be the ending of a filled zone
|
|
35995
|
+
// so we can keep the index of the bottom position.
|
|
35996
|
+
// - If it is odd, it means the bottom of the zone is already positioned on a filled zone
|
|
35997
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the successor
|
|
35998
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
35999
|
+
const bottomSuccIndex = binarySuccessorSearch(profile, bottomValue, 0, false);
|
|
36000
|
+
if ((bottomSuccIndex % 2 === 0 && !toRemove) || (bottomSuccIndex % 2 !== 0 && toRemove)) {
|
|
36001
|
+
newPoints.push(bottomValue);
|
|
36002
|
+
}
|
|
36003
|
+
// add the top and bottom value to the profile and
|
|
36004
|
+
// remove all information between the top and bottom index
|
|
36005
|
+
profile.splice(topPredIndex + 1, bottomSuccIndex - topPredIndex - 1, ...newPoints);
|
|
36006
|
+
}
|
|
36007
|
+
function removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex) {
|
|
36008
|
+
const start = leftIndex - 1 === -1 ? 0 : leftIndex - 1;
|
|
36009
|
+
const end = rightIndex === profilesStartingPosition.length - 1 ? rightIndex : rightIndex + 1;
|
|
36010
|
+
for (let i = end; i > start; i--) {
|
|
36011
|
+
if (deepEqualsArray(profiles.get(profilesStartingPosition[i]), profiles.get(profilesStartingPosition[i - 1]))) {
|
|
36012
|
+
profiles.delete(profilesStartingPosition[i]);
|
|
36013
|
+
profilesStartingPosition.splice(i, 1);
|
|
36014
|
+
}
|
|
36015
|
+
}
|
|
36016
|
+
}
|
|
36017
|
+
function constructZonesFromProfiles(profilesStartingPosition, profiles) {
|
|
36018
|
+
const mergedZone = [];
|
|
36019
|
+
let pendingZones = [];
|
|
36020
|
+
for (let colIndex = 0; colIndex < profilesStartingPosition.length; colIndex++) {
|
|
36021
|
+
const left = profilesStartingPosition[colIndex];
|
|
36022
|
+
const profile = profiles.get(left);
|
|
36023
|
+
if (!profile || profile.length === 0) {
|
|
36024
|
+
mergedZone.push(...pendingZones);
|
|
36025
|
+
pendingZones = [];
|
|
36026
|
+
continue;
|
|
36027
|
+
}
|
|
36028
|
+
let right = profilesStartingPosition[colIndex + 1];
|
|
36029
|
+
if (right !== undefined) {
|
|
36030
|
+
right--;
|
|
36031
|
+
}
|
|
36032
|
+
const nextPendingZones = [];
|
|
36033
|
+
for (let i = 0; i < profile.length; i += 2) {
|
|
36034
|
+
const top = profile[i];
|
|
36035
|
+
let bottom = profile[i + 1];
|
|
36036
|
+
if (bottom !== undefined) {
|
|
36037
|
+
bottom--;
|
|
36038
|
+
}
|
|
36039
|
+
const profileZone = {
|
|
36040
|
+
top,
|
|
36041
|
+
left,
|
|
36042
|
+
bottom,
|
|
36043
|
+
right,
|
|
36044
|
+
hasHeader: (bottom === undefined && top !== 0) || (right === undefined && left !== 0),
|
|
36045
|
+
};
|
|
36046
|
+
let findCorrespondingZone = false;
|
|
36047
|
+
for (let j = pendingZones.length - 1; j >= 0; j--) {
|
|
36048
|
+
const pendingZone = pendingZones[j];
|
|
36049
|
+
if (pendingZone.top === profileZone.top && pendingZone.bottom === profileZone.bottom) {
|
|
36050
|
+
pendingZone.right = profileZone.right;
|
|
36051
|
+
pendingZones.splice(j, 1);
|
|
36052
|
+
nextPendingZones.push(pendingZone);
|
|
36053
|
+
findCorrespondingZone = true;
|
|
36054
|
+
break;
|
|
36055
|
+
}
|
|
36056
|
+
}
|
|
36057
|
+
if (!findCorrespondingZone) {
|
|
36058
|
+
nextPendingZones.push(profileZone);
|
|
36059
|
+
}
|
|
36060
|
+
}
|
|
36061
|
+
mergedZone.push(...pendingZones);
|
|
36062
|
+
pendingZones = nextPendingZones;
|
|
36063
|
+
}
|
|
36064
|
+
mergedZone.push(...pendingZones);
|
|
36065
|
+
return mergedZone;
|
|
36066
|
+
}
|
|
36067
|
+
function binaryPredecessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
36068
|
+
let end = arr.length - 1;
|
|
36069
|
+
let result = -1;
|
|
36070
|
+
while (start <= end) {
|
|
36071
|
+
const mid = Math.floor((start + end) / 2);
|
|
36072
|
+
if (arr[mid] === val && matchEqual) {
|
|
36073
|
+
return mid;
|
|
36074
|
+
}
|
|
36075
|
+
else if (arr[mid] < val) {
|
|
36076
|
+
result = mid;
|
|
36077
|
+
start = mid + 1;
|
|
36078
|
+
}
|
|
36079
|
+
else {
|
|
36080
|
+
end = mid - 1;
|
|
36081
|
+
}
|
|
36082
|
+
}
|
|
36083
|
+
return result;
|
|
36084
|
+
}
|
|
36085
|
+
function binarySuccessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
36086
|
+
let end = arr.length - 1;
|
|
36087
|
+
let result = arr.length;
|
|
36088
|
+
while (start <= end) {
|
|
36089
|
+
const mid = Math.floor((start + end) / 2);
|
|
36090
|
+
if (arr[mid] === val && matchEqual) {
|
|
36091
|
+
return mid;
|
|
36092
|
+
}
|
|
36093
|
+
else if (arr[mid] > val) {
|
|
36094
|
+
result = mid;
|
|
36095
|
+
end = mid - 1;
|
|
36096
|
+
}
|
|
36097
|
+
else {
|
|
36098
|
+
start = mid + 1;
|
|
36099
|
+
}
|
|
36100
|
+
}
|
|
36101
|
+
return result;
|
|
36102
|
+
}
|
|
36103
|
+
/**
|
|
36104
|
+
* Compares two arrays.
|
|
36105
|
+
* For performance reasons, this function is to be preferred
|
|
36106
|
+
* to 'deepEquals' in the case we know that the inputs are arrays.
|
|
36107
|
+
*/
|
|
36108
|
+
function deepEqualsArray(arr1, arr2) {
|
|
36109
|
+
if (arr1.length !== arr2.length) {
|
|
36110
|
+
return false;
|
|
36111
|
+
}
|
|
36112
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
36113
|
+
if (!deepEquals(arr1[i], arr2[i])) {
|
|
36114
|
+
return false;
|
|
36115
|
+
}
|
|
36116
|
+
}
|
|
36117
|
+
return true;
|
|
36118
|
+
}
|
|
36119
|
+
|
|
35792
36120
|
function quickselect(arr, k, left, right, compare) {
|
|
35793
36121
|
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
35794
36122
|
}
|
|
@@ -36552,7 +36880,7 @@ class FormulaDependencyGraph {
|
|
|
36552
36880
|
}
|
|
36553
36881
|
}
|
|
36554
36882
|
/**
|
|
36555
|
-
* Return the
|
|
36883
|
+
* Return all the cells that depend on the provided ranges,
|
|
36556
36884
|
* in the correct order they should be evaluated.
|
|
36557
36885
|
* This is called a topological ordering (excluding cycles)
|
|
36558
36886
|
*/
|
|
@@ -36563,11 +36891,20 @@ class FormulaDependencyGraph {
|
|
|
36563
36891
|
const range = queue.pop();
|
|
36564
36892
|
visited.addMany(this.encoder.encodeBoundingBox(range));
|
|
36565
36893
|
const impactedPositionIds = this.rTree.search(range).map((dep) => dep.data);
|
|
36894
|
+
const nextInQueue = {};
|
|
36566
36895
|
for (const positionId of impactedPositionIds) {
|
|
36567
36896
|
if (!visited.has(positionId)) {
|
|
36568
|
-
|
|
36897
|
+
const { sheetId, zone } = this.encoder.decodeToBoundingBox(positionId);
|
|
36898
|
+
if (!nextInQueue[sheetId]) {
|
|
36899
|
+
nextInQueue[sheetId] = [];
|
|
36900
|
+
}
|
|
36901
|
+
nextInQueue[sheetId].push(zone);
|
|
36569
36902
|
}
|
|
36570
36903
|
}
|
|
36904
|
+
for (const sheetId in nextInQueue) {
|
|
36905
|
+
const zones = futureRecomputeZones(nextInQueue[sheetId]);
|
|
36906
|
+
queue.push(...zones.map((zone) => ({ sheetId, zone })));
|
|
36907
|
+
}
|
|
36571
36908
|
}
|
|
36572
36909
|
visited.deleteMany(ranges.flatMap((r) => this.encoder.encodeBoundingBox(r)));
|
|
36573
36910
|
return visited;
|
|
@@ -36716,7 +37053,7 @@ class Evaluator {
|
|
|
36716
37053
|
}
|
|
36717
37054
|
if (!content) {
|
|
36718
37055
|
// The previous content could have blocked some array formulas
|
|
36719
|
-
impactedPositionIds.addMany(this.
|
|
37056
|
+
impactedPositionIds.addMany(this.getArrayFormulasBlockedBy(positionId));
|
|
36720
37057
|
}
|
|
36721
37058
|
}
|
|
36722
37059
|
return impactedPositionIds;
|
|
@@ -36760,13 +37097,22 @@ class Evaluator {
|
|
|
36760
37097
|
}
|
|
36761
37098
|
return positionIds;
|
|
36762
37099
|
}
|
|
36763
|
-
|
|
37100
|
+
/**
|
|
37101
|
+
* Return the position of formulas blocked by the given position
|
|
37102
|
+
* as well as all their dependencies.
|
|
37103
|
+
*/
|
|
37104
|
+
getArrayFormulasBlockedBy(positionId) {
|
|
36764
37105
|
if (!this.spreadingRelations.hasArrayFormulaResult(positionId)) {
|
|
36765
37106
|
return [];
|
|
36766
37107
|
}
|
|
36767
37108
|
const arrayFormulas = this.spreadingRelations.getFormulaPositionsSpreadingOn(positionId);
|
|
36768
37109
|
const cells = new JetSet(arrayFormulas);
|
|
36769
|
-
|
|
37110
|
+
const arrayFormulaPositionId = this.getArrayFormulaSpreadingOnId(positionId);
|
|
37111
|
+
if (arrayFormulaPositionId) {
|
|
37112
|
+
// ignore the formula spreading on the position. Keep only the blocked ones
|
|
37113
|
+
cells.delete(arrayFormulaPositionId);
|
|
37114
|
+
}
|
|
37115
|
+
cells.addMany(this.getCellsDependingOn(cells));
|
|
36770
37116
|
return cells;
|
|
36771
37117
|
}
|
|
36772
37118
|
nextPositionsToUpdate = new JetSet();
|
|
@@ -36933,7 +37279,7 @@ class Evaluator {
|
|
|
36933
37279
|
}
|
|
36934
37280
|
this.evaluatedCells.delete(child);
|
|
36935
37281
|
this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([child]));
|
|
36936
|
-
this.nextPositionsToUpdate.addMany(this.
|
|
37282
|
+
this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedBy(child));
|
|
36937
37283
|
}
|
|
36938
37284
|
this.spreadingRelations.removeNode(positionId);
|
|
36939
37285
|
}
|
|
@@ -46752,7 +47098,6 @@ css /* scss */ `
|
|
|
46752
47098
|
cursor: pointer;
|
|
46753
47099
|
}
|
|
46754
47100
|
`;
|
|
46755
|
-
let tKey = 1;
|
|
46756
47101
|
class SpreadsheetDashboard extends Component {
|
|
46757
47102
|
static template = "o-spreadsheet-SpreadsheetDashboard";
|
|
46758
47103
|
static components = {
|
|
@@ -46830,13 +47175,9 @@ class SpreadsheetDashboard extends Component {
|
|
|
46830
47175
|
coordinates: rect,
|
|
46831
47176
|
position: { col, row },
|
|
46832
47177
|
action,
|
|
46833
|
-
// we can't rely on position only because a row or a column could
|
|
46834
|
-
// be inserted at any time.
|
|
46835
|
-
tKey: `${tKey}-${col}-${row}`,
|
|
46836
47178
|
});
|
|
46837
47179
|
}
|
|
46838
47180
|
}
|
|
46839
|
-
tKey++;
|
|
46840
47181
|
return cells;
|
|
46841
47182
|
}
|
|
46842
47183
|
getClickableAction(position) {
|
|
@@ -51750,6 +52091,6 @@ const constants = {
|
|
|
51750
52091
|
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 };
|
|
51751
52092
|
|
|
51752
52093
|
|
|
51753
|
-
__info__.version = '16.4.
|
|
51754
|
-
__info__.date = '2024-04-
|
|
51755
|
-
__info__.hash = '
|
|
52094
|
+
__info__.version = '16.4.31';
|
|
52095
|
+
__info__.date = '2024-04-26T07:37:06.433Z';
|
|
52096
|
+
__info__.hash = '16d6656';
|