summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-23 03:06:27 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-23 03:15:53 +0100
commit78bf950a3e988f20bb5db61c966faa3b8de6d0e3 (patch)
tree18f8a4cf59db879db9cee19ec8a1a09047ef32e0 /vcl
parent10c7500c46d33ee5d35c943322e2a0603ca72f18 (diff)
icons: Implement the fallback mechanism for icons.
When an icon is not found in eg. images_sifr.zip, search it in images_tango.zip, etc. Change-Id: I8af952a1bd8e9e02531f84012e8ce39e75422313
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impimagetree.hxx9
-rw-r--r--vcl/source/gdi/impimagetree.cxx38
2 files changed, 37 insertions, 10 deletions
diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index 7e8dda75ea7a..e66e754a1c8d 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -95,8 +95,17 @@ private:
bool findImage(std::vector< OUString > const & paths, BitmapEx & bitmap );
void loadImageLinks();
+
void parseLinkFile(boost::shared_ptr< SvStream > stream);
+
+ /// Return name of a real .png according to links.txt.
OUString const & getRealImageName(OUString const & name);
+
+ /** Rerurn name of the fallback style for the provided one.
+
+ Must not be cyclic :-) The last theme in the chain returns an empty string.
+ */
+ OUString fallbackStyle(const OUString &style);
};
typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 9ce7fd2e6053..8955902039fe 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -101,21 +101,39 @@ ImplImageTree::~ImplImageTree()
{
}
+OUString ImplImageTree::fallbackStyle(const OUString &style)
+{
+ if (style == "galaxy")
+ return OUString();
+ else if (style == "industrial")
+ return OUString("galaxy");
+ else if (style == "tango")
+ return OUString("industrial");
+ else if (style == "breeze")
+ return OUString("sifr");
+
+ return OUString("tango");
+}
+
bool ImplImageTree::loadImage(OUString const & name, 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;
+ OUString aStyle(style);
+ while (!aStyle.isEmpty())
+ {
+ try {
+ if (doLoadImage(name, aStyle, bitmap, localized))
+ return true;
+ }
+ catch (css::uno::RuntimeException &) {}
+
+ aStyle = fallbackStyle(aStyle);
}
- if (found || !loadMissing)
- return found;
- SAL_INFO("vcl", "ImplImageTree::loadImage exception couldn't load \""
- << name << "\", fetching default image");
+ if (!loadMissing)
+ return false;
+
+ SAL_INFO("vcl", "ImplImageTree::loadImage couldn't load \"" << name << "\", fetching default image");
return loadDefaultImage(style, bitmap);
}