summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorRodolfo Ribeiro Gomes <rodolforg@gmail.com>2013-05-15 01:11:52 -0300
committerFridrich Strba <fridrich@documentfoundation.org>2013-05-21 19:36:29 +0000
commit330ce827f2fbc6499eddf2084f8401fcdee5103b (patch)
tree64d6fbc5eed228b40df9774951bf81d840b44f79 /vcl
parent3ca73d5fcff2efbc2a5e2ce36714d24267a63fbc (diff)
Loader's ImageTree doesn't store multiple image paths anymore
Change-Id: Idd13039a76c46bfccad5f54e3357dde952508211 Signed-off-by: Rodolfo Ribeiro Gomes <rodolforg@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/3951 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impimagetree.hxx11
-rw-r--r--vcl/source/gdi/impimagetree.cxx107
2 files changed, 53 insertions, 65 deletions
diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index f42a0391bc90..0dc31104d43d 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -65,11 +65,10 @@ private:
OUString const & name, OUString const & style,
BitmapEx & bitmap, bool localized);
- typedef std::list<
- std::pair<
- OUString,
- com::sun::star::uno::Reference<
- com::sun::star::container::XNameAccess > > > Paths;
+ typedef std::pair<
+ OUString,
+ com::sun::star::uno::Reference<
+ com::sun::star::container::XNameAccess > > Path;
typedef boost::unordered_map<
OUString, bool, OUStringHash > CheckStyleCache;
@@ -77,7 +76,7 @@ private:
OUString, std::pair< bool, BitmapEx >, OUStringHash > IconCache;
OUString m_style;
- Paths m_paths;
+ Path m_path;
CheckStyleCache m_checkStyleCache;
IconCache m_iconCache;
bool m_cacheIcons;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index ea7d7cf254a3..935b8cf0135e 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -145,23 +145,21 @@ bool ImplImageTree::checkStyle(OUString const & style)
setStyle(style);
exists = false;
- for (Paths::iterator i(m_paths.begin()); i != m_paths.end() && !exists; ++i) {
- OUString aURL = i->first;
+ OUString aURL = m_path.first;
- osl::File aZip(aURL + ".zip");
- if (aZip.open(osl_File_OpenFlag_Read) == ::osl::FileBase::E_None) {
- aZip.close();
- exists = true;
- }
+ osl::File aZip(aURL + ".zip");
+ if (aZip.open(osl_File_OpenFlag_Read) == ::osl::FileBase::E_None) {
+ aZip.close();
+ exists = true;
+ }
- osl::Directory aLookaside(aURL);
- if (aLookaside.open() == ::osl::FileBase::E_None) {
- aLookaside.close();
- exists = true;
- m_cacheIcons = false;
- } else {
- m_cacheIcons = true;
- }
+ osl::Directory aLookaside(aURL);
+ if (aLookaside.open() == ::osl::FileBase::E_None) {
+ aLookaside.close();
+ exists = true;
+ m_cacheIcons = false;
+ } else {
+ m_cacheIcons = true;
}
m_checkStyleCache[style] = exists;
return exists;
@@ -239,7 +237,6 @@ bool ImplImageTree::doLoadImage(
void ImplImageTree::shutDown() {
m_style = OUString();
// for safety; empty m_style means "not initialized"
- m_paths.clear();
m_iconCache.clear();
m_checkStyleCache.clear();
}
@@ -254,8 +251,6 @@ void ImplImageTree::setStyle(OUString const & style) {
}
void ImplImageTree::resetPaths() {
- m_paths.clear();
-
OUString url( "$BRAND_BASE_DIR/share/config/" );
rtl::Bootstrap::expandMacros(url);
if ( m_style != "default" )
@@ -268,9 +263,8 @@ void ImplImageTree::resetPaths() {
}
else
url += "images";
- m_paths.push_back(
- std::make_pair(
- url, css::uno::Reference< css::container::XNameAccess >()));
+ m_path = std::make_pair(
+ url, css::uno::Reference< css::container::XNameAccess >());
}
bool ImplImageTree::checkStyleCacheLookup(
@@ -301,50 +295,45 @@ bool ImplImageTree::find(
std::vector< OUString > const & paths, BitmapEx & bitmap)
{
if (!m_cacheIcons) {
- for (Paths::iterator i(m_paths.begin()); i != m_paths.end(); ++i) {
- for (std::vector< OUString >::const_reverse_iterator j(
- paths.rbegin());
- j != paths.rend(); ++j)
- {
- osl::File file(i->first + "/" + *j);
- if (file.open(osl_File_OpenFlag_Read) == ::osl::FileBase::E_None) {
- loadImageFromStream( wrapFile(file), *j, bitmap );
- file.close();
- return true;
- }
- }
- }
- }
-
- for (Paths::iterator i(m_paths.begin()); i != m_paths.end();) {
- if (!i->second.is()) {
- try {
- i->second.set(
- css::packages::zip::ZipFileAccess::createWithURL(
- comphelper::getProcessComponentContext(),
- i->first + ".zip"),
- css::uno::UNO_QUERY_THROW);
- } catch (css::uno::RuntimeException &) {
- throw;
- } catch (const css::uno::Exception & e) {
- SAL_INFO("vcl", "ImplImageTree::find exception "
- << e.Message << " for " << i->first);
- i = m_paths.erase(i);
- continue;
- }
- }
for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin());
j != paths.rend(); ++j)
{
- if (i->second->hasByName(*j)) {
- css::uno::Reference< css::io::XInputStream > s;
- bool ok = i->second->getByName(*j) >>= s;
- OSL_ASSERT(ok); (void) ok;
- loadImageFromStream( wrapStream(s), *j, bitmap );
+ osl::File file(m_path.first + "/" + *j);
+ if (file.open(osl_File_OpenFlag_Read) == ::osl::FileBase::E_None) {
+ loadImageFromStream( wrapFile(file), *j, bitmap );
+ file.close();
return true;
}
}
- ++i;
+ }
+
+ if (!m_path.second.is()) {
+ css::uno::Sequence< css::uno::Any > args(1);
+ args[0] <<= m_path.first + ".zip";
+ try {
+ m_path.second.set(
+ comphelper::getProcessServiceFactory()->createInstanceWithArguments(
+ OUString( "com.sun.star.packages.zip.ZipFileAccess"),
+ args),
+ css::uno::UNO_QUERY_THROW);
+ } catch (css::uno::RuntimeException &) {
+ throw;
+ } catch (const css::uno::Exception & e) {
+ SAL_INFO("vcl", "ImplImageTree::find exception "
+ << e.Message << " for " << m_path.first);
+ return false;
+ }
+ }
+ for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin());
+ j != paths.rend(); ++j)
+ {
+ if (m_path.second->hasByName(*j)) {
+ css::uno::Reference< css::io::XInputStream > s;
+ bool ok = m_path.second->getByName(*j) >>= s;
+ OSL_ASSERT(ok); (void) ok;
+ loadImageFromStream( wrapStream(s), *j, bitmap );
+ return true;
+ }
}
return false;
}