LibreOffice Module vcl (master) 1
ImplImageTree.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_folders.h>
21
22#include <sal/config.h>
23#include <sal/log.hxx>
24
25#include <deque>
26#include <string_view>
27
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/io/XInputStream.hpp>
30#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
31#include <com/sun/star/ucb/SimpleFileAccess.hpp>
32#include <com/sun/star/uno/Exception.hpp>
33#include <com/sun/star/uno/RuntimeException.hpp>
34#include <com/sun/star/uno/Sequence.hxx>
37#include <osl/file.hxx>
38#include <osl/diagnose.h>
39#include <osl/process.h>
40#include <rtl/bootstrap.hxx>
41#include <rtl/uri.hxx>
42#include <rtl/strbuf.hxx>
43
44#include <tools/diagnose_ex.h>
45#include <tools/stream.hxx>
46#include <tools/urlobj.hxx>
47#include <implimagetree.hxx>
48
49#include <utility>
50#include <vcl/bitmapex.hxx>
51#include <vcl/dibtools.hxx>
52#include <vcl/settings.hxx>
53#include <vcl/svapp.hxx>
54#include <vcl/BitmapTools.hxx>
55#include <IconThemeScanner.hxx>
57#include <vcl/outdev.hxx>
59#include <o3tl/string_view.hxx>
61
62using namespace css;
63
65{
66 static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
67
68 bool bConvertToDarkTheme = false;
70 bConvertToDarkTheme = bIconsForDarkTheme;
71
72 return bConvertToDarkTheme;
73}
74
76{
77 sal_Int32 aScalePercentage = 100;
80 else if (mnScalePercentage > 0)
81 aScalePercentage = mnScalePercentage;
82 return aScalePercentage;
83}
84
85namespace
86{
87
88OUString convertLcTo32Path(std::u16string_view rPath)
89{
90 OUString aResult;
91 size_t nSlashPos = rPath.rfind('/');
92 if (nSlashPos != std::u16string_view::npos)
93 {
94 sal_Int32 nCopyFrom = nSlashPos + 1;
95 std::u16string_view sFile = rPath.substr(nCopyFrom);
96 std::u16string_view sDir = rPath.substr(0, nSlashPos);
97 if (!sFile.empty() && o3tl::starts_with(sFile, u"lc_"))
98 {
99 aResult = OUString::Concat(sDir) + "/32/" + sFile.substr(3);
100 }
101 }
102 return aResult;
103}
104
105OUString createPath(std::u16string_view name, sal_Int32 pos, std::u16string_view locale)
106{
107 return OUString::Concat(name.substr(0, pos + 1)) + locale + name.substr(pos);
108}
109
110OUString getIconCacheUrl(std::u16string_view sVariant, ImageRequestParameters const & rParameters)
111{
112 // the macro expansion can be expensive in bulk, so cache that
113 static OUString CACHE_DIR = []()
114 {
115 OUString sDir = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/";
116 rtl::Bootstrap::expandMacros(sDir);
117 return sDir;
118 }();
119 return CACHE_DIR + rParameters.msStyle + "/" + sVariant + "/" + rParameters.msName;
120}
121
122OUString createIconCacheUrl(
123 std::u16string_view sVariant, ImageRequestParameters const & rParameters)
124{
125 OUString sUrl(getIconCacheUrl(sVariant, rParameters));
126 OUString sDir = sUrl.copy(0, sUrl.lastIndexOf('/'));
127 osl::Directory::createPath(sDir);
128 return sUrl;
129}
130
131bool urlExists(OUString const & sUrl)
132{
133 osl::File aFile(sUrl);
134 osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
135 return osl::FileBase::E_None == eRC;
136}
137
138OUString getNameNoExtension(std::u16string_view sName)
139{
140 size_t nDotPosition = sName.rfind('.');
141 return OUString(sName.substr(0, nDotPosition));
142}
143
144std::shared_ptr<SvMemoryStream> wrapStream(uno::Reference<io::XInputStream> const & rInputStream)
145{
146 // This could use SvInputStream instead if that did not have a broken
147 // SeekPos implementation for an XInputStream that is not also XSeekable
148 // (cf. "@@@" at tags/DEV300_m37/svtools/source/misc1/strmadpt.cxx@264807
149 // l. 593):
150 OSL_ASSERT(rInputStream.is());
151 std::shared_ptr<SvMemoryStream> aMemoryStream(std::make_shared<SvMemoryStream>());
152 for (;;)
153 {
154 const sal_Int32 nSize(2048);
155 uno::Sequence<sal_Int8> aData(nSize);
156 sal_Int32 nRead = rInputStream->readBytes(aData, nSize);
157 aMemoryStream->WriteBytes(aData.getConstArray(), nRead);
158 if (nRead < nSize)
159 break;
160 }
161 aMemoryStream->Seek(0);
162 rInputStream->closeInput();
163 return aMemoryStream;
164}
165
166void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString const & rPath, ImageRequestParameters& rParameters)
167{
168 bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
169 sal_Int32 aScalePercentage = rParameters.scalePercentage();
170
171 if (rPath.endsWith(".png"))
172 {
173 vcl::PngImageReader aPNGReader(*xStream);
174 aPNGReader.read(rParameters.mrBitmap);
175 }
176 else if (rPath.endsWith(".svg"))
177 {
178 rParameters.mbWriteImageToCache = true; // We always want to cache a SVG image
179 vcl::bitmap::loadFromSvg(*xStream, rPath, rParameters.mrBitmap, aScalePercentage / 100.0);
180
181 if (bConvertToDarkTheme)
183
184 return;
185 }
186 else
187 {
188 ReadDIBBitmapEx(rParameters.mrBitmap, *xStream);
189 }
190
191 if (bConvertToDarkTheme)
192 {
193 rParameters.mbWriteImageToCache = true; // Cache the dark variant
195 }
196
197 if (aScalePercentage > 100)
198 {
199 rParameters.mbWriteImageToCache = true; // Cache the scaled variant
200 double aScaleFactor(aScalePercentage / 100.0);
201 // when scaling use the full 24bit RGB values
203 rParameters.mrBitmap.Scale(aScaleFactor, aScaleFactor, BmpScaleFlag::Fast);
204 }
205}
206
207} // end anonymous namespace
208
210{
211}
212
214{
215}
216
217std::vector<OUString> ImplImageTree::getPaths(OUString const & name, LanguageTag const & rLanguageTag)
218{
219 std::vector<OUString> sPaths;
220
221 sal_Int32 pos = name.lastIndexOf('/');
222 if (pos != -1)
223 {
224 for (const OUString& rFallback : rLanguageTag.getFallbackStrings(true))
225 {
226 OUString aFallbackName = getNameNoExtension(getRealImageName(createPath(name, pos, rFallback)));
227 sPaths.emplace_back(aFallbackName + ".png");
228 sPaths.emplace_back(aFallbackName + ".svg");
229 }
230 }
231
232 OUString aRealName = getNameNoExtension(getRealImageName(name));
233 sPaths.emplace_back(aRealName + ".png");
234 sPaths.emplace_back(aRealName + ".svg");
235
236 return sPaths;
237}
238
239OUString ImplImageTree::getImageUrl(OUString const & rName, OUString const & rStyle, OUString const & rLang)
240{
241 OUString aStyle(rStyle);
242
243 while (!aStyle.isEmpty())
244 {
245 try
246 {
247 setStyle(aStyle);
248
249 if (checkPathAccess())
250 {
251 IconSet& rIconSet = getCurrentIconSet();
252 const uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
253
254 LanguageTag aLanguageTag(rLang);
255
256 for (const OUString& rPath: getPaths(rName, aLanguageTag))
257 {
258 if (rNameAccess->hasByName(rPath))
259 {
260 return "vnd.sun.star.zip://"
261 + rtl::Uri::encode(rIconSet.maURL, rtl_UriCharClassRegName,
262 rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8)
263 + "/" + rPath;
264 }
265 }
266 }
267 }
268 catch (const uno::Exception &)
269 {
270 TOOLS_INFO_EXCEPTION("vcl", "");
271 }
272
273 aStyle = fallbackStyle(aStyle);
274 }
275 return OUString();
276}
277
278std::shared_ptr<SvMemoryStream> ImplImageTree::getImageStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
279{
280 OUString aStyle(rStyle);
281
282 while (!aStyle.isEmpty())
283 {
284 try
285 {
286 setStyle(aStyle);
287
288 if (checkPathAccess())
289 {
290 IconSet& rIconSet = getCurrentIconSet();
291 const uno::Reference<container::XNameAccess>& rNameAccess = rIconSet.maNameAccess;
292
293 LanguageTag aLanguageTag(rLang);
294
295 for (const OUString& rPath: getPaths(rName, aLanguageTag))
296 {
297 if (rNameAccess->hasByName(rPath))
298 {
299 uno::Reference<io::XInputStream> aStream;
300 bool ok = rNameAccess->getByName(rPath) >>= aStream;
301 assert(ok);
302 (void)ok; // prevent unused warning in release build
303 return wrapStream(aStream);
304 }
305 }
306 }
307 }
308 catch (const uno::Exception &)
309 {
310 TOOLS_INFO_EXCEPTION("vcl", "");
311 }
312
313 aStyle = fallbackStyle(aStyle);
314 }
315 return std::shared_ptr<SvMemoryStream>();
316}
317
318OUString ImplImageTree::fallbackStyle(std::u16string_view rsStyle)
319{
320 OUString sResult;
321
322 if (rsStyle == u"colibre" || rsStyle == u"helpimg")
323 sResult = "";
324 else if (rsStyle == u"sifr" || rsStyle == u"breeze_dark")
325 sResult = "breeze";
326 else if (rsStyle == u"sifr_dark" )
327 sResult = "breeze_dark";
328 else
329 sResult = "colibre";
330
331 return sResult;
332}
333
334bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized,
335 const ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
336{
337 OUString aCurrentStyle(rStyle);
338 while (!aCurrentStyle.isEmpty())
339 {
340 try
341 {
342 ImageRequestParameters aParameters(rName, aCurrentStyle, rBitmap, localized, eFlags, nScalePercentage);
343 if (doLoadImage(aParameters))
344 return true;
345 }
346 catch (uno::RuntimeException &)
347 {}
348
349 aCurrentStyle = fallbackStyle(aCurrentStyle);
350 }
351 return false;
352}
353
354namespace
355{
356
357OUString createVariant(ImageRequestParameters& rParameters)
358{
359 bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
360 sal_Int32 aScalePercentage = rParameters.scalePercentage();
361
362 OUString aVariant = OUString::number(aScalePercentage);
363
364 if (bConvertToDarkTheme)
365 aVariant += "-dark";
366
367 return aVariant;
368}
369
370bool loadDiskCachedVersion(std::u16string_view sVariant, ImageRequestParameters& rParameters)
371{
372 OUString sUrl(getIconCacheUrl(sVariant, rParameters));
373 if (!urlExists(sUrl))
374 return false;
375 SvFileStream aFileStream(sUrl, StreamMode::READ);
376 vcl::PngImageReader aPNGReader(aFileStream);
377 aPNGReader.read(rParameters.mrBitmap);
378 return true;
379}
380
381void cacheBitmapToDisk(std::u16string_view sVariant, ImageRequestParameters const & rParameters)
382{
383 OUString sUrl(createIconCacheUrl(sVariant, rParameters));
384 try
385 {
386 SvFileStream aStream(sUrl, StreamMode::WRITE);
387 vcl::PngImageWriter aWriter(aStream);
388 aWriter.write(rParameters.mrBitmap);
389 aStream.Close();
390 }
391 catch (...)
392 {}
393}
394
395} // end anonymous namespace
396
398{
399 setStyle(rParameters.msStyle);
400
401 if (iconCacheLookup(rParameters))
402 return true;
403
404 OUString aVariant = createVariant(rParameters);
405 if (loadDiskCachedVersion(aVariant, rParameters))
406 return true;
407
408 if (!rParameters.mrBitmap.IsEmpty())
409 rParameters.mrBitmap.SetEmpty();
410
412
413 std::vector<OUString> aPaths = getPaths(rParameters.msName, aLanguageTag);
414
415 bool bFound = false;
416
417 try
418 {
419 bFound = findImage(aPaths, rParameters);
420 }
421 catch (uno::RuntimeException&)
422 {
423 throw;
424 }
425 catch (const uno::Exception&)
426 {
427 TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::doLoadImage");
428 }
429
430 if (bFound)
431 {
432 if (rParameters.mbWriteImageToCache)
433 {
434 cacheBitmapToDisk(aVariant, rParameters);
435 }
436 getIconCache(rParameters)[rParameters.msName] = std::make_pair(rParameters.mbLocalized, rParameters.mrBitmap);
437 }
438
439 return bFound;
440}
441
443{
444 maCurrentStyle.clear();
445 maIconSets.clear();
446}
447
448void ImplImageTree::setStyle(OUString const & style)
449{
450 assert(!style.isEmpty());
451 if (style != maCurrentStyle)
452 {
453 maCurrentStyle = style;
454 createStyle();
455 }
456}
457
462static bool isVclDemo()
463{
464 static const bool bVclDemoOverride = std::getenv("LIBO_VCL_DEMO") != nullptr;
465 return bVclDemoOverride;
466}
467
469{
470 if (maIconSets.find(maCurrentStyle) != maIconSets.end())
471 return;
472
473 OUString sThemeUrl;
474
475 if (isVclDemo())
476 {
477 if (maCurrentStyle == "default")
478 sThemeUrl = "file://" SRC_ROOT "/icon-themes/colibre-svg";
479 else
480 sThemeUrl = "file://" SRC_ROOT "/icon-themes/" + maCurrentStyle;
481 }
482 else if (maCurrentStyle != "default")
483 {
485 std::deque<OUString> aPaths;
486 sal_Int32 nIndex = 0;
487 do
488 {
489 aPaths.push_front(paths.getToken(0, ';', nIndex));
490 }
491 while (nIndex >= 0);
492
493 for (const auto& path : aPaths)
494 {
495 INetURLObject aUrl(path);
496 OSL_ASSERT(!aUrl.HasError());
497
498 bool ok = aUrl.Append(OUStringConcatenation("images_" + maCurrentStyle), INetURLObject::EncodeMechanism::All);
499 OSL_ASSERT(ok);
500 sThemeUrl = aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE) + ".zip";
501 if (urlExists(sThemeUrl))
502 break;
503 sThemeUrl.clear();
504 }
505
506 if (sThemeUrl.isEmpty())
507 return;
508 }
509 else
510 {
511 sThemeUrl += "images";
512 if (!urlExists(sThemeUrl))
513 return;
514 }
515
516 maIconSets[maCurrentStyle] = IconSet(sThemeUrl);
517
519}
520
523{
525 auto it = rSet.maScaledIconCaches.find(rParameters.mnScalePercentage);
526 if ( it != rSet.maScaledIconCaches.end() )
527 return it->second;
528 rSet.maScaledIconCaches.emplace(rParameters.mnScalePercentage, IconCache());
529 return rSet.maScaledIconCaches[rParameters.mnScalePercentage];
530}
531
533{
534 IconCache& rIconCache = getIconCache(rParameters);
535
536 IconCache::iterator i(rIconCache.find(getRealImageName(rParameters.msName)));
537 if (i != rIconCache.end() && i->second.first == rParameters.mbLocalized)
538 {
539 rParameters.mrBitmap = i->second.second;
540 return true;
541 }
542
543 return false;
544}
545
546bool ImplImageTree::findImage(std::vector<OUString> const & rPaths, ImageRequestParameters& rParameters)
547{
548 if (!checkPathAccess())
549 return false;
550
551 uno::Reference<container::XNameAccess> const & rNameAccess = getCurrentIconSet().maNameAccess;
552
553 for (OUString const & rPath : rPaths)
554 {
555 if (rNameAccess->hasByName(rPath))
556 {
557 uno::Reference<io::XInputStream> aStream;
558 bool ok = rNameAccess->getByName(rPath) >>= aStream;
559 assert(ok);
560 (void)ok; // prevent unused warning in release build
561
562 loadImageFromStream(wrapStream(aStream), rPath, rParameters);
563
564 return true;
565 }
566 }
567 return false;
568}
569
571{
572 static const OUStringLiteral aLinkFilename(u"links.txt");
573
574 if (!checkPathAccess())
575 return;
576
577 const uno::Reference<container::XNameAccess> &rNameAccess = getCurrentIconSet().maNameAccess;
578
579 if (rNameAccess->hasByName(aLinkFilename))
580 {
581 uno::Reference<io::XInputStream> xStream;
582 bool ok = rNameAccess->getByName(aLinkFilename) >>= xStream;
583 assert(ok);
584 (void)ok; // prevent unused warning in release build
585
586 parseLinkFile(wrapStream(xStream));
587 return;
588 }
589}
590
591void ImplImageTree::parseLinkFile(std::shared_ptr<SvStream> const & xStream)
592{
593 OStringBuffer aLine;
594 OUString aLink, aOriginal;
595 int nLineNo = 0;
596 while (xStream->ReadLine(aLine))
597 {
598 ++nLineNo;
599 if (aLine.isEmpty())
600 continue;
601
602 sal_Int32 nIndex = 0;
603 aLink = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
604 aOriginal = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
605
606 // skip comments, or incomplete entries
607 if (aLink.isEmpty() || aLink[0] == '#' || aOriginal.isEmpty())
608 {
609 if (aLink.isEmpty() || aOriginal.isEmpty())
610 SAL_WARN("vcl", "ImplImageTree::parseLinkFile: icon links.txt parse error, incomplete link at line " << nLineNo);
611 continue;
612 }
613
614 getCurrentIconSet().maLinkHash[aLink] = aOriginal;
615
616 OUString aOriginal32 = convertLcTo32Path(aOriginal);
617 OUString aLink32 = convertLcTo32Path(aLink);
618
619 if (!aOriginal32.isEmpty() && !aLink32.isEmpty())
620 getCurrentIconSet().maLinkHash[aLink32] = aOriginal32;
621 }
622}
623
624OUString const & ImplImageTree::getRealImageName(OUString const & rIconName)
625{
626 IconLinkHash & rLinkHash = maIconSets[maCurrentStyle].maLinkHash;
627
628 OUString sNameWithNoExtension = getNameNoExtension(rIconName);
629
630 // PNG is priority
631 auto it = rLinkHash.find(sNameWithNoExtension + ".png");
632 if (it != rLinkHash.end())
633 return it->second;
634
635 // also check SVG name
636 it = rLinkHash.find(sNameWithNoExtension + ".svg");
637 if (it != rLinkHash.end())
638 return it->second;
639
640 // neither was found so just return the original name
641 return rIconName;
642}
643
644namespace {
645
646class FolderFileAccess : public ::cppu::WeakImplHelper<css::container::XNameAccess>
647{
648public:
649 uno::Reference< uno::XComponentContext > mxContext;
650 OUString maURL;
651 FolderFileAccess(uno::Reference< uno::XComponentContext > context, OUString url)
652 : mxContext(std::move(context)), maURL(std::move(url)) {}
653 // XElementAccess
654 virtual css::uno::Type SAL_CALL getElementType() override { return cppu::UnoType<io::XInputStream>::get(); }
655 virtual sal_Bool SAL_CALL hasElements() override { return true; }
656 // XNameAccess
657 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override
658 {
659 uno::Reference< io::XInputStream > xInputStream = ucb::SimpleFileAccess::create(mxContext)->openFileRead( maURL + "/" + aName );
660 return css::uno::Any(xInputStream);
661 }
662 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
663 {
664 return {};
665 }
666 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
667 {
668 osl::File aBaseFile(maURL + "/" + aName);
669 return osl::File::E_None == aBaseFile.open(osl_File_OpenFlag_Read);
670 }
671};
672
673}
674
676{
677 IconSet& rIconSet = getCurrentIconSet();
678 uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
679 if (rNameAccess.is())
680 return true;
681
682 try
683 {
684 if (isVclDemo())
685 rNameAccess = new FolderFileAccess(comphelper::getProcessComponentContext(), rIconSet.maURL);
686 else
687 rNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), rIconSet.maURL);
688 }
689 catch (const uno::RuntimeException &)
690 {
691 throw;
692 }
693 catch (const uno::Exception &)
694 {
695 TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::zip file location " << rIconSet.maURL);
696 return false;
697 }
698 return rNameAccess.is();
699}
700
701uno::Reference<container::XNameAccess> const & ImplImageTree::getNameAccess()
702{
703 (void)checkPathAccess();
705}
706
707/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ImageLoadFlags
Definition: ImageTree.hxx:32
static bool isVclDemo()
The vcldemo app doesn't set up all the config stuff that the main app does, so we need another way of...
Reference< XInputStream > xStream
const LanguageTag & GetUILanguageTag() const
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1165
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:761
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: BitmapEx.cxx:296
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: BitmapEx.cxx:374
bool IsEmpty() const
Definition: BitmapEx.cxx:177
void SetEmpty()
Definition: BitmapEx.cxx:182
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool HasError() const
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
std::unordered_map< OUString, OUString > IconLinkHash
std::shared_ptr< SvMemoryStream > getImageStream(OUString const &rName, OUString const &rStyle, OUString const &rLang)
bool iconCacheLookup(ImageRequestParameters &rParameters)
OUString getImageUrl(OUString const &name, OUString const &style, OUString const &lang)
bool doLoadImage(ImageRequestParameters &rParameters)
OUString maCurrentStyle
Style used for the current operations; switches switch several times during fallback search.
void shutdown()
a crude form of life cycle control (called from DeInitVCL; otherwise, if the ImplImageTree singleton ...
OUString const & getRealImageName(OUString const &rName)
Return name of a real .png according to links.txt.
std::vector< OUString > getPaths(OUString const &name, LanguageTag const &rLanguageTag)
std::unordered_map< OUString, IconSet > maIconSets
Remember all the (used) icon styles and individual icons in them.
IconSet & getCurrentIconSet()
css::uno::Reference< css::container::XNameAccess > const & getNameAccess()
IconCache & getIconCache(const ImageRequestParameters &rParameters)
Find an icon cache for the right scale factor.
static OUString fallbackStyle(std::u16string_view rStyle)
Return name of the fallback style for the provided one.
std::unordered_map< OUString, std::pair< bool, BitmapEx > > IconCache
bool loadImage(OUString const &name, OUString const &style, BitmapEx &bitmap, bool localized, const ImageLoadFlags eFlags, sal_Int32 nScalePercentage=-1)
void setStyle(OUString const &rStyle)
bool findImage(std::vector< OUString > const &rPaths, ImageRequestParameters &rParameters)
void parseLinkFile(std::shared_ptr< SvStream > const &aStream)
bool checkPathAccess()
::std::vector< OUString > getFallbackStrings(bool bIncludeFullBcp47) const
sal_Int32 GetDPIScalePercentage() const
Definition: outdev.hxx:402
css::uno::Type const & get()
static OUString GetStandardIconThemePath()
This method will return the standard path where icon themes are located.
#define SAL_CONFIGFILE(name)
#define TOOLS_INFO_EXCEPTION(area, stream)
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1718
Reference< XInputStream > rInputStream
uno::Reference< uno::XComponentContext > mxContext
float u
const char * name
sal_Int32 nIndex
#define SAL_WARN(area, stream)
const char * sName
constexpr OUStringLiteral aData
Reference< XComponentContext > getProcessComponentContext()
int i
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
void loadFromSvg(SvStream &rStream, const OUString &sPath, BitmapEx &rBitmapEx, double fScalingFactor)
Definition: BitmapTools.cxx:72
const URL maURL
static SfxItemSet & rSet
ImageLoadFlags meFlags
css::uno::Reference< css::container::XNameAccess > maNameAccess
unsigned char sal_Bool
size_t pos