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

Generated by: LCOV version 1.10