Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
27 : #include "MasterScriptProvider.hxx"
28 : #include "MasterScriptProviderFactory.hxx"
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::script;
33 :
34 : namespace func_provider
35 : {
36 :
37 10 : MasterScriptProviderFactory::MasterScriptProviderFactory(
38 : Reference< XComponentContext > const & xComponentContext )
39 10 : : m_xComponentContext( xComponentContext )
40 : {
41 10 : }
42 :
43 20 : MasterScriptProviderFactory::~MasterScriptProviderFactory()
44 : {
45 20 : }
46 :
47 : Reference< provider::XScriptProvider > SAL_CALL
48 212 : MasterScriptProviderFactory::createScriptProvider( const Any& context ) throw ( lang::IllegalArgumentException, RuntimeException, std::exception)
49 : {
50 212 : Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW );
51 212 : return xMsp;
52 : }
53 :
54 : const rtl::Reference< ActiveMSPList > &
55 212 : MasterScriptProviderFactory::getActiveMSPList() const
56 : {
57 212 : if ( !m_MSPList.is() )
58 : {
59 8 : ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
60 8 : if ( !m_MSPList.is() )
61 8 : m_MSPList = new ActiveMSPList( m_xComponentContext );
62 : }
63 212 : return m_MSPList;
64 : }
65 :
66 10 : Sequence< OUString > SAL_CALL mspf_getSupportedServiceNames( )
67 : {
68 : OUString str_name(
69 10 : "com.sun.star.script.provider.MasterScriptProviderFactory");
70 :
71 10 : return Sequence< OUString >( &str_name, 1 );
72 : }
73 :
74 18 : OUString SAL_CALL mspf_getImplementationName( )
75 : {
76 : return OUString(
77 18 : "com.sun.star.script.provider.MasterScriptProviderFactory");
78 : }
79 :
80 : Reference< XInterface > SAL_CALL
81 10 : mspf_create( Reference< XComponentContext > const & xComponentContext )
82 : {
83 : return static_cast< ::cppu::OWeakObject * >(
84 10 : new MasterScriptProviderFactory( xComponentContext ) );
85 : }
86 :
87 0 : OUString SAL_CALL MasterScriptProviderFactory::getImplementationName()
88 : throw (RuntimeException, std::exception)
89 : {
90 0 : return mspf_getImplementationName();
91 : }
92 :
93 0 : Sequence< OUString > SAL_CALL MasterScriptProviderFactory::getSupportedServiceNames()
94 : throw (RuntimeException, std::exception)
95 : {
96 0 : return mspf_getSupportedServiceNames();
97 : }
98 :
99 0 : sal_Bool MasterScriptProviderFactory::supportsService(
100 : OUString const & serviceName )
101 : throw (RuntimeException, std::exception)
102 : {
103 0 : return cppu::supportsService(this, serviceName);
104 : }
105 :
106 : } // namespace browsenodefactory
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|