1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <rtl/logfile.hxx>
22 #include <uiconfiguration/moduleimagemanager.hxx>
23 #include <threadhelp/resetableguard.hxx>
24 #include <xml/imagesconfiguration.hxx>
25 #include <uiconfiguration/graphicnameaccess.hxx>
27 #include "imagemanagerimpl.hxx"
29 #include "properties.h"
31 #include <com/sun/star/ui/UIElementType.hpp>
32 #include <com/sun/star/ui/ConfigurationEvent.hpp>
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/embed/ElementModes.hpp>
37 #include <com/sun/star/io/XStream.hpp>
38 #include <com/sun/star/ui/ImageType.hpp>
39 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
40 #include <com/sun/star/uri/XUriReference.hpp>
41 #include <com/sun/star/uno/XComponentContext.hpp>
43 #include <vcl/svapp.hxx>
44 #include <rtl/ustrbuf.hxx>
45 #include <osl/mutex.hxx>
46 #include <osl/file.hxx>
47 #include <comphelper/sequence.hxx>
48 #include <unotools/ucbstreamhelper.hxx>
49 #include <vcl/pngread.hxx>
50 #include <vcl/pngwrite.hxx>
52 //_________________________________________________________________________________________________________________
54 //_________________________________________________________________________________________________________________
56 using ::com::sun::star::uno::Sequence
;
57 using ::com::sun::star::uno::XInterface
;
58 using ::com::sun::star::uno::Exception
;
59 using ::com::sun::star::uno::RuntimeException
;
60 using ::com::sun::star::uno::UNO_QUERY
;
61 using ::com::sun::star::uno::Any
;
62 using ::com::sun::star::uno::makeAny
;
63 using ::com::sun::star::graphic::XGraphic
;
64 using namespace ::com::sun::star
;
65 using namespace ::com::sun::star::io
;
66 using namespace ::com::sun::star::embed
;
67 using namespace ::com::sun::star::lang
;
68 using namespace ::com::sun::star::container
;
69 using namespace ::com::sun::star::beans
;
70 using namespace ::com::sun::star::ui
;
74 ModuleImageManager::ModuleImageManager( uno::Reference
< XMultiServiceFactory
> xServiceManager
) :
75 ThreadHelpBase( &Application::GetSolarMutex() )
76 , m_pImpl( new ImageManagerImpl(comphelper::getComponentContext(xServiceManager
),static_cast< OWeakObject
* >(this),true) )
80 ModuleImageManager::~ModuleImageManager()
85 void SAL_CALL
ModuleImageManager::dispose() throw (::com::sun::star::uno::RuntimeException
)
90 void SAL_CALL
ModuleImageManager::addEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
92 m_pImpl
->addEventListener(xListener
);
95 void SAL_CALL
ModuleImageManager::removeEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
97 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
98 m_pImpl
->removeEventListener(xListener
);
102 void SAL_CALL
ModuleImageManager::initialize( const Sequence
< Any
>& aArguments
) throw ( Exception
, RuntimeException
)
104 m_pImpl
->initialize(aArguments
);
108 void SAL_CALL
ModuleImageManager::reset()
109 throw (::com::sun::star::uno::RuntimeException
)
114 Sequence
< OUString
> SAL_CALL
ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType
)
115 throw (::com::sun::star::uno::RuntimeException
)
117 return m_pImpl
->getAllImageNames( nImageType
);
120 ::sal_Bool SAL_CALL
ModuleImageManager::hasImage( ::sal_Int16 nImageType
, const OUString
& aCommandURL
)
121 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
123 return m_pImpl
->hasImage(nImageType
,aCommandURL
);
126 Sequence
< uno::Reference
< XGraphic
> > SAL_CALL
ModuleImageManager::getImages(
127 ::sal_Int16 nImageType
,
128 const Sequence
< OUString
>& aCommandURLSequence
)
129 throw ( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
131 RTL_LOGFILE_CONTEXT( aLog
, "framework: ModuleImageManager::getImages" );
132 return m_pImpl
->getImages(nImageType
,aCommandURLSequence
);
135 void SAL_CALL
ModuleImageManager::replaceImages(
136 ::sal_Int16 nImageType
,
137 const Sequence
< OUString
>& aCommandURLSequence
,
138 const Sequence
< uno::Reference
< XGraphic
> >& aGraphicsSequence
)
139 throw ( ::com::sun::star::lang::IllegalArgumentException
,
140 ::com::sun::star::lang::IllegalAccessException
,
141 ::com::sun::star::uno::RuntimeException
)
143 m_pImpl
->replaceImages(nImageType
,aCommandURLSequence
,aGraphicsSequence
);
146 void SAL_CALL
ModuleImageManager::removeImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
)
147 throw ( ::com::sun::star::lang::IllegalArgumentException
,
148 ::com::sun::star::lang::IllegalAccessException
,
149 ::com::sun::star::uno::RuntimeException
)
151 m_pImpl
->removeImages(nImageType
,aCommandURLSequence
);
154 void SAL_CALL
ModuleImageManager::insertImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
, const Sequence
< uno::Reference
< XGraphic
> >& aGraphicSequence
)
155 throw ( ::com::sun::star::container::ElementExistException
,
156 ::com::sun::star::lang::IllegalArgumentException
,
157 ::com::sun::star::lang::IllegalAccessException
,
158 ::com::sun::star::uno::RuntimeException
)
160 m_pImpl
->insertImages(nImageType
,aCommandURLSequence
,aGraphicSequence
);
164 void SAL_CALL
ModuleImageManager::addConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
165 throw (::com::sun::star::uno::RuntimeException
)
167 m_pImpl
->addConfigurationListener(xListener
);
170 void SAL_CALL
ModuleImageManager::removeConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
171 throw (::com::sun::star::uno::RuntimeException
)
173 m_pImpl
->removeConfigurationListener(xListener
);
176 // XUIConfigurationPersistence
177 void SAL_CALL
ModuleImageManager::reload()
178 throw ( ::com::sun::star::uno::Exception
,
179 ::com::sun::star::uno::RuntimeException
)
184 void SAL_CALL
ModuleImageManager::store()
185 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
190 void SAL_CALL
ModuleImageManager::storeToStorage( const uno::Reference
< XStorage
>& Storage
)
191 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
193 m_pImpl
->storeToStorage(Storage
);
196 sal_Bool SAL_CALL
ModuleImageManager::isModified()
197 throw (::com::sun::star::uno::RuntimeException
)
199 return m_pImpl
->isModified();
202 sal_Bool SAL_CALL
ModuleImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException
)
204 return m_pImpl
->isReadOnly();
207 } // namespace framework
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */