summaryrefslogtreecommitdiff
path: root/sw/source/uibase/lingu
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-24 16:40:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-24 20:52:41 +0000
commit51d5cb5de245245fc7a3498cf87743d33eede525 (patch)
treed304fbe5708c1967f5ddec7aea5ef6294b046329 /sw/source/uibase/lingu
parent49e6d5e49673011149c94788a86cf899a54a8085 (diff)
convert spell menu to .ui
Change-Id: I96a4b852fd396883385d5e2d43728dc8c2b20ce3
Diffstat (limited to 'sw/source/uibase/lingu')
-rw-r--r--sw/source/uibase/lingu/olmenu.cxx113
-rw-r--r--sw/source/uibase/lingu/olmenu.hrc9
-rw-r--r--sw/source/uibase/lingu/olmenu.src90
3 files changed, 78 insertions, 134 deletions
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 2932585ab6c3..39a52d85399b 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -259,7 +259,20 @@ SwSpellPopup::SwSpellPopup(
SwWrtShell* pWrtSh,
const uno::Reference< linguistic2::XSpellAlternatives > &xAlt,
const OUString &rParaText)
- : m_xPopupMenu( SW_RES(MN_SPELL_POPUP) )
+ : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
+ , m_xPopupMenu(m_aBuilder.get_menu("menu"))
+ , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
+ , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
+ , m_nAddId(m_xPopupMenu->GetItemId("add"))
+ , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
+ , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
+ , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
+ , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
+ , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
+ , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
+ , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
+ , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
+ , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
, m_pSh( pWrtSh )
, m_xSpellAlt(xAlt)
, m_nGrammarError(0)
@@ -280,7 +293,7 @@ SwSpellPopup::SwSpellPopup(
SvtLinguConfig aCfg;
- PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(MN_AUTOCORR);
+ PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nCorrectMenuId);
pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
bool bEnable = false;
if( nStringCount )
@@ -320,13 +333,13 @@ SwSpellPopup::SwSpellPopup(
OUString aIgnoreSelection( SW_RES( STR_IGNORE_SELECTION ) );
OUString aSpellingAndGrammar = RetrieveLabelFromCommand( ".uno:SpellingAndGrammarDialog" );
- m_xPopupMenu->SetItemText(MN_SPELLING_DLG, aSpellingAndGrammar);
- m_xPopupMenu->SetItemText(MN_AUTO_CORRECT_DLG, RetrieveLabelFromCommand(".uno:AutoCorrectDlg"));
- sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos( MN_IGNORE_WORD );
+ m_xPopupMenu->SetItemText(m_nSpellDialogId, aSpellingAndGrammar);
+ m_xPopupMenu->SetItemText(m_nCorrectDialogId, RetrieveLabelFromCommand(".uno:AutoCorrectDlg"));
+ sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
m_xPopupMenu->SetHelpId(MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
- m_xPopupMenu->EnableItem(MN_AUTOCORR, bEnable);
+ m_xPopupMenu->EnableItem(m_nCorrectMenuId, bEnable);
uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
m_nGuessLangWord = LANGUAGE_NONE;
@@ -345,7 +358,7 @@ SwSpellPopup::SwSpellPopup(
m_nGuessLangPara = m_nGuessLangWord;
}
- pMenu = m_xPopupMenu->GetPopupMenu(MN_ADD_TO_DIC);
+ pMenu = m_xPopupMenu->GetPopupMenu(m_nAddMenuId);
pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); //! necessary to retrieve the correct dictionary name in 'Execute' below
uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
sal_uInt16 nItemId = MN_DICTIONARIES_START;
@@ -399,8 +412,8 @@ SwSpellPopup::SwSpellPopup(
}
}
}
- m_xPopupMenu->EnableItem(MN_ADD_TO_DIC, (nItemId - MN_DICTIONARIES_START) > 1);
- m_xPopupMenu->EnableItem(MN_ADD_TO_DIC_SINGLE, (nItemId - MN_DICTIONARIES_START) == 1);
+ m_xPopupMenu->EnableItem(m_nAddMenuId, (nItemId - MN_DICTIONARIES_START) > 1);
+ m_xPopupMenu->EnableItem(m_nAddId, (nItemId - MN_DICTIONARIES_START) == 1);
//ADD NEW LANGUAGE MENU ITEM
@@ -426,19 +439,19 @@ SwSpellPopup::SwSpellPopup(
aSeq[2] = aKeyboardLang;
aSeq[3] = SvtLanguageTable::GetLanguageString(m_nGuessLangWord);
- pMenu = m_xPopupMenu->GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
+ pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, m_aLangTable_Text );
- m_xPopupMenu->EnableItem(MN_SET_LANGUAGE_SELECTION);
+ m_xPopupMenu->EnableItem(m_nLangSelectionMenuId);
- pMenu = m_xPopupMenu->GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
+ pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, m_aLangTable_Paragraph );
- m_xPopupMenu->EnableItem(MN_SET_LANGUAGE_PARAGRAPH);
+ m_xPopupMenu->EnableItem(m_nLangParaMenuId);
if (bUseImagesInMenus)
{
uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
Image rImg = ::GetImage( xFrame, ".uno:SpellingAndGrammarDialog", false );
- m_xPopupMenu->SetItemImage( MN_SPELLING_DLG, rImg );
+ m_xPopupMenu->SetItemImage(m_nSpellDialogId, rImg);
}
checkRedline();
@@ -451,7 +464,20 @@ SwSpellPopup::SwSpellPopup(
sal_Int32 nErrorInResult,
const uno::Sequence< OUString > &rSuggestions,
const OUString &rParaText )
- : m_xPopupMenu(SW_RES(MN_SPELL_POPUP))
+ : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
+ , m_xPopupMenu(m_aBuilder.get_menu("menu"))
+ , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
+ , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
+ , m_nAddId(m_xPopupMenu->GetItemId("add"))
+ , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
+ , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
+ , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
+ , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
+ , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
+ , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
+ , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
+ , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
+ , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
, m_pSh(pWrtSh)
, m_xGrammarResult(rResult)
, m_aSuggestions(rSuggestions)
@@ -524,13 +550,13 @@ SwSpellPopup::SwSpellPopup(
OUString aIgnoreSelection( SW_RES( STR_IGNORE_SELECTION ) );
OUString aSpellingAndGrammar = RetrieveLabelFromCommand( ".uno:SpellingAndGrammarDialog" );
- m_xPopupMenu->SetItemText(MN_SPELLING_DLG, aSpellingAndGrammar);
- sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(MN_IGNORE_WORD);
+ m_xPopupMenu->SetItemText(m_nSpellDialogId, aSpellingAndGrammar);
+ sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
m_xPopupMenu->SetHelpId(MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
- m_xPopupMenu->EnableItem(MN_AUTOCORR, false);
- m_xPopupMenu->EnableItem(MN_AUTO_CORRECT_DLG, false);
+ m_xPopupMenu->EnableItem(m_nCorrectMenuId, false);
+ m_xPopupMenu->EnableItem(m_nCorrectDialogId, false);
uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
m_nGuessLangWord = LANGUAGE_NONE;
@@ -548,8 +574,8 @@ SwSpellPopup::SwSpellPopup(
m_nGuessLangPara = m_nGuessLangWord;
}
- m_xPopupMenu->EnableItem(MN_ADD_TO_DIC, false);
- m_xPopupMenu->EnableItem(MN_ADD_TO_DIC_SINGLE, false);
+ m_xPopupMenu->EnableItem(m_nAddMenuId, false);
+ m_xPopupMenu->EnableItem(m_nAddId, false);
//ADD NEW LANGUAGE MENU ITEM
@@ -575,19 +601,19 @@ SwSpellPopup::SwSpellPopup(
aSeq[2] = aKeyboardLang;
aSeq[3] = SvtLanguageTable::GetLanguageString(m_nGuessLangWord);
- PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
+ PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, m_aLangTable_Text );
- m_xPopupMenu->EnableItem( MN_SET_LANGUAGE_SELECTION );
+ m_xPopupMenu->EnableItem(m_nLangSelectionMenuId);
- pMenu = m_xPopupMenu->GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
+ pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, m_aLangTable_Paragraph );
- m_xPopupMenu->EnableItem(MN_SET_LANGUAGE_PARAGRAPH);
+ m_xPopupMenu->EnableItem(m_nLangParaMenuId);
if (bUseImagesInMenus)
{
uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
Image rImg = ::GetImage( xFrame, ".uno:SpellingAndGrammarDialog", false );
- m_xPopupMenu->SetItemImage(MN_SPELLING_DLG, rImg);
+ m_xPopupMenu->SetItemImage(m_nSpellDialogId, rImg);
}
checkRedline();
@@ -621,11 +647,20 @@ void SwSpellPopup::checkRedline()
// cleared or not.
for (sal_uInt16 nWhich : pRedlineIds)
{
- m_xPopupMenu->EnableItem(nWhich, aSet.Get(nWhich).Which());
+ sal_uInt16 nId(0);
+ if (nWhich == FN_REDLINE_ACCEPT_DIRECT)
+ nId = m_nRedlineAcceptId;
+ else if (nWhich == FN_REDLINE_REJECT_DIRECT)
+ nId = m_nRedlineRejectId;
+ else if (nWhich == FN_REDLINE_NEXT_CHANGE)
+ nId = m_nRedlineNextId;
+ else if (nWhich == FN_REDLINE_PREV_CHANGE)
+ nId = m_nRedlinePrevId;
+ m_xPopupMenu->EnableItem(nId, aSet.Get(nWhich).Which());
}
}
-void SwSpellPopup::Execute( const Rectangle& rWordPos, vcl::Window* pWin )
+void SwSpellPopup::Execute( const Rectangle& rWordPos, vcl::Window* pWin )
{
sal_uInt16 nRet = m_xPopupMenu->Execute(pWin, pWin->LogicToPixel(rWordPos));
Execute( nRet );
@@ -701,7 +736,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
m_pSh->SetInsMode( bOldIns );
}
}
- else if (nId == MN_SPELLING_DLG)
+ else if (nId == m_nSpellDialogId)
{
if (m_bGrammarResults)
{
@@ -715,7 +750,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON );
}
}
- else if (nId == MN_AUTO_CORRECT_DLG)
+ else if (nId == m_nCorrectDialogId)
{
m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
}
@@ -725,7 +760,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
if (pPaM)
SwEditShell::IgnoreGrammarErrorAt( *pPaM );
}
- else if (nId == MN_IGNORE_WORD)
+ else if (nId == m_nIgnoreWordId)
{
uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY );
if (m_bGrammarResults) {
@@ -755,14 +790,14 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
}
}
- else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == MN_ADD_TO_DIC_SINGLE)
+ else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId)
{
OUString sWord( m_xSpellAlt->getWord() );
OUString aDicName;
if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
{
- PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(MN_ADD_TO_DIC);
+ PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nAddMenuId);
aDicName = pMenu->GetItemText(nId);
}
else
@@ -806,9 +841,17 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
aErrorBox->Execute();
}
}
- else if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT
- || nId == FN_REDLINE_NEXT_CHANGE || nId == FN_REDLINE_PREV_CHANGE)
+ else if (nId == m_nRedlineAcceptId || nId == m_nRedlineRejectId
+ || nId == m_nRedlineNextId || nId == m_nRedlinePrevId)
{
+ if (nId == m_nRedlineAcceptId)
+ nId = FN_REDLINE_ACCEPT_DIRECT;
+ else if (nId == m_nRedlineRejectId)
+ nId = FN_REDLINE_REJECT_DIRECT;
+ else if (nId == m_nRedlineNextId)
+ nId = FN_REDLINE_NEXT_CHANGE;
+ else if (nId == m_nRedlinePrevId)
+ nId = FN_REDLINE_PREV_CHANGE;
// Let SwView::Execute() handle the redline actions.
SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
m_pSh->GetView().Execute(aReq);
diff --git a/sw/source/uibase/lingu/olmenu.hrc b/sw/source/uibase/lingu/olmenu.hrc
index a0cd367a54cf..e10626918d07 100644
--- a/sw/source/uibase/lingu/olmenu.hrc
+++ b/sw/source/uibase/lingu/olmenu.hrc
@@ -22,7 +22,6 @@
#include "rcid.hrc"
-#define MN_SPELL_POPUP (RC_LINGU_BEGIN + 1)
#define STR_SPELL_OK (RC_LINGU_BEGIN + 2)
#define STR_HYP_OK (RC_LINGU_BEGIN + 3)
#define STR_WORD (RC_LINGU_BEGIN + 4)
@@ -36,17 +35,9 @@
#define BMP_INFO_16 (RC_LINGU_BEGIN + 100)
//! Don't change these values. You may break context menu modifying extensions!
-#define MN_SPELLING_DLG 200
#define MN_IGNORE_SELECTION 201
-#define MN_IGNORE_WORD 202
-#define MN_ADD_TO_DIC 203
-#define MN_AUTOCORR 204
-#define MN_SET_LANGUAGE_SELECTION 205
-#define MN_SET_LANGUAGE_PARAGRAPH 206
#define MN_SHORT_COMMENT 208
#define MN_EXPLANATION_LINK 209
-#define MN_ADD_TO_DIC_SINGLE 210
-#define MN_AUTO_CORRECT_DLG 211
// id range for dictionaries sub menu
#define MN_DICTIONARIES_START 300
diff --git a/sw/source/uibase/lingu/olmenu.src b/sw/source/uibase/lingu/olmenu.src
index 53ec2b402398..9dc16ca78b1f 100644
--- a/sw/source/uibase/lingu/olmenu.src
+++ b/sw/source/uibase/lingu/olmenu.src
@@ -22,96 +22,6 @@
#include "cmdid.h"
#include "helpid.h"
-#define SEPARATOR MenuItem { Separator = TRUE; };
-
-Menu MN_SPELL_POPUP
-{
- ItemList =
- {
- MenuItem
- {
- Identifier = MN_IGNORE_WORD ;
- HelpID = HID_LINGU_IGNORE_WORD ;
- Text [ en-US ] = "I~gnore All" ;
- };
- MenuItem
- {
- Identifier = MN_ADD_TO_DIC ;
- HelpID = HID_LINGU_ADD_WORD ;
- SubMenu = Menu
- {
- };
- Text [ en-US ] = "~Add to Dictionary" ;
- };
- MenuItem
- {
- Identifier = MN_ADD_TO_DIC_SINGLE ;
- HelpID = HID_LINGU_ADD_WORD ;
- Text [ en-US ] = "~Add to Dictionary" ;
- };
- MenuItem
- {
- Identifier = MN_SPELLING_DLG ;
- HelpID = HID_LINGU_SPELLING_DLG ;
- };
- SEPARATOR
- MenuItem
- {
- Identifier = MN_AUTOCORR ;
- HelpID = HID_LINGU_AUTOCORR ;
- SubMenu = Menu
- {
- };
- Text [ en-US ] = "Always correct ~to" ;
- };
- MenuItem
- {
- Identifier = MN_AUTO_CORRECT_DLG ;
- };
- SEPARATOR
- MenuItem
- {
- Identifier = MN_SET_LANGUAGE_SELECTION ;
- SubMenu = Menu
- {
- };
- Text [ en-US ] = "Set Language for Selection" ;
- };
- MenuItem
- {
- Identifier = MN_SET_LANGUAGE_PARAGRAPH ;
- SubMenu = Menu
- {
- };
- Text [ en-US ] = "Set Language for Paragraph" ;
- };
- SEPARATOR
- MenuItem
- {
- Identifier = FN_REDLINE_ACCEPT_DIRECT;
- HelpId = CMD_FN_REDLINE_ACCEPT_DIRECT ;
- Text [ en-US ] = "Accept Change" ;
- };
- MenuItem
- {
- Identifier = FN_REDLINE_REJECT_DIRECT ;
- HelpId = CMD_FN_REDLINE_REJECT_DIRECT ;
- Text [ en-US ] = "Reject Change" ;
- };
- MenuItem
- {
- Identifier = FN_REDLINE_NEXT_CHANGE;
- HelpId = CMD_FN_REDLINE_NEXT_CHANGE ;
- Text [ en-US ] = "Next Change" ;
- };
- MenuItem
- {
- Identifier = FN_REDLINE_PREV_CHANGE;
- HelpId = CMD_FN_REDLINE_PREV_CHANGE ;
- Text [ en-US ] = "Previous Change" ;
- };
- };
-};
String STR_WORD
{
Text [ en-US ] = "Word is " ;