tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / scripting / source / provider / MasterScriptProvider.hxx
blob0e6c40f5f0a6400e611785e9723632f983fa8f37
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 <rtl/ustring.hxx>
24 #include <cppuhelper/implbase.hxx>
26 #include <com/sun/star/frame/XModel.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/document/XScriptInvocationContext.hpp>
31 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/script/provider/XScriptProvider.hpp>
34 #include <com/sun/star/script/browse/XBrowseNode.hpp>
36 #include "ProviderCache.hxx"
37 #include <memory>
38 #include <mutex>
40 namespace func_provider
43 typedef ::cppu::WeakImplHelper<
44 css::script::provider::XScriptProvider,
45 css::script::browse::XBrowseNode, css::lang::XServiceInfo,
46 css::lang::XInitialization,
47 css::container::XNameContainer > t_helper;
49 class MasterScriptProvider :
50 public t_helper
52 public:
53 /// @throws css::uno::RuntimeException
54 explicit MasterScriptProvider(
55 const css::uno::Reference< css::uno::XComponentContext >
56 & xContext );
57 virtual ~MasterScriptProvider() override;
59 // XServiceInfo implementation
60 virtual OUString SAL_CALL getImplementationName( ) override;
62 // XBrowseNode implementation
63 virtual OUString SAL_CALL getName() override;
64 virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes() override;
65 virtual sal_Bool SAL_CALL hasChildNodes() override;
66 virtual sal_Int16 SAL_CALL getType() override;
67 // XNameContainer
68 virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
69 virtual void SAL_CALL removeByName( const OUString& Name ) override;
71 // XNameReplace
72 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
73 // XNameAccess
74 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
75 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
76 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
78 // XElementAccess
79 virtual css::uno::Type SAL_CALL getElementType( ) override;
80 virtual sal_Bool SAL_CALL hasElements( ) override;
81 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
82 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
84 // XScriptProvider implementation
85 virtual css::uno::Reference < css::script::provider::XScript > SAL_CALL
86 getScript( const OUString& scriptURI ) override;
88 /**
89 * XInitialise implementation
91 * @param args expected to contain a single OUString
92 * containing the URI
94 virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any > & args ) override;
96 // returns context string for this provider, eg
97 const OUString& getContextString() const { return m_sCtxString; }
99 private:
100 static OUString parseLocationName( const OUString& location );
101 void createPkgProvider();
103 ProviderCache* providerCache();
104 /* to obtain other services if needed */
105 css::uno::Reference< css::uno::XComponentContext > m_xContext;
106 css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
107 css::uno::Reference< css::frame::XModel > m_xModel;
108 css::uno::Reference< css::document::XScriptInvocationContext > m_xInvocationContext;
109 css::uno::Sequence< css::uno::Any > m_sAargs;
110 OUString m_sNodeName;
112 // This component supports XInitialization, it can be created
113 // using createInstanceXXX() or createInstanceWithArgumentsXXX using
114 // the service Manager.
115 // Need to detect proper initialisation and validity
116 // for the object, so m_bIsValid indicates that the object is valid is set in ctor
117 // in case of createInstanceWithArgumentsXXX() called m_bIsValid is set to reset
118 // and then set to true when initialisation is complete
119 bool m_bIsValid;
120 // m_bInitialised ensure initialisation only takes place once.
121 bool m_bInitialised;
122 bool m_bIsPkgMSP;
123 css::uno::Reference< css::script::provider::XScriptProvider > m_xMSPPkg;
124 std::unique_ptr<ProviderCache> m_pPCache;
125 std::mutex m_mutex;
126 OUString m_sCtxString;
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */