Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <uiconfiguration/imagemanager.hxx>
31 : : #include <threadhelp/resetableguard.hxx>
32 : : #include <xml/imagesconfiguration.hxx>
33 : : #include <uiconfiguration/graphicnameaccess.hxx>
34 : : #include <services.h>
35 : : #include "imagemanagerimpl.hxx"
36 : :
37 : : #include "properties.h"
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 : : #include <vcl/svapp.hxx>
49 : : #include <rtl/ustrbuf.hxx>
50 : : #include <osl/mutex.hxx>
51 : : #include <comphelper/sequence.hxx>
52 : : #include <unotools/ucbstreamhelper.hxx>
53 : : #include <vcl/pngread.hxx>
54 : : #include <vcl/pngwrite.hxx>
55 : : #include <rtl/logfile.hxx>
56 : :
57 : : //_________________________________________________________________________________________________________________
58 : : // namespaces
59 : : //_________________________________________________________________________________________________________________
60 : :
61 : : using ::rtl::OUString;
62 : : using ::com::sun::star::uno::Sequence;
63 : : using ::com::sun::star::uno::XInterface;
64 : : using ::com::sun::star::uno::Exception;
65 : : using ::com::sun::star::uno::RuntimeException;
66 : : using ::com::sun::star::uno::UNO_QUERY;
67 : : using ::com::sun::star::uno::Any;
68 : : using ::com::sun::star::uno::makeAny;
69 : : using ::com::sun::star::graphic::XGraphic;
70 : : using namespace ::com::sun::star;
71 : : using namespace ::com::sun::star::io;
72 : : using namespace ::com::sun::star::embed;
73 : : using namespace ::com::sun::star::lang;
74 : : using namespace ::com::sun::star::container;
75 : : using namespace ::com::sun::star::beans;
76 : : using namespace ::com::sun::star::ui;
77 : :
78 : : // Image sizes for our toolbars/menus
79 : : const sal_Int32 IMAGE_SIZE_NORMAL = 16;
80 : : const sal_Int32 IMAGE_SIZE_LARGE = 26;
81 : : const sal_Int16 MAX_IMAGETYPE_VALUE = ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST|
82 : : ::com::sun::star::ui::ImageType::SIZE_LARGE;
83 : :
84 : : namespace framework
85 : : {
86 : :
87 : : //*****************************************************************************************************************
88 : : // XInterface, XTypeProvider, XServiceInfo
89 : : //*****************************************************************************************************************
90 [ # # ][ # # ]: 504 : DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager ,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
91 : : ::cppu::OWeakObject ,
92 : : SERVICENAME_IMAGEMANAGER ,
93 : : IMPLEMENTATIONNAME_IMAGEMANAGER
94 : : )
95 : :
96 : 0 : DEFINE_INIT_SERVICE ( ImageManager, {} )
97 : :
98 : 1689 : ImageManager::ImageManager( uno::Reference< XMultiServiceFactory > xServiceManager ) :
99 : 1689 : ThreadHelpBase( &Application::GetSolarMutex() )
100 [ + - ][ + - ]: 1689 : , m_pImpl( new ImageManagerImpl(xServiceManager,false) )
[ + - ]
101 : : {
102 : 1689 : }
103 : :
104 [ + - ][ + - ]: 1598 : ImageManager::~ImageManager()
105 : : {
106 [ + - ]: 1598 : m_pImpl->clear();
107 [ - + ]: 3196 : }
108 : :
109 : : // XComponent
110 : 0 : void SAL_CALL ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
111 : : {
112 [ # # ]: 0 : m_pImpl->dispose(static_cast< OWeakObject* >(this));
113 : 0 : }
114 : :
115 : 0 : void SAL_CALL ImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
116 : : {
117 : 0 : m_pImpl->addEventListener(xListener);
118 : 0 : }
119 : :
120 : 0 : void SAL_CALL ImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
121 : : {
122 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
123 : 0 : m_pImpl->removeEventListener(xListener);
124 : 0 : }
125 : :
126 : : // Non-UNO methods
127 : 16 : void ImageManager::setStorage( const uno::Reference< XStorage >& Storage )
128 : : throw (::com::sun::star::uno::RuntimeException)
129 : : {
130 [ + - ]: 16 : ResetableGuard aLock( m_pImpl->m_aLock );
131 : :
132 [ + - ]: 16 : m_pImpl->m_xUserConfigStorage = Storage;
133 [ + - ][ + - ]: 16 : m_pImpl->implts_initialize();
134 : 16 : }
135 : :
136 : : // XInitialization
137 : 1689 : void SAL_CALL ImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
138 : : {
139 : 1689 : m_pImpl->initialize(aArguments);
140 : 1689 : }
141 : :
142 : : // XImageManager
143 : 0 : void SAL_CALL ImageManager::reset()
144 : : throw (::com::sun::star::uno::RuntimeException)
145 : : {
146 : :
147 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
148 [ # # ]: 0 : m_pImpl->reset(static_cast< OWeakObject* >(this));
149 : 0 : }
150 : :
151 : 0 : Sequence< ::rtl::OUString > SAL_CALL ImageManager::getAllImageNames( ::sal_Int16 nImageType )
152 : : throw (::com::sun::star::uno::RuntimeException)
153 : : {
154 : 0 : return m_pImpl->getAllImageNames( nImageType );
155 : : }
156 : :
157 : 0 : ::sal_Bool SAL_CALL ImageManager::hasImage( ::sal_Int16 nImageType, const ::rtl::OUString& aCommandURL )
158 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
159 : : {
160 : 0 : return m_pImpl->hasImage(nImageType,aCommandURL);
161 : : }
162 : :
163 : 17806 : Sequence< uno::Reference< XGraphic > > SAL_CALL ImageManager::getImages(
164 : : ::sal_Int16 nImageType,
165 : : const Sequence< ::rtl::OUString >& aCommandURLSequence )
166 : : throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
167 : : {
168 : 17806 : return m_pImpl->getImages(nImageType,aCommandURLSequence);
169 : : }
170 : :
171 : 0 : void SAL_CALL ImageManager::replaceImages(
172 : : ::sal_Int16 nImageType,
173 : : const Sequence< ::rtl::OUString >& aCommandURLSequence,
174 : : const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence )
175 : : throw ( ::com::sun::star::lang::IllegalArgumentException,
176 : : ::com::sun::star::lang::IllegalAccessException,
177 : : ::com::sun::star::uno::RuntimeException)
178 : : {
179 [ # # ]: 0 : m_pImpl->replaceImages(static_cast< OWeakObject* >(this),nImageType,aCommandURLSequence,aGraphicsSequence);
180 : 0 : }
181 : :
182 : 0 : void SAL_CALL ImageManager::removeImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence )
183 : : throw ( ::com::sun::star::lang::IllegalArgumentException,
184 : : ::com::sun::star::lang::IllegalAccessException,
185 : : ::com::sun::star::uno::RuntimeException)
186 : : {
187 [ # # ]: 0 : m_pImpl->removeImages(static_cast< OWeakObject* >(this),nImageType,aCommandURLSequence);
188 : 0 : }
189 : :
190 : 0 : void SAL_CALL ImageManager::insertImages( ::sal_Int16 nImageType, const Sequence< ::rtl::OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicSequence )
191 : : throw ( ::com::sun::star::container::ElementExistException,
192 : : ::com::sun::star::lang::IllegalArgumentException,
193 : : ::com::sun::star::lang::IllegalAccessException,
194 : : ::com::sun::star::uno::RuntimeException)
195 : : {
196 [ # # ]: 0 : m_pImpl->insertImages(static_cast< OWeakObject* >(this),nImageType,aCommandURLSequence,aGraphicSequence);
197 : 0 : }
198 : :
199 : : // XUIConfiguration
200 : 45781 : void SAL_CALL ImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
201 : : throw (::com::sun::star::uno::RuntimeException)
202 : : {
203 : 45781 : m_pImpl->addConfigurationListener(xListener);
204 : 45781 : }
205 : :
206 : 45690 : void SAL_CALL ImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
207 : : throw (::com::sun::star::uno::RuntimeException)
208 : : {
209 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
210 : 45690 : m_pImpl->removeConfigurationListener(xListener);
211 : 45690 : }
212 : :
213 : : // XUIConfigurationPersistence
214 : 0 : void SAL_CALL ImageManager::reload()
215 : : throw ( ::com::sun::star::uno::Exception,
216 : : ::com::sun::star::uno::RuntimeException )
217 : : {
218 [ # # ]: 0 : m_pImpl->reload(static_cast< OWeakObject* >(this));
219 : 0 : }
220 : :
221 : 0 : void SAL_CALL ImageManager::store()
222 : : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
223 : : {
224 : 0 : m_pImpl->store();
225 : 0 : }
226 : :
227 : 0 : void SAL_CALL ImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
228 : : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
229 : : {
230 : 0 : m_pImpl->storeToStorage(Storage);
231 : 0 : }
232 : :
233 : 0 : sal_Bool SAL_CALL ImageManager::isModified()
234 : : throw (::com::sun::star::uno::RuntimeException)
235 : : {
236 : 0 : return m_pImpl->isModified();
237 : : }
238 : :
239 : 0 : sal_Bool SAL_CALL ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
240 : : {
241 : 0 : return m_pImpl->isReadOnly();
242 : : }
243 : :
244 : : } // namespace framework
245 : :
246 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|