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