nss: upgrade to release 3.73
[LibreOffice.git] / sfx2 / source / dialog / filedlgimpl.hxx
blobc755bcc9f26fa38891f4f7cfacb245bde9941674
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX
20 #define INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX
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 <sfx2/fcontnr.hxx>
31 #include <sfx2/filedlghelper.hxx>
33 class SfxFilterMatcher;
34 class GraphicFilter;
35 class FileDialogHelper;
36 struct ImplSVEvent;
38 namespace sfx2
40 class FileDialogHelper_Impl :
41 public ::cppu::WeakImplHelper<
42 css::ui::dialogs::XFilePickerListener,
43 css::ui::dialogs::XDialogClosedListener >
45 friend class FileDialogHelper;
47 css::uno::Reference < css::ui::dialogs::XFilePicker3 > mxFileDlg;
48 css::uno::Reference < css::container::XNameAccess > mxFilterCFG;
50 std::vector< css::beans::StringPair > maFilters;
52 SfxFilterMatcher* mpMatcher;
53 std::unique_ptr<GraphicFilter> mpGraphicFilter;
54 FileDialogHelper* mpAntiImpl;
55 weld::Window* mpFrameWeld;
57 ::std::vector< OUString > mlLastURLs;
59 OUString maPath;
60 OUString maFileName;
61 OUString maCurFilter;
62 OUString maSelectFilter;
63 OUString maButtonLabel;
65 Idle maPreviewIdle;
66 Graphic maGraphic;
68 const short m_nDialogType;
70 SfxFilterFlags m_nMustFlags;
71 SfxFilterFlags m_nDontFlags;
73 ImplSVEvent * mnPostUserEventId;
75 FileDialogHelper::Context meContext;
77 bool mbHasPassword : 1;
78 bool mbIsPwdEnabled : 1;
79 bool m_bHaveFilterOptions : 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;
87 bool mbDeleteMatcher : 1;
88 bool mbInsert : 1;
89 bool mbSystemPicker : 1;
90 bool mbPwdCheckBoxState : 1;
91 bool mbSelection : 1;
92 bool mbSelectionEnabled : 1;
93 bool mbHasSelectionBox : 1;
94 bool mbSelectionFltrEnabled : 1;
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 updateFilterOptionsBox();
105 void updateExportButton();
106 void updateSelectionBox();
107 void updateVersions();
108 void updatePreviewState( bool _bUpdatePreviewWindow );
109 void dispose();
111 void loadConfig();
112 void saveConfig();
114 std::shared_ptr<const SfxFilter> getCurentSfxFilter();
115 bool updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable );
117 ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ) const;
118 void setDefaultValues();
120 void preExecute();
121 void postExecute( sal_Int16 _nResult );
122 sal_Int16 implDoExecute();
123 void implStartExecute();
125 void setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId );
127 bool CheckFilterOptionsCapability( const std::shared_ptr<const SfxFilter>& _pFilter );
129 bool isInOpenMode() const;
130 OUString getCurrentFilterUIName() const;
132 void LoadLastUsedFilter( const OUString& _rContextIdentifier );
133 void SaveLastUsedFilter();
135 void implInitializeFileName( );
137 void verifyPath( );
139 void implGetAndCacheFiles( const css::uno::Reference< XInterface >& xPicker ,
140 std::vector<OUString>& rpURLList );
142 DECL_LINK( TimeOutHdl_Impl, Timer *, void);
143 DECL_LINK( InitControls, void*, void );
145 public:
146 // XFilePickerListener methods
147 virtual void SAL_CALL fileSelectionChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
148 virtual void SAL_CALL directoryChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
149 virtual OUString SAL_CALL helpRequested( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
150 virtual void SAL_CALL controlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent ) override;
151 virtual void SAL_CALL dialogSizeChanged() override;
153 // XDialogClosedListener methods
154 virtual void SAL_CALL dialogClosed( const css::ui::dialogs::DialogClosedEvent& _rEvent ) override;
156 // XEventListener methods
157 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
159 // handle XFilePickerListener events
160 void handleFileSelectionChanged();
161 void handleDirectoryChanged();
162 static OUString handleHelpRequested( const css::ui::dialogs::FilePickerEvent& aEvent );
163 void handleControlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
164 void handleDialogSizeChanged();
166 // Own methods
167 FileDialogHelper_Impl(
168 FileDialogHelper* _pAntiImpl,
169 const sal_Int16 nDialogType,
170 FileDialogFlags nFlags,
171 sal_Int16 nDialog,
172 weld::Window* pFrameWeld,
173 const OUString& sStandardDir = OUString(),
174 const css::uno::Sequence< OUString >& rDenyList = css::uno::Sequence< OUString >()
176 virtual ~FileDialogHelper_Impl() override;
178 ErrCode execute( std::vector<OUString>& rpURLList,
179 std::unique_ptr<SfxItemSet>& rpSet,
180 OUString& rFilter );
181 ErrCode execute();
183 void setFilter( const OUString& rFilter );
185 /** sets the directory which should be browsed
187 <p>If the given path does not point to a valid (existent and accessible) folder, the request
188 is silently dropped</p>
190 void displayFolder( const OUString& rPath );
191 void setFileName( const OUString& _rFile );
193 OUString getPath() const;
194 OUString getFilter() const;
195 void getRealFilter( OUString& _rFilter ) const;
197 ErrCode getGraphic( Graphic& rGraphic ) const;
198 void createMatcher( const OUString& rFactory );
200 bool isShowFilterExtensionEnabled() const;
201 void addFilterPair( const OUString& rFilter,
202 const OUString& rFilterWithExtension );
203 OUString getFilterName( const OUString& rFilterWithExtension ) const;
204 OUString getFilterWithExtension( const OUString& rFilter ) const;
206 void SetContext( FileDialogHelper::Context _eNewContext );
208 bool isSystemFilePicker() const { return mbSystemPicker; }
209 bool isPasswordEnabled() const { return mbIsPwdEnabled; }
211 css::uno::Reference<css::awt::XWindow> GetFrameInterface();
214 } // end of namespace sfx2
216 #endif // INCLUDED_SFX2_SOURCE_DIALOG_FILEDLGIMPL_HXX
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */