LibreOffice Module sfx2 (master) 1
filedlgimpl.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_SOURCE_DIALOG_FILEDLGIMPL_HXX
20#define INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX
21
22#include <vcl/timer.hxx>
23#include <vcl/idle.hxx>
24#include <vcl/graph.hxx>
26#include <com/sun/star/beans/StringPair.hpp>
27#include <com/sun/star/container/XNameAccess.hpp>
28#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
29#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
30#include <sfx2/fcontnr.hxx>
32
34class GraphicFilter;
35class FileDialogHelper;
36struct ImplSVEvent;
37
38namespace sfx2
39{
41 public ::cppu::WeakImplHelper<
42 css::ui::dialogs::XFilePickerListener,
43 css::ui::dialogs::XDialogClosedListener >
44 {
45 friend class FileDialogHelper;
46
47 css::uno::Reference < css::ui::dialogs::XFilePicker3 > mxFileDlg;
48 css::uno::Reference < css::container::XNameAccess > mxFilterCFG;
49
50 std::vector< css::beans::StringPair > maFilters;
51
53 std::unique_ptr<GraphicFilter> mpGraphicFilter;
56
57 ::std::vector< OUString > mlLastURLs;
58
59 OUString maPath;
60 OUString maFileName;
61 OUString maCurFilter;
63 OUString maButtonLabel;
64
67
68 const short m_nDialogType;
69
72
74
76
77 bool mbHasPassword : 1;
80 bool mbHasVersions : 1;
81 bool mbHasAutoExt : 1;
82 bool mbHasPreview : 1;
83 bool mbShowPreview : 1;
84 bool mbIsSaveDlg : 1;
85 bool mbExport : 1;
86
88 bool mbInsert : 1;
90 bool mbAsyncPicker : 1;
92 bool mbSelection : 1;
96
97 private:
98 void addFilters( const OUString& rFactory,
99 SfxFilterFlags nMust,
100 SfxFilterFlags nDont );
101 void addFilter( const OUString& rFilterName,
102 const OUString& rExtension );
103 void addGraphicFilter();
104 void enablePasswordBox( bool bInit );
106 void updateExportButton();
107 void updateSelectionBox();
108 void updateVersions();
109 void updatePreviewState( bool _bUpdatePreviewWindow );
110 void dispose();
111
112 void loadConfig();
113 void saveConfig();
114
115 std::shared_ptr<const SfxFilter> getCurrentSfxFilter();
116 bool updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable );
117
118 ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ) const;
119 void setDefaultValues();
120
121 void preExecute();
122 void postExecute( sal_Int16 _nResult );
123 sal_Int16 implDoExecute();
124 void implStartExecute();
125
126 void setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId );
127
128 bool CheckFilterOptionsCapability( const std::shared_ptr<const SfxFilter>& _pFilter );
129
130 bool isInOpenMode() const;
131 OUString getCurrentFilterUIName() const;
132
133 void LoadLastUsedFilter( const OUString& _rContextIdentifier );
134 void SaveLastUsedFilter();
135
137
138 void verifyPath( );
139
140 void implGetAndCacheFiles( const css::uno::Reference< XInterface >& xPicker ,
141 std::vector<OUString>& rpURLList );
142
143 DECL_LINK( TimeOutHdl_Impl, Timer *, void);
144 DECL_LINK( InitControls, void*, void );
145
146 public:
147 // XFilePickerListener methods
148 virtual void SAL_CALL fileSelectionChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
149 virtual void SAL_CALL directoryChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
150 virtual OUString SAL_CALL helpRequested( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
151 virtual void SAL_CALL controlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
152 virtual void SAL_CALL dialogSizeChanged() override;
153
154 // XDialogClosedListener methods
155 virtual void SAL_CALL dialogClosed( const css::ui::dialogs::DialogClosedEvent& _rEvent ) override;
156
157 // XEventListener methods
158 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
159
160 // handle XFilePickerListener events
163 static OUString handleHelpRequested( const css::ui::dialogs::FilePickerEvent& aEvent );
164 void handleControlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
166
167 // Own methods
169 FileDialogHelper* _pAntiImpl,
170 const sal_Int16 nDialogType,
171 FileDialogFlags nFlags,
172 sal_Int16 nDialog,
173 weld::Window* pFrameWeld,
174 const OUString& sStandardDir = OUString(),
175 const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >()
176 );
177 virtual ~FileDialogHelper_Impl() override;
178
179 ErrCode execute( std::vector<OUString>& rpURLList,
180 std::optional<SfxAllItemSet>& rpSet,
181 OUString& rFilter );
183
184 void setFilter( const OUString& rFilter );
185
191 void displayFolder( const OUString& rPath );
192 void setFileName( const OUString& _rFile );
193
194 OUString getPath() const;
195 OUString getFilter() const;
196 void getRealFilter( OUString& _rFilter ) const;
197
198 ErrCode getGraphic( Graphic& rGraphic ) const;
199 void createMatcher( const OUString& rFactory );
200
201 bool isShowFilterExtensionEnabled() const;
202 void addFilterPair( const OUString& rFilter,
203 const OUString& rFilterWithExtension );
204 OUString getFilterName( std::u16string_view rFilterWithExtension ) const;
205 OUString getFilterWithExtension( std::u16string_view rFilter ) const;
206
207 void SetContext( FileDialogHelper::Context _eNewContext );
208 OUString getInitPath( std::u16string_view _rFallback, const sal_Int32 _nFallbackToken );
209
210 bool isAsyncFilePicker() const { return mbAsyncPicker; }
211 bool isPasswordEnabled() const { return mbIsPwdEnabled; }
212
213 css::uno::Reference<css::awt::XWindow> GetFrameInterface();
214 };
215
216} // end of namespace sfx2
217
218#endif // INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sStandardDir
Definition: appuno.cxx:142
virtual void SAL_CALL dialogSizeChanged() override
virtual void SAL_CALL controlStateChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
void createMatcher(const OUString &rFactory)
void updatePreviewState(bool _bUpdatePreviewWindow)
css::uno::Reference< css::awt::XWindow > GetFrameInterface()
OUString getFilterWithExtension(std::u16string_view rFilter) const
void displayFolder(const OUString &rPath)
sets the directory which should be browsed
FileDialogHelper::Context meContext
Definition: filedlgimpl.hxx:75
std::unique_ptr< GraphicFilter > mpGraphicFilter
Definition: filedlgimpl.hxx:53
virtual void SAL_CALL directoryChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
bool isShowFilterExtensionEnabled() const
void addFilterPair(const OUString &rFilter, const OUString &rFilterWithExtension)
ErrCode getGraphic(const OUString &rURL, Graphic &rGraphic) const
void getRealFilter(OUString &_rFilter) const
::std::vector< OUString > mlLastURLs
Definition: filedlgimpl.hxx:57
void setFileName(const OUString &_rFile)
void SetContext(FileDialogHelper::Context _eNewContext)
void addFilters(const OUString &rFactory, SfxFilterFlags nMust, SfxFilterFlags nDont)
void addFilter(const OUString &rFilterName, const OUString &rExtension)
OUString getCurrentFilterUIName() const
void setControlHelpIds(const sal_Int16 *_pControlId, const char **_pHelpId)
void implGetAndCacheFiles(const css::uno::Reference< XInterface > &xPicker, std::vector< OUString > &rpURLList)
OUString getInitPath(std::u16string_view _rFallback, const sal_Int32 _nFallbackToken)
css::uno::Reference< css::container::XNameAccess > mxFilterCFG
Definition: filedlgimpl.hxx:48
virtual void SAL_CALL dialogClosed(const css::ui::dialogs::DialogClosedEvent &_rEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void LoadLastUsedFilter(const OUString &_rContextIdentifier)
void handleControlStateChanged(const css::ui::dialogs::FilePickerEvent &aEvent)
SfxFilterMatcher * mpMatcher
Definition: filedlgimpl.hxx:52
std::vector< css::beans::StringPair > maFilters
Definition: filedlgimpl.hxx:50
bool updateExtendedControl(sal_Int16 _nExtendedControlId, bool _bEnable)
DECL_LINK(TimeOutHdl_Impl, Timer *, void)
FileDialogHelper_Impl(FileDialogHelper *_pAntiImpl, const sal_Int16 nDialogType, FileDialogFlags nFlags, sal_Int16 nDialog, weld::Window *pFrameWeld, const OUString &sStandardDir=OUString(), const css::uno::Sequence< OUString > &rDenyList=css::uno::Sequence< OUString >())
css::uno::Reference< css::ui::dialogs::XFilePicker3 > mxFileDlg
Definition: filedlgimpl.hxx:47
void postExecute(sal_Int16 _nResult)
virtual void SAL_CALL fileSelectionChanged(const css::ui::dialogs::FilePickerEvent &aEvent) override
FileDialogHelper * mpAntiImpl
Definition: filedlgimpl.hxx:54
virtual OUString SAL_CALL helpRequested(const css::ui::dialogs::FilePickerEvent &aEvent) override
void enablePasswordBox(bool bInit)
OUString getFilterName(std::u16string_view rFilterWithExtension) const
ImplSVEvent * mnPostUserEventId
Definition: filedlgimpl.hxx:73
virtual ~FileDialogHelper_Impl() override
DECL_LINK(InitControls, void *, void)
std::shared_ptr< const SfxFilter > getCurrentSfxFilter()
bool CheckFilterOptionsCapability(const std::shared_ptr< const SfxFilter > &_pFilter)
static OUString handleHelpRequested(const css::ui::dialogs::FilePickerEvent &aEvent)
void setFilter(const OUString &rFilter)
SfxFilterFlags
FileDialogFlags