1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filtask.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <rtl/ustring.hxx>
37 #include "osl/mutex.hxx"
38 #include <com/sun/star/ucb/DuplicateCommandIdentifierException.hpp>
39 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
40 #include <com/sun/star/ucb/XProgressHandler.hpp>
41 #include <com/sun/star/task/XInteractionHandler.hpp>
42 #include <com/sun/star/task/XInteractionRequest.hpp>
43 #ifndef _FILERROR_HXX_
44 #include "filerror.hxx"
53 * This implementation is inherited by class fileaccess::shell.
54 * The relevant methods in this class all have as first argument the CommandId,
55 * so if necessary, every method has acess to its relevant XInteractionHandler and
56 * XProgressHandler, simply by calling directly the method
57 * getInteractionHandler( CommandId )
59 * getProgressHandler();
71 bool m_bAbort
,m_bHandled
;
72 sal_Int32 m_nErrorCode
,m_nMinorCode
;
73 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> m_xInteractionHandler
;
74 com::sun::star::uno::Reference
< com::sun::star::ucb::XProgressHandler
> m_xProgressHandler
;
75 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> m_xCommandEnvironment
;
81 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xCommandEnv
82 = com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>( 0 ) )
85 m_nErrorCode( TASKHANDLER_NO_ERROR
),
86 m_nMinorCode( TASKHANDLER_NO_ERROR
),
87 m_xInteractionHandler( 0 ),
88 m_xProgressHandler( 0 ),
89 m_xCommandEnvironment( xCommandEnv
)
98 bool SAL_CALL
isAborted()
115 m_nErrorCode
= TASKHANDLER_NO_ERROR
;
116 m_nMinorCode
= TASKHANDLER_NO_ERROR
;
119 void SAL_CALL
installError( sal_Int32 nErrorCode
,
120 sal_Int32 nMinorCode
= TASKHANDLER_NO_ERROR
)
122 m_nErrorCode
= nErrorCode
;
123 m_nMinorCode
= nMinorCode
;
126 sal_Int32 SAL_CALL
getInstalledError()
131 sal_Int32 SAL_CALL
getMinorErrorCode()
136 com::sun::star::uno::Reference
< com::sun::star::ucb::XProgressHandler
> SAL_CALL
139 if( ! m_xProgressHandler
.is() && m_xCommandEnvironment
.is() )
140 m_xProgressHandler
= m_xCommandEnvironment
->getProgressHandler();
142 return m_xProgressHandler
;
145 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> SAL_CALL
146 getInteractionHandler()
148 if( ! m_xInteractionHandler
.is() && m_xCommandEnvironment
.is() )
149 m_xInteractionHandler
= m_xCommandEnvironment
->getInteractionHandler();
151 return m_xInteractionHandler
;
154 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> SAL_CALL
155 getCommandEnvironment()
157 return m_xCommandEnvironment
;
160 }; // end class TaskHandling
163 typedef std::hash_map
< sal_Int32
,TaskHandling
,std::hash
< sal_Int32
> > TaskMap
;
169 sal_Int32 m_nCommandId
;
176 virtual ~TaskManager();
178 void SAL_CALL
startTask(
180 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& xCommandEnv
)
181 throw( com::sun::star::ucb::DuplicateCommandIdentifierException
);
183 sal_Int32 SAL_CALL
getCommandId( void );
184 void SAL_CALL
abort( sal_Int32 CommandId
);
185 bool SAL_CALL
isAborted( sal_Int32 CommandId
);
189 * The error code may be one of the error codes defined in
191 * The minor code refines the information given in ErrorCode.
194 void SAL_CALL
clearError();
196 void SAL_CALL
installError( sal_Int32 CommandId
,
198 sal_Int32 minorCode
= TASKHANDLER_NO_ERROR
);
201 // void SAL_CALL installError( sal_Int32 CommandId,
202 // sal_Int32 ErrorCode,
203 // rtl::OUString message );
205 // void SAL_CALL installError( sal_Int32 CommandId,
206 // sal_Int32 ErrorCode,
207 // rtl::OUString message );
209 void SAL_CALL
retrieveError( sal_Int32 CommandId
,
210 sal_Int32
&ErrorCode
,
211 sal_Int32
&minorCode
);
214 * Deinstalls the task and evaluates a possibly set error code.
215 * "endTask" throws in case an error code is set the corresponding exception.
218 void SAL_CALL
endTask( sal_Int32 CommandId
,
219 // the physical URL of the object
220 const rtl::OUString
& aUnqPath
,
221 BaseContent
* pContent
);
225 * Handles an interactionrequest
228 void SAL_CALL
handleTask( sal_Int32 CommandId
,
229 const com::sun::star::uno::Reference
< com::sun::star::task::XInteractionRequest
>& request
);
232 * Clears any error which are set on the commandid
235 void SAL_CALL
clearError( sal_Int32
);
238 com::sun::star::uno::Reference
< com::sun::star::task::XInteractionHandler
> SAL_CALL
239 getInteractionHandler( sal_Int32 CommandId
);
241 com::sun::star::uno::Reference
< com::sun::star::ucb::XProgressHandler
> SAL_CALL
242 getProgressHandler( sal_Int32 CommandId
);
244 com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
> SAL_CALL
245 getCommandEnvironment( sal_Int32 CommandId
);
249 } // end namespace TaskHandling