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() 102 { 103 m_pImpl->dispose(); 104 } 105 106 void SAL_CALL ModuleImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) 107 { 108 m_pImpl->addEventListener(xListener); 109 } 110 111 void SAL_CALL ModuleImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) 112 { 113 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 114 m_pImpl->removeEventListener(xListener); 115 } 116 117 // XInitialization 118 void SAL_CALL ModuleImageManager::initialize( const Sequence< Any >& aArguments ) 119 { 120 m_pImpl->initialize(aArguments); 121 } 122 123 // XImageManager 124 void SAL_CALL ModuleImageManager::reset() 125 { 126 m_pImpl->reset(); 127 } 128 129 Sequence< ::rtl::OUString > SAL_CALL ModuleImageManager::getAllImageNames( ::sal_Int16 nImageType ) 130 { 131 return m_pImpl->getAllImageNames( nImageType ); 132 } 133 134 ::sal_Bool SAL_CALL ModuleImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL ) 135 { 136 return m_pImpl->hasImage(nImageType,aCommandURL); 137 } 138 139 Sequence< uno::Reference< XGraphic > > SAL_CALL ModuleImageManager::getImages( 140 ::sal_Int16 nImageType, 141 const Sequence< ::rtl::OUString >& aCommandURLSequence ) 142 { 143 RTL_LOGFILE_CONTEXT( aLog, "framework: ModuleImageManager::getImages" ); 144 return m_pImpl->getImages(nImageType,aCommandURLSequence); 145 } 146 147 void SAL_CALL ModuleImageManager::replaceImages( 148 ::sal_Int16 nImageType, 149 const Sequence< ::rtl::OUString >& aCommandURLSequence, 150 const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) 151 { 152 m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence); 153 } 154 155 void SAL_CALL ModuleImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence ) 156 { 157 m_pImpl->removeImages(nImageType,aCommandURLSequence); 158 } 159 160 void SAL_CALL ModuleImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence ) 161 { 162 m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence); 163 } 164 165 // XUIConfiguration 166 void SAL_CALL ModuleImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 167 { 168 m_pImpl->addConfigurationListener(xListener); 169 } 170 171 void SAL_CALL ModuleImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) 172 { 173 m_pImpl->removeConfigurationListener(xListener); 174 } 175 176 // XUIConfigurationPersistence 177 void SAL_CALL ModuleImageManager::reload() 178 { 179 m_pImpl->reload(); 180 } 181 182 void SAL_CALL ModuleImageManager::store() 183 { 184 m_pImpl->store(); 185 } 186 187 void SAL_CALL ModuleImageManager::storeToStorage( const uno::Reference< XStorage >& Storage ) 188 { 189 m_pImpl->storeToStorage(Storage); 190 } 191 192 sal_Bool SAL_CALL ModuleImageManager::isModified() 193 { 194 return m_pImpl->isModified(); 195 } 196 197 sal_Bool SAL_CALL ModuleImageManager::isReadOnly() 198 { 199 return m_pImpl->isReadOnly(); 200 } 201 202 } // namespace framework 203