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