Browse Source

fix: Find&Replace also replaces in locked cells

master
wbfsa 5 years ago
parent
commit
3b377617b3
  1. 4
      src/controllers/protection.js
  2. 24
      src/controllers/searchReplace.js

4
src/controllers/protection.js

@ -892,7 +892,7 @@ export function checkProtectionNotEnable(sheetIndex){
}
//cell locked state
export function checkProtectionLocked(r, c, sheetIndex){
export function checkProtectionLocked(r, c, sheetIndex, isOpenAlert=true, isLock=true){
let sheetFile = sheetmanage.getSheetByIndex(sheetIndex);
if(sheetFile==null){
@ -916,7 +916,7 @@ export function checkProtectionLocked(r, c, sheetIndex){
const _locale = locale();
const local_protection = _locale.protection;
return checkProtectionLockedSqref(r, c , aut, local_protection);
return checkProtectionLockedSqref(r, c , aut, local_protection, isOpenAlert, isLock);
}
//cell hidden state

24
src/controllers/searchReplace.js

@ -12,6 +12,8 @@ import tooltip from '../global/tooltip';
import func_methods from '../global/func_methods';
import Store from '../store';
import locale from '../locale/locale';
import {checkProtectionLockedRangeList,checkProtectionAllSelected,checkProtectionSelectLockedOrUnLockedCells,checkProtectionNotEnable,checkProtectionLocked} from './protection';
//查找替换
const luckysheetSearchReplace = {
@ -575,6 +577,10 @@ const luckysheetSearchReplace = {
let v = replaceText;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex)){
return;
}
setcellvalue(r, c, d, v);
}
else{
@ -589,6 +595,10 @@ const luckysheetSearchReplace = {
r = searchIndexArr[count].r;
c = searchIndexArr[count].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex)){
return;
}
let v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
setcellvalue(r, c, d, v);
@ -695,17 +705,22 @@ const luckysheetSearchReplace = {
let replaceText = $("#luckysheet-search-replace #replaceInput input").val();
let d = editor.deepCopyFlowData(Store.flowdata);
let replaceCount = 0;
if(wordCheck){
for(let i = 0; i < searchIndexArr.length; i++){
let r = searchIndexArr[i].r;
let c = searchIndexArr[i].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex, false)){
continue;
}
let v = replaceText;
setcellvalue(r, c, d, v);
range.push({ "row": [r, r], "column": [c, c] });
replaceCount++;
}
}
else{
@ -721,11 +736,16 @@ const luckysheetSearchReplace = {
let r = searchIndexArr[i].r;
let c = searchIndexArr[i].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex, false)){
continue;
}
let v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
setcellvalue(r, c, d, v);
range.push({ "row": [r, r], "column": [c, c] });
replaceCount++;
}
}
@ -739,7 +759,7 @@ const luckysheetSearchReplace = {
selectHightlightShow();
let succeedInfo = replaceHtml(locale_findAndReplace.successTip, {
"xlength": searchIndexArr.length
"xlength": replaceCount
});
if(isEditMode()){
alert(succeedInfo);

Loading…
Cancel
Save