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 //cell locked state
export function checkProtectionLocked(r, c, sheetIndex){ export function checkProtectionLocked(r, c, sheetIndex, isOpenAlert=true, isLock=true){
let sheetFile = sheetmanage.getSheetByIndex(sheetIndex); let sheetFile = sheetmanage.getSheetByIndex(sheetIndex);
if(sheetFile==null){ if(sheetFile==null){
@ -916,7 +916,7 @@ export function checkProtectionLocked(r, c, sheetIndex){
const _locale = locale(); const _locale = locale();
const local_protection = _locale.protection; const local_protection = _locale.protection;
return checkProtectionLockedSqref(r, c , aut, local_protection); return checkProtectionLockedSqref(r, c , aut, local_protection, isOpenAlert, isLock);
} }
//cell hidden state //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 func_methods from '../global/func_methods';
import Store from '../store'; import Store from '../store';
import locale from '../locale/locale'; import locale from '../locale/locale';
import {checkProtectionLockedRangeList,checkProtectionAllSelected,checkProtectionSelectLockedOrUnLockedCells,checkProtectionNotEnable,checkProtectionLocked} from './protection';
//查找替换 //查找替换
const luckysheetSearchReplace = { const luckysheetSearchReplace = {
@ -575,6 +577,10 @@ const luckysheetSearchReplace = {
let v = replaceText; let v = replaceText;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex)){
return;
}
setcellvalue(r, c, d, v); setcellvalue(r, c, d, v);
} }
else{ else{
@ -589,6 +595,10 @@ const luckysheetSearchReplace = {
r = searchIndexArr[count].r; r = searchIndexArr[count].r;
c = searchIndexArr[count].c; c = searchIndexArr[count].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex)){
return;
}
let v = valueShowEs(r, c, d).toString().replace(reg, replaceText); let v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
setcellvalue(r, c, d, v); setcellvalue(r, c, d, v);
@ -695,17 +705,22 @@ const luckysheetSearchReplace = {
let replaceText = $("#luckysheet-search-replace #replaceInput input").val(); let replaceText = $("#luckysheet-search-replace #replaceInput input").val();
let d = editor.deepCopyFlowData(Store.flowdata); let d = editor.deepCopyFlowData(Store.flowdata);
let replaceCount = 0;
if(wordCheck){ if(wordCheck){
for(let i = 0; i < searchIndexArr.length; i++){ for(let i = 0; i < searchIndexArr.length; i++){
let r = searchIndexArr[i].r; let r = searchIndexArr[i].r;
let c = searchIndexArr[i].c; let c = searchIndexArr[i].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex, false)){
continue;
}
let v = replaceText; let v = replaceText;
setcellvalue(r, c, d, v); setcellvalue(r, c, d, v);
range.push({ "row": [r, r], "column": [c, c] }); range.push({ "row": [r, r], "column": [c, c] });
replaceCount++;
} }
} }
else{ else{
@ -721,11 +736,16 @@ const luckysheetSearchReplace = {
let r = searchIndexArr[i].r; let r = searchIndexArr[i].r;
let c = searchIndexArr[i].c; let c = searchIndexArr[i].c;
if(!checkProtectionLocked(r, c, Store.currentSheetIndex, false)){
continue;
}
let v = valueShowEs(r, c, d).toString().replace(reg, replaceText); let v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
setcellvalue(r, c, d, v); setcellvalue(r, c, d, v);
range.push({ "row": [r, r], "column": [c, c] }); range.push({ "row": [r, r], "column": [c, c] });
replaceCount++;
} }
} }
@ -739,7 +759,7 @@ const luckysheetSearchReplace = {
selectHightlightShow(); selectHightlightShow();
let succeedInfo = replaceHtml(locale_findAndReplace.successTip, { let succeedInfo = replaceHtml(locale_findAndReplace.successTip, {
"xlength": searchIndexArr.length "xlength": replaceCount
}); });
if(isEditMode()){ if(isEditMode()){
alert(succeedInfo); alert(succeedInfo);

Loading…
Cancel
Save