merge the formfield patch from ooo-build
[ooovba.git] / framework / source / uiconfiguration / moduleimagemanager.cxx
blob2273c1d641b0046f21cead065e5782f0aa413f48
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: moduleimagemanager.cxx,v $
10 * $Revision: 1.21 $
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 <rtl/logfile.hxx>
34 #include <uiconfiguration/moduleimagemanager.hxx>
35 #include <threadhelp/resetableguard.hxx>
36 #include <xml/imagesconfiguration.hxx>
37 #include <uiconfiguration/graphicnameaccess.hxx>
38 #include <services.h>
39 #include "imagemanagerimpl.hxx"
41 #include "properties.h"
43 //_________________________________________________________________________________________________________________
44 // interface includes
45 //_________________________________________________________________________________________________________________
46 #include <com/sun/star/ui/UIElementType.hpp>
47 #include <com/sun/star/ui/ConfigurationEvent.hpp>
48 #include <com/sun/star/lang/DisposedException.hpp>
49 #include <com/sun/star/beans/XPropertySet.hpp>
50 #include <com/sun/star/beans/PropertyValue.hpp>
51 #include <com/sun/star/embed/ElementModes.hpp>
52 #include <com/sun/star/io/XStream.hpp>
53 #include <com/sun/star/ui/ImageType.hpp>
54 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
55 #include <com/sun/star/uri/XUriReference.hpp>
56 #include <com/sun/star/uno/XComponentContext.hpp>
58 //_________________________________________________________________________________________________________________
59 // other includes
60 //_________________________________________________________________________________________________________________
62 #include <vcl/svapp.hxx>
63 #include <rtl/ustrbuf.hxx>
64 #include <osl/mutex.hxx>
65 #include <osl/file.hxx>
66 #include <comphelper/sequence.hxx>
67 #include <tools/urlobj.hxx>
68 #include <unotools/ucbstreamhelper.hxx>
69 #include <vcl/pngread.hxx>
70 #include <vcl/pngwrite.hxx>
71 #include <rtl/logfile.hxx>
73 //_________________________________________________________________________________________________________________
74 // namespaces
75 //_________________________________________________________________________________________________________________
77 using ::rtl::OUString;
78 using ::com::sun::star::uno::Sequence;
79 using ::com::sun::star::uno::XInterface;
80 using ::com::sun::star::uno::Exception;
81 using ::com::sun::star::uno::RuntimeException;
82 using ::com::sun::star::uno::UNO_QUERY;
83 using ::com::sun::star::uno::Any;
84 using ::com::sun::star::uno::makeAny;
85 using ::com::sun::star::graphic::XGraphic;
86 using namespace ::com::sun::star;
87 using namespace ::com::sun::star::io;
88 using namespace ::com::sun::star::embed;
89 using namespace ::com::sun::star::lang;
90 using namespace ::com::sun::star::container;
91 using namespace ::com::sun::star::beans;
92 using namespace ::com::sun::star::ui;
94 namespace framework
96 ModuleImageManager::ModuleImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) :
97 ThreadHelpBase( &Application::GetSolarMutex() )
98 , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),true) )
102 ModuleImageManager::~ModuleImageManager()
106 // XComponent
107 void SAL_CALL ModuleImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
109 m_pImpl->dispose();
112 void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
114 m_pImpl->addEventListener(xListener);
117 void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
119 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
120 m_pImpl->removeEventListener(xListener);
123 // XInitialization
124 void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
126 m_pImpl->initialize(aArguments);
129 // XImageManager
130 void SAL_CALL ModuleImageManager::reset()
131 throw (::com::sun::star::uno::RuntimeException)
133 m_pImpl->reset();
136 Sequence< ::rtl::OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType )
137 throw (::com::sun::star::uno::RuntimeException)
139 return m_pImpl->getAllImageNames( nImageType );
142 ::sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL )
143 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
145 return m_pImpl->hasImage(nImageType,aCommandURL);
148 Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages(
149 ::sal_Int16 nImageType,
150 const Sequence< ::rtl::OUString >& aCommandURLSequence )
151 throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
153 RTL_LOGFILE_CONTEXT( aLog, "framework: ModuleImageManager::getImages" );
154 return m_pImpl->getImages(nImageType,aCommandURLSequence);
157 void SAL_CALL ModuleImageManager::replaceImages(
158 ::sal_Int16 nImageType,
159 const Sequence< ::rtl::OUString >& aCommandURLSequence,
160 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
161 throw ( ::com::sun::star::lang::IllegalArgumentException,
162 ::com::sun::star::lang::IllegalAccessException,
163 ::com::sun::star::uno::RuntimeException)
165 m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
168 void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence )
169 throw ( ::com::sun::star::lang::IllegalArgumentException,
170 ::com::sun::star::lang::IllegalAccessException,
171 ::com::sun::star::uno::RuntimeException)
173 m_pImpl->removeImages(nImageType,aCommandURLSequence);
176 void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
177 throw ( ::com::sun::star::container::ElementExistException,
178 ::com::sun::star::lang::IllegalArgumentException,
179 ::com::sun::star::lang::IllegalAccessException,
180 ::com::sun::star::uno::RuntimeException)
182 m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
185 // XUIConfiguration
186 void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
187 throw (::com::sun::star::uno::RuntimeException)
189 m_pImpl->addConfigurationListener(xListener);
192 void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
193 throw (::com::sun::star::uno::RuntimeException)
195 m_pImpl->removeConfigurationListener(xListener);
198 // XUIConfigurationPersistence
199 void SAL_CALL ModuleImageManager::reload()
200 throw ( ::com::sun::star::uno::Exception,
201 ::com::sun::star::uno::RuntimeException )
203 m_pImpl->reload();
206 void SAL_CALL ModuleImageManager::store()
207 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
209 m_pImpl->store();
212 void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
213 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
215 m_pImpl->storeToStorage(Storage);
218 sal_Bool SAL_CALL ModuleImageManager::isModified()
219 throw (::com::sun::star::uno::RuntimeException)
221 return m_pImpl->isModified();
224 sal_Bool SAL_CALL ModuleImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
226 return m_pImpl->isReadOnly();
229 } // namespace framework