LCOV - code coverage report
Current view: top level - sw/source/uibase/uno - unomodule.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 10 57 17.5 %
Date: 2014-11-03 Functions: 5 14 35.7 %
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 <com/sun/star/lang/XMultiServiceFactory.hpp>
      21             : #include <com/sun/star/frame/DispatchResultState.hpp>
      22             : 
      23             : #include "swmodule.hxx"
      24             : #include "swdll.hxx"
      25             : #include "unofreg.hxx"
      26             : #include "unomodule.hxx"
      27             : #include <cppuhelper/supportsservice.hxx>
      28             : #include <sfx2/objface.hxx>
      29             : #include <sfx2/bindings.hxx>
      30             : #include <sfx2/request.hxx>
      31             : #include <osl/mutex.hxx>
      32             : #include <vcl/svapp.hxx>
      33             : 
      34             : using namespace css;
      35             : 
      36           8 : OUString SAL_CALL SwUnoModule_getImplementationName() throw()
      37             : {
      38           8 :     return OUString( "com.sun.star.comp.Writer.WriterModule" );
      39             : }
      40             : 
      41           2 : uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw()
      42             : {
      43           2 :     uno::Sequence< OUString > aSeq( 1 );
      44           2 :     aSeq[0] = "com.sun.star.text.ModuleDispatcher";
      45           2 :     return aSeq;
      46             : }
      47             : 
      48           2 : uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance(
      49             :                 const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
      50             :     throw (css::uno::Exception)
      51             : {
      52           2 :     SolarMutexGuard aGuard;
      53           2 :     return uno::Reference< uno::XInterface >( dynamic_cast< frame::XDispatch * >(new SwUnoModule( rSMgr )), uno::UNO_QUERY );
      54             : }
      55             : 
      56             :     // XNotifyingDispatch
      57           0 : void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener ) throw (uno::RuntimeException, std::exception)
      58             : {
      59             :     // there is no guarantee, that we are holded alive during this method!
      60             :     // May the outside dispatch container will be updated by a CONTEXT_CHANGED
      61             :     // asynchronous ...
      62           0 :     uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
      63             : 
      64           0 :     SolarMutexGuard aGuard;
      65           0 :     SwGlobals::ensure();
      66           0 :     const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
      67             : 
      68           0 :     sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
      69           0 :     if ( !pSlot )
      70           0 :         aState = frame::DispatchResultState::FAILURE;
      71             :     else
      72             :     {
      73           0 :         SfxRequest aReq( pSlot, aArgs, SfxCallMode::SYNCHRON, SW_MOD()->GetPool() );
      74           0 :         const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq );
      75           0 :         if ( pResult )
      76           0 :             aState = frame::DispatchResultState::SUCCESS;
      77             :         else
      78           0 :             aState = frame::DispatchResultState::FAILURE;
      79             :     }
      80             : 
      81           0 :     if ( xListener.is() )
      82             :     {
      83           0 :         xListener->dispatchFinished(
      84             :             frame::DispatchResultEvent(
      85           0 :                     xThis, aState, uno::Any()));
      86           0 :     }
      87           0 : }
      88             : 
      89             :     // XDispatch
      90           0 : void SAL_CALL SwUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException, std::exception )
      91             : {
      92           0 :     dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
      93           0 : }
      94             : 
      95           0 : void SAL_CALL SwUnoModule::addStatusListener(
      96             :     const uno::Reference< frame::XStatusListener > & /*xControl*/,
      97             :     const util::URL& /*aURL*/)
      98             :     throw( uno::RuntimeException, std::exception )
      99             : {
     100           0 : }
     101             : 
     102           0 : void SAL_CALL SwUnoModule::removeStatusListener(
     103             :     const uno::Reference< frame::XStatusListener > & /*xControl*/,
     104             :     const util::URL& /*aURL*/) throw( uno::RuntimeException, std::exception )
     105             : {
     106           0 : }
     107             : 
     108           0 : uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SwUnoModule::queryDispatches(
     109             :     const uno::Sequence< frame::DispatchDescriptor >& seqDescripts ) throw( uno::RuntimeException, std::exception )
     110             : {
     111           0 :     sal_Int32 nCount = seqDescripts.getLength();
     112           0 :     uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
     113             : 
     114           0 :     for( sal_Int32 i=0; i<nCount; ++i )
     115             :     {
     116           0 :         lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL  ,
     117           0 :                                         seqDescripts[i].FrameName   ,
     118           0 :                                         seqDescripts[i].SearchFlags );
     119             :     }
     120             : 
     121           0 :     return lDispatcher;
     122             : }
     123             : 
     124             : // XDispatchProvider
     125           0 : uno::Reference< frame::XDispatch > SAL_CALL SwUnoModule::queryDispatch(
     126             :     const util::URL& aURL, const OUString& /*sTargetFrameName*/,
     127             :     sal_Int32 /*eSearchFlags*/    ) throw( uno::RuntimeException, std::exception )
     128             : {
     129           0 :     uno::Reference< frame::XDispatch > xReturn;
     130             : 
     131           0 :     SolarMutexGuard aGuard;
     132           0 :     SwGlobals::ensure();
     133           0 :     const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
     134           0 :     if ( pSlot )
     135           0 :         xReturn = uno::Reference< frame::XDispatch >(static_cast< frame::XDispatch* >(this), uno::UNO_QUERY);
     136             : 
     137           0 :     return xReturn;
     138             : }
     139             : 
     140             : // XServiceInfo
     141           0 : OUString SAL_CALL SwUnoModule::getImplementationName(  ) throw(uno::RuntimeException, std::exception)
     142             : {
     143           0 :     return SwUnoModule_getImplementationName();
     144             : }
     145             : 
     146           0 : sal_Bool SAL_CALL SwUnoModule::supportsService( const OUString& sServiceName ) throw(uno::RuntimeException, std::exception)
     147             : {
     148           0 :     return cppu::supportsService(this, sServiceName);
     149             : }
     150             : 
     151           0 : uno::Sequence< OUString > SAL_CALL SwUnoModule::getSupportedServiceNames(  ) throw(uno::RuntimeException, std::exception)
     152             : {
     153           0 :     return SwUnoModule_getSupportedServiceNames();
     154         270 : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10