Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / inc / impimagetree.hxx
blob68cb2418271a512b5c2fbae12d175281b9486935
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_VCL_INC_IMPIMAGETREE_HXX
21 #define INCLUDED_VCL_INC_IMPIMAGETREE_HXX
23 #include "sal/config.h"
25 #include <vector>
27 #include <boost/unordered_map.hpp>
29 #include "boost/noncopyable.hpp"
30 #include "com/sun/star/uno/Reference.hxx"
31 #include "rtl/ustring.hxx"
32 #include "salhelper/singletonref.hxx"
34 namespace com { namespace sun { namespace star { namespace container {
35 class XNameAccess;
36 } } } }
37 class BitmapEx;
39 class ImplImageTree: private boost::noncopyable {
40 public:
41 ImplImageTree();
43 ~ImplImageTree();
45 /// check whether the icon style is installed
46 bool checkStyle(OUString const & style);
48 bool loadImage(
49 OUString const & name, OUString const & style,
50 BitmapEx & bitmap, bool localized = false, bool loadMissing = false );
52 bool loadDefaultImage(
53 OUString const & style,
54 BitmapEx& bitmap);
56 /** a crude form of life cycle control (called from DeInitVCL; otherwise,
57 * if the ImplImageTree singleton were destroyed during exit that would
58 * be too late for the destructors of the bitmaps in m_iconCache)*/
59 void shutDown();
61 private:
62 bool doLoadImage(
63 OUString const & name, OUString const & style,
64 BitmapEx & bitmap, bool localized);
66 typedef std::pair<
67 OUString,
68 com::sun::star::uno::Reference<
69 com::sun::star::container::XNameAccess > > Path;
71 typedef boost::unordered_map<
72 OUString, bool, OUStringHash > CheckStyleCache;
73 typedef boost::unordered_map<
74 OUString, std::pair< bool, BitmapEx >, OUStringHash > IconCache;
75 typedef boost::unordered_map<
76 OUString, OUString, OUStringHash > IconLinkHash;
78 OUString m_style;
79 Path m_path;
80 CheckStyleCache m_checkStyleCache;
81 IconCache m_iconCache;
82 bool m_cacheIcons;
83 IconLinkHash m_linkHash;
85 void setStyle(OUString const & style );
87 void resetPaths();
89 bool checkStyleCacheLookup( OUString const & style, bool &exists );
90 bool iconCacheLookup( OUString const & name, bool localized, BitmapEx & bitmap );
92 bool find(std::vector< OUString > const & paths, BitmapEx & bitmap );
94 void loadImageLinks();
95 void parseLinkFile(boost::shared_ptr< SvStream > stream);
96 OUString const & getRealImageName(OUString const & name);
99 typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef;
101 #endif
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */