calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / fpicker / source / win32 / VistaFilePickerEventHandler.hxx
blobb27ef7326f3512c4113843a3c1ab432ced339a9b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <shobjidl.h>
24 #include "vistatypes.h"
25 #include "IVistaFilePickerInternalNotify.hxx"
27 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <comphelper/multicontainer2.hxx>
32 #include <osl/interlck.h>
34 namespace fpicker{
35 namespace win32{
36 namespace vista{
39 // types, const etcpp.
42 /** todo document me
44 class VistaFilePickerEventHandler : public ::cppu::BaseMutex
45 , public IFileDialogEvents
46 , public IFileDialogControlEvents
48 public:
51 // ctor/dtor
54 explicit VistaFilePickerEventHandler(IVistaFilePickerInternalNotify* pInternalNotify);
55 virtual ~VistaFilePickerEventHandler();
58 // IUnknown
60 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID rIID ,
61 void** ppObject) override;
62 virtual ULONG STDMETHODCALLTYPE AddRef() override;
63 virtual ULONG STDMETHODCALLTYPE Release() override;
66 // IFileDialogEvents
69 STDMETHODIMP OnFileOk(IFileDialog* pDialog) override;
71 STDMETHODIMP OnFolderChanging(IFileDialog* pDialog,
72 IShellItem* pFolder) override;
74 STDMETHODIMP OnFolderChange(IFileDialog* pDialog) override;
76 STDMETHODIMP OnSelectionChange(IFileDialog* pDialog) override;
78 STDMETHODIMP OnShareViolation(IFileDialog* pDialog ,
79 IShellItem* pItem ,
80 FDE_SHAREVIOLATION_RESPONSE* pResponse) override;
82 STDMETHODIMP OnTypeChange(IFileDialog* pDialog) override;
84 STDMETHODIMP OnOverwrite(IFileDialog* pDialog ,
85 IShellItem* pItem ,
86 FDE_OVERWRITE_RESPONSE* pResponse) override;
89 // IFileDialogControlEvents
92 STDMETHODIMP OnItemSelected(IFileDialogCustomize* pCustomize,
93 DWORD nIDCtl ,
94 DWORD nIDItem ) override;
96 STDMETHODIMP OnButtonClicked(IFileDialogCustomize* pCustomize,
97 DWORD nIDCtl ) override;
99 STDMETHODIMP OnCheckButtonToggled(IFileDialogCustomize* pCustomize,
100 DWORD nIDCtl ,
101 BOOL bChecked ) override;
103 STDMETHODIMP OnControlActivating(IFileDialogCustomize* pCustomize,
104 DWORD nIDCtl ) override;
107 // XFilePickerNotifier
109 /// @throws css::uno::RuntimeException
110 virtual void addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener );
112 /// @throws css::uno::RuntimeException
113 virtual void removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener );
116 // native interface
119 /** start listening for file picker events on the given file open dialog COM object.
121 * The broadcaster will be cached internally so deregistration will be easy.
122 * Further all needed information is capsulated within this class (e.g. the listener handler).
123 * Nobody outside must know such information.
125 * Nothing will happen if an inconsistent state will be detected
126 * (means: double registration will be ignored).
128 * @param pBroadcaster
129 * reference to the dialog, where we should start listening.
131 void startListening( const TFileDialog& pBroadcaster );
134 /** stop listening for file picker events on the internally cached dialog COM object.
136 * The COM dialog provided on the startListening() call was cached internally.
137 * And now it's used to deregister this listener. Doing so the also internally cached
138 * listener handle is used. If listener was not already registered - nothing will happen.
140 void stopListening();
142 public:
144 enum EEventType
146 E_FILE_SELECTION_CHANGED,
147 E_DIRECTORY_CHANGED,
148 E_HELP_REQUESTED,
149 E_CONTROL_STATE_CHANGED,
150 E_DIALOG_SIZE_CHANGED
153 private:
156 /// @todo document me
157 void impl_sendEvent( EEventType eEventType,
158 ::sal_Int16 nControlID);
160 private:
163 /// ref count for AddRef/Release()
164 oslInterlockedCount m_nRefCount;
167 /// unique handle for this listener provided by the broadcaster on registration time
168 DWORD m_nListenerHandle;
171 /// cached file dialog instance (there we listen for events)
172 TFileDialog m_pDialog;
175 IVistaFilePickerInternalNotify* m_pInternalNotify;
178 /** used to inform file picker listener asynchronously.
179 * Those listener must be called asynchronously .. because
180 * every request will block the caller thread. Mostly that will be
181 * the main thread of the office. Further the global SolarMutex will
182 * be locked during this time. If we call our listener back now synchronously ..
183 * we will block on SolarMutex.acquire() forever .-))
185 comphelper::OMultiTypeInterfaceContainerHelper2 m_lListener;
188 } // namespace vista
189 } // namespace win32
190 } // namespace fpicker
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */