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 .
22 #include "platform_vista.h"
26 #include "requests.hxx"
27 #include "vistatypes.h"
28 #include "FilterContainer.hxx"
29 #include "VistaFilePickerEventHandler.hxx"
30 #include "IVistaFilePickerInternalNotify.hxx"
31 #include "resourceprovider.hxx"
33 #include <cppuhelper/interfacecontainer.h>
34 #include <osl/thread.hxx>
35 #include <osl/conditn.hxx>
36 #include <rtl/ustring.hxx>
46 const ::sal_Int32 FEATURE_AUTOEXTENSION
= 1;
47 const ::sal_Int32 FEATURE_PASSWORD
= 2;
48 const ::sal_Int32 FEATURE_FILTEROPTIONS
= 4;
49 const ::sal_Int32 FEATURE_SELECTION
= 8;
50 const ::sal_Int32 FEATURE_TEMPLATE
= 16;
51 const ::sal_Int32 FEATURE_LINK
= 32;
52 const ::sal_Int32 FEATURE_PREVIEW
= 64;
53 const ::sal_Int32 FEATURE_IMAGETEMPLATE
= 128;
54 const ::sal_Int32 FEATURE_PLAY
= 256;
55 const ::sal_Int32 FEATURE_READONLY
= 512;
56 const ::sal_Int32 FEATURE_VERSION
= 1024;
57 const ::sal_Int32 FEATURE_GPGPASSWORD
= 2048;
58 const ::sal_Int32 FEATURE_IMAGEANCHOR
= 4096;
60 inline constexpr OUStringLiteral
PROP_PICKER_LISTENER(u
"picker_listener" ); // [XFilePickerListenert]
61 inline constexpr OUStringLiteral
PROP_DIALOG_SHOW_RESULT(u
"dialog_show_result" ); // [sal_Bool] true=OK, false=CANCEL
62 inline constexpr OUStringLiteral
PROP_SELECTED_FILES(u
"selected_files" ); // [seq< OUString >] contains all user selected files (can be empty!)
63 inline constexpr OUStringLiteral
PROP_MULTISELECTION_MODE(u
"multiselection_mode"); // [sal_Bool] true=ON, false=OFF
64 inline constexpr OUStringLiteral
PROP_TITLE(u
"title" ); // [OUString]
65 inline constexpr OUStringLiteral
PROP_FILENAME(u
"filename" ); // [OUString]
66 inline constexpr OUStringLiteral
PROP_DIRECTORY(u
"directory" ); // [OUString]
67 inline constexpr OUStringLiteral
PROP_FEATURES(u
"features" ); // [sal_Int32]
68 inline constexpr OUStringLiteral
PROP_TEMPLATE_DESCR(u
"templatedescription"); // [sal_Int32]
69 inline constexpr OUStringLiteral
PROP_FILTER_TITLE(u
"filter_title" ); // [OUString]
70 inline constexpr OUStringLiteral
PROP_FILTER_VALUE(u
"filter_value" ); // [OUString]
71 inline constexpr OUStringLiteral
PROP_FILTER_GROUP(u
"filter-group" ); // [seq< css:beans::StringPair >] contains a group of filters
73 inline constexpr OUStringLiteral
PROP_CONTROL_ID(u
"control_id" ); // [sal_Int16]
74 inline constexpr OUStringLiteral
PROP_CONTROL_ACTION(u
"control_action" ); // [sal_Int16]
75 inline constexpr OUStringLiteral
PROP_CONTROL_VALUE(u
"control_value" ); // [Any]
76 inline constexpr OUStringLiteral
PROP_CONTROL_LABEL(u
"control_label" ); // [OUString]
77 inline constexpr OUStringLiteral
PROP_CONTROL_ENABLE(u
"control_enable" ); // [sal_Bool] true=ON, false=OFF
78 inline constexpr OUStringLiteral
PROP_PARENT_WINDOW(u
"ParentWindow"); //[css::awt::XWindow] preferred parent window
79 inline constexpr OUStringLiteral
STRING_SEPARATOR(u
"------------------------------------------" );
81 class TDialogImplBase
;
83 /** native implementation of the file picker on Vista and upcoming windows versions.
84 * This dialog uses COM internally. Further it marshall every request so it will
85 * be executed on the main thread which is an STA thread !
88 class VistaFilePickerImpl
: public IVistaFilePickerInternalNotify
92 // Workaround made to get input in Template Listbox
93 css::uno::Sequence
< OUString
> m_lItems
;
94 /** used for marshalling requests.
95 * Will be used to map requests to the right implementations.
100 E_ADD_PICKER_LISTENER
,
101 E_REMOVE_PICKER_LISTENER
,
103 E_SET_CURRENT_FILTER
,
104 E_GET_CURRENT_FILTER
,
105 E_CREATE_OPEN_DIALOG
,
106 E_CREATE_SAVE_DIALOG
,
107 E_CREATE_FOLDER_PICKER
,
108 E_SET_MULTISELECTION_MODE
,
114 E_GET_SELECTED_FILES
,
127 // ctor/dtor - nothing special
129 VistaFilePickerImpl();
130 virtual ~VistaFilePickerImpl();
135 void doRequest(Request
& rRequest
);
138 // IVistaFilePickerInternalNotify
140 virtual void onAutoExtensionChanged (bool bChecked
) override
;
141 virtual bool onFileTypeChanged( UINT nTypeIndex
) override
;
142 virtual void onDirectoryChanged() override
;
145 OUString
GetDirectory();
147 /// implementation of request E_ADD_FILEPICKER_LISTENER
148 void impl_sta_addFilePickerListener(Request
& rRequest
);
151 /// implementation of request E_REMOVE_FILEPICKER_LISTENER
152 void impl_sta_removeFilePickerListener(Request
& rRequest
);
155 /// implementation of request E_APPEND_FILTER
156 void impl_sta_appendFilter(Request
& rRequest
);
159 /// implementation of request E_APPEND_FILTERGROUP
160 void impl_sta_appendFilterGroup(Request
& rRequest
);
163 /// implementation of request E_SET_CURRENT_FILTER
164 void impl_sta_setCurrentFilter(Request
& rRequest
);
167 /// implementation of request E_GET_CURRENT_FILTER
168 void impl_sta_getCurrentFilter(Request
& rRequest
);
171 /// implementation of request E_CREATE_OPEN_DIALOG
172 void impl_sta_CreateOpenDialog(Request
& rRequest
);
175 /// implementation of request E_CREATE_SAVE_DIALOG
176 void impl_sta_CreateSaveDialog(Request
& rRequest
);
179 /// implementation of request E_CREATE_FOLDER_PICKER
180 void impl_sta_CreateFolderPicker(Request
& rRequest
);
183 /// implementation of request E_SET_MULTISELECTION_MODE
184 void impl_sta_SetMultiSelectionMode(Request
& rRequest
);
187 /// implementation of request E_SET_TITLE
188 void impl_sta_SetTitle(Request
& rRequest
);
191 /// implementation of request E_SET_FILENAME
192 void impl_sta_SetFileName(Request
& rRequest
);
195 /// implementation of request E_SET_DIRECTORY
196 void impl_sta_SetDirectory(Request
& rRequest
);
199 /// implementation of request E_GET_DIRECTORY
200 void impl_sta_GetDirectory(Request
& rRequest
);
203 /// implementation of request E_SET_DEFAULT_NAME
204 void impl_sta_SetDefaultName(Request
& rRequest
);
207 /// implementation of request E_GET_SELECTED_FILES
208 void impl_sta_getSelectedFiles(Request
& rRequest
);
211 /// implementation of request E_SHOW_DIALOG_MODAL
212 void impl_sta_ShowDialogModal(Request
& rRequest
);
215 /// implementation of request E_SET_CONTROL_VALUE
216 void impl_sta_SetControlValue(Request
& rRequest
);
219 /// implementation of request E_GET_CONTROL_VALUE
220 void impl_sta_GetControlValue(Request
& rRequest
);
223 /// implementation of request E_SET_CONTROL_LABEL
224 void impl_sta_SetControlLabel(Request
& rRequest
);
227 /// implementation of request E_GET_CONTROL_LABEL
228 static void impl_sta_GetControlLabel(Request
& rRequest
);
231 /// implementation of request E_ENABLE_CONTROL
232 void impl_sta_EnableControl(Request
& rRequest
);
234 /** create all needed (optional!) UI controls addressed by the field nFeatures.
235 * The given number nFeatures is used as a flag field. Use const values FEATURE_XXX
238 * Internal new controls will be added to the dialog. Every control can be accessed
239 * by its own control id. Those control ID must be one of the const set
240 * css::ui::dialogs::ExtendedFilePickerElementIds.
242 * @see setControlValue()
243 * @see getControlValue()
244 * @see setControlLabel()
245 * @see getControlLabel()
246 * @see enableControl()
249 * flag field(!) knows all features which must be enabled.
251 void impl_sta_enableFeatures(::sal_Int32 nFeatures
, ::sal_Int32 nTemplate
);
254 /** returns an interface, which can be used to customize the internally used
257 * Because we use two member (open/save dialog) internally, this method
258 * ask the current active one for its customization interface.
260 * @return the customization interface for the current used dialog.
263 TFileDialogCustomize
impl_getCustomizeInterface();
264 TFileDialog
impl_getBaseDialogInterface();
267 /// fill filter list of internal used dialog.
268 void impl_sta_setFiltersOnDialog();
270 void impl_SetDefaultExtension( const OUString
& currentFilter
);
273 template <class TDialogImplClass
> void impl_sta_CreateDialog();
274 void impl_sta_InitDialog(Request
& rRequest
, DWORD nOrFlags
);
277 /// object representing a file dialog
278 std::shared_ptr
<TDialogImplBase
> m_pDialog
;
281 /// @todo document me
282 CFilterContainer m_lFilters
;
285 /** help us to handle dialog events and provide them to interested office
288 TFileDialogEvents m_iEventHandler
;
291 /// @todo document me
296 // handle to parent window
297 HWND m_hParentWindow
;
300 OUString m_sDirectory
;
303 OUString m_sFilename
;
308 } // namespace fpicker
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */