LCOV - code coverage report
Current view: top level - svtools/source/dialogs - filedlg2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 358 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 974 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/svapp.hxx>
      30                 :            : #include <vcl/button.hxx>
      31                 :            : #include <vcl/fixed.hxx>
      32                 :            : #include <vcl/edit.hxx>
      33                 :            : #include <vcl/lstbox.hxx>
      34                 :            : #include <svtools/svtresid.hxx>
      35                 :            : #include <filedlg2.hxx>
      36                 :            : #include <svtools/filedlg.hxx>
      37                 :            : #include <svtools/filedlg2.hrc>
      38                 :            : #include <vcl/msgbox.hxx>
      39                 :            : #include <osl/security.hxx>
      40                 :            : #include <comphelper/string.hxx>
      41                 :            : 
      42                 :            : #include <svtools/stdctrl.hxx>
      43                 :            : 
      44                 :            : #ifdef _MSC_VER
      45                 :            : #pragma optimize ("", off)
      46                 :            : #endif
      47                 :            : 
      48                 :            : #include <svtools/helpid.hrc>
      49                 :            : 
      50                 :            : using namespace com::sun::star;
      51                 :            : using namespace com::sun::star::uno;
      52                 :            : 
      53                 :            : typedef ::std::vector< UniString* > UniStringList;
      54                 :            : 
      55                 :            : #define INITCONTROL( p, ControlClass, nBits, aPos, aSize, aTitel, rHelpId ) \
      56                 :            :     p = new ControlClass( GetPathDialog(), WinBits( nBits ) ); \
      57                 :            :     p->SetHelpId( rHelpId ); \
      58                 :            :     p->SetPosSizePixel( aPos, aSize ); \
      59                 :            :     p->SetText( aTitel ); \
      60                 :            :     p->Show();
      61                 :            : 
      62                 :            : 
      63                 :          0 : inline sal_Bool IsPrintable( sal_Unicode c )
      64                 :            : {
      65 [ #  # ][ #  # ]:          0 :     return c >= 32 && c != 127 ? sal_True : sal_False;
      66                 :            : }
      67                 :            : 
      68                 :            : long
      69                 :          0 : KbdListBox::PreNotify( NotifyEvent& rNEvt )
      70                 :            : {
      71         [ #  # ]:          0 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
      72                 :            :     {
      73 [ #  # ][ #  # ]:          0 :         KeyEvent aKeyEvt    = *rNEvt.GetKeyEvent();
      74                 :          0 :         sal_Unicode  cCharCode  = aKeyEvt.GetCharCode();
      75                 :            : 
      76         [ #  # ]:          0 :         if ( IsPrintable ( cCharCode ) )
      77                 :            :         {
      78         [ #  # ]:          0 :             sal_uInt16 nCurrentPos = GetSelectEntryPos();
      79         [ #  # ]:          0 :             sal_uInt16 nEntries    = GetEntryCount();
      80                 :            : 
      81         [ #  # ]:          0 :             for ( sal_uInt16 i = 1; i < nEntries; i++ )
      82                 :            :             {
      83         [ #  # ]:          0 :                 UniString aEntry = GetEntry ( (i + nCurrentPos) % nEntries );
      84 [ #  # ][ #  # ]:          0 :                 aEntry = comphelper::string::stripStart(aEntry, ' ');
                 [ #  # ]
      85         [ #  # ]:          0 :                 aEntry.ToUpperAscii();
      86         [ #  # ]:          0 :                 UniString aCompare = rtl::OUString(cCharCode);
      87         [ #  # ]:          0 :                 aCompare.ToUpperAscii();
      88                 :            : 
      89 [ #  # ][ #  # ]:          0 :                 if ( aEntry.CompareTo( aCompare, 1 ) == COMPARE_EQUAL )
      90                 :            :                 {
      91         [ #  # ]:          0 :                     SelectEntryPos ( (i + nCurrentPos) % nEntries );
      92                 :            :                     break;
      93                 :            :                 }
      94 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
      95                 :            :         }
      96                 :            :         else
      97         [ #  # ]:          0 :         if ( aKeyEvt.GetKeyCode().GetCode() == KEY_RETURN )
      98                 :            :         {
      99         [ #  # ]:          0 :             DoubleClick();
     100                 :            :         }
     101                 :            :     }
     102                 :            : 
     103                 :          0 :     return ListBox::PreNotify ( rNEvt );
     104                 :            : }
     105                 :            : 
     106                 :          0 : ImpPathDialog::ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir )
     107                 :            : {
     108                 :          0 :     pSvPathDialog = pDlg;
     109                 :          0 :     nDirCount = 0;
     110                 :            : 
     111                 :            :     // initialize Controls if not used as a base class
     112         [ #  # ]:          0 :     if ( nType == WINDOW_PATHDIALOG )
     113                 :            :     {
     114         [ #  # ]:          0 :         InitControls();
     115         [ #  # ]:          0 :         if( pNewDirBtn )
     116         [ #  # ]:          0 :             pNewDirBtn->Enable( bCreateDir );
     117                 :            :     }
     118                 :            : 
     119         [ #  # ]:          0 :     pDlg->SetHelpId( HID_FILEDLG_PATHDLG );
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : ImpPathDialog::~ImpPathDialog()
     123                 :            : {
     124 [ #  # ][ #  # ]:          0 :     delete pEdit;
     125 [ #  # ][ #  # ]:          0 :     delete pDirTitel;
     126 [ #  # ][ #  # ]:          0 :     delete pDirList;
     127 [ #  # ][ #  # ]:          0 :     delete pDirPath;
     128 [ #  # ][ #  # ]:          0 :     delete pDriveList;
     129 [ #  # ][ #  # ]:          0 :     delete pDriveTitle;
     130 [ #  # ][ #  # ]:          0 :     delete pLoadBtn;
     131 [ #  # ][ #  # ]:          0 :     delete pOkBtn;
     132 [ #  # ][ #  # ]:          0 :     delete pCancelBtn;
     133 [ #  # ][ #  # ]:          0 :     delete pNewDirBtn;
     134                 :            : #   if defined(UNX)
     135 [ #  # ][ #  # ]:          0 :     delete pHomeBtn;
     136                 :            : #   endif
     137         [ #  # ]:          0 : }
     138                 :            : 
     139                 :          0 : void ImpPathDialog::InitControls()
     140                 :            : {
     141                 :          0 :     PathDialog* pDlg = GetPathDialog();
     142 [ #  # ][ #  # ]:          0 :     pDlg->SetText( SVT_RESSTR(STR_FILEDLG_SELECT) );
         [ #  # ][ #  # ]
                 [ #  # ]
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     Size a3Siz = pDlg->LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
                 [ #  # ]
     145 [ #  # ][ #  # ]:          0 :     Size a6Siz = pDlg->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :     Size aBtnSiz = pDlg->LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
                 [ #  # ]
     147 [ #  # ][ #  # ]:          0 :     Size aFTSiz = pDlg->LogicToPixel( Size( 142, 10 ), MAP_APPFONT );
                 [ #  # ]
     148 [ #  # ][ #  # ]:          0 :     Size aEDSiz = pDlg->LogicToPixel( Size( 142, 12 ), MAP_APPFONT );
                 [ #  # ]
     149                 :          0 :     Point aPnt( a6Siz.Width(), a6Siz.Height() );
     150 [ #  # ][ #  # ]:          0 :     long nLbH1 = pDlg->LogicToPixel( Size( 0, 93 ), MAP_APPFONT ).Height();
                 [ #  # ]
     151                 :          0 :     long nH = 0;
     152         [ #  # ]:          0 :     UniString aEmptyStr;
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :     INITCONTROL( pDirTitel, FixedText, 0,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     155                 :            :                  aPnt, aFTSiz, SVT_RESSTR( STR_FILEDLG_DIR ), HID_FILEDLG_DIR );
     156                 :          0 :     aPnt.Y() += aFTSiz.Height() + a3Siz.Height();
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :     INITCONTROL( pEdit, Edit, WB_BORDER, aPnt, aEDSiz, aPath.GetFull(), HID_FILEDLG_EDIT );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     159                 :            : 
     160                 :          0 :     aPnt.Y() += aEDSiz.Height() + a3Siz.Height();
     161                 :            : #ifndef UNX
     162                 :            :     long nLbH2 = pDlg->LogicToPixel( Size( 0, 60 ), MAP_APPFONT ).Height();
     163                 :            :     INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER,
     164                 :            :         aPnt, Size( aEDSiz.Width(), nLbH1 ), aEmptyStr, HID_FILEDLG_DIRS );
     165                 :            :     aPnt.Y() += nLbH1 + a6Siz.Height();
     166                 :            :     INITCONTROL( pDriveTitle, FixedText, 0,
     167                 :            :                  aPnt, aFTSiz, SVT_RESSTR( STR_FILEDLG_DRIVES ), HID_FILEDLG_DRIVE );
     168                 :            :     aPnt.Y() += aFTSiz.Height() + a3Siz.Height();
     169                 :            :     INITCONTROL( pDriveList, ListBox, WB_DROPDOWN,
     170                 :            :                  aPnt, Size( aEDSiz.Width(), nLbH2 ), aEmptyStr, HID_FILEDLG_DRIVES );
     171                 :            :     nH = aPnt.Y() + aEDSiz.Height() + a6Siz.Height();
     172                 :            : #else
     173                 :          0 :     long nNewH = nLbH1 + 3 * a3Siz.Height() +
     174                 :          0 :                  aFTSiz.Height() + aEDSiz.Height();
     175 [ #  # ][ #  # ]:          0 :     INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     176                 :            :                  aPnt, Size( aEDSiz.Width(), nNewH ), aEmptyStr, HID_FILEDLG_DIRS );
     177                 :          0 :     nH = aPnt.Y() + nNewH + a6Siz.Height();
     178                 :          0 :     pDriveTitle = NULL;
     179                 :          0 :     pDriveList = NULL;
     180                 :            : #endif
     181                 :            : 
     182 [ #  # ][ #  # ]:          0 :     long nExtraWidth = pDlg->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM( "(W)" ) ) )+10;
                 [ #  # ]
     183         [ #  # ]:          0 :     String aOkStr = Button::GetStandardText( BUTTON_OK );
     184         [ #  # ]:          0 :     long nTextWidth = pDlg->GetTextWidth( aOkStr )+nExtraWidth;
     185         [ #  # ]:          0 :     if( nTextWidth > aBtnSiz.Width() )
     186                 :          0 :         aBtnSiz.Width() = nTextWidth;
     187                 :            : 
     188         [ #  # ]:          0 :     String aCancelStr = Button::GetStandardText( BUTTON_CANCEL );
     189         [ #  # ]:          0 :     nTextWidth = pDlg->GetTextWidth( aCancelStr )+nExtraWidth;
     190         [ #  # ]:          0 :     if( nTextWidth > aBtnSiz.Width() )
     191                 :          0 :         aBtnSiz.Width() = nTextWidth;
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :     String aNewDirStr( SVT_RESSTR( STR_FILEDLG_NEWDIR ) );
                 [ #  # ]
     194         [ #  # ]:          0 :     nTextWidth = pDlg->GetTextWidth( aNewDirStr )+nExtraWidth;
     195         [ #  # ]:          0 :     if( nTextWidth > aBtnSiz.Width() )
     196                 :          0 :         aBtnSiz.Width() = nTextWidth;
     197                 :            : #if defined(UNX)
     198 [ #  # ][ #  # ]:          0 :     String aHomeDirStr( SVT_RESSTR( STR_FILEDLG_HOME ) );
                 [ #  # ]
     199         [ #  # ]:          0 :     nTextWidth = pDlg->GetTextWidth( aHomeDirStr )+nExtraWidth;
     200         [ #  # ]:          0 :     if( nTextWidth > aBtnSiz.Width() )
     201                 :          0 :         aBtnSiz.Width() = nTextWidth;
     202                 :            : #endif
     203                 :            : 
     204                 :          0 :     aPnt.X() = 2 * a6Siz.Width() + aEDSiz.Width();
     205                 :          0 :     aPnt.Y() = a6Siz.Height();
     206 [ #  # ][ #  # ]:          0 :     INITCONTROL( pOkBtn, PushButton, WB_DEFBUTTON,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     207                 :            :                  aPnt, aBtnSiz, aOkStr, "" );
     208                 :          0 :     aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
     209 [ #  # ][ #  # ]:          0 :     INITCONTROL( pCancelBtn, CancelButton, 0,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     210                 :            :                  aPnt, aBtnSiz, aCancelStr, "" );
     211                 :          0 :     aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
     212 [ #  # ][ #  # ]:          0 :     INITCONTROL( pNewDirBtn, PushButton, WB_DEFBUTTON,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     213                 :            :                  aPnt, aBtnSiz, aNewDirStr, HID_FILEDLG_NEWDIR );
     214                 :            : #if defined(UNX)
     215                 :          0 :     aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
     216 [ #  # ][ #  # ]:          0 :     INITCONTROL( pHomeBtn, PushButton, WB_DEFBUTTON,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     217                 :            :                  aPnt, aBtnSiz, aHomeDirStr, HID_FILEDLG_HOME );
     218                 :            : #else
     219                 :            :     pHomeBtn = NULL;
     220                 :            : #endif
     221                 :            : 
     222                 :          0 :     pDirPath = 0;
     223                 :          0 :     pLoadBtn = 0;
     224                 :            :     // Dialogbreite == OKBtn-Position + OKBtn-Breite + Rand
     225                 :          0 :     long nW = aPnt.X() + aBtnSiz.Width() + a6Siz.Width();
     226                 :            : 
     227         [ #  # ]:          0 :     pDlg->SetOutputSizePixel( Size( nW, nH ) );  // Groesse ggf. auch Resource wird geplaettet?
     228                 :            : 
     229         [ #  # ]:          0 :     if (pDirList)
     230         [ #  # ]:          0 :         pDirList->SetDoubleClickHdl(LINK( this, ImpPathDialog, DblClickHdl) );
     231                 :            : 
     232         [ #  # ]:          0 :     if (pDirList)
     233         [ #  # ]:          0 :         pDirList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) );
     234                 :            : 
     235         [ #  # ]:          0 :     if (pDriveList)
     236         [ #  # ]:          0 :         pDriveList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) );
     237                 :            : 
     238         [ #  # ]:          0 :     if (pOkBtn)
     239         [ #  # ]:          0 :         pOkBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
     240                 :            : 
     241         [ #  # ]:          0 :     if (pCancelBtn)
     242         [ #  # ]:          0 :         pCancelBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
     243                 :            : 
     244         [ #  # ]:          0 :     if (pHomeBtn)
     245         [ #  # ]:          0 :         pHomeBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
     246                 :            : 
     247         [ #  # ]:          0 :     if (pNewDirBtn)
     248         [ #  # ]:          0 :         pNewDirBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
     249                 :            : 
     250 [ #  # ][ #  # ]:          0 :     nOwnChildren = pDlg->GetChildCount();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     251                 :          0 : }
     252                 :            : 
     253                 :            : 
     254                 :            : 
     255                 :          0 : IMPL_LINK( ImpPathDialog, SelectHdl, ListBox *, p )
     256                 :            : {
     257         [ #  # ]:          0 :     if( p == pDriveList )
     258                 :            :     {
     259 [ #  # ][ #  # ]:          0 :         UniString aDrive( pDriveList->GetSelectEntry(), 0, 2);
                 [ #  # ]
     260         [ #  # ]:          0 :         aDrive += '\\';
     261 [ #  # ][ #  # ]:          0 :         SetPath( aDrive );
     262                 :            :     }
     263                 :            :     else
     264         [ #  # ]:          0 :     if( p == pDirList )
     265                 :            :     {
     266                 :            :         // isolate the pure name of the entry
     267                 :            :         // removing trainling stuff and leading spaces
     268         [ #  # ]:          0 :         UniString aEntry( pDirList->GetSelectEntry() );
     269 [ #  # ][ #  # ]:          0 :         aEntry = comphelper::string::stripStart(aEntry, ' ');
                 [ #  # ]
     270                 :            : 
     271         [ #  # ]:          0 :         sal_uInt16 nPos = aEntry.Search( '/' );
     272         [ #  # ]:          0 :         aEntry.Erase( nPos );
     273                 :            : 
     274                 :            :         // build the absolute path to the selected item
     275         [ #  # ]:          0 :         DirEntry aNewPath;
     276         [ #  # ]:          0 :         aNewPath.ToAbs();
     277                 :            : 
     278         [ #  # ]:          0 :         sal_uInt16 nCurPos = pDirList->GetSelectEntryPos();
     279                 :            : 
     280                 :            :         // Wird nach oben gewechselt
     281         [ #  # ]:          0 :         if( nCurPos < nDirCount )
     282 [ #  # ][ #  # ]:          0 :             aNewPath = aNewPath[nDirCount-nCurPos-1];
     283                 :            :         else
     284 [ #  # ][ #  # ]:          0 :             aNewPath += aEntry;
                 [ #  # ]
     285                 :            : 
     286 [ #  # ][ #  # ]:          0 :         pEdit->SetText( aNewPath.GetFull() );
         [ #  # ][ #  # ]
                 [ #  # ]
     287                 :            :     }
     288                 :            : 
     289                 :          0 :     return 0;
     290                 :            : }
     291                 :            : 
     292                 :            : 
     293                 :          0 : IMPL_LINK( ImpPathDialog, ClickHdl, Button*, pBtn )
     294                 :            : {
     295 [ #  # ][ #  # ]:          0 :     if ( pBtn == pOkBtn || pBtn == pLoadBtn )
     296                 :            :     {
     297 [ #  # ][ #  # ]:          0 :         DirEntry aFile( pEdit->GetText() );
                 [ #  # ]
     298                 :            : 
     299                 :            :         // Existiert File / File ueberschreiben
     300 [ #  # ][ #  # ]:          0 :         if( IsFileOk( aFile ) )
     301                 :            :         {
     302                 :            :             // Ja, dann kompletten Pfad mit Filenamen merken und Dialog beenden
     303         [ #  # ]:          0 :             aPath = aFile;
     304         [ #  # ]:          0 :             aPath.ToAbs();
     305         [ #  # ]:          0 :             GetPathDialog()->EndDialog( sal_True );
     306                 :            :         }
     307                 :            :         else
     308                 :            :         {
     309         [ #  # ]:          0 :             DirEntry aCheck( aPath );
     310         [ #  # ]:          0 :             aCheck += aFile;
     311 [ #  # ][ #  # ]:          0 :             if( aCheck.Exists() )
     312                 :            :             {
     313         [ #  # ]:          0 :                 aCheck.ToAbs();
     314 [ #  # ][ #  # ]:          0 :                 SetPath( aCheck.GetFull() );
                 [ #  # ]
     315         [ #  # ]:          0 :                 pEdit->SetSelection( Selection( 0x7FFFFFFF, 0x7FFFFFFF ) );
     316         [ #  # ]:          0 :             }
     317         [ #  # ]:          0 :         }
     318                 :            :     }
     319                 :            :     else
     320         [ #  # ]:          0 :     if ( pBtn == pCancelBtn )
     321                 :            :     {
     322                 :          0 :         GetPathDialog()->EndDialog( sal_False );
     323                 :            :     }
     324                 :            :     else
     325         [ #  # ]:          0 :     if ( pBtn == pHomeBtn )
     326                 :            :     {
     327                 :          0 :         ::rtl::OUString aHomeDir;
     328         [ #  # ]:          0 :         osl::Security aSecurity;
     329 [ #  # ][ #  # ]:          0 :         if ( aSecurity.getHomeDir( aHomeDir ) )
     330                 :            :         {
     331 [ #  # ][ #  # ]:          0 :             DirEntry aFile ( aHomeDir );
                 [ #  # ]
     332 [ #  # ][ #  # ]:          0 :             if ( IsFileOk( aFile ) )
     333                 :            :             {
     334         [ #  # ]:          0 :                 aFile.ToAbs();
     335 [ #  # ][ #  # ]:          0 :                 SetPath( aFile.GetFull() );
                 [ #  # ]
     336         [ #  # ]:          0 :             }
     337         [ #  # ]:          0 :         }
     338                 :            :     }
     339                 :            :     else
     340         [ #  # ]:          0 :     if ( pBtn == pNewDirBtn )
     341                 :            :     {
     342 [ #  # ][ #  # ]:          0 :         DirEntry aFile( pEdit->GetText() );
                 [ #  # ]
     343 [ #  # ][ #  # ]:          0 :         if( ! aFile.Exists() && ! FileStat( aFile ).IsKind( FSYS_KIND_WILD ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     344         [ #  # ]:          0 :             aFile.MakeDir();
     345                 :            : 
     346 [ #  # ][ #  # ]:          0 :         if( IsFileOk ( aFile ) )
     347                 :            :         {
     348         [ #  # ]:          0 :             aFile.ToAbs();
     349 [ #  # ][ #  # ]:          0 :             SetPath( aFile.GetFull() );
                 [ #  # ]
     350         [ #  # ]:          0 :         }
     351                 :            :     }
     352                 :            : 
     353                 :          0 :     return 0;
     354                 :            : }
     355                 :            : 
     356                 :            : 
     357                 :          0 : IMPL_LINK( ImpPathDialog, DblClickHdl, ListBox*, pBox )
     358                 :            : {
     359                 :            :     // isolate the pure name of the entry
     360                 :            :     // removing trainling stuff and leading spaces
     361         [ #  # ]:          0 :     UniString aEntry( pBox->GetSelectEntry() );
     362                 :            : 
     363 [ #  # ][ #  # ]:          0 :     aEntry = comphelper::string::stripStart(aEntry, ' ');
                 [ #  # ]
     364         [ #  # ]:          0 :     sal_uInt16 nPos = aEntry.Search( '/' );
     365         [ #  # ]:          0 :     aEntry.Erase( nPos );
     366                 :            : 
     367                 :            :     // build the absolute path to the selected item
     368         [ #  # ]:          0 :     DirEntry aNewPath;
     369         [ #  # ]:          0 :     aNewPath.ToAbs();
     370         [ #  # ]:          0 :     if( pBox == pDirList )
     371                 :            :     {
     372         [ #  # ]:          0 :         sal_uInt16 nCurPos = pDirList->GetSelectEntryPos();
     373                 :            : 
     374                 :            :         // Wenn es schon das aktuelle ist, dann mache nichts
     375         [ #  # ]:          0 :         if( nCurPos == nDirCount-1 )
     376                 :          0 :             return 0;
     377                 :            : 
     378                 :            :         // Wird nach oben gewechselt
     379         [ #  # ]:          0 :         if( nCurPos < nDirCount )
     380 [ #  # ][ #  # ]:          0 :             aNewPath = aNewPath[nDirCount-nCurPos-1];
     381                 :            :         else
     382 [ #  # ][ #  # ]:          0 :             aNewPath += aEntry;
                 [ #  # ]
     383                 :            :     }
     384                 :            :     else
     385 [ #  # ][ #  # ]:          0 :         aNewPath += aEntry;
                 [ #  # ]
     386                 :            : 
     387         [ #  # ]:          0 :     pSvPathDialog->EnterWait();
     388                 :            : 
     389 [ #  # ][ #  # ]:          0 :     if( FileStat( aNewPath ).GetKind() & FSYS_KIND_DIR )
                 [ #  # ]
     390                 :            :     {
     391                 :            :         // Neuen Pfad setzen und Listboxen updaten
     392         [ #  # ]:          0 :         aPath = aNewPath;
     393 [ #  # ][ #  # ]:          0 :         if( !aPath.SetCWD( sal_True ) )
     394                 :            :         {
     395                 :          0 :             ErrorBox aBox( GetPathDialog(),
     396                 :            :                            WB_OK_CANCEL | WB_DEF_OK,
     397 [ #  # ][ #  # ]:          0 :                            SVT_RESSTR( STR_FILEDLG_CANTCHDIR ) );
           [ #  #  #  # ]
                 [ #  # ]
     398 [ #  # ][ #  # ]:          0 :             if( aBox.Execute() == RET_CANCEL )
     399 [ #  # ][ #  # ]:          0 :                 GetPathDialog()->EndDialog( sal_False );
     400                 :            :         }
     401         [ #  # ]:          0 :         UpdateEntries( sal_True );
     402                 :            :     }
     403                 :            : 
     404         [ #  # ]:          0 :     pSvPathDialog->LeaveWait();
     405 [ #  # ][ #  # ]:          0 :     return 0;
     406                 :            : }
     407                 :            : 
     408                 :          0 : void ImpPathDialog::UpdateEntries( const sal_Bool )
     409                 :            : {
     410         [ #  # ]:          0 :     UniString aTabString;
     411         [ #  # ]:          0 :     DirEntry aTmpPath;
     412         [ #  # ]:          0 :     aTmpPath.ToAbs();
     413                 :            : 
     414         [ #  # ]:          0 :     nDirCount = aTmpPath.Level();
     415                 :            : 
     416         [ #  # ]:          0 :     pDirList->SetUpdateMode( sal_False );
     417         [ #  # ]:          0 :     pDirList->Clear();
     418                 :            : 
     419         [ #  # ]:          0 :     for( sal_uInt16 i = nDirCount; i > 0; i-- )
     420                 :            :     {
     421         [ #  # ]:          0 :         UniString aName( aTabString );
     422 [ #  # ][ #  # ]:          0 :         aName += aTmpPath[i-1].GetName();
         [ #  # ][ #  # ]
     423         [ #  # ]:          0 :         pDirList->InsertEntry( aName );
     424         [ #  # ]:          0 :         aTabString.AppendAscii( "  ", 2 );
     425         [ #  # ]:          0 :     }
     426                 :            : 
     427                 :            :     // scan the directory
     428         [ #  # ]:          0 :     DirEntry aCurrent;
     429         [ #  # ]:          0 :     aCurrent.ToAbs();
     430                 :            : 
     431         [ #  # ]:          0 :     Dir aDir( aCurrent, FSYS_KIND_DIR|FSYS_KIND_FILE );
     432                 :            : 
     433         [ #  # ]:          0 :     sal_uInt16 nEntries = aDir.Count();
     434         [ #  # ]:          0 :     if( nEntries )
     435                 :            :     {
     436         [ #  # ]:          0 :         UniStringList aSortDirList;
     437                 :            :         const comphelper::string::NaturalStringSorter& rSorter =
     438         [ #  # ]:          0 :             ::vcl::unohelper::getNaturalStringSorterForAppLocale();
     439         [ #  # ]:          0 :         for ( sal_uInt16 n = 0; n < nEntries; n++ )
     440                 :            :         {
     441         [ #  # ]:          0 :             DirEntry& rEntry = aDir[n];
     442         [ #  # ]:          0 :             UniString aName( rEntry.GetName() );
     443 [ #  # ][ #  # ]:          0 :             if( aName.Len() && ( aName.GetChar(0) != '.' ) && rEntry.Exists() )
         [ #  # ][ #  # ]
                 [ #  # ]
     444                 :            :             {
     445 [ #  # ][ #  # ]:          0 :                 if( FileStat( rEntry ).GetKind() & FSYS_KIND_DIR )
                 [ #  # ]
     446                 :            :                 {
     447                 :          0 :                     size_t l = 0;
     448         [ #  # ]:          0 :                     for( l = 0; l < aSortDirList.size(); l++ )
     449 [ #  # ][ #  # ]:          0 :                         if( rSorter.compare( *aSortDirList[ l ], aName ) > 0 )
         [ #  # ][ #  # ]
                 [ #  # ]
     450                 :          0 :                             break;
     451         [ #  # ]:          0 :                     if ( l < aSortDirList.size() ) {
     452                 :          0 :                         UniStringList::iterator it = aSortDirList.begin();
     453         [ #  # ]:          0 :                         ::std::advance( it, l );
     454 [ #  # ][ #  # ]:          0 :                         aSortDirList.insert( it, new UniString( aName ) );
                 [ #  # ]
     455                 :            :                     } else {
     456 [ #  # ][ #  # ]:          0 :                         aSortDirList.push_back( new UniString( aName ) );
                 [ #  # ]
     457                 :            :                     }
     458                 :            :                 }
     459                 :            :             }
     460         [ #  # ]:          0 :         }
     461                 :            : 
     462         [ #  # ]:          0 :         for( size_t l = 0; l < aSortDirList.size(); l++ )
     463                 :            :         {
     464         [ #  # ]:          0 :             UniString aEntryStr( aTabString );
     465 [ #  # ][ #  # ]:          0 :             aEntryStr += *aSortDirList[ l ];
     466         [ #  # ]:          0 :             pDirList->InsertEntry( aEntryStr );
     467 [ #  # ][ #  # ]:          0 :             delete aSortDirList[ l ];
                 [ #  # ]
     468         [ #  # ]:          0 :         }
     469                 :            :     }
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :     UpdateDirs( aTmpPath );
         [ #  # ][ #  # ]
                 [ #  # ]
     472                 :          0 : }
     473                 :            : 
     474                 :          0 : void ImpPathDialog::UpdateDirs( const DirEntry& rTmpPath )
     475                 :            : {
     476         [ #  # ]:          0 :     pDirList->SelectEntryPos( nDirCount-1 );
     477                 :            :     pDirList->SetTopEntry( nDirCount > 1
     478                 :            :                            ? nDirCount - 2
     479 [ #  # ][ #  # ]:          0 :                            : nDirCount - 1 );
     480         [ #  # ]:          0 :     pDirList->SetUpdateMode( sal_True );
     481         [ #  # ]:          0 :     pDirList->Invalidate();
     482         [ #  # ]:          0 :     pDirList->Update();
     483                 :            : 
     484         [ #  # ]:          0 :     UniString aDirName = rTmpPath.GetFull();
     485         [ #  # ]:          0 :     if( pDirPath )
     486         [ #  # ]:          0 :         pDirPath->SetText( aDirName );
     487                 :            :     else
     488 [ #  # ][ #  # ]:          0 :         pEdit->SetText( aDirName );
     489                 :          0 : }
     490                 :            : 
     491                 :          0 : sal_Bool ImpPathDialog::IsFileOk( const DirEntry& rDirEntry )
     492                 :            : {
     493         [ #  # ]:          0 :     if( FileStat( rDirEntry ).GetKind() & (FSYS_KIND_WILD | FSYS_KIND_DEV) )
     494                 :          0 :         return sal_False;
     495                 :            :     else
     496                 :            :     {
     497                 :            :         // Datei vorhanden ?
     498         [ #  # ]:          0 :         if( ! rDirEntry.Exists() )
     499                 :            :         {
     500 [ #  # ][ #  # ]:          0 :             UniString aQueryTxt( SVT_RESSTR( STR_FILEDLG_ASKNEWDIR ) );
                 [ #  # ]
     501 [ #  # ][ #  # ]:          0 :             aQueryTxt.SearchAndReplaceAscii( "%s", rDirEntry.GetFull() );
                 [ #  # ]
     502                 :          0 :             QueryBox aQuery( GetPathDialog(),
     503                 :            :                              WB_YES_NO | WB_DEF_YES,
     504         [ #  # ]:          0 :                              aQueryTxt  );
     505 [ #  # ][ #  # ]:          0 :             if( aQuery.Execute() == RET_YES )
     506         [ #  # ]:          0 :                 rDirEntry.MakeDir();
     507                 :            :             else
     508 [ #  # ][ #  # ]:          0 :                 return sal_False;
         [ #  # ][ #  # ]
     509                 :            :         }
     510 [ #  # ][ #  # ]:          0 :         if( !FileStat( rDirEntry ).IsKind( FSYS_KIND_DIR ) )
     511                 :            :         {
     512 [ #  # ][ #  # ]:          0 :             UniString aBoxText( SVT_RESSTR( STR_FILEDLG_CANTOPENDIR ) );
                 [ #  # ]
     513         [ #  # ]:          0 :             aBoxText.AppendAscii( "\n[" );
     514 [ #  # ][ #  # ]:          0 :             aBoxText += rDirEntry.GetFull();
                 [ #  # ]
     515         [ #  # ]:          0 :             aBoxText.AppendAscii( "]" );
     516         [ #  # ]:          0 :             InfoBox aBox( GetPathDialog(), aBoxText );
     517         [ #  # ]:          0 :             aBox.Execute();
     518 [ #  # ][ #  # ]:          0 :             return sal_False;
     519                 :            :         }
     520                 :            :     }
     521                 :          0 :     return GetPathDialog()->OK() != 0;
     522                 :            : }
     523                 :            : 
     524                 :            : 
     525                 :          0 : void ImpPathDialog::PreExecute()
     526                 :            : {
     527                 :            :     // Neues Verzeichnis setzen und Listboxen updaten
     528         [ #  # ]:          0 :     aPath.SetCWD( sal_True );
     529         [ #  # ]:          0 :     UpdateEntries( sal_True );
     530                 :            : 
     531                 :            :     // Zusaetzliche Buttons anordnen
     532                 :          0 :     Point   aPos;
     533                 :          0 :     Size    aSize;
     534                 :            :     long    nDY;
     535         [ #  # ]:          0 :     if( pLoadBtn )
     536                 :            :     {
     537         [ #  # ]:          0 :         aPos  = pLoadBtn->GetPosPixel();
     538         [ #  # ]:          0 :         aSize = pLoadBtn->GetSizePixel();
     539         [ #  # ]:          0 :         nDY   = pLoadBtn->GetSizePixel().Height() * 2;
     540                 :            :     }
     541                 :            :     else
     542                 :            :     {
     543         [ #  # ]:          0 :         aPos  = pCancelBtn->GetPosPixel();
     544         [ #  # ]:          0 :         aSize = pCancelBtn->GetSizePixel();
     545 [ #  # ][ #  # ]:          0 :         nDY   = pCancelBtn->GetPosPixel().Y() - pOkBtn->GetPosPixel().Y();
     546                 :            :     }
     547                 :            : 
     548                 :            :     // Standard-Controls anpassen
     549                 :          0 :     long nMaxWidth = 0;
     550                 :            : 
     551                 :            :     // Maximale Breite ermitteln
     552         [ #  # ]:          0 :     sal_uInt16 nChildren = GetPathDialog()->GetChildCount();
     553                 :            :     sal_uInt16 n;
     554         [ #  # ]:          0 :     for ( n = nOwnChildren; n < nChildren; n++ )
     555                 :            :     {
     556         [ #  # ]:          0 :         Window* pChild = GetPathDialog()->GetChild( n );
     557         [ #  # ]:          0 :         pChild = pChild->GetWindow( WINDOW_CLIENT );
     558 [ #  # ][ #  # ]:          0 :         if( pChild->GetType() != WINDOW_WINDOW )
     559                 :            :         {
     560 [ #  # ][ #  # ]:          0 :             long nWidth = pChild->GetTextWidth( pChild->GetText() ) + 12;
                 [ #  # ]
     561         [ #  # ]:          0 :             if( nMaxWidth < nWidth )
     562                 :          0 :                 nMaxWidth = nWidth;
     563         [ #  # ]:          0 :             nWidth = pChild->GetSizePixel().Width();
     564         [ #  # ]:          0 :             if( nMaxWidth < nWidth )
     565                 :          0 :                 nMaxWidth = nWidth;
     566                 :            :         }
     567                 :            :     }
     568                 :            : 
     569         [ #  # ]:          0 :     if( nMaxWidth > aSize.Width() )
     570                 :            :     {
     571                 :          0 :         Size aDlgSize = GetPathDialog()->GetOutputSizePixel();
     572         [ #  # ]:          0 :         GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nMaxWidth-aSize.Width(), aDlgSize.Height() ) );
     573                 :          0 :         aSize.Width() = nMaxWidth;
     574                 :            : 
     575         [ #  # ]:          0 :         if( pOkBtn )
     576         [ #  # ]:          0 :             pOkBtn->SetSizePixel( aSize );
     577         [ #  # ]:          0 :         if( pCancelBtn )
     578         [ #  # ]:          0 :             pCancelBtn->SetSizePixel( aSize );
     579         [ #  # ]:          0 :         if( pLoadBtn )
     580         [ #  # ]:          0 :             pLoadBtn->SetSizePixel( aSize );
     581                 :            :     }
     582                 :            :     else
     583                 :          0 :         nMaxWidth = aSize.Width();
     584                 :            : 
     585         [ #  # ]:          0 :     for ( n = nOwnChildren; n < nChildren; n++ )
     586                 :            :     {
     587         [ #  # ]:          0 :         Window* pChild = GetPathDialog()->GetChild( n );
     588         [ #  # ]:          0 :         pChild = pChild->GetWindow( WINDOW_CLIENT );
     589 [ #  # ][ #  # ]:          0 :         if( pChild->GetType() != WINDOW_WINDOW )
     590                 :            :         {
     591                 :          0 :             aPos.Y() += nDY;
     592         [ #  # ]:          0 :             pChild->SetPosSizePixel( aPos, aSize );
     593                 :            :         }
     594                 :            :         else
     595                 :            :         {
     596                 :          0 :             Size aDlgSize = GetPathDialog()->GetOutputSizePixel();
     597                 :          0 :             long nExtra = Min( aDlgSize.Height(), (long)160);
     598         [ #  # ]:          0 :             GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nExtra, aDlgSize.Height() ) );
     599                 :          0 :             Size aSz( nExtra, nExtra );
     600                 :          0 :             aSz.Width() -= 8;
     601                 :          0 :             aSz.Height() -= 8;
     602                 :          0 :             Point aCtrlPos( aDlgSize.Width() + 2, (aDlgSize.Height()-aSz.Height())/2 );
     603         [ #  # ]:          0 :             pChild->SetPosSizePixel( aCtrlPos, aSz );
     604                 :            :         }
     605                 :            :     }
     606                 :            : 
     607                 :            :     // Laufwerke-LB fuellen
     608         [ #  # ]:          0 :     if( pDriveList )
     609                 :            :     {
     610         [ #  # ]:          0 :         DirEntry aTmpDirEntry;
     611         [ #  # ]:          0 :         Dir aDir( aTmpDirEntry, FSYS_KIND_BLOCK );
     612                 :            : 
     613         [ #  # ]:          0 :         sal_uInt16 nCount = aDir.Count(), i;
     614         [ #  # ]:          0 :         for( i = 0; i < nCount; ++i )
     615                 :            :         {
     616         [ #  # ]:          0 :             DirEntry& rEntry = aDir[i];
     617         [ #  # ]:          0 :             UniString aStr    = rEntry.GetFull( FSYS_STYLE_HOST, sal_False );
     618                 :            : 
     619         [ #  # ]:          0 :             UniString aVolume = rEntry.GetVolume() ;
     620         [ #  # ]:          0 :             aStr.ToUpperAscii();
     621         [ #  # ]:          0 :             if ( aVolume.Len() )
     622                 :            :             {
     623         [ #  # ]:          0 :                 aStr += ' ';
     624         [ #  # ]:          0 :                 aStr += aVolume;
     625                 :            :             }
     626         [ #  # ]:          0 :             pDriveList->InsertEntry( aStr );
     627                 :            : 
     628 [ #  # ][ #  # ]:          0 :         }
     629         [ #  # ]:          0 :         UniString aPathStr = aPath.GetFull();
     630                 :            : 
     631 [ #  # ][ #  # ]:          0 :         for ( i = 0; i < pDriveList->GetEntryCount(); ++i )
     632                 :            :         {
     633         [ #  # ]:          0 :             UniString aEntry = pDriveList->GetEntry(i);
     634                 :          0 :             xub_StrLen nLen   = aEntry.Len();
     635                 :          0 :             nLen = nLen > 2 ? 2 : nLen;
     636 [ #  # ][ #  # ]:          0 :             if ( aEntry.CompareIgnoreCaseToAscii( aPathStr, nLen ) == COMPARE_EQUAL )
     637                 :            :             {
     638         [ #  # ]:          0 :                 pDriveList->SelectEntryPos(i);
     639                 :            :                 break;
     640                 :            :             }
     641 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
                 [ #  # ]
     642                 :            :     }
     643                 :          0 : }
     644                 :            : 
     645                 :          0 : void ImpPathDialog::PostExecute()
     646                 :            : {
     647                 :          0 : }
     648                 :            : 
     649                 :          0 : void ImpPathDialog::SetPath( UniString const & rPath )
     650                 :            : {
     651 [ #  # ][ #  # ]:          0 :     aPath = DirEntry( rPath );
                 [ #  # ]
     652                 :            : 
     653         [ #  # ]:          0 :     pSvPathDialog->EnterWait();
     654                 :            : 
     655         [ #  # ]:          0 :     DirEntry aFile( rPath );
     656                 :            :     // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt
     657                 :            :     // -> abschneiden und merken
     658 [ #  # ][ #  # ]:          0 :     if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     659 [ #  # ][ #  # ]:          0 :         aFile.CutName();
     660                 :            : 
     661                 :            :     // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten
     662         [ #  # ]:          0 :     pEdit->SetText( rPath );
     663         [ #  # ]:          0 :     aFile.SetCWD( sal_True );
     664         [ #  # ]:          0 :     UpdateEntries( sal_True );
     665                 :            : 
     666 [ #  # ][ #  # ]:          0 :     pSvPathDialog->LeaveWait();
     667                 :          0 : }
     668                 :            : 
     669                 :          0 : UniString ImpPathDialog::GetPath() const
     670                 :            : {
     671 [ #  # ][ #  # ]:          0 :     DirEntry aFile( pEdit->GetText() );
                 [ #  # ]
     672         [ #  # ]:          0 :     aFile.ToAbs();
     673 [ #  # ][ #  # ]:          0 :     return aFile.GetFull();
     674                 :            : }
     675                 :            : 
     676                 :          0 : void ImpSvFileDlg::CreatePathDialog( PathDialog* pSvDlg, bool bCreate )
     677                 :            : {
     678         [ #  # ]:          0 :     delete pDlg;
     679         [ #  # ]:          0 :     pDlg = new ImpPathDialog( pSvDlg, WINDOW_PATHDIALOG, bCreate );
     680                 :          0 : }
     681                 :            : 
     682                 :            : 
     683                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10