1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <uiconfiguration/imagemanager.hxx>
22 #include <threadhelp/resetableguard.hxx>
23 #include <xml/imagesconfiguration.hxx>
24 #include <uiconfiguration/graphicnameaccess.hxx>
26 #include "imagemanagerimpl.hxx"
28 #include "properties.h"
30 #include <com/sun/star/ui/UIElementType.hpp>
31 #include <com/sun/star/ui/ConfigurationEvent.hpp>
32 #include <com/sun/star/lang/DisposedException.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/embed/ElementModes.hpp>
36 #include <com/sun/star/io/XStream.hpp>
37 #include <com/sun/star/ui/ImageType.hpp>
39 #include <vcl/svapp.hxx>
40 #include <rtl/ustrbuf.hxx>
41 #include <osl/mutex.hxx>
42 #include <comphelper/sequence.hxx>
43 #include <unotools/ucbstreamhelper.hxx>
44 #include <vcl/pngread.hxx>
45 #include <vcl/pngwrite.hxx>
46 #include <rtl/logfile.hxx>
48 //_________________________________________________________________________________________________________________
50 //_________________________________________________________________________________________________________________
52 using ::com::sun::star::uno::Sequence
;
53 using ::com::sun::star::uno::XInterface
;
54 using ::com::sun::star::uno::Exception
;
55 using ::com::sun::star::uno::RuntimeException
;
56 using ::com::sun::star::uno::UNO_QUERY
;
57 using ::com::sun::star::uno::Any
;
58 using ::com::sun::star::uno::makeAny
;
59 using ::com::sun::star::graphic::XGraphic
;
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::io
;
62 using namespace ::com::sun::star::embed
;
63 using namespace ::com::sun::star::lang
;
64 using namespace ::com::sun::star::container
;
65 using namespace ::com::sun::star::beans
;
66 using namespace ::com::sun::star::ui
;
68 // Image sizes for our toolbars/menus
69 const sal_Int32 IMAGE_SIZE_NORMAL
= 16;
70 const sal_Int32 IMAGE_SIZE_LARGE
= 26;
71 const sal_Int16 MAX_IMAGETYPE_VALUE
= ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST
|
72 ::com::sun::star::ui::ImageType::SIZE_LARGE
;
77 #define SERVICENAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.ui.ImageManager" )
78 #define IMPLEMENTATIONNAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ImageManager" )
80 //*****************************************************************************************************************
81 // XInterface, XTypeProvider, XServiceInfo
82 //*****************************************************************************************************************
83 DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager
,
85 SERVICENAME_IMAGEMANAGER
,
86 IMPLEMENTATIONNAME_IMAGEMANAGER
89 DEFINE_INIT_SERVICE ( ImageManager
, {} )
91 ImageManager::ImageManager( uno::Reference
< XMultiServiceFactory
> xServiceManager
) :
92 ThreadHelpBase( &Application::GetSolarMutex() )
93 , m_pImpl( new ImageManagerImpl(comphelper::getComponentContext(xServiceManager
),this,false) )
97 ImageManager::~ImageManager()
103 void SAL_CALL
ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException
)
108 void SAL_CALL
ImageManager::addEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
110 m_pImpl
->addEventListener(xListener
);
113 void SAL_CALL
ImageManager::removeEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
115 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
116 m_pImpl
->removeEventListener(xListener
);
120 void ImageManager::setStorage( const uno::Reference
< XStorage
>& Storage
)
121 throw (::com::sun::star::uno::RuntimeException
)
123 ResetableGuard
aLock( m_pImpl
->m_aLock
);
125 m_pImpl
->m_xUserConfigStorage
= Storage
;
126 m_pImpl
->implts_initialize();
130 void SAL_CALL
ImageManager::initialize( const Sequence
< Any
>& aArguments
) throw ( Exception
, RuntimeException
)
132 m_pImpl
->initialize(aArguments
);
136 void SAL_CALL
ImageManager::reset()
137 throw (::com::sun::star::uno::RuntimeException
)
140 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
144 Sequence
< OUString
> SAL_CALL
ImageManager::getAllImageNames( ::sal_Int16 nImageType
)
145 throw (::com::sun::star::uno::RuntimeException
)
147 return m_pImpl
->getAllImageNames( nImageType
);
150 ::sal_Bool SAL_CALL
ImageManager::hasImage( ::sal_Int16 nImageType
, const OUString
& aCommandURL
)
151 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
153 return m_pImpl
->hasImage(nImageType
,aCommandURL
);
156 Sequence
< uno::Reference
< XGraphic
> > SAL_CALL
ImageManager::getImages(
157 ::sal_Int16 nImageType
,
158 const Sequence
< OUString
>& aCommandURLSequence
)
159 throw ( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
161 return m_pImpl
->getImages(nImageType
,aCommandURLSequence
);
164 void SAL_CALL
ImageManager::replaceImages(
165 ::sal_Int16 nImageType
,
166 const Sequence
< OUString
>& aCommandURLSequence
,
167 const Sequence
< uno::Reference
< XGraphic
> >& aGraphicsSequence
)
168 throw ( ::com::sun::star::lang::IllegalArgumentException
,
169 ::com::sun::star::lang::IllegalAccessException
,
170 ::com::sun::star::uno::RuntimeException
)
172 m_pImpl
->replaceImages(nImageType
,aCommandURLSequence
,aGraphicsSequence
);
175 void SAL_CALL
ImageManager::removeImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
)
176 throw ( ::com::sun::star::lang::IllegalArgumentException
,
177 ::com::sun::star::lang::IllegalAccessException
,
178 ::com::sun::star::uno::RuntimeException
)
180 m_pImpl
->removeImages(nImageType
,aCommandURLSequence
);
183 void SAL_CALL
ImageManager::insertImages( ::sal_Int16 nImageType
, const Sequence
< OUString
>& aCommandURLSequence
, const Sequence
< uno::Reference
< XGraphic
> >& aGraphicSequence
)
184 throw ( ::com::sun::star::container::ElementExistException
,
185 ::com::sun::star::lang::IllegalArgumentException
,
186 ::com::sun::star::lang::IllegalAccessException
,
187 ::com::sun::star::uno::RuntimeException
)
189 m_pImpl
->insertImages(nImageType
,aCommandURLSequence
,aGraphicSequence
);
193 void SAL_CALL
ImageManager::addConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
194 throw (::com::sun::star::uno::RuntimeException
)
196 m_pImpl
->addConfigurationListener(xListener
);
199 void SAL_CALL
ImageManager::removeConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
200 throw (::com::sun::star::uno::RuntimeException
)
202 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
203 m_pImpl
->removeConfigurationListener(xListener
);
206 // XUIConfigurationPersistence
207 void SAL_CALL
ImageManager::reload()
208 throw ( ::com::sun::star::uno::Exception
,
209 ::com::sun::star::uno::RuntimeException
)
214 void SAL_CALL
ImageManager::store()
215 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
220 void SAL_CALL
ImageManager::storeToStorage( const uno::Reference
< XStorage
>& Storage
)
221 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
223 m_pImpl
->storeToStorage(Storage
);
226 sal_Bool SAL_CALL
ImageManager::isModified()
227 throw (::com::sun::star::uno::RuntimeException
)
229 return m_pImpl
->isModified();
232 sal_Bool SAL_CALL
ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException
)
234 return m_pImpl
->isReadOnly();
237 } // namespace framework
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */