LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/misc - synchronousdispatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2012-12-27 Functions: 0 1 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             : 
      21             : #include "com/sun/star/frame/XDispatchProvider.hpp"
      22             : #include "com/sun/star/frame/XSynchronousDispatch.hpp"
      23             : #include "com/sun/star/lang/XComponent.hpp"
      24             : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
      25             : #include "com/sun/star/util/XURLTransformer.hpp"
      26             : 
      27             : #include "comphelper/synchronousdispatch.hxx"
      28             : #include "comphelper/processfactory.hxx"
      29             : 
      30             : #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
      31             : 
      32             : //.........................................................................
      33             : namespace comphelper
      34             : {
      35             : //.........................................................................
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39             : //====================================================================
      40             : //= SynchronousDispatch
      41             : //====================================================================
      42             : 
      43           0 : uno::Reference< lang::XComponent > SynchronousDispatch::dispatch(
      44             :         const uno::Reference< uno::XInterface > &xStartPoint,
      45             :         const rtl::OUString &sURL,
      46             :         const rtl::OUString &sTarget,
      47             :         const sal_Int32 nFlags,
      48             :         const uno::Sequence< beans::PropertyValue > &lArguments )
      49             : {
      50           0 :     util::URL aURL;
      51           0 :     aURL.Complete = sURL;
      52           0 :     uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
      53           0 :                                                                    UNISTRING("com.sun.star.util.URLTransformer" )),
      54           0 :                                                      uno::UNO_QUERY );
      55           0 :     if ( xTrans.is() )
      56           0 :         xTrans->parseStrict( aURL );
      57             : 
      58           0 :     uno::Reference < frame::XDispatch > xDispatcher;
      59           0 :     uno::Reference < frame::XDispatchProvider > xProvider( xStartPoint, uno::UNO_QUERY );
      60             : 
      61           0 :     if ( xProvider.is() )
      62           0 :         xDispatcher = xProvider->queryDispatch( aURL, sTarget, nFlags );
      63             : 
      64           0 :     uno::Reference < lang::XComponent > aComponent;
      65             : 
      66           0 :     if ( xDispatcher.is() )
      67             :     {
      68             :         try
      69             :         {
      70           0 :             uno::Any aRet;
      71           0 :             uno::Reference < frame::XSynchronousDispatch > xSyncDisp( xDispatcher, uno::UNO_QUERY_THROW );
      72             : 
      73           0 :             aRet = xSyncDisp->dispatchWithReturnValue( aURL, lArguments );
      74             : 
      75           0 :             aRet >>= aComponent;
      76             :         }
      77           0 :         catch ( uno::Exception& )
      78             :         {
      79           0 :             rtl::OUString aMsg = UNISTRING( "SynchronousDispatch::dispatch() Error while dispatching! ");
      80           0 :             OSL_FAIL( OUStringToOString(aMsg, RTL_TEXTENCODING_ASCII_US).getStr());
      81             :         }
      82             :     }
      83             : 
      84           0 :     return aComponent;
      85             : }
      86             : 
      87             : //.........................................................................
      88             : }   // namespace comphelper
      89             : //.........................................................................
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10