[PATCH] fd0#40778 - Remove dictionary choice when adding new entry
Rob Snelders
programming at ertai.nl
Thu May 17 07:50:34 PDT 2012
Change-Id: Ieaaf2466474463d19f91c74ea7f164962ba19936
---
sw/source/ui/inc/olmenu.hxx | 1 +
sw/source/ui/lingu/olmenu.cxx | 21 ++++++++++++++-------
sw/source/ui/lingu/olmenu.hrc | 1 +
sw/source/ui/lingu/olmenu.src | 6 ++++++
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/sw/source/ui/inc/olmenu.hxx b/sw/source/ui/inc/olmenu.hxx
index d0d45b7..3da80f3 100644
--- a/sw/source/ui/inc/olmenu.hxx
+++ b/sw/source/ui/inc/olmenu.hxx
@@ -62,6 +62,7 @@ class SwSpellPopup : public PopupMenu
std::map< sal_Int16, ::rtl::OUString > aLangTable_Paragraph;
// std::map< sal_Int16, ::rtl::OUString > aLangTable_Document;
+ String aDicNameSingle;
bool bGrammarResults; // show grammar results? Or show spellcheck results?
Image aInfo16;
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index 6abb921..1d53314 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -460,8 +460,8 @@ SwSpellPopup::SwSpellPopup(
pMenu = GetPopupMenu(MN_ADD_TO_DIC);
pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); //! necessary to retrieve the correct dictionary name in 'Execute' below
- bEnable = sal_False; // enable MN_ADD_TO_DIC?
uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() );
+ sal_uInt16 nItemId = MN_DICTIONARIES_START;
if (xDicList.is())
{
// add the default positive dictionary to dic-list (if not already done).
@@ -475,7 +475,6 @@ SwSpellPopup::SwSpellPopup(
const uno::Reference< linguistic2::XDictionary > *pDic = aDics.getConstArray();
sal_uInt16 nDicCount = static_cast< sal_uInt16 >(aDics.getLength());
- sal_uInt16 nItemId = MN_DICTIONARIES_START;
for( sal_uInt16 i = 0; i < nDicCount; i++ )
{
uno::Reference< linguistic2::XDictionary > xDicTmp( pDic[i], uno::UNO_QUERY );
@@ -492,7 +491,7 @@ SwSpellPopup::SwSpellPopup(
// the extra 1 is because of the (possible) external
// linguistic entry above
pMenu->InsertItem( nItemId, xDicTmp->getName() );
- bEnable = sal_True;
+ aDicNameSingle = xDicTmp->getName();
uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
if (xSvcInfo.is())
@@ -510,7 +509,8 @@ SwSpellPopup::SwSpellPopup(
}
}
}
- EnableItem( MN_ADD_TO_DIC, bEnable );
+ EnableItem( MN_ADD_TO_DIC, ((nItemId - MN_DICTIONARIES_START) > 1)?sal_True:sal_False );
+ EnableItem( MN_ADD_TO_DIC_SINGLE, ((nItemId - MN_DICTIONARIES_START) == 1)?sal_True:sal_False );
//ADD NEW LANGUAGE MENU ITEM
///////////////////////////////////////////////////////////////////////////
@@ -656,6 +656,7 @@ aInfo16( SW_RES(IMG_INFO_16) )
EnableItem( MN_IGNORE_WORD, false );
EnableItem( MN_ADD_TO_DIC, false );
+ EnableItem( MN_ADD_TO_DIC_SINGLE, false );
//ADD NEW LANGUAGE MENU ITEM
///////////////////////////////////////////////////////////////////////////
@@ -807,12 +808,18 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
linguistic::AddEntryToDic( xDictionary,
xSpellAlt->getWord(), sal_False, aEmptyStr, LANGUAGE_NONE );
}
- else if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
+ else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == MN_ADD_TO_DIC_SINGLE)
{
OUString aWord( xSpellAlt->getWord() );
+ String aDicName;
- PopupMenu *pMenu = GetPopupMenu(MN_ADD_TO_DIC);
- String aDicName ( pMenu->GetItemText(nId) );
+ if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
+ {
+ PopupMenu *pMenu = GetPopupMenu(MN_ADD_TO_DIC);
+ aDicName = pMenu->GetItemText(nId);
+ }
+ else
+ aDicName = aDicNameSingle;
uno::Reference< linguistic2::XDictionary > xDic;
uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() );
diff --git a/sw/source/ui/lingu/olmenu.hrc b/sw/source/ui/lingu/olmenu.hrc
index 1d65bbf..73fbac0 100644
--- a/sw/source/ui/lingu/olmenu.hrc
+++ b/sw/source/ui/lingu/olmenu.hrc
@@ -54,6 +54,7 @@
#define MN_SET_LANGUAGE_ALL_TEXT 207
#define MN_SHORT_COMMENT 208
#define MN_EXPLANATION_LINK 209
+#define MN_ADD_TO_DIC_SINGLE 210
// id range for dictionaries sub menu
#define MN_DICTIONARIES_START 300
diff --git a/sw/source/ui/lingu/olmenu.src b/sw/source/ui/lingu/olmenu.src
index 5b2d8b7..581bc1d 100644
--- a/sw/source/ui/lingu/olmenu.src
+++ b/sw/source/ui/lingu/olmenu.src
@@ -53,6 +53,12 @@ Menu MN_SPELL_POPUP
};
MenuItem
{
+ Identifier = MN_ADD_TO_DIC_SINGLE ;
+ HelpID = HID_LINGU_ADD_WORD ;
+ Text [ en-US ] = "~Add" ;
+ };
+ MenuItem
+ {
Identifier = MN_AUTOCORR ;
HelpID = HID_LINGU_AUTOCORR ;
SubMenu = Menu
--
1.7.5.4
--------------000302030808070706030606
Content-Type: text/x-patch;
name="0002-fd0-40778-Remove-dictionary-choice-when-adding-new-e.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0002-fd0-40778-Remove-dictionary-choice-when-adding-new-e.pa";
filename*1="tch"
More information about the LibreOffice
mailing list