From 5d6a605a698239638e0a1282e3e99a704b7f3654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 17 Feb 2017 13:39:24 +0000 Subject: [PATCH] convert editeng spell menu to .ui format Change-Id: Iaae8e6d6ee3c9cafad343fefb4f357b080df3a08 --- Repository.mk | 1 + editeng/Module_editeng.mk | 1 + editeng/UIConfig_editeng.mk | 16 +++++++ editeng/inc/editeng.hrc | 11 +---- editeng/inc/helpid.hrc | 4 -- editeng/source/editeng/editeng.src | 49 ------------------- editeng/source/editeng/editview.cxx | 32 ++++++++----- editeng/uiconfig/ui/spellmenu.ui | 74 +++++++++++++++++++++++++++++ include/editeng/editrids.hrc | 2 +- 9 files changed, 115 insertions(+), 75 deletions(-) create mode 100644 editeng/UIConfig_editeng.mk create mode 100644 editeng/uiconfig/ui/spellmenu.ui diff --git a/Repository.mk b/Repository.mk index e612fc714a33..227274737f87 100644 --- a/Repository.mk +++ b/Repository.mk @@ -1105,6 +1105,7 @@ $(eval $(call gb_Helper_register_uiconfigs,\ cui \ $(call gb_Helper_optional,DBCONNECTIVITY,dbaccess) \ desktop \ + editeng \ filter \ formula \ fps \ diff --git a/editeng/Module_editeng.mk b/editeng/Module_editeng.mk index f48dde947341..4bed89d70b1b 100644 --- a/editeng/Module_editeng.mk +++ b/editeng/Module_editeng.mk @@ -26,6 +26,7 @@ $(eval $(call gb_Module_add_targets,editeng,\ $(eval $(call gb_Module_add_l10n_targets,editeng,\ AllLangResTarget_editeng \ + UIConfig_editeng \ )) $(eval $(call gb_Module_add_check_targets,editeng,\ diff --git a/editeng/UIConfig_editeng.mk b/editeng/UIConfig_editeng.mk new file mode 100644 index 000000000000..dbe62f5b2ce3 --- /dev/null +++ b/editeng/UIConfig_editeng.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_UIConfig_UIConfig,editeng)) + +$(eval $(call gb_UIConfig_add_uifiles,editeng,\ + editeng/uiconfig/ui/spellmenu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/editeng/inc/editeng.hrc b/editeng/inc/editeng.hrc index e4b00b478937..18c62082623e 100644 --- a/editeng/inc/editeng.hrc +++ b/editeng/inc/editeng.hrc @@ -21,15 +21,8 @@ #include -#define MN_SPELLING 1 -#define MN_INSERT 2 -#define MN_IGNORE 3 -#define MN_AUTOCORR 4 -#define MN_WORDLANGUAGE 5 -#define MN_PARALANGUAGE 6 -#define MN_INSERT_SINGLE 7 -#define MN_AUTO_CORRECT_DLG 8 - +#define MN_WORDLANGUAGE 998 +#define MN_PARALANGUAGE 999 #define MN_ALTSTART 1000 #define MN_AUTOSTART 2000 #define MN_DICTSTART 3000 diff --git a/editeng/inc/helpid.hrc b/editeng/inc/helpid.hrc index 60bba79f1c71..018a50f8e164 100644 --- a/editeng/inc/helpid.hrc +++ b/editeng/inc/helpid.hrc @@ -21,10 +21,6 @@ #define HID_EDITENG_SPELLER_WORDLANGUAGE "EDITENG_HID_EDITENG_SPELLER_WORDLANGUAGE" #define HID_EDITENG_SPELLER_PARALANGUAGE "EDITENG_HID_EDITENG_SPELLER_PARALANGUAGE" -#define HID_EDITENG_SPELLER_ADDWORD "EDITENG_HID_EDITENG_SPELLER_ADDWORD" -#define HID_EDITENG_SPELLER_AUTOCORRECT "EDITENG_HID_EDITENG_SPELLER_AUTOCORRECT" -#define HID_EDITENG_SPELLER_IGNORE "EDITENG_HID_EDITENG_SPELLER_IGNORE" -#define HID_EDITENG_SPELLER_START "EDITENG_HID_EDITENG_SPELLER_START" #endif diff --git a/editeng/source/editeng/editeng.src b/editeng/source/editeng/editeng.src index 36d92102ab3e..7d49a54f8fb8 100644 --- a/editeng/source/editeng/editeng.src +++ b/editeng/source/editeng/editeng.src @@ -65,55 +65,6 @@ String RID_EDITUNDO_TRANSLITERATE Text [ en-US ] = "Change Case"; }; -Menu RID_MENU_SPELL -{ - ItemList = - { - MenuItem - { - Identifier = MN_IGNORE ; - HelpId = HID_EDITENG_SPELLER_IGNORE; - Text [ en-US ] = "I~gnore All" ; - }; - MenuItem - { - Identifier = MN_INSERT ; - HelpId = HID_EDITENG_SPELLER_ADDWORD; - SubMenu = Menu - { - }; - Text [ en-US ] = "~Add to Dictionary" ; - }; - MenuItem - { - Identifier = MN_INSERT_SINGLE ; - HelpId = HID_EDITENG_SPELLER_ADDWORD; - Text [ en-US ] = "~Add to Dictionary" ; - }; - MenuItem - { - Identifier = MN_SPELLING ; - HelpId = HID_EDITENG_SPELLER_START; - Text [ en-US ] = "~Spellcheck..." ; - }; - MenuItem { Separator = TRUE ; }; - MenuItem - { - Identifier = MN_AUTOCORR ; - HelpId = HID_EDITENG_SPELLER_AUTOCORRECT; - SubMenu = Menu - { - }; - Text [ en-US ] = "AutoCorrect ~To" ; - }; - MenuItem - { - Identifier = MN_AUTO_CORRECT_DLG ; - Text [ en-US ] = "Auto~Correct Options..." ; - }; - }; -}; - String RID_STR_WORD { Text [ en-US ] = "Word is %x"; diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 75774fb5ff29..4f72ae7bfcb0 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -817,10 +817,17 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkIsWrongSpelledWord( aPaM, true ) ) { - ScopedVclPtrInstance aPopupMenu( EditResId( RID_MENU_SPELL ) ); - PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu( MN_AUTOCORR ); - PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu( MN_INSERT ); // add word to user-dictionaries + VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", ""); + VclPtr aPopupMenu(aBuilder.get_menu("menu")); + const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect"); + PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId); + const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert"); + PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId); // add word to user-dictionaries pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics ); //! necessary to retrieve the correct dictionary names later + const sal_uInt16 nAddId = aPopupMenu->GetItemId("add"); + const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore"); + const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check"); + const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg"); EditPaM aPaM2( aPaM ); aPaM2.SetIndex( aPaM2.GetIndex()+1 ); @@ -910,7 +917,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkInsertSeparator(OString(), nWords); } else - aPopupMenu->RemoveItem( MN_AUTOCORR ); // delete? + aPopupMenu->RemoveItem(nAutoCorrId); // delete? SvtLinguConfig aCfg; @@ -963,10 +970,11 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkGetItemCount() != 1) - aPopupMenu->EnableItem( MN_INSERT_SINGLE, false ); - if ( pInsertMenu->GetItemCount() < 2 ) - aPopupMenu->EnableItem( MN_INSERT, false ); + + if (pInsertMenu->GetItemCount() != 1) + aPopupMenu->EnableItem(nAddId, false); + if (pInsertMenu->GetItemCount() < 2) + aPopupMenu->EnableItem(nInsertId, false); aPopupMenu->RemoveDisabledEntries( true, true ); @@ -976,7 +984,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkGetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() )); sal_uInt16 nId = aPopupMenu->Execute( pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose ); - if ( nId == MN_IGNORE ) + if (nId == nIgnoreId) { OUString aWord = pImpEditView->SpellIgnoreWord(); if ( pCallBack ) @@ -1015,7 +1023,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, LinkCall( aInf ); } } - else if ( nId == MN_AUTO_CORRECT_DLG && pCallBack) + else if (nId == nAutoCorrectDlgId && pCallBack) { SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() ); pCallBack->Call( aInf ); } - else if ( nId >= MN_DICTSTART || nId == MN_INSERT_SINGLE ) + else if ( nId >= MN_DICTSTART || nId == nAddId) { OUString aDicName; if (nId >= MN_DICTSTART) diff --git a/editeng/uiconfig/ui/spellmenu.ui b/editeng/uiconfig/ui/spellmenu.ui new file mode 100644 index 000000000000..365de28b512f --- /dev/null +++ b/editeng/uiconfig/ui/spellmenu.ui @@ -0,0 +1,74 @@ + + + + + + True + False + + + True + False + I_gnore All + + + + + True + False + _Add to Dictionary + True + + + True + False + + + + + + + True + False + _Add to Dictionary + True + + + + + True + False + _Spellcheck... + True + + + + + True + False + + + + + True + False + AutoCorrect _To + True + + + True + False + + + + + + + True + False + Auto_Correct Options... + True + + + + diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc index cff44d40c234..5a1defad9816 100644 --- a/include/editeng/editrids.hrc +++ b/include/editeng/editrids.hrc @@ -358,7 +358,7 @@ #define RID_EDITUNDO_RESETATTRIBS (RID_EDIT_START + 308) #define RID_EDITUNDO_INDENT (RID_EDIT_START + 309) #define RID_EDITUNDO_TRANSLITERATE (RID_EDIT_START + 310) -#define RID_MENU_SPELL (RID_EDIT_START + 311) +//free #define RID_STR_PARAGRAPH (RID_EDIT_START + 312) #define RID_STR_WORD (RID_EDIT_START + 313) #define RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION (RID_EDIT_START + 314)