1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_INCLUDE_VCL_IMPLIMAGETREE_HXX
21 #define INCLUDED_INCLUDE_VCL_IMPLIMAGETREE_HXX
23 #include <sal/config.h>
26 #include <unordered_map>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <rtl/ustring.hxx>
32 #include <vcl/bitmapex.hxx>
33 #include <vcl/dllapi.h>
35 namespace com
{ namespace sun
{ namespace star
{ namespace container
{
41 VCL_DLLPUBLIC
static ImplImageTree
& get();
47 VCL_DLLPUBLIC OUString
getImageUrl(
48 OUString
const & name
, OUString
const & style
, OUString
const & lang
);
51 OUString
const & name
, OUString
const & style
,
52 BitmapEx
& bitmap
, bool localized
= false, bool loadMissing
= false );
54 bool loadDefaultImage(
55 OUString
const & style
,
58 /** a crude form of life cycle control (called from DeInitVCL; otherwise,
59 * if the ImplImageTree singleton were destroyed during exit that would
60 * be too late for the destructors of the bitmaps in maIconCache)*/
63 css::uno::Reference
< css::container::XNameAccess
> getNameAccess();
66 ImplImageTree(const ImplImageTree
&) SAL_DELETED_FUNCTION
;
67 ImplImageTree
& operator=(const ImplImageTree
&) SAL_DELETED_FUNCTION
;
69 typedef std::unordered_map
<OUString
, std::pair
<bool, BitmapEx
>, OUStringHash
> IconCache
;
70 typedef std::unordered_map
<OUString
, OUString
, OUStringHash
> IconLinkHash
;
74 css::uno::Reference
<css::container::XNameAccess
> maNameAccess
;
75 IconCache maIconCache
;
76 IconLinkHash maLinkHash
;
79 IconSet(const OUString
&aURL
) : maURL(aURL
) {}
82 /// Map between the theme name(s) and the content.
83 typedef std::unordered_map
<OUString
, IconSet
, OUStringHash
> StyleIconSet
;
85 /// Remember all the (used) icon styles and individual icons in them.
86 StyleIconSet maIconSet
;
88 /// Styly used for the current operations; switches switch several times during fallback search.
89 OUString maCurrentStyle
;
92 OUString
const & name
, OUString
const & style
,
93 BitmapEx
& bitmap
, bool localized
);
95 bool checkPathAccess();
97 void setStyle(OUString
const & style
);
101 bool iconCacheLookup( OUString
const & name
, bool localized
, BitmapEx
& bitmap
);
103 bool findImage(std::vector
< OUString
> const & paths
, BitmapEx
& bitmap
);
105 void loadImageLinks();
107 void parseLinkFile(std::shared_ptr
<SvStream
> stream
);
109 /// Return name of a real .png according to links.txt.
110 OUString
const & getRealImageName(OUString
const & name
);
112 /** Rerurn name of the fallback style for the provided one.
114 Must not be cyclic :-) The last theme in the chain returns an empty string.
116 static OUString
fallbackStyle(const OUString
&style
);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */