1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6d739b60SAndrew Rist  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6d739b60SAndrew Rist  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19*6d739b60SAndrew Rist  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/logfile.hxx>
28cdf0e10cSrcweir #include <uiconfiguration/moduleimagemanager.hxx>
29cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
30cdf0e10cSrcweir #include <xml/imagesconfiguration.hxx>
31cdf0e10cSrcweir #include <uiconfiguration/graphicnameaccess.hxx>
32cdf0e10cSrcweir #include <services.h>
33cdf0e10cSrcweir #include "imagemanagerimpl.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "properties.h"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //_________________________________________________________________________________________________________________
38cdf0e10cSrcweir //	interface includes
39cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp>
41cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
43cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
45cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
46cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp>
48cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp>
49cdf0e10cSrcweir #include <com/sun/star/uri/XUriReference.hpp>
50cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir //	other includes
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <vcl/svapp.hxx>
57cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
58cdf0e10cSrcweir #include <osl/mutex.hxx>
59cdf0e10cSrcweir #include <osl/file.hxx>
60cdf0e10cSrcweir #include <comphelper/sequence.hxx>
61cdf0e10cSrcweir #include <tools/urlobj.hxx>
62cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
63cdf0e10cSrcweir #include <vcl/pngread.hxx>
64cdf0e10cSrcweir #include <vcl/pngwrite.hxx>
65cdf0e10cSrcweir #include <rtl/logfile.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //_________________________________________________________________________________________________________________
68cdf0e10cSrcweir //	namespaces
69cdf0e10cSrcweir //_________________________________________________________________________________________________________________
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using ::rtl::OUString;
72cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
73cdf0e10cSrcweir using ::com::sun::star::uno::XInterface;
74cdf0e10cSrcweir using ::com::sun::star::uno::Exception;
75cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
76cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY;
77cdf0e10cSrcweir using ::com::sun::star::uno::Any;
78cdf0e10cSrcweir using ::com::sun::star::uno::makeAny;
79cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic;
80cdf0e10cSrcweir using namespace ::com::sun::star;
81cdf0e10cSrcweir using namespace ::com::sun::star::io;
82cdf0e10cSrcweir using namespace ::com::sun::star::embed;
83cdf0e10cSrcweir using namespace ::com::sun::star::lang;
84cdf0e10cSrcweir using namespace ::com::sun::star::container;
85cdf0e10cSrcweir using namespace ::com::sun::star::beans;
86cdf0e10cSrcweir using namespace ::com::sun::star::ui;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir namespace framework
89cdf0e10cSrcweir {
ModuleImageManager(uno::Reference<XMultiServiceFactory> xServiceManager)90cdf0e10cSrcweir ModuleImageManager::ModuleImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) :
91cdf0e10cSrcweir     ThreadHelpBase( &Application::GetSolarMutex() )
92cdf0e10cSrcweir     , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),true) )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
~ModuleImageManager()96cdf0e10cSrcweir ModuleImageManager::~ModuleImageManager()
97cdf0e10cSrcweir {
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // XComponent
dispose()101cdf0e10cSrcweir void SAL_CALL ModuleImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     m_pImpl->dispose();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
addEventListener(const uno::Reference<XEventListener> & xListener)106cdf0e10cSrcweir void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     m_pImpl->addEventListener(xListener);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
removeEventListener(const uno::Reference<XEventListener> & xListener)111cdf0e10cSrcweir void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
114cdf0e10cSrcweir     m_pImpl->removeEventListener(xListener);
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir // XInitialization
initialize(const Sequence<Any> & aArguments)118cdf0e10cSrcweir void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     m_pImpl->initialize(aArguments);
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // XImageManager
reset()124cdf0e10cSrcweir void SAL_CALL ModuleImageManager::reset()
125cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     m_pImpl->reset();
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
getAllImageNames(::sal_Int16 nImageType)130cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType )
131cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     return m_pImpl->getAllImageNames( nImageType );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
hasImage(::sal_Int16 nImageType,const::rtl::OUString & aCommandURL)136cdf0e10cSrcweir ::sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL )
137cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     return m_pImpl->hasImage(nImageType,aCommandURL);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
getImages(::sal_Int16 nImageType,const Sequence<::rtl::OUString> & aCommandURLSequence)142cdf0e10cSrcweir Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages(
143cdf0e10cSrcweir     ::sal_Int16 nImageType,
144cdf0e10cSrcweir     const Sequence< ::rtl::OUString >& aCommandURLSequence )
145cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT( aLog, "framework: ModuleImageManager::getImages" );
148cdf0e10cSrcweir     return m_pImpl->getImages(nImageType,aCommandURLSequence);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
replaceImages(::sal_Int16 nImageType,const Sequence<::rtl::OUString> & aCommandURLSequence,const Sequence<uno::Reference<XGraphic>> & aGraphicsSequence)151cdf0e10cSrcweir void SAL_CALL ModuleImageManager::replaceImages(
152cdf0e10cSrcweir     ::sal_Int16 nImageType,
153cdf0e10cSrcweir     const Sequence< ::rtl::OUString >& aCommandURLSequence,
154cdf0e10cSrcweir     const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
155cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException,
156cdf0e10cSrcweir         ::com::sun::star::lang::IllegalAccessException,
157cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
removeImages(::sal_Int16 nImageType,const Sequence<::rtl::OUString> & aCommandURLSequence)162cdf0e10cSrcweir void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence )
163cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException,
164cdf0e10cSrcweir         ::com::sun::star::lang::IllegalAccessException,
165cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     m_pImpl->removeImages(nImageType,aCommandURLSequence);
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
insertImages(::sal_Int16 nImageType,const Sequence<::rtl::OUString> & aCommandURLSequence,const Sequence<uno::Reference<XGraphic>> & aGraphicSequence)170cdf0e10cSrcweir void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
171cdf0e10cSrcweir throw ( ::com::sun::star::container::ElementExistException,
172cdf0e10cSrcweir         ::com::sun::star::lang::IllegalArgumentException,
173cdf0e10cSrcweir         ::com::sun::star::lang::IllegalAccessException,
174cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir // XUIConfiguration
addConfigurationListener(const uno::Reference<::com::sun::star::ui::XUIConfigurationListener> & xListener)180cdf0e10cSrcweir void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
181cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     m_pImpl->addConfigurationListener(xListener);
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
removeConfigurationListener(const uno::Reference<::com::sun::star::ui::XUIConfigurationListener> & xListener)186cdf0e10cSrcweir void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
187cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     m_pImpl->removeConfigurationListener(xListener);
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir // XUIConfigurationPersistence
reload()193cdf0e10cSrcweir void SAL_CALL ModuleImageManager::reload()
194cdf0e10cSrcweir throw ( ::com::sun::star::uno::Exception,
195cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir     m_pImpl->reload();
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
store()200cdf0e10cSrcweir void SAL_CALL ModuleImageManager::store()
201cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir     m_pImpl->store();
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
storeToStorage(const uno::Reference<XStorage> & Storage)206cdf0e10cSrcweir void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
207cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     m_pImpl->storeToStorage(Storage);
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
isModified()212cdf0e10cSrcweir sal_Bool SAL_CALL ModuleImageManager::isModified()
213cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir     return m_pImpl->isModified();
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
isReadOnly()218cdf0e10cSrcweir sal_Bool SAL_CALL ModuleImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     return m_pImpl->isReadOnly();
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir } // namespace framework
224