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