Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 33E6498F9 for ; Sun, 24 Jun 2012 14:21:12 +0000 (UTC) Received: (qmail 16726 invoked by uid 500); 24 Jun 2012 14:21:11 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 16680 invoked by uid 500); 24 Jun 2012 14:21:11 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 16671 invoked by uid 99); 24 Jun 2012 14:21:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jun 2012 14:21:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jun 2012 14:21:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 899ED23888CD; Sun, 24 Jun 2012 14:20:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1353272 - in /incubator/ooo/trunk/main/cui/source: dialogs/SpellDialog.cxx inc/SpellDialog.hxx Date: Sun, 24 Jun 2012 14:20:50 -0000 To: ooo-commits@incubator.apache.org From: arielch@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120624142050.899ED23888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: arielch Date: Sun Jun 24 14:20:49 2012 New Revision: 1353272 URL: http://svn.apache.org/viewvc?rev=1353272&view=rev Log: i120048 - Correct handling of user dictionaries in svx::SpellDialog Modified: incubator/ooo/trunk/main/cui/source/dialogs/SpellDialog.cxx incubator/ooo/trunk/main/cui/source/inc/SpellDialog.hxx Modified: incubator/ooo/trunk/main/cui/source/dialogs/SpellDialog.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/cui/source/dialogs/SpellDialog.cxx?rev=1353272&r1=1353271&r2=1353272&view=diff ============================================================================== --- incubator/ooo/trunk/main/cui/source/dialogs/SpellDialog.cxx (original) +++ incubator/ooo/trunk/main/cui/source/dialogs/SpellDialog.cxx Sun Jun 24 14:20:49 2012 @@ -256,6 +256,9 @@ SpellDialog::SpellDialog( aChangePB. SetHelpId(HID_SPLDLG_BUTTON_CHANGE ); aChangeAllPB. SetHelpId(HID_SPLDLG_BUTTON_CHANGEALL); aExplainPB. SetHelpId(HID_SPLDLG_BUTTON_EXPLAIN ); + + aAddToDictMB.SetPopupMenu( new PopupMenu ); + Init_Impl(); // disable controls if service is missing @@ -301,6 +304,7 @@ void SpellDialog::Init_Impl() aSuggestionLB.SetDoubleClickHdl( LINK( this, SpellDialog, ChangeHdl ) ); aSentenceED.SetModifyHdl(LINK ( this, SpellDialog, ModifyHdl) ); + aAddToDictMB.SetActivateHdl(LINK ( this, SpellDialog, MenuButtonActivateHdl ) ); aAddToDictMB.SetSelectHdl(LINK ( this, SpellDialog, AddToDictionaryHdl ) ); aLanguageLB.SetSelectHdl(LINK( this, SpellDialog, LanguageSelectHdl ) ); @@ -310,9 +314,6 @@ void SpellDialog::Init_Impl() // get current language UpdateBoxes_Impl(); - // fill dictionary PopupMenu - InitUserDicts(); - aSentenceED.ClearModifyFlag(); SvxGetChangeAllList()->clear(); } @@ -347,8 +348,11 @@ void SpellDialog::UpdateBoxes_Impl() } else SetTitle_Impl( nAltLanguage ); - SetSelectedLang_Impl( nAltLanguage ); + SetSelectedLang_Impl( nAltLanguage ); + + // Initialize/update user dictionaries after setting the language in the listbox + InitUserDicts(); // Alternativen eintragen const ::rtl::OUString *pNewWords = aNewWords.getConstArray(); @@ -853,6 +857,8 @@ IMPL_LINK(SpellDialog, LanguageSelectHdl aSentenceED.AddUndoAction(new SpellUndoAction_Impl(SPELLUNDO_CHANGE_LANGUAGE, aDialogUndoLink)); } + + // Update listboxes and user dictionaries when selected language changes SpellDialog::UpdateBoxes_Impl(); return 0; } @@ -930,34 +936,46 @@ void SpellDialog::SetTitle_Impl(Language -----------------------------------------------------------------------*/ void SpellDialog::InitUserDicts() { - const LanguageType nLang = aLanguageLB.GetSelectLanguage(); - - const Reference< XDictionary > *pDic = 0; + bool bEnable = false; // get list of dictionaries Reference< XDictionaryList > xDicList( SvxGetDictionaryList() ); if (xDicList.is()) { // add active, positive dictionary to dic-list (if not already done). - // This is to ensure that there is at least on dictionary to which + // This is to ensure that there is at least one dictionary to which // words could be added. Reference< XDictionary > xDic( SvxGetOrCreatePosDic( xDicList ) ); if (xDic.is()) xDic->setActive( sal_True ); pImpl->aDics = xDicList->getDictionaries(); + + // this is redundant, there will always be *at least* one dictionary + bEnable = pImpl->aDics.getLength(); } + aAddToDictMB.Enable( bEnable ); +} + +IMPL_LINK(SpellDialog, MenuButtonActivateHdl, MenuButton*, ) +{ + bool bEnable = false; + const LanguageType nLang = aLanguageLB.GetSelectLanguage(); + const Reference< XDictionary > *pDic = 0; + SvtLinguConfig aCfg; const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); // list suitable dictionaries - bool bEnable = false; const sal_Int32 nSize = pImpl->aDics.getLength(); pDic = pImpl->aDics.getConstArray(); - delete aAddToDictMB.GetPopupMenu(); - PopupMenu* pMenu = new PopupMenu; + + PopupMenu* pMenu = aAddToDictMB.GetPopupMenu(); + OSL_ENSURE( pMenu, "svx::SpellDialog::MenuButtonActivateHdl - no PopupMenu!" ); + pMenu->Clear(); pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); + sal_uInt16 nItemId = 1; // menu items should be enumerated from 1 and not 0 for (sal_Int32 i = 0; i < nSize; ++i) { @@ -990,9 +1008,12 @@ void SpellDialog::InitUserDicts() ++nItemId; } } - aAddToDictMB.SetPopupMenu(pMenu); + aAddToDictMB.Enable( bEnable ); + + return 0; } + /*-- 20.10.2003 15:31:06--------------------------------------------------- -----------------------------------------------------------------------*/ Modified: incubator/ooo/trunk/main/cui/source/inc/SpellDialog.hxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/cui/source/inc/SpellDialog.hxx?rev=1353272&r1=1353271&r2=1353272&view=diff ============================================================================== --- incubator/ooo/trunk/main/cui/source/inc/SpellDialog.hxx (original) +++ incubator/ooo/trunk/main/cui/source/inc/SpellDialog.hxx Sun Jun 24 14:20:49 2012 @@ -212,6 +212,7 @@ private: DECL_LINK( CancelHdl, Button * ); DECL_LINK( ModifyHdl, SentenceEditWindow_Impl *); DECL_LINK( UndoHdl, Button * ); + DECL_LINK( MenuButtonActivateHdl, MenuButton* ); DECL_LINK( AddToDictionaryHdl, MenuButton* ); DECL_LINK( LanguageSelectHdl, SvxLanguageBox* ); DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* );