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