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

Generated by: LCOV version 1.10