Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / framework / source / uiconfiguration / imagemanagerimpl.hxx
blobfa224e09f3c05867da98bdd391393542e88d76ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/embed/XStorage.hpp>
24 #include <com/sun/star/lang/XEventListener.hpp>
25 #include <com/sun/star/ui/ConfigurationEvent.hpp>
26 #include <com/sun/star/ui/XUIConfigurationListener.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/embed/XTransactedObject.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <rtl/ustring.hxx>
34 #include <rtl/ref.hxx>
35 #include <salhelper/simplereferenceobject.hxx>
37 #include <unordered_map>
38 #include <vector>
40 #include "CommandImageResolver.hxx"
42 namespace framework
44 class CmdImageList
46 public:
47 CmdImageList(const css::uno::Reference< css::uno::XComponentContext >& rxContext, const OUString& aModuleIdentifier);
48 virtual ~CmdImageList();
50 virtual Image getImageFromCommandURL(vcl::ImageType nImageType, const OUString& rCommandURL);
51 virtual bool hasImage(vcl::ImageType nImageType, const OUString& rCommandURL);
52 virtual std::vector<OUString>& getImageCommandNames();
54 protected:
55 void initialize();
57 private:
58 bool m_bInitialized;
59 vcl::CommandImageResolver m_aResolver;
61 OUString m_aModuleIdentifier;
62 css::uno::Reference<css::uno::XComponentContext> m_xContext;
65 class GlobalImageList : public CmdImageList, public salhelper::SimpleReferenceObject
67 public:
68 explicit GlobalImageList(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
69 virtual ~GlobalImageList() override;
71 virtual Image getImageFromCommandURL( vcl::ImageType nImageType, const OUString& rCommandURL ) override;
72 virtual bool hasImage( vcl::ImageType nImageType, const OUString& rCommandURL ) override;
73 virtual ::std::vector< OUString >& getImageCommandNames() override;
76 class ImageManagerImpl
78 public:
79 ImageManagerImpl(const css::uno::Reference< css::uno::XComponentContext >& rxContext
80 ,::cppu::OWeakObject *pOwner
81 ,bool _bUseGlobal);
82 ~ImageManagerImpl();
84 void dispose();
85 void initialize( const css::uno::Sequence< css::uno::Any >& aArguments );
86 /// @throws css::uno::RuntimeException
87 void addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener );
88 /// @throws css::uno::RuntimeException
89 void removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener );
91 // XImageManager
92 /// @throws css::uno::RuntimeException
93 /// @throws css::lang::IllegalAccessException
94 void reset();
95 /// @throws css::uno::RuntimeException
96 css::uno::Sequence< OUString > getAllImageNames( ::sal_Int16 nImageType );
97 /// @throws css::lang::IllegalArgumentException
98 /// @throws css::uno::RuntimeException
99 bool hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL );
100 /// @throws css::lang::IllegalArgumentException
101 /// @throws css::uno::RuntimeException
102 css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > getImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence );
103 /// @throws css::lang::IllegalArgumentException
104 /// @throws css::lang::IllegalAccessException
105 /// @throws css::uno::RuntimeException
106 void replaceImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicsSequence );
107 /// @throws css::lang::IllegalArgumentException
108 /// @throws css::lang::IllegalAccessException
109 /// @throws css::uno::RuntimeException
110 void removeImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aResourceURLSequence );
111 /// @throws css::container::ElementExistException
112 /// @throws css::lang::IllegalArgumentException
113 /// @throws css::lang::IllegalAccessException
114 /// @throws css::uno::RuntimeException
115 void insertImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicSequence );
117 // XUIConfiguration
118 /// @throws css::uno::RuntimeException
119 void addConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener );
120 /// @throws css::uno::RuntimeException
121 void removeConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener );
123 // XUIConfigurationPersistence
124 /// @throws css::uno::Exception
125 /// @throws css::uno::RuntimeException
126 void reload();
127 /// @throws css::uno::Exception
128 /// @throws css::uno::RuntimeException
129 void store();
130 /// @throws css::uno::Exception
131 /// @throws css::uno::RuntimeException
132 void storeToStorage( const css::uno::Reference< css::embed::XStorage >& Storage );
133 /// @throws css::uno::RuntimeException
134 bool isModified() const;
135 /// @throws css::uno::RuntimeException
136 bool isReadOnly() const;
138 void clear();
140 typedef std::unordered_map< OUString,
141 sal_Bool > ImageNameMap;
143 enum NotifyOp
145 NotifyOp_Remove,
146 NotifyOp_Insert,
147 NotifyOp_Replace
150 typedef ::std::vector< css::ui::ConfigurationEvent > ConfigEventNotifyContainer;
152 void implts_initialize();
153 void implts_notifyContainerListener( const css::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
154 ImageList* implts_getUserImageList( vcl::ImageType nImageType );
155 void implts_loadUserImages( vcl::ImageType nImageType,
156 const css::uno::Reference< css::embed::XStorage >& xUserImageStorage,
157 const css::uno::Reference< css::embed::XStorage >& xUserBitmapsStorage );
158 bool implts_storeUserImages( vcl::ImageType nImageType,
159 const css::uno::Reference< css::embed::XStorage >& xUserImageStorage,
160 const css::uno::Reference< css::embed::XStorage >& xUserBitmapsStorage );
161 const rtl::Reference< GlobalImageList >& implts_getGlobalImageList();
162 CmdImageList* implts_getDefaultImageList();
164 css::uno::Reference< css::embed::XStorage > m_xUserConfigStorage;
165 css::uno::Reference< css::embed::XStorage > m_xUserImageStorage;
166 css::uno::Reference< css::embed::XStorage > m_xUserBitmapsStorage;
167 css::uno::Reference< css::embed::XTransactedObject > m_xUserRootCommit;
168 css::uno::Reference< css::uno::XComponentContext > m_xContext;
169 ::cppu::OWeakObject* m_pOwner;
170 rtl::Reference< GlobalImageList > m_pGlobalImageList;
171 std::unique_ptr<CmdImageList> m_pDefaultImageList;
172 OUString m_aModuleIdentifier;
173 OUString m_aResourceString;
174 osl::Mutex m_mutex;
175 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
176 o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>> m_pUserImageList;
177 o3tl::enumarray<vcl::ImageType,bool> m_bUserImageListModified;
178 bool m_bUseGlobal;
179 bool m_bReadOnly;
180 bool m_bInitialized;
181 bool m_bModified;
182 bool m_bDisposed;
186 #endif
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */