LCOV - code coverage report
Current view: top level - ucb/source/ucp/file - filtask.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 50 65 76.9 %
Date: 2014-11-03 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        3491 : TaskManager::TaskManager()
      38        3491 :     : m_nCommandId( 0 )
      39             : {
      40        3491 : }
      41             : 
      42             : 
      43             : 
      44        3456 : TaskManager::~TaskManager()
      45             : {
      46        3456 : }
      47             : 
      48             : 
      49             : 
      50             : void SAL_CALL
      51      299474 : TaskManager::startTask(
      52             :     sal_Int32 CommandId,
      53             :     const uno::Reference< XCommandEnvironment >& xCommandEnv )
      54             :     throw( DuplicateCommandIdentifierException )
      55             : {
      56      299474 :     osl::MutexGuard aGuard( m_aMutex );
      57      299474 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
      58      299474 :     if( it != m_aTaskMap.end() )
      59             :     {
      60           0 :         throw DuplicateCommandIdentifierException( OSL_LOG_PREFIX );
      61             :     }
      62      299474 :     m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv );
      63      299474 : }
      64             : 
      65             : 
      66             : 
      67             : void SAL_CALL
      68      299474 : TaskManager::endTask( sal_Int32 CommandId,
      69             :                       const OUString& aUncPath,
      70             :                       BaseContent* pContent)
      71             : {
      72      299474 :     osl::MutexGuard aGuard( m_aMutex );
      73      299474 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
      74      299474 :     if( it == m_aTaskMap.end() )
      75      263496 :         return;
      76             : 
      77      299474 :     sal_Int32 ErrorCode = it->second.getInstalledError();
      78      299474 :     sal_Int32 MinorCode = it->second.getMinorErrorCode();
      79      299474 :     bool isHandled = it->second.isHandled();
      80             : 
      81             :     Reference< XCommandEnvironment > xComEnv
      82      598948 :         = it->second.getCommandEnvironment();
      83             : 
      84      299474 :     m_aTaskMap.erase( it );
      85             : 
      86      299474 :     if( ErrorCode != TASKHANDLER_NO_ERROR )
      87             :         throw_handler(
      88             :             ErrorCode,
      89             :             MinorCode,
      90             :             xComEnv,
      91             :             aUncPath,
      92             :             pContent,
      93      335452 :             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        1467 : void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId,
     123             :                                           sal_Int32 &ErrorCode,
     124             :                                           sal_Int32 &minorCode)
     125             : {
     126        1467 :     osl::MutexGuard aGuard( m_aMutex );
     127        1467 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     128        1467 :     if( it != m_aTaskMap.end() )
     129             :     {
     130        1467 :         ErrorCode = it->second.getInstalledError();
     131        1467 :         minorCode = it->second. getMinorErrorCode();
     132        1467 :     }
     133        1467 : }
     134             : 
     135             : 
     136             : 
     137       35978 : void SAL_CALL TaskManager::installError( sal_Int32 CommandId,
     138             :                                          sal_Int32 ErrorCode,
     139             :                                          sal_Int32 MinorCode )
     140             : {
     141       35978 :     osl::MutexGuard aGuard( m_aMutex );
     142       35978 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     143       35978 :     if( it != m_aTaskMap.end() )
     144       35978 :         it->second.installError( ErrorCode,MinorCode );
     145       35978 : }
     146             : 
     147             : 
     148             : 
     149             : sal_Int32 SAL_CALL
     150      299474 : TaskManager::getCommandId( void )
     151             : {
     152      299474 :     osl::MutexGuard aGuard( m_aMutex );
     153      299474 :     return ++m_nCommandId;
     154             : }
     155             : 
     156             : 
     157             : 
     158        1467 : void SAL_CALL TaskManager::handleTask(
     159             :     sal_Int32 CommandId,
     160             :     const uno::Reference< task::XInteractionRequest >& request )
     161             : {
     162        1467 :     osl::MutexGuard aGuard( m_aMutex );
     163        1467 :     TaskMap::iterator it = m_aTaskMap.find( CommandId );
     164        2934 :     uno::Reference< task::XInteractionHandler > xInt;
     165        1467 :     if( it != m_aTaskMap.end() )
     166             :     {
     167        1467 :         xInt = it->second.getInteractionHandler();
     168        1467 :         if( xInt.is() )
     169           0 :             xInt->handle( request );
     170        1467 :         it->second.setHandled();
     171        1467 :     }
     172        1467 : }
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10