LCOV - code coverage report
Current view: top level - ucb/source/ucp/file - filtask.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 30 73.3 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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             : #ifndef INCLUDED_UCB_SOURCE_UCP_FILE_FILTASK_HXX
      20             : #define INCLUDED_UCB_SOURCE_UCP_FILE_FILTASK_HXX
      21             : #endif
      22             : 
      23             : #include <boost/unordered_map.hpp>
      24             : #include <rtl/ustring.hxx>
      25             : 
      26             : #include "osl/mutex.hxx"
      27             : #include <com/sun/star/ucb/DuplicateCommandIdentifierException.hpp>
      28             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      29             : #include <com/sun/star/ucb/XProgressHandler.hpp>
      30             : #include <com/sun/star/task/XInteractionHandler.hpp>
      31             : #include <com/sun/star/task/XInteractionRequest.hpp>
      32             : #include "filerror.hxx"
      33             : 
      34             : namespace fileaccess
      35             : {
      36             :     class BaseContent;
      37             : 
      38             :     /*
      39             :      * This implementation is inherited by class fileaccess::shell.
      40             :      * The relevant methods in this class all have as first argument the CommandId,
      41             :      * so if necessary, every method has access to its relevant XInteractionHandler and
      42             :      * XProgressHandler.
      43             :      */
      44             : 
      45             : 
      46             :     class TaskManager
      47             :     {
      48             :     protected:
      49             : 
      50      898422 :         class TaskHandling
      51             :         {
      52             :         private:
      53             : 
      54             :             bool m_bAbort,m_bHandled;
      55             :             sal_Int32 m_nErrorCode,m_nMinorCode;
      56             :             com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > m_xInteractionHandler;
      57             :             com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler >     m_xProgressHandler;
      58             :             com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >  m_xCommandEnvironment;
      59             : 
      60             : 
      61             :         public:
      62             : 
      63      598948 :             TaskHandling(
      64             :                 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >&  xCommandEnv
      65             :                 = com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >( 0 ) )
      66             :                 : m_bAbort( false ),
      67             :                   m_bHandled( false ),
      68             :                   m_nErrorCode( TASKHANDLER_NO_ERROR ),
      69             :                   m_nMinorCode( TASKHANDLER_NO_ERROR ),
      70             :                   m_xInteractionHandler( 0 ),
      71             :                   m_xProgressHandler( 0 ),
      72      598948 :                   m_xCommandEnvironment( xCommandEnv )
      73             :             {
      74      598948 :             }
      75             : 
      76           0 :             void SAL_CALL abort()
      77             :             {
      78           0 :                 m_bAbort = true;
      79           0 :             }
      80             : 
      81        1467 :             void setHandled()
      82             :             {
      83        1467 :                 m_bHandled = true;
      84        1467 :             }
      85             : 
      86      299474 :             bool isHandled() const
      87             :             {
      88      299474 :                 return true;
      89             :             }
      90             : 
      91           0 :             void clearError()
      92             :             {
      93           0 :                 m_nErrorCode = TASKHANDLER_NO_ERROR;
      94           0 :                 m_nMinorCode =  TASKHANDLER_NO_ERROR;
      95           0 :             }
      96             : 
      97       35978 :             void SAL_CALL installError( sal_Int32 nErrorCode,
      98             :                                         sal_Int32 nMinorCode = TASKHANDLER_NO_ERROR )
      99             :             {
     100       35978 :                 m_nErrorCode = nErrorCode;
     101       35978 :                 m_nMinorCode = nMinorCode;
     102       35978 :             }
     103             : 
     104      300941 :             sal_Int32 SAL_CALL getInstalledError()
     105             :             {
     106      300941 :                 return m_nErrorCode;
     107             :             }
     108             : 
     109      300941 :             sal_Int32 SAL_CALL getMinorErrorCode()
     110             :             {
     111      300941 :                 return m_nMinorCode;
     112             :             }
     113             : 
     114             :             com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler > SAL_CALL
     115             :             getProgressHandler()
     116             :             {
     117             :                 if( ! m_xProgressHandler.is() && m_xCommandEnvironment.is() )
     118             :                     m_xProgressHandler = m_xCommandEnvironment->getProgressHandler();
     119             : 
     120             :                 return m_xProgressHandler;
     121             :             }
     122             : 
     123             :             com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > SAL_CALL
     124        1467 :             getInteractionHandler()
     125             :             {
     126        1467 :                 if( ! m_xInteractionHandler.is() && m_xCommandEnvironment.is() )
     127           0 :                     m_xInteractionHandler = m_xCommandEnvironment->getInteractionHandler();
     128             : 
     129        1467 :                 return m_xInteractionHandler;
     130             :             }
     131             : 
     132             :             com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > SAL_CALL
     133      299474 :             getCommandEnvironment()
     134             :             {
     135      299474 :                 return m_xCommandEnvironment;
     136             :             }
     137             : 
     138             :         };  // end class TaskHandling
     139             : 
     140             : 
     141             :         typedef boost::unordered_map< sal_Int32,TaskHandling,boost::hash< sal_Int32 > > TaskMap;
     142             : 
     143             : 
     144             :     private:
     145             : 
     146             :         osl::Mutex                                                         m_aMutex;
     147             :         sal_Int32                                                           m_nCommandId;
     148             :         TaskMap                                                             m_aTaskMap;
     149             : 
     150             : 
     151             :     public:
     152             : 
     153             :         TaskManager();
     154             :         virtual ~TaskManager();
     155             : 
     156             :         void SAL_CALL startTask(
     157             :             sal_Int32 CommandId,
     158             :             const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >&  xCommandEnv )
     159             :             throw( com::sun::star::ucb::DuplicateCommandIdentifierException );
     160             : 
     161             :         sal_Int32 SAL_CALL getCommandId( void );
     162             :         void SAL_CALL abort( sal_Int32 CommandId );
     163             : 
     164             : 
     165             :         /**
     166             :          *  The error code may be one of the error codes defined in
     167             :          *  filerror.hxx.
     168             :          *  The minor code refines the information given in ErrorCode.
     169             :          */
     170             : 
     171             :         void SAL_CALL clearError();
     172             : 
     173             :         void SAL_CALL installError( sal_Int32 CommandId,
     174             :                                     sal_Int32 ErrorCode,
     175             :                                     sal_Int32 minorCode = TASKHANDLER_NO_ERROR );
     176             : 
     177             :         void SAL_CALL retrieveError( sal_Int32 CommandId,
     178             :                                      sal_Int32 &ErrorCode,
     179             :                                      sal_Int32 &minorCode);
     180             : 
     181             :         /**
     182             :          *  Deinstalls the task and evaluates a possibly set error code.
     183             :          *  "endTask" throws in case an error code is set the corresponding exception.
     184             :          */
     185             : 
     186             :         void SAL_CALL endTask( sal_Int32 CommandId,
     187             :                                // the physical URL of the object
     188             :                                const OUString& aUnqPath,
     189             :                                BaseContent* pContent);
     190             : 
     191             : 
     192             :         /**
     193             :          *  Handles an interactionrequest
     194             :          */
     195             : 
     196             :         void SAL_CALL handleTask( sal_Int32 CommandId,
     197             :                                   const com::sun::star::uno::Reference< com::sun::star::task::XInteractionRequest >& request );
     198             : 
     199             :         /**
     200             :          *  Clears any error which are set on the commandid
     201             :          */
     202             : 
     203             :         void SAL_CALL clearError( sal_Int32 );
     204             : 
     205             :     };
     206             : 
     207             : } // end namespace TaskHandling
     208             : 
     209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10