xref: /aoo41x/main/fpicker/source/office/iodlgimp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _IODLGIMP_HXX
28 #define _IODLGIMP_HXX
29 
30 #include <tools/string.hxx>
31 #include <vcl/fixed.hxx>
32 #include <vcl/lstbox.hxx>
33 #include <vcl/menubtn.hxx>
34 #include <vcl/timer.hxx>
35 #include <vcl/group.hxx>
36 
37 #include "svl/svarray.hxx"
38 
39 #include <vector>
40 
41 //*****************************************************************************
42 
43 class Accelerator;
44 class CheckBox;
45 class SvtFileDialog;
46 class SvStringsDtor;
47 class SvUShorts;
48 
49 //*****************************************************************************
50 
51 #define FILEDIALOG_DEF_EXTSEP		';'
52 #define FILEDIALOG_DEF_WILDCARD		'*'
53 #define FILEDIALOG_DEF_IMAGEBORDER	10
54 #define FILEDIALOG_DEF_TIMEOUT		250
55 
56 //*****************************************************************************
57 // SvtFileDialogFilter_Impl
58 //*****************************************************************************
59 
60 /*	[Beschreibung]
61 
62 	Instanzen dieser Klasse repr"asentieren einen Filter
63 */
64 
65 class SvtFileDialogFilter_Impl
66 {
67 private:
68 	String	m_aName;	// name of the entry
69 	String	m_aType;	// filter wildcard - if empty, the entry marks a group
70 
71 public:
72 	SvtFileDialogFilter_Impl( const String& rName, const String& rType );
73 	~SvtFileDialogFilter_Impl();
74 
75 	const String&		GetName() const		{ return m_aName; }
76 	const String&		GetType() const		{ return m_aType; }
77     const String        GetExtension() const    { return m_aType.Copy( 2 ); }
78 
79 	sal_Bool			isGroupSeparator() const	{ return 0 == m_aType.Len(); }
80 };
81 
82 //*****************************************************************************
83 // SvtFileDialogFilterList_Impl
84 //*****************************************************************************
85 
86 SV_DECL_PTRARR_DEL( SvtFileDialogFilterList_Impl, SvtFileDialogFilter_Impl*, 3, 3 )
87 
88 //*****************************************************************************
89 // SvtFileDlgMode
90 //*****************************************************************************
91 
92 enum SvtFileDlgMode
93 {
94 	FILEDLG_MODE_OPEN = 0,
95 	FILEDLG_MODE_SAVE = 1
96 };
97 
98 //*****************************************************************************
99 // SvtFileDlgType
100 //*****************************************************************************
101 
102 enum SvtFileDlgType
103 {
104 	FILEDLG_TYPE_FILEDLG = 0,
105 	FILEDLG_TYPE_PATHDLG
106 };
107 
108 //*****************************************************************************
109 // SvtFileDialogURLSelector
110 //*****************************************************************************
111 class SvtFileDialogURLSelector : public MenuButton
112 {
113 private:
114 	SvtFileDialog*	    m_pParent;
115 	PopupMenu*			m_pMenu;
116 
117 protected:
118     inline        SvtFileDialog*  GetDialogParent()       { return m_pParent; }
119 
120 protected:
121 	        void    OpenURL( const String& rURL );
122 
123     virtual void    FillURLMenu( PopupMenu* _pMenu ) = 0;
124 
125 protected:
126 	SvtFileDialogURLSelector( SvtFileDialog* _pParent, const ResId& _rResId, sal_uInt16 _nButtonId );
127     ~SvtFileDialogURLSelector();
128 
129     virtual void		Activate();
130 };
131 
132 //*****************************************************************************
133 // SvtUpButton_Impl
134 //*****************************************************************************
135 
136 class SvtUpButton_Impl : public SvtFileDialogURLSelector
137 {
138 private:
139 	SvStringsDtor*		_pURLs;
140 
141 public:
142 	SvtUpButton_Impl( SvtFileDialog* pParent, const ResId& rResId );
143 	~SvtUpButton_Impl();
144 
145 protected:
146 	virtual void		FillURLMenu( PopupMenu* _pMenu );
147 	virtual void		Select();
148 	virtual void		Click();
149 };
150 
151 //*****************************************************************************
152 // SvtTravelButton_Impl
153 //*****************************************************************************
154 
155 class SvtTravelButton_Impl : public SvtFileDialogURLSelector
156 {
157 private:
158     ::std::vector< String > m_aFavourites;
159 
160 public:
161 	SvtTravelButton_Impl( SvtFileDialog* pParent, const ResId& rResId );
162 	~SvtTravelButton_Impl();
163 
164             void            SetFavouriteLocations( const ::std::vector< String >& _rLocations );
165 
166 protected:
167 	virtual void		FillURLMenu( PopupMenu* _pMenu );
168 	virtual void		Select();
169 	virtual void		Click();
170 };
171 
172 //*****************************************************************************
173 // SvtFileDlgState
174 //*****************************************************************************
175 
176 typedef sal_uInt8 SvtFileDlgState;
177 
178 #define FILEDLG_STATE_NONE        ((SvtFileDlgState)0x00)
179 #define FILEDLG_STATE_REMOTE      ((SvtFileDlgState)0x01)
180 
181 //*****************************************************************************
182 // SvtExpFileDlg_Impl
183 //*****************************************************************************
184 class SvtURLBox;
185 class SvtExpFileDlg_Impl
186 {
187 private:
188 	DECL_STATIC_LINK( SvtExpFileDlg_Impl, UnClickHdl, Button* );
189 
190 private:
191 	ListBox*						_pLbFilter;
192 
193 	const SvtFileDialogFilter_Impl*	_pCurFilter;
194 	String							m_sCurrentFilterDisplayName;	// may differ from _pCurFilter->GetName in case it is a cached entry
195 
196 	::com::sun::star::uno::Sequence< ::rtl::OUString > _aBlackList;
197 
198 public:
199 	SvtFileDialogFilterList_Impl*	_pFilter;
200 	SvtFileDialogFilter_Impl*		_pUserFilter;
201 
202 	FixedText*						_pFtFileName;
203 	SvtURLBox*						_pEdFileName;
204 
205 	FixedText*						_pFtFileVersion;
206 	ListBox*						_pLbFileVersion;
207 
208 	FixedText*						_pFtTemplates;
209 	ListBox*						_pLbTemplates;
210 
211 	FixedText*						_pFtImageTemplates;
212 	ListBox*						_pLbImageTemplates;
213 
214 	FixedText*						_pFtFileType;
215 	PushButton*						_pBtnFileOpen;
216 	PushButton*						_pBtnCancel;
217 	HelpButton*						_pBtnHelp;
218 	SvtUpButton_Impl*				_pBtnUp;
219 	ImageButton*					_pBtnNewFolder;
220 	SvtTravelButton_Impl*			_pBtnStandard;
221 	CheckBox*						_pCbPassword;
222 	FixedText*          			_pFtCurrentPath;
223 	CheckBox*						_pCbAutoExtension;
224 	CheckBox*						_pCbOptions;
225 
226 	SvtFileDlgMode					_eMode;
227 	SvtFileDlgType					_eDlgType;
228 	SvtFileDlgState					_nState;
229 	WinBits							_nStyle;
230 
231 	String							_aStdDir;
232 
233 	// beim traveln der Filterbox erst Zeitversetzt filtern
234 	Timer							_aFilterTimer;
235 
236 	// Zeigt der OpenHdl_Imp(), ob das Open durch einen Doppelclick ausgel"ost wurde
237 	sal_Bool						_bDoubleClick;
238 	sal_Bool						m_bNeedDelayedFilterExecute;
239 
240 	// Liste mit den 5 zuletzt genutzten Filtern
241 	// Defaultfilter fuer <Alle> oder <Alle ...>
242 	const SvtFileDialogFilter_Impl*	_pDefaultFilter;
243 
244 	// Multiselektion?
245 	sal_Bool						_bMultiSelection;
246 
247 	// Fixgr"ossen f"ur Resize merken
248 	long                			_nFixDeltaHeight;
249 	Size				        	_a6Size;
250 	Size							_aDlgSize;
251 	String					       	_aIniKey;
252 
253 	sal_Bool						_bFolderHasOpened;
254 
255 							SvtExpFileDlg_Impl( WinBits nBits );
256 							~SvtExpFileDlg_Impl();
257 
258 
259 	inline void			    SetBlackList( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) { _aBlackList = rBlackList; }
260 	inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >& GetBlackList() const { return _aBlackList; }
261 	void					SetStandardDir( const String& _rDir );
262 	inline const String&	GetStandardDir() const			{ return _aStdDir; }
263 	inline void				DisableFilterBoxAutoWidth() 	{ _pLbFilter->EnableDDAutoWidth( sal_False ); }
264 
265 	// ------------------------------------------
266 	// access to the filter listbox only as Control* - we want to maintain the entries/userdata ourself
267 			Control*		GetFilterListControl()			{ return _pLbFilter; }
268 			const Control*	GetFilterListControl() const	{ return _pLbFilter; }
269 			void			CreateFilterListControl( Window* _pParent, const ResId& _rId );
270 	inline	void			SetFilterListSelectHdl( const Link& _rHandler );
271 
272 	// inits the listbox for the filters from the filter list (_pFilter)
273 			void			ClearFilterList( );
274 			void			InitFilterList( );
275 	inline	sal_Bool		HasFilterListEntry( const String& _rFilterName );
276 	inline	void			SelectFilterListEntry( const String& _rFilterName );
277 	inline	void			SetNoFilterListSelection( );
278 			void			InsertFilterListEntry( const SvtFileDialogFilter_Impl* _pFilterDesc );
279 								// _pFilterDesc must already have been added to _pFilter
280 	inline	SvtFileDialogFilter_Impl*	GetSelectedFilterEntry( String& /* [out] */ _rDisplayName ) const;
281 	inline	sal_Bool		IsFilterListTravelSelect() const;
282 
283 	// ------------------------------------------
284 	// access to the current filter via methods only - need to care for consistency between _pCurFilter and m_sCurrentFilterDisplayName
285 	inline		const SvtFileDialogFilter_Impl*		GetCurFilter( ) const;
286 	inline		const String&						GetCurFilterDisplayName() const;
287 				void								SetCurFilter( SvtFileDialogFilter_Impl* _pFilter, const String& _rDisplayName );
288 	inline		void								SetCurFilter( SvtFileDialogFilter_Impl* _pFilter );
289 };
290 
291 inline void SvtExpFileDlg_Impl::SetFilterListSelectHdl( const Link& _rHandler )
292 {
293 	_pLbFilter->SetSelectHdl( _rHandler );
294 }
295 
296 inline sal_Bool SvtExpFileDlg_Impl::HasFilterListEntry( const String& _rFilterName )
297 {
298 	return ( LISTBOX_ENTRY_NOTFOUND != _pLbFilter->GetEntryPos( _rFilterName ) );
299 }
300 
301 inline void SvtExpFileDlg_Impl::SelectFilterListEntry( const String& _rFilterName )
302 {
303 	_pLbFilter->SelectEntry( _rFilterName );
304 }
305 
306 inline	void SvtExpFileDlg_Impl::SetNoFilterListSelection( )
307 {
308 	_pLbFilter->SetNoSelection( );
309 }
310 
311 inline SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetSelectedFilterEntry( String& _rDisplayName ) const
312 {
313 	_rDisplayName = _pLbFilter->GetSelectEntry();
314 	return static_cast< SvtFileDialogFilter_Impl* >( _pLbFilter->GetEntryData ( _pLbFilter->GetSelectEntryPos() ) );
315 }
316 
317 inline sal_Bool SvtExpFileDlg_Impl::IsFilterListTravelSelect() const
318 {
319 	return _pLbFilter->IsTravelSelect();
320 }
321 
322 inline const SvtFileDialogFilter_Impl* SvtExpFileDlg_Impl::GetCurFilter( ) const
323 {
324 	return _pCurFilter;
325 }
326 
327 inline const String& SvtExpFileDlg_Impl::GetCurFilterDisplayName() const
328 {
329 	return m_sCurrentFilterDisplayName;
330 }
331 
332 inline	void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl* pFilter )
333 {
334 	SetCurFilter( pFilter, pFilter->GetName() );
335 }
336 
337 #endif // #ifndef _IODLGIMP_HXX
338 
339 
340