LCOV - code coverage report
Current view: top level - ucb/source/ucp/file - filtask.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 50 65 76.9 %
Date: 2015-06-13 12:38:46 Functions: 8 11 72.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             : #include "filtask.hxx"
      21             : #include "filglob.hxx"
      22             : 
      23             : /******************************************************************************/
      24             : /*                                                                            */
      25             : /*                              TaskHandling                                  */
      26             : /*                                                                            */
      27             : /******************************************************************************/
      28             : 
      29             : 
      30             : using namespace fileaccess;
      31             : using namespace com::sun::star;
      32             : using namespace com::sun::star::uno;
      33             : using namespace com::sun::star::ucb;
      34             : 
      35             : 
      36             : 
      37        2124 : TaskManager::TaskManager()
      38        2124 :     : m_nCommandId( 0 )
      39             : {
      40        2124 : }
      41             : 
      42             : 
      43             : 
      44        2084 : TaskManager::~TaskManager()
      45             : {
      46        2084 : }
      47             : 
      48             : 
      49             : 
      50             : void SAL_CALL
      51      195041 : TaskManager::startTask(
      52             :     sal_Int32 CommandId,
      53             :     const uno::Reference< XCommandEnvironment >& xCommandEnv )
      54             :     throw( DuplicateCommandIdentifierException )
      55             : {
      56      195041 :     osl::MutexGuard aGuard( m_aMutex );
      57      195041 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
      58      195041 :     if( it != m_aTaskMap.end() )
      59             :     {
      60           0 :         throw DuplicateCommandIdentifierException( OSL_LOG_PREFIX );
      61             :     }
      62      195041 :     m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv );
      63      195041 : }
      64             : 
      65             : 
      66             : 
      67             : void SAL_CALL
      68      195041 : TaskManager::endTask( sal_Int32 CommandId,
      69             :                       const OUString& aUncPath,
      70             :                       BaseContent* pContent)
      71             : {
      72      195041 :     osl::MutexGuard aGuard( m_aMutex );
      73      195041 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
      74      195041 :     if( it == m_aTaskMap.end() )
      75      171027 :         return;
      76             : 
      77      195041 :     sal_Int32 ErrorCode = it->second.getInstalledError();
      78      195041 :     sal_Int32 MinorCode = it->second.getMinorErrorCode();
      79      195041 :     bool isHandled = it->second.isHandled();
      80             : 
      81             :     Reference< XCommandEnvironment > xComEnv
      82      390082 :         = it->second.getCommandEnvironment();
      83             : 
      84      195041 :     m_aTaskMap.erase( it );
      85             : 
      86      195041 :     if( ErrorCode != TASKHANDLER_NO_ERROR )
      87             :         throw_handler(
      88             :             ErrorCode,
      89             :             MinorCode,
      90             :             xComEnv,
      91             :             aUncPath,
      92             :             pContent,
      93      219055 :             isHandled);
      94             : }
      95             : 
      96             : 
      97             : 
      98             : void SAL_CALL
      99           0 : TaskManager::abort( sal_Int32 CommandId )
     100             : {
     101           0 :     if( CommandId )
     102             :     {
     103           0 :         osl::MutexGuard aGuard( m_aMutex );
     104           0 :         TaskMap::iterator it = m_aTaskMap.find( CommandId );
     105           0 :         if( it == m_aTaskMap.end() )
     106           0 :             return;
     107             :         else
     108           0 :             it->second.abort();
     109             :     }
     110             : }
     111             : 
     112             : 
     113           0 : void SAL_CALL TaskManager::clearError( sal_Int32 CommandId )
     114             : {
     115           0 :     osl::MutexGuard aGuard( m_aMutex );
     116           0 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     117           0 :     if( it != m_aTaskMap.end() )
     118           0 :         it->second.clearError();
     119           0 : }
     120             : 
     121             : 
     122         980 : void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId,
     123             :                                           sal_Int32 &ErrorCode,
     124             :                                           sal_Int32 &minorCode)
     125             : {
     126         980 :     osl::MutexGuard aGuard( m_aMutex );
     127         980 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     128         980 :     if( it != m_aTaskMap.end() )
     129             :     {
     130         980 :         ErrorCode = it->second.getInstalledError();
     131         980 :         minorCode = it->second. getMinorErrorCode();
     132         980 :     }
     133         980 : }
     134             : 
     135             : 
     136             : 
     137       24014 : void SAL_CALL TaskManager::installError( sal_Int32 CommandId,
     138             :                                          sal_Int32 ErrorCode,
     139             :                                          sal_Int32 MinorCode )
     140             : {
     141       24014 :     osl::MutexGuard aGuard( m_aMutex );
     142       24014 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     143       24014 :     if( it != m_aTaskMap.end() )
     144       24014 :         it->second.installError( ErrorCode,MinorCode );
     145       24014 : }
     146             : 
     147             : 
     148             : 
     149             : sal_Int32 SAL_CALL
     150      195041 : TaskManager::getCommandId()
     151             : {
     152      195041 :     osl::MutexGuard aGuard( m_aMutex );
     153      195041 :     return ++m_nCommandId;
     154             : }
     155             : 
     156             : 
     157             : 
     158         980 : void SAL_CALL TaskManager::handleTask(
     159             :     sal_Int32 CommandId,
     160             :     const uno::Reference< task::XInteractionRequest >& request )
     161             : {
     162         980 :     osl::MutexGuard aGuard( m_aMutex );
     163         980 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     164        1960 :     uno::Reference< task::XInteractionHandler > xInt;
     165         980 :     if( it != m_aTaskMap.end() )
     166             :     {
     167         980 :         xInt = it->second.getInteractionHandler();
     168         980 :         if( xInt.is() )
     169           0 :             xInt->handle( request );
     170         980 :         it->second.setHandled();
     171         980 :     }
     172         980 : }
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11