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 .
20 #ifndef INCLUDED_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_UICONFIGURATION_IMAGEMANAGERIMPL_HXX
23 #include <macros/generic.hxx>
24 #include <macros/xinterface.hxx>
25 #include <macros/xtypeprovider.hxx>
26 #include <macros/xserviceinfo.hxx>
28 #include <uiconfiguration/imagetype.hxx>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <com/sun/star/lang/XComponent.hpp>
33 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
34 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
35 #include <com/sun/star/ui/XUIConfiguration.hpp>
36 #include <com/sun/star/ui/XImageManager.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/ui/ConfigurationEvent.hpp>
39 #include <com/sun/star/embed/XTransactedObject.hpp>
41 #include <cppuhelper/weak.hxx>
42 #include <cppuhelper/interfacecontainer.hxx>
43 #include <rtl/ustring.hxx>
45 #include <vcl/image.hxx>
46 #include <rtl/ref.hxx>
47 #include <salhelper/simplereferenceobject.hxx>
50 #include <unordered_map>
58 CmdImageList( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
,
59 const OUString
& aModuleIdentifier
);
60 virtual ~CmdImageList();
62 virtual Image
getImageFromCommandURL( sal_Int16 nImageType
, const OUString
& rCommandURL
);
63 virtual bool hasImage( sal_Int16 nImageType
, const OUString
& rCommandURL
);
64 virtual ::std::vector
< OUString
>& getImageNames();
65 virtual ::std::vector
< OUString
>& getImageCommandNames();
68 void impl_fillCommandToImageNameMap();
69 ImageList
* impl_getImageList( sal_Int16 nImageType
);
70 std::vector
< OUString
>& impl_getImageNameVector() { return m_aImageNameVector
;}
71 std::vector
< OUString
>& impl_getImageCommandNameVector() { return m_aImageCommandNameVector
;}
75 OUString m_aModuleIdentifier
;
76 ImageList
* m_pImageList
[ImageType_COUNT
];
77 CommandToImageNameMap m_aCommandToImageNameMap
;
78 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
79 ::std::vector
< OUString
> m_aImageNameVector
;
80 ::std::vector
< OUString
> m_aImageCommandNameVector
;
81 OUString m_sIconTheme
;
84 class GlobalImageList
: public CmdImageList
, public salhelper::SimpleReferenceObject
87 GlobalImageList( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
);
88 virtual ~GlobalImageList();
90 virtual Image
getImageFromCommandURL( sal_Int16 nImageType
, const OUString
& rCommandURL
) SAL_OVERRIDE
;
91 virtual bool hasImage( sal_Int16 nImageType
, const OUString
& rCommandURL
) SAL_OVERRIDE
;
92 virtual ::std::vector
< OUString
>& getImageNames() SAL_OVERRIDE
;
93 virtual ::std::vector
< OUString
>& getImageCommandNames() SAL_OVERRIDE
;
96 class ImageManagerImpl
99 ImageManagerImpl(const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxContext
100 ,::cppu::OWeakObject
*pOwner
105 void initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
);
106 void addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
107 void removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
110 void reset() throw (::com::sun::star::uno::RuntimeException
, css::lang::IllegalAccessException
);
111 ::com::sun::star::uno::Sequence
< OUString
> getAllImageNames( ::sal_Int16 nImageType
) throw (::com::sun::star::uno::RuntimeException
);
112 bool hasImage( ::sal_Int16 nImageType
, const OUString
& aCommandURL
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
113 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
> > getImages( ::sal_Int16 nImageType
, const ::com::sun::star::uno::Sequence
< OUString
>& aCommandURLSequence
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
114 void replaceImages( ::sal_Int16 nImageType
, const ::com::sun::star::uno::Sequence
< OUString
>& aCommandURLSequence
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
> >& aGraphicsSequence
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::IllegalAccessException
, ::com::sun::star::uno::RuntimeException
, std::exception
);
115 void removeImages( ::sal_Int16 nImageType
, const ::com::sun::star::uno::Sequence
< OUString
>& aResourceURLSequence
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::IllegalAccessException
, ::com::sun::star::uno::RuntimeException
);
116 void insertImages( ::sal_Int16 nImageType
, const ::com::sun::star::uno::Sequence
< OUString
>& aCommandURLSequence
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
> >& aGraphicSequence
) throw (::com::sun::star::container::ElementExistException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::IllegalAccessException
, ::com::sun::star::uno::RuntimeException
);
119 void addConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
120 void removeConfigurationListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
122 // XUIConfigurationPersistence
123 void reload() throw (css::uno::Exception
, css::uno::RuntimeException
, std::exception
);
125 throw (::com::sun::star::uno::Exception
,
126 ::com::sun::star::uno::RuntimeException
,
128 void storeToStorage( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& Storage
)
129 throw (::com::sun::star::uno::Exception
,
130 ::com::sun::star::uno::RuntimeException
,
132 bool isModified() throw (::com::sun::star::uno::RuntimeException
);
133 bool isReadOnly() throw (::com::sun::star::uno::RuntimeException
);
137 typedef std::unordered_map
< OUString
,
140 std::equal_to
< OUString
> > ImageNameMap
;
156 typedef ::std::vector
< ::com::sun::star::ui::ConfigurationEvent
> ConfigEventNotifyContainer
;
158 void implts_initialize();
159 void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent
& aEvent
, NotifyOp eOp
);
160 ImageList
* implts_getUserImageList( ImageType nImageType
);
161 bool implts_loadUserImages( ImageType nImageType
,
162 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>& xUserImageStorage
,
163 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>& xUserBitmapsStorage
);
164 bool implts_storeUserImages( ImageType nImageType
,
165 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>& xUserImageStorage
,
166 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>& xUserBitmapsStorage
);
167 const rtl::Reference
< GlobalImageList
>& implts_getGlobalImageList();
168 CmdImageList
* implts_getDefaultImageList();
170 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xUserConfigStorage
;
171 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xUserImageStorage
;
172 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> m_xUserBitmapsStorage
;
173 com::sun::star::uno::Reference
< com::sun::star::embed::XTransactedObject
> m_xUserRootCommit
;
174 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> m_xContext
;
175 ::cppu::OWeakObject
* m_pOwner
;
176 rtl::Reference
< GlobalImageList
> m_pGlobalImageList
;
177 CmdImageList
* m_pDefaultImageList
;
178 OUString m_aXMLPostfix
;
179 OUString m_aModuleIdentifier
;
180 OUString m_aResourceString
;
182 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
183 ImageList
* m_pUserImageList
[ImageType_COUNT
];
184 bool m_bUserImageListModified
[ImageType_COUNT
];
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */