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_VISTAFILEPICKERIMPL_HXX
21 #define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX
23 #include "platform_vista.h"
27 #include "asyncrequests.hxx"
29 #include "vistatypes.h"
30 #include "FilterContainer.hxx"
31 #include "VistaFilePickerEventHandler.hxx"
32 #include "IVistaFilePickerInternalNotify.hxx"
33 #include "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>
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
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.
105 E_ADD_PICKER_LISTENER
,
106 E_REMOVE_PICKER_LISTENER
,
108 E_SET_CURRENT_FILTER
,
109 E_GET_CURRENT_FILTER
,
110 E_CREATE_OPEN_DIALOG
,
111 E_CREATE_SAVE_DIALOG
,
112 E_CREATE_FOLDER_PICKER
,
113 E_SET_MULTISELECTION_MODE
,
119 E_GET_SELECTED_FILES
,
132 // ctor/dtor - nothing special
134 VistaFilePickerImpl();
135 virtual ~VistaFilePickerImpl() override
;
141 virtual void before() override
;
142 virtual void doRequest(const RequestRef
& rRequest
) override
;
143 virtual void after() override
;
146 // IVistaFilePickerInternalNotify
148 virtual void onAutoExtensionChanged (bool bChecked
) override
;
149 virtual bool onFileTypeChanged( UINT nTypeIndex
) override
;
154 /// implementation of request E_ADD_FILEPICKER_LISTENER
155 void impl_sta_addFilePickerListener(const RequestRef
& rRequest
);
158 /// implementation of request E_REMOVE_FILEPICKER_LISTENER
159 void impl_sta_removeFilePickerListener(const RequestRef
& rRequest
);
162 /// implementation of request E_APPEND_FILTER
163 void impl_sta_appendFilter(const RequestRef
& rRequest
);
166 /// implementation of request E_APPEND_FILTERGROUP
167 void impl_sta_appendFilterGroup(const RequestRef
& rRequest
);
170 /// implementation of request E_SET_CURRENT_FILTER
171 void impl_sta_setCurrentFilter(const RequestRef
& rRequest
);
174 /// implementation of request E_GET_CURRENT_FILTER
175 void impl_sta_getCurrentFilter(const RequestRef
& rRequest
);
178 /// implementation of request E_CREATE_OPEN_DIALOG
179 void impl_sta_CreateOpenDialog(const RequestRef
& rRequest
);
182 /// implementation of request E_CREATE_SAVE_DIALOG
183 void impl_sta_CreateSaveDialog(const RequestRef
& rRequest
);
186 /// implementation of request E_CREATE_FOLDER_PICKER
187 void impl_sta_CreateFolderPicker(const RequestRef
& rRequest
);
190 /// implementation of request E_SET_MULTISELECTION_MODE
191 void impl_sta_SetMultiSelectionMode(const RequestRef
& rRequest
);
194 /// implementation of request E_SET_TITLE
195 void impl_sta_SetTitle(const RequestRef
& rRequest
);
198 /// implementation of request E_SET_FILENAME
199 void impl_sta_SetFileName(const RequestRef
& rRequest
);
202 /// implementation of request E_SET_DIRECTORY
203 void impl_sta_SetDirectory(const RequestRef
& rRequest
);
206 /// implementation of request E_GET_DIRECTORY
207 void impl_sta_GetDirectory(const RequestRef
& rRequest
);
210 /// implementation of request E_SET_DEFAULT_NAME
211 void impl_sta_SetDefaultName(const RequestRef
& rRequest
);
214 /// implementation of request E_GET_SELECTED_FILES
215 void impl_sta_getSelectedFiles(const RequestRef
& rRequest
);
218 /// implementation of request E_SHOW_DIALOG_MODAL
219 void impl_sta_ShowDialogModal(const RequestRef
& rRequest
);
222 /// implementation of request E_SET_CONTROL_VALUE
223 void impl_sta_SetControlValue(const RequestRef
& rRequest
);
226 /// implementation of request E_GET_CONTROL_VALUE
227 void impl_sta_GetControlValue(const RequestRef
& rRequest
);
230 /// implementation of request E_SET_CONTROL_LABEL
231 void impl_sta_SetControlLabel(const RequestRef
& rRequest
);
234 /// implementation of request E_GET_CONTROL_LABEL
235 static void impl_sta_GetControlLabel(const RequestRef
& rRequest
);
238 /// implementation of request E_ENABLE_CONTROL
239 void impl_sta_EnableControl(const RequestRef
& rRequest
);
241 /** create all needed (optional!) UI controls addressed by the field nFeatures.
242 * The given number nFeatures is used as a flag field. Use const values FEATURE_XXX
245 * Internal new controls will be added to the dialog. Every control can be accessed
246 * by its own control id. Those control ID must be one of the const set
247 * css::ui::dialogs::ExtendedFilePickerElementIds.
249 * @see setControlValue()
250 * @see getControlValue()
251 * @see setControlLabel()
252 * @see getControlLabel()
253 * @see enableControl()
256 * flag field(!) knows all features which must be enabled.
258 void impl_sta_enableFeatures(::sal_Int32 nFeatures
, ::sal_Int32 nTemplate
);
261 /** returns an interface, which can be used to customize the internally used
264 * Because we use two member (open/save dialog) internally, this method
265 * ask the current active one for its customization interface.
267 * @return the customization interface for the current used dialog.
270 TFileDialogCustomize
impl_getCustomizeInterface();
271 TFileDialog
impl_getBaseDialogInterface();
274 /// fill filter list of internal used dialog.
275 void impl_sta_setFiltersOnDialog();
277 void impl_SetDefaultExtension( const OUString
& currentFilter
);
280 enum class PickerDialog
287 void impl_sta_CreateDialog(const RequestRef
& rRequest
, PickerDialog eType
, DWORD nOrFlags
);
290 /// COM object representing a file open dialog
291 TFileOpenDialog m_iDialogOpen
;
294 /// COM object representing a file save dialog
295 TFileSaveDialog m_iDialogSave
;
298 /// COM object representing a folder picker dialog
299 TFolderPickerDialog m_iFolderPicker
;
302 /// knows the return state of the last COM call
303 HRESULT m_hLastResult
;
306 /// @todo document me
307 CFilterContainer m_lFilters
;
310 /** help us to handle dialog events and provide them to interested office
313 TFileDialogEvents m_iEventHandler
;
316 /// @todo document me
321 // handle to parent window
322 HWND m_hParentWindow
;
325 OUString m_sDirectory
;
328 OUString m_sFilename
;
333 } // namespace fpicker
335 #endif // INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_VISTAFILEPICKERIMPL_HXX
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */