diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 299b873f9..dcf19017d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -93,7 +93,8 @@ define([ initialize: function() { this.addListeners({ 'FileMenu': { - 'settings:apply': _.bind(this.applySettings, this) + 'settings:apply': _.bind(this.applySettings, this), + 'spellcheck:apply': _.bind(this.applySpellcheckSettings, this) }, 'Common.Views.ReviewChanges': { 'settings:apply': _.bind(this.applySettings, this) @@ -685,6 +686,15 @@ define([ Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth); /** coauthoring end **/ + /** spellcheck settings begin **/ + var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true); + Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase); + this.api.asc_ignoreUppercase(ignoreUppercase); + var ignoreNumbers = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words", true); + Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers); + this.api.asc_ignoreUppercase(ignoreNumbers); + /** spellcheck settings end **/ + me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me)); me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me)); me.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(me.onActiveSheetChanged, me)); @@ -2040,6 +2050,17 @@ define([ } }, + applySpellcheckSettings: function() { + if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring && this.api) { + var value = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words"); + this.api.asc_ignoreUppercase(value); + value = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words"); + this.api.asc_ignoreNumbers(value); + value = parseInt(Common.localStorage.getItem("sse-spellcheck-locale")); + this.api.asc_setDefaultLanguage(value); + } + }, + onDocumentName: function(name) { this.headerView.setDocumentCaption(name); this.updateWindowTitle(this.api.asc_isDocumentModified(), true); diff --git a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js index 0a58ef1b3..f6e61d6ec 100644 --- a/apps/spreadsheeteditor/main/app/controller/Spellcheck.js +++ b/apps/spreadsheeteditor/main/app/controller/Spellcheck.js @@ -55,6 +55,7 @@ define([ 'Spellcheck': { 'show': function() { me._initSettings && me.loadLanguages(); + me.updateLanguages(); me.onClickNext(); }, 'hide': function() { @@ -124,20 +125,16 @@ define([ }, loadLanguages: function () { - var value = Common.localStorage.getItem("sse-spellcheck-locale"); - if (value) - value = parseInt(value); - else - value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409; + var me = this; + Common.Utils.InternalSettings.set("sse-spellcheck-locale", Common.localStorage.getItem("sse-spellcheck-locale")); - var combo = this.panelSpellcheck.cmbDictionaryLanguage; if (this.languages && this.languages.length>0) { - var langs = [], info, - allLangs = Common.util.LanguageInfo.getLanguages(); + var langs = [], info; + this.allLangs = Common.util.LanguageInfo.getLanguages(); this.languages.forEach(function (code) { code = parseInt(code); - if (allLangs.hasOwnProperty(code)) { - info = allLangs[code]; + if (me.allLangs.hasOwnProperty(code)) { + info = me.allLangs[code]; langs.push({ displayValue: info[1], shortName: info[0], @@ -151,13 +148,30 @@ define([ return 0; }); this.langs = langs; - combo.setData(langs); + } else { + this.langs = undefined; + } + this._initSettings = false; + + return [this.allLangs, this.langs]; + }, + + updateLanguages: function() { + var sessionValue = Common.Utils.InternalSettings.get("sse-spellcheck-locale"), + value; + if (sessionValue) + value = parseInt(sessionValue); + else + value = this.mode.lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)) : 0x0409; + var combo = this.panelSpellcheck.cmbDictionaryLanguage; + if (this.langs && this.langs.length>0) { + combo.setData(this.langs); var item = combo.store.findWhere({value: value}); - if (!item && allLangs[value]) { - value = allLangs[value][0].split(/[\-\_]/)[0]; + if (!item && this.allLangs[value]) { + value = this.allLangs[value][0].split(/[\-\_]/)[0]; item = combo.store.find(function(model){ - return model.get('shortName').indexOf(value)==0; - }); + return model.get('shortName').indexOf(value)==0; + }); } combo.setValue(item ? item.get('value') : langs[0].value); value = combo.getValue(); @@ -165,18 +179,21 @@ define([ combo.setValue(Common.util.LanguageInfo.getLocalLanguageName(value)[1]); combo.setDisabled(true); } - this.langValue = value; - this.api.asc_setDefaultLanguage(value); - this._initSettings = false; - - return [this.langs, this.langValue]; + if (this.api) { + this.api.asc_setDefaultLanguage(value); + if (value !== sessionValue) { + Common.Utils.InternalSettings.set("sse-spellcheck-locale", value); + } + } }, onSelectLanguage: function (combo, record) { var lang = record.value; if (this.api && lang) { this.api.asc_setDefaultLanguage(lang); - Common.localStorage.setItem("sse-spellcheck-locale", this.panelSpellcheck.cmbDictionaryLanguage.getValue()); + var value = this.panelSpellcheck.cmbDictionaryLanguage.getValue(); + Common.localStorage.setItem("sse-spellcheck-locale", value); + Common.Utils.InternalSettings.set("sse-spellcheck-locale", value); } Common.NotificationCenter.trigger('edit:complete', this, {restorefocus:true}); }, @@ -250,7 +267,7 @@ define([ onApiEditCell: function(state) { if (state == Asc.c_oAscCellEditorState.editEnd) { this.panelSpellcheck.buttonNext.setDisabled(!this.panelSpellcheck.lblComplete.hasClass('hidden')); - this.panelSpellcheck.cmbDictionaryLanguage.setDisabled(false); + this.panelSpellcheck.cmbDictionaryLanguage.setDisabled((this.languages && this.languages.length > 0) ? false : true); } else { this.panelSpellcheck.buttonNext.setDisabled(true); this.panelSpellcheck.currentWord.setDisabled(true); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 3810c812f..3fd6c8cfe 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -232,6 +232,7 @@ define([ if (!this.mode.canPrint) this.viewSettingsPicker.store.pop(); this.generalSettings && this.generalSettings.setMode(this.mode); + this.spellcheckSettings && this.spellcheckSettings.setMode(this.mode); }, setApi: function(api) { @@ -970,6 +971,11 @@ define([ '', '
', '', + '