bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / tools / IconCache.hxx
blob8caf5a67009feb667316dd4befbb69dad4a72aba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SD_SOURCE_UI_INC_TOOLS_ICONCACHE_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_TOOLS_ICONCACHE_HXX
23 #include "SdGlobalResourceContainer.hxx"
24 #include <vcl/image.hxx>
26 namespace sd {
28 /** This simple class stores frequently used icons so that the classes that
29 use the icons do not have to store them in every one of their
30 instances.
32 Icons are addressed over their resource id and are loaded on demand.
34 This cache acts like a singleton with a lifetime equal to that of the sd
35 module.
37 class IconCache
38 : public SdGlobalResource
40 public:
41 /** The lifetime of the returned reference is limited to that of the sd
42 module.
44 static IconCache& Instance();
46 /** Return the icon with the given resource id.
47 @return
48 The returned Image may be empty when there is no icon for the
49 given id or an error occurred. Should not happen under normal
50 circumstances.
52 Image GetIcon (sal_uInt16 nResourceId);
54 private:
55 class Implementation;
56 ::std::unique_ptr<Implementation> mpImpl;
58 /** The constructor creates the one instance of the cache and registers
59 it at the SdGlobalResourceContainer to limit is lifetime to that of
60 the sd module.
62 IconCache();
64 /** This destructor is called by SdGlobalResourceContainer.
66 virtual ~IconCache();
69 } // end of namespace sd
71 #endif
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */