[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Fri May 4 07:55:11 UTC 2018
include/vcl/ImageTree.hxx | 4 +++
vcl/inc/implimagetree.hxx | 3 ++
vcl/source/image/ImageTree.cxx | 5 ++++
vcl/source/image/ImplImageTree.cxx | 40 +++++++++++++++++++++++++++++++++++++
vcl/unx/gtk3/gtk3gtkinst.cxx | 32 +++++++++++++++--------------
5 files changed, 69 insertions(+), 15 deletions(-)
New commits:
commit 92d5cd31d93ca30f97fab09304a59aa41268431e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu May 3 17:47:43 2018 +0100
give icon data directly to gtk, skipping internal loaders
Change-Id: I4168b78d68a99e56105c49e1a1b6e1aa457609af
Reviewed-on: https://gerrit.libreoffice.org/53812
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx
index a40905d863ef..66a82b000ebc 100644
--- a/include/vcl/ImageTree.hxx
+++ b/include/vcl/ImageTree.hxx
@@ -22,6 +22,7 @@
#include <memory>
#include <sal/config.h>
+#include <tools/stream.hxx>
#include <vcl/dllapi.h>
#include <vcl/bitmapex.hxx>
@@ -55,6 +56,9 @@ public:
VCL_DLLPUBLIC OUString getImageUrl(
OUString const & name, OUString const & style, OUString const & lang);
+ VCL_DLLPUBLIC std::shared_ptr<SvMemoryStream> getImageStream(
+ OUString const & rName, OUString const & rStyle, OUString const & rLang);
+
VCL_DLLPUBLIC bool loadImage(
OUString const & name, OUString const & style,
BitmapEx & bitmap, bool localized,
diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx
index 92052e3c57e4..e35c9ac6ccfb 100644
--- a/vcl/inc/implimagetree.hxx
+++ b/vcl/inc/implimagetree.hxx
@@ -69,6 +69,9 @@ public:
OUString getImageUrl(
OUString const & name, OUString const & style, OUString const & lang);
+ std::shared_ptr<SvMemoryStream> getImageStream(
+ OUString const & rName, OUString const & rStyle, OUString const & rLang);
+
bool loadImage(
OUString const & name, OUString const & style,
BitmapEx & bitmap, bool localized,
diff --git a/vcl/source/image/ImageTree.cxx b/vcl/source/image/ImageTree.cxx
index 941812925190..2e20183b0da5 100644
--- a/vcl/source/image/ImageTree.cxx
+++ b/vcl/source/image/ImageTree.cxx
@@ -30,6 +30,11 @@ OUString ImageTree::getImageUrl(OUString const & rName, OUString const & rStyle,
return mpImplImageTree->getImageUrl(rName, rStyle, rLang);
}
+std::shared_ptr<SvMemoryStream> ImageTree::getImageStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
+{
+ return mpImplImageTree->getImageStream(rName, rStyle, rLang);
+}
+
bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle,
BitmapEx & rBitmap, bool bLocalized,
const ImageLoadFlags eFlags)
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 296800681fa7..ba1f22155d27 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -256,6 +256,46 @@ OUString ImplImageTree::getImageUrl(OUString const & rName, OUString const & rSt
return OUString();
}
+std::shared_ptr<SvMemoryStream> ImplImageTree::getImageStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
+{
+ OUString aStyle(rStyle);
+
+ while (!aStyle.isEmpty())
+ {
+ try
+ {
+ setStyle(aStyle);
+
+ if (checkPathAccess())
+ {
+ IconSet& rIconSet = getCurrentIconSet();
+ const css::uno::Reference<css::container::XNameAccess>& rNameAccess = rIconSet.maNameAccess;
+
+ LanguageTag aLanguageTag(rLang);
+
+ for (OUString& rPath: getPaths(rName, aLanguageTag))
+ {
+ if (rNameAccess->hasByName(rPath))
+ {
+ css::uno::Reference<css::io::XInputStream> aStream;
+ bool ok = rNameAccess->getByName(rPath) >>= aStream;
+ assert(ok);
+ (void)ok; // prevent unused warning in release build
+ return wrapStream(aStream);
+ }
+ }
+ }
+ }
+ catch (const css::uno::Exception & e)
+ {
+ SAL_INFO("vcl", e);
+ }
+
+ aStyle = fallbackStyle(aStyle);
+ }
+ return std::shared_ptr<SvMemoryStream>();
+}
+
OUString ImplImageTree::fallbackStyle(const OUString& rsStyle)
{
OUString sResult;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index ed78e141b124..d88b8a5b9e95 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -32,8 +32,8 @@
#include <tools/fract.hxx>
#include <tools/stream.hxx>
#include <unotools/resmgr.hxx>
+#include <vcl/ImageTree.hxx>
#include <vcl/mnemonic.hxx>
-#include <vcl/pngwrite.hxx>
#include <vcl/weld.hxx>
using namespace com::sun::star;
@@ -4226,6 +4226,8 @@ private:
ResHookProc m_pStringReplace;
OUString m_sHelpRoot;
OString m_aUtf8HelpRoot;
+ OUString m_aIconTheme;
+ OUString m_aUILang;
GtkBuilder* m_pBuilder;
GSList* m_pObjectList;
GtkWidget* m_pParentWidget;
@@ -4251,20 +4253,18 @@ private:
if (icon_name)
{
OUString aIconName(icon_name, strlen(icon_name), RTL_TEXTENCODING_UTF8);
-
- SvMemoryStream aMemStm;
- BitmapEx aBitmap(aIconName);
- vcl::PNGWriter aWriter(aBitmap);
- aWriter.Write(aMemStm);
-
- GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new();
- gdk_pixbuf_loader_write(pixbuf_loader, static_cast<const guchar*>(aMemStm.GetData()),
- aMemStm.Seek(STREAM_SEEK_TO_END), nullptr);
- gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
- GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
-
- gtk_image_set_from_pixbuf(pImage, pixbuf);
- g_object_unref(pixbuf_loader);
+ auto xMemStm = ImageTree::get().getImageStream(aIconName, m_aIconTheme, m_aUILang);
+ if (xMemStm)
+ {
+ GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new();
+ gdk_pixbuf_loader_write(pixbuf_loader, static_cast<const guchar*>(xMemStm->GetData()),
+ xMemStm->Seek(STREAM_SEEK_TO_END), nullptr);
+ gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
+ GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
+
+ gtk_image_set_from_pixbuf(pImage, pixbuf);
+ g_object_unref(pixbuf_loader);
+ }
}
}
//set helpids
@@ -4343,6 +4343,8 @@ public:
m_sHelpRoot = m_sHelpRoot.copy(0, nIdx);
m_sHelpRoot = m_sHelpRoot + OUString('/');
m_aUtf8HelpRoot = OUStringToOString(m_sHelpRoot, RTL_TEXTENCODING_UTF8);
+ m_aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+ m_aUILang = Application::GetSettings().GetUILanguageTag().getBcp47();
m_pObjectList = gtk_builder_get_objects(m_pBuilder);
g_slist_foreach(m_pObjectList, postprocess, this);
More information about the Libreoffice-commits
mailing list