1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
30 #include <uiconfiguration/imagemanager.hxx>
31 #include <threadhelp/resetableguard.hxx>
32 #include <xml/imagesconfiguration.hxx>
33 #include <uiconfiguration/graphicnameaccess.hxx>
35 #include "imagemanagerimpl.hxx"
37 #include "properties.h"
39 //_________________________________________________________________________________________________________________
41 //_________________________________________________________________________________________________________________
42 #include <com/sun/star/ui/UIElementType.hpp>
43 #include <com/sun/star/ui/ConfigurationEvent.hpp>
44 #include <com/sun/star/lang/DisposedException.hpp>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <com/sun/star/embed/ElementModes.hpp>
48 #include <com/sun/star/io/XStream.hpp>
49 #include <com/sun/star/ui/ImageType.hpp>
51 //_________________________________________________________________________________________________________________
53 //_________________________________________________________________________________________________________________
55 #include <vcl/svapp.hxx>
56 #include <rtl/ustrbuf.hxx>
57 #include <osl/mutex.hxx>
58 #include <comphelper/sequence.hxx>
59 #include <tools/urlobj.hxx>
60 #include <unotools/ucbstreamhelper.hxx>
61 #include <vcl/pngread.hxx>
62 #include <vcl/pngwrite.hxx>
63 #include <rtl/logfile.hxx>
65 //_________________________________________________________________________________________________________________
67 //_________________________________________________________________________________________________________________
69 using ::rtl::OUString
;
70 using ::com::sun::star::uno::Sequence
;
71 using ::com::sun::star::uno::XInterface
;
72 using ::com::sun::star::uno::Exception
;
73 using ::com::sun::star::uno::RuntimeException
;
74 using ::com::sun::star::uno::UNO_QUERY
;
75 using ::com::sun::star::uno::Any
;
76 using ::com::sun::star::uno::makeAny
;
77 using ::com::sun::star::graphic::XGraphic
;
78 using namespace ::com::sun::star
;
79 using namespace ::com::sun::star::io
;
80 using namespace ::com::sun::star::embed
;
81 using namespace ::com::sun::star::lang
;
82 using namespace ::com::sun::star::container
;
83 using namespace ::com::sun::star::beans
;
84 using namespace ::com::sun::star::ui
;
86 // Image sizes for our toolbars/menus
87 const sal_Int32 IMAGE_SIZE_NORMAL
= 16;
88 const sal_Int32 IMAGE_SIZE_LARGE
= 26;
89 const sal_Int16 MAX_IMAGETYPE_VALUE
= ::com::sun::star::ui::ImageType::COLOR_HIGHCONTRAST
|
90 ::com::sun::star::ui::ImageType::SIZE_LARGE
;
95 typedef GraphicNameAccess CmdToXGraphicNameAccess
;
97 //*****************************************************************************************************************
98 // XInterface, XTypeProvider, XServiceInfo
99 //*****************************************************************************************************************
100 DEFINE_XSERVICEINFO_MULTISERVICE ( ImageManager
,
101 ::cppu::OWeakObject
,
102 SERVICENAME_IMAGEMANAGER
,
103 IMPLEMENTATIONNAME_IMAGEMANAGER
106 DEFINE_INIT_SERVICE ( ImageManager
, {} )
108 ImageManager::ImageManager( uno::Reference
< XMultiServiceFactory
> xServiceManager
) :
109 ThreadHelpBase( &Application::GetSolarMutex() )
110 , m_pImpl( new ImageManagerImpl(xServiceManager
,static_cast< OWeakObject
* >(this),false) )
114 ImageManager::~ImageManager()
120 void SAL_CALL
ImageManager::dispose() throw (::com::sun::star::uno::RuntimeException
)
125 void SAL_CALL
ImageManager::addEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
127 m_pImpl
->addEventListener(xListener
);
130 void SAL_CALL
ImageManager::removeEventListener( const uno::Reference
< XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
)
132 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
133 m_pImpl
->removeEventListener(xListener
);
137 void ImageManager::setStorage( const uno::Reference
< XStorage
>& Storage
)
138 throw (::com::sun::star::uno::RuntimeException
)
140 ResetableGuard
aLock( m_pImpl
->m_aLock
);
142 m_pImpl
->m_xUserConfigStorage
= Storage
;
143 m_pImpl
->implts_initialize();
147 void SAL_CALL
ImageManager::initialize( const Sequence
< Any
>& aArguments
) throw ( Exception
, RuntimeException
)
149 m_pImpl
->initialize(aArguments
);
153 void SAL_CALL
ImageManager::reset()
154 throw (::com::sun::star::uno::RuntimeException
)
157 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
161 Sequence
< ::rtl::OUString
> SAL_CALL
ImageManager::getAllImageNames( ::sal_Int16 nImageType
)
162 throw (::com::sun::star::uno::RuntimeException
)
164 return m_pImpl
->getAllImageNames( nImageType
);
167 ::sal_Bool SAL_CALL
ImageManager::hasImage( ::sal_Int16 nImageType
, const ::rtl::OUString
& aCommandURL
)
168 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
170 return m_pImpl
->hasImage(nImageType
,aCommandURL
);
173 Sequence
< uno::Reference
< XGraphic
> > SAL_CALL
ImageManager::getImages(
174 ::sal_Int16 nImageType
,
175 const Sequence
< ::rtl::OUString
>& aCommandURLSequence
)
176 throw ( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
178 return m_pImpl
->getImages(nImageType
,aCommandURLSequence
);
181 void SAL_CALL
ImageManager::replaceImages(
182 ::sal_Int16 nImageType
,
183 const Sequence
< ::rtl::OUString
>& aCommandURLSequence
,
184 const Sequence
< uno::Reference
< XGraphic
> >& aGraphicsSequence
)
185 throw ( ::com::sun::star::lang::IllegalArgumentException
,
186 ::com::sun::star::lang::IllegalAccessException
,
187 ::com::sun::star::uno::RuntimeException
)
189 m_pImpl
->replaceImages(nImageType
,aCommandURLSequence
,aGraphicsSequence
);
192 void SAL_CALL
ImageManager::removeImages( ::sal_Int16 nImageType
, const Sequence
< ::rtl::OUString
>& aCommandURLSequence
)
193 throw ( ::com::sun::star::lang::IllegalArgumentException
,
194 ::com::sun::star::lang::IllegalAccessException
,
195 ::com::sun::star::uno::RuntimeException
)
197 m_pImpl
->removeImages(nImageType
,aCommandURLSequence
);
200 void SAL_CALL
ImageManager::insertImages( ::sal_Int16 nImageType
, const Sequence
< ::rtl::OUString
>& aCommandURLSequence
, const Sequence
< uno::Reference
< XGraphic
> >& aGraphicSequence
)
201 throw ( ::com::sun::star::container::ElementExistException
,
202 ::com::sun::star::lang::IllegalArgumentException
,
203 ::com::sun::star::lang::IllegalAccessException
,
204 ::com::sun::star::uno::RuntimeException
)
206 m_pImpl
->insertImages(nImageType
,aCommandURLSequence
,aGraphicSequence
);
210 void SAL_CALL
ImageManager::addConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
211 throw (::com::sun::star::uno::RuntimeException
)
213 m_pImpl
->addConfigurationListener(xListener
);
216 void SAL_CALL
ImageManager::removeConfigurationListener( const uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& xListener
)
217 throw (::com::sun::star::uno::RuntimeException
)
219 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
220 m_pImpl
->removeConfigurationListener(xListener
);
223 // XUIConfigurationPersistence
224 void SAL_CALL
ImageManager::reload()
225 throw ( ::com::sun::star::uno::Exception
,
226 ::com::sun::star::uno::RuntimeException
)
231 void SAL_CALL
ImageManager::store()
232 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
237 void SAL_CALL
ImageManager::storeToStorage( const uno::Reference
< XStorage
>& Storage
)
238 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
240 m_pImpl
->storeToStorage(Storage
);
243 sal_Bool SAL_CALL
ImageManager::isModified()
244 throw (::com::sun::star::uno::RuntimeException
)
246 return m_pImpl
->isModified();
249 sal_Bool SAL_CALL
ImageManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException
)
251 return m_pImpl
->isReadOnly();
254 } // namespace framework