update dev300-m58
[ooovba.git] / framework / source / uiconfiguration / imagemanager.cxx
blob18eb67dea3ec609a0401d407468264346602b20f
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.cxx,v $
10 * $Revision: 1.16.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
33 #include <uiconfiguration/imagemanager.hxx>
34 #include <threadhelp/resetableguard.hxx>
35 #include <xml/imagesconfiguration.hxx>
36 #include <uiconfiguration/graphicnameaccess.hxx>
37 #include <services.h>
38 #include "imagemanagerimpl.hxx"
40 #include "properties.h"
42 //_________________________________________________________________________________________________________________
43 // interface includes
44 //_________________________________________________________________________________________________________________
45 #include <com/sun/star/ui/UIElementType.hpp>
46 #include <com/sun/star/ui/ConfigurationEvent.hpp>
47 #include <com/sun/star/lang/DisposedException.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/beans/PropertyValue.hpp>
50 #include <com/sun/star/embed/ElementModes.hpp>
51 #include <com/sun/star/io/XStream.hpp>
52 #include <com/sun/star/ui/ImageType.hpp>
54 //_________________________________________________________________________________________________________________
55 // other includes
56 //_________________________________________________________________________________________________________________
58 #include <vcl/svapp.hxx>
59 #include <rtl/ustrbuf.hxx>
60 #include <osl/mutex.hxx>
61 #include <comphelper/sequence.hxx>
62 #include <tools/urlobj.hxx>
63 #include <unotools/ucbstreamhelper.hxx>
64 #include <vcl/pngread.hxx>
65 #include <vcl/pngwrite.hxx>
66 #include <rtl/logfile.hxx>
68 //_________________________________________________________________________________________________________________
69 // namespaces
70 //_________________________________________________________________________________________________________________
72 using ::rtl::OUString;
73 using ::com::sun::star::uno::Sequence;
74 using ::com::sun::star::uno::XInterface;
75 using ::com::sun::star::uno::Exception;
76 using ::com::sun::star::uno::RuntimeException;
77 using ::com::sun::star::uno::UNO_QUERY;
78 using ::com::sun::star::uno::Any;
79 using ::com::sun::star::uno::makeAny;
80 using ::com::sun::star::graphic::XGraphic;
81 using namespace ::com::sun::star;
82 using namespace ::com::sun::star::io;
83 using namespace ::com::sun::star::embed;
84 using namespace ::com::sun::star::lang;
85 using namespace ::com::sun::star::container;
86 using namespace ::com::sun::star::beans;
87 using namespace ::com::sun::star::ui;
89 // Image sizes for our toolbars/menus
90 const sal_Int32 IMAGE_SIZE_NORMAL = 16;
91 const sal_Int32 IMAGE_SIZE_LARGE = 26;
92 const sal_Int16 MAX_IMAGETYPE_VALUE = ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST|
93 ::com::sun::star::ui::ImageType::SIZE_LARGE;
95 namespace framework
98 typedef GraphicNameAccess CmdToXGraphicNameAccess;
100 //*****************************************************************************************************************
101 // XInterface, XTypeProvider, XServiceInfo
102 //*****************************************************************************************************************
103 DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager ,
104 ::cppu::OWeakObject ,
105 SERVICENAME_IMAGEMANAGER ,
106 IMPLEMENTATIONNAME_IMAGEMANAGER
109 DEFINE_INIT_SERVICE ( ImageManager, {} )
111 ImageManager::ImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) :
112 ThreadHelpBase( &Application::GetSolarMutex() )
113 , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),false) )
117 ImageManager::~ImageManager()
119 m_pImpl->clear();
122 // XComponent
123 void SAL_CALL ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
125 m_pImpl->dispose();
128 void SAL_CALL ImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
130 m_pImpl->addEventListener(xListener);
133 void SAL_CALL ImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
135 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
136 m_pImpl->removeEventListener(xListener);
139 // Non-UNO methods
140 void ImageManager::setStorage( const uno::Reference< XStorage >& Storage )
141 throw (::com::sun::star::uno::RuntimeException)
143 ResetableGuard aLock( m_pImpl->m_aLock );
145 m_pImpl->m_xUserConfigStorage = Storage;
146 m_pImpl->implts_initialize();
149 // XInitialization
150 void SAL_CALL ImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
152 m_pImpl->initialize(aArguments);
155 // XImageManager
156 void SAL_CALL ImageManager::reset()
157 throw (::com::sun::star::uno::RuntimeException)
160 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
161 m_pImpl->reset();
164 Sequence< ::rtl::OUString > SAL_CALL ImageManager::getAllImageNames( ::sal_Int16 nImageType )
165 throw (::com::sun::star::uno::RuntimeException)
167 return m_pImpl->getAllImageNames( nImageType );
170 ::sal_Bool SAL_CALL ImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL )
171 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
173 return m_pImpl->hasImage(nImageType,aCommandURL);
176 Sequence< uno::Reference< XGraphic > > SAL_CALL ImageManager::getImages(
177 ::sal_Int16 nImageType,
178 const Sequence< ::rtl::OUString >& aCommandURLSequence )
179 throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
181 return m_pImpl->getImages(nImageType,aCommandURLSequence);
184 void SAL_CALL ImageManager::replaceImages(
185 ::sal_Int16 nImageType,
186 const Sequence< ::rtl::OUString >& aCommandURLSequence,
187 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
188 throw ( ::com::sun::star::lang::IllegalArgumentException,
189 ::com::sun::star::lang::IllegalAccessException,
190 ::com::sun::star::uno::RuntimeException)
192 m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
195 void SAL_CALL ImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence )
196 throw ( ::com::sun::star::lang::IllegalArgumentException,
197 ::com::sun::star::lang::IllegalAccessException,
198 ::com::sun::star::uno::RuntimeException)
200 m_pImpl->removeImages(nImageType,aCommandURLSequence);
203 void SAL_CALL ImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
204 throw ( ::com::sun::star::container::ElementExistException,
205 ::com::sun::star::lang::IllegalArgumentException,
206 ::com::sun::star::lang::IllegalAccessException,
207 ::com::sun::star::uno::RuntimeException)
209 m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
212 // XUIConfiguration
213 void SAL_CALL ImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
214 throw (::com::sun::star::uno::RuntimeException)
216 m_pImpl->addConfigurationListener(xListener);
219 void SAL_CALL ImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
220 throw (::com::sun::star::uno::RuntimeException)
222 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
223 m_pImpl->removeConfigurationListener(xListener);
226 // XUIConfigurationPersistence
227 void SAL_CALL ImageManager::reload()
228 throw ( ::com::sun::star::uno::Exception,
229 ::com::sun::star::uno::RuntimeException )
231 m_pImpl->reload();
234 void SAL_CALL ImageManager::store()
235 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
237 m_pImpl->store();
240 void SAL_CALL ImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
241 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
243 m_pImpl->storeToStorage(Storage);
246 sal_Bool SAL_CALL ImageManager::isModified()
247 throw (::com::sun::star::uno::RuntimeException)
249 return m_pImpl->isModified();
252 sal_Bool SAL_CALL ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
254 return m_pImpl->isReadOnly();
257 } // namespace framework