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_svtools.hxx" 30*cdf0e10cSrcweir #include <svtools/acceleratorexecute.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir //=============================================== 33*cdf0e10cSrcweir // includes 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_FRAME_XMODULEMANAGER_HPP_ 36*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_FRAME_XDESKTOP_HPP_ 40*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_ 44*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp> 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_ 48*cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPPLIER_HPP_ 52*cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_AWT_XTOPWINDOW_HPP_ 56*cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp> 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_AWT_KEYMODIFIER_HPP_ 60*cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp> 61*cdf0e10cSrcweir #endif 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_UNO_SEQUENCE_HXX_ 64*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 68*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ 72*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 73*cdf0e10cSrcweir #endif 74*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #include <vcl/window.hxx> 77*cdf0e10cSrcweir #include <vcl/svapp.hxx> 78*cdf0e10cSrcweir #include <vos/mutex.hxx> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //=============================================== 81*cdf0e10cSrcweir // namespace 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir namespace css = ::com::sun::star; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir namespace svt 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //=============================================== 89*cdf0e10cSrcweir // definitions 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir //----------------------------------------------- 92*cdf0e10cSrcweir class SVT_DLLPRIVATE AsyncAccelExec 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir public: 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir //--------------------------------------- 97*cdf0e10cSrcweir /** creates a new instance of this class, which can be used 98*cdf0e10cSrcweir one times only! 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir This instance can be forced to execute it's internal set request 101*cdf0e10cSrcweir asynchronous. After that it deletes itself ! 102*cdf0e10cSrcweir */ 103*cdf0e10cSrcweir static AsyncAccelExec* createOnShotInstance(const css::uno::Reference< css::frame::XDispatch >& xDispatch, 104*cdf0e10cSrcweir const css::util::URL& aURL ); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void execAsync(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir private: 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //--------------------------------------- 111*cdf0e10cSrcweir /** @short allow creation of instances of this class 112*cdf0e10cSrcweir by using our factory only! 113*cdf0e10cSrcweir */ 114*cdf0e10cSrcweir SVT_DLLPRIVATE AsyncAccelExec(const css::uno::Reference< css::frame::XDispatch >& xDispatch, 115*cdf0e10cSrcweir const css::util::URL& aURL ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir DECL_DLLPRIVATE_LINK(impl_ts_asyncCallback, void*); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir private: 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir ::vcl::EventPoster m_aAsyncCallback; 122*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > m_xDispatch; 123*cdf0e10cSrcweir css::util::URL m_aURL; 124*cdf0e10cSrcweir }; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //----------------------------------------------- 127*cdf0e10cSrcweir AcceleratorExecute::AcceleratorExecute() 128*cdf0e10cSrcweir : TMutexInit ( ) 129*cdf0e10cSrcweir , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback)) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //----------------------------------------------- 134*cdf0e10cSrcweir AcceleratorExecute::AcceleratorExecute(const AcceleratorExecute&) 135*cdf0e10cSrcweir : TMutexInit ( ) 136*cdf0e10cSrcweir , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback)) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir // copy construction sint supported in real ... 139*cdf0e10cSrcweir // but we need this ctor to init our async callback ... 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir //----------------------------------------------- 143*cdf0e10cSrcweir AcceleratorExecute::~AcceleratorExecute() 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir // does nothing real 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir //----------------------------------------------- 149*cdf0e10cSrcweir AcceleratorExecute* AcceleratorExecute::createAcceleratorHelper() 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir AcceleratorExecute* pNew = new AcceleratorExecute(); 152*cdf0e10cSrcweir return pNew; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir //----------------------------------------------- 156*cdf0e10cSrcweir void AcceleratorExecute::init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR, 157*cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xEnv ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir // SAFE -> ---------------------------------- 160*cdf0e10cSrcweir ::osl::ResettableMutexGuard aLock(m_aLock); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // take over the uno service manager 163*cdf0e10cSrcweir m_xSMGR = xSMGR; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // specify our internal dispatch provider 166*cdf0e10cSrcweir // frame or desktop?! => document or global config. 167*cdf0e10cSrcweir sal_Bool bDesktopIsUsed = sal_False; 168*cdf0e10cSrcweir m_xDispatcher = css::uno::Reference< css::frame::XDispatchProvider >(xEnv, css::uno::UNO_QUERY); 169*cdf0e10cSrcweir if (!m_xDispatcher.is()) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir aLock.clear(); 172*cdf0e10cSrcweir // <- SAFE ------------------------------ 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProvider > xDispatcher( 175*cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), 176*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // SAFE -> ------------------------------ 179*cdf0e10cSrcweir aLock.reset(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir m_xDispatcher = xDispatcher; 182*cdf0e10cSrcweir bDesktopIsUsed = sal_True; 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir aLock.clear(); 186*cdf0e10cSrcweir // <- SAFE ---------------------------------- 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // open all needed configuration objects 189*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg; 190*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg; 191*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg ; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // global cfg 194*cdf0e10cSrcweir xGlobalCfg = AcceleratorExecute::st_openGlobalConfig(xSMGR); 195*cdf0e10cSrcweir if (!bDesktopIsUsed) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir // module cfg 198*cdf0e10cSrcweir xModuleCfg = AcceleratorExecute::st_openModuleConfig(xSMGR, xEnv); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir // doc cfg 201*cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController; 202*cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xModel; 203*cdf0e10cSrcweir xController = xEnv->getController(); 204*cdf0e10cSrcweir if (xController.is()) 205*cdf0e10cSrcweir xModel = xController->getModel(); 206*cdf0e10cSrcweir if (xModel.is()) 207*cdf0e10cSrcweir xDocCfg = AcceleratorExecute::st_openDocConfig(xModel); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir // SAFE -> ------------------------------ 211*cdf0e10cSrcweir aLock.reset(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir m_xGlobalCfg = xGlobalCfg; 214*cdf0e10cSrcweir m_xModuleCfg = xModuleCfg; 215*cdf0e10cSrcweir m_xDocCfg = xDocCfg ; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir aLock.clear(); 218*cdf0e10cSrcweir // <- SAFE ---------------------------------- 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir //----------------------------------------------- 222*cdf0e10cSrcweir sal_Bool AcceleratorExecute::execute(const KeyCode& aVCLKey) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir css::awt::KeyEvent aAWTKey = AcceleratorExecute::st_VCLKey2AWTKey(aVCLKey); 225*cdf0e10cSrcweir return execute(aAWTKey); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir //----------------------------------------------- 229*cdf0e10cSrcweir sal_Bool AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir ::rtl::OUString sCommand = impl_ts_findCommand(aAWTKey); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir // No Command found? Do nothing! User isnt interested on any error handling .-) 234*cdf0e10cSrcweir if (!sCommand.getLength()) 235*cdf0e10cSrcweir return sal_False; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir // SAFE -> ---------------------------------- 238*cdf0e10cSrcweir ::osl::ResettableMutexGuard aLock(m_aLock); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProvider > xProvider = m_xDispatcher; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir aLock.clear(); 243*cdf0e10cSrcweir // <- SAFE ---------------------------------- 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // convert command in URL structure 246*cdf0e10cSrcweir css::uno::Reference< css::util::XURLTransformer > xParser = impl_ts_getURLParser(); 247*cdf0e10cSrcweir css::util::URL aURL; 248*cdf0e10cSrcweir aURL.Complete = sCommand; 249*cdf0e10cSrcweir xParser->parseStrict(aURL); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir // ask for dispatch object 252*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, ::rtl::OUString(), 0); 253*cdf0e10cSrcweir sal_Bool bRet = xDispatch.is(); 254*cdf0e10cSrcweir if ( bRet ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir // Note: Such instance can be used one times only and destroy itself afterwards .-) 257*cdf0e10cSrcweir AsyncAccelExec* pExec = AsyncAccelExec::createOnShotInstance(xDispatch, aURL); 258*cdf0e10cSrcweir pExec->execAsync(); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir return bRet; 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir //----------------------------------------------- 265*cdf0e10cSrcweir css::awt::KeyEvent AcceleratorExecute::st_VCLKey2AWTKey(const KeyCode& aVCLKey) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir css::awt::KeyEvent aAWTKey; 268*cdf0e10cSrcweir aAWTKey.Modifiers = 0; 269*cdf0e10cSrcweir aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode(); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir if (aVCLKey.IsShift()) 272*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT; 273*cdf0e10cSrcweir if (aVCLKey.IsMod1()) 274*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1; 275*cdf0e10cSrcweir if (aVCLKey.IsMod2()) 276*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2; 277*cdf0e10cSrcweir if (aVCLKey.IsMod3()) 278*cdf0e10cSrcweir aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3; 279*cdf0e10cSrcweir return aAWTKey; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir //----------------------------------------------- 283*cdf0e10cSrcweir KeyCode AcceleratorExecute::st_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT ); 286*cdf0e10cSrcweir sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); 287*cdf0e10cSrcweir sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); 288*cdf0e10cSrcweir sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); 289*cdf0e10cSrcweir sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir return KeyCode(nKey, bShift, bMod1, bMod2, bMod3); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir //----------------------------------------------- 294*cdf0e10cSrcweir ::rtl::OUString AcceleratorExecute::findCommand(const css::awt::KeyEvent& aKey) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir return impl_ts_findCommand(aKey); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir //----------------------------------------------- 299*cdf0e10cSrcweir ::rtl::OUString AcceleratorExecute::impl_ts_findCommand(const css::awt::KeyEvent& aKey) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir // SAFE -> ---------------------------------- 302*cdf0e10cSrcweir ::osl::ResettableMutexGuard aLock(m_aLock); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg = m_xGlobalCfg; 305*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg = m_xModuleCfg; 306*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg = m_xDocCfg ; 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir aLock.clear(); 309*cdf0e10cSrcweir // <- SAFE ---------------------------------- 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir ::rtl::OUString sCommand; 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir try 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir if (xDocCfg.is()) 316*cdf0e10cSrcweir sCommand = xDocCfg->getCommandByKeyEvent(aKey); 317*cdf0e10cSrcweir if (sCommand.getLength()) 318*cdf0e10cSrcweir return sCommand; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir catch(const css::container::NoSuchElementException&) 321*cdf0e10cSrcweir {} 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir try 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if (xModuleCfg.is()) 326*cdf0e10cSrcweir sCommand = xModuleCfg->getCommandByKeyEvent(aKey); 327*cdf0e10cSrcweir if (sCommand.getLength()) 328*cdf0e10cSrcweir return sCommand; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir catch(const css::container::NoSuchElementException&) 331*cdf0e10cSrcweir {} 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir try 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir if (xGlobalCfg.is()) 336*cdf0e10cSrcweir sCommand = xGlobalCfg->getCommandByKeyEvent(aKey); 337*cdf0e10cSrcweir if (sCommand.getLength()) 338*cdf0e10cSrcweir return sCommand; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir catch(const css::container::NoSuchElementException&) 341*cdf0e10cSrcweir {} 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir // fall back to functional key codes 344*cdf0e10cSrcweir if( aKey.Modifiers == 0 ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir switch( aKey.KeyCode ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE: 349*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfLine" ) ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_TO_END_OF_LINE: 352*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfLine" ) ); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH: 355*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfPara" ) ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH: 358*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfPara" ) ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_WORD_BACKWARD: 361*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToStartOfWord" ) ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir case com::sun::star::awt::Key::DELETE_WORD_FORWARD: 364*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DelToEndOfWord" ) ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir case com::sun::star::awt::Key::INSERT_LINEBREAK: 367*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertLinebreak" ) ); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir case com::sun::star::awt::Key::INSERT_PARAGRAPH: 370*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPara" ) ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_WORD_BACKWARD: 373*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToPrevWord" ) ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_WORD_FORWARD: 376*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToNextWord" ) ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE: 379*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfLine" ) ); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE: 382*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfLine" ) ); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH: 385*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfPara" ) ); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH: 388*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfPara" ) ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT: 391*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfDoc" ) ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT: 394*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfDoc" ) ); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_BACKWARD: 397*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharLeftSel" ) ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_FORWARD: 400*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharRightSel" ) ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_WORD_BACKWARD: 403*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:WordLeftSel" ) ); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_WORD_FORWARD: 406*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:WordRightSel" ) ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_WORD: 409*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectWord" ) ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_LINE: 412*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_PARAGRAPH: 415*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectText" ) ); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE: 418*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfLineSel" ) ); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE: 421*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfLineSel" ) ); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH: 424*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfParaSel" ) ); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH: 427*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfParaSel" ) ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT: 430*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StartOfDocumentSel" ) ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT: 433*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:EndOfDocumentSel" ) ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir case com::sun::star::awt::Key::SELECT_ALL: 436*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SelectAll" ) ); 437*cdf0e10cSrcweir default: 438*cdf0e10cSrcweir break; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir return ::rtl::OUString(); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir //----------------------------------------------- 446*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openGlobalConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg( 449*cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration")), 450*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 451*cdf0e10cSrcweir return xAccCfg; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir //----------------------------------------------- 455*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openModuleConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , 456*cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xFrame) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir css::uno::Reference< css::frame::XModuleManager > xModuleDetection( 459*cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), 460*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir ::rtl::OUString sModule; 463*cdf0e10cSrcweir try 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir sModule = xModuleDetection->identify(xFrame); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir catch(const css::uno::RuntimeException&rEx) 468*cdf0e10cSrcweir { (void) rEx; throw; } 469*cdf0e10cSrcweir catch(const css::uno::Exception&) 470*cdf0e10cSrcweir { return css::uno::Reference< css::ui::XAcceleratorConfiguration >(); } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xUISupplier( 473*cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")), 474*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg; 477*cdf0e10cSrcweir try 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager(sModule); 480*cdf0e10cSrcweir xAccCfg = css::uno::Reference< css::ui::XAcceleratorConfiguration >(xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir catch(const css::container::NoSuchElementException&) 483*cdf0e10cSrcweir {} 484*cdf0e10cSrcweir return xAccCfg; 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir //----------------------------------------------- 488*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg; 491*cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xUISupplier(xModel, css::uno::UNO_QUERY); 492*cdf0e10cSrcweir if (xUISupplier.is()) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager(); 495*cdf0e10cSrcweir xAccCfg.set(xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir return xAccCfg; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir //----------------------------------------------- 501*cdf0e10cSrcweir css::uno::Reference< css::util::XURLTransformer > AcceleratorExecute::impl_ts_getURLParser() 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir // SAFE -> ---------------------------------- 504*cdf0e10cSrcweir ::osl::ResettableMutexGuard aLock(m_aLock); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir if (m_xURLParser.is()) 507*cdf0e10cSrcweir return m_xURLParser; 508*cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir aLock.clear(); 511*cdf0e10cSrcweir // <- SAFE ---------------------------------- 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir css::uno::Reference< css::util::XURLTransformer > xParser( 514*cdf0e10cSrcweir xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), 515*cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir // SAFE -> ---------------------------------- 518*cdf0e10cSrcweir aLock.reset(); 519*cdf0e10cSrcweir m_xURLParser = xParser; 520*cdf0e10cSrcweir aLock.clear(); 521*cdf0e10cSrcweir // <- SAFE ---------------------------------- 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir return xParser; 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir //----------------------------------------------- 527*cdf0e10cSrcweir IMPL_LINK(AcceleratorExecute, impl_ts_asyncCallback, void*, EMPTYARG) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir // replaced by AsyncAccelExec! 530*cdf0e10cSrcweir return 0; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir //----------------------------------------------- 534*cdf0e10cSrcweir AsyncAccelExec::AsyncAccelExec(const css::uno::Reference< css::frame::XDispatch >& xDispatch, 535*cdf0e10cSrcweir const css::util::URL& aURL ) 536*cdf0e10cSrcweir : m_aAsyncCallback(LINK(this, AsyncAccelExec, impl_ts_asyncCallback)) 537*cdf0e10cSrcweir , m_xDispatch (xDispatch ) 538*cdf0e10cSrcweir , m_aURL (aURL ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir //----------------------------------------------- 543*cdf0e10cSrcweir AsyncAccelExec* AsyncAccelExec::createOnShotInstance(const css::uno::Reference< css::frame::XDispatch >& xDispatch, 544*cdf0e10cSrcweir const css::util::URL& aURL ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir AsyncAccelExec* pExec = new AsyncAccelExec(xDispatch, aURL); 547*cdf0e10cSrcweir return pExec; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir //----------------------------------------------- 551*cdf0e10cSrcweir void AsyncAccelExec::execAsync() 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir m_aAsyncCallback.Post(0); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir //----------------------------------------------- 557*cdf0e10cSrcweir IMPL_LINK(AsyncAccelExec, impl_ts_asyncCallback, void*,) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir if (! m_xDispatch.is()) 560*cdf0e10cSrcweir return 0; 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir try 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir m_xDispatch->dispatch(m_aURL, css::uno::Sequence< css::beans::PropertyValue >()); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir catch(const css::lang::DisposedException&) 567*cdf0e10cSrcweir {} 568*cdf0e10cSrcweir catch(const css::uno::RuntimeException& ) 569*cdf0e10cSrcweir { throw; } 570*cdf0e10cSrcweir catch(const css::uno::Exception&) 571*cdf0e10cSrcweir {} 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir delete this; 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir return 0; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir } // namespace svt 579