diff options
author | Henry Castro <hcastro@collabora.com> | 2017-11-28 14:44:37 -0400 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2017-11-29 14:57:09 +0100 |
commit | 2e43a18a1585694cc3ff9d8e5b250f9c98b7719e (patch) | |
tree | 2600c50b22faab16450b75381f1c162dd8921a6f | |
parent | af8242b4e35faaa84c23ef1f3f4b34d279e90813 (diff) |
related tdf#113911: better statement to identify Writer app
Also remove duplicate code that I forgot from my drafts
Thanks for help Maxim Monastirsky
Change-Id: If9e26dfd6702f167c831296f0280ae5fe955a8a9
Reviewed-on: https://gerrit.libreoffice.org/45435
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r-- | framework/source/uielement/langselectionstatusbarcontroller.cxx | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 1cc23a8c1006..625436d4cd2b 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -34,6 +34,7 @@ #include <sal/types.h> #include <com/sun/star/awt/MenuItemStyle.hpp> #include <com/sun/star/document/XDocumentLanguages.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/frame/ModuleManager.hpp> #include <i18nlangtag/mslangid.hxx> #include <com/sun/star/i18n/ScriptType.hpp> @@ -128,7 +129,8 @@ void LangSelectionStatusbarController::LangMenu( if (!m_bShowMenu) return; - const Reference<XModuleManager> xModuleManager = ModuleManager::create( m_xContext ); + const Reference<XServiceInfo> xService(m_xFrame->getController()->getModel(), UNO_QUERY); + bool bWriter = xService.is() && xService->supportsService("com.sun.star.text.GenericTextDocument"); //add context menu Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph @@ -165,8 +167,7 @@ void LangSelectionStatusbarController::LangMenu( } } - - if (xModuleManager->identify(m_xFrame) == "com.sun.star.text.TextDocument") + if (bWriter) { xPopupMenu->insertItem( MID_LANG_SEL_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_SEL_NONE ); if ( sNone == m_aCurLang ) @@ -184,23 +185,6 @@ void LangSelectionStatusbarController::LangMenu( !rStr.isEmpty()) // 'no language found' from language guessing { SAL_WARN_IF( MID_LANG_PARA_1 > nItemId || nItemId > MID_LANG_PARA_9, - "fwk.uielement", "nItemId outside of expected range!" ); - subPopupMenu->insertItem( nItemId, rStr, 0, nItemId ); - aLangMap[nItemId] = rStr; - ++nItemId; - } - } - - // add entries to submenu ('set language for paragraph') - nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1); - for (it = aLangItems.begin(); it != aLangItems.end(); ++it) - { - const OUString & rStr( *it ); - if( rStr != sNone && - rStr != sAsterisk && - !rStr.isEmpty()) // 'no language found' from language guessing - { - SAL_WARN_IF( MID_LANG_PARA_1 > nItemId || nItemId > MID_LANG_PARA_9, "fwk.uielement", "nItemId outside of expected range!" ); subPopupMenu->insertItem( nItemId, rStr, 0, nItemId ); aLangMap[nItemId] = rStr; @@ -239,10 +223,11 @@ void LangSelectionStatusbarController::LangMenu( if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9) { - if ( xModuleManager->identify(m_xFrame) == "com.sun.star.text.TextDocument" ) + if (bWriter) aBuff.append( ".uno:LanguageStatus?Language:string=Current_" ); else aBuff.append( ".uno:LanguageStatus?Language:string=Default_" ); + aBuff.append( aSelectedLang ); } else if (nId == MID_LANG_SEL_NONE) |