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