1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_framework.hxx" 30 31 #include <rtl/logfile.hxx> 32 #include <uiconfiguration/moduleimagemanager.hxx> 33 #include <threadhelp/resetableguard.hxx> 34 #include <xml/imagesconfiguration.hxx> 35 #include <uiconfiguration/graphicnameaccess.hxx> 36 #include <services.h> 37 #include "imagemanagerimpl.hxx" 38 39 #include "properties.h" 40 41 //_________________________________________________________________________________________________________________ 42 // interface includes 43 //_________________________________________________________________________________________________________________ 44 #include <com/sun/star/ui/UIElementType.hpp> 45 #include <com/sun/star/ui/ConfigurationEvent.hpp> 46 #include <com/sun/star/lang/DisposedException.hpp> 47 #include <com/sun/star/beans/XPropertySet.hpp> 48 #include <com/sun/star/beans/PropertyValue.hpp> 49 #include <com/sun/star/embed/ElementModes.hpp> 50 #include <com/sun/star/io/XStream.hpp> 51 #include <com/sun/star/ui/ImageType.hpp> 52 #include <com/sun/star/uri/XUriReferenceFactory.hpp> 53 #include <com/sun/star/uri/XUriReference.hpp> 54 #include <com/sun/star/uno/XComponentContext.hpp> 55 56 //_________________________________________________________________________________________________________________ 57 // other includes 58 //_________________________________________________________________________________________________________________ 59 60 #include <vcl/svapp.hxx> 61 #include <rtl/ustrbuf.hxx> 62 #include <osl/mutex.hxx> 63 #include <osl/file.hxx> 64 #include <comphelper/sequence.hxx> 65 #include <tools/urlobj.hxx> 66 #include <unotools/ucbstreamhelper.hxx> 67 #include <vcl/pngread.hxx> 68 #include <vcl/pngwrite.hxx> 69 #include <rtl/logfile.hxx> 70 71 //_________________________________________________________________________________________________________________ 72 // namespaces 73 //_________________________________________________________________________________________________________________ 74 75 using ::rtl::OUString; 76 using ::com::sun::star::uno::Sequence; 77 using ::com::sun::star::uno::XInterface; 78 using ::com::sun::star::uno::Exception; 79 using ::com::sun::star::uno::RuntimeException; 80 using ::com::sun::star::uno::UNO_QUERY; 81 using ::com::sun::star::uno::Any; 82 using ::com::sun::star::uno::makeAny; 83 using ::com::sun::star::graphic::XGraphic; 84 using namespace ::com::sun::star; 85 using namespace ::com::sun::star::io; 86 using namespace ::com::sun::star::embed; 87 using namespace ::com::sun::star::lang; 88 using namespace ::com::sun::star::container; 89 using namespace ::com::sun::star::beans; 90 using namespace ::com::sun::star::ui; 91 92 namespace framework 93 { 94 ModuleImageManager::ModuleImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) : 95 ThreadHelpBase( &Application::GetSolarMutex() ) 96 , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),true) ) 97 { 98 } 99 100 ModuleImageManager::~ModuleImageManager() 101 { 102 } 103 104 // XComponent 105 void SAL_CALL ModuleImageManager::dispose() throw (::com::sun::star::uno::RuntimeException) 106 { 107 m_pImpl->dispose(); 108 } 109 110 void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 111 { 112 m_pImpl->addEventListener(xListener); 113 } 114 115 void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 116 { 117 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 118 m_pImpl->removeEventListener(xListener); 119 } 120 121 // XInitialization 122 void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) 123 { 124 m_pImpl->initialize(aArguments); 125 } 126 127 // XImageManager 128 void SAL_CALL ModuleImageManager::reset() 129 throw (::com::sun::star::uno::RuntimeException) 130 { 131 m_pImpl->reset(); 132 } 133 134 Sequence< ::rtl::OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType ) 135 throw (::com::sun::star::uno::RuntimeException) 136 { 137 return m_pImpl->getAllImageNames( nImageType ); 138 } 139 140 ::sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) 141 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 142 { 143 return m_pImpl->hasImage(nImageType,aCommandURL); 144 } 145 146 Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages( 147 ::sal_Int16 nImageType, 148 const Sequence< ::rtl::OUString >& aCommandURLSequence ) 149 throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) 150 { 151 RTL_LOGFILE_CONTEXT( aLog, "framework: ModuleImageManager::getImages" ); 152 return m_pImpl->getImages(nImageType,aCommandURLSequence); 153 } 154 155 void SAL_CALL ModuleImageManager::replaceImages( 156 ::sal_Int16 nImageType, 157 const Sequence< ::rtl::OUString >& aCommandURLSequence, 158 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) 159 throw ( ::com::sun::star::lang::IllegalArgumentException, 160 ::com::sun::star::lang::IllegalAccessException, 161 ::com::sun::star::uno::RuntimeException) 162 { 163 m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence); 164 } 165 166 void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence ) 167 throw ( ::com::sun::star::lang::IllegalArgumentException, 168 ::com::sun::star::lang::IllegalAccessException, 169 ::com::sun::star::uno::RuntimeException) 170 { 171 m_pImpl->removeImages(nImageType,aCommandURLSequence); 172 } 173 174 void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence ) 175 throw ( ::com::sun::star::container::ElementExistException, 176 ::com::sun::star::lang::IllegalArgumentException, 177 ::com::sun::star::lang::IllegalAccessException, 178 ::com::sun::star::uno::RuntimeException) 179 { 180 m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence); 181 } 182 183 // XUIConfiguration 184 void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 185 throw (::com::sun::star::uno::RuntimeException) 186 { 187 m_pImpl->addConfigurationListener(xListener); 188 } 189 190 void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 191 throw (::com::sun::star::uno::RuntimeException) 192 { 193 m_pImpl->removeConfigurationListener(xListener); 194 } 195 196 // XUIConfigurationPersistence 197 void SAL_CALL ModuleImageManager::reload() 198 throw ( ::com::sun::star::uno::Exception, 199 ::com::sun::star::uno::RuntimeException ) 200 { 201 m_pImpl->reload(); 202 } 203 204 void SAL_CALL ModuleImageManager::store() 205 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 206 { 207 m_pImpl->store(); 208 } 209 210 void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage ) 211 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 212 { 213 m_pImpl->storeToStorage(Storage); 214 } 215 216 sal_Bool SAL_CALL ModuleImageManager::isModified() 217 throw (::com::sun::star::uno::RuntimeException) 218 { 219 return m_pImpl->isModified(); 220 } 221 222 sal_Bool SAL_CALL ModuleImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException) 223 { 224 return m_pImpl->isReadOnly(); 225 } 226 227 } // namespace framework 228