framework/source/uielement/langselectionstatusbarcontroller.cxx | 27 ++-------- 1 file changed, 6 insertions(+), 21 deletions(-)
New commits: commit 2e43a18a1585694cc3ff9d8e5b250f9c98b7719e Author: Henry Castro <hcas...@collabora.com> Date: Tue Nov 28 14:44:37 2017 -0400 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 <c...@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits