summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-23 01:36:24 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-23 03:08:48 +0100
commit3820d954535b7b0b0e976ccd01251de848e3faea (patch)
treec54bdd0523413c97c897e4533fa2b9049b7f9110 /vcl
parent9e4a1396d602b010f2dbdb0b7f1249dfe1abd01a (diff)
icons: Store paths of more styles at the same time.
Change-Id: I9a13aa3ed928b989eaa2b2da8d1acfc5a37f506e
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impimagetree.hxx16
-rw-r--r--vcl/source/gdi/impimagetree.cxx50
2 files changed, 43 insertions, 23 deletions
diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index 22075862e7e1..94a54695038d 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -58,17 +58,27 @@ public:
css::uno::Reference< css::container::XNameAccess > getNameAccess();
private:
+ struct IconSet {
+ OUString maURL;
+ css::uno::Reference<css::container::XNameAccess> maNameAccess;
+
+ IconSet() {}
+ IconSet(const OUString &aURL) : maURL(aURL) {}
+ };
+
+ /// Map between the theme name(s) and the content.
+ typedef boost::unordered_map<OUString, IconSet, OUStringHash> StyleIconSet;
+
+ StyleIconSet maIconSet;
+
bool doLoadImage(
OUString const & name, OUString const & style,
BitmapEx & bitmap, bool localized);
- typedef std::pair<OUString, css::uno::Reference<css::container::XNameAccess>> Path;
-
typedef boost::unordered_map<OUString, std::pair<bool, BitmapEx>, OUStringHash> IconCache;
typedef boost::unordered_map<OUString, OUString, OUStringHash> IconLinkHash;
OUString m_style;
- Path m_path;
IconCache m_iconCache;
IconLinkHash m_linkHash;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 63a5c56710fe..d76070dac402 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -47,6 +47,8 @@
#include "impimagetree.hxx"
#include <vcldemo-debug.hxx>
+using namespace css;
+
namespace {
static OUString createPath(OUString const & name, sal_Int32 pos, OUString const & locale)
@@ -191,6 +193,9 @@ void ImplImageTree::setStyle(OUString const & style)
void ImplImageTree::resetPaths()
{
+ if (maIconSet.find(m_style) != maIconSet.end())
+ return;
+
OUString url( "$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/config/" );
rtl::Bootstrap::expandMacros(url);
if ( m_style != "default" )
@@ -203,8 +208,8 @@ void ImplImageTree::resetPaths()
}
else
url += "images";
- m_path = std::make_pair(
- url, css::uno::Reference< css::container::XNameAccess >());
+
+ maIconSet[m_style] = IconSet(url);
}
bool ImplImageTree::iconCacheLookup(OUString const & name, bool localized, BitmapEx & bitmap)
@@ -223,14 +228,16 @@ bool ImplImageTree::findImage(std::vector<OUString> const & paths, BitmapEx & bi
if (!checkPathAccess())
return false;
- for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin());
- j != paths.rend(); ++j)
+ const uno::Reference<container::XNameAccess> &rNameAccess = maIconSet[m_style].maNameAccess;
+
+ for (std::vector<OUString>::const_reverse_iterator j(paths.rbegin()); j != paths.rend(); ++j)
{
- if (m_path.second->hasByName(*j))
+ if (rNameAccess->hasByName(*j))
{
css::uno::Reference< css::io::XInputStream > s;
- bool ok = m_path.second->getByName(*j) >>= s;
- OSL_ASSERT(ok); (void) ok;
+ bool ok = rNameAccess->getByName(*j) >>= s;
+ assert(ok);
+
loadImageFromStream( wrapStream(s), *j, bitmap );
return true;
}
@@ -245,11 +252,13 @@ void ImplImageTree::loadImageLinks()
if (!checkPathAccess())
return;
- if ( m_path.second->hasByName(aLinkFilename) )
+ const uno::Reference<container::XNameAccess> &rNameAccess = maIconSet[m_style].maNameAccess;
+
+ if (rNameAccess->hasByName(aLinkFilename))
{
css::uno::Reference< css::io::XInputStream > s;
- bool ok = m_path.second->getByName(aLinkFilename) >>= s;
- OSL_ASSERT(ok); (void) ok;
+ bool ok = rNameAccess->getByName(aLinkFilename) >>= s;
+ assert(ok);
parseLinkFile( wrapStream(s) );
return;
@@ -293,25 +302,27 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name)
bool ImplImageTree::checkPathAccess()
{
- if (m_path.second.is())
+ uno::Reference<container::XNameAccess> &rNameAccess = maIconSet[m_style].maNameAccess;
+ if (rNameAccess.is())
return true;
try {
- m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
- } catch (const css::uno::RuntimeException &) {
+ rNameAccess = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), maIconSet[m_style].maURL + ".zip");
+ }
+ catch (const css::uno::RuntimeException &) {
throw;
- } catch (const css::uno::Exception & e) {
- SAL_INFO("vcl", "ImplImageTree::zip file location exception "
- << e.Message << " for " << m_path.first);
+ }
+ catch (const css::uno::Exception & e) {
+ SAL_INFO("vcl", "ImplImageTree::zip file location exception " << e.Message << " for " << maIconSet[m_style].maURL);
return false;
}
- return m_path.second.is();
+ return rNameAccess.is();
}
css::uno::Reference<css::container::XNameAccess> ImplImageTree::getNameAccess()
{
checkPathAccess();
- return m_path.second;
+ return maIconSet[m_style].maNameAccess;
}
/// Recursively dump all names ...
@@ -319,8 +330,7 @@ css::uno::Sequence<OUString> ImageTree_getAllImageNames()
{
static ImplImageTreeSingletonRef aImageTree;
- css::uno::Reference< css::container::XNameAccess > xRef(
- aImageTree->getNameAccess() );
+ css::uno::Reference<css::container::XNameAccess> xRef(aImageTree->getNameAccess());
return xRef->getElementNames();
}