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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir #include <vcl/svapp.hxx> 31*cdf0e10cSrcweir #include <vcl/button.hxx> 32*cdf0e10cSrcweir #include <vcl/fixed.hxx> 33*cdf0e10cSrcweir #include <vcl/edit.hxx> 34*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 35*cdf0e10cSrcweir #include <svtools/svtdata.hxx> 36*cdf0e10cSrcweir #include <filedlg2.hxx> 37*cdf0e10cSrcweir #include <svtools/filedlg.hxx> 38*cdf0e10cSrcweir #include <svtools/filedlg2.hrc> 39*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 40*cdf0e10cSrcweir #include <vos/security.hxx> 41*cdf0e10cSrcweir #include <com/sun/star/i18n/XCollator.hpp> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <svtools/stdctrl.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #ifdef _MSC_VER 46*cdf0e10cSrcweir #pragma optimize ("", off) 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <svtools/helpid.hrc> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace com::sun::star; 52*cdf0e10cSrcweir using namespace com::sun::star::uno; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir DECLARE_LIST( UniStringList, UniString* ) 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #define STD_BTN_WIDTH 80 58*cdf0e10cSrcweir #define STD_BTN_HEIGHT 26 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #ifndef UNX 61*cdf0e10cSrcweir #define ALLFILES "*.*" 62*cdf0e10cSrcweir #else 63*cdf0e10cSrcweir #define ALLFILES "*" 64*cdf0e10cSrcweir #endif 65*cdf0e10cSrcweir // #define STD_BTN_WIDTH 90 66*cdf0e10cSrcweir // #define STD_BTN_HEIGHT 35 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #define INITCONTROL( p, ControlClass, nBits, aPos, aSize, aTitel, rHelpId ) \ 69*cdf0e10cSrcweir p = new ControlClass( GetPathDialog(), WinBits( nBits ) ); \ 70*cdf0e10cSrcweir p->SetHelpId( rHelpId ); \ 71*cdf0e10cSrcweir p->SetPosSizePixel( aPos, aSize ); \ 72*cdf0e10cSrcweir p->SetText( aTitel ); \ 73*cdf0e10cSrcweir p->Show(); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir inline sal_Bool IsPrintable( sal_Unicode c ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir return c >= 32 && c != 127 ? sal_True : sal_False; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir long 82*cdf0e10cSrcweir KbdListBox::PreNotify( NotifyEvent& rNEvt ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); 87*cdf0e10cSrcweir sal_Unicode cCharCode = aKeyEvt.GetCharCode(); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir if ( IsPrintable ( cCharCode ) ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir sal_uInt16 nCurrentPos = GetSelectEntryPos(); 92*cdf0e10cSrcweir sal_uInt16 nEntries = GetEntryCount(); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir for ( sal_uInt16 i = 1; i < nEntries; i++ ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir UniString aEntry = GetEntry ( (i + nCurrentPos) % nEntries ); 97*cdf0e10cSrcweir aEntry.EraseLeadingChars( ' ' ); 98*cdf0e10cSrcweir aEntry.ToUpperAscii(); 99*cdf0e10cSrcweir UniString aCompare( cCharCode ); 100*cdf0e10cSrcweir aCompare.ToUpperAscii(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir if ( aEntry.CompareTo( aCompare, 1 ) == COMPARE_EQUAL ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir SelectEntryPos ( (i + nCurrentPos) % nEntries ); 105*cdf0e10cSrcweir break; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir if ( aKeyEvt.GetKeyCode().GetCode() == KEY_RETURN ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir DoubleClick(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir return ListBox::PreNotify ( rNEvt ); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir ImpPathDialog::ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir pSvPathDialog = pDlg; 122*cdf0e10cSrcweir nDirCount = 0; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // initialize Controls if not used as a base class 125*cdf0e10cSrcweir if ( nType == WINDOW_PATHDIALOG ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir InitControls(); 128*cdf0e10cSrcweir if( pNewDirBtn ) 129*cdf0e10cSrcweir pNewDirBtn->Enable( bCreateDir ); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir pDlg->SetHelpId( HID_FILEDLG_PATHDLG ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir lang::Locale aLocale = Application::GetSettings().GetLocale(); 135*cdf0e10cSrcweir xCollator = ::vcl::unohelper::CreateCollator(); 136*cdf0e10cSrcweir if( xCollator.is() ) 137*cdf0e10cSrcweir xCollator->loadDefaultCollator( aLocale, 1 ); 138*cdf0e10cSrcweir DBG_ASSERT( xCollator.is(), "not collator service for path dialog" ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir ImpPathDialog::~ImpPathDialog() 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir delete pEdit; 144*cdf0e10cSrcweir delete pDirTitel; 145*cdf0e10cSrcweir delete pDirList; 146*cdf0e10cSrcweir delete pDirPath; 147*cdf0e10cSrcweir delete pDriveList; 148*cdf0e10cSrcweir delete pDriveTitle; 149*cdf0e10cSrcweir delete pLoadBtn; 150*cdf0e10cSrcweir delete pOkBtn; 151*cdf0e10cSrcweir delete pCancelBtn; 152*cdf0e10cSrcweir delete pNewDirBtn; 153*cdf0e10cSrcweir # if defined(UNX) || defined(OS2) 154*cdf0e10cSrcweir delete pHomeBtn; 155*cdf0e10cSrcweir # endif 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir void ImpPathDialog::InitControls() 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir PathDialog* pDlg = GetPathDialog(); 161*cdf0e10cSrcweir pDlg->SetText( UniString( SvtResId( STR_FILEDLG_SELECT ) ) ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir Size a3Siz = pDlg->LogicToPixel( Size( 3, 3 ), MAP_APPFONT ); 164*cdf0e10cSrcweir Size a6Siz = pDlg->LogicToPixel( Size( 6, 6 ), MAP_APPFONT ); 165*cdf0e10cSrcweir Size aBtnSiz = pDlg->LogicToPixel( Size( 50, 14 ), MAP_APPFONT ); 166*cdf0e10cSrcweir Size aFTSiz = pDlg->LogicToPixel( Size( 142, 10 ), MAP_APPFONT ); 167*cdf0e10cSrcweir Size aEDSiz = pDlg->LogicToPixel( Size( 142, 12 ), MAP_APPFONT ); 168*cdf0e10cSrcweir Point aPnt( a6Siz.Width(), a6Siz.Height() ); 169*cdf0e10cSrcweir long nLbH1 = pDlg->LogicToPixel( Size( 0, 93 ), MAP_APPFONT ).Height(); 170*cdf0e10cSrcweir long nH = 0; 171*cdf0e10cSrcweir UniString aEmptyStr; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir INITCONTROL( pDirTitel, FixedText, 0, 174*cdf0e10cSrcweir aPnt, aFTSiz, UniString( SvtResId( STR_FILEDLG_DIR ) ), HID_FILEDLG_DIR ); 175*cdf0e10cSrcweir aPnt.Y() += aFTSiz.Height() + a3Siz.Height(); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir INITCONTROL( pEdit, Edit, WB_BORDER, aPnt, aEDSiz, aPath.GetFull(), HID_FILEDLG_EDIT ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir aPnt.Y() += aEDSiz.Height() + a3Siz.Height(); 180*cdf0e10cSrcweir #ifndef UNX 181*cdf0e10cSrcweir long nLbH2 = pDlg->LogicToPixel( Size( 0, 60 ), MAP_APPFONT ).Height(); 182*cdf0e10cSrcweir INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER, 183*cdf0e10cSrcweir aPnt, Size( aEDSiz.Width(), nLbH1 ), aEmptyStr, HID_FILEDLG_DIRS ); 184*cdf0e10cSrcweir aPnt.Y() += nLbH1 + a6Siz.Height(); 185*cdf0e10cSrcweir INITCONTROL( pDriveTitle, FixedText, 0, 186*cdf0e10cSrcweir aPnt, aFTSiz, UniString( SvtResId( STR_FILEDLG_DRIVES ) ), HID_FILEDLG_DRIVE ); 187*cdf0e10cSrcweir aPnt.Y() += aFTSiz.Height() + a3Siz.Height(); 188*cdf0e10cSrcweir INITCONTROL( pDriveList, ListBox, WB_DROPDOWN, 189*cdf0e10cSrcweir aPnt, Size( aEDSiz.Width(), nLbH2 ), aEmptyStr, HID_FILEDLG_DRIVES ); 190*cdf0e10cSrcweir nH = aPnt.Y() + aEDSiz.Height() + a6Siz.Height(); 191*cdf0e10cSrcweir #else 192*cdf0e10cSrcweir long nNewH = nLbH1 + 3 * a3Siz.Height() + 193*cdf0e10cSrcweir aFTSiz.Height() + aEDSiz.Height(); 194*cdf0e10cSrcweir INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER, 195*cdf0e10cSrcweir aPnt, Size( aEDSiz.Width(), nNewH ), aEmptyStr, HID_FILEDLG_DIRS ); 196*cdf0e10cSrcweir nH = aPnt.Y() + nNewH + a6Siz.Height(); 197*cdf0e10cSrcweir pDriveTitle = NULL; 198*cdf0e10cSrcweir pDriveList = NULL; 199*cdf0e10cSrcweir #endif 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir long nExtraWidth = pDlg->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM( "(W)" ) ) )+10; 202*cdf0e10cSrcweir String aOkStr = Button::GetStandardText( BUTTON_OK ); 203*cdf0e10cSrcweir long nTextWidth = pDlg->GetTextWidth( aOkStr )+nExtraWidth; 204*cdf0e10cSrcweir if( nTextWidth > aBtnSiz.Width() ) 205*cdf0e10cSrcweir aBtnSiz.Width() = nTextWidth; 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir String aCancelStr = Button::GetStandardText( BUTTON_CANCEL ); 208*cdf0e10cSrcweir nTextWidth = pDlg->GetTextWidth( aCancelStr )+nExtraWidth; 209*cdf0e10cSrcweir if( nTextWidth > aBtnSiz.Width() ) 210*cdf0e10cSrcweir aBtnSiz.Width() = nTextWidth; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir String aNewDirStr( SvtResId( STR_FILEDLG_NEWDIR ) ); 213*cdf0e10cSrcweir nTextWidth = pDlg->GetTextWidth( aNewDirStr )+nExtraWidth; 214*cdf0e10cSrcweir if( nTextWidth > aBtnSiz.Width() ) 215*cdf0e10cSrcweir aBtnSiz.Width() = nTextWidth; 216*cdf0e10cSrcweir #if defined(UNX) || defined(OS2) 217*cdf0e10cSrcweir String aHomeDirStr( SvtResId( STR_FILEDLG_HOME ) ); 218*cdf0e10cSrcweir nTextWidth = pDlg->GetTextWidth( aHomeDirStr )+nExtraWidth; 219*cdf0e10cSrcweir if( nTextWidth > aBtnSiz.Width() ) 220*cdf0e10cSrcweir aBtnSiz.Width() = nTextWidth; 221*cdf0e10cSrcweir #endif 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir aPnt.X() = 2 * a6Siz.Width() + aEDSiz.Width(); 224*cdf0e10cSrcweir aPnt.Y() = a6Siz.Height(); 225*cdf0e10cSrcweir INITCONTROL( pOkBtn, PushButton, WB_DEFBUTTON, 226*cdf0e10cSrcweir aPnt, aBtnSiz, aOkStr, "" ); 227*cdf0e10cSrcweir aPnt.Y() += aBtnSiz.Height() + a3Siz.Height(); 228*cdf0e10cSrcweir INITCONTROL( pCancelBtn, CancelButton, 0, 229*cdf0e10cSrcweir aPnt, aBtnSiz, aCancelStr, "" ); 230*cdf0e10cSrcweir aPnt.Y() += aBtnSiz.Height() + a3Siz.Height(); 231*cdf0e10cSrcweir INITCONTROL( pNewDirBtn, PushButton, WB_DEFBUTTON, 232*cdf0e10cSrcweir aPnt, aBtnSiz, aNewDirStr, HID_FILEDLG_NEWDIR ); 233*cdf0e10cSrcweir #if defined(UNX) || defined(OS2) 234*cdf0e10cSrcweir aPnt.Y() += aBtnSiz.Height() + a3Siz.Height(); 235*cdf0e10cSrcweir INITCONTROL( pHomeBtn, PushButton, WB_DEFBUTTON, 236*cdf0e10cSrcweir aPnt, aBtnSiz, aHomeDirStr, HID_FILEDLG_HOME ); 237*cdf0e10cSrcweir #else 238*cdf0e10cSrcweir pHomeBtn = NULL; 239*cdf0e10cSrcweir #endif 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir pDirPath = 0; 242*cdf0e10cSrcweir pLoadBtn = 0; 243*cdf0e10cSrcweir // Dialogbreite == OKBtn-Position + OKBtn-Breite + Rand 244*cdf0e10cSrcweir long nW = aPnt.X() + aBtnSiz.Width() + a6Siz.Width(); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir pDlg->SetOutputSizePixel( Size( nW, nH ) ); // Groesse ggf. auch Resource wird geplaettet? 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if (pDirList) 249*cdf0e10cSrcweir pDirList->SetDoubleClickHdl(LINK( this, ImpPathDialog, DblClickHdl) ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir if (pDirList) 252*cdf0e10cSrcweir pDirList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if (pDriveList) 255*cdf0e10cSrcweir pDriveList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if (pOkBtn) 258*cdf0e10cSrcweir pOkBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if (pCancelBtn) 261*cdf0e10cSrcweir pCancelBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir if (pHomeBtn) 264*cdf0e10cSrcweir pHomeBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir if (pNewDirBtn) 267*cdf0e10cSrcweir pNewDirBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir nOwnChilds = pDlg->GetChildCount(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir IMPL_LINK( ImpPathDialog, SelectHdl, ListBox *, p ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir if( p == pDriveList ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir UniString aDrive( pDriveList->GetSelectEntry(), 0, 2); 279*cdf0e10cSrcweir aDrive += '\\'; 280*cdf0e10cSrcweir SetPath( aDrive ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir else 283*cdf0e10cSrcweir if( p == pDirList ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir // isolate the pure name of the entry 286*cdf0e10cSrcweir // removing trainling stuff and leading spaces 287*cdf0e10cSrcweir UniString aEntry( pDirList->GetSelectEntry() ); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir aEntry.EraseLeadingChars( ' ' ); 290*cdf0e10cSrcweir sal_uInt16 nPos = aEntry.Search( '/' ); 291*cdf0e10cSrcweir aEntry.Erase( nPos ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir // build the absolute path to the selected item 294*cdf0e10cSrcweir DirEntry aNewPath; 295*cdf0e10cSrcweir aNewPath.ToAbs(); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir sal_uInt16 nCurPos = pDirList->GetSelectEntryPos(); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir // Wird nach oben gewechselt 300*cdf0e10cSrcweir if( nCurPos < nDirCount ) 301*cdf0e10cSrcweir aNewPath = aNewPath[nDirCount-nCurPos-1]; 302*cdf0e10cSrcweir else 303*cdf0e10cSrcweir aNewPath += aEntry; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir pEdit->SetText( aNewPath.GetFull() ); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir return 0; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir IMPL_LINK( ImpPathDialog, ClickHdl, Button*, pBtn ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir if ( pBtn == pOkBtn || pBtn == pLoadBtn ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir DirEntry aFile( pEdit->GetText() ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir // Existiert File / File ueberschreiben 319*cdf0e10cSrcweir if( IsFileOk( aFile ) ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir // Ja, dann kompletten Pfad mit Filenamen merken und Dialog beenden 322*cdf0e10cSrcweir aPath = aFile; 323*cdf0e10cSrcweir aPath.ToAbs(); 324*cdf0e10cSrcweir GetPathDialog()->EndDialog( sal_True ); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir else 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir DirEntry aCheck( aPath ); 329*cdf0e10cSrcweir aCheck += aFile; 330*cdf0e10cSrcweir if( aCheck.Exists() ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir aCheck.ToAbs(); 333*cdf0e10cSrcweir SetPath( aCheck.GetFull() ); 334*cdf0e10cSrcweir pEdit->SetSelection( Selection( 0x7FFFFFFF, 0x7FFFFFFF ) ); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir else 339*cdf0e10cSrcweir if ( pBtn == pCancelBtn ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir GetPathDialog()->EndDialog( sal_False ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir else 344*cdf0e10cSrcweir if ( pBtn == pHomeBtn ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir ::rtl::OUString aHomeDir; 347*cdf0e10cSrcweir vos:: OSecurity aSecurity; 348*cdf0e10cSrcweir if ( aSecurity.getHomeDir( aHomeDir ) ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir DirEntry aFile ( aHomeDir ); 351*cdf0e10cSrcweir if ( IsFileOk( aFile ) ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir aFile.ToAbs(); 354*cdf0e10cSrcweir SetPath( aFile.GetFull() ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir else 359*cdf0e10cSrcweir if ( pBtn == pNewDirBtn ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir DirEntry aFile( pEdit->GetText() ); 362*cdf0e10cSrcweir if( ! aFile.Exists() && ! FileStat( aFile ).IsKind( FSYS_KIND_WILD ) ) 363*cdf0e10cSrcweir aFile.MakeDir(); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir if( IsFileOk ( aFile ) ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir aFile.ToAbs(); 368*cdf0e10cSrcweir SetPath( aFile.GetFull() ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir return 0; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir IMPL_LINK( ImpPathDialog, DblClickHdl, ListBox*, pBox ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir // isolate the pure name of the entry 379*cdf0e10cSrcweir // removing trainling stuff and leading spaces 380*cdf0e10cSrcweir UniString aEntry( pBox->GetSelectEntry() ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir aEntry.EraseLeadingChars( ' ' ); 383*cdf0e10cSrcweir sal_uInt16 nPos = aEntry.Search( '/' ); 384*cdf0e10cSrcweir aEntry.Erase( nPos ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // build the absolute path to the selected item 387*cdf0e10cSrcweir DirEntry aNewPath; 388*cdf0e10cSrcweir aNewPath.ToAbs(); 389*cdf0e10cSrcweir if( pBox == pDirList ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir sal_uInt16 nCurPos = pDirList->GetSelectEntryPos(); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // Wenn es schon das aktuelle ist, dann mache nichts 394*cdf0e10cSrcweir if( nCurPos == nDirCount-1 ) 395*cdf0e10cSrcweir return 0; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // Wird nach oben gewechselt 398*cdf0e10cSrcweir if( nCurPos < nDirCount ) 399*cdf0e10cSrcweir aNewPath = aNewPath[nDirCount-nCurPos-1]; 400*cdf0e10cSrcweir else 401*cdf0e10cSrcweir aNewPath += aEntry; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir aNewPath += aEntry; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir pSvPathDialog->EnterWait(); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir if( FileStat( aNewPath ).GetKind() & FSYS_KIND_DIR ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir // Neuen Pfad setzen und Listboxen updaten 411*cdf0e10cSrcweir aPath = aNewPath; 412*cdf0e10cSrcweir if( !aPath.SetCWD( sal_True ) ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir ErrorBox aBox( GetPathDialog(), 415*cdf0e10cSrcweir WB_OK_CANCEL | WB_DEF_OK, 416*cdf0e10cSrcweir UniString( SvtResId( STR_FILEDLG_CANTCHDIR ) ) ); 417*cdf0e10cSrcweir if( aBox.Execute() == RET_CANCEL ) 418*cdf0e10cSrcweir GetPathDialog()->EndDialog( sal_False ); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir UpdateEntries( sal_True ); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir pSvPathDialog->LeaveWait(); 424*cdf0e10cSrcweir return 0; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir void ImpPathDialog::UpdateEntries( const sal_Bool ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir UniString aTabString; 430*cdf0e10cSrcweir DirEntry aTmpPath; 431*cdf0e10cSrcweir aTmpPath.ToAbs(); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir nDirCount = aTmpPath.Level(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir pDirList->SetUpdateMode( sal_False ); 436*cdf0e10cSrcweir pDirList->Clear(); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir for( sal_uInt16 i = nDirCount; i > 0; i-- ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir UniString aName( aTabString ); 441*cdf0e10cSrcweir aName += aTmpPath[i-1].GetName(); 442*cdf0e10cSrcweir pDirList->InsertEntry( aName ); 443*cdf0e10cSrcweir aTabString.AppendAscii( " ", 2 ); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir // scan the directory 447*cdf0e10cSrcweir DirEntry aCurrent; 448*cdf0e10cSrcweir aCurrent.ToAbs(); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir Dir aDir( aCurrent, FSYS_KIND_DIR|FSYS_KIND_FILE ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir sal_uInt16 nEntries = aDir.Count(); 453*cdf0e10cSrcweir if( nEntries ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir UniStringList aSortDirList; 456*cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nEntries; n++ ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir DirEntry& rEntry = aDir[n]; 459*cdf0e10cSrcweir UniString aName( rEntry.GetName() ); 460*cdf0e10cSrcweir if( aName.Len() && ( aName.GetChar(0) != '.' ) && rEntry.Exists() ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir if( FileStat( rEntry ).GetKind() & FSYS_KIND_DIR ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir sal_uLong l = 0; 465*cdf0e10cSrcweir if( xCollator.is() ) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir for( l = 0; l < aSortDirList.Count(); l++ ) 468*cdf0e10cSrcweir if( xCollator->compareString( *aSortDirList.GetObject(l), aName ) > 0 ) 469*cdf0e10cSrcweir break; 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir aSortDirList.Insert( new UniString( aName ), l ); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir for( sal_uLong l = 0; l < aSortDirList.Count(); l++ ) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir UniString aEntryStr( aTabString ); 479*cdf0e10cSrcweir aEntryStr += *aSortDirList.GetObject(l); 480*cdf0e10cSrcweir pDirList->InsertEntry( aEntryStr ); 481*cdf0e10cSrcweir delete aSortDirList.GetObject(l); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir UpdateDirs( aTmpPath ); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir void ImpPathDialog::UpdateDirs( const DirEntry& rTmpPath ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir pDirList->SelectEntryPos( nDirCount-1 ); 491*cdf0e10cSrcweir pDirList->SetTopEntry( nDirCount > 1 492*cdf0e10cSrcweir ? nDirCount - 2 493*cdf0e10cSrcweir : nDirCount - 1 ); 494*cdf0e10cSrcweir pDirList->SetUpdateMode( sal_True ); 495*cdf0e10cSrcweir pDirList->Invalidate(); 496*cdf0e10cSrcweir pDirList->Update(); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir UniString aDirName = rTmpPath.GetFull(); 499*cdf0e10cSrcweir if( pDirPath ) 500*cdf0e10cSrcweir pDirPath->SetText( aDirName ); 501*cdf0e10cSrcweir else 502*cdf0e10cSrcweir pEdit->SetText( aDirName ); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir sal_Bool ImpPathDialog::IsFileOk( const DirEntry& rDirEntry ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir if( FileStat( rDirEntry ).GetKind() & (FSYS_KIND_WILD | FSYS_KIND_DEV) ) 508*cdf0e10cSrcweir return sal_False; 509*cdf0e10cSrcweir else 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir // Datei vorhanden ? 512*cdf0e10cSrcweir if( ! rDirEntry.Exists() ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir UniString aQueryTxt( SvtResId( STR_FILEDLG_ASKNEWDIR ) ); 515*cdf0e10cSrcweir aQueryTxt.SearchAndReplaceAscii( "%s", rDirEntry.GetFull() ); 516*cdf0e10cSrcweir QueryBox aQuery( GetPathDialog(), 517*cdf0e10cSrcweir WB_YES_NO | WB_DEF_YES, 518*cdf0e10cSrcweir aQueryTxt ); 519*cdf0e10cSrcweir if( aQuery.Execute() == RET_YES ) 520*cdf0e10cSrcweir rDirEntry.MakeDir(); 521*cdf0e10cSrcweir else 522*cdf0e10cSrcweir return sal_False; 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir if( !FileStat( rDirEntry ).IsKind( FSYS_KIND_DIR ) ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir UniString aBoxText( SvtResId( STR_FILEDLG_CANTOPENDIR ) ); 527*cdf0e10cSrcweir aBoxText.AppendAscii( "\n[" ); 528*cdf0e10cSrcweir aBoxText += rDirEntry.GetFull(); 529*cdf0e10cSrcweir aBoxText.AppendAscii( "]" ); 530*cdf0e10cSrcweir InfoBox aBox( GetPathDialog(), aBoxText ); 531*cdf0e10cSrcweir aBox.Execute(); 532*cdf0e10cSrcweir return sal_False; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir return GetPathDialog()->OK() != 0; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir void ImpPathDialog::PreExecute() 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir // Neues Verzeichnis setzen und Listboxen updaten 542*cdf0e10cSrcweir aPath.SetCWD( sal_True ); 543*cdf0e10cSrcweir UpdateEntries( sal_True ); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir // Zusaetzliche Buttons anordnen 546*cdf0e10cSrcweir Point aPos; 547*cdf0e10cSrcweir Size aSize; 548*cdf0e10cSrcweir long nDY; 549*cdf0e10cSrcweir if( pLoadBtn ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir aPos = pLoadBtn->GetPosPixel(); 552*cdf0e10cSrcweir aSize = pLoadBtn->GetSizePixel(); 553*cdf0e10cSrcweir nDY = pLoadBtn->GetSizePixel().Height() * 2; 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir else 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir aPos = pCancelBtn->GetPosPixel(); 558*cdf0e10cSrcweir aSize = pCancelBtn->GetSizePixel(); 559*cdf0e10cSrcweir nDY = pCancelBtn->GetPosPixel().Y() - pOkBtn->GetPosPixel().Y(); 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir // Standard-Controls anpassen 563*cdf0e10cSrcweir long nMaxWidth = 0; 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // Maximale Breite ermitteln 566*cdf0e10cSrcweir sal_uInt16 nChilds = GetPathDialog()->GetChildCount(); 567*cdf0e10cSrcweir sal_uInt16 n; 568*cdf0e10cSrcweir for ( n = nOwnChilds; n < nChilds; n++ ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir Window* pChild = GetPathDialog()->GetChild( n ); 571*cdf0e10cSrcweir pChild = pChild->GetWindow( WINDOW_CLIENT ); 572*cdf0e10cSrcweir if( pChild->GetType() != WINDOW_WINDOW ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir long nWidth = pChild->GetTextWidth( pChild->GetText() ) + 12; 575*cdf0e10cSrcweir if( nMaxWidth < nWidth ) 576*cdf0e10cSrcweir nMaxWidth = nWidth; 577*cdf0e10cSrcweir nWidth = pChild->GetSizePixel().Width(); 578*cdf0e10cSrcweir if( nMaxWidth < nWidth ) 579*cdf0e10cSrcweir nMaxWidth = nWidth; 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir if( nMaxWidth > aSize.Width() ) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir Size aDlgSize = GetPathDialog()->GetOutputSizePixel(); 586*cdf0e10cSrcweir GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nMaxWidth-aSize.Width(), aDlgSize.Height() ) ); 587*cdf0e10cSrcweir aSize.Width() = nMaxWidth; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if( pOkBtn ) 590*cdf0e10cSrcweir pOkBtn->SetSizePixel( aSize ); 591*cdf0e10cSrcweir if( pCancelBtn ) 592*cdf0e10cSrcweir pCancelBtn->SetSizePixel( aSize ); 593*cdf0e10cSrcweir if( pLoadBtn ) 594*cdf0e10cSrcweir pLoadBtn->SetSizePixel( aSize ); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir else 597*cdf0e10cSrcweir nMaxWidth = aSize.Width(); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir for ( n = nOwnChilds; n < nChilds; n++ ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir Window* pChild = GetPathDialog()->GetChild( n ); 602*cdf0e10cSrcweir pChild = pChild->GetWindow( WINDOW_CLIENT ); 603*cdf0e10cSrcweir if( pChild->GetType() != WINDOW_WINDOW ) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir aPos.Y() += nDY; 606*cdf0e10cSrcweir pChild->SetPosSizePixel( aPos, aSize ); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir else 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir Size aDlgSize = GetPathDialog()->GetOutputSizePixel(); 611*cdf0e10cSrcweir long nExtra = Min( aDlgSize.Height(), (long)160); 612*cdf0e10cSrcweir GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nExtra, aDlgSize.Height() ) ); 613*cdf0e10cSrcweir Size aSz( nExtra, nExtra ); 614*cdf0e10cSrcweir aSz.Width() -= 8; 615*cdf0e10cSrcweir aSz.Height() -= 8; 616*cdf0e10cSrcweir Point aCtrlPos( aDlgSize.Width() + 2, (aDlgSize.Height()-aSz.Height())/2 ); 617*cdf0e10cSrcweir pChild->SetPosSizePixel( aCtrlPos, aSz ); 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir // Laufwerke-LB fuellen 622*cdf0e10cSrcweir if( pDriveList ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir DirEntry aTmpDirEntry; 625*cdf0e10cSrcweir Dir aDir( aTmpDirEntry, FSYS_KIND_BLOCK ); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir sal_uInt16 nCount = aDir.Count(), i; 628*cdf0e10cSrcweir for( i = 0; i < nCount; ++i ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir DirEntry& rEntry = aDir[i]; 631*cdf0e10cSrcweir UniString aStr = rEntry.GetFull( FSYS_STYLE_HOST, sal_False ); 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir UniString aVolume = rEntry.GetVolume() ; 634*cdf0e10cSrcweir aStr.ToUpperAscii(); 635*cdf0e10cSrcweir if ( aVolume.Len() ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir aStr += ' '; 638*cdf0e10cSrcweir aStr += aVolume; 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir pDriveList->InsertEntry( aStr ); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir UniString aPathStr = aPath.GetFull(); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir for ( i = 0; i < pDriveList->GetEntryCount(); ++i ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir UniString aEntry = pDriveList->GetEntry(i); 648*cdf0e10cSrcweir xub_StrLen nLen = aEntry.Len(); 649*cdf0e10cSrcweir nLen = nLen > 2 ? 2 : nLen; 650*cdf0e10cSrcweir if ( aEntry.CompareIgnoreCaseToAscii( aPathStr, nLen ) == COMPARE_EQUAL ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir pDriveList->SelectEntryPos(i); 653*cdf0e10cSrcweir break; 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir void ImpPathDialog::PostExecute() 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir void ImpPathDialog::SetPath( UniString const & rPath ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir aPath = DirEntry( rPath ); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir pSvPathDialog->EnterWait(); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir DirEntry aFile( rPath ); 670*cdf0e10cSrcweir // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt 671*cdf0e10cSrcweir // -> abschneiden und merken 672*cdf0e10cSrcweir if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() ) 673*cdf0e10cSrcweir aFile.CutName(); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten 676*cdf0e10cSrcweir pEdit->SetText( rPath ); 677*cdf0e10cSrcweir aFile.SetCWD( sal_True ); 678*cdf0e10cSrcweir UpdateEntries( sal_True ); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir pSvPathDialog->LeaveWait(); 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir void ImpPathDialog::SetPath( Edit const & rEdit ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir UniString aPresetText = rEdit.GetText(); 686*cdf0e10cSrcweir if( aPresetText.Len() ) 687*cdf0e10cSrcweir SetPath( aPresetText ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir UniString ImpPathDialog::GetPath() const 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir DirEntry aFile( pEdit->GetText() ); 694*cdf0e10cSrcweir aFile.ToAbs(); 695*cdf0e10cSrcweir return aFile.GetFull(); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir ImpFileDialog::ImpFileDialog( PathDialog* pDlg, WinBits nWinBits, RESOURCE_TYPE nType ) : 700*cdf0e10cSrcweir ImpPathDialog( pDlg, nType, sal_False ) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir bOpen = (nWinBits & WB_SAVEAS) == 0; 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir SvtResId aSvtResId = bOpen ? STR_FILEDLG_OPEN : STR_FILEDLG_SAVE; 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir // Titel setzen 707*cdf0e10cSrcweir GetFileDialog()->SetText( UniString( aSvtResId ) ); 708*cdf0e10cSrcweir nDirCount = 0; 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir // initialize Controls if not used as a base class 711*cdf0e10cSrcweir if ( nType == WINDOW_FILEDIALOG ) 712*cdf0e10cSrcweir InitControls(); 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir pDlg->SetHelpId( HID_FILEDLG_OPENDLG ); 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir ImpFileDialog::~ImpFileDialog() 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.First(); 721*cdf0e10cSrcweir while( pItem ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir delete pItem; 724*cdf0e10cSrcweir pItem = aFilterList.Next(); 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir delete pFileTitel; 728*cdf0e10cSrcweir if (pFileList && ( pFileList != pDirList ) ) 729*cdf0e10cSrcweir delete pFileList; 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir delete pTypeTitel; 732*cdf0e10cSrcweir delete pTypeList; 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir void ImpFileDialog::InitControls() 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir UniString aEmptyStr; 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir const int nW = 160; 740*cdf0e10cSrcweir const int nH = 48; // Um den Dialog in eine akzeptable Form zu bringen 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir INITCONTROL( pFileTitel, FixedText, 0, 743*cdf0e10cSrcweir Point(10, 12), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_FILE ) ), HID_FILEDLG_FILE ); 744*cdf0e10cSrcweir INITCONTROL( pEdit, Edit, WB_BORDER, 745*cdf0e10cSrcweir Point(10, 31), Size(nW, 20), aEmptyStr, HID_FILEDLG_EDIT ); // aMask() 746*cdf0e10cSrcweir INITCONTROL( pFileList, ListBox, WB_SORT | WB_AUTOHSCROLL | WB_BORDER, 747*cdf0e10cSrcweir Point(10, 58), Size(nW, 180-nH), aEmptyStr, HID_FILEDLG_FILES ); 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir INITCONTROL( pDirTitel, FixedText, 0, 750*cdf0e10cSrcweir Point(nW+20, 12), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_DIR ) ), HID_FILEDLG_DIR ); 751*cdf0e10cSrcweir INITCONTROL( pDirPath, FixedInfo, WB_PATHELLIPSIS, 752*cdf0e10cSrcweir Point(nW+20, 33), Size(nW, 20), aPath.GetFull(), HID_FILEDLG_PATH ); 753*cdf0e10cSrcweir INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER, 754*cdf0e10cSrcweir Point(nW+20, 58), Size(nW, 180-nH ), aEmptyStr, HID_FILEDLG_DIRS ); 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir INITCONTROL( pTypeTitel, FixedText, 0, 757*cdf0e10cSrcweir Point(10, 246-nH), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_TYPE ) ), HID_FILEDLG_TYPE ); 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir #ifndef UNX 760*cdf0e10cSrcweir INITCONTROL( pTypeList, ListBox, WB_DROPDOWN, 761*cdf0e10cSrcweir Point(10, 265-nH ), Size(nW, 100 ), aEmptyStr, HID_FILEDLG_TYPES ); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir INITCONTROL( pDriveTitle, FixedText, 0, 764*cdf0e10cSrcweir Point(nW+20, 246-nH), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_DRIVES ) ), HID_FILEDLG_DRIVE ); 765*cdf0e10cSrcweir INITCONTROL( pDriveList, ListBox, WB_DROPDOWN, 766*cdf0e10cSrcweir Point(nW+20, 265-nH ), Size(nW, 100 ), aEmptyStr, HID_FILEDLG_DRIVES ); 767*cdf0e10cSrcweir pNewDirBtn = NULL; 768*cdf0e10cSrcweir pHomeBtn = NULL; 769*cdf0e10cSrcweir #else 770*cdf0e10cSrcweir INITCONTROL( pTypeList, ListBox, WB_DROPDOWN, 771*cdf0e10cSrcweir Point(10, 265-nH ), Size(2*nW+20, 100 ), aEmptyStr, HID_FILEDLG_TYPES ); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir pDriveTitle = NULL; 774*cdf0e10cSrcweir pDriveList = NULL; 775*cdf0e10cSrcweir pNewDirBtn = NULL; 776*cdf0e10cSrcweir pHomeBtn = NULL; 777*cdf0e10cSrcweir #endif 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir const long nButtonStartX = 2*nW+20+15; 780*cdf0e10cSrcweir INITCONTROL( pOkBtn, PushButton, WB_DEFBUTTON, 781*cdf0e10cSrcweir Point(nButtonStartX, 10), Size(STD_BTN_WIDTH, STD_BTN_HEIGHT), 782*cdf0e10cSrcweir Button::GetStandardText( BUTTON_OK ), "" ); 783*cdf0e10cSrcweir INITCONTROL( pCancelBtn, CancelButton, 0, 784*cdf0e10cSrcweir Point(nButtonStartX, 45 ), Size(STD_BTN_WIDTH, STD_BTN_HEIGHT), 785*cdf0e10cSrcweir Button::GetStandardText( BUTTON_CANCEL ), "" ); 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir pLoadBtn = 0; 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir GetFileDialog()->SetOutputSizePixel( Size(nButtonStartX+STD_BTN_WIDTH+10, 298-nH) ); 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir nOwnChilds = GetPathDialog()->GetChildCount(); 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir // Handler setzen 794*cdf0e10cSrcweir if (pDriveList) 795*cdf0e10cSrcweir pDriveList->SetSelectHdl( LINK( this, ImpFileDialog, SelectHdl ) ); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir if (pDirList) 798*cdf0e10cSrcweir pDirList->SetDoubleClickHdl(LINK( this, ImpFileDialog, DblClickHdl) ); 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir if (pOkBtn) 801*cdf0e10cSrcweir pOkBtn->SetClickHdl( LINK( this, ImpFileDialog, ClickHdl) ); 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir if (pCancelBtn) 804*cdf0e10cSrcweir pCancelBtn->SetClickHdl( LINK( this, ImpFileDialog, ClickHdl) ); 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir if( pFileList ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir pFileList->SetSelectHdl( LINK( this, ImpFileDialog, SelectHdl ) ); 809*cdf0e10cSrcweir pFileList->SetDoubleClickHdl( LINK( this, ImpFileDialog, DblClickHdl ) ); 810*cdf0e10cSrcweir } 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir if( pTypeList ) 813*cdf0e10cSrcweir pTypeList->SetSelectHdl( LINK( this, ImpFileDialog, DblClickHdl ) ); 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir IMPL_LINK( ImpFileDialog, SelectHdl, ListBox *, p ) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir if( p == pDriveList ) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir UniString aDrive ( pDriveList->GetSelectEntry(), 0, 2); 821*cdf0e10cSrcweir aDrive += '\\'; 822*cdf0e10cSrcweir SetPath( aDrive ); 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir else if (p == pFileList) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir // Ausgewaehltes File in das Edit stellen 827*cdf0e10cSrcweir pEdit->SetText( pFileList->GetSelectEntry() ); 828*cdf0e10cSrcweir GetFileDialog()->FileSelect(); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir return 0; 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir IMPL_LINK( ImpFileDialog, DblClickHdl, ListBox *, pBox ) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir // isolate the pure name of the entry 837*cdf0e10cSrcweir // removing trailing stuff and leading spaces 838*cdf0e10cSrcweir UniString aEntry( pBox->GetSelectEntry() ); 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir aEntry.EraseLeadingChars( ' ' ); 841*cdf0e10cSrcweir sal_uInt16 nPos = aEntry.Search( '/' ); 842*cdf0e10cSrcweir aEntry.Erase( nPos ); 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir // build the absolute path to the selected item 845*cdf0e10cSrcweir DirEntry aNewPath; 846*cdf0e10cSrcweir aNewPath.ToAbs(); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir if( ( pDirList != pFileList ) && ( pBox == pDirList ) ) 849*cdf0e10cSrcweir { 850*cdf0e10cSrcweir // SVLOOK 851*cdf0e10cSrcweir sal_uInt16 nCurPos = pDirList->GetSelectEntryPos(); 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir // Wenn es schon das aktuelle ist, dann mache nichts 854*cdf0e10cSrcweir if( nCurPos == nDirCount-1 ) 855*cdf0e10cSrcweir return 0; 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // Wird nach oben gewechselt 858*cdf0e10cSrcweir if( nCurPos < nDirCount ) 859*cdf0e10cSrcweir aNewPath = aNewPath[nDirCount-nCurPos-1]; 860*cdf0e10cSrcweir else 861*cdf0e10cSrcweir aNewPath += aEntry; 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir else 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir // non-SVLOOK 866*cdf0e10cSrcweir if( aEntry == UniString( SvtResId( STR_FILEDLG_GOUP ) ) ) 867*cdf0e10cSrcweir aEntry.AssignAscii( ".." ); 868*cdf0e10cSrcweir aNewPath += aEntry; 869*cdf0e10cSrcweir } 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir if( pBox == pFileList ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir DirEntry aFile( aEntry ); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir // Abfrage, ob File ueberschrieben werden soll... 876*cdf0e10cSrcweir if( !FileStat(aFile).IsKind(FSYS_KIND_DIR) && IsFileOk( aFile ) ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir // dann kompletten Pfad mit Filenamen merken und Dialog beenden 879*cdf0e10cSrcweir aPath = aNewPath; 880*cdf0e10cSrcweir GetFileDialog()->EndDialog( sal_True ); 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir GetFileDialog()->EnterWait(); 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir UniString aFull = aNewPath.GetFull(); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if( ( ( pBox == pDirList ) && ( pDirList != pFileList ) ) || 889*cdf0e10cSrcweir ( ( pDirList == pFileList ) && FileStat( aNewPath ).GetKind() & FSYS_KIND_DIR ) ) 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir // Neuen Pfad setzen und Listboxen updaten 892*cdf0e10cSrcweir aPath = aNewPath; 893*cdf0e10cSrcweir if( !aPath.SetCWD( sal_True ) ) 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir if( ErrorBox( GetFileDialog(), WB_OK_CANCEL|WB_DEF_OK, 896*cdf0e10cSrcweir UniString( SvtResId( STR_FILEDLG_CANTCHDIR ) ) ).Execute() == RET_CANCEL ) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir GetFileDialog()->EndDialog( sal_False ); 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir UpdateEntries( sal_True ); 902*cdf0e10cSrcweir GetFileDialog()->FileSelect(); 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir if( pBox == pTypeList ) 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir // Neue Maske setzen, und Listboxen updaten 908*cdf0e10cSrcweir sal_uInt16 nCurPos = pTypeList->GetSelectEntryPos(); 909*cdf0e10cSrcweir if( nCurPos+1 > (sal_uInt16)aFilterList.Count() ) 910*cdf0e10cSrcweir aMask = UniString::CreateFromAscii( ALLFILES ); 911*cdf0e10cSrcweir else 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir UniString aFilterListMask = aFilterList.GetObject( nCurPos )->aMask; 914*cdf0e10cSrcweir // if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske 915*cdf0e10cSrcweir // aMask = WildCard( aFilterListMask, '\0' ); 916*cdf0e10cSrcweir // else // ; muss beruecksichtigt werden 917*cdf0e10cSrcweir aMask = WildCard( aFilterListMask, ';' ); 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir pEdit->SetText( aMask() ); 921*cdf0e10cSrcweir UpdateEntries( sal_False ); 922*cdf0e10cSrcweir GetFileDialog()->FilterSelect(); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir GetFileDialog()->LeaveWait(); 926*cdf0e10cSrcweir 927*cdf0e10cSrcweir return 0; 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir IMPL_LINK( ImpFileDialog, ClickHdl, Button*, pBtn ) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir if( ( pBtn == pOkBtn ) || ( pBtn == pLoadBtn ) ) 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir DirEntry aFile( pEdit->GetText() ); 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir // Existiert File / File ueberschreiben 937*cdf0e10cSrcweir if( IsFileOk( aFile ) ) 938*cdf0e10cSrcweir { 939*cdf0e10cSrcweir // Ja, dann kompletten Pfad mit Filenamen merken und Dialog beenden 940*cdf0e10cSrcweir aPath = aFile; 941*cdf0e10cSrcweir aPath.ToAbs(); 942*cdf0e10cSrcweir GetFileDialog()->EndDialog( sal_True ); 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir else 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir GetFileDialog()->EnterWait(); 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt 949*cdf0e10cSrcweir // -> abschneiden und merken 950*cdf0e10cSrcweir if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() ) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir aMask = aFile.CutName(); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten 956*cdf0e10cSrcweir pEdit->SetText( aMask() ); 957*cdf0e10cSrcweir aFile.SetCWD( sal_True ); 958*cdf0e10cSrcweir UpdateEntries( sal_True ); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir GetFileDialog()->LeaveWait(); 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir } 963*cdf0e10cSrcweir else if( pBtn == pCancelBtn ) 964*cdf0e10cSrcweir GetFileDialog()->EndDialog( sal_False ); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir return 0; 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir void ImpFileDialog::UpdateEntries( const sal_Bool bWithDirs ) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir GetFileDialog()->EnterWait(); 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir UniString aTabString; 974*cdf0e10cSrcweir DirEntry aTmpPath; 975*cdf0e10cSrcweir aTmpPath.ToAbs(); 976*cdf0e10cSrcweir nDirCount = aTmpPath.Level(); 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir if( pFileList ) 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir pFileList->SetUpdateMode( sal_False ); 981*cdf0e10cSrcweir pFileList->Clear(); 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir if( bWithDirs && (pDirList != pFileList) ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir pDirList->SetUpdateMode( sal_False ); 987*cdf0e10cSrcweir pDirList->Clear(); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir for( sal_uInt16 i = nDirCount; i > 0; i-- ) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir UniString aEntryStr( aTabString ); 992*cdf0e10cSrcweir aEntryStr += aTmpPath[i-1].GetName(); 993*cdf0e10cSrcweir pDirList->InsertEntry( aEntryStr ); 994*cdf0e10cSrcweir aTabString.AppendAscii( " ", 2 ); 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir } 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir // for the combined box insert a '..' 999*cdf0e10cSrcweir // (this happens only if WB_3DLOOK is not set) 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir if( pDirList == pFileList && nDirCount != 1 ) 1002*cdf0e10cSrcweir pFileList->InsertEntry( UniString( SvtResId( STR_FILEDLG_GOUP ) ) ); 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir // scan the directory 1005*cdf0e10cSrcweir DirEntry aCurrent; 1006*cdf0e10cSrcweir aCurrent.ToAbs(); 1007*cdf0e10cSrcweir Dir aDir( aCurrent, FSYS_KIND_DIR|FSYS_KIND_FILE ); 1008*cdf0e10cSrcweir sal_uInt16 nEntries = aDir.Count(); 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir // TempMask, weil Vergleich case-sensitiv 1011*cdf0e10cSrcweir sal_Bool bMatchCase = sal_False; //aCurrent.IsCaseSensitive(); 1012*cdf0e10cSrcweir UniString aWildCard( aMask.GetWildCard() ); 1013*cdf0e10cSrcweir if ( !bMatchCase ) 1014*cdf0e10cSrcweir aWildCard.ToLowerAscii(); 1015*cdf0e10cSrcweir WildCard aTmpMask( aWildCard, ';' ); 1016*cdf0e10cSrcweir if ( nEntries ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir UniStringList aSortDirList; 1019*cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nEntries; n++ ) 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir DirEntry& rEntry = aDir[n]; 1022*cdf0e10cSrcweir UniString aName( rEntry.GetName() ); 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir if( aName.Len() && 1025*cdf0e10cSrcweir ( ( ( aName.GetChar(0) != '.' ) || 1026*cdf0e10cSrcweir ( ( aName.GetChar(0) == '.' ) && ( aMask.GetWildCard() ).GetChar(0) == '.' ) ) 1027*cdf0e10cSrcweir && rEntry.Exists() ) ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir FileStat aFileStat( rEntry ); 1030*cdf0e10cSrcweir UniString aTmpName( aName ); 1031*cdf0e10cSrcweir if ( !bMatchCase ) 1032*cdf0e10cSrcweir aTmpName.ToLowerAscii(); 1033*cdf0e10cSrcweir if( ( aFileStat.GetKind() & FSYS_KIND_FILE ) && aTmpMask.Matches( aTmpName ) ) 1034*cdf0e10cSrcweir { 1035*cdf0e10cSrcweir if( pFileList ) 1036*cdf0e10cSrcweir pFileList->InsertEntry( aName ); 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir else if( bWithDirs && ( aFileStat.GetKind() & FSYS_KIND_DIR ) ) 1039*cdf0e10cSrcweir { 1040*cdf0e10cSrcweir if( pDirList == pFileList ) 1041*cdf0e10cSrcweir { 1042*cdf0e10cSrcweir UniString aEntryStr( aName ); 1043*cdf0e10cSrcweir aEntryStr += '/'; 1044*cdf0e10cSrcweir pDirList->InsertEntry( aEntryStr ); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir else 1047*cdf0e10cSrcweir { 1048*cdf0e10cSrcweir sal_uLong l = 0; 1049*cdf0e10cSrcweir if( xCollator.is() ) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir for( l = 0; l < aSortDirList.Count(); l++ ) 1052*cdf0e10cSrcweir if( xCollator->compareString( *aSortDirList.GetObject(l), aName ) > 0 ) 1053*cdf0e10cSrcweir break; 1054*cdf0e10cSrcweir } 1055*cdf0e10cSrcweir aSortDirList.Insert( new UniString( aName ), l ); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir for( sal_uLong l = 0; l < aSortDirList.Count(); l++ ) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir UniString aEntryStr( aTabString ); 1063*cdf0e10cSrcweir aEntryStr += *aSortDirList.GetObject(l); 1064*cdf0e10cSrcweir pDirList->InsertEntry( aEntryStr ); 1065*cdf0e10cSrcweir delete aSortDirList.GetObject(l); 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir if( bWithDirs ) 1070*cdf0e10cSrcweir UpdateDirs( aTmpPath ); 1071*cdf0e10cSrcweir 1072*cdf0e10cSrcweir if( pFileList ) 1073*cdf0e10cSrcweir { 1074*cdf0e10cSrcweir if ( pDirList == pFileList && nDirCount > 1 ) 1075*cdf0e10cSrcweir pFileList->SelectEntryPos( 1 ); 1076*cdf0e10cSrcweir else 1077*cdf0e10cSrcweir pFileList->SetNoSelection(); 1078*cdf0e10cSrcweir pFileList->SetUpdateMode( sal_True ); 1079*cdf0e10cSrcweir pFileList->Invalidate(); 1080*cdf0e10cSrcweir pFileList->Update(); 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir if( pDriveList ) 1084*cdf0e10cSrcweir { 1085*cdf0e10cSrcweir if( pDirList->GetEntryCount() > 0 ) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir UniString aStr( pDirList->GetEntry( 0 ) ); 1088*cdf0e10cSrcweir aStr.Erase( 2 ); 1089*cdf0e10cSrcweir aStr.ToLowerAscii(); 1090*cdf0e10cSrcweir pDriveList->SelectEntry( aStr ); 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir GetFileDialog()->LeaveWait(); 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir sal_Bool ImpFileDialog::IsFileOk( const DirEntry& rDirEntry ) 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir if( FileStat( rDirEntry ).GetKind() & (FSYS_KIND_WILD | FSYS_KIND_DEV) ) 1100*cdf0e10cSrcweir return sal_False; 1101*cdf0e10cSrcweir if( FileStat( rDirEntry ).GetKind() & FSYS_KIND_DIR ) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir if( pFileList ) 1104*cdf0e10cSrcweir return sal_False; 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir else if( bOpen ) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir // Datei vorhanden ? 1109*cdf0e10cSrcweir if( !FileStat( rDirEntry ).IsKind( FSYS_KIND_FILE ) ) 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir UniString aErrorString( SvtResId( STR_FILEDLG_CANTOPENFILE ) ); 1112*cdf0e10cSrcweir aErrorString.AppendAscii( "\n[" ); 1113*cdf0e10cSrcweir aErrorString += rDirEntry.GetFull(); 1114*cdf0e10cSrcweir aErrorString += ']'; 1115*cdf0e10cSrcweir InfoBox aBox( GetFileDialog(), 1116*cdf0e10cSrcweir aErrorString ); 1117*cdf0e10cSrcweir aBox.Execute(); 1118*cdf0e10cSrcweir return sal_False; 1119*cdf0e10cSrcweir } 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir else 1122*cdf0e10cSrcweir { 1123*cdf0e10cSrcweir // Datei vorhanden ? 1124*cdf0e10cSrcweir if( FileStat( ExtendFileName( rDirEntry ) ).IsKind( FSYS_KIND_FILE ) ) 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir UniString aQueryString( SvtResId( STR_FILEDLG_OVERWRITE ) ); 1127*cdf0e10cSrcweir aQueryString.AppendAscii( "\n[" ); 1128*cdf0e10cSrcweir aQueryString += rDirEntry.GetFull(); 1129*cdf0e10cSrcweir aQueryString += ']'; 1130*cdf0e10cSrcweir QueryBox aBox( GetFileDialog(), 1131*cdf0e10cSrcweir WinBits( WB_YES_NO | WB_DEF_NO ), 1132*cdf0e10cSrcweir aQueryString ); 1133*cdf0e10cSrcweir if( aBox.Execute() != RET_YES ) 1134*cdf0e10cSrcweir return sal_False; 1135*cdf0e10cSrcweir } 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir return GetFileDialog()->OK() != 0; 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir void ImpFileDialog::SetPath( UniString const & rPath ) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir aPath = DirEntry( rPath ); 1143*cdf0e10cSrcweir GetFileDialog()->EnterWait(); 1144*cdf0e10cSrcweir 1145*cdf0e10cSrcweir DirEntry aFile( rPath ); 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt 1148*cdf0e10cSrcweir // -> abschneiden und merken 1149*cdf0e10cSrcweir if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() ) 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir aMask = aFile.CutName(); 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten 1154*cdf0e10cSrcweir if( pDirList ) 1155*cdf0e10cSrcweir { 1156*cdf0e10cSrcweir UniString aWildCard( aMask.GetWildCard() ); 1157*cdf0e10cSrcweir pEdit->SetText( aWildCard ); 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir else 1160*cdf0e10cSrcweir pEdit->SetText( rPath ); 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir aFile.SetCWD( sal_True ); 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir UpdateEntries( sal_True ); 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir GetFileDialog()->LeaveWait(); 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir void ImpFileDialog::SetPath( Edit const& rEdit ) 1171*cdf0e10cSrcweir { 1172*cdf0e10cSrcweir UniString aPresetText = rEdit.GetText(); 1173*cdf0e10cSrcweir if( aPresetText.Len() ) 1174*cdf0e10cSrcweir SetPath( aPresetText ); 1175*cdf0e10cSrcweir } 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir void ImpFileDialog::AddFilter( const UniString& rFilter, const UniString& rMask ) 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir aFilterList.Insert( new ImpFilterItem( rFilter, rMask ), LIST_APPEND ); 1181*cdf0e10cSrcweir if( pTypeList ) 1182*cdf0e10cSrcweir pTypeList->InsertEntry( rFilter, LISTBOX_APPEND ); 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir if( !GetCurFilter().Len() ) 1185*cdf0e10cSrcweir SetCurFilter( rFilter ); 1186*cdf0e10cSrcweir } 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir void ImpFileDialog::RemoveFilter( const UniString& rFilter ) 1189*cdf0e10cSrcweir { 1190*cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.First(); 1191*cdf0e10cSrcweir while( pItem && pItem->aName != rFilter ) 1192*cdf0e10cSrcweir pItem = aFilterList.Next(); 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir if( pItem ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir delete aFilterList.Remove(); 1197*cdf0e10cSrcweir if( pTypeList ) 1198*cdf0e10cSrcweir pTypeList->RemoveEntry( rFilter ); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir } 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir void ImpFileDialog::RemoveAllFilter() 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.First(); 1205*cdf0e10cSrcweir while( pItem ) 1206*cdf0e10cSrcweir { 1207*cdf0e10cSrcweir delete pItem; 1208*cdf0e10cSrcweir pItem = aFilterList.Next(); 1209*cdf0e10cSrcweir } 1210*cdf0e10cSrcweir aFilterList.Clear(); 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir if( pTypeList ) 1213*cdf0e10cSrcweir pTypeList->Clear(); 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir void ImpFileDialog::SetCurFilter( const UniString& rFilter ) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir if( !pTypeList ) 1219*cdf0e10cSrcweir return; 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir ImpFilterItem* pItem = aFilterList.First(); 1222*cdf0e10cSrcweir while( pItem && pItem->aName != rFilter ) 1223*cdf0e10cSrcweir pItem = aFilterList.Next(); 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir if( pItem ) 1226*cdf0e10cSrcweir pTypeList->SelectEntryPos( (sal_uInt16)aFilterList.GetCurPos() ); 1227*cdf0e10cSrcweir else 1228*cdf0e10cSrcweir pTypeList->SetNoSelection(); 1229*cdf0e10cSrcweir } 1230*cdf0e10cSrcweir 1231*cdf0e10cSrcweir UniString ImpFileDialog::GetCurFilter() const 1232*cdf0e10cSrcweir { 1233*cdf0e10cSrcweir UniString aFilter; 1234*cdf0e10cSrcweir if ( pTypeList ) 1235*cdf0e10cSrcweir aFilter = pTypeList->GetSelectEntry(); 1236*cdf0e10cSrcweir return aFilter; 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir void ImpFileDialog::PreExecute() 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir // ListBoxen erst unmittelbar vor Execute fuellen 1242*cdf0e10cSrcweir // (damit vor Execute der Pfad umgesetzt werden kann, ohne das immer die 1243*cdf0e10cSrcweir // Listboxen sofort upgedatet werden) 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir GetFileDialog()->EnterWait(); 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir // Wenn kein Filter vorhanden, dann auch keine FilterBox 1248*cdf0e10cSrcweir if( pTypeList && !pTypeList->GetEntryCount() ) 1249*cdf0e10cSrcweir { 1250*cdf0e10cSrcweir // pTypeList->InsertEntry( "* (all files)" ); 1251*cdf0e10cSrcweir pTypeTitel->Disable(); 1252*cdf0e10cSrcweir pTypeList->Disable(); 1253*cdf0e10cSrcweir } 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir if( pTypeList ) 1256*cdf0e10cSrcweir { 1257*cdf0e10cSrcweir sal_uInt16 nCurType = pTypeList->GetSelectEntryPos(); 1258*cdf0e10cSrcweir if( nCurType < aFilterList.Count() ) 1259*cdf0e10cSrcweir { 1260*cdf0e10cSrcweir UniString aFilterListMask = aFilterList.GetObject( nCurType )->aMask; 1261*cdf0e10cSrcweir if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske 1262*cdf0e10cSrcweir aMask = WildCard( aFilterListMask, '\0' ); 1263*cdf0e10cSrcweir else // ; in der Maske, muss in der Wildcard beruecksichtigt werden 1264*cdf0e10cSrcweir aMask = WildCard( aFilterListMask, ';' ); 1265*cdf0e10cSrcweir } 1266*cdf0e10cSrcweir else 1267*cdf0e10cSrcweir aMask = UniString::CreateFromAscii( ALLFILES ); 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir else 1270*cdf0e10cSrcweir aMask = UniString::CreateFromAscii( ALLFILES ); 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir // Neue Maske setzen 1273*cdf0e10cSrcweir if( pEdit->GetText().Len() == 0 ) 1274*cdf0e10cSrcweir pEdit->SetText( aMask() ); 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir ImpPathDialog::PreExecute(); 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir GetFileDialog()->LeaveWait(); 1279*cdf0e10cSrcweir } 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir UniString ImpFileDialog::GetPath() const 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir DirEntry aFile( pEdit->GetText() ); 1284*cdf0e10cSrcweir return ExtendFileName( aFile ); 1285*cdf0e10cSrcweir } 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir UniString ImpFileDialog::ExtendFileName( DirEntry aEntry ) const 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir aEntry.ToAbs(); 1290*cdf0e10cSrcweir // das ganze Theater hier ohnehin nur machen, wenn Dateiname 1291*cdf0e10cSrcweir // ohne Extension angegeben wurde 1292*cdf0e10cSrcweir if( !aEntry.GetExtension().Len() ) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir UniString aPostfix; // hier kommt die ausgesuchte Extension herein 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir // ist ein Filter mit Extension gesetzt? 1297*cdf0e10cSrcweir sal_uInt16 nChosenFilterPos = pTypeList->GetSelectEntryPos(); 1298*cdf0e10cSrcweir if( nChosenFilterPos != LISTBOX_ENTRY_NOTFOUND ) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir UniString aExtensionMask = GetFileDialog()->GetFilterType( nChosenFilterPos ); 1301*cdf0e10cSrcweir // aExtension ist z.B. *.sdw, alles bis einschliesslich Punkt abschneiden 1302*cdf0e10cSrcweir UniString aExtension = aExtensionMask.Copy( aExtensionMask.Search( '.' )+1 ); 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir // hat der Filter ueberhaupt eine Extension 1305*cdf0e10cSrcweir if( aExtension.Len() ) 1306*cdf0e10cSrcweir { 1307*cdf0e10cSrcweir // keine Wildcards enthalten? 1308*cdf0e10cSrcweir if( ( aExtension.Search( '*' ) == STRING_NOTFOUND ) && 1309*cdf0e10cSrcweir ( aExtension.Search( '?' ) == STRING_NOTFOUND ) ) 1310*cdf0e10cSrcweir { 1311*cdf0e10cSrcweir // OK, Filter hat Extension ohne Wildcards -> verwenden 1312*cdf0e10cSrcweir aPostfix = aExtension; 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir else 1315*cdf0e10cSrcweir { 1316*cdf0e10cSrcweir // Filter hat Extension mit Wildcards (z.B. *.*) -> nicht verwenden 1317*cdf0e10cSrcweir aPostfix.Erase(); 1318*cdf0e10cSrcweir } 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir else 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir // Filter hatte keine Extension (schwer vorstellbar) -> nichts anhaengen 1323*cdf0e10cSrcweir aPostfix.Erase(); 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir } 1326*cdf0e10cSrcweir else 1327*cdf0e10cSrcweir { 1328*cdf0e10cSrcweir // kein Filter gefunden (merkw�rdig) -> Default-Extension anhaengen 1329*cdf0e10cSrcweir aPostfix = GetFileDialog()->GetDefaultExt(); 1330*cdf0e10cSrcweir } 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir // jetzt kann es mit dem Anhaengen losgehen 1333*cdf0e10cSrcweir const sal_Unicode* pExt = aPostfix.GetBuffer(); 1334*cdf0e10cSrcweir while( *pExt == '*' || *pExt == '?' ) 1335*cdf0e10cSrcweir pExt++; 1336*cdf0e10cSrcweir 1337*cdf0e10cSrcweir if( *pExt ) 1338*cdf0e10cSrcweir { 1339*cdf0e10cSrcweir UniString aName = aEntry.GetName(); 1340*cdf0e10cSrcweir if( *pExt != '.' ) 1341*cdf0e10cSrcweir aName += '.'; 1342*cdf0e10cSrcweir aName += pExt; 1343*cdf0e10cSrcweir aEntry.SetName( aName ); 1344*cdf0e10cSrcweir } 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir return aEntry.GetFull(); 1347*cdf0e10cSrcweir } 1348*cdf0e10cSrcweir 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir void ImpSvFileDlg::CreateDialog( PathDialog* pSvDlg, WinBits nStyle, RESOURCE_TYPE nType, sal_Bool bCreate ) 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir delete pDlg; 1353*cdf0e10cSrcweir if ( nType == WINDOW_PATHDIALOG ) 1354*cdf0e10cSrcweir pDlg = new ImpPathDialog( pSvDlg, nType, bCreate ); 1355*cdf0e10cSrcweir else 1356*cdf0e10cSrcweir pDlg = new ImpFileDialog( pSvDlg, nStyle, nType ); 1357*cdf0e10cSrcweir } 1358*cdf0e10cSrcweir 1359*cdf0e10cSrcweir 1360