1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SD_ICON_CACHE_HXX 29 #define SD_ICON_CACHE_HXX 30 31 #include "SdGlobalResourceContainer.hxx" 32 #include <vcl/image.hxx> 33 34 namespace sd { 35 36 /** This simple class stores frequently used icons so that the classes that 37 use the icons do not have to store them in every one of their 38 instances. 39 40 Icons are adressed over their resource id and are loaded on demand. 41 42 This cache acts like a singleton with a lifetime equal to that of the sd 43 module. 44 */ 45 class IconCache 46 : public SdGlobalResource 47 { 48 public: 49 /** The lifetime of the returned reference is limited to that of the sd 50 module. 51 */ 52 static IconCache& Instance (void); 53 54 /** Return the icon with the given resource id. 55 @return 56 The returned Image may be empty when there is no icon for the 57 given id or an error occured. Should not happen under normal 58 circumstances. 59 */ 60 Image GetIcon (sal_uInt16 nResourceId); 61 62 private: 63 class Implementation; 64 ::std::auto_ptr<Implementation> mpImpl; 65 66 /** The constructor creates the one instance of the cache and registers 67 it at the SdGlobalResourceContainer to limit is lifetime to that of 68 the sd module. 69 */ 70 IconCache (void); 71 72 /** This destructor is called by SdGlobalResourceContainer. 73 */ 74 virtual ~IconCache (void); 75 }; 76 77 } // end of namespace sd 78 79 #endif 80