1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_UCB_SOURCE_UCP_FILE_FILTASK_HXX
20 #define INCLUDED_UCB_SOURCE_UCP_FILE_FILTASK_HXX
23 #include <rtl/ustring.hxx>
25 #include "osl/mutex.hxx"
26 #include <com/sun/star/ucb/DuplicateCommandIdentifierException.hpp>
27 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
28 #include <com/sun/star/ucb/XProgressHandler.hpp>
29 #include <com/sun/star/task/XInteractionHandler.hpp>
30 #include <com/sun/star/task/XInteractionRequest.hpp>
31 #include <boost/functional/hash.hpp>
32 #include "filerror.hxx"
33 #include <unordered_map>
40 * This implementation is inherited by class fileaccess::shell.
41 * The relevant methods in this class all have as first argument the CommandId,
42 * so if necessary, every method has access to its relevant XInteractionHandler and
55 bool m_bAbort
,m_bHandled
;
56 sal_Int32 m_nErrorCode
,m_nMinorCode
;
57 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> m_xInteractionHandler
;
58 com::sun::star::uno::Reference
< com::sun::star::ucb::XProgressHandler
> m_xProgressHandler
;
59 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> m_xCommandEnvironment
;
65 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xCommandEnv
66 = com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>( 0 ) )
69 m_nErrorCode( TASKHANDLER_NO_ERROR
),
70 m_nMinorCode( TASKHANDLER_NO_ERROR
),
71 m_xInteractionHandler( 0 ),
72 m_xProgressHandler( 0 ),
73 m_xCommandEnvironment( xCommandEnv
)
87 bool isHandled() const
94 m_nErrorCode
= TASKHANDLER_NO_ERROR
;
95 m_nMinorCode
= TASKHANDLER_NO_ERROR
;
98 void SAL_CALL
installError( sal_Int32 nErrorCode
,
99 sal_Int32 nMinorCode
= TASKHANDLER_NO_ERROR
)
101 m_nErrorCode
= nErrorCode
;
102 m_nMinorCode
= nMinorCode
;
105 sal_Int32 SAL_CALL
getInstalledError()
110 sal_Int32 SAL_CALL
getMinorErrorCode()
115 com::sun::star::uno::Reference
< com::sun::star::ucb::XProgressHandler
> SAL_CALL
118 if( ! m_xProgressHandler
.is() && m_xCommandEnvironment
.is() )
119 m_xProgressHandler
= m_xCommandEnvironment
->getProgressHandler();
121 return m_xProgressHandler
;
124 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> SAL_CALL
125 getInteractionHandler()
127 if( ! m_xInteractionHandler
.is() && m_xCommandEnvironment
.is() )
128 m_xInteractionHandler
= m_xCommandEnvironment
->getInteractionHandler();
130 return m_xInteractionHandler
;
133 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> SAL_CALL
134 getCommandEnvironment()
136 return m_xCommandEnvironment
;
139 }; // end class TaskHandling
142 typedef std::unordered_map
< sal_Int32
,TaskHandling
,boost::hash
< sal_Int32
> > TaskMap
;
146 sal_Int32 m_nCommandId
;
153 virtual ~TaskManager();
155 void SAL_CALL
startTask(
157 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xCommandEnv
)
158 throw( com::sun::star::ucb::DuplicateCommandIdentifierException
);
160 sal_Int32 SAL_CALL
getCommandId();
161 void SAL_CALL
abort( sal_Int32 CommandId
);
165 * The error code may be one of the error codes defined in
167 * The minor code refines the information given in ErrorCode.
170 void SAL_CALL
clearError();
172 void SAL_CALL
installError( sal_Int32 CommandId
,
174 sal_Int32 minorCode
= TASKHANDLER_NO_ERROR
);
176 void SAL_CALL
retrieveError( sal_Int32 CommandId
,
177 sal_Int32
&ErrorCode
,
178 sal_Int32
&minorCode
);
181 * Deinstalls the task and evaluates a possibly set error code.
182 * "endTask" throws in case an error code is set the corresponding exception.
185 void SAL_CALL
endTask( sal_Int32 CommandId
,
186 // the physical URL of the object
187 const OUString
& aUnqPath
,
188 BaseContent
* pContent
);
192 * Handles an interactionrequest
195 void SAL_CALL
handleTask( sal_Int32 CommandId
,
196 const com::sun::star::uno::Reference
< com::sun::star::task::XInteractionRequest
>& request
);
199 * Clears any error which are set on the commandid
202 void SAL_CALL
clearError( sal_Int32
);
206 } // end namespace TaskHandling
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */