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/implementationentry.hxx> 21 #include <cppuhelper/exc_hlp.hxx> 22 #include <cppuhelper/factory.hxx> 23 #include <cppuhelper/supportsservice.hxx> 24 #include <cppuhelper/weakref.hxx> 25 26 #include "MasterScriptProvider.hxx" 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 MasterScriptProviderFactory::MasterScriptProviderFactory( 37 Reference< XComponentContext > const & xComponentContext ) 38 : m_xComponentContext( xComponentContext ) 39 { 40 } 41 42 MasterScriptProviderFactory::~MasterScriptProviderFactory() 43 { 44 } 45 46 Reference< provider::XScriptProvider > SAL_CALL 47 MasterScriptProviderFactory::createScriptProvider( const Any& context ) 48 { 49 Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW ); 50 return xMsp; 51 } 52 53 const rtl::Reference< ActiveMSPList > & 54 MasterScriptProviderFactory::getActiveMSPList() const 55 { 56 if ( !m_MSPList.is() ) 57 { 58 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); 59 if ( !m_MSPList.is() ) 60 m_MSPList = new ActiveMSPList( m_xComponentContext ); 61 } 62 return m_MSPList; 63 } 64 65 Sequence< OUString > mspf_getSupportedServiceNames( ) 66 { 67 OUString str_name( 68 "com.sun.star.script.provider.MasterScriptProviderFactory"); 69 70 return Sequence< OUString >( &str_name, 1 ); 71 } 72 73 OUString mspf_getImplementationName( ) 74 { 75 return OUString( 76 "com.sun.star.script.provider.MasterScriptProviderFactory"); 77 } 78 79 Reference< XInterface > 80 mspf_create( Reference< XComponentContext > const & xComponentContext ) 81 { 82 return static_cast< ::cppu::OWeakObject * >( 83 new MasterScriptProviderFactory( xComponentContext ) ); 84 } 85 86 OUString SAL_CALL MasterScriptProviderFactory::getImplementationName() 87 { 88 return mspf_getImplementationName(); 89 } 90 91 Sequence< OUString > SAL_CALL MasterScriptProviderFactory::getSupportedServiceNames() 92 { 93 return mspf_getSupportedServiceNames(); 94 } 95 96 sal_Bool MasterScriptProviderFactory::supportsService( 97 OUString const & serviceName ) 98 { 99 return cppu::supportsService(this, serviceName); 100 } 101 102 } // namespace browsenodefactory 103 104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 105
