1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "filtask.hxx"
30 #include "filglob.hxx"
32 /******************************************************************************/
36 /******************************************************************************/
39 using namespace fileaccess
;
40 using namespace com::sun::star
;
41 using namespace com::sun::star::uno
;
42 using namespace com::sun::star::ucb
;
46 TaskManager::TaskManager()
53 TaskManager::~TaskManager()
60 TaskManager::startTask(
62 const uno::Reference
< XCommandEnvironment
>& xCommandEnv
)
63 throw( DuplicateCommandIdentifierException
)
65 osl::MutexGuard
aGuard( m_aMutex
);
66 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
67 if( it
!= m_aTaskMap
.end() )
69 throw DuplicateCommandIdentifierException(
70 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ),
71 uno::Reference
< uno::XInterface
>() );
73 m_aTaskMap
[ CommandId
] = TaskHandling( xCommandEnv
);
79 TaskManager::endTask( sal_Int32 CommandId
,
80 const rtl::OUString
& aUncPath
,
81 BaseContent
* pContent
)
83 osl::MutexGuard
aGuard( m_aMutex
);
84 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
85 if( it
== m_aTaskMap
.end() )
88 sal_Int32 ErrorCode
= it
->second
.getInstalledError();
89 sal_Int32 MinorCode
= it
->second
.getMinorErrorCode();
90 bool isHandled
= it
->second
.isHandled();
92 Reference
< XCommandEnvironment
> xComEnv
93 = it
->second
.getCommandEnvironment();
95 m_aTaskMap
.erase( it
);
97 if( ErrorCode
!= TASKHANDLER_NO_ERROR
)
110 TaskManager::abort( sal_Int32 CommandId
)
114 osl::MutexGuard
aGuard( m_aMutex
);
115 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
116 if( it
== m_aTaskMap
.end() )
124 void SAL_CALL
TaskManager::clearError( sal_Int32 CommandId
)
126 osl::MutexGuard
aGuard( m_aMutex
);
127 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
128 if( it
!= m_aTaskMap
.end() )
129 it
->second
.clearError();
133 void SAL_CALL
TaskManager::retrieveError( sal_Int32 CommandId
,
134 sal_Int32
&ErrorCode
,
135 sal_Int32
&minorCode
)
137 osl::MutexGuard
aGuard( m_aMutex
);
138 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
139 if( it
!= m_aTaskMap
.end() )
141 ErrorCode
= it
->second
.getInstalledError();
142 minorCode
= it
->second
. getMinorErrorCode();
148 void SAL_CALL
TaskManager::installError( sal_Int32 CommandId
,
150 sal_Int32 MinorCode
)
152 osl::MutexGuard
aGuard( m_aMutex
);
153 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
154 if( it
!= m_aTaskMap
.end() )
155 it
->second
.installError( ErrorCode
,MinorCode
);
161 TaskManager::getCommandId( void )
163 osl::MutexGuard
aGuard( m_aMutex
);
164 return ++m_nCommandId
;
169 void SAL_CALL
TaskManager::handleTask(
171 const uno::Reference
< task::XInteractionRequest
>& request
)
173 osl::MutexGuard
aGuard( m_aMutex
);
174 TaskMap::iterator it
= m_aTaskMap
.find( CommandId
);
175 uno::Reference
< task::XInteractionHandler
> xInt
;
176 if( it
!= m_aTaskMap
.end() )
178 xInt
= it
->second
.getInteractionHandler();
180 xInt
->handle( request
);
181 it
->second
.setHandled();
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */