LCOV - code coverage report
Current view: top level - desktop/source/deployment/inc - dp_interact.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 36 88.9 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 28 52 53.8 %

           Branch data     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_DP_INTERACT_H
      21                 :            : #define INCLUDED_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 css = ::com::sun::star;
      31                 :            : 
      32                 :            : namespace dp_misc
      33                 :            : {
      34                 :            : 
      35                 :          6 : inline void progressUpdate(
      36                 :            :     ::rtl::OUString const & status,
      37                 :            :     css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
      38                 :            : {
      39         [ +  - ]:          6 :     if (xCmdEnv.is()) {
      40                 :            :         css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler(
      41 [ +  - ][ +  - ]:          6 :             xCmdEnv->getProgressHandler() );
      42         [ +  - ]:          6 :         if (xProgressHandler.is()) {
      43 [ +  - ][ +  - ]:          6 :             xProgressHandler->update( css::uno::makeAny(status) );
                 [ +  - ]
      44                 :          6 :         }
      45                 :            :     }
      46                 :          6 : }
      47                 :            : 
      48                 :            : //==============================================================================
      49                 :            : class ProgressLevel
      50                 :            : {
      51                 :            :     css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler;
      52                 :            : 
      53                 :            : public:
      54                 :            :     inline ~ProgressLevel();
      55                 :            :     inline ProgressLevel(
      56                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
      57                 :            :         ::rtl::OUString const & status );
      58                 :            : 
      59                 :            :     inline void update( ::rtl::OUString const & status ) const;
      60                 :            :     inline void update( css::uno::Any const & status ) const;
      61                 :            : };
      62                 :            : 
      63                 :            : //______________________________________________________________________________
      64                 :       3108 : inline ProgressLevel::ProgressLevel(
      65                 :            :     css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
      66                 :       3108 :     ::rtl::OUString const & status )
      67                 :            : {
      68         [ +  + ]:       3108 :     if (xCmdEnv.is())
      69 [ +  - ][ +  - ]:       3104 :         m_xProgressHandler = xCmdEnv->getProgressHandler();
                 [ +  - ]
      70         [ +  + ]:       3108 :     if (m_xProgressHandler.is())
      71 [ +  - ][ +  - ]:       3104 :         m_xProgressHandler->push( css::uno::makeAny(status) );
                 [ +  - ]
      72                 :       3108 : }
      73                 :            : 
      74                 :            : //______________________________________________________________________________
      75                 :       3108 : inline ProgressLevel::~ProgressLevel()
      76                 :            : {
      77         [ +  + ]:       3108 :     if (m_xProgressHandler.is())
      78 [ +  - ][ +  - ]:       3104 :         m_xProgressHandler->pop();
      79                 :       3108 : }
      80                 :            : 
      81                 :            : //______________________________________________________________________________
      82                 :        124 : inline void ProgressLevel::update( ::rtl::OUString const & status ) const
      83                 :            : {
      84         [ +  - ]:        124 :     if (m_xProgressHandler.is())
      85         [ +  - ]:        124 :         m_xProgressHandler->update( css::uno::makeAny(status) );
      86                 :        124 : }
      87                 :            : 
      88                 :            : //______________________________________________________________________________
      89                 :          0 : inline void ProgressLevel::update( css::uno::Any const & status ) const
      90                 :            : {
      91         [ #  # ]:          0 :     if (m_xProgressHandler.is())
      92                 :          0 :         m_xProgressHandler->update( status );
      93                 :          0 : }
      94                 :            : 
      95                 :            : //##############################################################################
      96                 :            : 
      97                 :            : /** @return true if ia handler is present and any selection has been chosen
      98                 :            :  */
      99                 :            : DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation(
     100                 :            :     css::uno::Any const & request,
     101                 :            :     css::uno::Type const & continuation,
     102                 :            :     css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
     103                 :            :     bool * pcont, bool * pabort );
     104                 :            : 
     105                 :            : //##############################################################################
     106                 :            : 
     107                 :            : //==============================================================================
     108         [ -  + ]:      26256 : class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC AbortChannel :
     109                 :            :     public ::cppu::WeakImplHelper1<css::task::XAbortChannel>
     110                 :            : {
     111                 :            :     bool m_aborted;
     112                 :            :     css::uno::Reference<css::task::XAbortChannel> m_xNext;
     113                 :            : 
     114                 :            : public:
     115                 :      13128 :     inline AbortChannel() : m_aborted( false ) {}
     116                 :      19220 :     inline static AbortChannel * get(
     117                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel )
     118         [ +  + ]:      19220 :         { return static_cast<AbortChannel *>(xAbortChannel.get()); }
     119                 :            : 
     120                 :        133 :     inline bool isAborted() const { return m_aborted; }
     121                 :            : 
     122                 :            :     // XAbortChannel
     123                 :            :     virtual void SAL_CALL sendAbort() throw (css::uno::RuntimeException);
     124                 :            : 
     125                 :            :     class SAL_DLLPRIVATE Chain
     126                 :            :     {
     127                 :            :         const ::rtl::Reference<AbortChannel> m_abortChannel;
     128                 :            :     public:
     129                 :      13128 :         inline Chain(
     130                 :            :             ::rtl::Reference<AbortChannel> const & abortChannel,
     131                 :            :             css::uno::Reference<css::task::XAbortChannel> const & xNext )
     132                 :      13128 :             : m_abortChannel( abortChannel )
     133 [ #  # ][ -  + ]:      13128 :             { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; }
     134                 :      13128 :         inline ~Chain()
     135         [ -  + ]:      13128 :             { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); }
     136                 :            :     };
     137                 :            :     friend class Chain;
     138                 :            : };
     139                 :            : 
     140                 :            : }
     141                 :            : 
     142                 :            : #endif
     143                 :            : 
     144                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10