diff options
author | Peter Burow <pb@openoffice.org> | 2001-11-22 13:06:38 +0000 |
---|---|---|
committer | Peter Burow <pb@openoffice.org> | 2001-11-22 13:06:38 +0000 |
commit | 40494e7561c7f4ae447d71abda94b855185d04f5 (patch) | |
tree | 220bde6e4a17640f6f12f8fac2ca922a6820a482 /svtools | |
parent | 621045d7c99a27fbac0ecedfa7157ae9ab86dbb7 (diff) |
fix: #83182# show correct volume icons
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 74 | ||||
-rw-r--r-- | svtools/source/misc/imagemgr.cxx | 159 | ||||
-rw-r--r-- | svtools/source/misc/imagemgr.src | 30 |
3 files changed, 158 insertions, 105 deletions
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 4ef001f53e26..f86ab2465892 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fileview.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: gt $ $Date: 2001-11-12 14:38:20 $ + * last change: $Author: pb $ $Date: 2001-11-22 14:04:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1268,15 +1268,8 @@ void SvtFileView::OpenFolder( const Sequence< OUString >& aContents ) aNewRow += aDate; // detect image sal_Bool bDoInsert = sal_True; - Image aImage; - - if ( bIsFolder ) - aImage = mpImp->maFolderImage; - else - { - INetURLObject aObj( aImageURL.Len() > 0 ? aImageURL : aURL ); - aImage = SvFileInformationManager::GetImage( aObj, FALSE ); - } + INetURLObject aObj( aImageURL.Len() > 0 ? aImageURL : aURL ); + Image aImage = SvFileInformationManager::GetImage( aObj, FALSE ); if ( bDoInsert ) { @@ -1761,24 +1754,24 @@ void SvtFileView_Impl::GetFolderContent_Impl( const String& rFolder ) try { + ::com::sun::star::util::DateTime aDT; + while ( xResultSet->next() ) { pData = new SortingData_Impl; - ::com::sun::star::util::DateTime aDT = xRow->getTimestamp( ROW_DATE_MOD ); + aDT = xRow->getTimestamp( ROW_DATE_MOD ); if ( xRow->wasNull() ) aDT = xRow->getTimestamp( ROW_DATE_CREATE ); OUString aContentURL = xContentAccess->queryContentIdentifierString(); OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); - sal_Bool bTarget = aTargetURL.getLength() > 0; - + sal_Bool bHasTargetURL = aTargetURL.getLength() > 0; pData->mbIsFolder = xRow->getBoolean( ROW_IS_FOLDER ); pData->SetNewTitle( xRow->getString( ROW_TITLE ) ); + pData->maSize = xRow->getLong( ROW_SIZE ); - pData->maSize = xRow->getLong( ROW_SIZE ); - - if ( bTarget && + if ( bHasTargetURL && INetURLObject( aContentURL ).GetProtocol() == INET_PROT_VND_SUN_STAR_HIER ) { Content aCnt( aTargetURL, Reference< XCommandEnvironment > () ); @@ -1788,14 +1781,13 @@ void SvtFileView_Impl::GetFolderContent_Impl( const String& rFolder ) CONVERT_DATETIME( aDT, pData->maModDate ); - if ( aTargetURL.getLength() ) - pData->maTargetURL = aTargetURL; + if ( bHasTargetURL ) + pData->maTargetURL = aTargetURL; else - pData->maTargetURL = aContentURL; + pData->maTargetURL = aContentURL; - INetURLObject aURLObj( pData->maTargetURL ); - - pData->maType = SvFileInformationManager::GetDescription( aURLObj ); + pData->maType = + SvFileInformationManager::GetDescription( INetURLObject( pData->maTargetURL ) ); // replace names on demand if( mbReplaceNames ) @@ -2020,22 +2012,21 @@ void SvtFileView_Impl::CreateDisplayText_Impl() if ( ! (*aIt)->mbIsFolder ) aValue += CreateExactSizeText_Impl( (*aIt)->maSize ); aValue += aTab; - // set the date - aValue += aLocaleWrapper.getDate( (*aIt)->maModDate ); - aValue += aDateSep; - aValue += aLocaleWrapper.getTime( (*aIt)->maModDate ); - + // set the date, but volumes have no date + sal_Bool bIsVolume = sal_False; + ::utl::UCBContentHelper::GetProperty( + (*aIt)->maTargetURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsVolume") ) ) >>= bIsVolume; + if ( ! (*aIt)->mbIsFolder || !bIsVolume ) + { + aValue += aLocaleWrapper.getDate( (*aIt)->maModDate ); + aValue += aDateSep; + aValue += aLocaleWrapper.getTime( (*aIt)->maModDate ); + } (*aIt)->maDisplayText = aValue; // detect image - - if ( (*aIt)->mbIsFolder ) - (*aIt)->maImage = maFolderImage; - else - { - INetURLObject aObj( (*aIt)->maTargetURL ); - (*aIt)->maImage = SvFileInformationManager::GetImage( aObj, FALSE ); - } + INetURLObject aObj( (*aIt)->maTargetURL ); + (*aIt)->maImage = SvFileInformationManager::GetImage( aObj, FALSE ); } } @@ -2117,13 +2108,8 @@ void SvtFileView_Impl::CreateVector_Impl( const Sequence < OUString > &rList ) pEntry->maDisplayText = aDisplayText; // detect the image - if ( pEntry->mbIsFolder ) - pEntry->maImage = maFolderImage; - else - { - INetURLObject aObj( pEntry->maImageURL.getLength() ? pEntry->maImageURL : pEntry->maTargetURL ); - pEntry->maImage = SvFileInformationManager::GetImage( aObj, FALSE ); - } + INetURLObject aObj( pEntry->maImageURL.getLength() ? pEntry->maImageURL : pEntry->maTargetURL ); + pEntry->maImage = SvFileInformationManager::GetImage( aObj, FALSE ); maContent.push_back( pEntry ); } @@ -2319,7 +2305,7 @@ void SvtFileView_Impl::FolderInserted( const OUString& rURL, INetURLObject aURLObj( rURL ); pData->maType = SvFileInformationManager::GetDescription( aURLObj ); - pData->maImage = maFolderImage; + pData->maImage = SvFileInformationManager::GetImage( aURLObj, FALSE ); LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index ffc9e17561aa..76505a004804 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imagemgr.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: mba $ $Date: 2001-09-13 12:40:26 $ + * last change: $Author: pb $ $Date: 2001-11-22 14:06:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,7 +106,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #endif -#include <com/sun/star/uno/Reference.h> +//#include <com/sun/star/uno/Reference.h> #include "svtools.hrc" #include "imagemgr.hrc" @@ -114,7 +114,9 @@ // globals ******************************************************************* -#define NO_INDEX ((USHORT)0xFFFF) +#define NO_INDEX ((USHORT)0xFFFF) +#define CONTENT_HELPER ::utl::UCBContentHelper +#define ASCII_STRING(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) static ImageList* _pSmallImageList = NULL; static ImageList* _pBigImageList = NULL; @@ -131,16 +133,12 @@ static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = { "awk", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, "bas", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, -#ifndef WNT "bat", TRUE, STR_DESCRIPTION_BATCHFILE, IMG_APP, -#endif "bmk", FALSE, STR_DESCRIPTION_BOOKMARKFILE, 0, "bmp", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP, "c", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, "cfg", FALSE, STR_DESCRIPTION_CFGFILE, 0, -#ifndef WNT "cmd", TRUE, STR_DESCRIPTION_BATCHFILE, IMG_APP, -#endif "cob", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, "com", TRUE, STR_DESCRIPTION_APPLICATION, IMG_APP, "cxx", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, @@ -149,9 +147,7 @@ static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = "dll", TRUE, STR_DESCRIPTION_SYSFILE, 0, "doc", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WORD, "dxf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_DXF, -#ifndef WNT "exe", TRUE, STR_DESCRIPTION_APPLICATION, IMG_APP, -#endif "gif", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF, "h", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE, "hlp", FALSE, STR_DESCRIPTION_HELP_DOC, IMG_HELP, @@ -300,7 +296,7 @@ String GetImageExtensionByFactory_Impl( const String& rURL ) // get the TypeDetection service to access all registered types ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xFac = ::comphelper::getProcessServiceFactory(); ::com::sun::star::uno::Reference < ::com::sun::star::document::XTypeDetection > xTypeDetector( - xFac->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection") ) ), ::com::sun::star::uno::UNO_QUERY ); + xFac->createInstance( ASCII_STRING("com.sun.star.document.TypeDetection") ), ::com::sun::star::uno::UNO_QUERY ); ::rtl::OUString aInternalType = xTypeDetector->queryTypeByURL( rURL ); ::com::sun::star::uno::Reference < ::com::sun::star::container::XNameAccess > xAccess( xTypeDetector, ::com::sun::star::uno::UNO_QUERY ); @@ -372,28 +368,61 @@ USHORT GetImageId_Impl( const String& rExtension ) return nImage; } +sal_Bool GetVolumeProperties_Impl( const String& rURL, + sal_Bool& rIsVolume, sal_Bool& rIsRemote, sal_Bool& rIsRemoveable ) +{ + sal_Bool bRet = sal_False; + + try + { + bRet = ( ( CONTENT_HELPER::GetProperty( rURL, ASCII_STRING("IsVolume") ) >>= rIsVolume ) && + ( CONTENT_HELPER::GetProperty( rURL, ASCII_STRING("IsRemote") ) >>= rIsRemote ) && + ( CONTENT_HELPER::GetProperty( rURL, ASCII_STRING("IsRemoveable") ) >>= rIsRemoveable ) ); + } + catch( const ::com::sun::star::uno::Exception& ) + { + // type detection failed -> no extension + } + + return bRet; +} + +USHORT GetFolderImageId_Impl( const String& rURL ) +{ + USHORT nRet = IMG_FOLDER; + sal_Bool bIsVolume = sal_False, bIsRemote = sal_False, bIsRemoveable = sal_False; + if ( GetVolumeProperties_Impl( rURL, bIsVolume, bIsRemote, bIsRemoveable ) ) + { + if ( bIsRemote ) + nRet = IMG_NETWORKDEV; + else if ( bIsRemoveable ) + nRet = IMG_REMOVEABLEDEV; + else if ( bIsVolume ) + nRet = IMG_FIXEDDEV; + } + return nRet; +} + USHORT GetImageId_Impl( const INetURLObject& rObject ) { - String aExt; + String aExt, sURL = rObject.GetMainURL( INetURLObject::NO_DECODE ); USHORT nImage = IMG_FILE; if ( rObject.GetProtocol() == INET_PROT_PRIVATE ) { - String aURLPath = rObject.GetMainURL().Erase( 0, URL_PREFIX_PRIV_SOFFICE_LEN ); + String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN ); String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN ); if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) ) - aExt = GetImageExtensionByFactory_Impl( rObject.GetMainURL() ); + aExt = GetImageExtensionByFactory_Impl( sURL ); else if ( aType == String( RTL_CONSTASCII_STRINGPARAM("image") ) ) - { nImage = (USHORT)aURLPath.GetToken( 1, INET_PATH_TOKEN ).ToInt32(); - } } else { aExt = rObject.getExtension(); if ( aExt.EqualsAscii( "vor" ) ) { - SotStorageRef aStorage = new SotStorage( rObject.GetMainURL(), STREAM_STD_READ ); + SotStorageRef aStorage = new SotStorage( sURL, STREAM_STD_READ ); USHORT nId = IMG_WRITERTEMPLATE; if ( !aStorage->GetError() ) { @@ -416,9 +445,9 @@ USHORT GetImageId_Impl( const INetURLObject& rObject ) #if defined( OS2 ) || defined( MAC ) if ( nImage == IMG_FILE ) { - SvEaMgr aMgr( rObject.GetMainURL() ); + SvEaMgr aMgr( sURL ); String aType; - if( aMgr.GetFileType( aType ) ) + if( aMgr.GetFileType( aType ) ) { for( USHORT nIndex = 0; Mappings[ nIndex ]._pExt; nIndex++ ) if ( Mappings[ nIndex ]._pExt == aType ) @@ -428,7 +457,12 @@ USHORT GetImageId_Impl( const INetURLObject& rObject ) #endif if ( nImage == IMG_FILE ) - nImage = GetImageId_Impl( aExt ); + { + if ( ::utl::UCBContentHelper::IsFolder( sURL ) ) + nImage = GetFolderImageId_Impl( sURL ); + else if ( aExt.Len() > 0 ) + nImage = GetImageId_Impl( aExt ); + } return nImage; } @@ -476,6 +510,20 @@ String GetDescriptionByFactory_Impl( const String& rFactory ) return aRet; } +USHORT GetFolderDescriptionId_Impl( const String& rURL ) +{ + USHORT nRet = STR_DESCRIPTION_FOLDER; + sal_Bool bIsVolume = sal_False, bIsRemote = sal_False, bIsRemoveable = sal_False; + if ( GetVolumeProperties_Impl( rURL, bIsVolume, bIsRemote, bIsRemoveable ) ) + { + if ( bIsRemote ) + nRet = STR_DESCRIPTION_REMOTE_VOLUME; + else if ( bIsRemoveable || bIsVolume ) + nRet = STR_DESCRIPTION_LOCALE_VOLUME; + } + return nRet; +} + //**************************************************************************** @@ -509,6 +557,10 @@ Image SvFileInformationManager::GetImage( const INetURLObject& rObject, BOOL bBi USHORT nImage = GetImageId_Impl( rObject ); DBG_ASSERT( nImage, "invalid ImageId" ); + if ( !bBig && IMG_FOLDER == nImage ) + // return our new small folder image (256 colors) + return Image( SvtResId( IMG_SVT_FOLDER ) ); + ImageList* pList = NULL; if ( bBig ) { @@ -534,26 +586,23 @@ Image SvFileInformationManager::GetImage( const INetURLObject& rObject, BOOL bBi String SvFileInformationManager::GetDescription( const INetURLObject& rObject ) { - String aDescription; - { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - aDescription = String( SvtResId( STR_DESCRIPTION_FOLDER ) ); - } - sal_Bool bShowExt = sal_False; - sal_Bool bDetected = sal_False; - sal_Bool bFolder = ::utl::UCBContentHelper::IsFolder( rObject.GetMainURL() ); + String sDescription; + String sExtension( rObject.getExtension() ), sURL( rObject.GetMainURL( INetURLObject::NO_DECODE ) ); + USHORT nResId = 0; + sal_Bool bShowExt = sal_False, bDetected = sal_False, bOnlyFile = sal_False; + sal_Bool bFolder = ::utl::UCBContentHelper::IsFolder( sURL ); if ( !bFolder ) { #if defined( OS2 ) || defined( MAC ) // FileType via EAs - SvEaMgr aMgr( rObject.GetMainURL() ); + SvEaMgr aMgr( sMainURL ); String aType; if ( aMgr.GetFileType( aType ) ) { for( USHORT nIndex = 0; !bDetected && Mappings[ nIndex ]._pExt; nIndex++ ) if ( Mappings[ nIndex ]._pExt == aType ) { - aDescription = SfxResId( Mappings[ nIndex ]._nStrId ); + sDescription = SfxResId( Mappings[ nIndex ]._nStrId ); bDetected = sal_True; } } @@ -562,43 +611,57 @@ String SvFileInformationManager::GetDescription( const INetURLObject& rObject ) { if ( rObject.GetProtocol() == INET_PROT_PRIVATE ) { - String aURLPath = rObject.GetMainURL().Erase( 0, URL_PREFIX_PRIV_SOFFICE_LEN ); + String aURLPath = sURL.Copy( URL_PREFIX_PRIV_SOFFICE_LEN ); String aType = aURLPath.GetToken( 0, INET_PATH_TOKEN ); if ( aType == String( RTL_CONSTASCII_STRINGPARAM("factory") ) ) { - aDescription = GetDescriptionByFactory_Impl( aURLPath.Copy( aURLPath.Search( INET_PATH_TOKEN ) + 1 ) ); + sDescription = GetDescriptionByFactory_Impl( aURLPath.Copy( aURLPath.Search( INET_PATH_TOKEN ) + 1 ) ); bDetected = sal_True; } } if ( !bDetected ) { - // Bestimmung der Dateiendung - String aExtension( rObject.getExtension() ); - aExtension.ToLowerAscii(); - - // Iteration ueber alle Zuordnungen - USHORT nResId = 0; - if ( aExtension.Len() ) - nResId = GetDescriptionId_Impl( aExtension, bShowExt ); + // search a description by extension + sal_Bool bExt = ( sExtension.Len() > 0 ); + if ( bExt ) + { + sExtension.ToLowerAscii(); + nResId = GetDescriptionId_Impl( sExtension, bShowExt ); + } if ( !nResId ) + { nResId = STR_DESCRIPTION_FILE; - - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - aDescription = String( SvtResId( nResId ) ); + bOnlyFile = bExt; + } } + } + } + else + nResId = GetFolderDescriptionId_Impl( sURL ); - DBG_ASSERT( aDescription.Len() > 0, "file without description" ); + if ( nResId > 0 ) + { + if ( bOnlyFile ) + { + bShowExt = sal_False; + sExtension.ToUpperAscii(); + sDescription = sExtension; + sDescription += '-'; } + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + sDescription += String( SvtResId( nResId ) ); } + DBG_ASSERT( sDescription.Len() > 0, "file without description" ); + if ( bShowExt ) { - aDescription += String( RTL_CONSTASCII_STRINGPARAM(" (") ); - aDescription += rObject.getExtension().ToLowerAscii(); - aDescription += ')'; + sDescription += String( RTL_CONSTASCII_STRINGPARAM(" (") ); + sDescription += sExtension; + sDescription += ')'; } - return aDescription; + return sDescription; } diff --git a/svtools/source/misc/imagemgr.src b/svtools/source/misc/imagemgr.src index e1f5a29a1c05..f04eaf59eb43 100644 --- a/svtools/source/misc/imagemgr.src +++ b/svtools/source/misc/imagemgr.src @@ -2,9 +2,9 @@ * * $RCSfile: imagemgr.src,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: vg $ $Date: 2001-11-13 22:29:46 $ + * last change: $Author: pb $ $Date: 2001-11-22 14:06:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1191,15 +1191,19 @@ String STR_DESCRIPTION_WRITER_TEMPLATE Text[ arabic ] = "%PRODUCTNAME 6.0 Textdocument Template"; Text[ catalan ] = "%PRODUCTNAME 6.0 Textdocument Template"; }; - - - - - - - - - - - +String STR_DESCRIPTION_REMOTE_VOLUME +{ + Text = "Netzwerkverbindung" ; + Text [ english_us ] = "Network connection" ; +}; +String STR_DESCRIPTION_LOCALE_VOLUME +{ + Text = "Lokales Laufwerk" ; + Text [ english_us ] = "Local drive" ; +}; +String STR_DESCRIPTION_CDROM_VOLUME +{ + Text = "CD-ROM-Laufwerk" ; + Text [ english_us ] = "CD-ROM drive" ; +}; |