xref: /trunk/main/svtools/source/dialogs/filedlg2.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _FILEDLG2_HXX
29 #define _FILEDLG2_HXX
30 
31 #include <tools/debug.hxx>
32 #include <tools/fsys.hxx>
33 #ifndef _SV_BUTTON_HXX //autogen wg. PushButton
34 #include <vcl/button.hxx>
35 #endif
36 #include <vcl/unohelp.hxx>
37 
38 class FixedText;
39 class Edit;
40 class ListBox;
41 class ListBox;
42 class Button;
43 
44 class PathDialog;
45 class FileDialog;
46 class ImpPathDialog;
47 
48 struct ImpFilterItem
49 {
50     String aName;
51     String aMask;
52 
53     ImpFilterItem( const String & rFilter, const String & rMask )
54     {
55         aName = rFilter;
56         aMask = rMask;
57     }
58 };
59 
60 DECLARE_LIST( ImpFilterList, ImpFilterItem* )
61 #include <vcl/lstbox.hxx>
62 
63 class KbdListBox : public ListBox
64 {
65 public:
66 
67                 KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
68                     : ListBox ( pParent, nStyle )
69                 {};
70 
71 virtual long    PreNotify( NotifyEvent& rNEvt );
72 
73 };
74 
75 
76 class ImpPathDialog
77 {
78     friend class ImpFileDialog;
79 
80 private:
81     PathDialog*         pSvPathDialog;
82     Edit*               pEdit;
83     FixedText*          pDirTitel;
84     KbdListBox*         pDirList;
85     FixedText*          pDirPath;
86     ListBox*            pDriveList;
87     FixedText*          pDriveTitle;
88     PushButton*         pLoadBtn;
89     PushButton*         pOkBtn;
90     PushButton*         pCancelBtn;
91     PushButton*         pHomeBtn;
92     PushButton*         pNewDirBtn;
93 
94     sal_uInt16              nOwnChilds;
95 
96     DirEntry            aPath;          // aktuell angewaehlter Pfad
97     sal_uInt16              nDirCount;      // Anzahl der Verzeichnis-
98                                         // Verschachtelungen
99 
100     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
101                         xCollator;
102 
103 protected:
104 
105     virtual void        UpdateEntries( const sal_Bool bWithDirs );
106     void                UpdateDirs( const DirEntry& rTmpPath );
107 
108     sal_Bool                IsFileOk( const DirEntry& rDirEntry );
109     void                InitControls();
110 
111     DECL_LINK(          SelectHdl, ListBox * );
112     DECL_LINK(          DblClickHdl, ListBox * );
113     DECL_LINK(          ClickHdl, Button * );
114 
115 public:
116                         ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir );
117     virtual             ~ImpPathDialog();
118 
119     virtual void        SetPath( const String& rPath );
120     virtual void        SetPath( const Edit& rEdit );
121     virtual String      GetPath() const;
122 
123     virtual void        PreExecute();
124     virtual void        PostExecute();
125 
126     PathDialog*     GetPathDialog() const   { return pSvPathDialog; }
127 
128     void            SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
129     void            SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
130 
131 };
132 
133 
134 class ImpFileDialog : public ImpPathDialog
135 {
136 private:
137     FixedText*          pFileTitel;
138     ListBox*            pFileList;
139     FixedText*          pTypeTitel;
140     ListBox*            pTypeList;
141 
142     WildCard            aMask;          // aktuelle Maske
143 
144     ImpFilterList       aFilterList;    // Filterliste
145     sal_uInt16              nCurFilter;     // aktueller Filter
146 
147     sal_Bool                bOpen;          // sal_True = Open; sal_False = SAVEAS
148 
149 protected:
150     void                InitControls();
151 
152     String              ExtendFileName( DirEntry aEntry ) const;
153 
154     DECL_LINK(          SelectHdl, ListBox * );
155     DECL_LINK(          DblClickHdl, ListBox * );
156     DECL_LINK(          ClickHdl, Button * );
157 
158     virtual void        UpdateEntries( const sal_Bool bWithDirs );
159     sal_Bool                IsFileOk( const DirEntry& rDirEntry );
160 
161 public:
162                         ImpFileDialog( PathDialog* pDlg, WinBits nStyle, RESOURCE_TYPE nType );
163     virtual             ~ImpFileDialog();
164 
165     void                AddFilter( const String& rFilter, const String& rMask );
166     void                RemoveFilter( const String& rFilter );
167     void                RemoveAllFilter();
168     void                SetCurFilter( const String& rFilter );
169     String              GetCurFilter() const;
170 
171     sal_uInt16              GetFilterCount() const  { return (sal_uInt16)aFilterList.Count(); }
172     inline String       GetFilterName( sal_uInt16 nPos ) const;
173     inline String       GetFilterType( sal_uInt16 nPos ) const;
174 
175     virtual void        SetPath( const String& rPath );
176     virtual void        SetPath( const Edit& rEdit );
177     virtual String      GetPath() const;
178 
179     virtual void        PreExecute();
180 
181     FileDialog*     GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
182 };
183 
184 inline String ImpFileDialog::GetFilterName( sal_uInt16 nPos ) const
185 {
186     String aName;
187     ImpFilterItem* pItem = aFilterList.GetObject( nPos );
188     if ( pItem )
189         aName = pItem->aName;
190     return aName;
191 }
192 
193 inline String ImpFileDialog::GetFilterType( sal_uInt16 nPos ) const
194 {
195     String aFilterMask;
196     ImpFilterItem* pItem = aFilterList.GetObject( nPos );
197     if ( pItem )
198         aFilterMask = pItem->aMask;
199     return aFilterMask;
200 }
201 
202 class ImpSvFileDlg
203 {
204 private:
205     ImpPathDialog*  pDlg;
206 
207 public:
208                     ImpSvFileDlg()      { pDlg = 0; }
209                     ~ImpSvFileDlg()     { delete pDlg; }
210 
211     ImpPathDialog*  GetDialog() const   { return pDlg; }
212     void            CreateDialog( PathDialog* pCreateFrom, WinBits nStyle, RESOURCE_TYPE nType, sal_Bool bCreate );
213 
214     void            SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); }  // ihr habts ja nicht anders gewollt
215     void            SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
216 
217 };
218 
219 #endif // _FILEDLG2_HXX
220