LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - unomodule.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 53 18.9 %
Date: 2015-06-13 12:38:46 Functions: 3 10 30.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 <com/sun/star/lang/XMultiServiceFactory.hpp>
      21             : #include <com/sun/star/frame/DispatchResultState.hpp>
      22             : #include <cppuhelper/supportsservice.hxx>
      23             : 
      24             : #include "facreg.hxx"
      25             : #include "sddll.hxx"
      26             : #include "sdmod.hxx"
      27             : #include "unomodule.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 ::com::sun::star;
      35             : 
      36             :     // XNotifyingDispatch
      37           0 : void SAL_CALL SdUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener )
      38             :     throw (uno::RuntimeException, std::exception)
      39             : {
      40             :     // there is no guarantee, that we are holded alive during this method!
      41             :     // May the outside dispatch container will be updated by a CONTEXT_CHANGED
      42             :     // asynchronous ...
      43           0 :     uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
      44             : 
      45           0 :     SolarMutexGuard aGuard;
      46           0 :     SdDLL::Init();
      47           0 :     const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
      48             : 
      49           0 :     sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
      50           0 :     if ( !pSlot )
      51           0 :         aState = frame::DispatchResultState::FAILURE;
      52             :     else
      53             :     {
      54           0 :         SfxRequest aReq( pSlot, aArgs, SfxCallMode::SYNCHRON, SD_MOD()->GetPool() );
      55           0 :         const SfxPoolItem* pResult = SD_MOD()->ExecuteSlot( aReq );
      56           0 :         if ( pResult )
      57           0 :             aState = frame::DispatchResultState::SUCCESS;
      58             :         else
      59           0 :             aState = frame::DispatchResultState::FAILURE;
      60             :     }
      61             : 
      62           0 :     if ( xListener.is() )
      63             :     {
      64           0 :         xListener->dispatchFinished(
      65             :             frame::DispatchResultEvent(
      66           0 :                     xThis, aState, uno::Any()));
      67           0 :     }
      68           0 : }
      69             :     // XDispatch
      70           0 : void SAL_CALL SdUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException, std::exception )
      71             : {
      72           0 :     dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
      73           0 : }
      74             : 
      75           0 : void SAL_CALL SdUnoModule::addStatusListener(const uno::Reference< frame::XStatusListener > &, const util::URL&) throw( uno::RuntimeException, std::exception )
      76             : {
      77           0 : }
      78             : 
      79           0 : void SAL_CALL SdUnoModule::removeStatusListener(const uno::Reference< frame::XStatusListener > &, const util::URL&) throw( uno::RuntimeException, std::exception )
      80             : {
      81           0 : }
      82             : 
      83           0 : uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SdUnoModule::queryDispatches( const uno::Sequence< frame::DispatchDescriptor >& seqDescripts ) throw( uno::RuntimeException, std::exception )
      84             : {
      85           0 :     sal_Int32 nCount = seqDescripts.getLength();
      86           0 :     uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
      87             : 
      88           0 :     for( sal_Int32 i=0; i<nCount; ++i )
      89             :     {
      90           0 :         lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL  ,
      91           0 :                                         seqDescripts[i].FrameName   ,
      92           0 :                                         seqDescripts[i].SearchFlags );
      93             :     }
      94             : 
      95           0 :     return lDispatcher;
      96             : }
      97             : 
      98             : // XDispatchProvider
      99           0 : uno::Reference< frame::XDispatch > SAL_CALL SdUnoModule::queryDispatch( const util::URL& aURL, const OUString&, sal_Int32 )
     100             :     throw (uno::RuntimeException, std::exception)
     101             : {
     102           0 :     SolarMutexGuard aGuard;
     103           0 :     SdDLL::Init();
     104           0 :     const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
     105             : 
     106           0 :     uno::Reference< frame::XDispatch > xSlot;
     107           0 :     if ( pSlot )
     108           0 :         xSlot = this;
     109             : 
     110           0 :     return xSlot;
     111             : }
     112             : 
     113             : // XServiceInfo
     114           1 : OUString SAL_CALL SdUnoModule::getImplementationName(  ) throw(uno::RuntimeException, std::exception)
     115             : {
     116           1 :     return OUString( "com.sun.star.comp.Draw.DrawingModule" );
     117             : }
     118             : 
     119           0 : sal_Bool SAL_CALL SdUnoModule::supportsService( const OUString& sServiceName ) throw(uno::RuntimeException, std::exception)
     120             : {
     121           0 :     return cppu::supportsService(this, sServiceName);
     122             : }
     123             : 
     124           1 : uno::Sequence< OUString > SAL_CALL SdUnoModule::getSupportedServiceNames(  ) throw(uno::RuntimeException, std::exception)
     125             : {
     126           1 :     uno::Sequence< OUString > aSeq( 1 );
     127           1 :     aSeq[0] = "com.sun.star.drawing.ModuleDispatcher";
     128           1 :     return aSeq;
     129             : }
     130             : 
     131             : 
     132             : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
     133           1 : com_sun_star_comp_Draw_DrawingModule_get_implementation(::com::sun::star::uno::XComponentContext* context,
     134             :                                                         ::com::sun::star::uno::Sequence<css::uno::Any> const &)
     135             : {
     136           1 :     SolarMutexGuard aGuard;
     137             : 
     138           2 :     uno::Reference< lang::XMultiServiceFactory> xSM(context->getServiceManager(), uno::UNO_QUERY_THROW);
     139           2 :     return cppu::acquire(new SdUnoModule(xSM));
     140             : }
     141             : 
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11