1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_framework.hxx" 26 27 #include <rtl/logfile.hxx> 28 #include <uiconfiguration/moduleimagemanager.hxx> 29 #include <threadhelp/resetableguard.hxx> 30 #include <xml/imagesconfiguration.hxx> 31 #include <uiconfiguration/graphicnameaccess.hxx> 32 #include <services.h> 33 #include "imagemanagerimpl.hxx" 34 35 #include "properties.h" 36 37 //_________________________________________________________________________________________________________________ 38 // interface includes 39 //_________________________________________________________________________________________________________________ 40 #include <com/sun/star/ui/UIElementType.hpp> 41 #include <com/sun/star/ui/ConfigurationEvent.hpp> 42 #include <com/sun/star/lang/DisposedException.hpp> 43 #include <com/sun/star/beans/XPropertySet.hpp> 44 #include <com/sun/star/beans/PropertyValue.hpp> 45 #include <com/sun/star/embed/ElementModes.hpp> 46 #include <com/sun/star/io/XStream.hpp> 47 #include <com/sun/star/ui/ImageType.hpp> 48 #include <com/sun/star/uri/XUriReferenceFactory.hpp> 49 #include <com/sun/star/uri/XUriReference.hpp> 50 #include <com/sun/star/uno/XComponentContext.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 <osl/file.hxx> 60 #include <comphelper/sequence.hxx> 61 #include <tools/urlobj.hxx> 62 #include <unotools/ucbstreamhelper.hxx> 63 #include <vcl/pngread.hxx> 64 #include <vcl/pngwrite.hxx> 65 #include <rtl/logfile.hxx> 66 67 //_________________________________________________________________________________________________________________ 68 // namespaces 69 //_________________________________________________________________________________________________________________ 70 71 using ::rtl::OUString; 72 using ::com::sun::star::uno::Sequence; 73 using ::com::sun::star::uno::XInterface; 74 using ::com::sun::star::uno::Exception; 75 using ::com::sun::star::uno::RuntimeException; 76 using ::com::sun::star::uno::UNO_QUERY; 77 using ::com::sun::star::uno::Any; 78 using ::com::sun::star::uno::makeAny; 79 using ::com::sun::star::graphic::XGraphic; 80 using namespace ::com::sun::star; 81 using namespace ::com::sun::star::io; 82 using namespace ::com::sun::star::embed; 83 using namespace ::com::sun::star::lang; 84 using namespace ::com::sun::star::container; 85 using namespace ::com::sun::star::beans; 86 using namespace ::com::sun::star::ui; 87 88 namespace framework 89 { 90 ModuleImageManager::ModuleImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) : 91 ThreadHelpBase( &Application::GetSolarMutex() ) 92 , m_pImpl( new ImageManagerImpl(xServiceManager,static_cast< OWeakObject* >(this),true) ) 93 { 94 } 95 96 ModuleImageManager::~ModuleImageManager() 97 { 98 } 99 100 // XComponent 101 void SAL_CALL ModuleImageManager::dispose() throw (::com::sun::star::uno::RuntimeException) 102 { 103 m_pImpl->dispose(); 104 } 105 106 void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 107 { 108 m_pImpl->addEventListener(xListener); 109 } 110 111 void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 112 { 113 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 114 m_pImpl->removeEventListener(xListener); 115 } 116 117 // XInitialization 118 void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) 119 { 120 m_pImpl->initialize(aArguments); 121 } 122 123 // XImageManager 124 void SAL_CALL ModuleImageManager::reset() 125 throw (::com::sun::star::uno::RuntimeException) 126 { 127 m_pImpl->reset(); 128 } 129 130 Sequence< ::rtl::OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType ) 131 throw (::com::sun::star::uno::RuntimeException) 132 { 133 return m_pImpl->getAllImageNames( nImageType ); 134 } 135 136 ::sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) 137 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 138 { 139 return m_pImpl->hasImage(nImageType,aCommandURL); 140 } 141 142 Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages( 143 ::sal_Int16 nImageType, 144 const Sequence< ::rtl::OUString >& aCommandURLSequence ) 145 throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) 146 { 147 RTL_LOGFILE_CONTEXT( aLog, "framework: ModuleImageManager::getImages" ); 148 return m_pImpl->getImages(nImageType,aCommandURLSequence); 149 } 150 151 void SAL_CALL ModuleImageManager::replaceImages( 152 ::sal_Int16 nImageType, 153 const Sequence< ::rtl::OUString >& aCommandURLSequence, 154 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) 155 throw ( ::com::sun::star::lang::IllegalArgumentException, 156 ::com::sun::star::lang::IllegalAccessException, 157 ::com::sun::star::uno::RuntimeException) 158 { 159 m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence); 160 } 161 162 void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence ) 163 throw ( ::com::sun::star::lang::IllegalArgumentException, 164 ::com::sun::star::lang::IllegalAccessException, 165 ::com::sun::star::uno::RuntimeException) 166 { 167 m_pImpl->removeImages(nImageType,aCommandURLSequence); 168 } 169 170 void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence ) 171 throw ( ::com::sun::star::container::ElementExistException, 172 ::com::sun::star::lang::IllegalArgumentException, 173 ::com::sun::star::lang::IllegalAccessException, 174 ::com::sun::star::uno::RuntimeException) 175 { 176 m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence); 177 } 178 179 // XUIConfiguration 180 void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 181 throw (::com::sun::star::uno::RuntimeException) 182 { 183 m_pImpl->addConfigurationListener(xListener); 184 } 185 186 void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 187 throw (::com::sun::star::uno::RuntimeException) 188 { 189 m_pImpl->removeConfigurationListener(xListener); 190 } 191 192 // XUIConfigurationPersistence 193 void SAL_CALL ModuleImageManager::reload() 194 throw ( ::com::sun::star::uno::Exception, 195 ::com::sun::star::uno::RuntimeException ) 196 { 197 m_pImpl->reload(); 198 } 199 200 void SAL_CALL ModuleImageManager::store() 201 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 202 { 203 m_pImpl->store(); 204 } 205 206 void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage ) 207 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 208 { 209 m_pImpl->storeToStorage(Storage); 210 } 211 212 sal_Bool SAL_CALL ModuleImageManager::isModified() 213 throw (::com::sun::star::uno::RuntimeException) 214 { 215 return m_pImpl->isModified(); 216 } 217 218 sal_Bool SAL_CALL ModuleImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException) 219 { 220 return m_pImpl->isReadOnly(); 221 } 222 223 } // namespace framework 224