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