1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/implbase1.hxx>
21 #include <cppuhelper/implementationentry.hxx>
22 #include <cppuhelper/exc_hlp.hxx>
23 #include <cppuhelper/factory.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <cppuhelper/weakref.hxx>
27 #include "MasterScriptProvider.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()
47 Reference
< provider::XScriptProvider
> SAL_CALL
48 MasterScriptProviderFactory::createScriptProvider( const Any
& context
) throw ( lang::IllegalArgumentException
, RuntimeException
, std::exception
)
50 Reference
< provider::XScriptProvider
> xMsp( getActiveMSPList() ->getMSPFromAnyContext( context
), UNO_QUERY_THROW
);
54 const rtl::Reference
< ActiveMSPList
> &
55 MasterScriptProviderFactory::getActiveMSPList() const
57 if ( !m_MSPList
.is() )
59 ::osl::MutexGuard
guard( ::osl::Mutex::getGlobalMutex() );
60 if ( !m_MSPList
.is() )
61 m_MSPList
= new ActiveMSPList( m_xComponentContext
);
66 Sequence
< OUString
> SAL_CALL
mspf_getSupportedServiceNames( )
69 "com.sun.star.script.provider.MasterScriptProviderFactory");
71 return Sequence
< OUString
>( &str_name
, 1 );
74 OUString SAL_CALL
mspf_getImplementationName( )
77 "com.sun.star.script.provider.MasterScriptProviderFactory");
80 Reference
< XInterface
> SAL_CALL
81 mspf_create( Reference
< XComponentContext
> const & xComponentContext
)
83 return static_cast< ::cppu::OWeakObject
* >(
84 new MasterScriptProviderFactory( xComponentContext
) );
87 OUString SAL_CALL
MasterScriptProviderFactory::getImplementationName()
88 throw (RuntimeException
, std::exception
)
90 return mspf_getImplementationName();
93 Sequence
< OUString
> SAL_CALL
MasterScriptProviderFactory::getSupportedServiceNames()
94 throw (RuntimeException
, std::exception
)
96 return mspf_getSupportedServiceNames();
99 sal_Bool
MasterScriptProviderFactory::supportsService(
100 OUString
const & serviceName
)
101 throw (RuntimeException
, std::exception
)
103 return cppu::supportsService(this, serviceName
);
106 } // namespace browsenodefactory
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */