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