diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js index 1f1d52163..a4711695e 100644 --- a/apps/common/main/lib/view/SearchPanel.js +++ b/apps/common/main/lib/view/SearchPanel.js @@ -326,7 +326,9 @@ define([ if (count > 300) { text = this.textTooManyResults; } else { - text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)); + text = current === 'no-results' ? this.textNoSearchResults : + (current === 'stop' ? this.textSearchHasStopped : + (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count))); } this.$reaultsNumber.text(text); this.disableReplaceButtons(!count); @@ -412,7 +414,8 @@ define([ textName: 'Name', textCell: 'Cell', textValue: 'Value', - textFormula: 'Formula' + textFormula: 'Formula', + textSearchHasStopped: 'Search has stopped' }, Common.Views.SearchPanel || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index 649e8f73c..21e8f7825 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -100,6 +100,7 @@ define([ this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this)); this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this)); this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this)); + this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this)); } return this; }, @@ -215,7 +216,7 @@ define([ searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_WholeWords(this._state.matchWord); if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { - this.allResultsWasRemoved(); + this.removeResultItems(); } } }, @@ -242,14 +243,14 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.allResultsWasRemoved(); + this.removeResultItems(); } }, - allResultsWasRemoved: function () { + removeResultItems: function (type) { this.resultItems = []; this.hideResults(); - this.view.updateResultsNumber(undefined, 0); + this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches this.view.disableReplaceButtons(true); this._state.currentResult = 0; this._state.resultsNumber = 0; @@ -420,6 +421,10 @@ define([ } }, + onApiSearchEnd: function () { + this.removeResultItems('stop'); + }, + notcriticalErrorTitle: 'Warning', warnReplaceString: '{0} is not a valid special character for the Replace With box.' diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 76ab2592b..ece2b315f 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -480,6 +480,7 @@ "Common.Views.SearchPanel.textWholeWords": "Whole words only", "Common.Views.SearchPanel.tipNextResult": "Next result", "Common.Views.SearchPanel.tipPreviousResult": "Previous result", + "Common.Views.SearchPanel.textSearchHasStopped": "Search has stopped", "Common.Views.SelectFileDlg.textLoading": "Loading", "Common.Views.SelectFileDlg.textTitle": "Select Data Source", "Common.Views.SignDialog.textBold": "Bold", diff --git a/apps/documenteditor/mobile/src/controller/Search.jsx b/apps/documenteditor/mobile/src/controller/Search.jsx index 4e95b4684..e47467400 100644 --- a/apps/documenteditor/mobile/src/controller/Search.jsx +++ b/apps/documenteditor/mobile/src/controller/Search.jsx @@ -108,10 +108,13 @@ const Search = withTranslation()(props => { f7.popover.close('.document-menu.modal-in', false); if (params.find && params.find.length) { + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); if (params.highlight) api.asc_selectSearchingResults(true); - api.asc_findText(params.find, params.forward, params.caseSensitive, function (resultCount) { + api.asc_findText(options, params.forward, function (resultCount) { !resultCount && f7.dialog.alert(null, _t.textNoTextFound); }); } @@ -127,7 +130,10 @@ const Search = withTranslation()(props => { const api = Common.EditorApi.get(); if (params.find && params.find.length) { - api.asc_replaceText(params.find, params.replace || '', false, params.caseSensitive, params.highlight); + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); + api.asc_replaceText(options, params.replace || '', false); } } @@ -135,7 +141,10 @@ const Search = withTranslation()(props => { const api = Common.EditorApi.get(); if (params.find && params.find.length) { - api.asc_replaceText(params.find, params.replace || '', true, params.caseSensitive, params.highlight); + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); + api.asc_replaceText(options, params.replace || '', true); } } diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index cde4704a9..1c8d11973 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -97,6 +97,7 @@ define([ this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this)); this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this)); this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this)); + this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this)); } return this; }, @@ -198,7 +199,7 @@ define([ searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_WholeWords(this._state.matchWord); if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { - this.allResultsWasRemoved(); + this.removeResultItems(); } } }, @@ -211,14 +212,14 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.allResultsWasRemoved(); + this.removeResultItems(); } }, - allResultsWasRemoved: function () { + removeResultItems: function (type) { this.resultItems = []; this.hideResults(); - this.view.updateResultsNumber(undefined, 0); + this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches this.view.disableReplaceButtons(true); this._state.currentResult = 0; this._state.resultsNumber = 0; @@ -373,6 +374,10 @@ define([ this.hideResults(); }, + onApiSearchEnd: function () { + this.removeResultItems('stop'); + }, + notcriticalErrorTitle: 'Warning', warnReplaceString: '{0} is not a valid special character for the Replace With box.' diff --git a/apps/presentationeditor/mobile/src/controller/Search.jsx b/apps/presentationeditor/mobile/src/controller/Search.jsx index c3c254ac3..069e69893 100644 --- a/apps/presentationeditor/mobile/src/controller/Search.jsx +++ b/apps/presentationeditor/mobile/src/controller/Search.jsx @@ -88,7 +88,10 @@ const Search = withTranslation()(props => { f7.popover.close('.document-menu.modal-in', false); if (params.find && params.find.length) { - api.asc_findText(params.find, params.forward, params.caseSensitive, function(resultCount) { + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); + api.asc_findText(options, params.forward, function(resultCount) { !resultCount && f7.dialog.alert(null, _t.textNoTextFound); }); @@ -105,7 +108,10 @@ const Search = withTranslation()(props => { const api = Common.EditorApi.get(); if (params.find && params.find.length) { - api.asc_replaceText(params.find, params.replace || '', false, params.caseSensitive); + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); + api.asc_replaceText(options, params.replace || '', false); } } @@ -113,7 +119,10 @@ const Search = withTranslation()(props => { const api = Common.EditorApi.get(); if (params.find && params.find.length) { - api.asc_replaceText(params.find, params.replace || '', true, params.caseSensitive); + var options = new AscCommon.CSearchSettings(); + options.put_Text(params.find); + options.put_MatchCase(params.caseSensitive); + api.asc_replaceText(options, params.replace || '', true); } } diff --git a/apps/spreadsheeteditor/main/app/view/LeftMenu.js b/apps/spreadsheeteditor/main/app/view/LeftMenu.js index 46052302c..4d07dc04b 100644 --- a/apps/spreadsheeteditor/main/app/view/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/view/LeftMenu.js @@ -216,6 +216,7 @@ define([ if (this.panelSearch) { if (this.btnSearchBar.pressed) { this.panelSearch.show(); + this.panelSearch.focus(); } else { this.panelSearch.hide(); }