LibreOffice Module scripting (master) 1
ProviderCache.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 <rtl/ustring.hxx>
23#include <com/sun/star/lang/XSingleComponentFactory.hpp>
24#include <com/sun/star/lang/XMultiComponentFactory.hpp>
25
26#include <com/sun/star/script/provider/XScriptProvider.hpp>
27
28#include <mutex>
29#include <unordered_map>
30
31namespace func_provider
32{
33
34//Typedefs
35
36
38{
39 //css::uno::Reference< css::lang::XSingleServiceFactory > factory;
40 css::uno::Reference< css::lang::XSingleComponentFactory > factory;
41 css::uno::Reference< css::script::provider::XScriptProvider > provider;
42};
43typedef std::unordered_map < OUString, ProviderDetails > ProviderDetails_hash;
44
45
47{
48
49public:
51 ProviderCache( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Sequence< css::uno::Any >& scriptContext );
53 ProviderCache( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Sequence< css::uno::Any >& scriptContext,
54 const css::uno::Sequence< OUString >& denyList );
56 css::uno::Reference< css::script::provider::XScriptProvider >
57 getProvider( const OUString& providerName );
59 css::uno::Sequence < css::uno::Reference< css::script::provider::XScriptProvider > >
61private:
63 void populateCache();
64
66 css::uno::Reference< css::script::provider::XScriptProvider >
68 bool isInDenyList( const OUString& serviceName ) const;
69 css::uno::Sequence< OUString > m_sDenyList;
71 std::mutex m_mutex;
72 css::uno::Sequence< css::uno::Any > m_Sctx;
73 css::uno::Reference< css::uno::XComponentContext > m_xContext;
74 css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
75
76
77};
78} // func_provider
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::script::provider::XScriptProvider > createProvider(ProviderDetails &details)
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr
ProviderCache(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Sequence< css::uno::Any > &scriptContext, const css::uno::Sequence< OUString > &denyList)
css::uno::Sequence< OUString > m_sDenyList
css::uno::Sequence< css::uno::Any > m_Sctx
ProviderCache(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Sequence< css::uno::Any > &scriptContext)
bool isInDenyList(const OUString &serviceName) const
css::uno::Sequence< css::uno::Reference< css::script::provider::XScriptProvider > > getAllProviders()
css::uno::Reference< css::script::provider::XScriptProvider > getProvider(const OUString &providerName)
ProviderDetails_hash m_hProviderDetailsCache
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::unordered_map< OUString, ProviderDetails > ProviderDetails_hash
css::uno::Reference< css::lang::XSingleComponentFactory > factory
css::uno::Reference< css::script::provider::XScriptProvider > provider