bump product version to 6.1.0.2
[LibreOffice.git] / fpicker / source / win32 / filepicker / VistaFilePickerImpl.hxx
blob8f9314e990aa7f530e8dddd8e7a2f81c977b4be0
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 #ifndef INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX
21 #define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX
23 #include "platform_vista.h"
25 #include <shobjidl.h>
27 #include "asyncrequests.hxx"
28 #include "comptr.hxx"
29 #include "vistatypes.h"
30 #include "FilterContainer.hxx"
31 #include "VistaFilePickerEventHandler.hxx"
32 #include "IVistaFilePickerInternalNotify.hxx"
33 #include "../misc/resourceprovider.hxx"
35 #include <cppuhelper/interfacecontainer.h>
36 #include <cppuhelper/basemutex.hxx>
37 #include <osl/thread.hxx>
38 #include <osl/conditn.hxx>
39 #include <rtl/ustring.hxx>
41 namespace fpicker{
42 namespace win32{
43 namespace vista{
46 // types, const etcpp
49 static const ::sal_Int32 FEATURE_AUTOEXTENSION = 1;
50 static const ::sal_Int32 FEATURE_PASSWORD = 2;
51 static const ::sal_Int32 FEATURE_FILTEROPTIONS = 4;
52 static const ::sal_Int32 FEATURE_SELECTION = 8;
53 static const ::sal_Int32 FEATURE_TEMPLATE = 16;
54 static const ::sal_Int32 FEATURE_LINK = 32;
55 static const ::sal_Int32 FEATURE_PREVIEW = 64;
56 static const ::sal_Int32 FEATURE_IMAGETEMPLATE = 128;
57 static const ::sal_Int32 FEATURE_PLAY = 256;
58 static const ::sal_Int32 FEATURE_READONLY = 512;
59 static const ::sal_Int32 FEATURE_VERSION = 1024;
60 static const ::sal_Int32 FEATURE_GPGPASSWORD = 2048;
61 static const ::sal_Int32 FEATURE_IMAGEANCHOR = 4096;
63 static const OUString PROP_PICKER_LISTENER("picker_listener" ); // [XFilePickerListenert]
64 static const OUString PROP_DIALOG_SHOW_RESULT("dialog_show_result" ); // [sal_Bool] true=OK, false=CANCEL
65 static const OUString PROP_SELECTED_FILES("selected_files" ); // [seq< OUString >] contains all user selected files (can be empty!)
66 static const OUString PROP_MULTISELECTION_MODE("multiselection_mode"); // [sal_Bool] true=ON, false=OFF
67 static const OUString PROP_TITLE("title" ); // [OUString]
68 static const OUString PROP_FILENAME("filename" ); // [OUString]
69 static const OUString PROP_DIRECTORY("directory" ); // [OUString]
70 static const OUString PROP_FEATURES("features" ); // [sal_Int32]
71 static const OUString PROP_TEMPLATE_DESCR("templatedescription"); // [sal_Int32]
72 static const OUString PROP_FILTER_TITLE("filter_title" ); // [OUString]
73 static const OUString PROP_FILTER_VALUE("filter_value" ); // [OUString]
74 static const OUString PROP_FORCE("force" ); // [sal_Bool]
75 static const OUString PROP_FILTER_GROUP("filter-group" ); // [seq< css:beans::StringPair >] contains a group of filters
77 static const OUString PROP_CONTROL_ID("control_id" ); // [sal_Int16]
78 static const OUString PROP_CONTROL_ACTION("control_action" ); // [sal_Int16]
79 static const OUString PROP_CONTROL_VALUE("control_value" ); // [Any]
80 static const OUString PROP_CONTROL_LABEL("control_label" ); // [OUString]
81 static const OUString PROP_CONTROL_ENABLE("control_enable" ); // [sal_Bool] true=ON, false=OFF
82 static const OUString PROP_PARENT_WINDOW("ParentWindow"); //[css::awt::XWindow] preferred parent window
83 static const OUString STRING_SEPARATOR("------------------------------------------" );
86 /** native implementation of the file picker on Vista and upcoming windows versions.
87 * This dialog uses COM internally. Further it marshall every request so it will
88 * be executed within its own STA thread !
91 class VistaFilePickerImpl : private ::cppu::BaseMutex
92 , public RequestHandler
93 , public IVistaFilePickerInternalNotify
95 public:
97 // Workaround made to get input in Template Listbox
98 css::uno::Sequence< OUString > m_lItems;
99 /** used for marshalling requests.
100 * Will be used to map requests to the right implementations.
102 enum ERequest
104 E_NO_REQUEST,
105 E_ADD_PICKER_LISTENER,
106 E_REMOVE_PICKER_LISTENER,
107 E_APPEND_FILTER,
108 E_SET_CURRENT_FILTER,
109 E_GET_CURRENT_FILTER,
110 E_CREATE_OPEN_DIALOG,
111 E_CREATE_SAVE_DIALOG,
112 E_SET_MULTISELECTION_MODE,
113 E_SET_TITLE,
114 E_SET_FILENAME,
115 E_GET_DIRECTORY,
116 E_SET_DIRECTORY,
117 E_SET_DEFAULT_NAME,
118 E_GET_SELECTED_FILES,
119 E_SHOW_DIALOG_MODAL,
120 E_SET_CONTROL_VALUE,
121 E_GET_CONTROL_VALUE,
122 E_SET_CONTROL_LABEL,
123 E_GET_CONTROL_LABEL,
124 E_ENABLE_CONTROL,
125 E_APPEND_FILTERGROUP
128 public:
131 // ctor/dtor - nothing special
133 VistaFilePickerImpl();
134 virtual ~VistaFilePickerImpl() override;
137 // RequestHandler
140 virtual void before() override;
141 virtual void doRequest(const RequestRef& rRequest) override;
142 virtual void after() override;
145 // IVistaFilePickerInternalNotify
147 virtual void onAutoExtensionChanged (bool bChecked) override;
148 virtual bool onFileTypeChanged( UINT nTypeIndex ) override;
150 private:
153 /// implementation of request E_ADD_FILEPICKER_LISTENER
154 void impl_sta_addFilePickerListener(const RequestRef& rRequest);
157 /// implementation of request E_REMOVE_FILEPICKER_LISTENER
158 void impl_sta_removeFilePickerListener(const RequestRef& rRequest);
161 /// implementation of request E_APPEND_FILTER
162 void impl_sta_appendFilter(const RequestRef& rRequest);
165 /// implementation of request E_APPEND_FILTERGROUP
166 void impl_sta_appendFilterGroup(const RequestRef& rRequest);
169 /// implementation of request E_SET_CURRENT_FILTER
170 void impl_sta_setCurrentFilter(const RequestRef& rRequest);
173 /// implementation of request E_GET_CURRENT_FILTER
174 void impl_sta_getCurrentFilter(const RequestRef& rRequest);
177 /// implementation of request E_CREATE_OPEN_DIALOG
178 void impl_sta_CreateOpenDialog(const RequestRef& rRequest);
181 /// implementation of request E_CREATE_SAVE_DIALOG
182 void impl_sta_CreateSaveDialog(const RequestRef& rRequest);
185 /// implementation of request E_SET_MULTISELECTION_MODE
186 void impl_sta_SetMultiSelectionMode(const RequestRef& rRequest);
189 /// implementation of request E_SET_TITLE
190 void impl_sta_SetTitle(const RequestRef& rRequest);
193 /// implementation of request E_SET_FILENAME
194 void impl_sta_SetFileName(const RequestRef& rRequest);
197 /// implementation of request E_SET_DIRECTORY
198 void impl_sta_SetDirectory(const RequestRef& rRequest);
201 /// implementation of request E_GET_DIRECTORY
202 void impl_sta_GetDirectory(const RequestRef& rRequest);
205 /// implementation of request E_SET_DEFAULT_NAME
206 void impl_sta_SetDefaultName(const RequestRef& rRequest);
209 /// implementation of request E_GET_SELECTED_FILES
210 void impl_sta_getSelectedFiles(const RequestRef& rRequest);
213 /// implementation of request E_SHOW_DIALOG_MODAL
214 void impl_sta_ShowDialogModal(const RequestRef& rRequest);
217 /// implementation of request E_SET_CONTROL_VALUE
218 void impl_sta_SetControlValue(const RequestRef& rRequest);
221 /// implementation of request E_GET_CONTROL_VALUE
222 void impl_sta_GetControlValue(const RequestRef& rRequest);
225 /// implementation of request E_SET_CONTROL_LABEL
226 void impl_sta_SetControlLabel(const RequestRef& rRequest);
229 /// implementation of request E_GET_CONTROL_LABEL
230 static void impl_sta_GetControlLabel(const RequestRef& rRequest);
233 /// implementation of request E_ENABLE_CONTROL
234 void impl_sta_EnableControl(const RequestRef& rRequest);
236 /** create all needed (optional!) UI controls addressed by the field nFeatures.
237 * The given number nFeatures is used as a flag field. Use const values FEATURE_XXX
238 * to address it.
240 * Internal new controls will be added to the dialog. Every control can be accessed
241 * by its own control id. Those control ID must be one of the const set
242 * css::ui::dialogs::ExtendedFilePickerElementIds.
244 * @see setControlValue()
245 * @see getControlValue()
246 * @see setControlLabel()
247 * @see getControlLabel()
248 * @see enableControl()
250 * @param nFeatures
251 * flag field(!) knows all features which must be enabled.
253 void impl_sta_enableFeatures(::sal_Int32 nFeatures, ::sal_Int32 nTemplate);
256 /** returns an interface, which can be used to customize the internally used
257 * COM dialog.
259 * Because we use two member (open/save dialog) internally, this method
260 * ask the current active one for its customization interface.
262 * @return the customization interface for the current used dialog.
263 * Must not be null.
265 TFileDialogCustomize impl_getCustomizeInterface();
266 TFileDialog impl_getBaseDialogInterface();
269 /// fill filter list of internal used dialog.
270 void impl_sta_setFiltersOnDialog();
272 void impl_SetDefaultExtension( const OUString& currentFilter );
274 private:
277 /// COM object representing a file open dialog
278 TFileOpenDialog m_iDialogOpen;
281 /// COM object representing a file save dialog
282 TFileSaveDialog m_iDialogSave;
285 /// knows the return state of the last COM call
286 HRESULT m_hLastResult;
289 /// @todo document me
290 CFilterContainer m_lFilters;
293 /** help us to handle dialog events and provide them to interested office
294 * listener.
296 TFileDialogEvents m_iEventHandler;
299 /// @todo document me
300 bool m_bInExecute;
302 bool m_bWasExecuted;
304 // handle to parent window
305 HWND m_hParentWindow;
308 OUString m_sDirectory;
311 OUString m_sFilename;
314 } // namespace vista
315 } // namespace win32
316 } // namespace fpicker
318 #endif // INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */