Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <uiconfiguration/imagemanager.hxx>
22 : #include <threadhelp/resetableguard.hxx>
23 : #include <xml/imagesconfiguration.hxx>
24 : #include <uiconfiguration/graphicnameaccess.hxx>
25 : #include <services.h>
26 : #include "imagemanagerimpl.hxx"
27 :
28 : #include "properties.h"
29 :
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>
38 :
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>
47 :
48 : //_________________________________________________________________________________________________________________
49 : // namespaces
50 : //_________________________________________________________________________________________________________________
51 :
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;
67 :
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;
73 :
74 : namespace framework
75 : {
76 :
77 : #define SERVICENAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.ui.ImageManager" )
78 : #define IMPLEMENTATIONNAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.comp.framework.ImageManager" )
79 :
80 : //*****************************************************************************************************************
81 : // XInterface, XTypeProvider, XServiceInfo
82 : //*****************************************************************************************************************
83 381 : DEFINE_XSERVICEINFO_MULTISERVICE_2 ( ImageManager ,
84 : ::cppu::OWeakObject ,
85 : SERVICENAME_IMAGEMANAGER ,
86 : IMPLEMENTATIONNAME_IMAGEMANAGER
87 : )
88 :
89 0 : DEFINE_INIT_SERVICE ( ImageManager, {} )
90 :
91 1061 : ImageManager::ImageManager( const uno::Reference< uno::XComponentContext >& rxContext ) :
92 1061 : ThreadHelpBase( &Application::GetSolarMutex() )
93 1061 : , m_pImpl( new ImageManagerImpl(rxContext, this, false) )
94 : {
95 1061 : }
96 :
97 3177 : ImageManager::~ImageManager()
98 : {
99 1059 : m_pImpl->clear();
100 2118 : }
101 :
102 : // XComponent
103 0 : void SAL_CALL ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException)
104 : {
105 0 : m_pImpl->dispose();
106 0 : }
107 :
108 0 : void SAL_CALL ImageManager::addEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
109 : {
110 0 : m_pImpl->addEventListener(xListener);
111 0 : }
112 :
113 0 : void SAL_CALL ImageManager::removeEventListener( const uno::Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
114 : {
115 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
116 0 : m_pImpl->removeEventListener(xListener);
117 0 : }
118 :
119 : // Non-UNO methods
120 8 : void ImageManager::setStorage( const uno::Reference< XStorage >& Storage )
121 : throw (::com::sun::star::uno::RuntimeException)
122 : {
123 8 : ResetableGuard aLock( m_pImpl->m_aLock );
124 :
125 8 : m_pImpl->m_xUserConfigStorage = Storage;
126 8 : m_pImpl->implts_initialize();
127 8 : }
128 :
129 : // XInitialization
130 1061 : void SAL_CALL ImageManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
131 : {
132 1061 : m_pImpl->initialize(aArguments);
133 1061 : }
134 :
135 : // XImageManager
136 0 : void SAL_CALL ImageManager::reset()
137 : throw (::com::sun::star::uno::RuntimeException)
138 : {
139 :
140 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
141 0 : m_pImpl->reset();
142 0 : }
143 :
144 0 : Sequence< OUString > SAL_CALL ImageManager::getAllImageNames( ::sal_Int16 nImageType )
145 : throw (::com::sun::star::uno::RuntimeException)
146 : {
147 0 : return m_pImpl->getAllImageNames( nImageType );
148 : }
149 :
150 0 : ::sal_Bool SAL_CALL ImageManager::hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL )
151 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
152 : {
153 0 : return m_pImpl->hasImage(nImageType,aCommandURL);
154 : }
155 :
156 18072 : 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 )
160 : {
161 18072 : return m_pImpl->getImages(nImageType,aCommandURLSequence);
162 : }
163 :
164 0 : 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)
171 : {
172 0 : m_pImpl->replaceImages(nImageType,aCommandURLSequence,aGraphicsSequence);
173 0 : }
174 :
175 0 : 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)
179 : {
180 0 : m_pImpl->removeImages(nImageType,aCommandURLSequence);
181 0 : }
182 :
183 0 : 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)
188 : {
189 0 : m_pImpl->insertImages(nImageType,aCommandURLSequence,aGraphicSequence);
190 0 : }
191 :
192 : // XUIConfiguration
193 25164 : void SAL_CALL ImageManager::addConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
194 : throw (::com::sun::star::uno::RuntimeException)
195 : {
196 25164 : m_pImpl->addConfigurationListener(xListener);
197 25164 : }
198 :
199 25162 : void SAL_CALL ImageManager::removeConfigurationListener( const uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener )
200 : throw (::com::sun::star::uno::RuntimeException)
201 : {
202 : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
203 25162 : m_pImpl->removeConfigurationListener(xListener);
204 25162 : }
205 :
206 : // XUIConfigurationPersistence
207 0 : void SAL_CALL ImageManager::reload()
208 : throw ( ::com::sun::star::uno::Exception,
209 : ::com::sun::star::uno::RuntimeException )
210 : {
211 0 : m_pImpl->reload();
212 0 : }
213 :
214 0 : void SAL_CALL ImageManager::store()
215 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
216 : {
217 0 : m_pImpl->store();
218 0 : }
219 :
220 0 : void SAL_CALL ImageManager::storeToStorage( const uno::Reference< XStorage >& Storage )
221 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
222 : {
223 0 : m_pImpl->storeToStorage(Storage);
224 0 : }
225 :
226 0 : sal_Bool SAL_CALL ImageManager::isModified()
227 : throw (::com::sun::star::uno::RuntimeException)
228 : {
229 0 : return m_pImpl->isModified();
230 : }
231 :
232 0 : sal_Bool SAL_CALL ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
233 : {
234 0 : return m_pImpl->isReadOnly();
235 : }
236 :
237 402 : } // namespace framework
238 :
239 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|