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
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;
79 if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor) && pDevice != nullptr)
80 aScalePercentage = pDevice->GetDPIScalePercentage();
81 else if (mnScalePercentage > 0)
82 aScalePercentage = mnScalePercentage;
83 return aScalePercentage;
84}
85
86namespace
87{
88
89OUString convertLcTo32Path(std::u16string_view rPath)
90{
91 OUString aResult;
92 size_t nSlashPos = rPath.rfind('/');
93 if (nSlashPos != std::u16string_view::npos)
94 {
95 sal_Int32 nCopyFrom = nSlashPos + 1;
96 std::u16string_view sFile = rPath.substr(nCopyFrom);
97 std::u16string_view sDir = rPath.substr(0, nSlashPos);
98 if (!sFile.empty() && o3tl::starts_with(sFile, u"lc_"))
99 {
100 aResult = OUString::Concat(sDir) + "/32/" + sFile.substr(3);
101 }
102 }
103 return aResult;
104}
105
106OUString createPath(std::u16string_view name, sal_Int32 pos, std::u16string_view locale)
107{
108 return OUString::Concat(name.substr(0, pos + 1)) + locale + name.substr(pos);
109}
110
111OUString getIconCacheUrl(std::u16string_view sVariant, ImageRequestParameters const & rParameters)
112{
113 // the macro expansion can be expensive in bulk, so cache that
114 static OUString CACHE_DIR = []()
115 {
116 OUString sDir = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/";
117 rtl::Bootstrap::expandMacros(sDir);
118 return sDir;
119 }();
120 return CACHE_DIR + rParameters.msStyle + "/" + sVariant + "/" + rParameters.msName;
121}
122
123OUString createIconCacheUrl(
124 std::u16string_view sVariant, ImageRequestParameters const & rParameters)
125{
126 OUString sUrl(getIconCacheUrl(sVariant, rParameters));
127 OUString sDir = sUrl.copy(0, sUrl.lastIndexOf('/'));
128 osl::Directory::createPath(sDir);
129 return sUrl;
130}
131
132bool urlExists(OUString const & sUrl)
133{
134 osl::File aFile(sUrl);
135 osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
136 return osl::FileBase::E_None == eRC;
137}
138
139OUString getNameNoExtension(std::u16string_view sName)
140{
141 size_t nDotPosition = sName.rfind('.');
142 return OUString(sName.substr(0, nDotPosition));
143}
144
145std::shared_ptr<SvMemoryStream> wrapStream(uno::Reference<io::XInputStream> const & rInputStream)
146{
147 // This could use SvInputStream instead if that did not have a broken
148 // SeekPos implementation for an XInputStream that is not also XSeekable
149 // (cf. "@@@" at tags/DEV300_m37/svtools/source/misc1/strmadpt.cxx@264807
150 // l. 593):
151 OSL_ASSERT(rInputStream.is());
152 std::shared_ptr<SvMemoryStream> aMemoryStream(std::make_shared<SvMemoryStream>());
153 for (;;)
154 {
155 const sal_Int32 nSize(2048);
156 uno::Sequence<sal_Int8> aData(nSize);
157 sal_Int32 nRead = rInputStream->readBytes(aData, nSize);
158 aMemoryStream->WriteBytes(aData.getConstArray(), nRead);
159 if (nRead < nSize)
160 break;
161 }
162 aMemoryStream->Seek(0);
163 rInputStream->closeInput();
164 return aMemoryStream;
165}
166
167void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString const & rPath, ImageRequestParameters& rParameters)
168{
169 bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
170 sal_Int32 aScalePercentage = rParameters.scalePercentage();
171
172 if (rPath.endsWith(".png"))
173 {
174 vcl::PngImageReader aPNGReader(*xStream);
175 aPNGReader.read(rParameters.mrBitmap);
176 }
177 else if (rPath.endsWith(".svg"))
178 {
179 rParameters.mbWriteImageToCache = true; // We always want to cache a SVG image
180 vcl::bitmap::loadFromSvg(*xStream, rPath, rParameters.mrBitmap, aScalePercentage / 100.0);
181
182 if (bConvertToDarkTheme)
184
185 return;
186 }
187 else
188 {
189 ReadDIBBitmapEx(rParameters.mrBitmap, *xStream);
190 }
191
192 if (bConvertToDarkTheme)
193 {
194 rParameters.mbWriteImageToCache = true; // Cache the dark variant
196 }
197
198 if (aScalePercentage > 100)
199 {
200 rParameters.mbWriteImageToCache = true; // Cache the scaled variant
201 double aScaleFactor(aScalePercentage / 100.0);
202 // when scaling use the full 24bit RGB values
204 rParameters.mrBitmap.Scale(aScaleFactor, aScaleFactor, BmpScaleFlag::Fast);
205 }
206}
207
208} // end anonymous namespace
209
211{
212}
213
215{
216}
217
218std::vector<OUString> ImplImageTree::getPaths(OUString const & name, LanguageTag const & rLanguageTag)
219{
220 std::vector<OUString> sPaths;
221
222 sal_Int32 pos = name.lastIndexOf('/');
223 if (pos != -1)
224 {
225 for (const OUString& rFallback : rLanguageTag.getFallbackStrings(true))
226 {
227 OUString aFallbackName = getNameNoExtension(getRealImageName(createPath(name, pos, rFallback)));
228 sPaths.emplace_back(aFallbackName + ".png");
229 sPaths.emplace_back(aFallbackName + ".svg");
230 }
231 }
232
233 OUString aRealName = getNameNoExtension(getRealImageName(name));
234 sPaths.emplace_back(aRealName + ".png");
235 sPaths.emplace_back(aRealName + ".svg");
236
237 return sPaths;
238}
239
240OUString ImplImageTree::getImageUrl(OUString const & rName, OUString const & rStyle, OUString const & rLang)
241{
242 OUString aStyle(rStyle);
243
244 while (!aStyle.isEmpty())
245 {
246 try
247 {
248 setStyle(aStyle);
249
250 if (checkPathAccess())
251 {
252 IconSet& rIconSet = getCurrentIconSet();
253 const uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
254
255 LanguageTag aLanguageTag(rLang);
256
257 for (const OUString& rPath: getPaths(rName, aLanguageTag))
258 {
259 if (rNameAccess->hasByName(rPath))
260 {
261 return "vnd.sun.star.zip://"
262 + rtl::Uri::encode(rIconSet.maURL, rtl_UriCharClassRegName,
263 rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8)
264 + "/" + rPath;
265 }
266 }
267 }
268 }
269 catch (const uno::Exception &)
270 {
271 TOOLS_INFO_EXCEPTION("vcl", "");
272 }
273
274 aStyle = fallbackStyle(aStyle);
275 }
276 return OUString();
277}
278
279uno::Reference<io::XInputStream> ImplImageTree::getImageXInputStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
280{
281 OUString aStyle(rStyle);
282
283 while (!aStyle.isEmpty())
284 {
285 try
286 {
287 setStyle(aStyle);
288
289 if (checkPathAccess())
290 {
291 IconSet& rIconSet = getCurrentIconSet();
292 const uno::Reference<container::XNameAccess>& rNameAccess = rIconSet.maNameAccess;
293
294 LanguageTag aLanguageTag(rLang);
295
296 for (const OUString& rPath: getPaths(rName, aLanguageTag))
297 {
298 if (rNameAccess->hasByName(rPath))
299 {
300 uno::Reference<io::XInputStream> aStream;
301 bool ok = rNameAccess->getByName(rPath) >>= aStream;
302 assert(ok);
303 (void)ok; // prevent unused warning in release build
304 return aStream;
305 }
306 }
307 }
308 }
309 catch (const uno::Exception &)
310 {
311 TOOLS_INFO_EXCEPTION("vcl", "");
312 }
313
314 aStyle = fallbackStyle(aStyle);
315 }
316 return nullptr;
317}
318
319std::shared_ptr<SvMemoryStream> ImplImageTree::getImageStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
320{
321 uno::Reference<io::XInputStream> xStream = getImageXInputStream(rName, rStyle, rLang);
322 if (xStream)
323 return wrapStream(xStream);
324 return std::shared_ptr<SvMemoryStream>();
325}
326
327OUString ImplImageTree::fallbackStyle(std::u16string_view rsStyle)
328{
329 OUString sResult;
330
331 if (rsStyle == u"colibre" || rsStyle == u"helpimg")
332 sResult = "";
333 else if (rsStyle == u"sifr" || rsStyle == u"breeze_dark")
334 sResult = "breeze";
335 else if (rsStyle == u"sifr_dark" )
336 sResult = "breeze_dark";
337 else
338 sResult = "colibre";
339
340 return sResult;
341}
342
343bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized,
344 const ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
345{
346 OUString aCurrentStyle(rStyle);
347 while (!aCurrentStyle.isEmpty())
348 {
349 try
350 {
351 ImageRequestParameters aParameters(rName, aCurrentStyle, rBitmap, localized, eFlags, nScalePercentage);
352 if (doLoadImage(aParameters))
353 return true;
354 }
355 catch (uno::RuntimeException &)
356 {}
357
358 aCurrentStyle = fallbackStyle(aCurrentStyle);
359 }
360 return false;
361}
362
363namespace
364{
365
366OUString createVariant(ImageRequestParameters& rParameters)
367{
368 bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
369 sal_Int32 aScalePercentage = rParameters.scalePercentage();
370
371 OUString aVariant = OUString::number(aScalePercentage);
372
373 if (bConvertToDarkTheme)
374 aVariant += "-dark";
375
376 return aVariant;
377}
378
379bool loadDiskCachedVersion(std::u16string_view sVariant, ImageRequestParameters& rParameters)
380{
381 OUString sUrl(getIconCacheUrl(sVariant, rParameters));
382 if (!urlExists(sUrl))
383 return false;
384 SvFileStream aFileStream(sUrl, StreamMode::READ);
385 vcl::PngImageReader aPNGReader(aFileStream);
386 aPNGReader.read(rParameters.mrBitmap);
387 return true;
388}
389
390void cacheBitmapToDisk(std::u16string_view sVariant, ImageRequestParameters const & rParameters)
391{
392 OUString sUrl(createIconCacheUrl(sVariant, rParameters));
393 try
394 {
395 SvFileStream aStream(sUrl, StreamMode::WRITE);
396 vcl::PngImageWriter aWriter(aStream);
397 aWriter.write(rParameters.mrBitmap);
398 aStream.Close();
399 }
400 catch (...)
401 {}
402}
403
404} // end anonymous namespace
405
407{
408 setStyle(rParameters.msStyle);
409
410 if (iconCacheLookup(rParameters))
411 return true;
412
413 OUString aVariant = createVariant(rParameters);
414 if (loadDiskCachedVersion(aVariant, rParameters))
415 return true;
416
417 if (!rParameters.mrBitmap.IsEmpty())
418 rParameters.mrBitmap.SetEmpty();
419
421
422 std::vector<OUString> aPaths = getPaths(rParameters.msName, aLanguageTag);
423
424 bool bFound = false;
425
426 try
427 {
428 bFound = findImage(aPaths, rParameters);
429 }
430 catch (uno::RuntimeException&)
431 {
432 throw;
433 }
434 catch (const uno::Exception&)
435 {
436 TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::doLoadImage");
437 }
438
439 if (bFound)
440 {
441 if (rParameters.mbWriteImageToCache)
442 {
443 cacheBitmapToDisk(aVariant, rParameters);
444 }
445 getIconCache(rParameters)[rParameters.msName] = std::make_pair(rParameters.mbLocalized, rParameters.mrBitmap);
446 }
447
448 return bFound;
449}
450
452{
453 maCurrentStyle.clear();
454 maIconSets.clear();
455}
456
457void ImplImageTree::setStyle(OUString const & style)
458{
459 assert(!style.isEmpty());
460 if (style != maCurrentStyle)
461 {
462 maCurrentStyle = style;
463 createStyle();
464 }
465}
466
471static bool isVclDemo()
472{
473 static const bool bVclDemoOverride = std::getenv("LIBO_VCL_DEMO") != nullptr;
474 return bVclDemoOverride;
475}
476
478{
479 if (maIconSets.find(maCurrentStyle) != maIconSets.end())
480 return;
481
482 OUString sThemeUrl;
483
484 if (isVclDemo())
485 {
486 if (maCurrentStyle == "default")
487 sThemeUrl = "file://" SRC_ROOT "/icon-themes/colibre-svg";
488 else
489 sThemeUrl = "file://" SRC_ROOT "/icon-themes/" + maCurrentStyle;
490 }
491 else if (maCurrentStyle != "default")
492 {
494 std::deque<OUString> aPaths;
495 sal_Int32 nIndex = 0;
496 do
497 {
498 aPaths.push_front(paths.getToken(0, ';', nIndex));
499 }
500 while (nIndex >= 0);
501
502 for (const auto& path : aPaths)
503 {
504 INetURLObject aUrl(path);
505 OSL_ASSERT(!aUrl.HasError());
506
507 bool ok = aUrl.Append(Concat2View("images_" + maCurrentStyle), INetURLObject::EncodeMechanism::All);
508 OSL_ASSERT(ok);
509 sThemeUrl = aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE) + ".zip";
510 if (urlExists(sThemeUrl))
511 break;
512 sThemeUrl.clear();
513 }
514
515 if (sThemeUrl.isEmpty())
516 return;
517 }
518 else
519 {
520 sThemeUrl += "images";
521 if (!urlExists(sThemeUrl))
522 return;
523 }
524
525 maIconSets[maCurrentStyle] = IconSet(sThemeUrl);
526
528}
529
532{
534 auto it = rSet.maScaledIconCaches.find(rParameters.mnScalePercentage);
535 if ( it != rSet.maScaledIconCaches.end() )
536 return it->second;
537 rSet.maScaledIconCaches.emplace(rParameters.mnScalePercentage, IconCache());
538 return rSet.maScaledIconCaches[rParameters.mnScalePercentage];
539}
540
542{
543 IconCache& rIconCache = getIconCache(rParameters);
544
545 IconCache::iterator i(rIconCache.find(getRealImageName(rParameters.msName)));
546 if (i != rIconCache.end() && i->second.first == rParameters.mbLocalized)
547 {
548 rParameters.mrBitmap = i->second.second;
549 return true;
550 }
551
552 return false;
553}
554
555bool ImplImageTree::findImage(std::vector<OUString> const & rPaths, ImageRequestParameters& rParameters)
556{
557 if (!checkPathAccess())
558 return false;
559
560 uno::Reference<container::XNameAccess> const & rNameAccess = getCurrentIconSet().maNameAccess;
561
562 for (OUString const & rPath : rPaths)
563 {
564 if (rNameAccess->hasByName(rPath))
565 {
566 uno::Reference<io::XInputStream> aStream;
567 bool ok = rNameAccess->getByName(rPath) >>= aStream;
568 assert(ok);
569 (void)ok; // prevent unused warning in release build
570
571 loadImageFromStream(wrapStream(aStream), rPath, rParameters);
572
573 return true;
574 }
575 }
576 return false;
577}
578
580{
581 static const OUStringLiteral aLinkFilename(u"links.txt");
582
583 if (!checkPathAccess())
584 return;
585
586 const uno::Reference<container::XNameAccess> &rNameAccess = getCurrentIconSet().maNameAccess;
587
588 if (rNameAccess->hasByName(aLinkFilename))
589 {
590 uno::Reference<io::XInputStream> xStream;
591 bool ok = rNameAccess->getByName(aLinkFilename) >>= xStream;
592 assert(ok);
593 (void)ok; // prevent unused warning in release build
594
595 parseLinkFile(wrapStream(xStream));
596 return;
597 }
598}
599
600void ImplImageTree::parseLinkFile(std::shared_ptr<SvStream> const & xStream)
601{
602 OStringBuffer aLine;
603 OUString aLink, aOriginal;
604 int nLineNo = 0;
605 while (xStream->ReadLine(aLine))
606 {
607 ++nLineNo;
608 if (aLine.isEmpty())
609 continue;
610
611 sal_Int32 nIndex = 0;
612 aLink = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
613 aOriginal = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
614
615 // skip comments, or incomplete entries
616 if (aLink.isEmpty() || aLink[0] == '#' || aOriginal.isEmpty())
617 {
618 if (aLink.isEmpty() || aOriginal.isEmpty())
619 SAL_WARN("vcl", "ImplImageTree::parseLinkFile: icon links.txt parse error, incomplete link at line " << nLineNo);
620 continue;
621 }
622
623 getCurrentIconSet().maLinkHash[aLink] = aOriginal;
624
625 OUString aOriginal32 = convertLcTo32Path(aOriginal);
626 OUString aLink32 = convertLcTo32Path(aLink);
627
628 if (!aOriginal32.isEmpty() && !aLink32.isEmpty())
629 getCurrentIconSet().maLinkHash[aLink32] = aOriginal32;
630 }
631}
632
633OUString const & ImplImageTree::getRealImageName(OUString const & rIconName)
634{
635 IconLinkHash & rLinkHash = maIconSets[maCurrentStyle].maLinkHash;
636
637 OUString sNameWithNoExtension = getNameNoExtension(rIconName);
638
639 // PNG is priority
640 auto it = rLinkHash.find(sNameWithNoExtension + ".png");
641 if (it != rLinkHash.end())
642 return it->second;
643
644 // also check SVG name
645 it = rLinkHash.find(sNameWithNoExtension + ".svg");
646 if (it != rLinkHash.end())
647 return it->second;
648
649 // neither was found so just return the original name
650 return rIconName;
651}
652
653namespace {
654
655class FolderFileAccess : public ::cppu::WeakImplHelper<css::container::XNameAccess>
656{
657public:
658 uno::Reference< uno::XComponentContext > mxContext;
659 OUString maURL;
660 FolderFileAccess(uno::Reference< uno::XComponentContext > context, OUString url)
661 : mxContext(std::move(context)), maURL(std::move(url)) {}
662 // XElementAccess
663 virtual css::uno::Type SAL_CALL getElementType() override { return cppu::UnoType<io::XInputStream>::get(); }
664 virtual sal_Bool SAL_CALL hasElements() override { return true; }
665 // XNameAccess
666 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override
667 {
668 uno::Reference< io::XInputStream > xInputStream = ucb::SimpleFileAccess::create(mxContext)->openFileRead( maURL + "/" + aName );
669 return css::uno::Any(xInputStream);
670 }
671 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
672 {
673 return {};
674 }
675 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
676 {
677 osl::File aBaseFile(maURL + "/" + aName);
678 return osl::File::E_None == aBaseFile.open(osl_File_OpenFlag_Read);
679 }
680};
681
682}
683
685{
686 IconSet& rIconSet = getCurrentIconSet();
687 uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
688 if (rNameAccess.is())
689 return true;
690
691 try
692 {
693 if (isVclDemo())
694 rNameAccess = new FolderFileAccess(comphelper::getProcessComponentContext(), rIconSet.maURL);
695 else
696 rNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), rIconSet.maURL);
697 }
698 catch (const uno::RuntimeException &)
699 {
700 throw;
701 }
702 catch (const uno::Exception &)
703 {
704 TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::zip file location " << rIconSet.maURL);
705 return false;
706 }
707 return rNameAccess.is();
708}
709
710uno::Reference<container::XNameAccess> const & ImplImageTree::getNameAccess()
711{
712 (void)checkPathAccess();
714}
715
716/* 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:1166
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:291
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: BitmapEx.cxx:369
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.
css::uno::Reference< css::io::XInputStream > getImageXInputStream(OUString const &rName, OUString const &rStyle, OUString const &rLang)
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
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
sal_Int32 GetDPIScalePercentage() const
Definition: outdev.hxx:401
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:1676
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