LCOV - code coverage report
Current view: top level - framework/source/dispatch - dispatchinformationprovider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 73 9.6 %
Date: 2012-08-25 Functions: 6 9 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 167 4.8 %

           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 <dispatch/dispatchinformationprovider.hxx>
      30                 :            : #include <dispatch/closedispatcher.hxx>
      31                 :            : #include <threadhelp/readguard.hxx>
      32                 :            : #include <threadhelp/writeguard.hxx>
      33                 :            : #include <stdtypes.h>
      34                 :            : #include <services.h>
      35                 :            : 
      36                 :            : #include <com/sun/star/frame/CommandGroup.hpp>
      37                 :            : 
      38                 :            : #include <comphelper/sequenceasvector.hxx>
      39                 :            : 
      40                 :            : namespace framework{
      41                 :            : 
      42                 :            : namespace css = ::com::sun::star;
      43                 :            : 
      44 [ -  + ][ #  # ]:       8644 : DEFINE_XINTERFACE_1(DispatchInformationProvider                               ,
      45                 :            :                     OWeakObject                                               ,
      46                 :            :                     DIRECT_INTERFACE(css::frame::XDispatchInformationProvider))
      47                 :            : 
      48                 :            : //_________________________________________________________________________________________________________________
      49                 :       1747 : DispatchInformationProvider::DispatchInformationProvider(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
      50                 :            :                                                          const css::uno::Reference< css::frame::XFrame >&              xFrame)
      51         [ +  - ]:       1747 :     : ThreadHelpBase(&Application::GetSolarMutex())
      52                 :            :     , m_xSMGR       (xSMGR                        )
      53 [ +  - ][ +  - ]:       3494 :     , m_xFrame      (xFrame                       )
      54                 :            : {
      55                 :       1747 : }
      56                 :            : 
      57                 :            : //_________________________________________________________________________________________________________________
      58 [ +  - ][ +  - ]:       1656 : DispatchInformationProvider::~DispatchInformationProvider()
                 [ +  - ]
      59                 :            : {
      60         [ -  + ]:       3312 : }
      61                 :            : 
      62                 :            : //_________________________________________________________________________________________________________________
      63                 :          0 : css::uno::Sequence< sal_Int16 > SAL_CALL DispatchInformationProvider::getSupportedCommandGroups()
      64                 :            :     throw (css::uno::RuntimeException)
      65                 :            : {
      66         [ #  # ]:          0 :     css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider = implts_getAllSubProvider();
      67                 :          0 :     sal_Int32                                                                             c1        = lProvider.getLength();
      68                 :          0 :     sal_Int32                                                                             i1        = 0;
      69                 :            : 
      70         [ #  # ]:          0 :     ::comphelper::SequenceAsVector< sal_Int16 > lGroups;
      71                 :            : 
      72         [ #  # ]:          0 :     for (i1=0; i1<c1; ++i1)
      73                 :            :     {
      74                 :            :         // ignore controller, which doesnt implement the right interface
      75         [ #  # ]:          0 :         css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider = lProvider[i1];
      76         [ #  # ]:          0 :         if (!xProvider.is())
      77                 :          0 :             continue;
      78                 :            : 
      79 [ #  # ][ #  # ]:          0 :         const css::uno::Sequence< sal_Int16 > lProviderGroups = xProvider->getSupportedCommandGroups();
      80                 :          0 :               sal_Int32                       c2              = lProviderGroups.getLength();
      81                 :          0 :               sal_Int32                       i2              = 0;
      82         [ #  # ]:          0 :         for (i2=0; i2<c2; ++i2)
      83                 :            :         {
      84                 :          0 :             const sal_Int16&                                                  rGroup = lProviderGroups[i2];
      85 [ #  # ][ #  # ]:          0 :                   ::comphelper::SequenceAsVector< sal_Int16 >::const_iterator pGroup = ::std::find(lGroups.begin(), lGroups.end(), rGroup);
      86 [ #  # ][ #  # ]:          0 :             if (pGroup == lGroups.end())
      87         [ #  # ]:          0 :                 lGroups.push_back(rGroup);
      88                 :            :         }
      89 [ #  # ][ #  # ]:          0 :     }
      90                 :            : 
      91 [ #  # ][ #  # ]:          0 :     return lGroups.getAsConstList();
      92                 :            : }
      93                 :            : 
      94                 :            : //_________________________________________________________________________________________________________________
      95                 :          0 : css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL DispatchInformationProvider::getConfigurableDispatchInformation(sal_Int16 nCommandGroup)
      96                 :            :     throw (css::uno::RuntimeException)
      97                 :            : {
      98         [ #  # ]:          0 :     css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider = implts_getAllSubProvider();
      99                 :          0 :     sal_Int32                                                                             c1        = lProvider.getLength();
     100                 :          0 :     sal_Int32                                                                             i1        = 0;
     101                 :            : 
     102         [ #  # ]:          0 :     BaseHash< css::frame::DispatchInformation > lInfos;
     103                 :            : 
     104         [ #  # ]:          0 :     for (i1=0; i1<c1; ++i1)
     105                 :            :     {
     106                 :            :         try
     107                 :            :         {
     108                 :            :             // ignore controller, which doesnt implement the right interface
     109         [ #  # ]:          0 :             css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider = lProvider[i1];
     110         [ #  # ]:          0 :             if (!xProvider.is())
     111                 :          0 :                 continue;
     112                 :            : 
     113 [ #  # ][ #  # ]:          0 :             const css::uno::Sequence< css::frame::DispatchInformation > lProviderInfos = xProvider->getConfigurableDispatchInformation(nCommandGroup);
     114                 :          0 :                   sal_Int32                                             c2             = lProviderInfos.getLength();
     115                 :          0 :                   sal_Int32                                             i2             = 0;
     116         [ #  # ]:          0 :             for (i2=0; i2<c2; ++i2)
     117                 :            :             {
     118                 :          0 :                 const css::frame::DispatchInformation&                            rInfo = lProviderInfos[i2];
     119         [ #  # ]:          0 :                       BaseHash< css::frame::DispatchInformation >::const_iterator pInfo = lInfos.find(rInfo.Command);
     120 [ #  # ][ #  # ]:          0 :                 if (pInfo == lInfos.end())
     121         [ #  # ]:          0 :                     lInfos[rInfo.Command] = rInfo;
     122 [ #  # ][ #  # ]:          0 :             }
     123                 :            :         }
     124      [ #  #  # ]:          0 :         catch(const css::uno::RuntimeException&)
     125                 :          0 :             { throw; }
     126         [ #  # ]:          0 :         catch(const css::uno::Exception&)
     127                 :          0 :             { continue; }
     128                 :            :     }
     129                 :            : 
     130                 :          0 :     c1 = (sal_Int32)lInfos.size();
     131                 :          0 :     i1 = 0;
     132                 :            : 
     133         [ #  # ]:          0 :     css::uno::Sequence< css::frame::DispatchInformation >       lReturn(c1);
     134                 :          0 :     BaseHash< css::frame::DispatchInformation >::const_iterator pStepp ;
     135 [ #  # ][ #  # ]:          0 :     for (  pStepp  = lInfos.begin()          ;
         [ #  # ][ #  # ]
     136 [ #  # ][ #  # ]:          0 :            pStepp != lInfos.end  () && i1<c1 ;
                 [ #  # ]
           [ #  #  #  # ]
     137                 :            :          ++pStepp, ++i1                      )
     138                 :            :     {
     139 [ #  # ][ #  # ]:          0 :         lReturn[i1] = pStepp->second;
     140                 :            :     }
     141 [ #  # ][ #  # ]:          0 :     return lReturn;
     142                 :            : }
     143                 :            : 
     144                 :            : //_________________________________________________________________________________________________________________
     145                 :          0 : css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > DispatchInformationProvider::implts_getAllSubProvider()
     146                 :            : {
     147                 :            :     // SAFE -> ----------------------------------
     148         [ #  # ]:          0 :     ReadGuard aReadLock(m_aLock);
     149                 :          0 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
     150 [ #  # ][ #  # ]:          0 :     css::uno::Reference< css::frame::XFrame >              xFrame(m_xFrame.get(), css::uno::UNO_QUERY);
     151         [ #  # ]:          0 :     aReadLock.unlock();
     152                 :            :     // <- SAFE ----------------------------------
     153                 :            : 
     154         [ #  # ]:          0 :     if (!xFrame.is())
     155         [ #  # ]:          0 :         return css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > >();
     156                 :            : 
     157         [ #  # ]:          0 :     CloseDispatcher* pCloser = new CloseDispatcher(xSMGR, xFrame, ::rtl::OUString("_self")); // explicit "_self" ... not "" ... see implementation of close dispatcher itself!
     158 [ #  # ][ #  # ]:          0 :     css::uno::Reference< css::uno::XInterface > xCloser(static_cast< css::frame::XDispatch* >(pCloser), css::uno::UNO_QUERY);
     159                 :            : 
     160         [ #  # ]:          0 :     css::uno::Reference< css::frame::XDispatchInformationProvider > xCloseDispatch(xCloser                                                      , css::uno::UNO_QUERY);
     161 [ #  # ][ #  # ]:          0 :     css::uno::Reference< css::frame::XDispatchInformationProvider > xController   (xFrame->getController()                                      , css::uno::UNO_QUERY);
                 [ #  # ]
     162 [ #  # ][ #  # ]:          0 :     css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher(xSMGR->createInstance(IMPLEMENTATIONNAME_APPDISPATCHPROVIDER), css::uno::UNO_QUERY);
         [ #  # ][ #  # ]
     163                 :            : 
     164         [ #  # ]:          0 :     css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider(3);
     165 [ #  # ][ #  # ]:          0 :     lProvider[0] = xController   ;
     166 [ #  # ][ #  # ]:          0 :     lProvider[1] = xCloseDispatch;
     167 [ #  # ][ #  # ]:          0 :     lProvider[2] = xAppDispatcher;
     168                 :            : 
     169 [ #  # ][ #  # ]:          0 :     return lProvider;
                 [ #  # ]
     170                 :            : }
     171                 :            : 
     172                 :            : } // namespace framework
     173                 :            : 
     174                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10