merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / dialogs / filedlg2.hxx
blob6c5efd25187b6687139491ad77a4bba676c88a4c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filedlg2.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FILEDLG2_HXX
32 #define _FILEDLG2_HXX
34 #include <tools/debug.hxx>
35 #include <tools/fsys.hxx>
36 #ifndef _SV_BUTTON_HXX //autogen wg. PushButton
37 #include <vcl/button.hxx>
38 #endif
39 #include <vcl/unohelp.hxx>
41 class FixedText;
42 class Edit;
43 class ListBox;
44 class ListBox;
45 class Button;
47 class PathDialog;
48 class FileDialog;
49 class ImpPathDialog;
51 struct ImpFilterItem
53 String aName;
54 String aMask;
56 ImpFilterItem( const String & rFilter, const String & rMask )
58 aName = rFilter;
59 aMask = rMask;
63 DECLARE_LIST( ImpFilterList, ImpFilterItem* )
64 #include <vcl/lstbox.hxx>
66 class KbdListBox : public ListBox
68 public:
70 KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
71 : ListBox ( pParent, nStyle )
72 {};
74 virtual long PreNotify( NotifyEvent& rNEvt );
79 class ImpPathDialog
81 friend class ImpFileDialog;
83 private:
84 PathDialog* pSvPathDialog;
85 Edit* pEdit;
86 FixedText* pDirTitel;
87 KbdListBox* pDirList;
88 FixedText* pDirPath;
89 ListBox* pDriveList;
90 FixedText* pDriveTitle;
91 PushButton* pLoadBtn;
92 PushButton* pOkBtn;
93 PushButton* pCancelBtn;
94 PushButton* pHomeBtn;
95 PushButton* pNewDirBtn;
97 USHORT nOwnChilds;
99 DirEntry aPath; // aktuell angewaehlter Pfad
100 USHORT nDirCount; // Anzahl der Verzeichnis-
101 // Verschachtelungen
103 ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
104 xCollator;
106 protected:
108 virtual void UpdateEntries( const BOOL bWithDirs );
109 void UpdateDirs( const DirEntry& rTmpPath );
111 BOOL IsFileOk( const DirEntry& rDirEntry );
112 void InitControls();
114 DECL_LINK( SelectHdl, ListBox * );
115 DECL_LINK( DblClickHdl, ListBox * );
116 DECL_LINK( ClickHdl, Button * );
118 public:
119 ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, BOOL bCreateDir );
120 virtual ~ImpPathDialog();
122 virtual void SetPath( const String& rPath );
123 virtual void SetPath( const Edit& rEdit );
124 virtual String GetPath() const;
126 virtual void PreExecute();
127 virtual void PostExecute();
129 PathDialog* GetPathDialog() const { return pSvPathDialog; }
131 void SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
132 void SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
137 class ImpFileDialog : public ImpPathDialog
139 private:
140 FixedText* pFileTitel;
141 ListBox* pFileList;
142 FixedText* pTypeTitel;
143 ListBox* pTypeList;
145 WildCard aMask; // aktuelle Maske
147 ImpFilterList aFilterList; // Filterliste
148 USHORT nCurFilter; // aktueller Filter
150 BOOL bOpen; // TRUE = Open; FALSE = SAVEAS
152 protected:
153 void InitControls();
155 String ExtendFileName( DirEntry aEntry ) const;
157 DECL_LINK( SelectHdl, ListBox * );
158 DECL_LINK( DblClickHdl, ListBox * );
159 DECL_LINK( ClickHdl, Button * );
161 virtual void UpdateEntries( const BOOL bWithDirs );
162 BOOL IsFileOk( const DirEntry& rDirEntry );
164 public:
165 ImpFileDialog( PathDialog* pDlg, WinBits nStyle, RESOURCE_TYPE nType );
166 virtual ~ImpFileDialog();
168 void AddFilter( const String& rFilter, const String& rMask );
169 void RemoveFilter( const String& rFilter );
170 void RemoveAllFilter();
171 void SetCurFilter( const String& rFilter );
172 String GetCurFilter() const;
174 USHORT GetFilterCount() const { return (USHORT)aFilterList.Count(); }
175 inline String GetFilterName( USHORT nPos ) const;
176 inline String GetFilterType( USHORT nPos ) const;
178 virtual void SetPath( const String& rPath );
179 virtual void SetPath( const Edit& rEdit );
180 virtual String GetPath() const;
182 virtual void PreExecute();
184 FileDialog* GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
187 inline String ImpFileDialog::GetFilterName( USHORT nPos ) const
189 String aName;
190 ImpFilterItem* pItem = aFilterList.GetObject( nPos );
191 if ( pItem )
192 aName = pItem->aName;
193 return aName;
196 inline String ImpFileDialog::GetFilterType( USHORT nPos ) const
198 String aFilterMask;
199 ImpFilterItem* pItem = aFilterList.GetObject( nPos );
200 if ( pItem )
201 aFilterMask = pItem->aMask;
202 return aFilterMask;
205 class ImpSvFileDlg
207 private:
208 ImpPathDialog* pDlg;
210 public:
211 ImpSvFileDlg() { pDlg = 0; }
212 ~ImpSvFileDlg() { delete pDlg; }
214 ImpPathDialog* GetDialog() const { return pDlg; }
215 void CreateDialog( PathDialog* pCreateFrom, WinBits nStyle, RESOURCE_TYPE nType, BOOL bCreate );
217 void SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); } // ihr habts ja nicht anders gewollt
218 void SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
222 #endif // _FILEDLG2_HXX