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