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