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