Hi,The attached patch implements in the ImageList class a fallback to load a default icon if no one is found.
I have performed the following tests:1st test I have done is adding the 'About Libre Office' entry to the standard toolbar, using an existing icon.
in ~/.libreoffice/.../lc_imagelist.xml there is the following entry: <image:entry image:bitmap-index="0" image:command=".uno:About"/>I replace .uno:About by .uno:AboutFoo, I restart soffice and the default icon is now loaded for the About button :-)
2nd test is removing from images.zip all the icons except the default one... Find attached a screenshot of the result. All buttons are now displayed with the default icon. Regards, Joachim.
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx index 1a09d86..d2fa1fe 100644 --- a/sd/source/ui/view/viewoverlaymanager.cxx +++ b/sd/source/ui/view/viewoverlaymanager.cxx @@ -45,7 +45,6 @@ #include <tools/rcid.h> #include <vcl/help.hxx> -#include <vcl/imagerepository.hxx> #include <vcl/lazydelete.hxx> #include <svx/sdrpagewindow.hxx> diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index fabf676..5cfa9d1 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -63,6 +63,8 @@ #include <rtl/logfile.hxx> #include "svtools/miscopt.hxx" +#include "vcl/imagerepository.hxx" + //_________________________________________________________________________________________________________________ // namespaces //_________________________________________________________________________________________________________________ @@ -322,7 +324,6 @@ Image CmdImageList::getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUS ImageList* pImageList = impl_getImageList( nImageType ); return pImageList->GetImage( pIter->second ); } - return Image(); } @@ -361,7 +362,17 @@ GlobalImageList::~GlobalImageList() Image GlobalImageList::getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUString& rCommandURL ) { osl::MutexGuard guard( getGlobalImageListMutex() ); - return CmdImageList::getImageFromCommandURL( nImageType, rCommandURL ); + Image aImage = CmdImageList::getImageFromCommandURL( nImageType, rCommandURL ); + if (!aImage) + { + BitmapEx rBitmap; + bool res = ::vcl::ImageRepository::loadDefaultImage(rBitmap); + if (res) { + aImage = Image(rBitmap); + } + } + return aImage; } bool GlobalImageList::hasImage( sal_Int16 nImageType, const rtl::OUString& rCommandURL ) @@ -953,8 +964,9 @@ throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno: if ( !aImage && m_bUseGlobal ) { aImage = pDefaultImageList->getImageFromCommandURL( nIndex, aStrArray[n] ); - if ( !aImage ) + if ( !aImage ) { aImage = rGlobalImageList->getImageFromCommandURL( nIndex, aStrArray[n] ); + } } aGraphSeq[n] = aImage.GetXGraphic(); diff --git a/toolkit/source/layout/core/helper.cxx b/toolkit/source/layout/core/helper.cxx index 0afd3a4..791901b 100644 --- a/toolkit/source/layout/core/helper.cxx +++ b/toolkit/source/layout/core/helper.cxx @@ -595,7 +595,7 @@ uno::Reference< graphic::XGraphic > loadGraphic( const char *pName ) if ( aStr.compareToAscii( ".uno:" ) == 0 ) aStr = aStr.copy( 5 ).toAsciiLowerCase(); - if ( !vcl::ImageRepository::loadImage( OUString::createFromAscii( pName ), aBmp, true ) ) + if ( !vcl::ImageRepository::loadImage( OUString::createFromAscii( pName ), aBmp, true, true ) ) return uno::Reference< graphic::XGraphic >(); return Graphic( aBmp ).GetXGraphic(); diff --git a/vcl/inc/vcl/imagerepository.hxx b/vcl/inc/vcl/imagerepository.hxx index a9009df..cb1dc2a 100644 --- a/vcl/inc/vcl/imagerepository.hxx +++ b/vcl/inc/vcl/imagerepository.hxx @@ -59,7 +59,12 @@ namespace vcl static bool loadImage( const ::rtl::OUString& _rName, BitmapEx& _out_rImage, - bool bSearchLanguageDependent + bool bSearchLanguageDependent, + bool loadMissing = false + ); + + static bool loadDefaultImage( + BitmapEx& _out_rImage ); }; diff --git a/vcl/inc/vcl/impimagetree.hxx b/vcl/inc/vcl/impimagetree.hxx index bfaff19..68f9a73 100644 --- a/vcl/inc/vcl/impimagetree.hxx +++ b/vcl/inc/vcl/impimagetree.hxx @@ -60,6 +60,10 @@ public: rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap, bool localized = false, bool loadMissing = false ); + bool loadDefaultImage( + rtl::OUString const & style, + BitmapEx& bitmap); + void shutDown(); // a crude form of life cycle control (called from DeInitVCL; otherwise, // if the ImplImageTree singleton were destroyed during exit that would diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 43589e3..f63c0fe 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -104,7 +104,7 @@ BitmapEx::BitmapEx( const ResId& rResId ) : const String aFileName( pResMgr->ReadString() ); ::rtl::OUString aCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); - if( !aImageTree->loadImage( aFileName, aCurrentSymbolsStyle, *this ) ) + if( !aImageTree->loadImage( aFileName, aCurrentSymbolsStyle, *this, true ) ) { #ifdef DBG_UTIL ByteString aErrorStr( "BitmapEx::BitmapEx( const ResId& rResId ): could not load image <" ); diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx index db4cfdb..8b24fba 100644 --- a/vcl/source/gdi/image.cxx +++ b/vcl/source/gdi/image.cxx @@ -44,6 +44,7 @@ #include <vcl/impimagetree.hxx> #include <vcl/image.h> #include <vcl/image.hxx> +#include <vcl/imagerepository.hxx> #if OSL_DEBUG_LEVEL > 0 #include <rtl/strbuf.hxx> @@ -490,8 +491,6 @@ ImageList::ImageList( const ::std::vector< ::rtl::OUString >& rNameVector, mpImplData->maPrefix = rPrefix; for( sal_uInt32 i = 0; i < rNameVector.size(); ++i ) { -// fprintf (stderr, "List %p [%d]: '%s'\n", -// this, i, rtl::OUStringToOString( rNameVector[i], RTL_TEXTENCODING_UTF8 ).getStr() ); mpImplData->AddImage( rNameVector[ i ], static_cast< USHORT >( i ) + 1, BitmapEx() ); } } @@ -537,9 +536,6 @@ void ImageAryData::Load(const rtl::OUString &rPrefix) BitmapEx aBmpEx; -// fprintf (stderr, "Attempt load of '%s'\n", -// rtl::OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ).getStr() ); - rtl::OUString aFileName = rPrefix; aFileName += maName; #if OSL_DEBUG_LEVEL > 0 @@ -616,8 +612,6 @@ void ImageList::InsertFromHorizontalStrip( const BitmapEx &rBitmapEx, { USHORT nItems = sal::static_int_cast< USHORT >( rNameVector.size() ); -// fprintf (stderr, "InsertFromHorizontalStrip (1) [%d items]\n", nItems); - if (!nItems) return; @@ -789,8 +783,6 @@ Image ImageList::GetImage( USHORT nId ) const { DBG_CHKTHIS( ImageList, NULL ); -// fprintf (stderr, "GetImage %d\n", nId); - Image aRet; if( mpImplData ) @@ -809,6 +801,15 @@ Image ImageList::GetImage( USHORT nId ) const } } + if (!aRet) + { + BitmapEx rBitmap; + bool res = ::vcl::ImageRepository::loadDefaultImage(rBitmap); + if (res) { + aRet = Image(rBitmap); + } + } + return aRet; } @@ -816,9 +817,6 @@ Image ImageList::GetImage( USHORT nId ) const Image ImageList::GetImage( const ::rtl::OUString& rImageName ) const { -// fprintf (stderr, "GetImage '%s'\n", -// rtl::OUStringToOString( rImageName, RTL_TEXTENCODING_UTF8 ).getStr() ); - if( mpImplData ) { ImageAryData *pImg = mpImplData->maNameHash[ rImageName ]; @@ -830,7 +828,6 @@ Image ImageList::GetImage( const ::rtl::OUString& rImageName ) const return Image( pImg->maBitmapEx ); } } -// fprintf (stderr, "no such image\n"); return Image(); } @@ -979,9 +976,6 @@ Size ImageList::GetImageSize() const aRet = mpImplData->maImageSize = aTmp.GetSizePixel(); } } -// fprintf (stderr, "GetImageSize returns %d, %d\n", -// aRet.Width(), aRet.Height()); - return aRet; } diff --git a/vcl/source/gdi/imagerepository.cxx b/vcl/source/gdi/imagerepository.cxx index fa358c9..e1c8aac 100644 --- a/vcl/source/gdi/imagerepository.cxx +++ b/vcl/source/gdi/imagerepository.cxx @@ -42,12 +42,19 @@ namespace vcl //= ImageRepository //==================================================================== //-------------------------------------------------------------------- - bool ImageRepository::loadImage( const ::rtl::OUString& _rName, BitmapEx& _out_rImage, bool _bSearchLanguageDependent ) + bool ImageRepository::loadImage( const ::rtl::OUString& _rName, BitmapEx& _out_rImage, bool _bSearchLanguageDependent, bool loadMissing ) { ::rtl::OUString sCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); ImplImageTreeSingletonRef aImplImageTree; - return aImplImageTree->loadImage( _rName, sCurrentSymbolsStyle, _out_rImage, _bSearchLanguageDependent ); + return aImplImageTree->loadImage( _rName, sCurrentSymbolsStyle, _out_rImage, _bSearchLanguageDependent, loadMissing ); + } + + bool ImageRepository::loadDefaultImage( BitmapEx& _out_rImage) + { + ::rtl::OUString sCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); + ImplImageTreeSingletonRef aImplImageTree; + return aImplImageTree->loadDefaultImage( sCurrentSymbolsStyle,_out_rImage); } //........................................................................ diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index 5bf567d..6ad214e 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -167,14 +167,23 @@ bool ImplImageTree::loadImage( OSL_TRACE( "ImplImageTree::loadImage exception couldn't load \"%s\", fetching missing_icon.png", rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr()); - found = doLoadImage( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("res/missing_icon.png")), - style, bitmap, false); + found = loadDefaultImage(style, bitmap); } catch (css::uno::RuntimeException &) { throw; } return found; } +bool ImplImageTree::loadDefaultImage( + rtl::OUString const & style, + BitmapEx& bitmap) +{ + return doLoadImage( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("res/grafikde.png")), + style, bitmap, false); +} + + bool ImplImageTree::doLoadImage( rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap, bool localized)
Attachment:
Screenshot_no_icon.png
Description: PNG image