Bump version to 24.04.3.4
[LibreOffice.git] / framework / source / uiconfiguration / imagemanagerimpl.hxx
blob4d48da1c231289e5e0747cf5ff18400064a50fe3
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 #pragma once
22 #include <com/sun/star/embed/XStorage.hpp>
23 #include <com/sun/star/lang/XEventListener.hpp>
24 #include <com/sun/star/ui/ConfigurationEvent.hpp>
25 #include <com/sun/star/ui/XUIConfigurationListener.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <com/sun/star/embed/XTransactedObject.hpp>
29 #include <cppuhelper/weak.hxx>
30 #include <comphelper/interfacecontainer4.hxx>
31 #include <rtl/ustring.hxx>
33 #include <rtl/ref.hxx>
34 #include <salhelper/simplereferenceobject.hxx>
36 #include <mutex>
37 #include <unordered_map>
38 #include <vector>
40 #include "CommandImageResolver.hxx"
42 namespace framework
44 class CmdImageList
46 public:
47 CmdImageList(css::uno::Reference< css::uno::XComponentContext > xContext, 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(css::uno::Reference< css::uno::XComponentContext > xContext
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 enum NotifyOp
142 NotifyOp_Remove,
143 NotifyOp_Insert,
144 NotifyOp_Replace
147 void implts_initialize();
148 void implts_notifyContainerListener( const css::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
149 ImageList* implts_getUserImageList( vcl::ImageType nImageType );
150 void implts_loadUserImages( vcl::ImageType nImageType,
151 const css::uno::Reference< css::embed::XStorage >& xUserImageStorage,
152 const css::uno::Reference< css::embed::XStorage >& xUserBitmapsStorage );
153 bool implts_storeUserImages( vcl::ImageType nImageType,
154 const css::uno::Reference< css::embed::XStorage >& xUserImageStorage,
155 const css::uno::Reference< css::embed::XStorage >& xUserBitmapsStorage );
156 const rtl::Reference< GlobalImageList >& implts_getGlobalImageList();
157 CmdImageList* implts_getDefaultImageList();
159 css::uno::Reference< css::embed::XStorage > m_xUserConfigStorage;
160 css::uno::Reference< css::embed::XStorage > m_xUserImageStorage;
161 css::uno::Reference< css::embed::XStorage > m_xUserBitmapsStorage;
162 css::uno::Reference< css::embed::XTransactedObject > m_xUserRootCommit;
163 css::uno::Reference< css::uno::XComponentContext > m_xContext;
164 ::cppu::OWeakObject* m_pOwner;
165 rtl::Reference< GlobalImageList > m_pGlobalImageList;
166 std::unique_ptr<CmdImageList> m_pDefaultImageList;
167 OUString m_aModuleIdentifier;
168 OUString m_aResourceString;
169 std::mutex m_mutex;
170 comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
171 comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
172 o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>> m_pUserImageList;
173 o3tl::enumarray<vcl::ImageType,bool> m_bUserImageListModified;
174 bool m_bUseGlobal;
175 bool m_bReadOnly;
176 bool m_bInitialized;
177 bool m_bModified;
178 bool m_bDisposed;
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */