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 <uiconfiguration/imagemanager.hxx> 32*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 33*cdf0e10cSrcweir #include <xml/imagesconfiguration.hxx> 34*cdf0e10cSrcweir #include <uiconfiguration/graphicnameaccess.hxx> 35*cdf0e10cSrcweir #include <services.h> 36*cdf0e10cSrcweir #include "imagemanagerimpl.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include "properties.h" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 41*cdf0e10cSrcweir // interface includes 42*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43*cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 53*cdf0e10cSrcweir // other includes 54*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include <vcl/svapp.hxx> 57*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 58*cdf0e10cSrcweir #include <osl/mutex.hxx> 59*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 60*cdf0e10cSrcweir #include <tools/urlobj.hxx> 61*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 62*cdf0e10cSrcweir #include <vcl/pngread.hxx> 63*cdf0e10cSrcweir #include <vcl/pngwrite.hxx> 64*cdf0e10cSrcweir #include <rtl/logfile.hxx> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 67*cdf0e10cSrcweir // namespaces 68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir using ::rtl::OUString; 71*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 72*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 73*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 74*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 75*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 76*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 77*cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 78*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 79*cdf0e10cSrcweir using namespace ::com::sun::star; 80*cdf0e10cSrcweir using namespace ::com::sun::star::io; 81*cdf0e10cSrcweir using namespace ::com::sun::star::embed; 82*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 83*cdf0e10cSrcweir using namespace ::com::sun::star::container; 84*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 85*cdf0e10cSrcweir using namespace ::com::sun::star::ui; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // Image sizes for our toolbars/menus 88*cdf0e10cSrcweir const sal_Int32 IMAGE_SIZE_NORMAL = 16; 89*cdf0e10cSrcweir const sal_Int32 IMAGE_SIZE_LARGE = 26; 90*cdf0e10cSrcweir const sal_Int16 MAX_IMAGETYPE_VALUE = ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST| 91*cdf0e10cSrcweir ::com::sun::star::ui::ImageType::SIZE_LARGE; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir namespace framework 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir typedef GraphicNameAccess CmdToXGraphicNameAccess; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir //***************************************************************************************************************** 99*cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 100*cdf0e10cSrcweir //***************************************************************************************************************** 101*cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager , 102*cdf0e10cSrcweir ::cppu::OWeakObject , 103*cdf0e10cSrcweir SERVICENAME_IMAGEMANAGER , 104*cdf0e10cSrcweir IMPLEMENTATIONNAME_IMAGEMANAGER 105*cdf0e10cSrcweir ) 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir DEFINE_INIT_SERVICE ( ImageManager, {} ) 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir ImageManager::ImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) : 110*cdf0e10cSrcweir ThreadHelpBase( &Application::GetSolarMutex() ) 111*cdf0e10cSrcweir , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),false) ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir ImageManager::~ImageManager() 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir m_pImpl->clear(); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // XComponent 121*cdf0e10cSrcweir void SAL_CALL ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir m_pImpl->dispose(); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir void SAL_CALL ImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir m_pImpl->addEventListener(xListener); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir void SAL_CALL ImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 134*cdf0e10cSrcweir m_pImpl->removeEventListener(xListener); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // Non-UNO methods 138*cdf0e10cSrcweir void ImageManager::setStorage( const uno::Reference< XStorage >& Storage ) 139*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir ResetableGuard aLock( m_pImpl->m_aLock ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir m_pImpl->m_xUserConfigStorage = Storage; 144*cdf0e10cSrcweir m_pImpl->implts_initialize(); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // XInitialization 148*cdf0e10cSrcweir void SAL_CALL ImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir m_pImpl->initialize(aArguments); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // XImageManager 154*cdf0e10cSrcweir void SAL_CALL ImageManager::reset() 155*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 159*cdf0e10cSrcweir m_pImpl->reset(); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ImageManager::getAllImageNames( ::sal_Int16 nImageType ) 163*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir return m_pImpl->getAllImageNames( nImageType ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir ::sal_Bool SAL_CALL ImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) 169*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir return m_pImpl->hasImage(nImageType,aCommandURL); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir Sequence< uno::Reference< XGraphic > > SAL_CALL ImageManager::getImages( 175*cdf0e10cSrcweir ::sal_Int16 nImageType, 176*cdf0e10cSrcweir const Sequence< ::rtl::OUString >& aCommandURLSequence ) 177*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return m_pImpl->getImages(nImageType,aCommandURLSequence); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir void SAL_CALL ImageManager::replaceImages( 183*cdf0e10cSrcweir ::sal_Int16 nImageType, 184*cdf0e10cSrcweir const Sequence< ::rtl::OUString >& aCommandURLSequence, 185*cdf0e10cSrcweir const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) 186*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, 187*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 188*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir void SAL_CALL ImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence ) 194*cdf0e10cSrcweir throw ( ::com::sun::star::lang::IllegalArgumentException, 195*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 196*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir m_pImpl->removeImages(nImageType,aCommandURLSequence); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void SAL_CALL ImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence ) 202*cdf0e10cSrcweir throw ( ::com::sun::star::container::ElementExistException, 203*cdf0e10cSrcweir ::com::sun::star::lang::IllegalArgumentException, 204*cdf0e10cSrcweir ::com::sun::star::lang::IllegalAccessException, 205*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir // XUIConfiguration 211*cdf0e10cSrcweir void SAL_CALL ImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 212*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir m_pImpl->addConfigurationListener(xListener); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void SAL_CALL ImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 218*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 221*cdf0e10cSrcweir m_pImpl->removeConfigurationListener(xListener); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // XUIConfigurationPersistence 225*cdf0e10cSrcweir void SAL_CALL ImageManager::reload() 226*cdf0e10cSrcweir throw ( ::com::sun::star::uno::Exception, 227*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir m_pImpl->reload(); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir void SAL_CALL ImageManager::store() 233*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir m_pImpl->store(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void SAL_CALL ImageManager::storeToStorage( const uno::Reference< XStorage >& Storage ) 239*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir m_pImpl->storeToStorage(Storage); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir sal_Bool SAL_CALL ImageManager::isModified() 245*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir return m_pImpl->isModified(); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir sal_Bool SAL_CALL ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir return m_pImpl->isReadOnly(); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir } // namespace framework 256