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 <vcl/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  return aMemoryStream;
154 }
155 
156 void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString const & rPath, ImageRequestParameters& rParameters)
157 {
158  bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
159  sal_Int32 aScalePercentage = rParameters.scalePercentage();
160 
161  if (rPath.endsWith(".png"))
162  {
163  vcl::PngImageReader aPNGReader(*xStream);
164  aPNGReader.read(rParameters.mrBitmap);
165  }
166  else if (rPath.endsWith(".svg"))
167  {
168  rParameters.mbWriteImageToCache = true; // We always want to cache a SVG image
169  vcl::bitmap::loadFromSvg(*xStream, rPath, rParameters.mrBitmap, aScalePercentage / 100.0);
170 
171  if (bConvertToDarkTheme)
173 
174  return;
175  }
176  else
177  {
178  ReadDIBBitmapEx(rParameters.mrBitmap, *xStream);
179  }
180 
181  if (bConvertToDarkTheme)
182  {
183  rParameters.mbWriteImageToCache = true; // Cache the dark variant
185  }
186 
187  if (aScalePercentage > 100)
188  {
189  rParameters.mbWriteImageToCache = true; // Cache the scaled variant
190  double aScaleFactor(aScalePercentage / 100.0);
191  // when scaling use the full 24bit RGB values
193  rParameters.mrBitmap.Scale(aScaleFactor, aScaleFactor, BmpScaleFlag::Fast);
194  }
195 }
196 
197 } // end anonymous namespace
198 
200 {
201 }
202 
204 {
205 }
206 
207 std::vector<OUString> ImplImageTree::getPaths(OUString const & name, LanguageTag const & rLanguageTag)
208 {
209  std::vector<OUString> sPaths;
210 
211  sal_Int32 pos = name.lastIndexOf('/');
212  if (pos != -1)
213  {
214  for (const OUString& rFallback : rLanguageTag.getFallbackStrings(true))
215  {
216  OUString aFallbackName = getNameNoExtension(getRealImageName(createPath(name, pos, rFallback)));
217  sPaths.emplace_back(aFallbackName + ".png");
218  sPaths.emplace_back(aFallbackName + ".svg");
219  }
220  }
221 
222  OUString aRealName = getNameNoExtension(getRealImageName(name));
223  sPaths.emplace_back(aRealName + ".png");
224  sPaths.emplace_back(aRealName + ".svg");
225 
226  return sPaths;
227 }
228 
229 OUString ImplImageTree::getImageUrl(OUString const & rName, OUString const & rStyle, OUString const & rLang)
230 {
231  OUString aStyle(rStyle);
232 
233  while (!aStyle.isEmpty())
234  {
235  try
236  {
237  setStyle(aStyle);
238 
239  if (checkPathAccess())
240  {
241  IconSet& rIconSet = getCurrentIconSet();
242  const uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
243 
244  LanguageTag aLanguageTag(rLang);
245 
246  for (const OUString& rPath: getPaths(rName, aLanguageTag))
247  {
248  if (rNameAccess->hasByName(rPath))
249  {
250  return "vnd.sun.star.zip://"
251  + rtl::Uri::encode(rIconSet.maURL, rtl_UriCharClassRegName,
252  rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8)
253  + "/" + rPath;
254  }
255  }
256  }
257  }
258  catch (const uno::Exception &)
259  {
260  TOOLS_INFO_EXCEPTION("vcl", "");
261  }
262 
263  aStyle = fallbackStyle(aStyle);
264  }
265  return OUString();
266 }
267 
268 std::shared_ptr<SvMemoryStream> ImplImageTree::getImageStream(OUString const & rName, OUString const & rStyle, OUString const & rLang)
269 {
270  OUString aStyle(rStyle);
271 
272  while (!aStyle.isEmpty())
273  {
274  try
275  {
276  setStyle(aStyle);
277 
278  if (checkPathAccess())
279  {
280  IconSet& rIconSet = getCurrentIconSet();
281  const uno::Reference<container::XNameAccess>& rNameAccess = rIconSet.maNameAccess;
282 
283  LanguageTag aLanguageTag(rLang);
284 
285  for (const OUString& rPath: getPaths(rName, aLanguageTag))
286  {
287  if (rNameAccess->hasByName(rPath))
288  {
289  uno::Reference<io::XInputStream> aStream;
290  bool ok = rNameAccess->getByName(rPath) >>= aStream;
291  assert(ok);
292  (void)ok; // prevent unused warning in release build
293  return wrapStream(aStream);
294  }
295  }
296  }
297  }
298  catch (const uno::Exception &)
299  {
300  TOOLS_INFO_EXCEPTION("vcl", "");
301  }
302 
303  aStyle = fallbackStyle(aStyle);
304  }
305  return std::shared_ptr<SvMemoryStream>();
306 }
307 
308 OUString ImplImageTree::fallbackStyle(const OUString& rsStyle)
309 {
310  OUString sResult;
311 
312  if (rsStyle == "colibre" || rsStyle == "helpimg")
313  sResult = "";
314  else if (rsStyle == "sifr" || rsStyle == "breeze_dark")
315  sResult = "breeze";
316  else if (rsStyle == "sifr_dark" )
317  sResult = "breeze_dark";
318  else
319  sResult = "colibre";
320 
321  return sResult;
322 }
323 
324 bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized,
325  const ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
326 {
327  OUString aCurrentStyle(rStyle);
328  while (!aCurrentStyle.isEmpty())
329  {
330  try
331  {
332  ImageRequestParameters aParameters(rName, aCurrentStyle, rBitmap, localized, eFlags, nScalePercentage);
333  if (doLoadImage(aParameters))
334  return true;
335  }
336  catch (uno::RuntimeException &)
337  {}
338 
339  aCurrentStyle = fallbackStyle(aCurrentStyle);
340  }
341  return false;
342 }
343 
344 namespace
345 {
346 
347 OUString createVariant(ImageRequestParameters& rParameters)
348 {
349  bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
350  sal_Int32 aScalePercentage = rParameters.scalePercentage();
351 
352  OUString aVariant = OUString::number(aScalePercentage);
353 
354  if (bConvertToDarkTheme)
355  aVariant += "-dark";
356 
357  return aVariant;
358 }
359 
360 bool loadDiskCachedVersion(OUString const & sVariant, ImageRequestParameters& rParameters)
361 {
362  OUString sUrl(getIconCacheUrl(sVariant, rParameters));
363  if (!urlExists(sUrl))
364  return false;
365  SvFileStream aFileStream(sUrl, StreamMode::READ);
366  vcl::PngImageReader aPNGReader(aFileStream);
367  aPNGReader.read(rParameters.mrBitmap);
368  return true;
369 }
370 
371 void cacheBitmapToDisk(OUString const & sVariant, ImageRequestParameters const & rParameters)
372 {
373  OUString sUrl(createIconCacheUrl(sVariant, rParameters));
374  vcl::PNGWriter aWriter(rParameters.mrBitmap);
375  try
376  {
377  SvFileStream aStream(sUrl, StreamMode::WRITE);
378  aWriter.Write(aStream);
379  aStream.Close();
380  }
381  catch (...)
382  {}
383 }
384 
385 } // end anonymous namespace
386 
388 {
389  setStyle(rParameters.msStyle);
390 
391  if (iconCacheLookup(rParameters))
392  return true;
393 
394  OUString aVariant = createVariant(rParameters);
395  if (loadDiskCachedVersion(aVariant, rParameters))
396  return true;
397 
398  if (!rParameters.mrBitmap.IsEmpty())
399  rParameters.mrBitmap.SetEmpty();
400 
402 
403  std::vector<OUString> aPaths = getPaths(rParameters.msName, aLanguageTag);
404 
405  bool bFound = false;
406 
407  try
408  {
409  bFound = findImage(aPaths, rParameters);
410  }
411  catch (uno::RuntimeException&)
412  {
413  throw;
414  }
415  catch (const uno::Exception&)
416  {
417  TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::doLoadImage");
418  }
419 
420  if (bFound)
421  {
422  if (rParameters.mbWriteImageToCache)
423  {
424  cacheBitmapToDisk(aVariant, rParameters);
425  }
426  getIconCache(rParameters)[rParameters.msName] = std::make_pair(rParameters.mbLocalized, rParameters.mrBitmap);
427  }
428 
429  return bFound;
430 }
431 
433 {
434  maCurrentStyle.clear();
435  maIconSets.clear();
436 }
437 
438 void ImplImageTree::setStyle(OUString const & style)
439 {
440  assert(!style.isEmpty());
441  if (style != maCurrentStyle)
442  {
443  maCurrentStyle = style;
444  createStyle();
445  }
446 }
447 
452 static bool isVclDemo()
453 {
454  static const bool bVclDemoOverride = std::getenv("LIBO_VCL_DEMO") != nullptr;
455  return bVclDemoOverride;
456 }
457 
459 {
460  if (maIconSets.find(maCurrentStyle) != maIconSets.end())
461  return;
462 
463  OUString sThemeUrl;
464 
465  if (isVclDemo())
466  {
467  static OUString s_workingDir;
468  if (!s_workingDir.getLength())
469  osl_getProcessWorkingDir( &s_workingDir.pData );
470 
471  if (maCurrentStyle == "default")
472  sThemeUrl = s_workingDir + "/icon-themes/colibre-svg";
473  else
474  sThemeUrl = s_workingDir + "/icon-themes/" + maCurrentStyle;
475  }
476  else if (maCurrentStyle != "default")
477  {
479  std::deque<OUString> aPaths;
480  sal_Int32 nIndex = 0;
481  do
482  {
483  aPaths.push_front(paths.getToken(0, ';', nIndex));
484  }
485  while (nIndex >= 0);
486 
487  for (const auto& path : aPaths)
488  {
489  INetURLObject aUrl(path);
490  OSL_ASSERT(!aUrl.HasError());
491 
492  bool ok = aUrl.Append("images_" + maCurrentStyle, INetURLObject::EncodeMechanism::All);
493  OSL_ASSERT(ok);
494  sThemeUrl = aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE) + ".zip";
495  if (urlExists(sThemeUrl))
496  break;
497  sThemeUrl.clear();
498  }
499 
500  if (sThemeUrl.isEmpty())
501  return;
502  }
503  else
504  {
505  sThemeUrl += "images";
506  if (!urlExists(sThemeUrl))
507  return;
508  }
509 
510  maIconSets[maCurrentStyle] = IconSet(sThemeUrl);
511 
512  loadImageLinks();
513 }
514 
517 {
518  IconSet &rSet = getCurrentIconSet();
519  auto it = rSet.maScaledIconCaches.find(rParameters.mnScalePercentage);
520  if ( it != rSet.maScaledIconCaches.end() )
521  return *it->second;
522  rSet.maScaledIconCaches[rParameters.mnScalePercentage] = std::make_unique<IconCache>();
523  return *rSet.maScaledIconCaches[rParameters.mnScalePercentage];
524 }
525 
527 {
528  IconCache& rIconCache = getIconCache(rParameters);
529 
530  IconCache::iterator i(rIconCache.find(getRealImageName(rParameters.msName)));
531  if (i != rIconCache.end() && i->second.first == rParameters.mbLocalized)
532  {
533  rParameters.mrBitmap = i->second.second;
534  return true;
535  }
536 
537  return false;
538 }
539 
540 bool ImplImageTree::findImage(std::vector<OUString> const & rPaths, ImageRequestParameters& rParameters)
541 {
542  if (!checkPathAccess())
543  return false;
544 
545  uno::Reference<container::XNameAccess> const & rNameAccess = getCurrentIconSet().maNameAccess;
546 
547  for (OUString const & rPath : rPaths)
548  {
549  if (rNameAccess->hasByName(rPath))
550  {
551  uno::Reference<io::XInputStream> aStream;
552  bool ok = rNameAccess->getByName(rPath) >>= aStream;
553  assert(ok);
554  (void)ok; // prevent unused warning in release build
555 
556  loadImageFromStream(wrapStream(aStream), rPath, rParameters);
557 
558  return true;
559  }
560  }
561  return false;
562 }
563 
565 {
566  const OUString aLinkFilename("links.txt");
567 
568  if (!checkPathAccess())
569  return;
570 
571  const uno::Reference<container::XNameAccess> &rNameAccess = getCurrentIconSet().maNameAccess;
572 
573  if (rNameAccess->hasByName(aLinkFilename))
574  {
575  uno::Reference<io::XInputStream> xStream;
576  bool ok = rNameAccess->getByName(aLinkFilename) >>= xStream;
577  assert(ok);
578  (void)ok; // prevent unused warning in release build
579 
580  parseLinkFile(wrapStream(xStream));
581  return;
582  }
583 }
584 
585 void ImplImageTree::parseLinkFile(std::shared_ptr<SvStream> const & xStream)
586 {
587  OString aLine;
588  OUString aLink, aOriginal;
589  int nLineNo = 0;
590  while (xStream->ReadLine(aLine))
591  {
592  ++nLineNo;
593  if (aLine.isEmpty())
594  continue;
595 
596  sal_Int32 nIndex = 0;
597  aLink = OStringToOUString(aLine.getToken(0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
598  aOriginal = OStringToOUString(aLine.getToken(0, ' ', nIndex), RTL_TEXTENCODING_UTF8);
599 
600  // skip comments, or incomplete entries
601  if (aLink.isEmpty() || aLink[0] == '#' || aOriginal.isEmpty())
602  {
603  if (aLink.isEmpty() || aOriginal.isEmpty())
604  SAL_WARN("vcl", "ImplImageTree::parseLinkFile: icon links.txt parse error, incomplete link at line " << nLineNo);
605  continue;
606  }
607 
608  getCurrentIconSet().maLinkHash[aLink] = aOriginal;
609 
610  OUString aOriginal32 = convertLcTo32Path(aOriginal);
611  OUString aLink32 = convertLcTo32Path(aLink);
612 
613  if (!aOriginal32.isEmpty() && !aLink32.isEmpty())
614  getCurrentIconSet().maLinkHash[aLink32] = aOriginal32;
615  }
616 }
617 
618 OUString const & ImplImageTree::getRealImageName(OUString const & rIconName)
619 {
620  IconLinkHash & rLinkHash = maIconSets[maCurrentStyle].maLinkHash;
621 
622  OUString sNameWithNoExtension = getNameNoExtension(rIconName);
623 
624  // PNG is priority
625  auto it = rLinkHash.find(sNameWithNoExtension + ".png");
626  if (it != rLinkHash.end())
627  return it->second;
628 
629  // also check SVG name
630  it = rLinkHash.find(sNameWithNoExtension + ".svg");
631  if (it != rLinkHash.end())
632  return it->second;
633 
634  // neither was found so just return the original name
635  return rIconName;
636 }
637 
638 class FolderFileAccess : public ::cppu::WeakImplHelper<css::container::XNameAccess>
639 {
640 public:
641  uno::Reference< uno::XComponentContext > mxContext;
642  OUString maURL;
643  FolderFileAccess(uno::Reference< uno::XComponentContext > const & context, OUString const & url)
644  : mxContext(context), maURL(url) {}
645  // XElementAccess
646  virtual css::uno::Type SAL_CALL getElementType() override { return cppu::UnoType<io::XInputStream>::get(); }
647  virtual sal_Bool SAL_CALL hasElements() override { return true; }
648  // XNameAccess
649  virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override
650  {
651  uno::Reference< io::XInputStream > xInputStream = ucb::SimpleFileAccess::create(mxContext)->openFileRead( maURL + "/" + aName );
652  return css::uno::Any(xInputStream);
653  }
654  virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
655  {
656  return {};
657  }
658  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
659  {
660  osl::File aBaseFile(maURL + "/" + aName);
661  return osl::File::E_None == aBaseFile.open(osl_File_OpenFlag_Read);
662  }
663 };
664 
666 {
667  IconSet& rIconSet = getCurrentIconSet();
668  uno::Reference<container::XNameAccess> & rNameAccess = rIconSet.maNameAccess;
669  if (rNameAccess.is())
670  return true;
671 
672  try
673  {
674  if (isVclDemo())
675  rNameAccess = new FolderFileAccess(comphelper::getProcessComponentContext(), rIconSet.maURL);
676  else
677  rNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), rIconSet.maURL);
678  }
679  catch (const uno::RuntimeException &)
680  {
681  throw;
682  }
683  catch (const uno::Exception &)
684  {
685  TOOLS_INFO_EXCEPTION("vcl", "ImplImageTree::zip file location " << rIconSet.maURL);
686  return false;
687  }
688  return rNameAccess.is();
689 }
690 
691 uno::Reference<container::XNameAccess> const & ImplImageTree::getNameAccess()
692 {
693  (void)checkPathAccess();
694  return getCurrentIconSet().maNameAccess;
695 }
696 
697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void loadFromSvg(SvStream &rStream, const OUString &sPath, BitmapEx &rBitmapEx, double fScalingFactor)
Definition: BitmapTools.cxx:61
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
const char aData[]
virtual css::uno::Type SAL_CALL getElementType() override
void shutdown()
a crude form of life cycle control (called from DeInitVCL; otherwise, if the ImplImageTree singleton ...
const LanguageTag & GetUILanguageTag() const
bool findImage(std::vector< OUString > const &rPaths, ImageRequestParameters &rParameters)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmapex.cxx:370
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:705
uno::Reference< uno::XComponentContext > mxContext
bool HasError() const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: bitmapex.cxx:454
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:1055
ScaledIconCache maScaledIconCaches
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
css::uno::Reference< css::container::XNameAccess > const & getNameAccess()
bool ReadDIBBitmapEx(BitmapEx &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
Definition: dibtools.cxx:1741
OUString const msStyle
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:208
bool IsEmpty() const
Definition: bitmapex.cxx:203
#define SAL_CONFIGFILE(name)
bool Append(OUString const &rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
int i
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()
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
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)
virtual sal_Bool SAL_CALL hasElements() override
bool loadImage(OUString const &name, OUString const &style, BitmapEx &bitmap, bool localized, const ImageLoadFlags eFlags, sal_Int32 nScalePercentage=-1)
bool checkPathAccess()
FolderFileAccess(uno::Reference< uno::XComponentContext > const &context, OUString const &url)
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:517
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
#define SAL_WARN(area, stream)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo