LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/misc - acceleratorexecute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 194 0.0 %
Date: 2012-12-27 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10