1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _SFX_FILEDLGIMPL_HXX
29 #define _SFX_FILEDLGIMPL_HXX
31 #include <vcl/timer.hxx>
32 #include <vcl/graph.hxx>
33 #include <cppuhelper/implbase2.hxx>
34 #include <com/sun/star/beans/StringPair.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
37 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
38 #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
39 #include <sfx2/fcontnr.hxx>
40 #include <svl/svstdarr.hxx>
41 #include <sfx2/filedlghelper.hxx>
42 #include <comphelper/sequenceasvector.hxx>
44 class SfxFilterMatcher
;
46 class FileDialogHelper
;
50 typedef ::com::sun::star::beans::StringPair FilterPair
;
52 class FileDialogHelper_Impl
:
53 public ::cppu::WeakImplHelper2
<
54 ::com::sun::star::ui::dialogs::XFilePickerListener
,
55 ::com::sun::star::ui::dialogs::XDialogClosedListener
>
57 friend class FileDialogHelper
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePicker
> mxFileDlg
;
60 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> mxFilterCFG
;
62 std::vector
< FilterPair
> maFilters
;
64 SfxFilterMatcher
* mpMatcher
;
65 GraphicFilter
* mpGraphicFilter
;
66 FileDialogHelper
* mpAntiImpl
;
67 Window
* mpPreferredParentWindow
;
69 ::comphelper::SequenceAsVector
< ::rtl::OUString
> mlLastURLs
;
71 ::rtl::OUString maPath
;
72 ::rtl::OUString maFileName
;
73 ::rtl::OUString maCurFilter
;
74 ::rtl::OUString maSelectFilter
;
75 ::rtl::OUString maButtonLabel
;
80 const short m_nDialogType
;
82 SfxFilterFlags m_nMustFlags
;
83 SfxFilterFlags m_nDontFlags
;
85 sal_uIntPtr mnPostUserEventId
;
89 FileDialogHelper::Context meContext
;
91 sal_Bool mbHasPassword
: 1;
92 sal_Bool mbIsPwdEnabled
: 1;
93 sal_Bool m_bHaveFilterOptions
: 1;
94 sal_Bool mbHasVersions
: 1;
95 sal_Bool mbHasAutoExt
: 1;
96 sal_Bool mbAddGraphicFilter
: 1;
97 sal_Bool mbHasPreview
: 1;
98 sal_Bool mbShowPreview
: 1;
99 sal_Bool mbIsSaveDlg
: 1;
100 sal_Bool mbExport
: 1;
102 sal_Bool mbDeleteMatcher
: 1;
103 sal_Bool mbInsert
: 1;
104 sal_Bool mbSystemPicker
: 1;
105 sal_Bool mbPwdCheckBoxState
: 1;
106 sal_Bool mbSelection
: 1;
107 sal_Bool mbSelectionEnabled
: 1;
108 sal_Bool mbHasSelectionBox
: 1;
109 sal_Bool mbSelectionFltrEnabled
: 1;
112 void addFilters( const String
& rFactory
,
113 SfxFilterFlags nMust
,
114 SfxFilterFlags nDont
);
115 void addFilter( const ::rtl::OUString
& rFilterName
,
116 const ::rtl::OUString
& rExtension
);
117 void addGraphicFilter();
118 void enablePasswordBox( sal_Bool bInit
);
119 void updateFilterOptionsBox();
120 void updateExportButton();
121 void updateSelectionBox();
122 void updateVersions();
123 void updatePreviewState( sal_Bool _bUpdatePreviewWindow
= sal_True
);
129 const SfxFilter
* getCurentSfxFilter();
130 sal_Bool
updateExtendedControl( sal_Int16 _nExtendedControlId
, sal_Bool _bEnable
);
132 ErrCode
getGraphic( const ::rtl::OUString
& rURL
, Graphic
& rGraphic
) const;
133 void setDefaultValues();
136 void postExecute( sal_Int16 _nResult
);
137 sal_Int16
implDoExecute();
138 void implStartExecute();
140 void correctVirtualDialogType();
142 void setControlHelpIds( const sal_Int16
* _pControlId
, const char** _pHelpId
);
144 sal_Bool
CheckFilterOptionsCapability( const SfxFilter
* _pFilter
);
146 sal_Bool
isInOpenMode() const;
147 String
getCurrentFilterUIName() const;
149 void LoadLastUsedFilter( const ::rtl::OUString
& _rContextIdentifier
);
150 void SaveLastUsedFilter( const ::rtl::OUString
& _rContextIdentifier
);
151 void SaveLastUsedFilter( void );
153 void implInitializeFileName( );
157 void implGetAndCacheFiles( const ::com::sun::star::uno::Reference
< XInterface
>& xPicker
,
158 std::vector
<rtl::OUString
>& rpURLList
,
159 const SfxFilter
* pFilter
);
161 DECL_LINK(TimeOutHdl_Impl
, void *);
162 DECL_LINK( HandleEvent
, FileDialogHelper
* );
163 DECL_LINK( InitControls
, void* );
166 // XFilePickerListener methods
167 virtual void SAL_CALL
fileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
directoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
169 virtual ::rtl::OUString SAL_CALL
helpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
170 virtual void SAL_CALL
controlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
171 virtual void SAL_CALL
dialogSizeChanged() throw( ::com::sun::star::uno::RuntimeException
);
173 // XDialogClosedListener methods
174 virtual void SAL_CALL
dialogClosed( const ::com::sun::star::ui::dialogs::DialogClosedEvent
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
);
176 // XEventListener methods
177 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
);
179 // handle XFilePickerListener events
180 void handleFileSelectionChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
);
181 void handleDirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
);
182 ::rtl::OUString
handleHelpRequested( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
);
183 void handleControlStateChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent
& aEvent
);
184 void handleDialogSizeChanged();
187 FileDialogHelper_Impl(
188 FileDialogHelper
* _pAntiImpl
,
189 const short nDialogType
,
191 sal_Int16 nDialog
= SFX2_IMPL_DIALOG_CONFIG
,
192 Window
* _pPreferredParentWindow
= NULL
,
193 const String
& sStandardDir
= String::CreateFromAscii( "" ),
194 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& rBlackList
= ::com::sun::star::uno::Sequence
< ::rtl::OUString
>()
196 virtual ~FileDialogHelper_Impl();
198 ErrCode
execute( std::vector
<rtl::OUString
>& rpURLList
,
203 void setFilter( const ::rtl::OUString
& rFilter
);
205 /** sets the directory which should be browsed
207 <p>If the given path does not point to a valid (existent and accessible) folder, the request
208 is silently dropped</p>
210 void displayFolder( const ::rtl::OUString
& rPath
);
211 void setFileName( const ::rtl::OUString
& _rFile
);
213 ::rtl::OUString
getPath() const;
214 ::rtl::OUString
getFilter() const;
215 void getRealFilter( String
& _rFilter
) const;
217 ErrCode
getGraphic( Graphic
& rGraphic
) const;
218 void createMatcher( const String
& rFactory
);
220 sal_Bool
isShowFilterExtensionEnabled() const;
221 void addFilterPair( const ::rtl::OUString
& rFilter
,
222 const ::rtl::OUString
& rFilterWithExtension
);
223 ::rtl::OUString
getFilterName( const ::rtl::OUString
& rFilterWithExtension
) const;
224 ::rtl::OUString
getFilterWithExtension( const ::rtl::OUString
& rFilter
) const;
226 void SetContext( FileDialogHelper::Context _eNewContext
);
228 inline sal_Bool
isSystemFilePicker() const { return mbSystemPicker
; }
229 inline sal_Bool
isPasswordEnabled() const { return mbIsPwdEnabled
; }
232 } // end of namespace sfx2
234 #endif // _SFX_FILEDLGIMPL_HXX
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */