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