Index: sfx2/source/toolbox/tbxcust.cxx =================================================================== RCS file: /cvs/framework/sfx2/source/toolbox/tbxcust.cxx,v retrieving revision 1.27 diff -u -p -u -r1.27 tbxcust.cxx --- sfx2/source/toolbox/tbxcust.cxx 15 May 2003 10:54:28 -0000 1.27 +++ sfx2/source/toolbox/tbxcust.cxx 1 Oct 2003 16:18:43 -0000 @@ -1026,14 +1026,12 @@ SfxUserBitmapDialog_Impl::SfxUserBitmapD pMgr (pTbxMgr), pImageMgr (pImgMgr), bNoDefaultImage (FALSE), - bBigImages (FALSE), - nBmpColorConversion(BMP_CONVERSION_4BIT_COLORS), - nBmpColorDepth(4) + bBigImages (FALSE) { // file name prefixes for standard images - const sal_Int32 nPrefixLength = 2; - const char aSmallImagePrefix[] = "s_"; - const char aBigImagePrefix[] = "l_"; + const sal_Int32 nPrefixLength = 1; + const char aSmallImagePrefix[] = "s"; + const char aBigImagePrefix[] = "l"; Color aColor( pImageMgr->GetMaskColor() ); FreeResource(); @@ -1046,52 +1044,10 @@ SfxUserBitmapDialog_Impl::SfxUserBitmapD String aEmptyStr; Size aSize = pImageMgr->GetImageSize(); - // #109421# - // Get reference bitmap to determine the current color depth. Due to restriction - // of the ImageList and toolbar implementation we can only use one color depth - // for all bitmaps in an ImageList. Reference color depth is defined by the bitmaps - // in our resources. - Image aRefImage = pImageMgr->GetImage( SID_OPENDOC, BOOL(FALSE), 0 ); - if ( !!aRefImage ) - { - Bitmap aRefBitmap = aRefImage.GetBitmap(); - USHORT nColorDepth = aRefBitmap.GetBitCount(); - if ( nColorDepth == 1 ) - { - nBmpColorConversion = BMP_CONVERSION_1BIT_THRESHOLD; - nBmpColorDepth = 1; - } - else if ( nColorDepth <= 4 ) - { - nBmpColorConversion = BMP_CONVERSION_4BIT_COLORS; - nBmpColorDepth = 4; - } - else if ( nColorDepth <= 8 ) - { - nBmpColorConversion = BMP_CONVERSION_8BIT_COLORS; - nBmpColorDepth = 8; - } - else - { - nBmpColorConversion = BMP_CONVERSION_24BIT; - nBmpColorDepth = 24; - } - } - // Search the given directory for bitmaps: Sequence< rtl::OUString > aUrls( SfxContentHelper::GetFolderContents( aDirName, false )); USHORT nId = 1; - ImageList aImages(128, 128); // large growth factor, expecting many entries - - Image aDefaultImage = GetDefaultImage( nFuncId ); - - // Initially add default image to the front - aBitmapUrls.push_back( aEmptyStr ); - aSymbolTb.InsertItem( nId, aEmptyStr ); - aImages.AddImage( nId, aDefaultImage ); - - ++nId; // Insert the default image on the first position for (sal_Int32 i = 0; i < aUrls.getLength(); ++i) @@ -1103,27 +1059,21 @@ SfxUserBitmapDialog_Impl::SfxUserBitmapD { rtl::OUString aFileName = aUrlObj.getName(); - // Ignore "s_*" files if we show big images and "l_*" files if we show small images! - sal_Bool bIgnoreFile = bBigImages ? aFileName.matchIgnoreAsciiCaseAsciiL( aSmallImagePrefix, nPrefixLength, 0 ) : - aFileName.matchIgnoreAsciiCaseAsciiL( aBigImagePrefix, nPrefixLength, 0 ); + // Ignore "s*" files if we show big images and "l*" files if we show small images! + sal_Bool bIgnoreFile = bBigImages ? !aFileName.matchIgnoreAsciiCaseAsciiL( aBigImagePrefix, nPrefixLength, 0 ) : + !aFileName.matchIgnoreAsciiCaseAsciiL( aSmallImagePrefix, nPrefixLength, 0 ); if ( !bIgnoreFile ) { Bitmap aBitmap( createBitmap( rUrl )); - - // Check if we have a valid bitmap otherwise it can be possible that we can crash!! - if ( !!aBitmap ) - { - if ( aBitmap.GetSizePixel() != aSize ) - aBitmap.Scale( aSize, BMP_SCALE_FAST ); - - // Add image to the image list which will be used to initialize toolbox - aBitmapUrls.push_back( rUrl ); - aImages.AddImage( nId, Image( aBitmap, aColor ) ); - aSymbolTb.InsertItem( nId, aUrlObj.getName() ); - - if (++nId == 0) - break; - } + + if ( aBitmap.GetSizePixel() != aSize ) + continue; + + // Add image to the image list which will be used to initialize toolbox + aBitmapUrls.push_back( rUrl ); + aSymbolTb.InsertItem( nId, aUrlObj.getName() ); + aSymbolTb.SetItemImage( nId, Image( BitmapEx( aBitmap, aColor ) ) ); + nId++; } } } @@ -1135,24 +1085,13 @@ SfxUserBitmapDialog_Impl::SfxUserBitmapD for ( sal_Int32 i = 0; i < pOfficeImageList->GetImageCount(); i++ ) { USHORT nImageId = pOfficeImageList->GetImageId(i); - aSymbolTb.InsertItem( nImageId, aEmptyStr ); - - aImages.AddImage( nImageId, pOfficeImageList->GetImage( nImageId )); - - if (++nId == 0) - break; + aSymbolTb.InsertItem( nImageId, aEmptyStr ); + aSymbolTb.SetItemImage( nImageId, pOfficeImageList->GetImage( nImageId ) ); } } - // Set imagelist to the toolbox - aSymbolTb.SetImageList( aImages ); - LeaveWait(); -/* - // Einen Button f"ur reine Textbuttons einf"ugen - aSymbolTb.InsertItem(nCount+1, "Text"); - aSymbolTb.SetItemImage(nCount+1, Image()); -*/ + aOKButton.SetClickHdl( LINK(this,SfxUserBitmapDialog_Impl, OKHdl)); aSymbolTb.SetSelectHdl(LINK(this,SfxUserBitmapDialog_Impl, SelectHdl)); aDefaultBtn.SetClickHdl(LINK(this,SfxUserBitmapDialog_Impl, DefaultHdl)); @@ -1325,12 +1265,7 @@ Bitmap SfxUserBitmapDialog_Impl::createB (*pStream) >> aBitmap; delete pStream; } - - // Convert bitmap color depth to match our resource bitmap color depth. Otherwise - // we will have display problems on the screen. #109421# - if ( aBitmap.GetBitCount() != nBmpColorDepth ) - aBitmap.Convert( nBmpColorConversion ); - + return aBitmap; }