LCOV - code coverage report
Current view: top level - svtools/source/misc - acceleratorexecute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 56 201 27.9 %
Date: 2012-08-25 Functions: 8 24 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 360 13.6 %

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

Generated by: LCOV version 1.10