1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
21 #define FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
24 #pragma warning( disable : 4917 )
29 // Without IFileDialogCustomize we can't do this
30 #ifdef __IFileDialogCustomize_INTERFACE_DEFINED__
33 #include "vistatypes.h"
34 #include "IVistaFilePickerInternalNotify.hxx"
36 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
37 #include <com/sun/star/uno/Reference.hxx>
39 #include <cppuhelper/basemutex.hxx>
40 #include <cppuhelper/interfacecontainer.h>
41 #include <osl/interlck.h>
47 //-----------------------------------------------------------------------------
48 // types, const etcpp.
49 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
54 class VistaFilePickerEventHandler
: public ::cppu::BaseMutex
55 , public IFileDialogEvents
56 , public IFileDialogControlEvents
60 //------------------------------------------------------------------------------------
62 //------------------------------------------------------------------------------------
64 VistaFilePickerEventHandler(IVistaFilePickerInternalNotify
* pInternalNotify
);
65 virtual ~VistaFilePickerEventHandler();
67 //------------------------------------------------------------------------------------
69 //------------------------------------------------------------------------------------
70 virtual HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID rIID
,
72 virtual ULONG STDMETHODCALLTYPE
AddRef();
73 virtual ULONG STDMETHODCALLTYPE
Release();
75 //------------------------------------------------------------------------------------
77 //------------------------------------------------------------------------------------
79 STDMETHODIMP
OnFileOk(IFileDialog
* pDialog
);
81 STDMETHODIMP
OnFolderChanging(IFileDialog
* pDialog
,
84 STDMETHODIMP
OnFolderChange(IFileDialog
* pDialog
);
86 STDMETHODIMP
OnSelectionChange(IFileDialog
* pDialog
);
88 STDMETHODIMP
OnShareViolation(IFileDialog
* pDialog
,
90 FDE_SHAREVIOLATION_RESPONSE
* pResponse
);
92 STDMETHODIMP
OnTypeChange(IFileDialog
* pDialog
);
94 STDMETHODIMP
OnOverwrite(IFileDialog
* pDialog
,
96 FDE_OVERWRITE_RESPONSE
* pResponse
);
98 //------------------------------------------------------------------------------------
99 // IFileDialogControlEvents
100 //------------------------------------------------------------------------------------
102 STDMETHODIMP
OnItemSelected(IFileDialogCustomize
* pCustomize
,
106 STDMETHODIMP
OnButtonClicked(IFileDialogCustomize
* pCustomize
,
109 STDMETHODIMP
OnCheckButtonToggled(IFileDialogCustomize
* pCustomize
,
113 STDMETHODIMP
OnControlActivating(IFileDialogCustomize
* pCustomize
,
116 //------------------------------------------------------------------------------------
117 // XFilePickerNotifier
118 //------------------------------------------------------------------------------------
120 virtual void SAL_CALL
addFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
)
121 throw( css::uno::RuntimeException
);
123 virtual void SAL_CALL
removeFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
)
124 throw( css::uno::RuntimeException
);
126 //------------------------------------------------------------------------------------
128 //------------------------------------------------------------------------------------
130 //------------------------------------------------------------------------------------
131 /** start listening for file picker events on the given file open dialog COM object.
133 * The broadcaster will be cached internaly so deregistration will be easy.
134 * Further all needed information are capsulated within this class (e.g. the listener handler).
135 * Nobody outside must know such information.
137 * Nothing will happen if an inconsistent state will be detected
138 * (means: double registration will be ignored).
140 * @param pBroadcaster
141 * reference to the dialog, where we should start listening.
143 void startListening( const TFileDialog
& pBroadcaster
);
145 //------------------------------------------------------------------------------------
146 /** stop listening for file picker events on the internaly cached dialog COM object.
148 * The COM dialog provided on the startListeneing() call was cached internaly.
149 * And now its used to deregister this listener. Doing so the also internaly cached
150 * listener handle is used. If listener was not already registered - nothing will happen.
152 void stopListening();
158 E_FILE_SELECTION_CHANGED
,
161 E_CONTROL_STATE_CHANGED
,
162 E_DIALOG_SIZE_CHANGED
167 //------------------------------------------------------------------------------------
168 /// @todo document me
169 void impl_sendEvent( EEventType eEventType
,
170 ::sal_Int16 nControlID
);
174 //------------------------------------------------------------------------------------
175 /// ref count for AddRef/Release()
176 oslInterlockedCount m_nRefCount
;
178 //------------------------------------------------------------------------------------
179 /// unique handle for this listener provided by the broadcaster on registration time
180 DWORD m_nListenerHandle
;
182 //------------------------------------------------------------------------------------
183 /// cached file dialog instance (there we listen for events)
184 TFileDialog m_pDialog
;
186 //---------------------------------------------------------------------
187 IVistaFilePickerInternalNotify
* m_pInternalNotify
;
189 //---------------------------------------------------------------------
190 /** used to inform file picker listener asynchronously.
191 * Those listener must be called asynchronously .. because
192 * every request will block the caller thread. Mostly that will be
193 * the main thread of the office. Further the global SolarMutex will
194 * be locked during this time. If we call our listener back now synchronously ..
195 * we will block on SolarMutex.acquire() forever .-))
197 ::cppu::OMultiTypeInterfaceContainerHelper m_lListener
;
202 } // namespace fpicker
204 #endif // __IFileDialogCustomize_INTERFACE_DEFINED__
206 #endif // FPICKER_WIN32_VISTA_FILEPICKER_EVENTHANDLER_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */