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 INCLUDED_VCL_IMPIMAGETREE_HXX 29 #define INCLUDED_VCL_IMPIMAGETREE_HXX 30 31 #include "sal/config.h" 32 33 #include <list> 34 #include <utility> 35 #include <vector> 36 37 #include <hash_map> 38 39 #include "boost/noncopyable.hpp" 40 #include "com/sun/star/uno/Reference.hxx" 41 #include "rtl/ustring.hxx" 42 #include "salhelper/singletonref.hxx" 43 44 namespace com { namespace sun { namespace star { namespace container { 45 class XNameAccess; 46 } } } } 47 class BitmapEx; 48 49 class ImplImageTree: private boost::noncopyable { 50 public: 51 ImplImageTree(); 52 53 ~ImplImageTree(); 54 55 // check whether the icon style is installed 56 bool checkStyle(rtl::OUString const & style); 57 58 bool loadImage( 59 rtl::OUString const & name, rtl::OUString const & style, 60 BitmapEx & bitmap, bool localized = false ); 61 62 void shutDown(); 63 // a crude form of life cycle control (called from DeInitVCL; otherwise, 64 // if the ImplImageTree singleton were destroyed during exit that would 65 // be too late for the destructors of the bitmaps in m_iconCache) 66 67 private: 68 typedef std::list< 69 std::pair< 70 rtl::OUString, 71 com::sun::star::uno::Reference< 72 com::sun::star::container::XNameAccess > > > Zips; 73 74 typedef std::hash_map< 75 rtl::OUString, bool, rtl::OUStringHash > CheckStyleCache; 76 typedef std::hash_map< 77 rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > IconCache; 78 79 rtl::OUString m_style; 80 Zips m_zips; 81 CheckStyleCache m_checkStyleCache; 82 IconCache m_iconCache; 83 84 void setStyle(rtl::OUString const & style ); 85 86 void resetZips(); 87 88 bool checkStyleCacheLookup( rtl::OUString const & style, bool &exists ); 89 bool iconCacheLookup( rtl::OUString const & name, bool localized, BitmapEx & bitmap ); 90 91 bool find(std::vector< rtl::OUString > const & paths, BitmapEx & bitmap ); 92 }; 93 94 typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; 95 96 #endif 97