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 "MasterScriptProviderFactory.hxx"
28 :
29 : using namespace ::com::sun::star;
30 : using namespace ::com::sun::star::uno;
31 : using namespace ::com::sun::star::script;
32 :
33 : namespace func_provider
34 : {
35 :
36 0 : MasterScriptProviderFactory::MasterScriptProviderFactory(
37 : Reference< XComponentContext > const & xComponentContext )
38 0 : : m_xComponentContext( xComponentContext )
39 : {
40 0 : }
41 :
42 0 : MasterScriptProviderFactory::~MasterScriptProviderFactory()
43 : {
44 0 : }
45 :
46 : Reference< provider::XScriptProvider > SAL_CALL
47 0 : MasterScriptProviderFactory::createScriptProvider( const Any& context ) throw ( lang::IllegalArgumentException, RuntimeException, std::exception)
48 : {
49 0 : Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW );
50 0 : return xMsp;
51 : }
52 :
53 : const rtl::Reference< ActiveMSPList > &
54 0 : MasterScriptProviderFactory::getActiveMSPList() const
55 : {
56 0 : if ( !m_MSPList.is() )
57 : {
58 0 : ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
59 0 : if ( !m_MSPList.is() )
60 0 : m_MSPList = new ActiveMSPList( m_xComponentContext );
61 : }
62 0 : return m_MSPList;
63 : }
64 :
65 0 : Sequence< OUString > SAL_CALL mspf_getSupportedServiceNames( )
66 : SAL_THROW(())
67 : {
68 : OUString str_name(
69 0 : "com.sun.star.script.provider.MasterScriptProviderFactory");
70 :
71 0 : return Sequence< OUString >( &str_name, 1 );
72 : }
73 :
74 0 : OUString SAL_CALL mspf_getImplementationName( )
75 : SAL_THROW(())
76 : {
77 : return OUString(
78 0 : "com.sun.star.script.provider.MasterScriptProviderFactory");
79 : }
80 :
81 : Reference< XInterface > SAL_CALL
82 0 : mspf_create( Reference< XComponentContext > const & xComponentContext )
83 : SAL_THROW( (Exception) )
84 : {
85 : return static_cast< ::cppu::OWeakObject * >(
86 0 : new MasterScriptProviderFactory( xComponentContext ) );
87 : }
88 :
89 0 : OUString SAL_CALL MasterScriptProviderFactory::getImplementationName()
90 : throw (RuntimeException, std::exception)
91 : {
92 0 : return mspf_getImplementationName();
93 : }
94 :
95 0 : Sequence< OUString > SAL_CALL MasterScriptProviderFactory::getSupportedServiceNames()
96 : throw (RuntimeException, std::exception)
97 : {
98 0 : return mspf_getSupportedServiceNames();
99 : }
100 :
101 0 : sal_Bool MasterScriptProviderFactory::supportsService(
102 : OUString const & serviceName )
103 : throw (RuntimeException, std::exception)
104 : {
105 0 : return cppu::supportsService(this, serviceName);
106 : }
107 :
108 : } // namespace browsenodefactory
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|