LibreOffice Module filter (master) 1
basecontainer.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#pragma once
20
21#include <memory>
22
23#include "filtercache.hxx"
24#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <com/sun/star/util/XRefreshable.hpp>
26#include <com/sun/star/uno/XComponentContext.hpp>
27#include <com/sun/star/container/XNameContainer.hpp>
28#include <com/sun/star/container/XContainerQuery.hpp>
29#include <com/sun/star/util/XFlushable.hpp>
33#include <rtl/ustring.hxx>
34
35
36namespace filter::config {
37
38
52class BaseContainer : public ::cppu::WeakImplHelper< css::lang::XServiceInfo ,
53 css::container::XNameContainer , // => XNameReplace => XNameAccess => XElementAccess
54 css::container::XContainerQuery ,
55 css::util::XFlushable >
56{
57
58 // member
59
60 protected:
61 mutable std::mutex m_aMutex;
62
66
69 css::uno::Sequence< OUString > m_lServiceNames;
70
86 std::unique_ptr<FilterCache> m_pFlushCache;
87
91
94
95
96 // native interface
97
98 public:
99
100
101 // ctor/dtor
102
114
115
118 virtual ~BaseContainer() override;
119
120
145 void init( const OUString& sImplementationName,
146 const css::uno::Sequence< OUString >& lServiceNames ,
148
149
150 // helper
151
152 protected:
153
154
158 void impl_loadOnDemand(std::unique_lock<std::mutex>& rGuard);
159
160
170 void impl_initFlushMode(std::unique_lock<std::mutex>& rGuard);
171
172
191 FilterCache* impl_getWorkingCache(std::unique_lock<std::mutex>& rGuard) const;
192
193
194 // uno interface
195
196 public:
197
198
199 // XServiceInfo
200
201 virtual OUString SAL_CALL getImplementationName() override;
202
203 virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override;
204
205 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
206
207
208 // XNameContainer
209
210 virtual void SAL_CALL insertByName(const OUString& sItem ,
211 const css::uno::Any& aValue) override;
212
213 virtual void SAL_CALL removeByName(const OUString& sItem) override;
214
215
216 // XNameReplace
217
218 virtual void SAL_CALL replaceByName(const OUString& sItem ,
219 const css::uno::Any& aValue) override;
220
221
222 // XElementAccess
223
224 virtual css::uno::Any SAL_CALL getByName(const OUString& sItem) override;
225
226 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
227
228 virtual sal_Bool SAL_CALL hasByName(const OUString& sItem) override;
229
230 virtual css::uno::Type SAL_CALL getElementType() override;
231
232 virtual sal_Bool SAL_CALL hasElements() override;
233
234
235 // XContainerQuery
236
237 // must be implemented really by derived class...
238 // We implement return of an empty result here only!
239 // But we show an assertion :-)
240 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const OUString& sQuery) override;
241
242 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties) override;
243
244
245 // XFlushable
246
247 virtual void SAL_CALL flush() override;
248
249 virtual void SAL_CALL addFlushListener(const css::uno::Reference< css::util::XFlushListener >& xListener) override;
250
251 virtual void SAL_CALL removeFlushListener(const css::uno::Reference< css::util::XFlushListener >& xListener) override;
252};
253
254} // namespace filter::config
255
256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implements the interface css::container::XNameContainer on top of a FilterCache reference.
OUString m_sImplementationName
the implementation name of our derived class, which we provide at the interface XServiceInfo of our c...
void init(const OUString &sImplementationName, const css::uno::Sequence< OUString > &lServiceNames, FilterCache::EItemType eType)
initialize this generic instance with some specialized values from our derived object.
virtual ~BaseContainer() override
standard dtor.
virtual sal_Bool SAL_CALL hasByName(const OUString &sItem) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue > &lProperties) override
virtual void SAL_CALL replaceByName(const OUString &sItem, const css::uno::Any &aValue) override
virtual void SAL_CALL removeByName(const OUString &sItem) override
virtual void SAL_CALL flush() override
FilterCache * impl_getWorkingCache(std::unique_lock< std::mutex > &rGuard) const
returns a pointer to the current used cache member.
virtual css::uno::Type SAL_CALL getElementType() override
FilterCache::EItemType m_eType
specify, which sub container of the used filter cache must be wrapped by this container interface.
std::unique_ptr< FilterCache > m_pFlushCache
local filter cache, which is used to collect changes on the filter configuration first and flush it l...
virtual sal_Bool SAL_CALL hasElements() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const OUString &sQuery) override
void impl_initFlushMode(std::unique_lock< std::mutex > &rGuard)
it creates the global instance m_pFilterCache, which is a copy of the global instance m_rCache,...
void impl_loadOnDemand(std::unique_lock< std::mutex > &rGuard)
check if the underlying configuration data was already loaded and do it if necessary automatically.
virtual OUString SAL_CALL getImplementationName() override
css::uno::Sequence< OUString > m_lServiceNames
the list of supported uno service names of our derived class, which we provide at the interface XServ...
virtual css::uno::Any SAL_CALL getByName(const OUString &sItem) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL removeFlushListener(const css::uno::Reference< css::util::XFlushListener > &xListener) override
virtual void SAL_CALL insertByName(const OUString &sItem, const css::uno::Any &aValue) override
virtual void SAL_CALL addFlushListener(const css::uno::Reference< css::util::XFlushListener > &xListener) override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
comphelper::OInterfaceContainerHelper4< css::util::XFlushListener > m_lListener
holds all listener, which are registered at this instance.
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
implements a cache, which contains all elements of our filter and type detection configuration.
Definition: filtercache.hxx:61
EItemType
identify the type of a container item.
Definition: filtercache.hxx:74
unsigned char sal_Bool