vcldemo: dump and render all icons from images.zip when zoomed in.
Change-Id: I89f37b8a1ed70334a3485bc3ca06d04cfe6d0827
This commit is contained in:
committed by
Markus Mohrhard
parent
f5b3ea832e
commit
3bc5e986b3
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
return aNames;
|
||||
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();
|
||||
}
|
||||
|
||||
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: */
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user