Avoid potential negative array index access to cached text.
[LibreOffice.git] / scripting / source / provider / MasterScriptProviderFactory.cxx
blobacdb8f8da0ff02a2a80e5c73e14eb2772e754307
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 #include <cppuhelper/supportsservice.hxx>
22 #include "MasterScriptProviderFactory.hxx"
24 using namespace ::com::sun::star;
25 using namespace ::com::sun::star::uno;
26 using namespace ::com::sun::star::script;
28 namespace func_provider
31 MasterScriptProviderFactory::MasterScriptProviderFactory(
32 Reference< XComponentContext > const & xComponentContext )
33 : m_xComponentContext( xComponentContext )
37 MasterScriptProviderFactory::~MasterScriptProviderFactory()
41 Reference< provider::XScriptProvider > SAL_CALL
42 MasterScriptProviderFactory::createScriptProvider( const Any& context )
44 Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_SET_THROW );
45 return xMsp;
48 const rtl::Reference< ActiveMSPList > &
49 MasterScriptProviderFactory::getActiveMSPList() const
51 if ( !m_MSPList.is() )
53 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
54 if ( !m_MSPList.is() )
55 m_MSPList = new ActiveMSPList( m_xComponentContext );
57 return m_MSPList;
60 OUString SAL_CALL MasterScriptProviderFactory::getImplementationName()
62 return "com.sun.star.script.provider.MasterScriptProviderFactory";
65 Sequence< OUString > SAL_CALL MasterScriptProviderFactory::getSupportedServiceNames()
67 return { "com.sun.star.script.provider.MasterScriptProviderFactory" };
70 sal_Bool MasterScriptProviderFactory::supportsService(
71 OUString const & serviceName )
73 return cppu::supportsService(this, serviceName);
76 } // namespace func_provider
78 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
79 scripting_MasterScriptProviderFactory_get_implementation(
80 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
82 return cppu::acquire(new func_provider::MasterScriptProviderFactory(context));
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */