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