update dev300-m57
[ooovba.git] / sfx2 / source / dialog / filedlgimpl.hxx
blob09ddcfa86804fb5063d16fef2d964238c7248942
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filedlgimpl.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFX_FILEDLGIMPL_HXX
31 #define _SFX_FILEDLGIMPL_HXX
33 #include <vcl/timer.hxx>
34 #include <vcl/graph.hxx>
35 #include <cppuhelper/implbase2.hxx>
36 #include <com/sun/star/beans/StringPair.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
39 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
40 #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
41 #include <sfx2/fcontnr.hxx>
43 #define _SVSTDARR_STRINGSDTOR
44 #include <svtools/svstdarr.hxx>
46 #include <sfx2/filedlghelper.hxx>
47 #include <comphelper/sequenceasvector.hxx>
49 class SfxFilterMatcher;
50 class GraphicFilter;
51 class FileDialogHelper;
53 namespace sfx2
55 typedef ::com::sun::star::beans::StringPair FilterPair;
57 class FileDialogHelper_Impl :
58 public ::cppu::WeakImplHelper2<
59 ::com::sun::star::ui::dialogs::XFilePickerListener,
60 ::com::sun::star::ui::dialogs::XDialogClosedListener >
62 friend class FileDialogHelper;
64 ::com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XFilePicker > mxFileDlg;
65 ::com::sun::star::uno::Reference < ::com::sun::star::container::XNameAccess > mxFilterCFG;
67 std::vector< FilterPair > maFilters;
69 SfxFilterMatcher* mpMatcher;
70 GraphicFilter* mpGraphicFilter;
71 FileDialogHelper* mpAntiImpl;
72 Window* mpPreferredParentWindow;
74 ::comphelper::SequenceAsVector< ::rtl::OUString > mlLastURLs;
76 ::rtl::OUString maPath;
77 ::rtl::OUString maFileName;
78 ::rtl::OUString maCurFilter;
79 ::rtl::OUString maSelectFilter;
80 ::rtl::OUString maButtonLabel;
82 Timer maPreViewTimer;
83 Graphic maGraphic;
85 const short m_nDialogType;
87 SfxFilterFlags m_nMustFlags;
88 SfxFilterFlags m_nDontFlags;
90 ULONG mnPostUserEventId;
92 ErrCode mnError;
94 FileDialogHelper::Context meContext;
96 sal_Bool mbHasPassword : 1;
97 sal_Bool mbIsPwdEnabled : 1;
98 sal_Bool m_bHaveFilterOptions : 1;
99 sal_Bool mbHasVersions : 1;
100 sal_Bool mbHasAutoExt : 1;
101 sal_Bool mbHasLink : 1;
102 sal_Bool mbHasPreview : 1;
103 sal_Bool mbShowPreview : 1;
104 sal_Bool mbIsSaveDlg : 1;
105 sal_Bool mbExport : 1;
107 sal_Bool mbDeleteMatcher : 1;
108 sal_Bool mbInsert : 1;
109 sal_Bool mbSystemPicker : 1;
110 sal_Bool mbPwdCheckBoxState : 1;
111 sal_Bool mbSelection : 1;
112 sal_Bool mbSelectionEnabled : 1;
114 private:
115 void addFilters( sal_Int64 nFlags,
116 const String& rFactory,
117 SfxFilterFlags nMust,
118 SfxFilterFlags nDont );
119 void addFilter( const ::rtl::OUString& rFilterName,
120 const ::rtl::OUString& rExtension );
121 void addGraphicFilter();
122 void enablePasswordBox( sal_Bool bInit );
123 void updateFilterOptionsBox();
124 void updateExportButton();
125 void updateSelectionBox();
126 void updateVersions();
127 void updatePreviewState( sal_Bool _bUpdatePreviewWindow = sal_True );
128 void dispose();
130 void loadConfig();
131 void saveConfig();
133 const SfxFilter* getCurentSfxFilter();
134 sal_Bool updateExtendedControl( sal_Int16 _nExtendedControlId, sal_Bool _bEnable );
136 ErrCode getGraphic( const ::rtl::OUString& rURL, Graphic& rGraphic ) const;
137 void setDefaultValues();
139 void preExecute();
140 void postExecute( sal_Int16 _nResult );
141 sal_Int16 implDoExecute();
142 void implStartExecute();
144 void correctVirtualDialogType();
146 void setControlHelpIds( const sal_Int16* _pControlId, const sal_Int32* _pHelpId );
147 void setDialogHelpId( const sal_Int32 _nHelpId );
149 sal_Bool CheckFilterOptionsCapability( const SfxFilter* _pFilter );
151 sal_Bool isInOpenMode() const;
152 String getCurrentFilterUIName() const;
154 void LoadLastUsedFilter( const ::rtl::OUString& _rContextIdentifier );
155 void SaveLastUsedFilter( const ::rtl::OUString& _rContextIdentifier );
156 void SaveLastUsedFilter( void );
158 void implInitializeFileName( );
160 void implGetAndCacheFiles( const ::com::sun::star::uno::Reference< XInterface >& xPicker ,
161 SvStringsDtor*& rpURLList,
162 const SfxFilter* pFilter );
163 String implEnsureURLExtension(const String& sURL ,
164 const String& sExtension);
166 DECL_LINK( TimeOutHdl_Impl, Timer* );
167 DECL_LINK( HandleEvent, FileDialogHelper* );
168 DECL_LINK( InitControls, void* );
170 public:
171 // XFilePickerListener methods
172 virtual void SAL_CALL fileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
173 virtual void SAL_CALL directoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
174 virtual ::rtl::OUString SAL_CALL helpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
175 virtual void SAL_CALL controlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
176 virtual void SAL_CALL dialogSizeChanged() throw( ::com::sun::star::uno::RuntimeException );
178 // XDialogClosedListener methods
179 virtual void SAL_CALL dialogClosed( const ::com::sun::star::ui::dialogs::DialogClosedEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
181 // XEventListener methods
182 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException );
184 // handle XFilePickerListener events
185 void handleFileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
186 void handleDirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
187 ::rtl::OUString handleHelpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
188 void handleControlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
189 void handleDialogSizeChanged();
191 // Own methods
192 FileDialogHelper_Impl(
193 FileDialogHelper* _pAntiImpl,
194 const short nDialogType,
195 sal_Int64 nFlags,
196 sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG,
197 Window* _pPreferredParentWindow = NULL,
198 const String& sStandardDir = String::CreateFromAscii( "" ),
199 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >()
201 virtual ~FileDialogHelper_Impl();
203 ErrCode execute( SvStringsDtor*& rpURLList,
204 SfxItemSet *& rpSet,
205 String& rFilter );
206 ErrCode execute();
208 void setFilter( const ::rtl::OUString& rFilter );
210 /** sets the directory which should be browsed
212 <p>If the given path does not point to a valid (existent and accessible) folder, the request
213 is silently dropped</p>
215 void displayFolder( const ::rtl::OUString& rPath );
216 void setFileName( const ::rtl::OUString& _rFile );
218 ::rtl::OUString getPath() const;
219 ::rtl::OUString getFilter() const;
220 void getRealFilter( String& _rFilter ) const;
222 ErrCode getGraphic( Graphic& rGraphic ) const;
223 void createMatcher( const String& rFactory );
225 sal_Bool isShowFilterExtensionEnabled() const;
226 void addFilterPair( const ::rtl::OUString& rFilter,
227 const ::rtl::OUString& rFilterWithExtension );
228 ::rtl::OUString getFilterName( const ::rtl::OUString& rFilterWithExtension ) const;
229 ::rtl::OUString getFilterWithExtension( const ::rtl::OUString& rFilter ) const;
231 void SetContext( FileDialogHelper::Context _eNewContext );
233 inline sal_Bool isSystemFilePicker() const { return mbSystemPicker; }
234 inline sal_Bool isPasswordEnabled() const { return mbIsPwdEnabled; }
237 } // end of namespace sfx2
239 #endif // _SFX_FILEDLGIMPL_HXX