xref: /trunk/main/svtools/source/dialogs/filedlg2.hxx (revision 01aa44aa)
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 
24 #ifndef _FILEDLG2_HXX
25 #define _FILEDLG2_HXX
26 
27 #include <tools/debug.hxx>
28 #include <tools/fsys.hxx>
29 #ifndef _SV_BUTTON_HXX //autogen wg. PushButton
30 #include <vcl/button.hxx>
31 #endif
32 #include <vcl/unohelp.hxx>
33 
34 class FixedText;
35 class Edit;
36 class ListBox;
37 class ListBox;
38 class Button;
39 
40 class PathDialog;
41 class FileDialog;
42 class ImpPathDialog;
43 
44 struct ImpFilterItem
45 {
46 	String aName;
47 	String aMask;
48 
ImpFilterItemImpFilterItem49 	ImpFilterItem( const String & rFilter, const String & rMask )
50 	{
51 		aName = rFilter;
52 		aMask = rMask;
53 	}
54 };
55 
56 DECLARE_LIST( ImpFilterList, ImpFilterItem* )
57 #include <vcl/lstbox.hxx>
58 
59 class KbdListBox : public ListBox
60 {
61 public:
62 
KbdListBox(Window * pParent,WinBits nStyle=WB_BORDER)63 				KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
64 					: ListBox ( pParent, nStyle )
65 				{};
66 
67 virtual long    PreNotify( NotifyEvent& rNEvt );
68 
69 };
70 
71 
72 class ImpPathDialog
73 {
74 	friend class ImpFileDialog;
75 
76 private:
77 	PathDialog*			pSvPathDialog;
78 	Edit*			    pEdit;
79 	FixedText*          pDirTitel;
80 	KbdListBox*         pDirList;
81 	FixedText*          pDirPath;
82 	ListBox*			pDriveList;
83 	FixedText*			pDriveTitle;
84 	PushButton*         pLoadBtn;
85 	PushButton*         pOkBtn;
86 	PushButton*         pCancelBtn;
87 	PushButton*         pHomeBtn;
88 	PushButton*         pNewDirBtn;
89 
90 	sal_uInt16 				nOwnChilds;
91 
92 	DirEntry            aPath;          // aktuell angewaehlter Pfad
93 	sal_uInt16              nDirCount;      // Anzahl der Verzeichnis-
94 										// Verschachtelungen
95 
96     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
97     					xCollator;
98 
99 protected:
100 
101 	virtual	void		UpdateEntries( const sal_Bool bWithDirs );
102 	void				UpdateDirs( const DirEntry& rTmpPath );
103 
104 	sal_Bool            	IsFileOk( const DirEntry& rDirEntry );
105 	void				InitControls();
106 
107 	DECL_LINK( 			SelectHdl, ListBox * );
108 	DECL_LINK( 			DblClickHdl, ListBox * );
109 	DECL_LINK( 			ClickHdl, Button * );
110 
111 public:
112 						ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir );
113 	virtual 			~ImpPathDialog();
114 
115 	virtual	void		SetPath( const String& rPath );
116 	virtual void    	SetPath( const Edit& rEdit );
117 	virtual	String		GetPath() const;
118 
119 	virtual	void		PreExecute();
120 	virtual void 		PostExecute();
121 
GetPathDialog() const122 	PathDialog*		GetPathDialog() const	{ return pSvPathDialog; }
123 
SetOkButtonText(const String & rText)124 	void			SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
SetCancelButtonText(const String & rText)125 	void			SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
126 
127 };
128 
129 
130 class ImpFileDialog : public ImpPathDialog
131 {
132 private:
133 	FixedText*          pFileTitel;
134 	ListBox*            pFileList;
135 	FixedText*          pTypeTitel;
136 	ListBox*		    pTypeList;
137 
138 	WildCard            aMask;          // aktuelle Maske
139 
140 	ImpFilterList		aFilterList;    // Filterliste
141 	sal_uInt16              nCurFilter;     // aktueller Filter
142 
143 	sal_Bool                bOpen;          // sal_True = Open; sal_False = SAVEAS
144 
145 protected:
146 	void				InitControls();
147 
148 	String 				ExtendFileName( DirEntry aEntry ) const;
149 
150 	DECL_LINK( 			SelectHdl, ListBox * );
151 	DECL_LINK( 			DblClickHdl, ListBox * );
152 	DECL_LINK( 			ClickHdl, Button * );
153 
154 	virtual	void		UpdateEntries( const sal_Bool bWithDirs );
155 	sal_Bool            	IsFileOk( const DirEntry& rDirEntry );
156 
157 public:
158 						ImpFileDialog( PathDialog* pDlg, WinBits nStyle, RESOURCE_TYPE nType );
159 	virtual 			~ImpFileDialog();
160 
161 	void				AddFilter( const String& rFilter, const String& rMask );
162 	void				RemoveFilter( const String& rFilter );
163 	void				RemoveAllFilter();
164 	void				SetCurFilter( const String& rFilter );
165 	String				GetCurFilter() const;
166 
GetFilterCount() const167 	sal_uInt16				GetFilterCount() const	{ return (sal_uInt16)aFilterList.Count(); }
168 	inline String		GetFilterName( sal_uInt16 nPos ) const;
169 	inline String		GetFilterType( sal_uInt16 nPos ) const;
170 
171 	virtual	void		SetPath( const String& rPath );
172 	virtual void 		SetPath( const Edit& rEdit );
173 	virtual	String		GetPath() const;
174 
175 	virtual	void		PreExecute();
176 
GetFileDialog() const177 	FileDialog*		GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
178 };
179 
GetFilterName(sal_uInt16 nPos) const180 inline String ImpFileDialog::GetFilterName( sal_uInt16 nPos ) const
181 {
182 	String aName;
183 	ImpFilterItem* pItem = aFilterList.GetObject( nPos );
184 	if ( pItem )
185 		aName = pItem->aName;
186 	return aName;
187 }
188 
GetFilterType(sal_uInt16 nPos) const189 inline String ImpFileDialog::GetFilterType( sal_uInt16 nPos ) const
190 {
191 	String aFilterMask;
192 	ImpFilterItem* pItem = aFilterList.GetObject( nPos );
193 	if ( pItem )
194 		aFilterMask = pItem->aMask;
195 	return aFilterMask;
196 }
197 
198 class ImpSvFileDlg
199 {
200 private:
201 	ImpPathDialog* 	pDlg;
202 
203 public:
ImpSvFileDlg()204 					ImpSvFileDlg() 		{ pDlg = 0; }
~ImpSvFileDlg()205 					~ImpSvFileDlg() 	{ delete pDlg; }
206 
GetDialog() const207 	ImpPathDialog* 	GetDialog() const 	{ return pDlg; }
208 	void			CreateDialog( PathDialog* pCreateFrom, WinBits nStyle, RESOURCE_TYPE nType, sal_Bool bCreate );
209 
SetOkButtonText(const String & rText)210 	void			SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); }	// ihr habts ja nicht anders gewollt
SetCancelButtonText(const String & rText)211 	void			SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
212 
213 };
214 
215 #endif // _FILEDLG2_HXX
216