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