/src/libreoffice/sfx2/source/dialog/filedlgimpl.hxx
Line | Count | Source (jump to first uncovered line) |
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> |
25 | | #include <cppuhelper/implbase.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 <unotools/saveopt.hxx> |
31 | | #include <sfx2/fcontnr.hxx> |
32 | | #include <sfx2/filedlghelper.hxx> |
33 | | |
34 | | class SfxFilterMatcher; |
35 | | class GraphicFilter; |
36 | | |
37 | | namespace sfx2 |
38 | | { |
39 | | class FileDialogHelper_Impl : |
40 | | public ::cppu::WeakImplHelper< |
41 | | css::ui::dialogs::XFilePickerListener, |
42 | | css::ui::dialogs::XDialogClosedListener > |
43 | | { |
44 | | friend class FileDialogHelper; |
45 | | |
46 | | css::uno::Reference < css::ui::dialogs::XFilePicker3 > mxFileDlg; |
47 | | css::uno::Reference < css::container::XNameAccess > mxFilterCFG; |
48 | | |
49 | | std::vector< css::beans::StringPair > maFilters; |
50 | | |
51 | | SfxFilterMatcher* mpMatcher; |
52 | | std::unique_ptr<GraphicFilter> mpGraphicFilter; |
53 | | FileDialogHelper* mpAntiImpl; |
54 | | weld::Window* mpFrameWeld; |
55 | | |
56 | | OUString maPath; |
57 | | OUString maFileName; |
58 | | OUString maCurFilter; |
59 | | OUString maSelectFilter; |
60 | | OUString maButtonLabel; |
61 | | OUString msPreselectedDir; |
62 | | |
63 | | Idle maPreviewIdle; |
64 | | Graphic maGraphic; |
65 | | |
66 | | const short m_nDialogType; |
67 | | |
68 | | SfxFilterFlags m_nMustFlags; |
69 | | SfxFilterFlags m_nDontFlags; |
70 | | |
71 | | FileDialogHelper::Context meContext; |
72 | | |
73 | | bool mbHasPassword : 1; // checkbox is visible |
74 | | bool mbIsPwdEnabled : 1; // password checkbox is not grayed out |
75 | | bool mbIsGpgEncrEnabled : 1; // GPG checkbox is not grayed out |
76 | | bool m_bHaveFilterOptions : 1; |
77 | | bool mbHasVersions : 1; |
78 | | bool mbHasAutoExt : 1; |
79 | | bool mbHasPreview : 1; |
80 | | bool mbShowPreview : 1; |
81 | | bool mbIsSaveDlg : 1; |
82 | | bool mbExport : 1; |
83 | | |
84 | | bool mbDeleteMatcher : 1; |
85 | | bool mbInsert : 1; |
86 | | bool mbSystemPicker : 1; |
87 | | bool mbAsyncPicker : 1; |
88 | | bool mbPwdCheckBoxState : 1; |
89 | | bool mbGpgCheckBoxState : 1; |
90 | | bool mbSelection : 1; |
91 | | bool mbSelectionEnabled : 1; |
92 | | bool mbHasSelectionBox : 1; |
93 | | bool mbSelectionFltrEnabled : 1; |
94 | | bool mbHasSignByDefault : 1; |
95 | | |
96 | | private: |
97 | | void addFilters( const OUString& rFactory, |
98 | | SfxFilterFlags nMust, |
99 | | SfxFilterFlags nDont ); |
100 | | void addFilter( const OUString& rFilterName, |
101 | | const OUString& rExtension ); |
102 | | void addGraphicFilter(); |
103 | | void enablePasswordBox( bool bInit ); |
104 | | void enableGpgEncrBox( bool bInit ); |
105 | | void updateFilterOptionsBox(); |
106 | | void updateExportButton(); |
107 | | void updateSelectionBox(); |
108 | | void updateSignByDefault(); |
109 | | void updateVersions(); |
110 | | void updatePreviewState( bool _bUpdatePreviewWindow ); |
111 | | void dispose(); |
112 | | |
113 | | void loadConfig(); |
114 | | void saveConfig(); |
115 | | |
116 | | std::shared_ptr<const SfxFilter> getCurrentSfxFilter(); |
117 | | bool updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable ); |
118 | | |
119 | | ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ); |
120 | | void setDefaultValues(); |
121 | | |
122 | | void preExecute(); |
123 | | void postExecute( sal_Int16 _nResult ); |
124 | | sal_Int16 implDoExecute(); |
125 | | void implStartExecute(); |
126 | | |
127 | | void setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId ); |
128 | | |
129 | | bool CheckFilterOptionsCapability( const std::shared_ptr<const SfxFilter>& _pFilter ); |
130 | | |
131 | | bool isInOpenMode() const; |
132 | | OUString getCurrentFilterUIName() const; |
133 | | |
134 | | void LoadLastUsedFilter( const OUString& _rContextIdentifier ); |
135 | | void SaveLastUsedFilter(); |
136 | | |
137 | | void implInitializeFileName( ); |
138 | | |
139 | | void verifyPath( ); |
140 | | |
141 | | DECL_LINK( TimeOutHdl_Impl, Timer *, void); |
142 | | |
143 | | public: |
144 | | // XFilePickerListener methods |
145 | | virtual void SAL_CALL fileSelectionChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override; |
146 | | virtual void SAL_CALL directoryChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override; |
147 | | virtual OUString SAL_CALL helpRequested( const css::ui::dialogs::FilePickerEvent& aEvent ) override; |
148 | | virtual void SAL_CALL controlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override; |
149 | | virtual void SAL_CALL dialogSizeChanged() override; |
150 | | |
151 | | // XDialogClosedListener methods |
152 | | virtual void SAL_CALL dialogClosed( const css::ui::dialogs::DialogClosedEvent& _rEvent ) override; |
153 | | |
154 | | // XEventListener methods |
155 | | virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; |
156 | | |
157 | | // handle XFilePickerListener events |
158 | | void handleFileSelectionChanged(); |
159 | | void handleDirectoryChanged(); |
160 | | static OUString handleHelpRequested( const css::ui::dialogs::FilePickerEvent& aEvent ); |
161 | | void handleControlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent ); |
162 | | void handleDialogSizeChanged(); |
163 | | |
164 | | // Own methods |
165 | | FileDialogHelper_Impl( |
166 | | FileDialogHelper* _pAntiImpl, |
167 | | const sal_Int16 nDialogType, |
168 | | FileDialogFlags nFlags, |
169 | | sal_Int16 nDialog, |
170 | | weld::Window* pFrameWeld, |
171 | | const OUString& sPreselectedDir = OUString(), |
172 | | const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >() |
173 | | ); |
174 | | virtual ~FileDialogHelper_Impl() override; |
175 | | |
176 | | ErrCode execute( css::uno::Sequence<OUString>& rpURLList, |
177 | | std::optional<SfxAllItemSet>& rpSet, |
178 | | OUString& rFilter, |
179 | | SignatureState nScriptingSignatureState); |
180 | | ErrCode execute(); |
181 | | |
182 | | void setFilter( const OUString& rFilter ); |
183 | | |
184 | | /** sets the directory which should be browsed |
185 | | |
186 | | <p>If the given path does not point to a valid (existent and accessible) folder, the request |
187 | | is silently dropped</p> |
188 | | */ |
189 | | void displayFolder( const OUString& rPath ); |
190 | | void setFileName( const OUString& _rFile ); |
191 | | |
192 | | OUString getPath() const; |
193 | | OUString getFilter() const; |
194 | | void getRealFilter( OUString& _rFilter ) const; |
195 | | |
196 | | ErrCode getGraphic( Graphic& rGraphic ); |
197 | | void createMatcher( const OUString& rFactory ); |
198 | | |
199 | | bool isShowFilterExtensionEnabled() const; |
200 | | void addFilterPair( const OUString& rFilter, |
201 | | const OUString& rFilterWithExtension ); |
202 | | OUString getFilterName( std::u16string_view rFilterWithExtension ) const; |
203 | | OUString getFilterWithExtension( std::u16string_view rFilter ) const; |
204 | | |
205 | | void SetContext( FileDialogHelper::Context _eNewContext ); |
206 | | OUString getInitPath( std::u16string_view _rFallback, const sal_Int32 _nFallbackToken ); |
207 | | |
208 | 0 | bool isAsyncFilePicker() const { return mbAsyncPicker; } |
209 | 0 | bool isPasswordEnabled() const { return mbIsPwdEnabled; } |
210 | | |
211 | | css::uno::Reference<css::awt::XWindow> GetFrameInterface(); |
212 | | }; |
213 | | } // end of namespace sfx2 |
214 | | |
215 | | #endif // INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX |
216 | | |
217 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |