1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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 ...
42 //_________________________________________________________________________________________________________________
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>
51 #include <uiconfiguration/imagetype.hxx>
53 //_________________________________________________________________________________________________________________
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 //_________________________________________________________________________________________________________________
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>
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();
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();
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
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();
124 virtual oslInterlockedCount SAL_CALL
acquire();
125 virtual oslInterlockedCount SAL_CALL
release();
128 oslInterlockedCount m_nRefCount
;
131 class ImageManagerImpl
: public ThreadHelpBase
// Struct for right initalization of mutex member! Must be first of baseclasses.
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
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
);
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
);
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
);
167 typedef std::hash_map
< rtl::OUString
,
170 ::std::equal_to
< ::rtl::OUString
> > ImageNameMap
;
186 typedef ::std::vector
< ::com::sun::star::ui::ConfigurationEvent
> ConfigEventNotifyContainer
;
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
];
225 #endif // __FRAMEWORK_UICONFIGURATION_IMAGEMANAGERIMPL_HXX_