@odoo/o-spreadsheet 17.0.56 → 17.0.57
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 +594 -466
- package/dist/o-spreadsheet.d.ts +19 -10
- package/dist/o-spreadsheet.esm.js +594 -466
- package/dist/o-spreadsheet.iife.js +594 -466
- package/dist/o-spreadsheet.iife.min.js +16 -16
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
4
4
|
* @see https://github.com/odoo/o-spreadsheet
|
|
5
|
-
* @version 17.0.
|
|
6
|
-
* @date 2025-04-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.57
|
|
6
|
+
* @date 2025-04-14T17:13:56.677Z
|
|
7
|
+
* @hash 6ac8bb7
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -2003,6 +2003,7 @@ const coreTypes = new Set([
|
|
|
2003
2003
|
"CLEAR_FORMATTING",
|
|
2004
2004
|
"SET_BORDER",
|
|
2005
2005
|
"SET_ZONE_BORDERS",
|
|
2006
|
+
"SET_BORDERS_ON_TARGET",
|
|
2006
2007
|
/** CHART */
|
|
2007
2008
|
"CREATE_CHART",
|
|
2008
2009
|
"UPDATE_CHART",
|
|
@@ -34685,6 +34686,15 @@ class BordersPlugin extends CorePlugin {
|
|
|
34685
34686
|
case "SET_BORDER":
|
|
34686
34687
|
this.setBorder(cmd.sheetId, cmd.col, cmd.row, cmd.border);
|
|
34687
34688
|
break;
|
|
34689
|
+
case "SET_BORDERS_ON_TARGET":
|
|
34690
|
+
for (const zone of cmd.target) {
|
|
34691
|
+
for (let row = zone.top; row <= zone.bottom; row++) {
|
|
34692
|
+
for (let col = zone.left; col <= zone.right; col++) {
|
|
34693
|
+
this.setBorder(cmd.sheetId, col, row, cmd.border);
|
|
34694
|
+
}
|
|
34695
|
+
}
|
|
34696
|
+
}
|
|
34697
|
+
break;
|
|
34688
34698
|
case "SET_ZONE_BORDERS":
|
|
34689
34699
|
if (cmd.border) {
|
|
34690
34700
|
const target = cmd.target.map((zone) => this.getters.expandZone(cmd.sheetId, zone));
|
|
@@ -36691,6 +36701,353 @@ class ChartPlugin extends CorePlugin {
|
|
|
36691
36701
|
}
|
|
36692
36702
|
}
|
|
36693
36703
|
|
|
36704
|
+
/**
|
|
36705
|
+
* ####################################################
|
|
36706
|
+
* # INTRODUCTION
|
|
36707
|
+
* ####################################################
|
|
36708
|
+
*
|
|
36709
|
+
* This file contain the function recomputeZones.
|
|
36710
|
+
* This function try to recompute in a performant way
|
|
36711
|
+
* an ensemble of zones possibly overlapping to avoid
|
|
36712
|
+
* overlapping and to reduce the number of zones.
|
|
36713
|
+
*
|
|
36714
|
+
* It also allows to remove some zones from the ensemble.
|
|
36715
|
+
*
|
|
36716
|
+
* In the following example, 2 zones are overlapping.
|
|
36717
|
+
* Applying recomputeZones will return zones without
|
|
36718
|
+
* overlapping:
|
|
36719
|
+
*
|
|
36720
|
+
* ["B3:D4", "D2:E3"] ["B3:C4", "D2:D4", "E2:E3"]
|
|
36721
|
+
*
|
|
36722
|
+
* A B C D E A B C D E
|
|
36723
|
+
* 1 ___ 1 ___
|
|
36724
|
+
* 2 ___|_ | 2 ___| | |
|
|
36725
|
+
* 3 | |_|_| ---> 3 | | |_|
|
|
36726
|
+
* 4 |_____| 4 |___|_|
|
|
36727
|
+
* 6 6
|
|
36728
|
+
* 7 7
|
|
36729
|
+
*
|
|
36730
|
+
*
|
|
36731
|
+
* In the following example, 2 zones are contiguous.
|
|
36732
|
+
* Applying recomputeZones will return only one zone:
|
|
36733
|
+
*
|
|
36734
|
+
* ["B2:B3", "C2:D3"] ["B2:D3"]
|
|
36735
|
+
*
|
|
36736
|
+
* A B C D E A B C D E
|
|
36737
|
+
* 1 _ ___ 1 _____
|
|
36738
|
+
* 2 | | | ---> 2 | |
|
|
36739
|
+
* 3 |_|___| 3 |_____|
|
|
36740
|
+
* 4 4
|
|
36741
|
+
*
|
|
36742
|
+
*
|
|
36743
|
+
* In the following example, we want to remove a zone
|
|
36744
|
+
* from the ensemble. Applying recomputeZones will
|
|
36745
|
+
* return the ensemble without the zone to remove:
|
|
36746
|
+
*
|
|
36747
|
+
* remove ["C3:D3"] ["B2:B4", "C2:D2",
|
|
36748
|
+
* "C4:D4", "E2:E4"]
|
|
36749
|
+
*
|
|
36750
|
+
* A B C D E F A B C D E F
|
|
36751
|
+
* 1 _______ 1 _______
|
|
36752
|
+
* 2 | | ---> 2 | |___| |
|
|
36753
|
+
* 3 | xxx | 3 | |___| |
|
|
36754
|
+
* 4 |_______| 4 |_|___|_|
|
|
36755
|
+
* 5 5
|
|
36756
|
+
*
|
|
36757
|
+
*
|
|
36758
|
+
* The exercise seems simple when we have only 2 zones.
|
|
36759
|
+
* But with n zones and in a performant way, we want to
|
|
36760
|
+
* avoid comparing each zone with all the others.
|
|
36761
|
+
*
|
|
36762
|
+
*
|
|
36763
|
+
* ####################################################
|
|
36764
|
+
* # Methodological approach
|
|
36765
|
+
* ####################################################
|
|
36766
|
+
*
|
|
36767
|
+
* The methodological approach to avoid comparing each
|
|
36768
|
+
* zone with all the others is to use a data structure
|
|
36769
|
+
* that allow to quickly find which zones are
|
|
36770
|
+
* overlapping with any other given zone.
|
|
36771
|
+
*
|
|
36772
|
+
* Here the idea is to profile the zones at the columns level.
|
|
36773
|
+
*
|
|
36774
|
+
* To do that, we propose to use a data structure
|
|
36775
|
+
* composed of 2 parts:
|
|
36776
|
+
* - profilesStartingPosition: a sorted number array
|
|
36777
|
+
* indicating on which columns a new profile begins.
|
|
36778
|
+
* - profiles: a map where the key is a column
|
|
36779
|
+
* position (from profilesStartingPosition) and the
|
|
36780
|
+
* value is a sorted number array representing a
|
|
36781
|
+
* profile.
|
|
36782
|
+
*
|
|
36783
|
+
*
|
|
36784
|
+
* See the following example: here profileStartingPosition
|
|
36785
|
+
* corresponds to [A,C,E,G,K]
|
|
36786
|
+
* A B C D E F G H I J K so with number [0,2,4,6,10]
|
|
36787
|
+
* 1 ' ' ' '
|
|
36788
|
+
* 2 ' ' '_______' here profile correspond
|
|
36789
|
+
* 3 '___' |_______| for A to []
|
|
36790
|
+
* 4 | | for C to [3, 5]
|
|
36791
|
+
* 5 |___| for E to []
|
|
36792
|
+
* 6 for G to [2, 3]
|
|
36793
|
+
* 7 for K to []
|
|
36794
|
+
*
|
|
36795
|
+
*
|
|
36796
|
+
* Now we can easily find which zones are overlapping
|
|
36797
|
+
* with a given zone. Suppose we want to add a new zone
|
|
36798
|
+
* D5:H6 to the ensemble:
|
|
36799
|
+
*
|
|
36800
|
+
* With a binary search of left and right
|
|
36801
|
+
* A B C D E F G H I J K on profilesStartingPosition, we can
|
|
36802
|
+
* 1 ' ' ' ' find the indexes of the profiles on which
|
|
36803
|
+
* 2 ' ' '_______' to apply a modification.
|
|
36804
|
+
* 3 '___' |_______|
|
|
36805
|
+
* 4 | _|_______ Here we will:
|
|
36806
|
+
* 5 |_|_| | - add a new profile in D --> become [3, 6]
|
|
36807
|
+
* 6 |_________| - modify the profile in E --> become [4, 6]
|
|
36808
|
+
* 7 - modify the profile in G --> become [2, 3, 4, 6]
|
|
36809
|
+
* - add a new profile in I --> become [8, 10]
|
|
36810
|
+
*
|
|
36811
|
+
* See below the result:
|
|
36812
|
+
*
|
|
36813
|
+
* Note the particularity of the profile
|
|
36814
|
+
* A B C D E F G H I J K for G: it will correspond to [2, 3, 4, 6]
|
|
36815
|
+
* 1 ' ' ' ' ' '
|
|
36816
|
+
* 2 ' ' ' '___'___' To know how to modify the profile (add a
|
|
36817
|
+
* 3 '_'_' |___|___| zone or remove it) we do a binary
|
|
36818
|
+
* 4 | | |___ ___ search of the top and bottom value on the
|
|
36819
|
+
* 5 |_| | | | profile array. Depending on the result index
|
|
36820
|
+
* 6 |_|___|___| parity (odd or even), because zone boundaries
|
|
36821
|
+
* 7 go by pairs, we know if we are in a zone or
|
|
36822
|
+
* not and how operate.
|
|
36823
|
+
*/
|
|
36824
|
+
/**
|
|
36825
|
+
* Recompute the zone without the cells in toRemoveZones and avoid overlapping.
|
|
36826
|
+
* This compute is particularly useful because after this function:
|
|
36827
|
+
* - you will find coordinate of a cell only once among all the zones
|
|
36828
|
+
* - the number of zones will be reduced to the minimum
|
|
36829
|
+
*/
|
|
36830
|
+
function futureRecomputeZones(zones, zonesToRemove = []) {
|
|
36831
|
+
const profilesStartingPosition = [0];
|
|
36832
|
+
const profiles = new Map([[0, []]]);
|
|
36833
|
+
modifyProfiles(profilesStartingPosition, profiles, zones, false);
|
|
36834
|
+
modifyProfiles(profilesStartingPosition, profiles, zonesToRemove, true);
|
|
36835
|
+
return constructZonesFromProfiles(profilesStartingPosition, profiles);
|
|
36836
|
+
}
|
|
36837
|
+
function modifyProfiles(// export for testing only
|
|
36838
|
+
profilesStartingPosition, profiles, zones, toRemove = false) {
|
|
36839
|
+
for (const zone of zones) {
|
|
36840
|
+
const leftValue = zone.left;
|
|
36841
|
+
const rightValue = zone.right === undefined ? undefined : zone.right + 1;
|
|
36842
|
+
const leftIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, leftValue, true, 0);
|
|
36843
|
+
const rightIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, rightValue, false, leftIndex);
|
|
36844
|
+
for (let i = leftIndex; i <= rightIndex; i++) {
|
|
36845
|
+
const profile = profiles.get(profilesStartingPosition[i]);
|
|
36846
|
+
modifyProfile(profile, zone, toRemove);
|
|
36847
|
+
}
|
|
36848
|
+
// maybe this part cost in performance, and maybe it's not necessary (depending on the use case). To be checked
|
|
36849
|
+
removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex);
|
|
36850
|
+
}
|
|
36851
|
+
}
|
|
36852
|
+
function findIndexAndCreateProfile(profilesStartingPosition, profiles, value, searchLeft, startIndex) {
|
|
36853
|
+
if (value === undefined) {
|
|
36854
|
+
// this is only the case when the value correspond to a bottom value that could be undefined
|
|
36855
|
+
return profilesStartingPosition.length - 1;
|
|
36856
|
+
}
|
|
36857
|
+
const predecessorIndex = binaryPredecessorSearch(profilesStartingPosition, value, startIndex);
|
|
36858
|
+
if (value != profilesStartingPosition[predecessorIndex]) {
|
|
36859
|
+
// mean that the value is not ending/starting at the same position as the previous/next profile
|
|
36860
|
+
// --> it's a new profile
|
|
36861
|
+
// --> we need to add it
|
|
36862
|
+
profilesStartingPosition.splice(predecessorIndex + 1, 0, value);
|
|
36863
|
+
// suppose the we want to add the for the left value
|
|
36864
|
+
// following profile following zone: 'C', the predecessor index
|
|
36865
|
+
// for B: [1, 3] "C3:D4" correspond to 'B'.
|
|
36866
|
+
// The next line code will
|
|
36867
|
+
// A B C D A B C D copy the profile of 'B'
|
|
36868
|
+
// 1 '___' 1 '___' to 'C'. In the rest of the
|
|
36869
|
+
// 2 | | ---> 2 | _|_ process the 'modifyProfile'
|
|
36870
|
+
// 3 |___| 3 |_|_| | function will adapt the waiting
|
|
36871
|
+
// 4 4 |___| 'C' profile [1, 3] to the
|
|
36872
|
+
// correct 'C' profile [1, 4]
|
|
36873
|
+
profiles.set(value, [...profiles.get(profilesStartingPosition[predecessorIndex])]);
|
|
36874
|
+
return searchLeft ? predecessorIndex + 1 : predecessorIndex;
|
|
36875
|
+
}
|
|
36876
|
+
return searchLeft ? predecessorIndex : predecessorIndex - 1;
|
|
36877
|
+
}
|
|
36878
|
+
/**
|
|
36879
|
+
* Suppose the following Suppose we want to add We want to have the
|
|
36880
|
+
* profile: the following zone: following profile:
|
|
36881
|
+
*
|
|
36882
|
+
* A B C D E F A B C D E F A B C D E F
|
|
36883
|
+
* 1 '___' 1 ' ' 1 '___'
|
|
36884
|
+
* 2 |___| 2 '___' 2 | |
|
|
36885
|
+
* 3 ' ' 3 | | 3 | |
|
|
36886
|
+
* 4 '___' --> 4 | | --> 4 | |
|
|
36887
|
+
* 6 | | 6 |___| 6 | |
|
|
36888
|
+
* 7 |___| 7 7 |___|
|
|
36889
|
+
* 8 8 8
|
|
36890
|
+
*
|
|
36891
|
+
* the profile for 'C' the top zone correspond Here [2, 3, 5, 8] with [3, 7]
|
|
36892
|
+
* corresponds to: to 3 and the bottom zone would be merged into [2, 8]
|
|
36893
|
+
* ____ ____ correspond to 6
|
|
36894
|
+
* [2, 3, 5, 8] would be the profile: The difficulty of modify profile
|
|
36895
|
+
* ____ is to know what must be deleted
|
|
36896
|
+
* Note that the 'filled [3, 7] and what must be added to the
|
|
36897
|
+
* zone' are always between existing profile.
|
|
36898
|
+
* an even index and its
|
|
36899
|
+
* next index
|
|
36900
|
+
*
|
|
36901
|
+
*/
|
|
36902
|
+
function modifyProfile(profile, zone, toRemove = false) {
|
|
36903
|
+
const topValue = zone.top;
|
|
36904
|
+
const bottomValue = zone.bottom === undefined ? undefined : zone.bottom + 1;
|
|
36905
|
+
const newPoints = [];
|
|
36906
|
+
// Case we want to add a zone to the profile:
|
|
36907
|
+
// - If the top predecessor index `topPredIndex` is even, it means the top of the zone is already positioned on a filled zone
|
|
36908
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the predecessor.
|
|
36909
|
+
// - If it is odd, it means the top of the zone must be the beginning of a filled zone.
|
|
36910
|
+
// so we can keep the index of the top position
|
|
36911
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
36912
|
+
const topPredIndex = binaryPredecessorSearch(profile, topValue, 0, false);
|
|
36913
|
+
if ((topPredIndex % 2 !== 0 && !toRemove) || (topPredIndex % 2 === 0 && toRemove)) {
|
|
36914
|
+
newPoints.push(topValue);
|
|
36915
|
+
}
|
|
36916
|
+
if (bottomValue === undefined) {
|
|
36917
|
+
// The following two code lines will not impact the final result,
|
|
36918
|
+
// but they will impact the intermediate profile.
|
|
36919
|
+
// We keep them for performance reason
|
|
36920
|
+
profile.splice(topPredIndex + 1);
|
|
36921
|
+
profile.push(...newPoints);
|
|
36922
|
+
return;
|
|
36923
|
+
}
|
|
36924
|
+
// Case we want to add a zone to the profile:
|
|
36925
|
+
// - If the bottom successor index `bottomSuccIndex` is even, it means the bottom of the zone must be the ending of a filled zone
|
|
36926
|
+
// so we can keep the index of the bottom position.
|
|
36927
|
+
// - If it is odd, it means the bottom of the zone is already positioned on a filled zone
|
|
36928
|
+
// so we don't need to add it to the profile. we can keep in reference the index of the successor
|
|
36929
|
+
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
36930
|
+
const bottomSuccIndex = binarySuccessorSearch(profile, bottomValue, 0, false);
|
|
36931
|
+
if ((bottomSuccIndex % 2 === 0 && !toRemove) || (bottomSuccIndex % 2 !== 0 && toRemove)) {
|
|
36932
|
+
newPoints.push(bottomValue);
|
|
36933
|
+
}
|
|
36934
|
+
// add the top and bottom value to the profile and
|
|
36935
|
+
// remove all information between the top and bottom index
|
|
36936
|
+
profile.splice(topPredIndex + 1, bottomSuccIndex - topPredIndex - 1, ...newPoints);
|
|
36937
|
+
}
|
|
36938
|
+
function removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex) {
|
|
36939
|
+
const start = leftIndex - 1 === -1 ? 0 : leftIndex - 1;
|
|
36940
|
+
const end = rightIndex === profilesStartingPosition.length - 1 ? rightIndex : rightIndex + 1;
|
|
36941
|
+
for (let i = end; i > start; i--) {
|
|
36942
|
+
if (deepEqualsArray(profiles.get(profilesStartingPosition[i]), profiles.get(profilesStartingPosition[i - 1]))) {
|
|
36943
|
+
profiles.delete(profilesStartingPosition[i]);
|
|
36944
|
+
profilesStartingPosition.splice(i, 1);
|
|
36945
|
+
}
|
|
36946
|
+
}
|
|
36947
|
+
}
|
|
36948
|
+
function constructZonesFromProfiles(profilesStartingPosition, profiles) {
|
|
36949
|
+
const mergedZone = [];
|
|
36950
|
+
let pendingZones = [];
|
|
36951
|
+
for (let colIndex = 0; colIndex < profilesStartingPosition.length; colIndex++) {
|
|
36952
|
+
const left = profilesStartingPosition[colIndex];
|
|
36953
|
+
const profile = profiles.get(left);
|
|
36954
|
+
if (!profile || profile.length === 0) {
|
|
36955
|
+
mergedZone.push(...pendingZones);
|
|
36956
|
+
pendingZones = [];
|
|
36957
|
+
continue;
|
|
36958
|
+
}
|
|
36959
|
+
let right = profilesStartingPosition[colIndex + 1];
|
|
36960
|
+
if (right !== undefined) {
|
|
36961
|
+
right--;
|
|
36962
|
+
}
|
|
36963
|
+
const nextPendingZones = [];
|
|
36964
|
+
for (let i = 0; i < profile.length; i += 2) {
|
|
36965
|
+
const top = profile[i];
|
|
36966
|
+
let bottom = profile[i + 1];
|
|
36967
|
+
if (bottom !== undefined) {
|
|
36968
|
+
bottom--;
|
|
36969
|
+
}
|
|
36970
|
+
const profileZone = {
|
|
36971
|
+
top,
|
|
36972
|
+
left,
|
|
36973
|
+
bottom,
|
|
36974
|
+
right,
|
|
36975
|
+
hasHeader: (bottom === undefined && top !== 0) || (right === undefined && left !== 0),
|
|
36976
|
+
};
|
|
36977
|
+
let findCorrespondingZone = false;
|
|
36978
|
+
for (let j = pendingZones.length - 1; j >= 0; j--) {
|
|
36979
|
+
const pendingZone = pendingZones[j];
|
|
36980
|
+
if (pendingZone.top === profileZone.top && pendingZone.bottom === profileZone.bottom) {
|
|
36981
|
+
pendingZone.right = profileZone.right;
|
|
36982
|
+
pendingZones.splice(j, 1);
|
|
36983
|
+
nextPendingZones.push(pendingZone);
|
|
36984
|
+
findCorrespondingZone = true;
|
|
36985
|
+
break;
|
|
36986
|
+
}
|
|
36987
|
+
}
|
|
36988
|
+
if (!findCorrespondingZone) {
|
|
36989
|
+
nextPendingZones.push(profileZone);
|
|
36990
|
+
}
|
|
36991
|
+
}
|
|
36992
|
+
mergedZone.push(...pendingZones);
|
|
36993
|
+
pendingZones = nextPendingZones;
|
|
36994
|
+
}
|
|
36995
|
+
mergedZone.push(...pendingZones);
|
|
36996
|
+
return mergedZone;
|
|
36997
|
+
}
|
|
36998
|
+
function binaryPredecessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
36999
|
+
let end = arr.length - 1;
|
|
37000
|
+
let result = -1;
|
|
37001
|
+
while (start <= end) {
|
|
37002
|
+
const mid = Math.floor((start + end) / 2);
|
|
37003
|
+
if (arr[mid] === val && matchEqual) {
|
|
37004
|
+
return mid;
|
|
37005
|
+
}
|
|
37006
|
+
else if (arr[mid] < val) {
|
|
37007
|
+
result = mid;
|
|
37008
|
+
start = mid + 1;
|
|
37009
|
+
}
|
|
37010
|
+
else {
|
|
37011
|
+
end = mid - 1;
|
|
37012
|
+
}
|
|
37013
|
+
}
|
|
37014
|
+
return result;
|
|
37015
|
+
}
|
|
37016
|
+
function binarySuccessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
37017
|
+
let end = arr.length - 1;
|
|
37018
|
+
let result = arr.length;
|
|
37019
|
+
while (start <= end) {
|
|
37020
|
+
const mid = Math.floor((start + end) / 2);
|
|
37021
|
+
if (arr[mid] === val && matchEqual) {
|
|
37022
|
+
return mid;
|
|
37023
|
+
}
|
|
37024
|
+
else if (arr[mid] > val) {
|
|
37025
|
+
result = mid;
|
|
37026
|
+
end = mid - 1;
|
|
37027
|
+
}
|
|
37028
|
+
else {
|
|
37029
|
+
start = mid + 1;
|
|
37030
|
+
}
|
|
37031
|
+
}
|
|
37032
|
+
return result;
|
|
37033
|
+
}
|
|
37034
|
+
/**
|
|
37035
|
+
* Compares two arrays.
|
|
37036
|
+
* For performance reasons, this function is to be preferred
|
|
37037
|
+
* to 'deepEquals' in the case we know that the inputs are arrays.
|
|
37038
|
+
*/
|
|
37039
|
+
function deepEqualsArray(arr1, arr2) {
|
|
37040
|
+
if (arr1.length !== arr2.length) {
|
|
37041
|
+
return false;
|
|
37042
|
+
}
|
|
37043
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
37044
|
+
if (!deepEquals(arr1[i], arr2[i])) {
|
|
37045
|
+
return false;
|
|
37046
|
+
}
|
|
37047
|
+
}
|
|
37048
|
+
return true;
|
|
37049
|
+
}
|
|
37050
|
+
|
|
36694
37051
|
// -----------------------------------------------------------------------------
|
|
36695
37052
|
// Constants
|
|
36696
37053
|
// -----------------------------------------------------------------------------
|
|
@@ -36860,10 +37217,12 @@ class ConditionalFormatPlugin extends CorePlugin {
|
|
|
36860
37217
|
const replaceIndex = rules.findIndex((c) => c.id === cf.id);
|
|
36861
37218
|
let currentRanges = [];
|
|
36862
37219
|
if (replaceIndex > -1) {
|
|
36863
|
-
currentRanges = rules[replaceIndex].ranges;
|
|
37220
|
+
currentRanges = rules[replaceIndex].ranges.map(toUnboundedZone);
|
|
36864
37221
|
}
|
|
36865
37222
|
currentRanges = currentRanges.concat(toAdd);
|
|
36866
|
-
|
|
37223
|
+
// Remove the zones first in case the same position is in toAdd and toRemove
|
|
37224
|
+
const withRemovedZones = futureRecomputeZones(currentRanges, toRemove);
|
|
37225
|
+
return futureRecomputeZones([...toAdd, ...withRemovedZones], []);
|
|
36867
37226
|
}
|
|
36868
37227
|
// ---------------------------------------------------------------------------
|
|
36869
37228
|
// Private
|
|
@@ -40598,353 +40957,6 @@ class CompilationParametersBuilder {
|
|
|
40598
40957
|
}
|
|
40599
40958
|
}
|
|
40600
40959
|
|
|
40601
|
-
/**
|
|
40602
|
-
* ####################################################
|
|
40603
|
-
* # INTRODUCTION
|
|
40604
|
-
* ####################################################
|
|
40605
|
-
*
|
|
40606
|
-
* This file contain the function recomputeZones.
|
|
40607
|
-
* This function try to recompute in a performant way
|
|
40608
|
-
* an ensemble of zones possibly overlapping to avoid
|
|
40609
|
-
* overlapping and to reduce the number of zones.
|
|
40610
|
-
*
|
|
40611
|
-
* It also allows to remove some zones from the ensemble.
|
|
40612
|
-
*
|
|
40613
|
-
* In the following example, 2 zones are overlapping.
|
|
40614
|
-
* Applying recomputeZones will return zones without
|
|
40615
|
-
* overlapping:
|
|
40616
|
-
*
|
|
40617
|
-
* ["B3:D4", "D2:E3"] ["B3:C4", "D2:D4", "E2:E3"]
|
|
40618
|
-
*
|
|
40619
|
-
* A B C D E A B C D E
|
|
40620
|
-
* 1 ___ 1 ___
|
|
40621
|
-
* 2 ___|_ | 2 ___| | |
|
|
40622
|
-
* 3 | |_|_| ---> 3 | | |_|
|
|
40623
|
-
* 4 |_____| 4 |___|_|
|
|
40624
|
-
* 6 6
|
|
40625
|
-
* 7 7
|
|
40626
|
-
*
|
|
40627
|
-
*
|
|
40628
|
-
* In the following example, 2 zones are contiguous.
|
|
40629
|
-
* Applying recomputeZones will return only one zone:
|
|
40630
|
-
*
|
|
40631
|
-
* ["B2:B3", "C2:D3"] ["B2:D3"]
|
|
40632
|
-
*
|
|
40633
|
-
* A B C D E A B C D E
|
|
40634
|
-
* 1 _ ___ 1 _____
|
|
40635
|
-
* 2 | | | ---> 2 | |
|
|
40636
|
-
* 3 |_|___| 3 |_____|
|
|
40637
|
-
* 4 4
|
|
40638
|
-
*
|
|
40639
|
-
*
|
|
40640
|
-
* In the following example, we want to remove a zone
|
|
40641
|
-
* from the ensemble. Applying recomputeZones will
|
|
40642
|
-
* return the ensemble without the zone to remove:
|
|
40643
|
-
*
|
|
40644
|
-
* remove ["C3:D3"] ["B2:B4", "C2:D2",
|
|
40645
|
-
* "C4:D4", "E2:E4"]
|
|
40646
|
-
*
|
|
40647
|
-
* A B C D E F A B C D E F
|
|
40648
|
-
* 1 _______ 1 _______
|
|
40649
|
-
* 2 | | ---> 2 | |___| |
|
|
40650
|
-
* 3 | xxx | 3 | |___| |
|
|
40651
|
-
* 4 |_______| 4 |_|___|_|
|
|
40652
|
-
* 5 5
|
|
40653
|
-
*
|
|
40654
|
-
*
|
|
40655
|
-
* The exercise seems simple when we have only 2 zones.
|
|
40656
|
-
* But with n zones and in a performant way, we want to
|
|
40657
|
-
* avoid comparing each zone with all the others.
|
|
40658
|
-
*
|
|
40659
|
-
*
|
|
40660
|
-
* ####################################################
|
|
40661
|
-
* # Methodological approach
|
|
40662
|
-
* ####################################################
|
|
40663
|
-
*
|
|
40664
|
-
* The methodological approach to avoid comparing each
|
|
40665
|
-
* zone with all the others is to use a data structure
|
|
40666
|
-
* that allow to quickly find which zones are
|
|
40667
|
-
* overlapping with any other given zone.
|
|
40668
|
-
*
|
|
40669
|
-
* Here the idea is to profile the zones at the columns level.
|
|
40670
|
-
*
|
|
40671
|
-
* To do that, we propose to use a data structure
|
|
40672
|
-
* composed of 2 parts:
|
|
40673
|
-
* - profilesStartingPosition: a sorted number array
|
|
40674
|
-
* indicating on which columns a new profile begins.
|
|
40675
|
-
* - profiles: a map where the key is a column
|
|
40676
|
-
* position (from profilesStartingPosition) and the
|
|
40677
|
-
* value is a sorted number array representing a
|
|
40678
|
-
* profile.
|
|
40679
|
-
*
|
|
40680
|
-
*
|
|
40681
|
-
* See the following example: here profileStartingPosition
|
|
40682
|
-
* corresponds to [A,C,E,G,K]
|
|
40683
|
-
* A B C D E F G H I J K so with number [0,2,4,6,10]
|
|
40684
|
-
* 1 ' ' ' '
|
|
40685
|
-
* 2 ' ' '_______' here profile correspond
|
|
40686
|
-
* 3 '___' |_______| for A to []
|
|
40687
|
-
* 4 | | for C to [3, 5]
|
|
40688
|
-
* 5 |___| for E to []
|
|
40689
|
-
* 6 for G to [2, 3]
|
|
40690
|
-
* 7 for K to []
|
|
40691
|
-
*
|
|
40692
|
-
*
|
|
40693
|
-
* Now we can easily find which zones are overlapping
|
|
40694
|
-
* with a given zone. Suppose we want to add a new zone
|
|
40695
|
-
* D5:H6 to the ensemble:
|
|
40696
|
-
*
|
|
40697
|
-
* With a binary search of left and right
|
|
40698
|
-
* A B C D E F G H I J K on profilesStartingPosition, we can
|
|
40699
|
-
* 1 ' ' ' ' find the indexes of the profiles on which
|
|
40700
|
-
* 2 ' ' '_______' to apply a modification.
|
|
40701
|
-
* 3 '___' |_______|
|
|
40702
|
-
* 4 | _|_______ Here we will:
|
|
40703
|
-
* 5 |_|_| | - add a new profile in D --> become [3, 6]
|
|
40704
|
-
* 6 |_________| - modify the profile in E --> become [4, 6]
|
|
40705
|
-
* 7 - modify the profile in G --> become [2, 3, 4, 6]
|
|
40706
|
-
* - add a new profile in I --> become [8, 10]
|
|
40707
|
-
*
|
|
40708
|
-
* See below the result:
|
|
40709
|
-
*
|
|
40710
|
-
* Note the particularity of the profile
|
|
40711
|
-
* A B C D E F G H I J K for G: it will correspond to [2, 3, 4, 6]
|
|
40712
|
-
* 1 ' ' ' ' ' '
|
|
40713
|
-
* 2 ' ' ' '___'___' To know how to modify the profile (add a
|
|
40714
|
-
* 3 '_'_' |___|___| zone or remove it) we do a binary
|
|
40715
|
-
* 4 | | |___ ___ search of the top and bottom value on the
|
|
40716
|
-
* 5 |_| | | | profile array. Depending on the result index
|
|
40717
|
-
* 6 |_|___|___| parity (odd or even), because zone boundaries
|
|
40718
|
-
* 7 go by pairs, we know if we are in a zone or
|
|
40719
|
-
* not and how operate.
|
|
40720
|
-
*/
|
|
40721
|
-
/**
|
|
40722
|
-
* Recompute the zone without the cells in toRemoveZones and avoid overlapping.
|
|
40723
|
-
* This compute is particularly useful because after this function:
|
|
40724
|
-
* - you will find coordinate of a cell only once among all the zones
|
|
40725
|
-
* - the number of zones will be reduced to the minimum
|
|
40726
|
-
*/
|
|
40727
|
-
function futureRecomputeZones(zones, zonesToRemove = []) {
|
|
40728
|
-
const profilesStartingPosition = [0];
|
|
40729
|
-
const profiles = new Map([[0, []]]);
|
|
40730
|
-
modifyProfiles(profilesStartingPosition, profiles, zones, false);
|
|
40731
|
-
modifyProfiles(profilesStartingPosition, profiles, zonesToRemove, true);
|
|
40732
|
-
return constructZonesFromProfiles(profilesStartingPosition, profiles);
|
|
40733
|
-
}
|
|
40734
|
-
function modifyProfiles(// export for testing only
|
|
40735
|
-
profilesStartingPosition, profiles, zones, toRemove = false) {
|
|
40736
|
-
for (const zone of zones) {
|
|
40737
|
-
const leftValue = zone.left;
|
|
40738
|
-
const rightValue = zone.right === undefined ? undefined : zone.right + 1;
|
|
40739
|
-
const leftIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, leftValue, true, 0);
|
|
40740
|
-
const rightIndex = findIndexAndCreateProfile(profilesStartingPosition, profiles, rightValue, false, leftIndex);
|
|
40741
|
-
for (let i = leftIndex; i <= rightIndex; i++) {
|
|
40742
|
-
const profile = profiles.get(profilesStartingPosition[i]);
|
|
40743
|
-
modifyProfile(profile, zone, toRemove);
|
|
40744
|
-
}
|
|
40745
|
-
// maybe this part cost in performance, and maybe it's not necessary (depending on the use case). To be checked
|
|
40746
|
-
removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex);
|
|
40747
|
-
}
|
|
40748
|
-
}
|
|
40749
|
-
function findIndexAndCreateProfile(profilesStartingPosition, profiles, value, searchLeft, startIndex) {
|
|
40750
|
-
if (value === undefined) {
|
|
40751
|
-
// this is only the case when the value correspond to a bottom value that could be undefined
|
|
40752
|
-
return profilesStartingPosition.length - 1;
|
|
40753
|
-
}
|
|
40754
|
-
const predecessorIndex = binaryPredecessorSearch(profilesStartingPosition, value, startIndex);
|
|
40755
|
-
if (value != profilesStartingPosition[predecessorIndex]) {
|
|
40756
|
-
// mean that the value is not ending/starting at the same position as the previous/next profile
|
|
40757
|
-
// --> it's a new profile
|
|
40758
|
-
// --> we need to add it
|
|
40759
|
-
profilesStartingPosition.splice(predecessorIndex + 1, 0, value);
|
|
40760
|
-
// suppose the we want to add the for the left value
|
|
40761
|
-
// following profile following zone: 'C', the predecessor index
|
|
40762
|
-
// for B: [1, 3] "C3:D4" correspond to 'B'.
|
|
40763
|
-
// The next line code will
|
|
40764
|
-
// A B C D A B C D copy the profile of 'B'
|
|
40765
|
-
// 1 '___' 1 '___' to 'C'. In the rest of the
|
|
40766
|
-
// 2 | | ---> 2 | _|_ process the 'modifyProfile'
|
|
40767
|
-
// 3 |___| 3 |_|_| | function will adapt the waiting
|
|
40768
|
-
// 4 4 |___| 'C' profile [1, 3] to the
|
|
40769
|
-
// correct 'C' profile [1, 4]
|
|
40770
|
-
profiles.set(value, [...profiles.get(profilesStartingPosition[predecessorIndex])]);
|
|
40771
|
-
return searchLeft ? predecessorIndex + 1 : predecessorIndex;
|
|
40772
|
-
}
|
|
40773
|
-
return searchLeft ? predecessorIndex : predecessorIndex - 1;
|
|
40774
|
-
}
|
|
40775
|
-
/**
|
|
40776
|
-
* Suppose the following Suppose we want to add We want to have the
|
|
40777
|
-
* profile: the following zone: following profile:
|
|
40778
|
-
*
|
|
40779
|
-
* A B C D E F A B C D E F A B C D E F
|
|
40780
|
-
* 1 '___' 1 ' ' 1 '___'
|
|
40781
|
-
* 2 |___| 2 '___' 2 | |
|
|
40782
|
-
* 3 ' ' 3 | | 3 | |
|
|
40783
|
-
* 4 '___' --> 4 | | --> 4 | |
|
|
40784
|
-
* 6 | | 6 |___| 6 | |
|
|
40785
|
-
* 7 |___| 7 7 |___|
|
|
40786
|
-
* 8 8 8
|
|
40787
|
-
*
|
|
40788
|
-
* the profile for 'C' the top zone correspond Here [2, 3, 5, 8] with [3, 7]
|
|
40789
|
-
* corresponds to: to 3 and the bottom zone would be merged into [2, 8]
|
|
40790
|
-
* ____ ____ correspond to 6
|
|
40791
|
-
* [2, 3, 5, 8] would be the profile: The difficulty of modify profile
|
|
40792
|
-
* ____ is to know what must be deleted
|
|
40793
|
-
* Note that the 'filled [3, 7] and what must be added to the
|
|
40794
|
-
* zone' are always between existing profile.
|
|
40795
|
-
* an even index and its
|
|
40796
|
-
* next index
|
|
40797
|
-
*
|
|
40798
|
-
*/
|
|
40799
|
-
function modifyProfile(profile, zone, toRemove = false) {
|
|
40800
|
-
const topValue = zone.top;
|
|
40801
|
-
const bottomValue = zone.bottom === undefined ? undefined : zone.bottom + 1;
|
|
40802
|
-
const newPoints = [];
|
|
40803
|
-
// Case we want to add a zone to the profile:
|
|
40804
|
-
// - If the top predecessor index `topPredIndex` is even, it means the top of the zone is already positioned on a filled zone
|
|
40805
|
-
// so we don't need to add it to the profile. we can keep in reference the index of the predecessor.
|
|
40806
|
-
// - If it is odd, it means the top of the zone must be the beginning of a filled zone.
|
|
40807
|
-
// so we can keep the index of the top position
|
|
40808
|
-
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
40809
|
-
const topPredIndex = binaryPredecessorSearch(profile, topValue, 0, false);
|
|
40810
|
-
if ((topPredIndex % 2 !== 0 && !toRemove) || (topPredIndex % 2 === 0 && toRemove)) {
|
|
40811
|
-
newPoints.push(topValue);
|
|
40812
|
-
}
|
|
40813
|
-
if (bottomValue === undefined) {
|
|
40814
|
-
// The following two code lines will not impact the final result,
|
|
40815
|
-
// but they will impact the intermediate profile.
|
|
40816
|
-
// We keep them for performance reason
|
|
40817
|
-
profile.splice(topPredIndex + 1);
|
|
40818
|
-
profile.push(...newPoints);
|
|
40819
|
-
return;
|
|
40820
|
-
}
|
|
40821
|
-
// Case we want to add a zone to the profile:
|
|
40822
|
-
// - If the bottom successor index `bottomSuccIndex` is even, it means the bottom of the zone must be the ending of a filled zone
|
|
40823
|
-
// so we can keep the index of the bottom position.
|
|
40824
|
-
// - If it is odd, it means the bottom of the zone is already positioned on a filled zone
|
|
40825
|
-
// so we don't need to add it to the profile. we can keep in reference the index of the successor
|
|
40826
|
-
// Case we want to remove a zone from the profile: it's the opposite of the previous case
|
|
40827
|
-
const bottomSuccIndex = binarySuccessorSearch(profile, bottomValue, 0, false);
|
|
40828
|
-
if ((bottomSuccIndex % 2 === 0 && !toRemove) || (bottomSuccIndex % 2 !== 0 && toRemove)) {
|
|
40829
|
-
newPoints.push(bottomValue);
|
|
40830
|
-
}
|
|
40831
|
-
// add the top and bottom value to the profile and
|
|
40832
|
-
// remove all information between the top and bottom index
|
|
40833
|
-
profile.splice(topPredIndex + 1, bottomSuccIndex - topPredIndex - 1, ...newPoints);
|
|
40834
|
-
}
|
|
40835
|
-
function removeContiguousProfiles(profilesStartingPosition, profiles, leftIndex, rightIndex) {
|
|
40836
|
-
const start = leftIndex - 1 === -1 ? 0 : leftIndex - 1;
|
|
40837
|
-
const end = rightIndex === profilesStartingPosition.length - 1 ? rightIndex : rightIndex + 1;
|
|
40838
|
-
for (let i = end; i > start; i--) {
|
|
40839
|
-
if (deepEqualsArray(profiles.get(profilesStartingPosition[i]), profiles.get(profilesStartingPosition[i - 1]))) {
|
|
40840
|
-
profiles.delete(profilesStartingPosition[i]);
|
|
40841
|
-
profilesStartingPosition.splice(i, 1);
|
|
40842
|
-
}
|
|
40843
|
-
}
|
|
40844
|
-
}
|
|
40845
|
-
function constructZonesFromProfiles(profilesStartingPosition, profiles) {
|
|
40846
|
-
const mergedZone = [];
|
|
40847
|
-
let pendingZones = [];
|
|
40848
|
-
for (let colIndex = 0; colIndex < profilesStartingPosition.length; colIndex++) {
|
|
40849
|
-
const left = profilesStartingPosition[colIndex];
|
|
40850
|
-
const profile = profiles.get(left);
|
|
40851
|
-
if (!profile || profile.length === 0) {
|
|
40852
|
-
mergedZone.push(...pendingZones);
|
|
40853
|
-
pendingZones = [];
|
|
40854
|
-
continue;
|
|
40855
|
-
}
|
|
40856
|
-
let right = profilesStartingPosition[colIndex + 1];
|
|
40857
|
-
if (right !== undefined) {
|
|
40858
|
-
right--;
|
|
40859
|
-
}
|
|
40860
|
-
const nextPendingZones = [];
|
|
40861
|
-
for (let i = 0; i < profile.length; i += 2) {
|
|
40862
|
-
const top = profile[i];
|
|
40863
|
-
let bottom = profile[i + 1];
|
|
40864
|
-
if (bottom !== undefined) {
|
|
40865
|
-
bottom--;
|
|
40866
|
-
}
|
|
40867
|
-
const profileZone = {
|
|
40868
|
-
top,
|
|
40869
|
-
left,
|
|
40870
|
-
bottom,
|
|
40871
|
-
right,
|
|
40872
|
-
hasHeader: (bottom === undefined && top !== 0) || (right === undefined && left !== 0),
|
|
40873
|
-
};
|
|
40874
|
-
let findCorrespondingZone = false;
|
|
40875
|
-
for (let j = pendingZones.length - 1; j >= 0; j--) {
|
|
40876
|
-
const pendingZone = pendingZones[j];
|
|
40877
|
-
if (pendingZone.top === profileZone.top && pendingZone.bottom === profileZone.bottom) {
|
|
40878
|
-
pendingZone.right = profileZone.right;
|
|
40879
|
-
pendingZones.splice(j, 1);
|
|
40880
|
-
nextPendingZones.push(pendingZone);
|
|
40881
|
-
findCorrespondingZone = true;
|
|
40882
|
-
break;
|
|
40883
|
-
}
|
|
40884
|
-
}
|
|
40885
|
-
if (!findCorrespondingZone) {
|
|
40886
|
-
nextPendingZones.push(profileZone);
|
|
40887
|
-
}
|
|
40888
|
-
}
|
|
40889
|
-
mergedZone.push(...pendingZones);
|
|
40890
|
-
pendingZones = nextPendingZones;
|
|
40891
|
-
}
|
|
40892
|
-
mergedZone.push(...pendingZones);
|
|
40893
|
-
return mergedZone;
|
|
40894
|
-
}
|
|
40895
|
-
function binaryPredecessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
40896
|
-
let end = arr.length - 1;
|
|
40897
|
-
let result = -1;
|
|
40898
|
-
while (start <= end) {
|
|
40899
|
-
const mid = Math.floor((start + end) / 2);
|
|
40900
|
-
if (arr[mid] === val && matchEqual) {
|
|
40901
|
-
return mid;
|
|
40902
|
-
}
|
|
40903
|
-
else if (arr[mid] < val) {
|
|
40904
|
-
result = mid;
|
|
40905
|
-
start = mid + 1;
|
|
40906
|
-
}
|
|
40907
|
-
else {
|
|
40908
|
-
end = mid - 1;
|
|
40909
|
-
}
|
|
40910
|
-
}
|
|
40911
|
-
return result;
|
|
40912
|
-
}
|
|
40913
|
-
function binarySuccessorSearch(arr, val, start = 0, matchEqual = true) {
|
|
40914
|
-
let end = arr.length - 1;
|
|
40915
|
-
let result = arr.length;
|
|
40916
|
-
while (start <= end) {
|
|
40917
|
-
const mid = Math.floor((start + end) / 2);
|
|
40918
|
-
if (arr[mid] === val && matchEqual) {
|
|
40919
|
-
return mid;
|
|
40920
|
-
}
|
|
40921
|
-
else if (arr[mid] > val) {
|
|
40922
|
-
result = mid;
|
|
40923
|
-
end = mid - 1;
|
|
40924
|
-
}
|
|
40925
|
-
else {
|
|
40926
|
-
start = mid + 1;
|
|
40927
|
-
}
|
|
40928
|
-
}
|
|
40929
|
-
return result;
|
|
40930
|
-
}
|
|
40931
|
-
/**
|
|
40932
|
-
* Compares two arrays.
|
|
40933
|
-
* For performance reasons, this function is to be preferred
|
|
40934
|
-
* to 'deepEquals' in the case we know that the inputs are arrays.
|
|
40935
|
-
*/
|
|
40936
|
-
function deepEqualsArray(arr1, arr2) {
|
|
40937
|
-
if (arr1.length !== arr2.length) {
|
|
40938
|
-
return false;
|
|
40939
|
-
}
|
|
40940
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
40941
|
-
if (!deepEquals(arr1[i], arr2[i])) {
|
|
40942
|
-
return false;
|
|
40943
|
-
}
|
|
40944
|
-
}
|
|
40945
|
-
return true;
|
|
40946
|
-
}
|
|
40947
|
-
|
|
40948
40960
|
function quickselect(arr, k, left, right, compare) {
|
|
40949
40961
|
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
40950
40962
|
}
|
|
@@ -43541,25 +43553,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43541
43553
|
case "AUTOFILL_AUTO":
|
|
43542
43554
|
this.autofillAuto();
|
|
43543
43555
|
break;
|
|
43544
|
-
case "AUTOFILL_CELL":
|
|
43545
|
-
this.autoFillMerge(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
43546
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
43547
|
-
this.dispatch("UPDATE_CELL", {
|
|
43548
|
-
sheetId,
|
|
43549
|
-
col: cmd.col,
|
|
43550
|
-
row: cmd.row,
|
|
43551
|
-
style: cmd.style || null,
|
|
43552
|
-
content: cmd.content || "",
|
|
43553
|
-
format: cmd.format || "",
|
|
43554
|
-
});
|
|
43555
|
-
this.dispatch("SET_BORDER", {
|
|
43556
|
-
sheetId,
|
|
43557
|
-
col: cmd.col,
|
|
43558
|
-
row: cmd.row,
|
|
43559
|
-
border: cmd.border,
|
|
43560
|
-
});
|
|
43561
|
-
this.autofillCF(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
43562
|
-
this.autofillDV(cmd.originCol, cmd.originRow, cmd.col, cmd.row);
|
|
43563
43556
|
}
|
|
43564
43557
|
}
|
|
43565
43558
|
// ---------------------------------------------------------------------------
|
|
@@ -43583,6 +43576,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43583
43576
|
}
|
|
43584
43577
|
const source = this.getters.getSelectedZone();
|
|
43585
43578
|
const target = this.autofillZone;
|
|
43579
|
+
const autofillCellsData = [];
|
|
43586
43580
|
switch (this.direction) {
|
|
43587
43581
|
case "down" /* DIRECTION.DOWN */:
|
|
43588
43582
|
for (let col = source.left; col <= source.right; col++) {
|
|
@@ -43592,7 +43586,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43592
43586
|
}
|
|
43593
43587
|
const generator = this.createGenerator(xcs);
|
|
43594
43588
|
for (let row = target.top; row <= target.bottom; row++) {
|
|
43595
|
-
this.computeNewCell(generator, col, row
|
|
43589
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
43596
43590
|
}
|
|
43597
43591
|
}
|
|
43598
43592
|
break;
|
|
@@ -43604,7 +43598,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43604
43598
|
}
|
|
43605
43599
|
const generator = this.createGenerator(xcs);
|
|
43606
43600
|
for (let row = target.bottom; row >= target.top; row--) {
|
|
43607
|
-
this.computeNewCell(generator, col, row
|
|
43601
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
43608
43602
|
}
|
|
43609
43603
|
}
|
|
43610
43604
|
break;
|
|
@@ -43616,7 +43610,7 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43616
43610
|
}
|
|
43617
43611
|
const generator = this.createGenerator(xcs);
|
|
43618
43612
|
for (let col = target.right; col >= target.left; col--) {
|
|
43619
|
-
this.computeNewCell(generator, col, row
|
|
43613
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
43620
43614
|
}
|
|
43621
43615
|
}
|
|
43622
43616
|
break;
|
|
@@ -43628,12 +43622,26 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43628
43622
|
}
|
|
43629
43623
|
const generator = this.createGenerator(xcs);
|
|
43630
43624
|
for (let col = target.left; col <= target.right; col++) {
|
|
43631
|
-
this.computeNewCell(generator, col, row
|
|
43625
|
+
autofillCellsData.push(this.computeNewCell(generator, col, row));
|
|
43632
43626
|
}
|
|
43633
43627
|
}
|
|
43634
43628
|
break;
|
|
43635
43629
|
}
|
|
43636
43630
|
if (apply) {
|
|
43631
|
+
const bordersZones = {};
|
|
43632
|
+
const cfNewRanges = {};
|
|
43633
|
+
const dvNewZones = {};
|
|
43634
|
+
const sheetId = this.getters.getActiveSheetId();
|
|
43635
|
+
for (const data of autofillCellsData) {
|
|
43636
|
+
this.collectBordersData(data, bordersZones);
|
|
43637
|
+
this.autofillMerge(sheetId, data);
|
|
43638
|
+
this.autofillCell(sheetId, data);
|
|
43639
|
+
this.collectConditionalFormatsData(sheetId, data, cfNewRanges);
|
|
43640
|
+
this.collectDataValidationsData(sheetId, data, dvNewZones);
|
|
43641
|
+
}
|
|
43642
|
+
this.autofillBorders(sheetId, bordersZones);
|
|
43643
|
+
this.autofillConditionalFormats(sheetId, cfNewRanges);
|
|
43644
|
+
this.autofillDataValidations(sheetId, dvNewZones);
|
|
43637
43645
|
this.autofillZone = undefined;
|
|
43638
43646
|
this.selection.resizeAnchorZone(this.direction, this.steps);
|
|
43639
43647
|
this.lastCellSelected = {};
|
|
@@ -43642,6 +43650,95 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43642
43650
|
this.tooltip = undefined;
|
|
43643
43651
|
}
|
|
43644
43652
|
}
|
|
43653
|
+
collectBordersData(data, bordersPositions) {
|
|
43654
|
+
const key = JSON.stringify(data.border);
|
|
43655
|
+
if (!(key in bordersPositions)) {
|
|
43656
|
+
bordersPositions[key] = [];
|
|
43657
|
+
}
|
|
43658
|
+
bordersPositions[key].push(positionToZone({ col: data.col, row: data.row }));
|
|
43659
|
+
}
|
|
43660
|
+
collectConditionalFormatsData(sheetId, data, cfNewRanges) {
|
|
43661
|
+
const { originCol, originRow, col, row } = data;
|
|
43662
|
+
const cfsAtOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
43663
|
+
const xc = toXC(col, row);
|
|
43664
|
+
for (const cf of cfsAtOrigin) {
|
|
43665
|
+
if (!(cf.id in cfNewRanges)) {
|
|
43666
|
+
cfNewRanges[cf.id] = [];
|
|
43667
|
+
}
|
|
43668
|
+
cfNewRanges[cf.id].push(xc);
|
|
43669
|
+
}
|
|
43670
|
+
}
|
|
43671
|
+
collectDataValidationsData(sheetId, data, dvNewZones) {
|
|
43672
|
+
const { originCol, originRow, col, row } = data;
|
|
43673
|
+
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
43674
|
+
const dvsAtOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
43675
|
+
if (!dvsAtOrigin) {
|
|
43676
|
+
return;
|
|
43677
|
+
}
|
|
43678
|
+
if (!(dvsAtOrigin.id in dvNewZones)) {
|
|
43679
|
+
dvNewZones[dvsAtOrigin.id] = [];
|
|
43680
|
+
}
|
|
43681
|
+
dvNewZones[dvsAtOrigin.id].push(positionToZone({ col, row }));
|
|
43682
|
+
}
|
|
43683
|
+
autofillCell(sheetId, data) {
|
|
43684
|
+
this.dispatch("UPDATE_CELL", {
|
|
43685
|
+
sheetId,
|
|
43686
|
+
col: data.col,
|
|
43687
|
+
row: data.row,
|
|
43688
|
+
content: data.content || "",
|
|
43689
|
+
style: data.style || null,
|
|
43690
|
+
format: data.format || "",
|
|
43691
|
+
});
|
|
43692
|
+
// Still usefull in odoo ATM to autofill field sync
|
|
43693
|
+
this.dispatch("AUTOFILL_CELL", data);
|
|
43694
|
+
}
|
|
43695
|
+
autofillBorders(sheetId, bordersPositions) {
|
|
43696
|
+
for (const stringifiedBorder in bordersPositions) {
|
|
43697
|
+
const border = stringifiedBorder === "undefined" ? undefined : JSON.parse(stringifiedBorder);
|
|
43698
|
+
this.dispatch("SET_BORDERS_ON_TARGET", {
|
|
43699
|
+
sheetId,
|
|
43700
|
+
border,
|
|
43701
|
+
target: futureRecomputeZones(bordersPositions[stringifiedBorder]),
|
|
43702
|
+
});
|
|
43703
|
+
}
|
|
43704
|
+
}
|
|
43705
|
+
autofillConditionalFormats(sheetId, cfNewRanges) {
|
|
43706
|
+
for (const cfId in cfNewRanges) {
|
|
43707
|
+
const changes = cfNewRanges[cfId];
|
|
43708
|
+
const cf = this.getters.getConditionalFormats(sheetId).find((cf) => cf.id === cfId);
|
|
43709
|
+
if (!cf) {
|
|
43710
|
+
continue;
|
|
43711
|
+
}
|
|
43712
|
+
const newCfZones = this.getters.getAdaptedCfRanges(sheetId, cf, changes.map(toZone), []);
|
|
43713
|
+
if (newCfZones) {
|
|
43714
|
+
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
43715
|
+
cf: {
|
|
43716
|
+
id: cf.id,
|
|
43717
|
+
rule: cf.rule,
|
|
43718
|
+
stopIfTrue: cf.stopIfTrue,
|
|
43719
|
+
},
|
|
43720
|
+
ranges: newCfZones.map((xc) => this.getters.getRangeDataFromZone(sheetId, xc)),
|
|
43721
|
+
sheetId,
|
|
43722
|
+
});
|
|
43723
|
+
}
|
|
43724
|
+
}
|
|
43725
|
+
}
|
|
43726
|
+
autofillDataValidations(sheetId, dvNewZones) {
|
|
43727
|
+
for (const dvId in dvNewZones) {
|
|
43728
|
+
const changes = dvNewZones[dvId];
|
|
43729
|
+
const dvOrigin = this.getters.getDataValidationRule(sheetId, dvId);
|
|
43730
|
+
if (!dvOrigin) {
|
|
43731
|
+
continue;
|
|
43732
|
+
}
|
|
43733
|
+
const dvRangesXcs = dvOrigin.ranges.map((range) => range.zone);
|
|
43734
|
+
const newDvRanges = futureRecomputeZones(dvRangesXcs.concat(changes), []);
|
|
43735
|
+
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
43736
|
+
rule: dvOrigin,
|
|
43737
|
+
ranges: newDvRanges.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
43738
|
+
sheetId,
|
|
43739
|
+
});
|
|
43740
|
+
}
|
|
43741
|
+
}
|
|
43645
43742
|
/**
|
|
43646
43743
|
* Select a cell which becomes the last cell of the autofillZone
|
|
43647
43744
|
*/
|
|
@@ -43708,22 +43805,20 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43708
43805
|
/**
|
|
43709
43806
|
* Generate the next cell
|
|
43710
43807
|
*/
|
|
43711
|
-
computeNewCell(generator, col, row
|
|
43808
|
+
computeNewCell(generator, col, row) {
|
|
43712
43809
|
const { cellData, tooltip, origin } = generator.next();
|
|
43713
43810
|
const { content, style, border, format } = cellData;
|
|
43714
43811
|
this.tooltip = tooltip;
|
|
43715
|
-
|
|
43716
|
-
|
|
43717
|
-
|
|
43718
|
-
|
|
43719
|
-
|
|
43720
|
-
|
|
43721
|
-
|
|
43722
|
-
|
|
43723
|
-
|
|
43724
|
-
|
|
43725
|
-
});
|
|
43726
|
-
}
|
|
43812
|
+
return {
|
|
43813
|
+
originCol: origin.col,
|
|
43814
|
+
originRow: origin.row,
|
|
43815
|
+
col,
|
|
43816
|
+
row,
|
|
43817
|
+
content,
|
|
43818
|
+
style,
|
|
43819
|
+
border,
|
|
43820
|
+
format,
|
|
43821
|
+
};
|
|
43727
43822
|
}
|
|
43728
43823
|
/**
|
|
43729
43824
|
* Get the rule associated to the current cell
|
|
@@ -43791,8 +43886,8 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43791
43886
|
? position[first].value
|
|
43792
43887
|
: position[second].value;
|
|
43793
43888
|
}
|
|
43794
|
-
|
|
43795
|
-
const
|
|
43889
|
+
autofillMerge(sheetId, data) {
|
|
43890
|
+
const { originCol, originRow, col, row } = data;
|
|
43796
43891
|
const position = { sheetId, col, row };
|
|
43797
43892
|
const originPosition = { sheetId, col: originCol, row: originRow };
|
|
43798
43893
|
if (this.getters.isInMerge(position) && !this.getters.isInMerge(originPosition)) {
|
|
@@ -43819,35 +43914,6 @@ class AutofillPlugin extends UIPlugin {
|
|
|
43819
43914
|
});
|
|
43820
43915
|
}
|
|
43821
43916
|
}
|
|
43822
|
-
autofillCF(originCol, originRow, col, row) {
|
|
43823
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
43824
|
-
const cfOrigin = this.getters.getRulesByCell(sheetId, originCol, originRow);
|
|
43825
|
-
for (const cf of cfOrigin) {
|
|
43826
|
-
const newCfRanges = this.getters.getAdaptedCfRanges(sheetId, cf, [toXC(col, row)], []);
|
|
43827
|
-
if (newCfRanges) {
|
|
43828
|
-
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
43829
|
-
cf: deepCopy(cf),
|
|
43830
|
-
ranges: newCfRanges.map((xc) => this.getters.getRangeDataFromXc(sheetId, xc)),
|
|
43831
|
-
sheetId,
|
|
43832
|
-
});
|
|
43833
|
-
}
|
|
43834
|
-
}
|
|
43835
|
-
}
|
|
43836
|
-
autofillDV(originCol, originRow, col, row) {
|
|
43837
|
-
const sheetId = this.getters.getActiveSheetId();
|
|
43838
|
-
const cellPosition = { sheetId, col: originCol, row: originRow };
|
|
43839
|
-
const dvOrigin = this.getters.getValidationRuleForCell(cellPosition);
|
|
43840
|
-
if (!dvOrigin) {
|
|
43841
|
-
return;
|
|
43842
|
-
}
|
|
43843
|
-
const dvRangesXcs = dvOrigin.ranges.map((range) => this.getters.getRangeString(range, sheetId));
|
|
43844
|
-
const newDvRanges = recomputeZones(dvRangesXcs.concat(toXC(col, row)), []);
|
|
43845
|
-
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
43846
|
-
rule: dvOrigin,
|
|
43847
|
-
ranges: newDvRanges.map((xc) => this.getters.getRangeDataFromXc(sheetId, xc)),
|
|
43848
|
-
sheetId,
|
|
43849
|
-
});
|
|
43850
|
-
}
|
|
43851
43917
|
// ---------------------------------------------------------------------------
|
|
43852
43918
|
// Grid rendering
|
|
43853
43919
|
// ---------------------------------------------------------------------------
|
|
@@ -45234,6 +45300,9 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45234
45300
|
copiedTables;
|
|
45235
45301
|
zones;
|
|
45236
45302
|
uuidGenerator = new UuidGenerator();
|
|
45303
|
+
queuedBordersToAdd = {};
|
|
45304
|
+
queuedCFChanges = {};
|
|
45305
|
+
queuedDVChanges = {};
|
|
45237
45306
|
constructor(zones, operation, getters, dispatch, selection) {
|
|
45238
45307
|
super(operation, getters, dispatch, selection);
|
|
45239
45308
|
if (!zones.length) {
|
|
@@ -45343,6 +45412,8 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45343
45412
|
* Paste the clipboard content in the given target
|
|
45344
45413
|
*/
|
|
45345
45414
|
paste(target, options) {
|
|
45415
|
+
this.queuedCFChanges = {};
|
|
45416
|
+
this.queuedDVChanges = {};
|
|
45346
45417
|
if (this.operation === "COPY") {
|
|
45347
45418
|
this.pasteFromCopy(target, options);
|
|
45348
45419
|
}
|
|
@@ -45355,6 +45426,7 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45355
45426
|
if (options?.selectTarget) {
|
|
45356
45427
|
this.selectPastedZone(width, height, isCutOperation, target);
|
|
45357
45428
|
}
|
|
45429
|
+
this.executeQueuedChanges(this.getters.getActiveSheetId());
|
|
45358
45430
|
}
|
|
45359
45431
|
pasteFromCopy(target, options) {
|
|
45360
45432
|
if (target.length === 1) {
|
|
@@ -45529,7 +45601,11 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45529
45601
|
left: targetBorders?.left || originBorders?.left,
|
|
45530
45602
|
right: targetBorders?.right || originBorders?.right,
|
|
45531
45603
|
};
|
|
45532
|
-
|
|
45604
|
+
const borderKey = JSON.stringify(border);
|
|
45605
|
+
if (!this.queuedBordersToAdd[borderKey]) {
|
|
45606
|
+
this.queuedBordersToAdd[borderKey] = [];
|
|
45607
|
+
}
|
|
45608
|
+
this.queuedBordersToAdd[borderKey].push(positionToZone(target));
|
|
45533
45609
|
if (clipboardOption?.pasteOption === "onlyFormat") {
|
|
45534
45610
|
this.dispatch("UPDATE_CELL", {
|
|
45535
45611
|
...target,
|
|
@@ -45675,7 +45751,8 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45675
45751
|
}
|
|
45676
45752
|
}
|
|
45677
45753
|
pasteCf(origin, target) {
|
|
45678
|
-
const
|
|
45754
|
+
const zone = positionToZone(target);
|
|
45755
|
+
const originZone = positionToZone(origin);
|
|
45679
45756
|
for (let rule of this.getters.getConditionalFormats(origin.sheetId)) {
|
|
45680
45757
|
for (let range of rule.ranges) {
|
|
45681
45758
|
if (isInside(origin.col, origin.row, this.getters.getRangeFromSheetXC(origin.sheetId, range).zone)) {
|
|
@@ -45683,15 +45760,15 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45683
45760
|
const toRemoveRange = [];
|
|
45684
45761
|
if (this.operation === "CUT") {
|
|
45685
45762
|
//remove from current rule
|
|
45686
|
-
toRemoveRange.push(
|
|
45763
|
+
toRemoveRange.push(originZone);
|
|
45687
45764
|
}
|
|
45688
45765
|
if (origin.sheetId === target.sheetId) {
|
|
45689
|
-
this.adaptCFRules(origin.sheetId, cf, [
|
|
45766
|
+
this.adaptCFRules(origin.sheetId, cf, [zone], toRemoveRange);
|
|
45690
45767
|
}
|
|
45691
45768
|
else {
|
|
45692
45769
|
this.adaptCFRules(origin.sheetId, cf, [], toRemoveRange);
|
|
45693
45770
|
const cfToCopyTo = this.getCFToCopyTo(target.sheetId, cf);
|
|
45694
|
-
this.adaptCFRules(target.sheetId, cfToCopyTo, [
|
|
45771
|
+
this.adaptCFRules(target.sheetId, cfToCopyTo, [zone], []);
|
|
45695
45772
|
}
|
|
45696
45773
|
}
|
|
45697
45774
|
}
|
|
@@ -45701,79 +45778,130 @@ class ClipboardCellsState extends ClipboardCellsAbstractState {
|
|
|
45701
45778
|
* Add or remove cells to a given conditional formatting rule.
|
|
45702
45779
|
*/
|
|
45703
45780
|
adaptCFRules(sheetId, cf, toAdd, toRemove) {
|
|
45704
|
-
|
|
45705
|
-
|
|
45706
|
-
return;
|
|
45781
|
+
if (!this.queuedCFChanges[sheetId]) {
|
|
45782
|
+
this.queuedCFChanges[sheetId] = [];
|
|
45707
45783
|
}
|
|
45708
|
-
|
|
45709
|
-
|
|
45710
|
-
|
|
45784
|
+
const queuedChange = this.queuedCFChanges[sheetId].find((queued) => queued.cf.id === cf.id);
|
|
45785
|
+
if (!queuedChange) {
|
|
45786
|
+
this.queuedCFChanges[sheetId].push({ toAdd, toRemove, cf });
|
|
45787
|
+
}
|
|
45788
|
+
else {
|
|
45789
|
+
queuedChange.toAdd.push(...toAdd);
|
|
45790
|
+
queuedChange.toRemove.push(...toRemove);
|
|
45711
45791
|
}
|
|
45712
|
-
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
45713
|
-
cf: {
|
|
45714
|
-
id: cf.id,
|
|
45715
|
-
rule: cf.rule,
|
|
45716
|
-
stopIfTrue: cf.stopIfTrue,
|
|
45717
|
-
},
|
|
45718
|
-
ranges: newRangesXC.map((xc) => this.getters.getRangeDataFromXc(sheetId, xc)),
|
|
45719
|
-
sheetId,
|
|
45720
|
-
});
|
|
45721
45792
|
}
|
|
45722
45793
|
getCFToCopyTo(targetSheetId, originCF) {
|
|
45723
|
-
|
|
45794
|
+
let targetCF = this.getters
|
|
45724
45795
|
.getConditionalFormats(targetSheetId)
|
|
45725
45796
|
.find((cf) => cf.stopIfTrue === originCF.stopIfTrue && deepEquals(cf.rule, originCF.rule));
|
|
45726
|
-
|
|
45727
|
-
|
|
45728
|
-
|
|
45797
|
+
const queuedCfs = this.queuedCFChanges[targetSheetId];
|
|
45798
|
+
if (!targetCF && queuedCfs) {
|
|
45799
|
+
targetCF = queuedCfs.find((queued) => queued.cf.stopIfTrue === originCF.stopIfTrue && deepEquals(queued.cf.rule, originCF.rule))?.cf;
|
|
45800
|
+
}
|
|
45801
|
+
return targetCF ? targetCF : { ...originCF, id: this.uuidGenerator.smallUuid(), ranges: [] };
|
|
45729
45802
|
}
|
|
45730
45803
|
pasteDataValidation(origin, target) {
|
|
45731
45804
|
const rule = this.getters.getValidationRuleForCell(origin);
|
|
45805
|
+
const originZone = positionToZone(origin);
|
|
45732
45806
|
if (!rule) {
|
|
45733
45807
|
return;
|
|
45734
45808
|
}
|
|
45735
|
-
const
|
|
45809
|
+
const zone = positionToZone(target);
|
|
45736
45810
|
for (const range of rule.ranges) {
|
|
45737
45811
|
if (isInside(origin.col, origin.row, range.zone)) {
|
|
45738
45812
|
const toRemoveRange = [];
|
|
45739
45813
|
if (this.operation === "CUT") {
|
|
45740
|
-
toRemoveRange.push(
|
|
45814
|
+
toRemoveRange.push(originZone);
|
|
45741
45815
|
}
|
|
45742
45816
|
if (origin.sheetId === target.sheetId) {
|
|
45743
|
-
this.
|
|
45817
|
+
const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule);
|
|
45818
|
+
this.adaptDataValidationRule(origin.sheetId, copyToRule, [zone], toRemoveRange);
|
|
45744
45819
|
}
|
|
45745
45820
|
else {
|
|
45746
|
-
this.
|
|
45747
|
-
|
|
45748
|
-
|
|
45821
|
+
const originRule = this.getters.getValidationRuleForCell(origin);
|
|
45822
|
+
if (originRule) {
|
|
45823
|
+
this.adaptDataValidationRule(origin.sheetId, originRule, [], toRemoveRange);
|
|
45824
|
+
}
|
|
45825
|
+
const copyToRule = this.getDataValidationRuleToCopyTo(target.sheetId, rule);
|
|
45826
|
+
this.adaptDataValidationRule(target.sheetId, copyToRule, [zone], []);
|
|
45749
45827
|
}
|
|
45750
45828
|
}
|
|
45751
45829
|
}
|
|
45752
45830
|
}
|
|
45753
45831
|
getDataValidationRuleToCopyTo(targetSheetId, originRule) {
|
|
45754
|
-
|
|
45832
|
+
let targetRule = this.getters
|
|
45755
45833
|
.getDataValidationRules(targetSheetId)
|
|
45756
45834
|
.find((rule) => deepEquals(originRule.criterion, rule.criterion) &&
|
|
45757
45835
|
originRule.isBlocking === rule.isBlocking);
|
|
45758
|
-
|
|
45759
|
-
|
|
45760
|
-
|
|
45836
|
+
const queuedRules = this.queuedDVChanges[targetSheetId];
|
|
45837
|
+
if (!targetRule && queuedRules) {
|
|
45838
|
+
targetRule = queuedRules.find((queued) => deepEquals(originRule.criterion, queued.rule.criterion) &&
|
|
45839
|
+
originRule.isBlocking === queued.rule.isBlocking)?.rule;
|
|
45840
|
+
}
|
|
45841
|
+
return targetRule || { ...originRule, id: this.uuidGenerator.smallUuid(), ranges: [] };
|
|
45761
45842
|
}
|
|
45762
45843
|
/**
|
|
45763
45844
|
* Add or remove XCs to a given data validation rule.
|
|
45764
45845
|
*/
|
|
45765
45846
|
adaptDataValidationRule(sheetId, rule, toAdd, toRemove) {
|
|
45766
|
-
|
|
45767
|
-
|
|
45768
|
-
if (newRangesXC.length === 0) {
|
|
45769
|
-
this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: rule.id });
|
|
45770
|
-
return;
|
|
45847
|
+
if (!this.queuedDVChanges[sheetId]) {
|
|
45848
|
+
this.queuedDVChanges[sheetId] = [];
|
|
45771
45849
|
}
|
|
45772
|
-
this.
|
|
45773
|
-
|
|
45774
|
-
|
|
45775
|
-
|
|
45776
|
-
|
|
45850
|
+
const queuedChange = this.queuedDVChanges[sheetId].find((queued) => queued.rule.id === rule.id);
|
|
45851
|
+
if (!queuedChange) {
|
|
45852
|
+
this.queuedDVChanges[sheetId].push({ toAdd, toRemove, rule: deepCopy(rule) });
|
|
45853
|
+
}
|
|
45854
|
+
else {
|
|
45855
|
+
queuedChange.toAdd.push(...toAdd);
|
|
45856
|
+
queuedChange.toRemove.push(...toRemove);
|
|
45857
|
+
}
|
|
45858
|
+
}
|
|
45859
|
+
executeQueuedChanges(pasteSheetTarget) {
|
|
45860
|
+
for (const sheetId in this.queuedCFChanges) {
|
|
45861
|
+
for (const { toAdd, toRemove, cf } of this.queuedCFChanges[sheetId]) {
|
|
45862
|
+
const newRangesXc = this.getters.getAdaptedCfRanges(sheetId, cf, toAdd, toRemove);
|
|
45863
|
+
if (!newRangesXc) {
|
|
45864
|
+
continue;
|
|
45865
|
+
}
|
|
45866
|
+
if (newRangesXc.length === 0) {
|
|
45867
|
+
this.dispatch("REMOVE_CONDITIONAL_FORMAT", { id: cf.id, sheetId });
|
|
45868
|
+
continue;
|
|
45869
|
+
}
|
|
45870
|
+
this.dispatch("ADD_CONDITIONAL_FORMAT", {
|
|
45871
|
+
cf: {
|
|
45872
|
+
id: cf.id,
|
|
45873
|
+
rule: cf.rule,
|
|
45874
|
+
stopIfTrue: cf.stopIfTrue,
|
|
45875
|
+
},
|
|
45876
|
+
ranges: newRangesXc.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
45877
|
+
sheetId,
|
|
45878
|
+
});
|
|
45879
|
+
}
|
|
45880
|
+
}
|
|
45881
|
+
for (const sheetId in this.queuedDVChanges) {
|
|
45882
|
+
for (const { toAdd, toRemove, rule: dv } of this.queuedDVChanges[sheetId]) {
|
|
45883
|
+
// Remove the zones first in case the same position is in toAdd and toRemove
|
|
45884
|
+
const dvZones = dv.ranges.map((range) => range.zone);
|
|
45885
|
+
const withRemovedZones = futureRecomputeZones(dvZones, toRemove);
|
|
45886
|
+
const newDvZones = futureRecomputeZones([...withRemovedZones, ...toAdd], []);
|
|
45887
|
+
if (newDvZones.length === 0) {
|
|
45888
|
+
this.dispatch("REMOVE_DATA_VALIDATION_RULE", { sheetId, id: dv.id });
|
|
45889
|
+
continue;
|
|
45890
|
+
}
|
|
45891
|
+
this.dispatch("ADD_DATA_VALIDATION_RULE", {
|
|
45892
|
+
rule: { id: dv.id, criterion: dv.criterion, isBlocking: dv.isBlocking },
|
|
45893
|
+
ranges: newDvZones.map((zone) => this.getters.getRangeDataFromZone(sheetId, zone)),
|
|
45894
|
+
sheetId,
|
|
45895
|
+
});
|
|
45896
|
+
}
|
|
45897
|
+
}
|
|
45898
|
+
for (const borderKey in this.queuedBordersToAdd) {
|
|
45899
|
+
const zones = this.queuedBordersToAdd[borderKey];
|
|
45900
|
+
const border = JSON.parse(borderKey);
|
|
45901
|
+
const target = futureRecomputeZones(zones, []);
|
|
45902
|
+
this.dispatch("SET_BORDERS_ON_TARGET", { sheetId: pasteSheetTarget, target, border });
|
|
45903
|
+
}
|
|
45904
|
+
this.queuedBordersToAdd = {};
|
|
45777
45905
|
}
|
|
45778
45906
|
}
|
|
45779
45907
|
|
|
@@ -58121,6 +58249,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
58121
58249
|
exports.tokenize = tokenize;
|
|
58122
58250
|
|
|
58123
58251
|
|
|
58124
|
-
__info__.version = "17.0.
|
|
58125
|
-
__info__.date = "2025-04-
|
|
58126
|
-
__info__.hash = "
|
|
58252
|
+
__info__.version = "17.0.57";
|
|
58253
|
+
__info__.date = "2025-04-14T17:13:56.677Z";
|
|
58254
|
+
__info__.hash = "6ac8bb7";
|