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