Commit 50f14296 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Изменено апи поиска и замены

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49019 954022d7-b5bf-4e40-9824-e11837661b57
parent c4760ec6
......@@ -22,6 +22,9 @@ function CParagraphSearchElement(StartPos, EndPos, Type)
//----------------------------------------------------------------------------------------------------------------------
function CDocumentSearch()
{
this.Text = "";
this.IsMatchCase = false;
this.Id = 0;
this.Count = 0;
this.Elements = new Array();
......@@ -33,8 +36,25 @@ function CDocumentSearch()
CDocumentSearch.prototype =
{
Set : function(Text, Props)
{
this.Text = Text;
this.IsMatchCase = Props.IsMatchCase;
},
Compare : function(Text, Props)
{
if ( this.Text === Text && this.IsMatchCase === Props.IsMatchCase )
return true;
return false;
},
Clear : function()
{
this.Text = "";
this.IsMatchCase = false;
// Очищаем предыдущие элементы поиска
for ( var Id in this.Elements )
{
......@@ -154,7 +174,11 @@ CDocument.prototype.Search = function(Str, Props)
{
var StartTime = new Date().getTime();
if ( true === this.SearchEngine.Compare( Str, Props ) )
return this.SearchEngine;
this.SearchEngine.Clear();
this.SearchEngine.Set( Str, Props );
// Поиск в основном документе
var Count = this.Content.length;
......
......@@ -2740,32 +2740,22 @@ asc_docs_api.prototype.sync_ReturnHeadersCallback = function (headers){
}
*/
asc_docs_api.prototype.asc_findText = function(text, isMatchCase)
asc_docs_api.prototype.asc_findText = function(text, isNext, isMatchCase)
{
var SearchEngine = editor.WordControl.m_oLogicDocument.Search( text, { MatchCase : isMatchCase } );
var Id = this.WordControl.m_oLogicDocument.Search_GetId( true );
if ( null != Id )
this.WordControl.m_oLogicDocument.Search_Select( Id );
return SearchEngine.Count;
}
asc_docs_api.prototype.asc_findForward = function(isNext)
{
var Id = this.WordControl.m_oLogicDocument.Search_GetId( isNext );
if ( null != Id )
{
this.WordControl.m_oLogicDocument.Search_Select( Id );
return true;
}
return false;
return SearchEngine.Count;
}
asc_docs_api.prototype.asc_replaceText = function(replaceWith, isReplaceAll)
asc_docs_api.prototype.asc_replaceText = function(text, replaceWith, isReplaceAll, isMatchCase)
{
editor.WordControl.m_oLogicDocument.Search( text, { MatchCase : isMatchCase } );
if ( true === isReplaceAll )
this.WordControl.m_oLogicDocument.Search_Replace(replaceWith, true, -1);
else
......
......@@ -4155,18 +4155,24 @@ $(".colorWatch").mouseover(function(){
var String = document.getElementById("searchString").value;
var MatchCase = document.getElementById("searchMatchCase").checked;
editor.asc_findText(String, MatchCase);
editor.asc_findText(String, true, MatchCase);
Search_Start();
});
$("#searchNext").click(function()
{
editor.asc_findForward(true);
var String = document.getElementById("searchString").value;
var MatchCase = document.getElementById("searchMatchCase").checked;
editor.asc_findText(String, true, MatchCase);
//Search_NextElemet(true);
});
$("#searchPrev").click(function()
{
editor.asc_findForward(false);
var String = document.getElementById("searchString").value;
var MatchCase = document.getElementById("searchMatchCase").checked;
editor.asc_findText(String, false, MatchCase);
//Search_NextElemet(false);
});
......@@ -4188,15 +4194,21 @@ $(".colorWatch").mouseover(function(){
$("#replaceStringButton").click(function()
{
var String = document.getElementById("replaceString").value;
editor.asc_replaceText(String, false);
var srcString = document.getElementById("searchString").value;
var MatchCase = document.getElementById("searchMatchCase").checked;
var repString = document.getElementById("replaceString").value;
editor.asc_replaceText(srcString, repString, false, MatchCase);
//Search_Replace(false);
});
$("#replaceAllStringButton").click(function()
{
var String = document.getElementById("replaceString").value;
editor.asc_replaceText(String, true);
var srcString = document.getElementById("searchString").value;
var MatchCase = document.getElementById("searchMatchCase").checked;
var repString = document.getElementById("replaceString").value;
editor.asc_replaceText(srcString, repString, true, MatchCase);
//Search_Replace(true);
});
......
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