Commit 3409668d authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил asc_CFindOptions - опции для поиска (и замены)

Добавил поиск по значениям (а не только по формулам)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55508 954022d7-b5bf-4e40-9824-e11837661b57
parent ad17bac8
......@@ -2276,8 +2276,15 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
asc_findText: function (text, scanByRows, scanForward, isMatchCase, isWholeCell) {
var d = this.wb.findCellText({text: text, scanByRows: scanByRows, scanForward: scanForward,
isMatchCase: isMatchCase, isWholeCell: isWholeCell, isNotSelect: false});
var temp = new asc.asc_CFindOptions();
temp.findWhat = text;
temp.scanByRows = scanByRows;
temp.scanForward = scanForward;
temp.isMatchCase = isMatchCase;
temp.isWholeCell = isWholeCell;
temp.isNotSelect = false;
var d = this.wb.findCellText(temp);
if (d) {
if (d.deltaX) {this.controller.scrollHorizontal(d.deltaX);}
if (d.deltaY) {this.controller.scrollVertical(d.deltaY);}
......@@ -2286,8 +2293,16 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
asc_replaceText: function (findWhat, replaceWith, isReplaceAll, isMatchCase, isWholeCell) {
this.wb.replaceCellText({findWhat: findWhat, replaceWith: replaceWith, isReplaceAll: isReplaceAll,
isMatchCase: isMatchCase, isWholeCell: isWholeCell});
var temp = new asc.asc_CFindOptions();
temp.findWhat = findWhat;
temp.isMatchCase = isMatchCase;
temp.isWholeCell = isWholeCell;
temp.lookIn = c_oAscFindLookIn.Formulas; // При замене поиск только в формулах
temp.replaceWith = replaceWith;
temp.isReplaceAll = isReplaceAll;
this.wb.replaceCellText(temp);
},
/**
......
......@@ -469,6 +469,12 @@ var c_oAscFreezePane = {
FreezeFirstColumn : 3,
FreezeClean : 4
};
var c_oAscFindLookIn = {
Formulas : 1,
Value : 2,
Annotations : 3
};
var c_oAscCoAuthoringMeBorderColor = new window.CColor(22, 156, 0);
var c_oAscCoAuthoringOtherBorderColor = new window.CColor(238, 53, 37);
......
......@@ -4204,7 +4204,7 @@ Cell.prototype.getValue=function(numFormat, dDigitsCount){
};
Cell.prototype.getValue2=function(dDigitsCount, fIsFitMeasurer){
if(null == fIsFitMeasurer)
fIsFitMeasurer = function(aText){return true;}
fIsFitMeasurer = function(aText){return true;};
if(null == dDigitsCount)
dDigitsCount = gc_nMaxDigCountView;
return this.oValue.getValue2(dDigitsCount, fIsFitMeasurer);
......@@ -4213,7 +4213,7 @@ Cell.prototype.getNumFormatStr=function(){
if(null != this.xfs && null != this.xfs.num)
return this.xfs.num.f;
return g_oDefaultNum.f;
}
};
Cell.prototype.moveHor=function(val){
//копируем потому что изначально обьект ыбл получен из g_oCellAddressUtils
this.oId = new CellAddress(this.oId.getRow0(), this.oId.getCol0(), 0);
......
......@@ -1245,6 +1245,47 @@
asc_getAverage: function () { return this.average; }
};
/** @constructor */
function asc_CFindOptions() {
this.findWhat = ""; // текст, который ищем
this.scanByRows = true; // просмотр по строкам/столбцам
this.scanForward = true; // поиск вперед/назад
this.isMatchCase = false; // учитывать регистр
this.isWholeCell = false; // ячейка целиком
this.scanOnOnlySheet = true; // искать только на листе/в книге
this.lookIn = c_oAscFindLookIn.Formulas; // искать в формулах/значениях/примечаниях
this.replaceWith = ""; // текст, на который заменяем (если у нас замена)
this.isReplaceAll = false; // заменить все (если у нас замена)
// внутренние переменные
this.activeRange = null;
this.isNotSelect = false;
this.indexInArray = 0;
this.countFind = 0;
this.countReplace = 0;
}
asc_CFindOptions.prototype.clone = function () {
var result = new asc_CFindOptions();
result.findWhat = this.findWhat;
result.scanByRows = this.scanByRows;
result.scanForward = this.scanForward;
result.isMatchCase = this.isMatchCase;
result.isWholeCell = this.isWholeCell;
result.scanOnOnlySheet = this.scanOnOnlySheet;
result.lookIn = this.lookIn;
result.replaceWith = this.replaceWith;
result.isReplaceAll = this.isReplaceAll;
result.activeRange = this.activeRange ? this.activeRange.clone() : null;
result.isNotSelect = this.isNotSelect;
result.indexInArray = this.indexInArray;
result.countFind = this.countFind;
result.countReplace = this.countReplace;
return result;
};
/*
* Export
* -----------------------------------------------------------------------------
......@@ -1380,5 +1421,7 @@
prot["asc_getSum"] = prot.asc_getSum;
prot["asc_getAverage"] = prot.asc_getAverage;
window["Asc"]["asc_CFindOptions"] = window["Asc"].asc_CFindOptions = asc_CFindOptions;
}
)(jQuery, window);
......@@ -9669,7 +9669,7 @@
WorksheetView.prototype.findCellText = function (options) {
var self = this;
if (true !== options.isMatchCase)
options.text = options.text.toLowerCase();
options.findWhat = options.findWhat.toLowerCase();
var ar = options.activeRange ? options.activeRange : this.activeRange;
var c = ar.startCol;
var r = ar.startRow;
......@@ -9715,11 +9715,11 @@
_tmpCell = this.model.getCell (new CellAddress(mc.r1, mc.c1, 0));
else
_tmpCell = this.model.getCell (new CellAddress(r, c, 0));
cellText = _tmpCell.getValueForEdit();
cellText = (options.lookIn === c_oAscFindLookIn.Formulas) ? _tmpCell.getValueForEdit() : _tmpCell.getValue();
if (true !== options.isMatchCase)
cellText = cellText.toLowerCase();
if (cellText.indexOf(options.text) >= 0) {
if (true !== options.isWholeCell || options.text.length === cellText.length)
if (cellText.indexOf(options.findWhat) >= 0) {
if (true !== options.isWholeCell || options.findWhat.length === cellText.length)
return (options.isNotSelect) ? (mc ? new asc_Range(mc.c1, mc.r1, mc.c1, mc.r1) : new asc_Range(c, r, c, r)) : this._setActiveCell(c, r);
}
}
......@@ -9767,11 +9767,11 @@
_tmpCell = this.model.getCell (new CellAddress(mc.r1, mc.c1, 0));
else
_tmpCell = this.model.getCell (new CellAddress(r, c, 0));
cellText = _tmpCell.getValueForEdit();
cellText = (options.lookIn === c_oAscFindLookIn.Formulas) ? _tmpCell.getValueForEdit() : _tmpCell.getValue();
if (true !== options.isMatchCase)
cellText = cellText.toLowerCase();
if (cellText.indexOf(options.text) >= 0) {
if (true !== options.isWholeCell || options.text.length === cellText.length)
if (cellText.indexOf(options.findWhat) >= 0) {
if (true !== options.isWholeCell || options.findWhat.length === cellText.length)
return (options.isNotSelect) ? (mc ? new asc_Range(mc.c1, mc.r1, mc.c1, mc.r1) : new asc_Range(c, r, c, r)) : this._setActiveCell(c, r);
}
}
......@@ -9800,8 +9800,9 @@
// На ReplaceAll ставим медленную операцию
t.handlers.trigger("slowOperation", true);
var aReplaceCellsIndex = {};
var optionsFind = {text: options.findWhat, scanByRows: true, scanForward: true,
isMatchCase: options.isMatchCase, isWholeCell: options.isWholeCell, isNotSelect: true, activeRange: ar};
var optionsFind = options.clone();
optionsFind.isNotSelect = true;
optionsFind.activeRange = ar;
var findResult, index;
while (true) {
findResult = t.findCellText(optionsFind);
......@@ -9827,7 +9828,7 @@
return;
}
var cellValue = c.getValueForEdit();
var cellValue = (options.lookIn === c_oAscFindLookIn.Formulas) ? c.getValueForEdit() : c.getValue();
// Попробуем сначала найти
if ((true === options.isWholeCell && cellValue.length !== options.findWhat.length) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment