Update ooo320-m1
[ooovba.git] / fpicker / source / win32 / filepicker / VistaFilePickerEventHandler.hxx
blobad1870d5ee75ba2674939545c3aeabcf63f7b65e
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: VistaFilePickerEventHandler.hxx,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 #ifndef FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
32 #define FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
34 //-----------------------------------------------------------------------------
35 // includes
36 //-----------------------------------------------------------------------------
38 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
39 #pragma warning( disable : 4917 )
40 #endif
42 #include "comptr.hxx"
43 #include "vistatypes.h"
44 #include "IVistaFilePickerInternalNotify.hxx"
46 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
47 #include <com/sun/star/uno/Reference.hxx>
49 #include <cppuhelper/basemutex.hxx>
50 #include <cppuhelper/interfacecontainer.h>
51 #include <osl/interlck.h>
53 #include <shobjidl.h>
55 //-----------------------------------------------------------------------------
56 // namespace
57 //-----------------------------------------------------------------------------
59 #ifdef css
60 #error "Clash on using CSS as namespace define."
61 #else
62 #define css ::com::sun::star
63 #endif
65 namespace fpicker{
66 namespace win32{
67 namespace vista{
69 //-----------------------------------------------------------------------------
70 // types, const etcpp.
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
74 /** todo document me
76 class VistaFilePickerEventHandler : public ::cppu::BaseMutex
77 , public IFileDialogEvents
78 , public IFileDialogControlEvents
80 public:
82 //------------------------------------------------------------------------------------
83 // ctor/dtor
84 //------------------------------------------------------------------------------------
86 VistaFilePickerEventHandler(IVistaFilePickerInternalNotify* pInternalNotify);
87 virtual ~VistaFilePickerEventHandler();
89 //------------------------------------------------------------------------------------
90 // IUnknown
91 //------------------------------------------------------------------------------------
92 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID rIID ,
93 void** ppObject);
94 virtual ULONG STDMETHODCALLTYPE AddRef();
95 virtual ULONG STDMETHODCALLTYPE Release();
97 //------------------------------------------------------------------------------------
98 // IFileDialogEvents
99 //------------------------------------------------------------------------------------
101 STDMETHODIMP OnFileOk(IFileDialog* pDialog);
103 STDMETHODIMP OnFolderChanging(IFileDialog* pDialog,
104 IShellItem* pFolder);
106 STDMETHODIMP OnFolderChange(IFileDialog* pDialog);
108 STDMETHODIMP OnSelectionChange(IFileDialog* pDialog);
110 STDMETHODIMP OnShareViolation(IFileDialog* pDialog ,
111 IShellItem* pItem ,
112 FDE_SHAREVIOLATION_RESPONSE* pResponse);
114 STDMETHODIMP OnTypeChange(IFileDialog* pDialog);
116 STDMETHODIMP OnOverwrite(IFileDialog* pDialog ,
117 IShellItem* pItem ,
118 FDE_OVERWRITE_RESPONSE* pResponse);
120 //------------------------------------------------------------------------------------
121 // IFileDialogControlEvents
122 //------------------------------------------------------------------------------------
124 STDMETHODIMP OnItemSelected(IFileDialogCustomize* pCustomize,
125 DWORD nIDCtl ,
126 DWORD nIDItem );
128 STDMETHODIMP OnButtonClicked(IFileDialogCustomize* pCustomize,
129 DWORD nIDCtl );
131 STDMETHODIMP OnCheckButtonToggled(IFileDialogCustomize* pCustomize,
132 DWORD nIDCtl ,
133 BOOL bChecked );
135 STDMETHODIMP OnControlActivating(IFileDialogCustomize* pCustomize,
136 DWORD nIDCtl );
138 //------------------------------------------------------------------------------------
139 // XFilePickerNotifier
140 //------------------------------------------------------------------------------------
142 virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener )
143 throw( css::uno::RuntimeException );
145 virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener )
146 throw( css::uno::RuntimeException );
148 //------------------------------------------------------------------------------------
149 // native interface
150 //------------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------------
153 /** start listening for file picker events on the given file open dialog COM object.
155 * The broadcaster will be cached internaly so deregistration will be easy.
156 * Further all needed informations are capsulated within this class (e.g. the listener handler).
157 * Nobody outside must know such informations.
159 * Nothing will happen if an inconsistent state will be detected
160 * (means: double registration will be ignored).
162 * @param pBroadcaster
163 * reference to the dialog, where we should start listening.
165 void startListening( const TFileDialog& pBroadcaster );
167 //------------------------------------------------------------------------------------
168 /** stop listening for file picker events on the internaly cached dialog COM object.
170 * The COM dialog provided on the startListeneing() call was cached internaly.
171 * And now its used to deregister this listener. Doing so the also internaly cached
172 * listener handle is used. If listener was not already registered - nothing will happen.
174 void stopListening();
176 public:
178 enum EEventType
180 E_FILE_SELECTION_CHANGED,
181 E_DIRECTORY_CHANGED,
182 E_HELP_REQUESTED,
183 E_CONTROL_STATE_CHANGED,
184 E_DIALOG_SIZE_CHANGED
187 private:
189 //------------------------------------------------------------------------------------
190 /// @todo document me
191 void impl_sendEvent( EEventType eEventType,
192 ::sal_Int16 nControlID);
194 private:
196 //------------------------------------------------------------------------------------
197 /// ref count for AddRef/Release()
198 oslInterlockedCount m_nRefCount;
200 //------------------------------------------------------------------------------------
201 /// unique handle for this listener provided by the broadcaster on registration time
202 DWORD m_nListenerHandle;
204 //------------------------------------------------------------------------------------
205 /// cached file dialog instance (there we listen for events)
206 TFileDialog m_pDialog;
208 //---------------------------------------------------------------------
209 IVistaFilePickerInternalNotify* m_pInternalNotify;
211 //---------------------------------------------------------------------
212 /** used to inform file picker listener asynchronously.
213 * Those listener must be called asynchronously .. because
214 * every request will block the caller thread. Mostly that will be
215 * the main thread of the office. Further the global SolarMutex will
216 * be locked during this time. If we call our listener back now synchronously ..
217 * we will block on SolarMutex.acquire() forever .-))
219 ::cppu::OMultiTypeInterfaceContainerHelper m_lListener;
222 } // namespace vista
223 } // namespace win32
224 } // namespace fpicker
226 #undef css
228 #endif // FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX