1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_VCL_IMPIMAGETREE_HXX 25 #define INCLUDED_VCL_IMPIMAGETREE_HXX 26 27 #include "sal/config.h" 28 29 #include <list> 30 #include <utility> 31 #include <vector> 32 33 #include <hash_map> 34 35 #include "boost/noncopyable.hpp" 36 #include "com/sun/star/uno/Reference.hxx" 37 #include "rtl/ustring.hxx" 38 #include "salhelper/singletonref.hxx" 39 40 namespace com { namespace sun { namespace star { namespace container { 41 class XNameAccess; 42 } } } } 43 class BitmapEx; 44 45 class ImplImageTree: private boost::noncopyable { 46 public: 47 ImplImageTree(); 48 49 ~ImplImageTree(); 50 51 // check whether the icon style is installed 52 bool checkStyle(rtl::OUString const & style); 53 54 bool loadImage( 55 rtl::OUString const & name, rtl::OUString const & style, 56 BitmapEx & bitmap, bool localized = false ); 57 58 void shutDown(); 59 // a crude form of life cycle control (called from DeInitVCL; otherwise, 60 // if the ImplImageTree singleton were destroyed during exit that would 61 // be too late for the destructors of the bitmaps in m_iconCache) 62 63 private: 64 typedef std::list< 65 std::pair< 66 rtl::OUString, 67 com::sun::star::uno::Reference< 68 com::sun::star::container::XNameAccess > > > Zips; 69 70 typedef std::hash_map< 71 rtl::OUString, bool, rtl::OUStringHash > CheckStyleCache; 72 typedef std::hash_map< 73 rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > IconCache; 74 75 rtl::OUString m_style; 76 Zips m_zips; 77 CheckStyleCache m_checkStyleCache; 78 IconCache m_iconCache; 79 80 void setStyle(rtl::OUString const & style ); 81 82 void resetZips(); 83 84 bool checkStyleCacheLookup( rtl::OUString const & style, bool &exists ); 85 bool iconCacheLookup( rtl::OUString const & name, bool localized, BitmapEx & bitmap ); 86 87 bool find(std::vector< rtl::OUString > const & paths, BitmapEx & bitmap ); 88 }; 89 90 typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; 91 92 #endif 93