Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / file / filtask.cxx
blob592929cea2174fcbb99ee3d1351ab2eeb0a5d92b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "filtask.hxx"
21 #include "filglob.hxx"
23 /******************************************************************************/
24 /* */
25 /* TaskHandling */
26 /* */
27 /******************************************************************************/
30 using namespace fileaccess;
31 using namespace com::sun::star;
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::ucb;
37 TaskManager::TaskManager()
38 : m_nCommandId( 0 )
44 TaskManager::~TaskManager()
50 void SAL_CALL
51 TaskManager::startTask(
52 sal_Int32 CommandId,
53 const uno::Reference< XCommandEnvironment >& xCommandEnv )
54 throw( DuplicateCommandIdentifierException )
56 osl::MutexGuard aGuard( m_aMutex );
57 TaskMap::iterator it = m_aTaskMap.find( CommandId );
58 if( it != m_aTaskMap.end() )
60 throw DuplicateCommandIdentifierException(
61 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ),
62 uno::Reference< uno::XInterface >() );
64 m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv );
69 void SAL_CALL
70 TaskManager::endTask( sal_Int32 CommandId,
71 const rtl::OUString& aUncPath,
72 BaseContent* pContent)
74 osl::MutexGuard aGuard( m_aMutex );
75 TaskMap::iterator it = m_aTaskMap.find( CommandId );
76 if( it == m_aTaskMap.end() )
77 return;
79 sal_Int32 ErrorCode = it->second.getInstalledError();
80 sal_Int32 MinorCode = it->second.getMinorErrorCode();
81 bool isHandled = it->second.isHandled();
83 Reference< XCommandEnvironment > xComEnv
84 = it->second.getCommandEnvironment();
86 m_aTaskMap.erase( it );
88 if( ErrorCode != TASKHANDLER_NO_ERROR )
89 throw_handler(
90 ErrorCode,
91 MinorCode,
92 xComEnv,
93 aUncPath,
94 pContent,
95 isHandled);
100 void SAL_CALL
101 TaskManager::abort( sal_Int32 CommandId )
103 if( CommandId )
105 osl::MutexGuard aGuard( m_aMutex );
106 TaskMap::iterator it = m_aTaskMap.find( CommandId );
107 if( it == m_aTaskMap.end() )
108 return;
109 else
110 it->second.abort();
115 void SAL_CALL TaskManager::clearError( sal_Int32 CommandId )
117 osl::MutexGuard aGuard( m_aMutex );
118 TaskMap::iterator it = m_aTaskMap.find( CommandId );
119 if( it != m_aTaskMap.end() )
120 it->second.clearError();
124 void SAL_CALL TaskManager::retrieveError( sal_Int32 CommandId,
125 sal_Int32 &ErrorCode,
126 sal_Int32 &minorCode)
128 osl::MutexGuard aGuard( m_aMutex );
129 TaskMap::iterator it = m_aTaskMap.find( CommandId );
130 if( it != m_aTaskMap.end() )
132 ErrorCode = it->second.getInstalledError();
133 minorCode = it->second. getMinorErrorCode();
139 void SAL_CALL TaskManager::installError( sal_Int32 CommandId,
140 sal_Int32 ErrorCode,
141 sal_Int32 MinorCode )
143 osl::MutexGuard aGuard( m_aMutex );
144 TaskMap::iterator it = m_aTaskMap.find( CommandId );
145 if( it != m_aTaskMap.end() )
146 it->second.installError( ErrorCode,MinorCode );
151 sal_Int32 SAL_CALL
152 TaskManager::getCommandId( void )
154 osl::MutexGuard aGuard( m_aMutex );
155 return ++m_nCommandId;
160 void SAL_CALL TaskManager::handleTask(
161 sal_Int32 CommandId,
162 const uno::Reference< task::XInteractionRequest >& request )
164 osl::MutexGuard aGuard( m_aMutex );
165 TaskMap::iterator it = m_aTaskMap.find( CommandId );
166 uno::Reference< task::XInteractionHandler > xInt;
167 if( it != m_aTaskMap.end() )
169 xInt = it->second.getInteractionHandler();
170 if( xInt.is() )
171 xInt->handle( request );
172 it->second.setHandled();
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */