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: VistaFilePickerEventHandler.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 ************************************************************************/
31 #ifndef FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
32 #define FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
39 #pragma warning( disable : 4917 )
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>
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
60 #error "Clash on using CSS as namespace define."
62 #define css ::com::sun::star
69 //-----------------------------------------------------------------------------
70 // types, const etcpp.
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
76 class VistaFilePickerEventHandler
: public ::cppu::BaseMutex
77 , public IFileDialogEvents
78 , public IFileDialogControlEvents
82 //------------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------------
86 VistaFilePickerEventHandler(IVistaFilePickerInternalNotify
* pInternalNotify
);
87 virtual ~VistaFilePickerEventHandler();
89 //------------------------------------------------------------------------------------
91 //------------------------------------------------------------------------------------
92 virtual HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID rIID
,
94 virtual ULONG STDMETHODCALLTYPE
AddRef();
95 virtual ULONG STDMETHODCALLTYPE
Release();
97 //------------------------------------------------------------------------------------
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
,
112 FDE_SHAREVIOLATION_RESPONSE
* pResponse
);
114 STDMETHODIMP
OnTypeChange(IFileDialog
* pDialog
);
116 STDMETHODIMP
OnOverwrite(IFileDialog
* pDialog
,
118 FDE_OVERWRITE_RESPONSE
* pResponse
);
120 //------------------------------------------------------------------------------------
121 // IFileDialogControlEvents
122 //------------------------------------------------------------------------------------
124 STDMETHODIMP
OnItemSelected(IFileDialogCustomize
* pCustomize
,
128 STDMETHODIMP
OnButtonClicked(IFileDialogCustomize
* pCustomize
,
131 STDMETHODIMP
OnCheckButtonToggled(IFileDialogCustomize
* pCustomize
,
135 STDMETHODIMP
OnControlActivating(IFileDialogCustomize
* pCustomize
,
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 //------------------------------------------------------------------------------------
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();
180 E_FILE_SELECTION_CHANGED
,
183 E_CONTROL_STATE_CHANGED
,
184 E_DIALOG_SIZE_CHANGED
189 //------------------------------------------------------------------------------------
190 /// @todo document me
191 void impl_sendEvent( EEventType eEventType
,
192 ::sal_Int16 nControlID
);
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
;
224 } // namespace fpicker
228 #endif // FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX