give icon data directly to gtk, skipping internal loaders
Change-Id: I4168b78d68a99e56105c49e1a1b6e1aa457609af Reviewed-on: https://gerrit.libreoffice.org/53812 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
parent
a7dde8db81
commit
92d5cd31d9
5 changed files with 68 additions and 14 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue