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