LCOV - code coverage report
Current view: top level - desktop/source/deployment/misc - dp_interact.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 53 0.0 %
Date: 2014-04-14 Functions: 0 14 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 "dp_interact.h"
      22             : #include "cppuhelper/exc_hlp.hxx"
      23             : #include "cppuhelper/implbase1.hxx"
      24             : #include "com/sun/star/task/XInteractionAbort.hpp"
      25             : 
      26             : 
      27             : using namespace ::com::sun::star;
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::ucb;
      30             : 
      31             : namespace dp_misc {
      32             : namespace {
      33             : 
      34             : 
      35           0 : class InteractionContinuationImpl : public ::cppu::OWeakObject,
      36             :                                     public task::XInteractionContinuation
      37             : {
      38             :     const Type m_type;
      39             :     bool * m_pselect;
      40             : 
      41             : public:
      42           0 :     inline InteractionContinuationImpl( Type const & type, bool * pselect )
      43             :         : m_type( type ),
      44           0 :           m_pselect( pselect )
      45             :         { OSL_ASSERT(
      46             :             ::getCppuType(
      47             :                 static_cast< Reference<task::XInteractionContinuation>
      48           0 :                 const *>(0) ).isAssignableFrom(m_type) ); }
      49             : 
      50             :     // XInterface
      51             :     virtual void SAL_CALL acquire() throw () SAL_OVERRIDE;
      52             :     virtual void SAL_CALL release() throw () SAL_OVERRIDE;
      53             :     virtual Any SAL_CALL queryInterface( Type const & type )
      54             :         throw (RuntimeException, std::exception) SAL_OVERRIDE;
      55             : 
      56             :     // XInteractionContinuation
      57             :     virtual void SAL_CALL select() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      58             : };
      59             : 
      60             : // XInterface
      61             : 
      62           0 : void InteractionContinuationImpl::acquire() throw ()
      63             : {
      64           0 :     OWeakObject::acquire();
      65           0 : }
      66             : 
      67             : 
      68           0 : void InteractionContinuationImpl::release() throw ()
      69             : {
      70           0 :     OWeakObject::release();
      71           0 : }
      72             : 
      73             : 
      74           0 : Any InteractionContinuationImpl::queryInterface( Type const & type )
      75             :     throw (RuntimeException, std::exception)
      76             : {
      77           0 :     if (type.isAssignableFrom( m_type )) {
      78           0 :         Reference<task::XInteractionContinuation> xThis(this);
      79           0 :         return Any( &xThis, type );
      80             :     }
      81             :     else
      82           0 :         return OWeakObject::queryInterface(type);
      83             : }
      84             : 
      85             : // XInteractionContinuation
      86             : 
      87           0 : void InteractionContinuationImpl::select() throw (RuntimeException, std::exception)
      88             : {
      89           0 :     *m_pselect = true;
      90           0 : }
      91             : 
      92             : 
      93           0 : class InteractionRequest :
      94             :     public ::cppu::WeakImplHelper1<task::XInteractionRequest>
      95             : {
      96             :     Any m_request;
      97             :     Sequence< Reference<task::XInteractionContinuation> > m_conts;
      98             : 
      99             : public:
     100           0 :     inline InteractionRequest(
     101             :         Any const & request,
     102             :         Sequence< Reference<task::XInteractionContinuation> > const & conts )
     103             :         : m_request( request ),
     104           0 :           m_conts( conts )
     105           0 :         {}
     106             : 
     107             :     // XInteractionRequest
     108             :     virtual Any SAL_CALL getRequest()
     109             :         throw (RuntimeException, std::exception) SAL_OVERRIDE;
     110             :     virtual Sequence< Reference<task::XInteractionContinuation> >
     111             :     SAL_CALL getContinuations() throw (RuntimeException, std::exception) SAL_OVERRIDE;
     112             : };
     113             : 
     114             : // XInteractionRequest
     115             : 
     116           0 : Any InteractionRequest::getRequest() throw (RuntimeException, std::exception)
     117             : {
     118           0 :     return m_request;
     119             : }
     120             : 
     121             : 
     122             : Sequence< Reference< task::XInteractionContinuation > >
     123           0 : InteractionRequest::getContinuations() throw (RuntimeException, std::exception)
     124             : {
     125           0 :     return m_conts;
     126             : }
     127             : 
     128             : } // anon namespace
     129             : 
     130             : 
     131           0 : bool interactContinuation( Any const & request,
     132             :                            Type const & continuation,
     133             :                            Reference<XCommandEnvironment> const & xCmdEnv,
     134             :                            bool * pcont, bool * pabort )
     135             : {
     136             :     OSL_ASSERT(
     137             :         cppu::UnoType<task::XInteractionContinuation>::get().isAssignableFrom(
     138             :             continuation ) );
     139           0 :     if (xCmdEnv.is()) {
     140             :         Reference<task::XInteractionHandler> xInteractionHandler(
     141           0 :             xCmdEnv->getInteractionHandler() );
     142           0 :         if (xInteractionHandler.is()) {
     143           0 :             bool cont = false;
     144           0 :             bool abort = false;
     145           0 :             Sequence< Reference<task::XInteractionContinuation> > conts( 2 );
     146           0 :             conts[ 0 ] = new InteractionContinuationImpl(
     147           0 :                 continuation, &cont );
     148           0 :             conts[ 1 ] = new InteractionContinuationImpl(
     149           0 :                 cppu::UnoType<task::XInteractionAbort>::get(), &abort );
     150           0 :             xInteractionHandler->handle(
     151           0 :                 new InteractionRequest( request, conts ) );
     152           0 :             if (cont || abort) {
     153           0 :                 if (pcont != 0)
     154           0 :                     *pcont = cont;
     155           0 :                 if (pabort != 0)
     156           0 :                     *pabort = abort;
     157           0 :                 return true;
     158           0 :             }
     159           0 :         }
     160             :     }
     161           0 :     return false;
     162             : }
     163             : 
     164             : // XAbortChannel
     165             : 
     166           0 : void AbortChannel::sendAbort() throw (RuntimeException, std::exception)
     167             : {
     168           0 :     m_aborted = true;
     169           0 :     if (m_xNext.is())
     170           0 :         m_xNext->sendAbort();
     171           0 : }
     172             : 
     173             : } // dp_misc
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10