@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
|
@@ -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";
|
|
@@ -31398,7 +31399,7 @@ class BordersPlugin extends CorePlugin {
|
|
|
31398
31399
|
this.clearBorders(cmd.sheetId, cmd.target);
|
|
31399
31400
|
break;
|
|
31400
31401
|
case "REMOVE_COLUMNS_ROWS":
|
|
31401
|
-
for (let el of cmd.elements) {
|
|
31402
|
+
for (let el of [...cmd.elements].sort((a, b) => b - a)) {
|
|
31402
31403
|
if (cmd.dimension === "COL") {
|
|
31403
31404
|
this.shiftBordersHorizontally(cmd.sheetId, el + 1, -1);
|
|
31404
31405
|
}
|
|
@@ -35769,6 +35770,353 @@ class CompilationParametersBuilder {
|
|
|
35769
35770
|
}
|
|
35770
35771
|
}
|
|
35771
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
|
+
|
|
35772
36120
|
function quickselect(arr, k, left, right, compare) {
|
|
35773
36121
|
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
35774
36122
|
}
|
|
@@ -36532,7 +36880,7 @@ class FormulaDependencyGraph {
|
|
|
36532
36880
|
}
|
|
36533
36881
|
}
|
|
36534
36882
|
/**
|
|
36535
|
-
* Return the
|
|
36883
|
+
* Return all the cells that depend on the provided ranges,
|
|
36536
36884
|
* in the correct order they should be evaluated.
|
|
36537
36885
|
* This is called a topological ordering (excluding cycles)
|
|
36538
36886
|
*/
|
|
@@ -36543,11 +36891,20 @@ class FormulaDependencyGraph {
|
|
|
36543
36891
|
const range = queue.pop();
|
|
36544
36892
|
visited.addMany(this.encoder.encodeBoundingBox(range));
|
|
36545
36893
|
const impactedPositionIds = this.rTree.search(range).map((dep) => dep.data);
|
|
36894
|
+
const nextInQueue = {};
|
|
36546
36895
|
for (const positionId of impactedPositionIds) {
|
|
36547
36896
|
if (!visited.has(positionId)) {
|
|
36548
|
-
|
|
36897
|
+
const { sheetId, zone } = this.encoder.decodeToBoundingBox(positionId);
|
|
36898
|
+
if (!nextInQueue[sheetId]) {
|
|
36899
|
+
nextInQueue[sheetId] = [];
|
|
36900
|
+
}
|
|
36901
|
+
nextInQueue[sheetId].push(zone);
|
|
36549
36902
|
}
|
|
36550
36903
|
}
|
|
36904
|
+
for (const sheetId in nextInQueue) {
|
|
36905
|
+
const zones = futureRecomputeZones(nextInQueue[sheetId]);
|
|
36906
|
+
queue.push(...zones.map((zone) => ({ sheetId, zone })));
|
|
36907
|
+
}
|
|
36551
36908
|
}
|
|
36552
36909
|
visited.deleteMany(ranges.flatMap((r) => this.encoder.encodeBoundingBox(r)));
|
|
36553
36910
|
return visited;
|
|
@@ -36696,7 +37053,7 @@ class Evaluator {
|
|
|
36696
37053
|
}
|
|
36697
37054
|
if (!content) {
|
|
36698
37055
|
// The previous content could have blocked some array formulas
|
|
36699
|
-
impactedPositionIds.addMany(this.
|
|
37056
|
+
impactedPositionIds.addMany(this.getArrayFormulasBlockedBy(positionId));
|
|
36700
37057
|
}
|
|
36701
37058
|
}
|
|
36702
37059
|
return impactedPositionIds;
|
|
@@ -36740,13 +37097,22 @@ class Evaluator {
|
|
|
36740
37097
|
}
|
|
36741
37098
|
return positionIds;
|
|
36742
37099
|
}
|
|
36743
|
-
|
|
37100
|
+
/**
|
|
37101
|
+
* Return the position of formulas blocked by the given position
|
|
37102
|
+
* as well as all their dependencies.
|
|
37103
|
+
*/
|
|
37104
|
+
getArrayFormulasBlockedBy(positionId) {
|
|
36744
37105
|
if (!this.spreadingRelations.hasArrayFormulaResult(positionId)) {
|
|
36745
37106
|
return [];
|
|
36746
37107
|
}
|
|
36747
37108
|
const arrayFormulas = this.spreadingRelations.getFormulaPositionsSpreadingOn(positionId);
|
|
36748
37109
|
const cells = new JetSet(arrayFormulas);
|
|
36749
|
-
|
|
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));
|
|
36750
37116
|
return cells;
|
|
36751
37117
|
}
|
|
36752
37118
|
nextPositionsToUpdate = new JetSet();
|
|
@@ -36913,7 +37279,7 @@ class Evaluator {
|
|
|
36913
37279
|
}
|
|
36914
37280
|
this.evaluatedCells.delete(child);
|
|
36915
37281
|
this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([child]));
|
|
36916
|
-
this.nextPositionsToUpdate.addMany(this.
|
|
37282
|
+
this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedBy(child));
|
|
36917
37283
|
}
|
|
36918
37284
|
this.spreadingRelations.removeNode(positionId);
|
|
36919
37285
|
}
|
|
@@ -51725,6 +52091,6 @@ const constants = {
|
|
|
51725
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 };
|
|
51726
52092
|
|
|
51727
52093
|
|
|
51728
|
-
__info__.version = '16.4.
|
|
51729
|
-
__info__.date = '2024-04-
|
|
51730
|
-
__info__.hash = '
|
|
52094
|
+
__info__.version = '16.4.31';
|
|
52095
|
+
__info__.date = '2024-04-26T07:37:06.433Z';
|
|
52096
|
+
__info__.hash = '16d6656';
|