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 INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKEREVENTHANDLER_HXX
21 #define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKEREVENTHANDLER_HXX
26 #include "vistatypes.h"
27 #include "IVistaFilePickerInternalNotify.hxx"
29 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 #include <cppuhelper/interfacecontainer.h>
34 #include <osl/interlck.h>
41 // types, const etcpp.
46 class VistaFilePickerEventHandler
: public ::cppu::BaseMutex
47 , public IFileDialogEvents
48 , public IFileDialogControlEvents
56 explicit VistaFilePickerEventHandler(IVistaFilePickerInternalNotify
* pInternalNotify
);
57 virtual ~VistaFilePickerEventHandler();
62 virtual HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID rIID
,
63 void** ppObject
) override
;
64 virtual ULONG STDMETHODCALLTYPE
AddRef() override
;
65 virtual ULONG STDMETHODCALLTYPE
Release() override
;
71 STDMETHODIMP
OnFileOk(IFileDialog
* pDialog
) override
;
73 STDMETHODIMP
OnFolderChanging(IFileDialog
* pDialog
,
74 IShellItem
* pFolder
) override
;
76 STDMETHODIMP
OnFolderChange(IFileDialog
* pDialog
) override
;
78 STDMETHODIMP
OnSelectionChange(IFileDialog
* pDialog
) override
;
80 STDMETHODIMP
OnShareViolation(IFileDialog
* pDialog
,
82 FDE_SHAREVIOLATION_RESPONSE
* pResponse
) override
;
84 STDMETHODIMP
OnTypeChange(IFileDialog
* pDialog
) override
;
86 STDMETHODIMP
OnOverwrite(IFileDialog
* pDialog
,
88 FDE_OVERWRITE_RESPONSE
* pResponse
) override
;
91 // IFileDialogControlEvents
94 STDMETHODIMP
OnItemSelected(IFileDialogCustomize
* pCustomize
,
96 DWORD nIDItem
) override
;
98 STDMETHODIMP
OnButtonClicked(IFileDialogCustomize
* pCustomize
,
99 DWORD nIDCtl
) override
;
101 STDMETHODIMP
OnCheckButtonToggled(IFileDialogCustomize
* pCustomize
,
103 BOOL bChecked
) override
;
105 STDMETHODIMP
OnControlActivating(IFileDialogCustomize
* pCustomize
,
106 DWORD nIDCtl
) override
;
109 // XFilePickerNotifier
111 /// @throws css::uno::RuntimeException
112 virtual void addFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
);
114 /// @throws css::uno::RuntimeException
115 virtual void removeFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
);
121 /** start listening for file picker events on the given file open dialog COM object.
123 * The broadcaster will be cached internally so deregistration will be easy.
124 * Further all needed information is capsulated within this class (e.g. the listener handler).
125 * Nobody outside must know such information.
127 * Nothing will happen if an inconsistent state will be detected
128 * (means: double registration will be ignored).
130 * @param pBroadcaster
131 * reference to the dialog, where we should start listening.
133 void startListening( const TFileDialog
& pBroadcaster
);
136 /** stop listening for file picker events on the internally cached dialog COM object.
138 * The COM dialog provided on the startListening() call was cached internally.
139 * And now it's used to deregister this listener. Doing so the also internally cached
140 * listener handle is used. If listener was not already registered - nothing will happen.
142 void stopListening();
148 E_FILE_SELECTION_CHANGED
,
151 E_CONTROL_STATE_CHANGED
,
152 E_DIALOG_SIZE_CHANGED
158 /// @todo document me
159 void impl_sendEvent( EEventType eEventType
,
160 ::sal_Int16 nControlID
);
165 /// ref count for AddRef/Release()
166 oslInterlockedCount m_nRefCount
;
169 /// unique handle for this listener provided by the broadcaster on registration time
170 DWORD m_nListenerHandle
;
173 /// cached file dialog instance (there we listen for events)
174 TFileDialog m_pDialog
;
177 IVistaFilePickerInternalNotify
* m_pInternalNotify
;
180 /** used to inform file picker listener asynchronously.
181 * Those listener must be called asynchronously .. because
182 * every request will block the caller thread. Mostly that will be
183 * the main thread of the office. Further the global SolarMutex will
184 * be locked during this time. If we call our listener back now synchronously ..
185 * we will block on SolarMutex.acquire() forever .-))
187 ::cppu::OMultiTypeInterfaceContainerHelper m_lListener
;
192 } // namespace fpicker
194 #endif // INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKEREVENTHANDLER_HXX
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */