update credits
[LibreOffice.git] / scripting / source / provider / MasterScriptProviderFactory.cxx
blobaac8b34bceb740aa2df20f37dde48cdd65c30f07
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/weakref.hxx>
21 #include <cppuhelper/implementationentry.hxx>
22 #include <cppuhelper/factory.hxx>
23 #include <cppuhelper/exc_hlp.hxx>
24 #include <cppuhelper/implbase1.hxx>
26 #include <util/util.hxx>
28 #include "MasterScriptProviderFactory.hxx"
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::script;
34 namespace func_provider
37 MasterScriptProviderFactory::MasterScriptProviderFactory(
38 Reference< XComponentContext > const & xComponentContext )
39 : m_xComponentContext( xComponentContext )
43 MasterScriptProviderFactory::~MasterScriptProviderFactory()
48 //############################################################################
49 // Implementation of XScriptProviderFactory
50 //############################################################################
53 Reference< provider::XScriptProvider > SAL_CALL
54 MasterScriptProviderFactory::createScriptProvider( const Any& context ) throw ( lang::IllegalArgumentException, RuntimeException)
56 Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW );
57 return xMsp;
60 //############################################################################
61 // Helper methods
62 //############################################################################
64 const rtl::Reference< ActiveMSPList > &
65 MasterScriptProviderFactory::getActiveMSPList() const
67 if ( !m_MSPList.is() )
69 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
70 if ( !m_MSPList.is() )
71 m_MSPList = new ActiveMSPList( m_xComponentContext );
73 return m_MSPList;
76 //############################################################################
77 // Namespace global methods for setting up MasterScriptProviderFactory service
78 //############################################################################
80 Sequence< OUString > SAL_CALL
81 mspf_getSupportedServiceNames( )
82 SAL_THROW(())
84 OUString str_name(
85 "com.sun.star.script.provider.MasterScriptProviderFactory");
87 return Sequence< OUString >( &str_name, 1 );
90 OUString SAL_CALL
91 mspf_getImplementationName( )
92 SAL_THROW(())
94 return OUString(
95 "com.sun.star.script.provider.MasterScriptProviderFactory");
98 Reference< XInterface > SAL_CALL
99 mspf_create( Reference< XComponentContext > const & xComponentContext )
100 SAL_THROW( (Exception) )
102 return static_cast< ::cppu::OWeakObject * >(
103 new MasterScriptProviderFactory( xComponentContext ) );
106 //############################################################################
107 // Implementation of XServiceInfo
108 //############################################################################
110 OUString SAL_CALL
111 MasterScriptProviderFactory::getImplementationName()
112 throw (RuntimeException)
114 return mspf_getImplementationName();
117 Sequence< OUString > SAL_CALL
118 MasterScriptProviderFactory::getSupportedServiceNames()
119 throw (RuntimeException)
121 return mspf_getSupportedServiceNames();
124 sal_Bool MasterScriptProviderFactory::supportsService(
125 OUString const & serviceName )
126 throw (RuntimeException)
128 // check();
130 Sequence< OUString > supported_services(
131 getSupportedServiceNames() );
133 OUString const * ar = supported_services.getConstArray();
135 for ( sal_Int32 pos = supported_services.getLength(); pos--; )
137 if (ar[ pos ].equals( serviceName ))
138 return true;
140 return false;
143 } // namespace browsenodefactory
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */