incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arie...@apache.org
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 GMT
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* );



Mime
View raw message