LibreOffice Module framework (master) 1
imagemanagerimpl.hxx
Go to the documentation of this file.
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#pragma once
21
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>
28
29#include <cppuhelper/weak.hxx>
31#include <rtl/ustring.hxx>
32
33#include <rtl/ref.hxx>
35
36#include <mutex>
37#include <unordered_map>
38#include <vector>
39
41
42namespace framework
43{
45 {
46 public:
47 CmdImageList(css::uno::Reference< css::uno::XComponentContext > xContext, OUString aModuleIdentifier);
48 virtual ~CmdImageList();
49
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();
53
54 protected:
55 void initialize();
56
57 private:
60
62 css::uno::Reference<css::uno::XComponentContext> m_xContext;
63 };
64
66 {
67 public:
68 explicit GlobalImageList(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
69 virtual ~GlobalImageList() override;
70
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;
74 };
75
77 {
78 public:
79 ImageManagerImpl(css::uno::Reference< css::uno::XComponentContext > xContext
81 ,bool _bUseGlobal);
83
84 void dispose();
85 void initialize( const css::uno::Sequence< css::uno::Any >& aArguments );
87 void addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener );
89 void removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener );
90
91 // XImageManager
94 void reset();
96 css::uno::Sequence< OUString > getAllImageNames( ::sal_Int16 nImageType );
99 bool hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL );
102 css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > getImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence );
106 void replaceImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicsSequence );
110 void removeImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aResourceURLSequence );
115 void insertImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicSequence );
116
117 // XUIConfiguration
119 void addConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener );
121 void removeConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener );
122
123 // XUIConfigurationPersistence
126 void reload();
129 void store();
132 void storeToStorage( const css::uno::Reference< css::embed::XStorage >& Storage );
134 bool isModified() const;
136 bool isReadOnly() const;
137
138 void clear();
139
141 {
145 };
146
147 void implts_initialize();
148 void implts_notifyContainerListener( const css::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
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 );
158
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;
166 std::unique_ptr<CmdImageList> m_pDefaultImageList;
169 std::mutex m_mutex;
179 };
180}
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > m_xContext
CmdImageList(css::uno::Reference< css::uno::XComponentContext > xContext, OUString aModuleIdentifier)
virtual std::vector< OUString > & getImageCommandNames()
vcl::CommandImageResolver m_aResolver
virtual Image getImageFromCommandURL(vcl::ImageType nImageType, const OUString &rCommandURL)
virtual bool hasImage(vcl::ImageType nImageType, const OUString &rCommandURL)
virtual ::std::vector< OUString > & getImageCommandNames() override
virtual ~GlobalImageList() override
GlobalImageList(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual Image getImageFromCommandURL(vcl::ImageType nImageType, const OUString &rCommandURL) override
virtual bool hasImage(vcl::ImageType nImageType, const OUString &rCommandURL) override
css::uno::Sequence< OUString > getAllImageNames(::sal_Int16 nImageType)
void implts_notifyContainerListener(const css::ui::ConfigurationEvent &aEvent, NotifyOp eOp)
o3tl::enumarray< vcl::ImageType, std::unique_ptr< ImageList > > m_pUserImageList
ImageManagerImpl(css::uno::Reference< css::uno::XComponentContext > xContext,::cppu::OWeakObject *pOwner, bool _bUseGlobal)
::cppu::OWeakObject * m_pOwner
css::uno::Reference< css::embed::XStorage > m_xUserConfigStorage
CmdImageList * implts_getDefaultImageList()
void storeToStorage(const css::uno::Reference< css::embed::XStorage > &Storage)
o3tl::enumarray< vcl::ImageType, bool > m_bUserImageListModified
std::unique_ptr< CmdImageList > m_pDefaultImageList
void insertImages(::sal_Int16 nImageType, const css::uno::Sequence< OUString > &aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > &aGraphicSequence)
rtl::Reference< GlobalImageList > m_pGlobalImageList
bool hasImage(::sal_Int16 nImageType, const OUString &aCommandURL)
const rtl::Reference< GlobalImageList > & implts_getGlobalImageList()
css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > getImages(::sal_Int16 nImageType, const css::uno::Sequence< OUString > &aCommandURLSequence)
comphelper::OInterfaceContainerHelper4< css::ui::XUIConfigurationListener > m_aConfigListeners
css::uno::Reference< css::embed::XStorage > m_xUserBitmapsStorage
css::uno::Reference< css::embed::XStorage > m_xUserImageStorage
void addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener)
void initialize(const css::uno::Sequence< css::uno::Any > &aArguments)
void removeImages(::sal_Int16 nImageType, const css::uno::Sequence< OUString > &aResourceURLSequence)
void replaceImages(::sal_Int16 nImageType, const css::uno::Sequence< OUString > &aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > &aGraphicsSequence)
css::uno::Reference< css::embed::XTransactedObject > m_xUserRootCommit
void removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener > &Listener)
bool implts_storeUserImages(vcl::ImageType nImageType, const css::uno::Reference< css::embed::XStorage > &xUserImageStorage, const css::uno::Reference< css::embed::XStorage > &xUserBitmapsStorage)
ImageList * implts_getUserImageList(vcl::ImageType nImageType)
void implts_loadUserImages(vcl::ImageType nImageType, const css::uno::Reference< css::embed::XStorage > &xUserImageStorage, const css::uno::Reference< css::embed::XStorage > &xUserBitmapsStorage)
void removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener)
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aEventListeners
void addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener > &Listener)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Sequence< PropertyValue > aArguments
SvLinkSource * pOwner