Commit 40506e4e authored by Ilya.Kirillov's avatar Ilya.Kirillov

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

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