LibreOffice Module scripting (master) 1
ActiveMSPList.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 <osl/mutex.hxx>
22#include <rtl/ustring.hxx>
24
25#include <com/sun/star/lang/XEventListener.hpp>
26
27#include <com/sun/star/script/provider/XScriptProvider.hpp>
28#include <com/sun/star/document/XScriptInvocationContext.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30
31#include <map>
32#include <unordered_map>
33
34namespace func_provider
35{
36
37//Typedefs
38typedef std::map < css::uno::Reference< css::uno::XInterface >
39 , css::uno::Reference< css::script::provider::XScriptProvider >
41
42typedef std::unordered_map< OUString,
43 css::uno::Reference< css::script::provider::XScriptProvider > > Msp_hash;
44
46
47class ActiveMSPList : public ::cppu::WeakImplHelper< css::lang::XEventListener >
48{
49
50public:
51
52 explicit ActiveMSPList( const css::uno::Reference<
53 css::uno::XComponentContext > & xContext );
54 virtual ~ActiveMSPList() override;
55
56 css::uno::Reference< css::script::provider::XScriptProvider >
57 getMSPFromStringContext( const OUString& context );
58
59 css::uno::Reference< css::script::provider::XScriptProvider >
60 getMSPFromAnyContext( const css::uno::Any& context );
61
62 css::uno::Reference< css::script::provider::XScriptProvider >
63 getMSPFromInvocationContext( const css::uno::Reference< css::document::XScriptInvocationContext >& context );
64
65 //XEventListener
66
67
68 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
69
70private:
71 void addActiveMSP( const css::uno::Reference< css::uno::XInterface >& xComponent,
72 const css::uno::Reference< css::script::provider::XScriptProvider >& msp );
73 css::uno::Reference< css::script::provider::XScriptProvider >
74 createNewMSP( const css::uno::Any& context );
75 css::uno::Reference< css::script::provider::XScriptProvider >
76 createNewMSP( const OUString& context )
77 {
78 return createNewMSP( css::uno::Any( context ) );
79 }
80
81 friend class NonDocMSPCreator;
82 void createNonDocMSPs();
83
86 osl::Mutex m_mutex;
87 OUString userDirString;
90 css::uno::Reference< css::uno::XComponentContext > m_xContext;
91};
92} // func_provider
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual ~ActiveMSPList() override
css::uno::Reference< css::script::provider::XScriptProvider > getMSPFromStringContext(const OUString &context)
css::uno::Reference< css::script::provider::XScriptProvider > createNewMSP(const OUString &context)
ActiveMSPList(const css::uno::Reference< css::uno::XComponentContext > &xContext)
css::uno::Reference< css::script::provider::XScriptProvider > getMSPFromAnyContext(const css::uno::Any &context)
css::uno::Reference< css::script::provider::XScriptProvider > getMSPFromInvocationContext(const css::uno::Reference< css::document::XScriptInvocationContext > &context)
css::uno::Reference< css::script::provider::XScriptProvider > createNewMSP(const css::uno::Any &context)
css::uno::Reference< css::uno::XComponentContext > m_xContext
ScriptComponent_map m_mScriptComponents
void addActiveMSP(const css::uno::Reference< css::uno::XInterface > &xComponent, const css::uno::Reference< css::script::provider::XScriptProvider > &msp)
std::unordered_map< OUString, css::uno::Reference< css::script::provider::XScriptProvider > > Msp_hash
std::map< css::uno::Reference< css::uno::XInterface >, css::uno::Reference< css::script::provider::XScriptProvider > > ScriptComponent_map