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

Generated by: LCOV version 1.10