bump product version to 4.1.6.2
[LibreOffice.git] / framework / source / uiconfiguration / imagemanagerimpl.hxx
blob81bd48609543f033a80473f7d951c5edac3010e3
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 __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_
21 #define __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_
24 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
25 with solaris headers ...
27 #include <vector>
28 #include <list>
29 #include <boost/unordered_map.hpp>
31 #include <threadhelp/threadhelpbase.hxx>
32 #include <macros/generic.hxx>
33 #include <macros/xinterface.hxx>
34 #include <macros/xtypeprovider.hxx>
35 #include <macros/xserviceinfo.hxx>
36 #include <stdtypes.h>
37 #include <uiconfiguration/imagetype.hxx>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/XTypeProvider.hpp>
41 #include <com/sun/star/lang/XComponent.hpp>
42 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
43 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
44 #include <com/sun/star/ui/XUIConfiguration.hpp>
45 #include <com/sun/star/ui/XImageManager.hpp>
46 #include <com/sun/star/lang/XInitialization.hpp>
47 #include <com/sun/star/ui/ConfigurationEvent.hpp>
48 #include <com/sun/star/embed/XTransactedObject.hpp>
50 #include <cppuhelper/weak.hxx>
51 #include <cppuhelper/interfacecontainer.hxx>
52 #include <rtl/ustring.hxx>
54 #include <vcl/image.hxx>
55 #include <rtl/ref.hxx>
57 namespace framework
59 class CmdImageList
61 public:
62 CmdImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
63 const OUString& aModuleIdentifier );
64 virtual ~CmdImageList();
66 virtual Image getImageFromCommandURL( sal_Int16 nImageType, const OUString& rCommandURL );
67 virtual bool hasImage( sal_Int16 nImageType, const OUString& rCommandURL );
68 virtual ::std::vector< OUString >& getImageNames();
69 virtual ::std::vector< OUString >& getImageCommandNames();
71 protected:
72 void impl_fillCommandToImageNameMap();
73 ImageList* impl_getImageList( sal_Int16 nImageType );
74 std::vector< OUString >& impl_getImageNameVector();
75 std::vector< OUString >& impl_getImageCommandNameVector();
77 private:
78 sal_Bool m_bVectorInit;
79 OUString m_aModuleIdentifier;
80 ImageList* m_pImageList[ImageType_COUNT];
81 CommandToImageNameMap m_aCommandToImageNameMap;
82 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
83 ::std::vector< OUString > m_aImageNameVector;
84 ::std::vector< OUString > m_aImageCommandNameVector;
85 sal_Int16 m_nSymbolsStyle;
88 class GlobalImageList : public CmdImageList, public rtl::IReference
90 public:
91 GlobalImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
92 virtual ~GlobalImageList();
94 virtual Image getImageFromCommandURL( sal_Int16 nImageType, const OUString& rCommandURL );
95 virtual bool hasImage( sal_Int16 nImageType, const OUString& rCommandURL );
96 virtual ::std::vector< OUString >& getImageNames();
97 virtual ::std::vector< OUString >& getImageCommandNames();
99 // ÍReference
100 virtual oslInterlockedCount SAL_CALL acquire();
101 virtual oslInterlockedCount SAL_CALL release();
103 private:
104 oslInterlockedCount m_nRefCount;
107 class ImageManagerImpl : public ThreadHelpBase // Struct for right initalization of mutex member! Must be first of baseclasses.
109 public:
111 ImageManagerImpl(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
112 ,::cppu::OWeakObject *pOwner
113 ,bool _bUseGlobal);
114 ~ImageManagerImpl();
116 void dispose();
117 void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
118 void addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
119 void removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
121 // XImageManager
122 void reset() throw (::com::sun::star::uno::RuntimeException);
123 ::com::sun::star::uno::Sequence< OUString > getAllImageNames( ::sal_Int16 nImageType ) throw (::com::sun::star::uno::RuntimeException);
124 ::sal_Bool hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
125 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > getImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
126 void replaceImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& aGraphicsSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
127 void removeImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aResourceURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
128 void insertImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< OUString >& aCommandURLSequence, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& aGraphicSequence ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
130 // XUIConfiguration
131 void addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
132 void removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
134 // XUIConfigurationPersistence
135 void reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
136 void store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
137 void storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
138 sal_Bool isModified() throw (::com::sun::star::uno::RuntimeException);
139 sal_Bool isReadOnly() throw (::com::sun::star::uno::RuntimeException);
141 void clear();
143 typedef boost::unordered_map< OUString,
144 sal_Bool,
145 OUStringHash,
146 ::std::equal_to< OUString > > ImageNameMap;
148 enum Layer
150 LAYER_DEFAULT,
151 LAYER_USERDEFINED,
152 LAYER_COUNT
155 enum NotifyOp
157 NotifyOp_Remove,
158 NotifyOp_Insert,
159 NotifyOp_Replace
162 typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
164 // private methods
165 void implts_initialize();
166 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
167 ImageList* implts_getUserImageList( ImageType nImageType );
168 sal_Bool implts_loadUserImages( ImageType nImageType,
169 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
170 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
171 sal_Bool implts_storeUserImages( ImageType nImageType,
172 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
173 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
174 const rtl::Reference< GlobalImageList >& implts_getGlobalImageList();
175 CmdImageList* implts_getDefaultImageList();
178 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage;
179 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserImageStorage;
180 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserBitmapsStorage;
181 com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit;
182 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
183 ::cppu::OWeakObject* m_pOwner;
184 rtl::Reference< GlobalImageList > m_pGlobalImageList;
185 CmdImageList* m_pDefaultImageList;
186 OUString m_aXMLPostfix;
187 OUString m_aModuleIdentifier;
188 OUString m_aResourceString;
189 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
190 ImageList* m_pUserImageList[ImageType_COUNT];
191 bool m_bUserImageListModified[ImageType_COUNT];
192 bool m_bUseGlobal;
193 bool m_bReadOnly;
194 bool m_bInitialized;
195 bool m_bModified;
196 bool m_bConfigRead;
197 bool m_bDisposed;
201 #endif // __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */