@odoo/o-spreadsheet 16.4.30 → 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 +381 -15
- package/dist/o-spreadsheet.d.ts +1 -1
- package/dist/o-spreadsheet.esm.js +381 -15
- package/dist/o-spreadsheet.iife.js +381 -15
- package/dist/o-spreadsheet.iife.min.js +96 -96
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -16386,7 +16386,7 @@ function truncateLabel(label) {
|
|
|
16386
16386
|
/**
|
|
16387
16387
|
* Get a default chart js configuration
|
|
16388
16388
|
*/
|
|
16389
|
-
function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }) {
|
|
16389
|
+
function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale }, truncateLabels = true) {
|
|
16390
16390
|
return {
|
|
16391
16391
|
type: chart.type,
|
|
16392
16392
|
options: {
|
|
@@ -16439,7 +16439,7 @@ function getDefaultChartJsRuntime(chart, labels, fontColor, { format, locale })
|
|
|
16439
16439
|
},
|
|
16440
16440
|
},
|
|
16441
16441
|
data: {
|
|
16442
|
-
labels: labels.map(truncateLabel),
|
|
16442
|
+
labels: truncateLabels ? labels.map(truncateLabel) : labels,
|
|
16443
16443
|
datasets: [],
|
|
16444
16444
|
},
|
|
16445
16445
|
};
|
|
@@ -17282,9 +17282,9 @@ function canBeLinearChart(labelRange, getters) {
|
|
|
17282
17282
|
}
|
|
17283
17283
|
return true;
|
|
17284
17284
|
}
|
|
17285
|
-
function getLineConfiguration(chart, labels, localeFormat) {
|
|
17285
|
+
function getLineConfiguration(chart, labels, localeFormat, truncateLabels = true) {
|
|
17286
17286
|
const fontColor = chartFontColor(chart.background);
|
|
17287
|
-
const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat);
|
|
17287
|
+
const config = getDefaultChartJsRuntime(chart, labels, fontColor, localeFormat, truncateLabels);
|
|
17288
17288
|
const legend = {
|
|
17289
17289
|
labels: {
|
|
17290
17290
|
fontColor,
|
|
@@ -17360,9 +17360,10 @@ function createLineChartRuntime(chart, getters) {
|
|
|
17360
17360
|
({ labels, dataSetsValues } = aggregateDataForLabels(labels, dataSetsValues));
|
|
17361
17361
|
}
|
|
17362
17362
|
const locale = getters.getLocale();
|
|
17363
|
+
const truncateLabels = axisType === "category";
|
|
17363
17364
|
const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
|
|
17364
17365
|
const localeFormat = { format: dataSetFormat, locale };
|
|
17365
|
-
const config = getLineConfiguration(chart, labels, localeFormat);
|
|
17366
|
+
const config = getLineConfiguration(chart, labels, localeFormat, truncateLabels);
|
|
17366
17367
|
const labelFormat = getChartLabelFormat(getters, chart.labelRange);
|
|
17367
17368
|
if (axisType === "time") {
|
|
17368
17369
|
config.options.scales.xAxes[0].type = "time";
|
|
@@ -31402,7 +31403,7 @@ class BordersPlugin extends CorePlugin {
|
|
|
31402
31403
|
this.clearBorders(cmd.sheetId, cmd.target);
|
|
31403
31404
|
break;
|
|
31404
31405
|
case "REMOVE_COLUMNS_ROWS":
|
|
31405
|
-
for (let el of cmd.elements) {
|
|
31406
|
+
for (let el of [...cmd.elements].sort((a, b) => b - a)) {
|
|
31406
31407
|
if (cmd.dimension === "COL") {
|
|
31407
31408
|
this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
|
|
31408
31409
|
}
|
|
@@ -35773,6 +35774,353 @@ class CompilationParametersBuilder {
|
|
|
35773
35774
|
}
|
|
35774
35775
|
}
|
|
35775
35776
|
|
|
35777
|
+
/**
|
|
35778
|
+
* ####################################################
|
|
35779
|
+
* # INTRODUCTION
|
|
35780
|
+
* ####################################################
|
|
35781
|
+
*
|
|
35782
|
+
* This file contain the function recomputeZones.
|
|
35783
|
+
* This function try to recompute in a performant way
|
|
35784
|
+
* an ensemble of zones possibly overlapping to avoid
|
|
35785
|
+
* overlapping and to reduce the number of zones.
|
|
35786
|
+
*
|
|
35787
|
+
* It also allows to remove some zones from the ensemble.
|
|
35788
|
+
*
|
|
35789
|
+
* In the following example, 2 zones are overlapping.
|
|
35790
|
+
* Applying recomputeZones will return zones without
|
|
35791
|
+
* overlapping:
|
|
35792
|
+
*
|
|
35793
|
+
* ["B3:D4", "D2:E3"] ["B3:C4", "D2:D4", "E2:E3"]
|
|
35794
|
+
*
|
|
35795
|
+
* A B C D E A B C D E
|
|
35796
|
+
* 1 ___ 1 ___
|
|
35797
|
+
* 2 ___|_ | 2 ___| | |
|
|
35798
|
+
* 3 | |_|_| ---> 3 | | |_|
|
|
35799
|
+
* 4 |_____| 4 |___|_|
|
|
35800
|
+
* 6 6
|
|
35801
|
+
* 7 7
|
|
35802
|
+
*
|
|
35803
|
+
*
|
|
35804
|
+
* In the following example, 2 zones are contiguous.
|
|
35805
|
+
* Applying recomputeZones will return only one zone:
|
|
35806
|
+
*
|
|
35807
|
+
* ["B2:B3", "C2:D3"] ["B2:D3"]
|
|
35808
|
+
*
|
|
35809
|
+
* A B C D E A B C D E
|
|
35810
|
+
* 1 _ ___ 1 _____
|
|
35811
|
+
* 2 | | | ---> 2 | |
|
|
35812
|
+
* 3 |_|___| 3 |_____|
|
|
35813
|
+
* 4 4
|
|
35814
|
+
*
|
|
35815
|
+
*
|
|
35816
|
+
* In the following example, we want to remove a zone
|
|
35817
|
+
* from the ensemble. Applying recomputeZones will
|
|
35818
|
+
* return the ensemble without the zone to remove:
|
|
35819
|
+
*
|
|
35820
|
+
* remove ["C3:D3"] ["B2:B4", "C2:D2",
|
|
35821
|
+
* "C4:D4", "E2:E4"]
|
|
35822
|
+
*
|
|
35823
|
+
* A B C D E F A B C D E F
|
|
35824
|
+
* 1 _______ 1 _______
|
|
35825
|
+
* 2 | | ---> 2 | |___| |
|
|
35826
|
+
* 3 | xxx | 3 | |___| |
|
|
35827
|
+
* 4 |_______| 4 |_|___|_|
|
|
35828
|
+
* 5 5
|
|
35829
|
+
*
|
|
35830
|
+
*
|
|
35831
|
+
* The exercise seems simple when we have only 2 zones.
|
|
35832
|
+
* But with n zones and in a performant way, we want to
|
|
35833
|
+
* avoid comparing each zone with all the others.
|
|
35834
|
+
*
|
|
35835
|
+
*
|
|
35836
|
+
* ####################################################
|
|
35837
|
+
* # Methodological approach
|
|
35838
|
+
* ####################################################
|
|
35839
|
+
*
|
|
35840
|
+
* The methodological approach to avoid comparing each
|
|
35841
|
+
* zone with all the others is to use a data structure
|
|
35842
|
+
* that allow to quickly find which zones are
|
|
35843
|
+
* overlapping with any other given zone.
|
|
35844
|
+
*
|
|
35845
|
+
* Here the idea is to profile the zones at the columns level.
|
|
35846
|
+
*
|
|
35847
|
+
* To do that, we propose to use a data structure
|
|
35848
|
+
* composed of 2 parts:
|
|
35849
|
+
* - profilesStartingPosition: a sorted number array
|
|
35850
|
+
* indicating on which columns a new profile begins.
|
|
35851
|
+
* - profiles: a map where the key is a column
|
|
35852
|
+
* position (from profilesStartingPosition) and the
|
|
35853
|
+
* value is a sorted number array representing a
|
|
35854
|
+
* profile.
|
|
35855
|
+
*
|
|
35856
|
+
*
|
|
35857
|
+
* See the following example: here profileStartingPosition
|
|
35858
|
+
* corresponds to [A,C,E,G,K]
|
|
35859
|
+
* A B C D E F G H I J K so with number [0,2,4,6,10]
|
|
35860
|
+
* 1 ' ' ' '
|
|
35861
|
+
* 2 ' ' '_______' here profile correspond
|
|
35862
|
+
* 3 '___' |_______| for A to []
|
|
35863
|
+
* 4 | | for C to [3, 5]
|
|
35864
|
+
* 5 |___| for E to []
|
|
35865
|
+
* 6 for G to [2, 3]
|
|
35866
|
+
* 7 for K to []
|
|
35867
|
+
*
|
|
35868
|
+
*
|
|
35869
|
+
* Now we can easily find which zones are overlapping
|
|
35870
|
+
* with a given zone. Suppose we want to add a new zone
|
|
35871
|
+
* D5:H6 to the ensemble:
|
|
35872
|
+
*
|
|
35873
|
+
* With a binary search of left and right
|
|
35874
|
+
* A B C D E F G H I J K on profilesStartingPosition, we can
|
|
35875
|
+
* 1 ' ' ' ' find the indexes of the profiles on which
|
|
35876
|
+
* 2 ' ' '_______' to apply a modification.
|
|
35877
|
+
* 3 '___' |_______|
|
|
35878
|
+
* 4 | _|_______ Here we will:
|
|
35879
|
+
* 5 |_|_| | - add a new profile in D --> become [3, 6]
|
|
35880
|
+
* 6 |_________| - modify the profile in E --> become [4, 6]
|
|
35881
|
+
* 7 - modify the profile in G --> become [2, 3, 4, 6]
|
|
35882
|
+
* - add a new profile in I --> become [8, 10]
|
|
35883
|
+
*
|
|
35884
|
+
* See below the result:
|
|
35885
|
+
*
|
|
35886
|
+
* Note the particularity of the profile
|
|
35887
|
+
* A B C D E F G H I J K for G: it will correspond to [2, 3, 4, 6]
|
|
35888
|
+
* 1 ' ' ' ' ' '
|
|
35889
|
+
* 2 ' ' ' '___'___' To know how to modify the profile (add a
|
|
35890
|
+
* 3 '_'_' |___|___| zone or remove it) we do a binary
|
|
35891
|
+
* 4 | | |___ ___ search of the top and bottom value on the
|
|
35892
|
+
* 5 |_| | | | profile array. Depending on the result index
|
|
35893
|
+
* 6 |_|___|___| parity (odd or even), because zone boundaries
|
|
35894
|
+
* 7 go by pairs, we know if we are in a zone or
|
|
35895
|
+
* not and how operate.
|
|
35896
|
+
*/
|
|
35897
|
+
/**
|
|
35898
|
+
* Recompute the zone without the cells in toRemoveZones and avoid overlapping.
|
|
35899
|
+
* This compute is particularly useful because after this function:
|
|
35900
|
+
* - you will find coordinate of a cell only once among all the zones
|
|
35901
|
+
* - the number of zones will be reduced to the minimum
|
|
35902
|
+
*/
|
|
35903
|
+
function futureRecomputeZones(zones, zonesToRemove = []) {
|
|
35904
|
+
const profilesStartingPosition = [0];
|
|
35905
|
+
const profiles = new Map([[0, []]]);
|
|
35906
|
+
modifyProfiles(profilesStartingPosition, profiles, zones, false);
|
|
35907
|
+
modifyProfiles(profilesStartingPosition, profiles, zonesToRemove, true);
|
|
35908
|
+
return constructZonesFromProfiles(profilesStartingPosition, profiles);
|
|
35909
|
+
}
|
|
35910
|
+
function modifyProfiles(// export for testing only
|
|
35911
|
+
profilesStartingPosition, profiles, zones, toRemove = false) {
|
|
35912
|
+
for (const zone of zones) {
|
|
35913
|
+
const leftValue = zone.left;
|
|
35914
|
+
const rightValue = zone.right === undefined ? undefined : zone.right + 1;
|
|
35915
|
+
const leftIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, leftValue, true, 0);
|
|
35916
|
+
const rightIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, rightValue, false, leftIndex);
|
|
35917
|
+
for (let i = leftIndex; i <= rightIndex; i++) {
|
|
35918
|
+
const profile = profiles.get(profilesStartingPosition[i]);
|
|
35919
|
+
modifyProfile(profile, zone, toRemove);
|
|
35920
|
+
}
|
|
35921
|
+
// maybe this part cost in performance, and maybe it's not necessary (depending on the use case). To be checked
|
|
35922
|
+
removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex);
|
|
35923
|
+
}
|
|
35924
|
+
}
|
|
35925
|
+
function findIndexAndCreateProfile(profilesStartingPosition, profiles, value, searchLeft, startIndex) {
|
|
35926
|
+
if (value === undefined) {
|
|
35927
|
+
// this is only the case when the value correspond to a bottom value that could be undefined
|
|
35928
|
+
return profilesStartingPosition.length - 1;
|
|
35929
|
+
}
|
|
35930
|
+
const predecessorIndex = binaryPredecessorSearch(profilesStartingPosition, value, startIndex);
|
|
35931
|
+
if (value != profilesStartingPosition[predecessorIndex]) {
|
|
35932
|
+
// mean that the value is not ending/starting at the same position as the previous/next profile
|
|
35933
|
+
// --> it's a new profile
|
|
35934
|
+
// --> we need to add it
|
|
35935
|
+
profilesStartingPosition.splice(predecessorIndex + 1, 0, value);
|
|
35936
|
+
// suppose the we want to add the for the left value
|
|
35937
|
+
// following profile following zone: 'C', the predecessor index
|
|
35938
|
+
// for B: [1, 3] "C3:D4" correspond to 'B'.
|
|
35939
|
+
// The next line code will
|
|
35940
|
+
// A B C D A B C D copy the profile of 'B'
|
|
35941
|
+
// 1 '___' 1 '___' to 'C'. In the rest of the
|
|
35942
|
+
// 2 | | ---> 2 | _|_ process the 'modifyProfile'
|
|
35943
|
+
// 3 |___| 3 |_|_| | function will adapt the waiting
|
|
35944
|
+
// 4 4 |___| 'C' profile [1, 3] to the
|
|
35945
|
+
// correct 'C' profile [1, 4]
|
|
35946
|
+
profiles.set(value, [...profiles.get(profilesStartingPosition[predecessorIndex])]);
|
|
35947
|
+
return searchLeft ? predecessorIndex + 1 : predecessorIndex;
|
|
35948
|
+
}
|
|
35949
|
+
return searchLeft ? predecessorIndex : predecessorIndex - 1;
|
|
35950
|
+
}
|
|
35951
|
+
/**
|
|
35952
|
+
* Suppose the following Suppose we want to add We want to have the
|
|
35953
|
+
* profile: the following zone: following profile:
|
|
35954
|
+
*
|
|
35955
|
+
* A B C D E F A B C D E F A B C D E F
|
|
35956
|
+
* 1 '___' 1 ' ' 1 '___'
|
|
35957
|
+
* 2 |___| 2 '___' 2 | |
|
|
35958
|
+
* 3 ' ' 3 | | 3 | |
|
|
35959
|
+
* 4 '___' --> 4 | | --> 4 | |
|
|
35960
|
+
* 6 | | 6 |___| 6 | |
|
|
35961
|
+
* 7 |___| 7 7 |___|
|
|
35962
|
+
* 8 8 8
|
|
35963
|
+
*
|
|
35964
|
+
* the profile for 'C' the top zone correspond Here [2, 3, 5, 8] with [3, 7]
|
|
35965
|
+
* corresponds to: to 3 and the bottom zone would be merged into [2, 8]
|
|
35966
|
+
* ____ ____ correspond to 6
|
|
35967
|
+
* [2, 3, 5, 8] would be the profile: The difficulty of modify profile
|
|
35968
|
+
* ____ is to know what must be deleted
|
|
35969
|
+
* Note that the 'filled [3, 7] and what must be added to the
|
|
35970
|
+
* zone' are always between existing profile.
|
|
35971
|
+
* an even index and its
|
|
35972
|
+
* next index
|
|
35973
|
+
*
|
|
35974
|
+
*/
|
|
35975
|
+
function modifyProfile(profile, zone, toRemove = false) {
|
|
35976
|
+
const topValue = zone.top;
|
|
35977
|
+
const bottomValue = zone.bottom === undefined ? undefined : zone.bottom + 1;
|
|
35978
|
+
const newPoints = [];
|
|
35979
|
+
// Case we want to add a zone to the profile:
|
|
35980
|
+
// - If the top predecessor index `topPredIndex` is even, it means the top of the zone is already positioned on a filled zone
|
|
35981
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the predecessor.
|
|
35982
|
+
// - If it is odd, it means the top of the zone must be the beginning of a filled zone.
|
|
35983
|
+
// so we can keep the index of the top position
|
|
35984
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
35985
|
+
const topPredIndex = binaryPredecessorSearch(profile, topValue, 0, false);
|
|
35986
|
+
if ((topPredIndex % 2 !== 0 && !toRemove) || (topPredIndex % 2 === 0 && toRemove)) {
|
|
35987
|
+
newPoints.push(topValue);
|
|
35988
|
+
}
|
|
35989
|
+
if (bottomValue === undefined) {
|
|
35990
|
+
// The following two code lines will not impact the final result,
|
|
35991
|
+
// but they will impact the intermediate profile.
|
|
35992
|
+
// We keep them for performance reason
|
|
35993
|
+
profile.splice(topPredIndex + 1);
|
|
35994
|
+
profile.push(...newPoints);
|
|
35995
|
+
return;
|
|
35996
|
+
}
|
|
35997
|
+
// Case we want to add a zone to the profile:
|
|
35998
|
+
// - If the bottom successor index `bottomSuccIndex` is even, it means the bottom of the zone must be the ending of a filled zone
|
|
35999
|
+
// so we can keep the index of the bottom position.
|
|
36000
|
+
// - If it is odd, it means the bottom of the zone is already positioned on a filled zone
|
|
36001
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the successor
|
|
36002
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
36003
|
+
const bottomSuccIndex = binarySuccessorSearch(profile, bottomValue, 0, false);
|
|
36004
|
+
if ((bottomSuccIndex % 2 === 0 && !toRemove) || (bottomSuccIndex % 2 !== 0 && toRemove)) {
|
|
36005
|
+
newPoints.push(bottomValue);
|
|
36006
|
+
}
|
|
36007
|
+
// add the top and bottom value to the profile and
|
|
36008
|
+
// remove all information between the top and bottom index
|
|
36009
|
+
profile.splice(topPredIndex + 1, bottomSuccIndex - topPredIndex - 1, ...newPoints);
|
|
36010
|
+
}
|
|
36011
|
+
function removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex) {
|
|
36012
|
+
const start = leftIndex - 1 === -1 ? 0 : leftIndex - 1;
|
|
36013
|
+
const end = rightIndex === profilesStartingPosition.length - 1 ? rightIndex : rightIndex + 1;
|
|
36014
|
+
for (let i = end; i > start; i--) {
|
|
36015
|
+
if (deepEqualsArray(profiles.get(profilesStartingPosition[i]), profiles.get(profilesStartingPosition[i - 1]))) {
|
|
36016
|
+
profiles.delete(profilesStartingPosition[i]);
|
|
36017
|
+
profilesStartingPosition.splice(i, 1);
|
|
36018
|
+
}
|
|
36019
|
+
}
|
|
36020
|
+
}
|
|
36021
|
+
function constructZonesFromProfiles(profilesStartingPosition, profiles) {
|
|
36022
|
+
const mergedZone = [];
|
|
36023
|
+
let pendingZones = [];
|
|
36024
|
+
for (let colIndex = 0; colIndex < profilesStartingPosition.length; colIndex++) {
|
|
36025
|
+
const left = profilesStartingPosition[colIndex];
|
|
36026
|
+
const profile = profiles.get(left);
|
|
36027
|
+
if (!profile || profile.length === 0) {
|
|
36028
|
+
mergedZone.push(...pendingZones);
|
|
36029
|
+
pendingZones = [];
|
|
36030
|
+
continue;
|
|
36031
|
+
}
|
|
36032
|
+
let right = profilesStartingPosition[colIndex + 1];
|
|
36033
|
+
if (right !== undefined) {
|
|
36034
|
+
right--;
|
|
36035
|
+
}
|
|
36036
|
+
const nextPendingZones = [];
|
|
36037
|
+
for (let i = 0; i < profile.length; i += 2) {
|
|
36038
|
+
const top = profile[i];
|
|
36039
|
+
let bottom = profile[i + 1];
|
|
36040
|
+
if (bottom !== undefined) {
|
|
36041
|
+
bottom--;
|
|
36042
|
+
}
|
|
36043
|
+
const profileZone = {
|
|
36044
|
+
top,
|
|
36045
|
+
left,
|
|
36046
|
+
bottom,
|
|
36047
|
+
right,
|
|
36048
|
+
hasHeader: (bottom === undefined && top !== 0) || (right === undefined && left !== 0),
|
|
36049
|
+
};
|
|
36050
|
+
let findCorrespondingZone = false;
|
|
36051
|
+
for (let j = pendingZones.length - 1; j >= 0; j--) {
|
|
36052
|
+
const pendingZone = pendingZones[j];
|
|
36053
|
+
if (pendingZone.top === profileZone.top && pendingZone.bottom === profileZone.bottom) {
|
|
36054
|
+
pendingZone.right = profileZone.right;
|
|
36055
|
+
pendingZones.splice(j, 1);
|
|
36056
|
+
nextPendingZones.push(pendingZone);
|
|
36057
|
+
findCorrespondingZone = true;
|
|
36058
|
+
break;
|
|
36059
|
+
}
|
|
36060
|
+
}
|
|
36061
|
+
if (!findCorrespondingZone) {
|
|
36062
|
+
nextPendingZones.push(profileZone);
|
|
36063
|
+
}
|
|
36064
|
+
}
|
|
36065
|
+
mergedZone.push(...pendingZones);
|
|
36066
|
+
pendingZones = nextPendingZones;
|
|
36067
|
+
}
|
|
36068
|
+
mergedZone.push(...pendingZones);
|
|
36069
|
+
return mergedZone;
|
|
36070
|
+
}
|
|
36071
|
+
function binaryPredecessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
36072
|
+
let end = arr.length - 1;
|
|
36073
|
+
let result = -1;
|
|
36074
|
+
while (start <= end) {
|
|
36075
|
+
const mid = Math.floor((start + end) / 2);
|
|
36076
|
+
if (arr[mid] === val && matchEqual) {
|
|
36077
|
+
return mid;
|
|
36078
|
+
}
|
|
36079
|
+
else if (arr[mid] < val) {
|
|
36080
|
+
result = mid;
|
|
36081
|
+
start = mid + 1;
|
|
36082
|
+
}
|
|
36083
|
+
else {
|
|
36084
|
+
end = mid - 1;
|
|
36085
|
+
}
|
|
36086
|
+
}
|
|
36087
|
+
return result;
|
|
36088
|
+
}
|
|
36089
|
+
function binarySuccessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
36090
|
+
let end = arr.length - 1;
|
|
36091
|
+
let result = arr.length;
|
|
36092
|
+
while (start <= end) {
|
|
36093
|
+
const mid = Math.floor((start + end) / 2);
|
|
36094
|
+
if (arr[mid] === val && matchEqual) {
|
|
36095
|
+
return mid;
|
|
36096
|
+
}
|
|
36097
|
+
else if (arr[mid] > val) {
|
|
36098
|
+
result = mid;
|
|
36099
|
+
end = mid - 1;
|
|
36100
|
+
}
|
|
36101
|
+
else {
|
|
36102
|
+
start = mid + 1;
|
|
36103
|
+
}
|
|
36104
|
+
}
|
|
36105
|
+
return result;
|
|
36106
|
+
}
|
|
36107
|
+
/**
|
|
36108
|
+
* Compares two arrays.
|
|
36109
|
+
* For performance reasons, this function is to be preferred
|
|
36110
|
+
* to 'deepEquals' in the case we know that the inputs are arrays.
|
|
36111
|
+
*/
|
|
36112
|
+
function deepEqualsArray(arr1, arr2) {
|
|
36113
|
+
if (arr1.length !== arr2.length) {
|
|
36114
|
+
return false;
|
|
36115
|
+
}
|
|
36116
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
36117
|
+
if (!deepEquals(arr1[i], arr2[i])) {
|
|
36118
|
+
return false;
|
|
36119
|
+
}
|
|
36120
|
+
}
|
|
36121
|
+
return true;
|
|
36122
|
+
}
|
|
36123
|
+
|
|
35776
36124
|
function quickselect(arr, k, left, right, compare) {
|
|
35777
36125
|
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
35778
36126
|
}
|
|
@@ -36536,7 +36884,7 @@ class FormulaDependencyGraph {
|
|
|
36536
36884
|
}
|
|
36537
36885
|
}
|
|
36538
36886
|
/**
|
|
36539
|
-
* Return the
|
|
36887
|
+
* Return all the cells that depend on the provided ranges,
|
|
36540
36888
|
* in the correct order they should be evaluated.
|
|
36541
36889
|
* This is called a topological ordering (excluding cycles)
|
|
36542
36890
|
*/
|
|
@@ -36547,11 +36895,20 @@ class FormulaDependencyGraph {
|
|
|
36547
36895
|
const range = queue.pop();
|
|
36548
36896
|
visited.addMany(this.encoder.encodeBoundingBox(range));
|
|
36549
36897
|
const impactedPositionIds = this.rTree.search(range).map((dep) => dep.data);
|
|
36898
|
+
const nextInQueue = {};
|
|
36550
36899
|
for (const positionId of impactedPositionIds) {
|
|
36551
36900
|
if (!visited.has(positionId)) {
|
|
36552
|
-
|
|
36901
|
+
const { sheetId, zone } = this.encoder.decodeToBoundingBox(positionId);
|
|
36902
|
+
if (!nextInQueue[sheetId]) {
|
|
36903
|
+
nextInQueue[sheetId] = [];
|
|
36904
|
+
}
|
|
36905
|
+
nextInQueue[sheetId].push(zone);
|
|
36553
36906
|
}
|
|
36554
36907
|
}
|
|
36908
|
+
for (const sheetId in nextInQueue) {
|
|
36909
|
+
const zones = futureRecomputeZones(nextInQueue[sheetId]);
|
|
36910
|
+
queue.push(...zones.map((zone) => ({ sheetId, zone })));
|
|
36911
|
+
}
|
|
36555
36912
|
}
|
|
36556
36913
|
visited.deleteMany(ranges.flatMap((r) => this.encoder.encodeBoundingBox(r)));
|
|
36557
36914
|
return visited;
|
|
@@ -36700,7 +37057,7 @@ class Evaluator {
|
|
|
36700
37057
|
}
|
|
36701
37058
|
if (!content) {
|
|
36702
37059
|
// The previous content could have blocked some array formulas
|
|
36703
|
-
impactedPositionIds.addMany(this.
|
|
37060
|
+
impactedPositionIds.addMany(this.getArrayFormulasBlockedBy(positionId));
|
|
36704
37061
|
}
|
|
36705
37062
|
}
|
|
36706
37063
|
return impactedPositionIds;
|
|
@@ -36744,13 +37101,22 @@ class Evaluator {
|
|
|
36744
37101
|
}
|
|
36745
37102
|
return positionIds;
|
|
36746
37103
|
}
|
|
36747
|
-
|
|
37104
|
+
/**
|
|
37105
|
+
* Return the position of formulas blocked by the given position
|
|
37106
|
+
* as well as all their dependencies.
|
|
37107
|
+
*/
|
|
37108
|
+
getArrayFormulasBlockedBy(positionId) {
|
|
36748
37109
|
if (!this.spreadingRelations.hasArrayFormulaResult(positionId)) {
|
|
36749
37110
|
return [];
|
|
36750
37111
|
}
|
|
36751
37112
|
const arrayFormulas = this.spreadingRelations.getFormulaPositionsSpreadingOn(positionId);
|
|
36752
37113
|
const cells = new JetSet(arrayFormulas);
|
|
36753
|
-
|
|
37114
|
+
const arrayFormulaPositionId = this.getArrayFormulaSpreadingOnId(positionId);
|
|
37115
|
+
if (arrayFormulaPositionId) {
|
|
37116
|
+
// ignore the formula spreading on the position. Keep only the blocked ones
|
|
37117
|
+
cells.delete(arrayFormulaPositionId);
|
|
37118
|
+
}
|
|
37119
|
+
cells.addMany(this.getCellsDependingOn(cells));
|
|
36754
37120
|
return cells;
|
|
36755
37121
|
}
|
|
36756
37122
|
nextPositionsToUpdate = new JetSet();
|
|
@@ -36917,7 +37283,7 @@ class Evaluator {
|
|
|
36917
37283
|
}
|
|
36918
37284
|
this.evaluatedCells.delete(child);
|
|
36919
37285
|
this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([child]));
|
|
36920
|
-
this.nextPositionsToUpdate.addMany(this.
|
|
37286
|
+
this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedBy(child));
|
|
36921
37287
|
}
|
|
36922
37288
|
this.spreadingRelations.removeNode(positionId);
|
|
36923
37289
|
}
|
|
@@ -51761,6 +52127,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
51761
52127
|
exports.tokenize = tokenize;
|
|
51762
52128
|
|
|
51763
52129
|
|
|
51764
|
-
__info__.version = '16.4.
|
|
51765
|
-
__info__.date = '2024-04-
|
|
51766
|
-
__info__.hash = '
|
|
52130
|
+
__info__.version = '16.4.31';
|
|
52131
|
+
__info__.date = '2024-04-26T07:37:06.433Z';
|
|
52132
|
+
__info__.hash = '16d6656';
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -7242,7 +7242,7 @@ declare function chartFontColor(backgroundColor: Color | undefined): Color;
|
|
|
7242
7242
|
/**
|
|
7243
7243
|
* Get a default chart js configuration
|
|
7244
7244
|
*/
|
|
7245
|
-
declare function getDefaultChartJsRuntime(chart: AbstractChart, labels: string[], fontColor: Color, { format, locale }: LocaleFormat): ChartConfiguration;
|
|
7245
|
+
declare function getDefaultChartJsRuntime(chart: AbstractChart, labels: string[], fontColor: Color, { format, locale }: LocaleFormat, truncateLabels?: boolean): ChartConfiguration;
|
|
7246
7246
|
/** See https://www.chartjs.org/docs/latest/charts/area.html#filling-modes */
|
|
7247
7247
|
declare function getFillingMode(index: number): "origin" | number;
|
|
7248
7248
|
|