merge the formfield patch from ooo-build
[ooovba.git] / framework / source / uiconfiguration / imagemanagerimpl.hxx
blobe5201e9a9b175a1314a334b382d54fd84c4f9b4f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: imagemanager.hxx,v $
10 * $Revision: 1.7.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_
32 #define __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_
35 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
36 with solaris headers ...
38 #include <vector>
39 #include <list>
40 #include <hash_map>
42 //_________________________________________________________________________________________________________________
43 // my own includes
44 //_________________________________________________________________________________________________________________
45 #include <threadhelp/threadhelpbase.hxx>
46 #include <macros/generic.hxx>
47 #include <macros/xinterface.hxx>
48 #include <macros/xtypeprovider.hxx>
49 #include <macros/xserviceinfo.hxx>
50 #include <stdtypes.h>
51 #include <uiconfiguration/imagetype.hxx>
53 //_________________________________________________________________________________________________________________
54 // interface includes
55 //_________________________________________________________________________________________________________________
56 #include <com/sun/star/lang/XServiceInfo.hpp>
57 #include <com/sun/star/lang/XTypeProvider.hpp>
58 #include <com/sun/star/lang/XComponent.hpp>
59 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
60 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
61 #include <com/sun/star/ui/XUIConfiguration.hpp>
62 #include <com/sun/star/ui/XImageManager.hpp>
63 #include <com/sun/star/lang/XInitialization.hpp>
64 #include <com/sun/star/ui/ConfigurationEvent.hpp>
65 #include <com/sun/star/embed/XTransactedObject.hpp>
66 #include <com/sun/star/ui/XImageManager.hpp>
68 //_________________________________________________________________________________________________________________
69 // other includes
70 //_________________________________________________________________________________________________________________
71 #include <cppuhelper/weak.hxx>
72 #include <cppuhelper/interfacecontainer.hxx>
73 #include <rtl/ustring.hxx>
75 #include <vcl/image.hxx>
76 #include <tools/color.hxx>
77 #include <rtl/ref.hxx>
79 #include <vector>
81 namespace framework
83 class CmdImageList
85 public:
86 CmdImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
87 const ::rtl::OUString& aModuleIdentifier );
88 virtual ~CmdImageList();
90 virtual Image getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUString& rCommandURL );
91 virtual bool hasImage( sal_Int16 nImageType, const rtl::OUString& rCommandURL );
92 virtual ::std::vector< rtl::OUString >& getImageNames();
93 virtual ::std::vector< rtl::OUString >& getImageCommandNames();
95 protected:
96 void impl_fillCommandToImageNameMap();
97 ImageList* impl_getImageList( sal_Int16 nImageType );
98 std::vector< ::rtl::OUString >& impl_getImageNameVector();
99 std::vector< ::rtl::OUString >& impl_getImageCommandNameVector();
101 private:
102 sal_Bool m_bVectorInit;
103 rtl::OUString m_aModuleIdentifier;
104 ImageList* m_pImageList[ImageType_COUNT];
105 CommandToImageNameMap m_aCommandToImageNameMap;
106 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
107 ::std::vector< rtl::OUString > m_aImageNameVector;
108 ::std::vector< rtl::OUString > m_aImageCommandNameVector;
109 sal_Int16 m_nSymbolsStyle;
112 class GlobalImageList : public CmdImageList, public rtl::IReference
114 public:
115 GlobalImageList( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
116 virtual ~GlobalImageList();
118 virtual Image getImageFromCommandURL( sal_Int16 nImageType, const rtl::OUString& rCommandURL );
119 virtual bool hasImage( sal_Int16 nImageType, const rtl::OUString& rCommandURL );
120 virtual ::std::vector< rtl::OUString >& getImageNames();
121 virtual ::std::vector< rtl::OUString >& getImageCommandNames();
123 // ÍReference
124 virtual oslInterlockedCount SAL_CALL acquire();
125 virtual oslInterlockedCount SAL_CALL release();
127 private:
128 oslInterlockedCount m_nRefCount;
131 class ImageManagerImpl : public ThreadHelpBase // Struct for right initalization of mutex member! Must be first of baseclasses.
133 public:
135 ImageManagerImpl(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager
136 ,const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& _xOwner
137 ,bool _bUseGlobal);
138 ~ImageManagerImpl();
140 void dispose();
141 void initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
142 void addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
143 void removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
145 // XImageManager
146 void reset() throw (::com::sun::star::uno::RuntimeException);
147 ::com::sun::star::uno::Sequence< ::rtl::OUString > getAllImageNames( ::sal_Int16 nImageType ) throw (::com::sun::star::uno::RuntimeException);
148 ::sal_Bool hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
149 ::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< ::rtl::OUString >& aCommandURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
150 void replaceImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< ::rtl::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);
151 void removeImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aResourceURLSequence ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
152 void insertImages( ::sal_Int16 nImageType, const ::com::sun::star::uno::Sequence< ::rtl::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);
154 // XUIConfiguration
155 void addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
156 void removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
158 // XUIConfigurationPersistence
159 void reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
160 void store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
161 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);
162 sal_Bool isModified() throw (::com::sun::star::uno::RuntimeException);
163 sal_Bool isReadOnly() throw (::com::sun::star::uno::RuntimeException);
165 void clear();
167 typedef std::hash_map< rtl::OUString,
168 sal_Bool,
169 OUStringHashCode,
170 ::std::equal_to< ::rtl::OUString > > ImageNameMap;
172 enum Layer
174 LAYER_DEFAULT,
175 LAYER_USERDEFINED,
176 LAYER_COUNT
179 enum NotifyOp
181 NotifyOp_Remove,
182 NotifyOp_Insert,
183 NotifyOp_Replace
186 typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
188 // private methods
189 void implts_initialize();
190 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
191 ImageList* implts_getUserImageList( ImageType nImageType );
192 sal_Bool implts_loadUserImages( ImageType nImageType,
193 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
194 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
195 sal_Bool implts_storeUserImages( ImageType nImageType,
196 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserImageStorage,
197 const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xUserBitmapsStorage );
198 const rtl::Reference< GlobalImageList >& implts_getGlobalImageList();
199 CmdImageList* implts_getDefaultImageList();
202 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserConfigStorage;
203 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserImageStorage;
204 com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xUserBitmapsStorage;
205 com::sun::star::uno::Reference< com::sun::star::embed::XTransactedObject > m_xUserRootCommit;
206 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
207 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xOwner;
208 rtl::Reference< GlobalImageList > m_pGlobalImageList;
209 CmdImageList* m_pDefaultImageList;
210 rtl::OUString m_aXMLPostfix;
211 rtl::OUString m_aModuleIdentifier;
212 rtl::OUString m_aResourceString;
213 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
214 ImageList* m_pUserImageList[ImageType_COUNT];
215 bool m_bUserImageListModified[ImageType_COUNT];
216 bool m_bUseGlobal;
217 bool m_bReadOnly;
218 bool m_bInitialized;
219 bool m_bModified;
220 bool m_bConfigRead;
221 bool m_bDisposed;
225 #endif // __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_