1*6d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6d739b60SAndrew Rist * distributed with this work for additional information 6*6d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6d739b60SAndrew Rist * "License"); you may not use this file except in compliance 9*6d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10*6d739b60SAndrew Rist * 11*6d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6d739b60SAndrew Rist * 13*6d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6d739b60SAndrew Rist * software distributed under the License is distributed on an 15*6d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6d739b60SAndrew Rist * KIND, either express or implied. See the License for the 17*6d739b60SAndrew Rist * specific language governing permissions and limitations 18*6d739b60SAndrew Rist * under the License. 19*6d739b60SAndrew Rist * 20*6d739b60SAndrew Rist *************************************************************/ 21*6d739b60SAndrew Rist 22*6d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <uielement/langselectionstatusbarcontroller.hxx> 28cdf0e10cSrcweir #include <classes/fwkresid.hxx> 29cdf0e10cSrcweir #include <services.h> 30cdf0e10cSrcweir #include <classes/resource.hrc> 31cdf0e10cSrcweir #include <vos/mutex.hxx> 32cdf0e10cSrcweir #include <vcl/svapp.hxx> 33cdf0e10cSrcweir #include <vcl/window.hxx> 34cdf0e10cSrcweir #include <vcl/status.hxx> 35cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 36cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <com/sun/star/frame/XPopupMenuController.hpp> 41cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 42cdf0e10cSrcweir #include <com/sun/star/awt/PopupMenuDirection.hpp> 43cdf0e10cSrcweir #include <svtools/langtab.hxx> 44cdf0e10cSrcweir #include "sal/types.h" 45cdf0e10cSrcweir #include <vcl/svapp.hxx> 46cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp> 47cdf0e10cSrcweir #include <com/sun/star/document/XDocumentLanguages.hpp> 48cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 49cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 50cdf0e10cSrcweir #include <com/sun/star/frame/XModule.hpp> 51cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <classes/fwkresid.hxx> 54cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_ 55cdf0e10cSrcweir #include <classes/resource.hrc> 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 58cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 59cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 60cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 61cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 62cdf0e10cSrcweir 63cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 64cdf0e10cSrcweir #include <tools/gen.hxx> 65cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp> 66cdf0e10cSrcweir #include <svl/languageoptions.hxx> 67cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLanguageGuessing.hpp> 68cdf0e10cSrcweir #include <dispatch/uieventloghelper.hxx> 69cdf0e10cSrcweir 70cdf0e10cSrcweir #include "helper/mischelper.hxx" 71cdf0e10cSrcweir 72cdf0e10cSrcweir #include <map> 73cdf0e10cSrcweir #include <set> 74cdf0e10cSrcweir 75cdf0e10cSrcweir using namespace ::cppu; 76cdf0e10cSrcweir using namespace ::com::sun::star; 77cdf0e10cSrcweir using namespace ::com::sun::star::uno; 78cdf0e10cSrcweir using namespace ::com::sun::star::lang; 79cdf0e10cSrcweir using namespace ::com::sun::star::frame; 80cdf0e10cSrcweir using namespace ::com::sun::star::i18n; 81cdf0e10cSrcweir using namespace ::com::sun::star::document; 82cdf0e10cSrcweir 83cdf0e10cSrcweir using ::rtl::OUString; 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir namespace framework 87cdf0e10cSrcweir { 88cdf0e10cSrcweir 89cdf0e10cSrcweir //////////////////////////////////////////////////////////// 90cdf0e10cSrcweir 91cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController , 92cdf0e10cSrcweir OWeakObject , 93cdf0e10cSrcweir SERVICENAME_STATUSBARCONTROLLER , 94cdf0e10cSrcweir IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER 95cdf0e10cSrcweir ) 96cdf0e10cSrcweir 97cdf0e10cSrcweir DEFINE_INIT_SERVICE ( LangSelectionStatusbarController, {} ) 98cdf0e10cSrcweir 99cdf0e10cSrcweir LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : 100cdf0e10cSrcweir svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ), 101cdf0e10cSrcweir m_bShowMenu( sal_True ), 102cdf0e10cSrcweir m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ), 103cdf0e10cSrcweir m_aLangGuessHelper( xServiceManager ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XInterface 108cdf0e10cSrcweir Any SAL_CALL LangSelectionStatusbarController::queryInterface( const Type& rType ) 109cdf0e10cSrcweir throw ( RuntimeException ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir return svt::StatusbarController::queryInterface( rType ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::acquire() throw () 115cdf0e10cSrcweir { 116cdf0e10cSrcweir svt::StatusbarController::acquire(); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::release() throw () 120cdf0e10cSrcweir { 121cdf0e10cSrcweir svt::StatusbarController::release(); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 125cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::initialize" ); 128cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir svt::StatusbarController::initialize( aArguments ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir if ( m_xParentWindow.is() && m_nID > 0 ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); 135cdf0e10cSrcweir if ( pWindow && ( pWindow->GetType() == WINDOW_STATUSBAR )) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir StatusBar* pStatusBar = (StatusBar *)pWindow; 138cdf0e10cSrcweir pStatusBar->SetItemText( m_nID, FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir // XComponent 144cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::dispose() 145cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::dispose" ); 148cdf0e10cSrcweir svt::StatusbarController::dispose(); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir // XEventListener 152cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::disposing( const com::sun::star::lang::EventObject& Source ) 153cdf0e10cSrcweir throw ( RuntimeException ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::disposing" ); 156cdf0e10cSrcweir svt::StatusbarController::disposing( Source ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir // XStatusbarController 160cdf0e10cSrcweir ::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseButtonDown( 161cdf0e10cSrcweir const ::com::sun::star::awt::MouseEvent& ) 162cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonDown" ); 165cdf0e10cSrcweir return sal_False; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir ::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseMove( 169cdf0e10cSrcweir const ::com::sun::star::awt::MouseEvent& ) 170cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseMove" ); 173cdf0e10cSrcweir return sal_False; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir ::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseButtonUp( 177cdf0e10cSrcweir const ::com::sun::star::awt::MouseEvent& ) 178cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonUp" ); 181cdf0e10cSrcweir return sal_False; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir void LangSelectionStatusbarController::LangMenu() 185cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" ); 188cdf0e10cSrcweir if (!m_bShowMenu) 189cdf0e10cSrcweir return; 190cdf0e10cSrcweir 191cdf0e10cSrcweir //add context menu 192cdf0e10cSrcweir const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu")); 193cdf0e10cSrcweir Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); 194cdf0e10cSrcweir //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph 195cdf0e10cSrcweir Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); 196cdf0e10cSrcweir 197cdf0e10cSrcweir SvtLanguageTable aLanguageTable; 198cdf0e10cSrcweir 199cdf0e10cSrcweir // get languages to be displayed in the menu 200cdf0e10cSrcweir std::set< OUString > aLangItems; 201cdf0e10cSrcweir FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper, 202cdf0e10cSrcweir m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir // 205cdf0e10cSrcweir // add first few entries to main menu 206cdf0e10cSrcweir // 207cdf0e10cSrcweir sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1); 208cdf0e10cSrcweir const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection 209cdf0e10cSrcweir const OUString sEmpty; // 'no language found' from language guessing 210cdf0e10cSrcweir std::map< sal_Int16, OUString > aLangMap; 211cdf0e10cSrcweir std::set< OUString >::const_iterator it; 212cdf0e10cSrcweir for (it = aLangItems.begin(); it != aLangItems.end(); ++it) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir const OUString & rStr( *it ); 215cdf0e10cSrcweir if ( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) ) && 216cdf0e10cSrcweir rStr != sAsterix && 217cdf0e10cSrcweir rStr != sEmpty) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9, 220cdf0e10cSrcweir "nItemId outside of expected range!" ); 221cdf0e10cSrcweir xPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); 222cdf0e10cSrcweir if ( rStr == m_aCurLang ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir //make a sign for the current language 225cdf0e10cSrcweir xPopupMenu->checkItem( nItemId, sal_True ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir aLangMap[ nItemId ] = rStr; 228cdf0e10cSrcweir ++nItemId; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir xPopupMenu->insertItem( MID_LANG_SEL_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_NONE ); 232cdf0e10cSrcweir xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_RESET ); 233cdf0e10cSrcweir xPopupMenu->insertItem( MID_LANG_SEL_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_MORE ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir // 236cdf0e10cSrcweir // add entries to submenu ('set language for paragraph') 237cdf0e10cSrcweir // 238cdf0e10cSrcweir nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1); 239cdf0e10cSrcweir for (it = aLangItems.begin(); it != aLangItems.end(); ++it) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir const OUString & rStr( *it ); 242cdf0e10cSrcweir if( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&& 243cdf0e10cSrcweir rStr != sAsterix && 244cdf0e10cSrcweir rStr != sEmpty) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir DBG_ASSERT( MID_LANG_PARA_1 <= nItemId && nItemId <= MID_LANG_PARA_9, 247cdf0e10cSrcweir "nItemId outside of expected range!" ); 248cdf0e10cSrcweir subPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); 249cdf0e10cSrcweir aLangMap[nItemId] = rStr; 250cdf0e10cSrcweir ++nItemId; 251cdf0e10cSrcweir } 252cdf0e10cSrcweir } 253cdf0e10cSrcweir subPopupMenu->insertItem( MID_LANG_PARA_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_NONE ); 254cdf0e10cSrcweir subPopupMenu->insertItem( MID_LANG_PARA_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_RESET ); 255cdf0e10cSrcweir subPopupMenu->insertItem( MID_LANG_PARA_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_MORE ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir // 258cdf0e10cSrcweir // add last two entries to main menu 259cdf0e10cSrcweir // 260cdf0e10cSrcweir xPopupMenu->insertSeparator( MID_LANG_PARA_SEPERATOR ); 261cdf0e10cSrcweir xPopupMenu->insertItem( MID_LANG_PARA_STRING, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_STRING ); 262cdf0e10cSrcweir xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir 265cdf0e10cSrcweir // 266cdf0e10cSrcweir // now display the popup menu and execute every command ... 267cdf0e10cSrcweir // 268cdf0e10cSrcweir 269cdf0e10cSrcweir Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY ); 270cdf0e10cSrcweir 271cdf0e10cSrcweir com::sun::star::awt::Rectangle aRectangle; 272cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); 273cdf0e10cSrcweir const Point mMousePos = pWindow->GetPointerPosPixel(); 274cdf0e10cSrcweir aRectangle.X = mMousePos.X(); 275cdf0e10cSrcweir aRectangle.Y = mMousePos.Y(); 276cdf0e10cSrcweir sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); 277cdf0e10cSrcweir //click "More..." 278cdf0e10cSrcweir if ( nId && m_xFrame.is() ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); 281cdf0e10cSrcweir util::URL aURL; 282cdf0e10cSrcweir 283cdf0e10cSrcweir if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir //set selected language as current language for selection 286cdf0e10cSrcweir String aSelectedLang = aLangMap[nId]; 287cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_"); 288cdf0e10cSrcweir aURL.Complete += aSelectedLang; 289cdf0e10cSrcweir } 290cdf0e10cSrcweir else if (nId == MID_LANG_SEL_NONE) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir //set None as current language for selection 293cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE"); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir else if (nId == MID_LANG_SEL_RESET) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir // reset language attributes for selection 298cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES"); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir else if (nId == MID_LANG_SEL_MORE) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir //open the dialog "format/character" for current selection 303cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:FontDialog?Language:string=*"); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir //set selected language for current paragraph 308cdf0e10cSrcweir String aSelectedLang = aLangMap[nId]; 309cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_"); 310cdf0e10cSrcweir aURL.Complete += aSelectedLang; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir else if (nId == MID_LANG_PARA_NONE) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir //set None as language for current paragraph 315cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE"); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir else if (nId == MID_LANG_PARA_RESET) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir // reset language attributes for paragraph 320cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES"); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir else if (nId == MID_LANG_PARA_MORE) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir //open the dialog "format/character" for current paragraph 325cdf0e10cSrcweir aURL.Complete += OUString::createFromAscii(".uno:FontDialogForParagraph"); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir uno::Reference< util::XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY ); 329cdf0e10cSrcweir xURLTransformer->parseStrict( aURL ); 330cdf0e10cSrcweir uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, OUString(), 0); 331cdf0e10cSrcweir if( xDispatch.is() ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPV; 334cdf0e10cSrcweir if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# 335cdf0e10cSrcweir UiEventLogHelper( OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aURL, aPV); 336cdf0e10cSrcweir xDispatch->dispatch( aURL, aPV); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir } 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::command( 342cdf0e10cSrcweir const ::com::sun::star::awt::Point& /*aPos*/, 343cdf0e10cSrcweir ::sal_Int32 nCommand, 344cdf0e10cSrcweir ::sal_Bool /*bMouseEvent*/, 345cdf0e10cSrcweir const ::com::sun::star::uno::Any& /*aData*/ ) 346cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::command" ); 349cdf0e10cSrcweir if ( nCommand & ::awt::Command::CONTEXTMENU ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir LangMenu(); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::paint( 356cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics, 357cdf0e10cSrcweir const ::com::sun::star::awt::Rectangle& rOutputRectangle, 358cdf0e10cSrcweir ::sal_Int32 nItemId, 359cdf0e10cSrcweir ::sal_Int32 nStyle ) 360cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::paint" ); 363cdf0e10cSrcweir svt::StatusbarController::paint( xGraphics, rOutputRectangle, nItemId, nStyle ); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::click() 367cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::click" ); 370cdf0e10cSrcweir LangMenu(); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::doubleClick() 374cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::doubleClick" ); 377cdf0e10cSrcweir svt::StatusbarController::doubleClick(); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir // XStatusListener 381cdf0e10cSrcweir void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event ) 382cdf0e10cSrcweir throw ( RuntimeException ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir // This function will be called when observed data changes, 385cdf0e10cSrcweir // for example the selection or keyboard language. 386cdf0e10cSrcweir // - It displays the language in use in the status bar 387cdf0e10cSrcweir // - and it stores the relevant data for creating the menu 388cdf0e10cSrcweir // at some later point in the member variables 389cdf0e10cSrcweir // m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText 390cdf0e10cSrcweir 391cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" ); 392cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 393cdf0e10cSrcweir 394cdf0e10cSrcweir if ( m_bDisposed ) 395cdf0e10cSrcweir return; 396cdf0e10cSrcweir 397cdf0e10cSrcweir m_bShowMenu = sal_True; 398cdf0e10cSrcweir 399cdf0e10cSrcweir m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value 400cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); 401cdf0e10cSrcweir if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir OUString aStrValue; 404cdf0e10cSrcweir Sequence< OUString > aSeq; 405cdf0e10cSrcweir 406cdf0e10cSrcweir StatusBar* pStatusBar = (StatusBar *)pWindow; 407cdf0e10cSrcweir if ( Event.State >>= aStrValue ) 408cdf0e10cSrcweir pStatusBar->SetItemText( m_nID, aStrValue ); 409cdf0e10cSrcweir else if ( Event.State >>= aSeq ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir if ( aSeq.getLength() == 4 ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir const String aMultipleLangText( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ); 414cdf0e10cSrcweir OUString aStatusText = aSeq[0]; 415cdf0e10cSrcweir if ( 0 == aStatusText.compareToAscii( "*" )) 416cdf0e10cSrcweir aStatusText = aMultipleLangText; 417cdf0e10cSrcweir pStatusBar->SetItemText( m_nID, aStatusText ); 418cdf0e10cSrcweir 419cdf0e10cSrcweir // Retrieve all other values from the sequence and 420cdf0e10cSrcweir // store it members! 421cdf0e10cSrcweir m_aCurLang = aSeq[0]; 422cdf0e10cSrcweir m_nScriptType = static_cast< sal_Int16 >( aSeq[1].toInt32() ); 423cdf0e10cSrcweir m_aKeyboardLang = aSeq[2]; 424cdf0e10cSrcweir m_aGuessedTextLang = aSeq[3]; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir } 427cdf0e10cSrcweir else if ( !Event.State.hasValue() ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir pStatusBar->SetItemText( m_nID, String() ); 430cdf0e10cSrcweir m_bShowMenu = sal_False; // no language -> no menu 431cdf0e10cSrcweir } 432cdf0e10cSrcweir } 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437