Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / file / filtask.hxx
blobf34ef10c88d20672146605bfe7dd6e7a183c798d
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 ************************************************************************/
28 #ifndef _FILTASK_HXX_
29 #define _FILTASK_HXX_
30 #endif
32 #include <boost/unordered_map.hpp>
33 #include <rtl/ustring.hxx>
35 #include "osl/mutex.hxx"
36 #include <com/sun/star/ucb/DuplicateCommandIdentifierException.hpp>
37 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
38 #include <com/sun/star/ucb/XProgressHandler.hpp>
39 #include <com/sun/star/task/XInteractionHandler.hpp>
40 #include <com/sun/star/task/XInteractionRequest.hpp>
41 #include "filerror.hxx"
43 namespace fileaccess
45 class BaseContent;
48 * This implementation is inherited by class fileaccess::shell.
49 * The relevant methods in this class all have as first argument the CommandId,
50 * so if necessary, every method has access to its relevant XInteractionHandler and
51 * XProgressHandler.
55 class TaskManager
57 protected:
59 class TaskHandling
61 private:
63 bool m_bAbort,m_bHandled;
64 sal_Int32 m_nErrorCode,m_nMinorCode;
65 com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > m_xInteractionHandler;
66 com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler > m_xProgressHandler;
67 com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCommandEnvironment;
70 public:
72 TaskHandling(
73 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xCommandEnv
74 = com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >( 0 ) )
75 : m_bAbort( false ),
76 m_bHandled( false ),
77 m_nErrorCode( TASKHANDLER_NO_ERROR ),
78 m_nMinorCode( TASKHANDLER_NO_ERROR ),
79 m_xInteractionHandler( 0 ),
80 m_xProgressHandler( 0 ),
81 m_xCommandEnvironment( xCommandEnv )
85 void SAL_CALL abort()
87 m_bAbort = true;
90 void setHandled()
92 m_bHandled = true;
95 bool isHandled() const
97 return true;
100 void clearError()
102 m_nErrorCode = TASKHANDLER_NO_ERROR;
103 m_nMinorCode = TASKHANDLER_NO_ERROR;
106 void SAL_CALL installError( sal_Int32 nErrorCode,
107 sal_Int32 nMinorCode = TASKHANDLER_NO_ERROR )
109 m_nErrorCode = nErrorCode;
110 m_nMinorCode = nMinorCode;
113 sal_Int32 SAL_CALL getInstalledError()
115 return m_nErrorCode;
118 sal_Int32 SAL_CALL getMinorErrorCode()
120 return m_nMinorCode;
123 com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler > SAL_CALL
124 getProgressHandler()
126 if( ! m_xProgressHandler.is() && m_xCommandEnvironment.is() )
127 m_xProgressHandler = m_xCommandEnvironment->getProgressHandler();
129 return m_xProgressHandler;
132 com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > SAL_CALL
133 getInteractionHandler()
135 if( ! m_xInteractionHandler.is() && m_xCommandEnvironment.is() )
136 m_xInteractionHandler = m_xCommandEnvironment->getInteractionHandler();
138 return m_xInteractionHandler;
141 com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > SAL_CALL
142 getCommandEnvironment()
144 return m_xCommandEnvironment;
147 }; // end class TaskHandling
150 typedef boost::unordered_map< sal_Int32,TaskHandling,boost::hash< sal_Int32 > > TaskMap;
153 private:
155 osl::Mutex m_aMutex;
156 sal_Int32 m_nCommandId;
157 TaskMap m_aTaskMap;
160 public:
162 TaskManager();
163 virtual ~TaskManager();
165 void SAL_CALL startTask(
166 sal_Int32 CommandId,
167 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xCommandEnv )
168 throw( com::sun::star::ucb::DuplicateCommandIdentifierException );
170 sal_Int32 SAL_CALL getCommandId( void );
171 void SAL_CALL abort( sal_Int32 CommandId );
175 * The error code may be one of the error codes defined in
176 * filerror.hxx.
177 * The minor code refines the information given in ErrorCode.
180 void SAL_CALL clearError();
182 void SAL_CALL installError( sal_Int32 CommandId,
183 sal_Int32 ErrorCode,
184 sal_Int32 minorCode = TASKHANDLER_NO_ERROR );
186 void SAL_CALL retrieveError( sal_Int32 CommandId,
187 sal_Int32 &ErrorCode,
188 sal_Int32 &minorCode);
191 * Deinstalls the task and evaluates a possibly set error code.
192 * "endTask" throws in case an error code is set the corresponding exception.
195 void SAL_CALL endTask( sal_Int32 CommandId,
196 // the physical URL of the object
197 const rtl::OUString& aUnqPath,
198 BaseContent* pContent);
202 * Handles an interactionrequest
205 void SAL_CALL handleTask( sal_Int32 CommandId,
206 const com::sun::star::uno::Reference< com::sun::star::task::XInteractionRequest >& request );
209 * Clears any error which are set on the commandid
212 void SAL_CALL clearError( sal_Int32 );
216 } // end namespace TaskHandling
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */