LCOV - code coverage report
Current view: top level - toolkit/source/awt - asynccallback.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 27 0.0 %
Date: 2014-04-14 Functions: 0 11 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 <sal/config.h>
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include "vcl/svapp.hxx"
      24             : #include "osl/mutex.hxx"
      25             : #include "sal/config.h"
      26             : #include "cppuhelper/factory.hxx"
      27             : #include "cppuhelper/implementationentry.hxx"
      28             : #include "cppuhelper/implbase2.hxx"
      29             : #include <cppuhelper/supportsservice.hxx>
      30             : #include "com/sun/star/lang/XServiceInfo.hpp"
      31             : #include "com/sun/star/awt/XRequestCallback.hpp"
      32             : 
      33             : /// anonymous implementation namespace
      34             : namespace {
      35             : 
      36             : class AsyncCallback:
      37             :     public ::cppu::WeakImplHelper2<
      38             :         css::lang::XServiceInfo,
      39             :         css::awt::XRequestCallback>,
      40             :     private boost::noncopyable
      41             : {
      42             : public:
      43           0 :     AsyncCallback() {}
      44             : 
      45             :     // ::com::sun::star::lang::XServiceInfo:
      46             :     virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      47             :     virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      48             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      49             : 
      50             :     // ::com::sun::star::awt::XRequestCallback:
      51             :     virtual void SAL_CALL addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const ::com::sun::star::uno::Any & aData) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      52             : 
      53             : private:
      54             : 
      55           0 :     struct CallbackData
      56             :     {
      57           0 :         CallbackData( const css::uno::Reference< css::awt::XCallback >& rCallback, const css::uno::Any& rAny ) :
      58           0 :             xCallback( rCallback ), aData( rAny ) {}
      59             : 
      60             :         css::uno::Reference< css::awt::XCallback > xCallback;
      61             :         css::uno::Any                              aData;
      62             :     };
      63             : 
      64             :     DECL_STATIC_LINK( AsyncCallback, Notify_Impl, CallbackData* );
      65             : 
      66           0 :     virtual ~AsyncCallback() {}
      67             : };
      68             : 
      69             : // com.sun.star.uno.XServiceInfo:
      70           0 : OUString SAL_CALL AsyncCallback::getImplementationName() throw (css::uno::RuntimeException, std::exception)
      71             : {
      72           0 :     return OUString("com.sun.star.awt.comp.AsyncCallback");
      73             : }
      74             : 
      75           0 : sal_Bool SAL_CALL AsyncCallback::supportsService(OUString const & serviceName) throw (css::uno::RuntimeException, std::exception)
      76             : {
      77           0 :     return cppu::supportsService(this, serviceName);
      78             : }
      79             : 
      80           0 : css::uno::Sequence< OUString > SAL_CALL AsyncCallback::getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception)
      81             : {
      82           0 :     css::uno::Sequence< OUString > s(1);
      83           0 :     s[0] = "com.sun.star.awt.AsyncCallback";
      84           0 :     return s;
      85             : }
      86             : 
      87             : // ::com::sun::star::awt::XRequestCallback:
      88           0 : void SAL_CALL AsyncCallback::addCallback(const css::uno::Reference< css::awt::XCallback > & xCallback, const ::com::sun::star::uno::Any & aData) throw (css::uno::RuntimeException, std::exception)
      89             : {
      90           0 :     if ( Application::IsInMain() )
      91             :     {
      92           0 :         SolarMutexGuard aSolarGuard;
      93             : 
      94           0 :         CallbackData* pCallbackData = new CallbackData( xCallback, aData );
      95           0 :         Application::PostUserEvent( STATIC_LINK( this, AsyncCallback, Notify_Impl ), pCallbackData );
      96             :     }
      97           0 : }
      98             : 
      99             : // private asynchronous link to call reference to the callback object
     100           0 : IMPL_STATIC_LINK_NOINSTANCE( AsyncCallback, Notify_Impl, CallbackData*, pCallbackData )
     101             : {
     102             :     try
     103             :     {
     104             :         // Asynchronous execution
     105             :         // Check pointer and reference before!
     106           0 :         if ( pCallbackData && pCallbackData->xCallback.is() )
     107           0 :             pCallbackData->xCallback->notify( pCallbackData->aData );
     108             :     }
     109           0 :     catch ( css::uno::Exception& )
     110             :     {
     111             :     }
     112             : 
     113           0 :     delete pCallbackData;
     114           0 :     return 0;
     115             : }
     116             : 
     117             : } // closing anonymous implementation namespace
     118             : 
     119             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     120           0 : com_sun_star_awt_comp_AsyncCallback_get_implementation(
     121             :     css::uno::XComponentContext *,
     122             :     css::uno::Sequence<css::uno::Any> const &)
     123             : {
     124           0 :     return cppu::acquire(new AsyncCallback());
     125             : }
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10