summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-14 11:58:28 +0000
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-11-15 13:51:45 +0100
commit3bc5e986b38f620db9d0119b5d431c10c67eeb74 (patch)
treea25ee1eba13c0f34fdcb05a8908f22096a71042c /vcl
parentf5b3ea832e39da9bd70fa132699acb533f1e474f (diff)
vcldemo: dump and render all icons from images.zip when zoomed in.
Change-Id: I89f37b8a1ed70334a3485bc3ca06d04cfe6d0827
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impimagetree.hxx8
-rw-r--r--vcl/source/gdi/impimagetree.cxx64
-rw-r--r--vcl/workben/vcldemo.cxx19
3 files changed, 51 insertions, 40 deletions
diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index 712ec805e26a..9e4f579acdc3 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -55,6 +55,8 @@ public:
* be too late for the destructors of the bitmaps in m_iconCache)*/
void shutDown();
+ css::uno::Reference< css::container::XNameAccess > getNameAccess();
+
private:
bool doLoadImage(
OUString const & name, OUString const & style,
@@ -62,8 +64,7 @@ private:
typedef std::pair<
OUString,
- com::sun::star::uno::Reference<
- com::sun::star::container::XNameAccess > > Path;
+ css::uno::Reference< css::container::XNameAccess > > Path;
typedef boost::unordered_map<
OUString, bool, OUStringHash > CheckStyleCache;
@@ -78,6 +79,8 @@ private:
bool m_cacheIcons;
IconLinkHash m_linkHash;
+ bool checkPathAccess();
+
void setStyle(OUString const & style );
void resetPaths();
@@ -89,7 +92,6 @@ private:
void loadImageLinks();
void parseLinkFile(boost::shared_ptr< SvStream > stream);
OUString const & getRealImageName(OUString const & name);
- std::vector<OUString> getAllPaths();
};
typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 807f89e569ad..9f2741bfb133 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -248,17 +248,9 @@ bool ImplImageTree::find(
}
}
- if (!m_path.second.is()) {
- try {
- m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
- } catch (const css::uno::RuntimeException &) {
- throw;
- } catch (const css::uno::Exception & e) {
- SAL_INFO("vcl", "ImplImageTree::find exception "
- << e.Message << " for " << m_path.first);
- return false;
- }
- }
+ if (!checkPathAccess())
+ return false;
+
for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin());
j != paths.rend(); ++j)
{
@@ -288,21 +280,9 @@ void ImplImageTree::loadImageLinks()
}
}
- if ( !m_path.second.is() )
- {
- try
- {
- m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
- } catch (const css::uno::RuntimeException &) {
- throw;
- }
- catch (const css::uno::Exception & e)
- {
- SAL_INFO("vcl", "ImplImageTree::find exception "
- << e.Message << " for " << m_path.first);
- return;
- }
- }
+ if (!checkPathAccess())
+ return;
+
if ( m_path.second->hasByName(aLinkFilename) )
{
css::uno::Reference< css::io::XInputStream > s;
@@ -349,21 +329,41 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name)
return it->second;
}
-std::vector<OUString> ImplImageTree::getAllPaths()
+bool ImplImageTree::checkPathAccess()
{
- std::vector<OUString> aNames;
+ if (m_path.second.is())
+ return true;
+
+ try {
+ m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".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);
+ return false;
+ }
+ return m_path.second.is();
+}
- return aNames;
+css::uno::Reference< css::container::XNameAccess > ImplImageTree::getNameAccess()
+{
+ checkPathAccess();
+ return m_path.second;
}
// For vcldemo / debugging
-SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames();
/// Recursively dump all names ...
-std::vector<OUString> ImageTree_getAllImageNames()
+css::uno::Sequence< OUString > ImageTree_getAllImageNames()
{
static ImplImageTreeSingletonRef aImageTree;
- return aImageTree.getAllPaths();
+
+ css::uno::Reference< css::container::XNameAccess > xRef(
+ aImageTree->getNameAccess() );
+
+ return xRef->getElementNames();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index e9ffdc75a5bf..81dc3169c1b1 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -31,7 +31,7 @@
#endif
// debugging hook just for us
-SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames();
using namespace css;
@@ -566,6 +566,7 @@ public:
struct DrawIcons : public RegionRenderer
{
+ std::vector<OUString> maIconNames;
std::vector<BitmapEx> maIcons;
bool bHasLoadedAll;
DrawIcons() : bHasLoadedAll(false)
@@ -596,18 +597,24 @@ public:
"cmd/lc_hyperlinkdialog.png",
};
for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
- maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i])));
+ {
+ maIconNames.push_back(OUString::createFromAscii(pNames[i]));
+ maIcons.push_back(BitmapEx(maIconNames[i]));
+ }
}
- void LoadAllIcons()
+ void LoadAllImages()
{
if (bHasLoadedAll)
return;
bHasLoadedAll = true;
- std::vector<OUString> aAllIcons = ImageTree_getAllImageNames();
- for (size_t i = 0; i < aAllIcons.size(); i++)
+ css::uno::Sequence< OUString > aAllIcons = ImageTree_getAllImageNames();
+ for (sal_Int32 i = 0; i < aAllIcons.getLength() && i < 1024; i++)
+ {
+ maIconNames.push_back(aAllIcons[i]);
maIcons.push_back(BitmapEx(aAllIcons[i]));
+ }
}
void doDrawIcons(OutputDevice &rDev, Rectangle r)
@@ -617,6 +624,7 @@ public:
for (size_t i = 0; i < maIcons.size(); i++)
{
Size aSize(maIcons[i].GetSizePixel());
+// sAL_DEBUG("Draw icon '" << maIconNames[i] << "'");
rDev.DrawBitmapEx(p, maIcons[i]);
p.Move(aSize.Width(), 0);
if (aSize.Height() > nMaxH)
@@ -635,6 +643,7 @@ public:
{
if (rCtx.meStyle == RENDER_EXPANDED)
{
+ LoadAllImages();
doDrawIcons(rDev, r);
}
else