Update ooo320-m1
[ooovba.git] / ucb / source / ucp / file / filtask.hxx
blobbcb57587a372ffb3087f4426865474177bdd024d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filtask.hxx,v $
10 * $Revision: 1.16 $
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 ************************************************************************/
30 #ifndef _FILTASK_HXX_
31 #define _FILTASK_HXX_
32 #endif
34 #include <hash_map>
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"
45 #endif
48 namespace fileaccess
50 class BaseContent;
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 )
58 * and
59 * getProgressHandler();
63 class TaskManager
65 protected:
67 class TaskHandling
69 private:
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;
78 public:
80 TaskHandling(
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 ) )
83 : m_bAbort( false ),
84 m_bHandled( false ),
85 m_nErrorCode( TASKHANDLER_NO_ERROR ),
86 m_nMinorCode( TASKHANDLER_NO_ERROR ),
87 m_xInteractionHandler( 0 ),
88 m_xProgressHandler( 0 ),
89 m_xCommandEnvironment( xCommandEnv )
93 void SAL_CALL abort()
95 m_bAbort = true;
98 bool SAL_CALL isAborted()
100 return m_bAbort;
103 void setHandled()
105 m_bHandled = true;
108 bool isHandled()
110 return true;
113 void clearError()
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()
128 return m_nErrorCode;
131 sal_Int32 SAL_CALL getMinorErrorCode()
133 return m_nMinorCode;
136 com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler > SAL_CALL
137 getProgressHandler()
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;
166 private:
168 osl::Mutex m_aMutex;
169 sal_Int32 m_nCommandId;
170 TaskMap m_aTaskMap;
173 public:
175 TaskManager();
176 virtual ~TaskManager();
178 void SAL_CALL startTask(
179 sal_Int32 CommandId,
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
190 * filerror.hxx.
191 * The minor code refines the information given in ErrorCode.
194 void SAL_CALL clearError();
196 void SAL_CALL installError( sal_Int32 CommandId,
197 sal_Int32 ErrorCode,
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