1*01aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*01aa44aaSAndrew Rist * distributed with this work for additional information
6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at
10*01aa44aaSAndrew Rist *
11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*01aa44aaSAndrew Rist *
13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the
17*01aa44aaSAndrew Rist * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist * under the License.
19*01aa44aaSAndrew Rist *
20*01aa44aaSAndrew Rist *************************************************************/
21*01aa44aaSAndrew Rist
22*01aa44aaSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _FILEDLG2_HXX
25cdf0e10cSrcweir #define _FILEDLG2_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/debug.hxx>
28cdf0e10cSrcweir #include <tools/fsys.hxx>
29cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX //autogen wg. PushButton
30cdf0e10cSrcweir #include <vcl/button.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <vcl/unohelp.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir class FixedText;
35cdf0e10cSrcweir class Edit;
36cdf0e10cSrcweir class ListBox;
37cdf0e10cSrcweir class ListBox;
38cdf0e10cSrcweir class Button;
39cdf0e10cSrcweir
40cdf0e10cSrcweir class PathDialog;
41cdf0e10cSrcweir class FileDialog;
42cdf0e10cSrcweir class ImpPathDialog;
43cdf0e10cSrcweir
44cdf0e10cSrcweir struct ImpFilterItem
45cdf0e10cSrcweir {
46cdf0e10cSrcweir String aName;
47cdf0e10cSrcweir String aMask;
48cdf0e10cSrcweir
ImpFilterItemImpFilterItem49cdf0e10cSrcweir ImpFilterItem( const String & rFilter, const String & rMask )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir aName = rFilter;
52cdf0e10cSrcweir aMask = rMask;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir };
55cdf0e10cSrcweir
56cdf0e10cSrcweir DECLARE_LIST( ImpFilterList, ImpFilterItem* )
57cdf0e10cSrcweir #include <vcl/lstbox.hxx>
58cdf0e10cSrcweir
59cdf0e10cSrcweir class KbdListBox : public ListBox
60cdf0e10cSrcweir {
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir
KbdListBox(Window * pParent,WinBits nStyle=WB_BORDER)63cdf0e10cSrcweir KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
64cdf0e10cSrcweir : ListBox ( pParent, nStyle )
65cdf0e10cSrcweir {};
66cdf0e10cSrcweir
67cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt );
68cdf0e10cSrcweir
69cdf0e10cSrcweir };
70cdf0e10cSrcweir
71cdf0e10cSrcweir
72cdf0e10cSrcweir class ImpPathDialog
73cdf0e10cSrcweir {
74cdf0e10cSrcweir friend class ImpFileDialog;
75cdf0e10cSrcweir
76cdf0e10cSrcweir private:
77cdf0e10cSrcweir PathDialog* pSvPathDialog;
78cdf0e10cSrcweir Edit* pEdit;
79cdf0e10cSrcweir FixedText* pDirTitel;
80cdf0e10cSrcweir KbdListBox* pDirList;
81cdf0e10cSrcweir FixedText* pDirPath;
82cdf0e10cSrcweir ListBox* pDriveList;
83cdf0e10cSrcweir FixedText* pDriveTitle;
84cdf0e10cSrcweir PushButton* pLoadBtn;
85cdf0e10cSrcweir PushButton* pOkBtn;
86cdf0e10cSrcweir PushButton* pCancelBtn;
87cdf0e10cSrcweir PushButton* pHomeBtn;
88cdf0e10cSrcweir PushButton* pNewDirBtn;
89cdf0e10cSrcweir
90cdf0e10cSrcweir sal_uInt16 nOwnChilds;
91cdf0e10cSrcweir
92cdf0e10cSrcweir DirEntry aPath; // aktuell angewaehlter Pfad
93cdf0e10cSrcweir sal_uInt16 nDirCount; // Anzahl der Verzeichnis-
94cdf0e10cSrcweir // Verschachtelungen
95cdf0e10cSrcweir
96cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
97cdf0e10cSrcweir xCollator;
98cdf0e10cSrcweir
99cdf0e10cSrcweir protected:
100cdf0e10cSrcweir
101cdf0e10cSrcweir virtual void UpdateEntries( const sal_Bool bWithDirs );
102cdf0e10cSrcweir void UpdateDirs( const DirEntry& rTmpPath );
103cdf0e10cSrcweir
104cdf0e10cSrcweir sal_Bool IsFileOk( const DirEntry& rDirEntry );
105cdf0e10cSrcweir void InitControls();
106cdf0e10cSrcweir
107cdf0e10cSrcweir DECL_LINK( SelectHdl, ListBox * );
108cdf0e10cSrcweir DECL_LINK( DblClickHdl, ListBox * );
109cdf0e10cSrcweir DECL_LINK( ClickHdl, Button * );
110cdf0e10cSrcweir
111cdf0e10cSrcweir public:
112cdf0e10cSrcweir ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir );
113cdf0e10cSrcweir virtual ~ImpPathDialog();
114cdf0e10cSrcweir
115cdf0e10cSrcweir virtual void SetPath( const String& rPath );
116cdf0e10cSrcweir virtual void SetPath( const Edit& rEdit );
117cdf0e10cSrcweir virtual String GetPath() const;
118cdf0e10cSrcweir
119cdf0e10cSrcweir virtual void PreExecute();
120cdf0e10cSrcweir virtual void PostExecute();
121cdf0e10cSrcweir
GetPathDialog() const122cdf0e10cSrcweir PathDialog* GetPathDialog() const { return pSvPathDialog; }
123cdf0e10cSrcweir
SetOkButtonText(const String & rText)124cdf0e10cSrcweir void SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
SetCancelButtonText(const String & rText)125cdf0e10cSrcweir void SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
126cdf0e10cSrcweir
127cdf0e10cSrcweir };
128cdf0e10cSrcweir
129cdf0e10cSrcweir
130cdf0e10cSrcweir class ImpFileDialog : public ImpPathDialog
131cdf0e10cSrcweir {
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir FixedText* pFileTitel;
134cdf0e10cSrcweir ListBox* pFileList;
135cdf0e10cSrcweir FixedText* pTypeTitel;
136cdf0e10cSrcweir ListBox* pTypeList;
137cdf0e10cSrcweir
138cdf0e10cSrcweir WildCard aMask; // aktuelle Maske
139cdf0e10cSrcweir
140cdf0e10cSrcweir ImpFilterList aFilterList; // Filterliste
141cdf0e10cSrcweir sal_uInt16 nCurFilter; // aktueller Filter
142cdf0e10cSrcweir
143cdf0e10cSrcweir sal_Bool bOpen; // sal_True = Open; sal_False = SAVEAS
144cdf0e10cSrcweir
145cdf0e10cSrcweir protected:
146cdf0e10cSrcweir void InitControls();
147cdf0e10cSrcweir
148cdf0e10cSrcweir String ExtendFileName( DirEntry aEntry ) const;
149cdf0e10cSrcweir
150cdf0e10cSrcweir DECL_LINK( SelectHdl, ListBox * );
151cdf0e10cSrcweir DECL_LINK( DblClickHdl, ListBox * );
152cdf0e10cSrcweir DECL_LINK( ClickHdl, Button * );
153cdf0e10cSrcweir
154cdf0e10cSrcweir virtual void UpdateEntries( const sal_Bool bWithDirs );
155cdf0e10cSrcweir sal_Bool IsFileOk( const DirEntry& rDirEntry );
156cdf0e10cSrcweir
157cdf0e10cSrcweir public:
158cdf0e10cSrcweir ImpFileDialog( PathDialog* pDlg, WinBits nStyle, RESOURCE_TYPE nType );
159cdf0e10cSrcweir virtual ~ImpFileDialog();
160cdf0e10cSrcweir
161cdf0e10cSrcweir void AddFilter( const String& rFilter, const String& rMask );
162cdf0e10cSrcweir void RemoveFilter( const String& rFilter );
163cdf0e10cSrcweir void RemoveAllFilter();
164cdf0e10cSrcweir void SetCurFilter( const String& rFilter );
165cdf0e10cSrcweir String GetCurFilter() const;
166cdf0e10cSrcweir
GetFilterCount() const167cdf0e10cSrcweir sal_uInt16 GetFilterCount() const { return (sal_uInt16)aFilterList.Count(); }
168cdf0e10cSrcweir inline String GetFilterName( sal_uInt16 nPos ) const;
169cdf0e10cSrcweir inline String GetFilterType( sal_uInt16 nPos ) const;
170cdf0e10cSrcweir
171cdf0e10cSrcweir virtual void SetPath( const String& rPath );
172cdf0e10cSrcweir virtual void SetPath( const Edit& rEdit );
173cdf0e10cSrcweir virtual String GetPath() const;
174cdf0e10cSrcweir
175cdf0e10cSrcweir virtual void PreExecute();
176cdf0e10cSrcweir
GetFileDialog() const177cdf0e10cSrcweir FileDialog* GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
178cdf0e10cSrcweir };
179cdf0e10cSrcweir
GetFilterName(sal_uInt16 nPos) const180cdf0e10cSrcweir inline String ImpFileDialog::GetFilterName( sal_uInt16 nPos ) const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir String aName;
183cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.GetObject( nPos );
184cdf0e10cSrcweir if ( pItem )
185cdf0e10cSrcweir aName = pItem->aName;
186cdf0e10cSrcweir return aName;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
GetFilterType(sal_uInt16 nPos) const189cdf0e10cSrcweir inline String ImpFileDialog::GetFilterType( sal_uInt16 nPos ) const
190cdf0e10cSrcweir {
191cdf0e10cSrcweir String aFilterMask;
192cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.GetObject( nPos );
193cdf0e10cSrcweir if ( pItem )
194cdf0e10cSrcweir aFilterMask = pItem->aMask;
195cdf0e10cSrcweir return aFilterMask;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir class ImpSvFileDlg
199cdf0e10cSrcweir {
200cdf0e10cSrcweir private:
201cdf0e10cSrcweir ImpPathDialog* pDlg;
202cdf0e10cSrcweir
203cdf0e10cSrcweir public:
ImpSvFileDlg()204cdf0e10cSrcweir ImpSvFileDlg() { pDlg = 0; }
~ImpSvFileDlg()205cdf0e10cSrcweir ~ImpSvFileDlg() { delete pDlg; }
206cdf0e10cSrcweir
GetDialog() const207cdf0e10cSrcweir ImpPathDialog* GetDialog() const { return pDlg; }
208cdf0e10cSrcweir void CreateDialog( PathDialog* pCreateFrom, WinBits nStyle, RESOURCE_TYPE nType, sal_Bool bCreate );
209cdf0e10cSrcweir
SetOkButtonText(const String & rText)210cdf0e10cSrcweir void SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); } // ihr habts ja nicht anders gewollt
SetCancelButtonText(const String & rText)211cdf0e10cSrcweir void SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
212cdf0e10cSrcweir
213cdf0e10cSrcweir };
214cdf0e10cSrcweir
215cdf0e10cSrcweir #endif // _FILEDLG2_HXX
216