Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/3951 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/51/3951/1 Loader's ImageTree doesn't store multiple image pathes anymore Change-Id: Idd13039a76c46bfccad5f54e3357dde952508211 Signed-off-by: Rodolfo Ribeiro Gomes <rodolf...@gmail.com> --- M vcl/inc/impimagetree.hxx M vcl/source/gdi/impimagetree.cxx 2 files changed, 53 insertions(+), 67 deletions(-) diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx index f42a039..0dc3110 100644 --- a/vcl/inc/impimagetree.hxx +++ b/vcl/inc/impimagetree.hxx @@ -65,11 +65,10 @@ 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 @@ 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 97fa471..86e2f22 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -144,23 +144,21 @@ 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; @@ -238,7 +236,6 @@ void ImplImageTree::shutDown() { m_style = OUString(); // for safety; empty m_style means "not initialized" - m_paths.clear(); m_iconCache.clear(); m_checkStyleCache.clear(); } @@ -253,8 +250,6 @@ } void ImplImageTree::resetPaths() { - m_paths.clear(); - OUString url( "$BRAND_BASE_DIR/share/config/" ); rtl::Bootstrap::expandMacros(url); if ( m_style != "default" ) @@ -267,9 +262,8 @@ } 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( @@ -300,52 +294,45 @@ 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 (std::vector< OUString >::const_reverse_iterator j(paths.rbegin()); + j != paths.rend(); ++j) + { + 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; } } } - for (Paths::iterator i(m_paths.begin()); i != m_paths.end();) { - if (!i->second.is()) { - css::uno::Sequence< css::uno::Any > args(1); - args[0] <<= i->first + ".zip"; - try { - i->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 " << i->first); - i = m_paths.erase(i); - continue; - } + 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 (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 ); - return true; - } + } + 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; } - ++i; } return false; } -- To view, visit https://gerrit.libreoffice.org/3951 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idd13039a76c46bfccad5f54e3357dde952508211 Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: master Gerrit-Owner: Rodolfo Ribeiro Gomes <l...@rodolfo.eng.br> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice