LCOV - code coverage report
Current view: top level - desktop/source/deployment/inc - dp_interact.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 36 88.9 %
Date: 2015-06-13 12:38:46 Functions: 11 12 91.7 %
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             : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_INTERACT_H
      21             : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_INTERACT_H
      22             : 
      23             : #include <rtl/ref.hxx>
      24             : #include <cppuhelper/implbase1.hxx>
      25             : #include <com/sun/star/uno/XComponentContext.hpp>
      26             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      27             : #include <com/sun/star/task/XAbortChannel.hpp>
      28             : #include "dp_misc_api.hxx"
      29             : 
      30             : namespace dp_misc
      31             : {
      32             : 
      33           3 : inline void progressUpdate(
      34             :     OUString const & status,
      35             :     css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
      36             : {
      37           3 :     if (xCmdEnv.is()) {
      38             :         css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler(
      39           3 :             xCmdEnv->getProgressHandler() );
      40           3 :         if (xProgressHandler.is()) {
      41           3 :             xProgressHandler->update( css::uno::makeAny(status) );
      42           3 :         }
      43             :     }
      44           3 : }
      45             : 
      46             : 
      47             : class ProgressLevel
      48             : {
      49             :     css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler;
      50             : 
      51             : public:
      52             :     inline ~ProgressLevel();
      53             :     inline ProgressLevel(
      54             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
      55             :         OUString const & status );
      56             : 
      57             :     inline void update( OUString const & status ) const;
      58             :     inline void update( css::uno::Any const & status ) const;
      59             : };
      60             : 
      61             : 
      62         163 : inline ProgressLevel::ProgressLevel(
      63             :     css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
      64         163 :     OUString const & status )
      65             : {
      66         163 :     if (xCmdEnv.is())
      67         161 :         m_xProgressHandler = xCmdEnv->getProgressHandler();
      68         163 :     if (m_xProgressHandler.is())
      69         161 :         m_xProgressHandler->push( css::uno::makeAny(status) );
      70         163 : }
      71             : 
      72             : 
      73         326 : inline ProgressLevel::~ProgressLevel()
      74             : {
      75         163 :     if (m_xProgressHandler.is())
      76         161 :         m_xProgressHandler->pop();
      77         163 : }
      78             : 
      79             : 
      80         106 : inline void ProgressLevel::update( OUString const & status ) const
      81             : {
      82         106 :     if (m_xProgressHandler.is())
      83         106 :         m_xProgressHandler->update( css::uno::makeAny(status) );
      84         106 : }
      85             : 
      86             : 
      87           0 : inline void ProgressLevel::update( css::uno::Any const & status ) const
      88             : {
      89           0 :     if (m_xProgressHandler.is())
      90           0 :         m_xProgressHandler->update( status );
      91           0 : }
      92             : 
      93             : 
      94             : 
      95             : /** @return true if ia handler is present and any selection has been chosen
      96             :  */
      97             : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation(
      98             :     css::uno::Any const & request,
      99             :     css::uno::Type const & continuation,
     100             :     css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
     101             :     bool * pcont, bool * pabort );
     102             : 
     103             : 
     104             : 
     105             : 
     106          12 : class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC AbortChannel :
     107             :     public ::cppu::WeakImplHelper1<css::task::XAbortChannel>
     108             : {
     109             :     bool m_aborted;
     110             :     css::uno::Reference<css::task::XAbortChannel> m_xNext;
     111             : 
     112             : public:
     113           6 :     inline AbortChannel() : m_aborted( false ) {}
     114          15 :     inline static AbortChannel * get(
     115             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel )
     116          15 :         { return static_cast<AbortChannel *>(xAbortChannel.get()); }
     117             : 
     118           3 :     inline bool isAborted() const { return m_aborted; }
     119             : 
     120             :     // XAbortChannel
     121             :     virtual void SAL_CALL sendAbort() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     122             : 
     123             :     class SAL_DLLPRIVATE Chain
     124             :     {
     125             :         const ::rtl::Reference<AbortChannel> m_abortChannel;
     126             :     public:
     127           6 :         inline Chain(
     128             :             ::rtl::Reference<AbortChannel> const & abortChannel,
     129             :             css::uno::Reference<css::task::XAbortChannel> const & xNext )
     130           6 :             : m_abortChannel( abortChannel )
     131           6 :             { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; }
     132           6 :         inline ~Chain()
     133           6 :             { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); }
     134             :     };
     135             :     friend class Chain;
     136             : };
     137             : 
     138             : }
     139             : 
     140             : #endif
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11