Avoid potential negative array index access to cached text.
[LibreOffice.git] / scripting / source / basprov / basprov.hxx
blob994113b6286875bd94a0142f7eaae380c9ac6024
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 <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/script/XLibraryContainer.hpp>
25 #include <com/sun/star/script/browse/XBrowseNode.hpp>
26 #include <com/sun/star/script/provider/XScriptProvider.hpp>
27 #include <com/sun/star/document/XScriptInvocationContext.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <cppuhelper/implbase.hxx>
30 #include <svl/lstner.hxx>
32 class BasicManager;
35 namespace basprov
41 typedef ::cppu::WeakImplHelper<
42 css::lang::XServiceInfo,
43 css::lang::XInitialization,
44 css::script::provider::XScriptProvider,
45 css::script::browse::XBrowseNode > BasicProviderImpl_BASE;
48 class BasicProviderImpl : public BasicProviderImpl_BASE, public SfxListener
50 private:
51 BasicManager* m_pAppBasicManager;
52 BasicManager* m_pDocBasicManager;
53 css::uno::Reference< css::script::XLibraryContainer > m_xLibContainerApp;
54 css::uno::Reference< css::script::XLibraryContainer > m_xLibContainerDoc;
55 css::uno::Reference< css::uno::XComponentContext > m_xContext;
56 css::uno::Reference< css::document::XScriptInvocationContext > m_xInvocationContext;
57 OUString m_sScriptingContext;
58 bool m_bIsAppScriptCtx;
59 bool m_bIsUserCtx;
61 bool isLibraryShared(
62 const css::uno::Reference< css::script::XLibraryContainer >& rxLibContainer,
63 const OUString& rLibName );
65 public:
66 explicit BasicProviderImpl(
67 const css::uno::Reference< css::uno::XComponentContext >& xContext );
68 virtual ~BasicProviderImpl() override;
70 // XServiceInfo
71 virtual OUString SAL_CALL getImplementationName( ) override;
72 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
73 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
75 // XInitialization
76 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
78 // XScriptProvider
79 virtual css::uno::Reference < css::script::provider::XScript > SAL_CALL getScript(
80 const OUString& scriptURI ) override;
82 // XBrowseNode
83 virtual OUString SAL_CALL getName( ) override;
84 virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes( ) override;
85 virtual sal_Bool SAL_CALL hasChildNodes( ) override;
86 virtual sal_Int16 SAL_CALL getType( ) override;
88 protected:
89 // SfxListener
90 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
94 } // namespace basprov
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */