diff options
author | Joachim Trémouroux <joachim.tremouroux@gmail.com> | 2010-11-25 13:10:12 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-11-25 13:11:18 +0000 |
commit | 6c1779cedf60353cf4fcb109b71a632d4008720a (patch) | |
tree | 3d8193f682bb5d4e00d90dffa76368d046be160c | |
parent | 78f1ebca9503610d18147c7706e557049b2d73c5 (diff) |
Add a 'loadMissing' parameter for loading a special icon if necessary
-rw-r--r-- | vcl/inc/vcl/impimagetree.hxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/impimagetree.cxx | 26 |
2 files changed, 31 insertions, 1 deletions
diff --git a/vcl/inc/vcl/impimagetree.hxx b/vcl/inc/vcl/impimagetree.hxx index 849e98bb234c..4afa807cf28a 100644 --- a/vcl/inc/vcl/impimagetree.hxx +++ b/vcl/inc/vcl/impimagetree.hxx @@ -58,7 +58,7 @@ public: bool loadImage( rtl::OUString const & name, rtl::OUString const & style, - BitmapEx & bitmap, bool localized = false ); + BitmapEx & bitmap, bool localized = false, bool loadMissing = false ); void shutDown(); // a crude form of life cycle control (called from DeInitVCL; otherwise, @@ -66,6 +66,10 @@ public: // be too late for the destructors of the bitmaps in m_iconCache) private: + bool doLoadImage( + rtl::OUString const & name, rtl::OUString const & style, + BitmapEx & bitmap, bool localized); + typedef std::list< std::pair< rtl::OUString, diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index 7ad82a866067..403eb638b63c 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -151,6 +151,32 @@ bool ImplImageTree::checkStyle(rtl::OUString const & style) bool ImplImageTree::loadImage( rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap, + bool localized, bool loadMissing ) +{ + bool found = false; + try { + found = doLoadImage(name, style, bitmap, localized); + } catch (css::uno::RuntimeException &) { + if (!loadMissing) + throw; + } + if (found || !loadMissing) + return found; + + try { + 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); + } catch (css::uno::RuntimeException &) { + throw; + } + return found; +} + +bool ImplImageTree::doLoadImage( + rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap, bool localized) { setStyle(style); |