LibreOffice Module sfx2 (master) 1
filedlghelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SFX2_FILEDLGHELPER_HXX
20#define INCLUDED_SFX2_FILEDLGHELPER_HXX
21
22#include <sal/config.h>
23#include <sfx2/dllapi.h>
24#include <sal/types.h>
25#include <com/sun/star/uno/Sequence.hxx>
26
27#include <rtl/ref.hxx>
28#include <rtl/ustring.hxx>
30#include <tools/link.hxx>
33
34#include <memory>
35#include <optional>
36#include <vector>
37
39{
40 class XFilePicker3;
41 class XFolderPicker2;
42 struct FilePickerEvent;
43 struct DialogClosedEvent;
44}
45namespace com::sun::star::awt { class XWindow; }
46namespace com::sun::star::uno { template <typename > class Reference; }
47namespace com::sun::star::uno { class XComponentContext; }
48namespace weld { class Window; }
49
50class Graphic;
51class SfxFilter;
52class SfxItemSet;
53class SfxAllItemSet;
54
55enum class FileDialogFlags {
56 NONE = 0x00,
57 Insert = 0x01, // turn Open into Insert dialog
58 Export = 0x02, // turn Save into Export dialog
59 SaveACopy = 0x04, // turn Save into Save a Copy dialog
60 MultiSelection = 0x08,
61 Graphic = 0x10, // register graphic formats
63 SignPDF = 0x20,
64 InsertCompare = 0x40,
65 InsertMerge = 0x80,
66};
67namespace o3tl {
68 template<> struct typed_flags<FileDialogFlags> : is_typed_flags<FileDialogFlags, 0xFF> {};
69}
70
71inline constexpr OUStringLiteral FILEDIALOG_FILTER_ALL = u"*.*";
72
73namespace sfx2 {
74
75class FileDialogHelper_Impl;
76
78{
79public:
80 // context where the FileDialogHelper is used
82 {
138 XMLFilterSettings
139 };
140 static OUString contextToString(Context context);
141
142private:
145
147
148
149public:
150 FileDialogHelper(sal_Int16 nDialogType,
151 FileDialogFlags nFlags,
152 weld::Window* pPreferredParent);
153
154 FileDialogHelper(sal_Int16 nDialogType,
155 FileDialogFlags nFlags,
156 const OUString& rFactory,
157 SfxFilterFlags nMust,
158 SfxFilterFlags nDont,
159 weld::Window* pPreferredParent);
160
161 FileDialogHelper(sal_Int16 nDialogType,
162 FileDialogFlags nFlags,
163 const OUString& rFactory,
164 sal_Int16 nDialog,
165 SfxFilterFlags nMust,
166 SfxFilterFlags nDont,
167 const OUString& rStandardDir,
168 const css::uno::Sequence< OUString >& rDenyList,
169 weld::Window* pPreferredParent);
170
171 FileDialogHelper(sal_Int16 nDialogType,
172 FileDialogFlags nFlags,
173 const OUString& aFilterUIName,
174 std::u16string_view aExtName,
175 const OUString& rStandardDir,
176 const css::uno::Sequence< OUString >& rDenyList,
177 weld::Window* pPreferredParent);
178
179 virtual ~FileDialogHelper();
180
183
185 void StartExecuteModal( const Link<FileDialogHelper*,void>& rEndDialogHdl );
186 ErrCode const & GetError() const { return m_nError; }
187 sal_Int16 GetDialogType() const;
188 bool IsPasswordEnabled() const;
189 OUString GetRealFilter() const;
190
191 void SetTitle( const OUString& rNewTitle );
192 OUString GetPath() const;
193
199 css::uno::Sequence< OUString > GetMPath() const;
200
202 css::uno::Sequence< OUString > GetSelectedFiles() const;
203
204 void AddFilter( const OUString& rFilterName, const OUString& rExtension );
205 void SetCurrentFilter( const OUString& rFilter );
206
217 void SetDisplayDirectory( const OUString& rPath );
218
228 void SetDisplayFolder( const OUString& _rURL );
229
242 void SetFileName( const OUString& _rFileName );
243
244 OUString GetCurrentFilter() const;
245 OUString GetDisplayDirectory() const;
246 ErrCode GetGraphic( Graphic& rGraphic ) const;
247
248 const css::uno::Reference < css::ui::dialogs::XFilePicker3 >& GetFilePicker() const;
249
250 // XFilePickerListener methods
251 void FileSelectionChanged();
252 void DirectoryChanged();
253 virtual void ControlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
254 void DialogSizeChanged();
255 static OUString HelpRequested( const css::ui::dialogs::FilePickerEvent& aEvent );
256
257 // XDialogClosedListener methods
258 void DialogClosed( const css::ui::dialogs::DialogClosedEvent& _rEvent );
259
268 void SetControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId );
269 void CreateMatcher( const OUString& rName );
270
277 void SetContext( Context _eNewContext );
278
279 DECL_DLLPRIVATE_LINK( ExecuteSystemFilePicker, void*, void );
280
281 ErrCode Execute( std::vector<OUString>& rpURLList,
282 std::optional<SfxAllItemSet>& rpSet,
283 OUString& rFilter,
284 const OUString& rDirPath );
285 ErrCode Execute( std::optional<SfxAllItemSet>& rpSet,
286 OUString& rFilter );
287};
288
289#define SFX2_IMPL_DIALOG_CONFIG 0
290#define SFX2_IMPL_DIALOG_SYSTEM 1
291#define SFX2_IMPL_DIALOG_OOO 2
292#define SFX2_IMPL_DIALOG_REMOTE 3
293
295 sal_Int16 nDialogType,
296 FileDialogFlags nFlags,
297 std::vector<OUString>& rpURLList,
298 OUString& rFilter,
299 std::optional<SfxAllItemSet>& rpSet,
300 const OUString* pPath,
301 sal_Int16 nDialog,
302 const OUString& rStandardDir,
303 const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >());
304
305css::uno::Reference<css::ui::dialogs::XFolderPicker2> SFX2_DLLPUBLIC createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Window* pPreferredParent);
306
307ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const css::uno::Reference<css::awt::XWindow>& rParent);
308ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxItemSet* pSet,
309 const OUString& rPasswordToOpen, std::u16string_view rPasswordToModify,
310 bool bAllowPasswordReset = false);
311bool IsOOXML(const std::shared_ptr<const SfxFilter>& pCurrentFilter);
312bool IsMSType(const std::shared_ptr<const SfxFilter>& pCurrentFilter);
313}
314
315#endif
316
317/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< FileDialogHelper_Impl > mpImpl
DECL_DLLPRIVATE_LINK(ExecuteSystemFilePicker, void *, void)
FileDialogHelper(const FileDialogHelper &)=delete
FileDialogHelper & operator=(const FileDialogHelper &)=delete
Link< FileDialogHelper *, void > m_aDialogClosedLink
ErrCode const & GetError() const
virtual void SetTitle(const OUString &rNewTitle) override
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
virtual OUString GetPath() const override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SfxFilterFlags
float u
constexpr OUStringLiteral FILEDIALOG_FILTER_ALL
FileDialogFlags
@ InsertMerge
Special insertion ("Compare" caption)
@ SignPDF
Sign existing PDF.
NONE
Reference
bool IsMSType(const std::shared_ptr< const SfxFilter > &pCurrentFilter)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
bool IsOOXML(const std::shared_ptr< const SfxFilter > &pCurrentFilter)
ErrCode SetPassword(const std::shared_ptr< const SfxFilter > &pCurrentFilter, SfxItemSet *pSet, const OUString &rPasswordToOpen, std::u16string_view rPasswordToModify, bool bAllowPasswordReset)
ErrCode RequestPassword(const std::shared_ptr< const SfxFilter > &pCurrentFilter, OUString const &aURL, SfxItemSet *pSet, const css::uno::Reference< css::awt::XWindow > &rParent)
ErrCode FileOpenDialog_Impl(weld::Window *pParent, sal_Int16 nDialogType, FileDialogFlags nFlags, std::vector< OUString > &rpURLList, OUString &rFilter, std::optional< SfxAllItemSet > &rpSet, const OUString *pPath, sal_Int16 nDialog, const OUString &rStandardDir, const css::uno::Sequence< OUString > &rDenyList)
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)