merge the formfield patch from ooo-build
[ooovba.git] / scripting / source / provider / MasterScriptProviderFactory.cxx
blob851485fd42980620711e11a6b3eda8b826fa38b8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MasterScriptProviderFactory.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_scripting.hxx"
33 #include <cppuhelper/weakref.hxx>
34 #include <cppuhelper/implementationentry.hxx>
35 #include <cppuhelper/factory.hxx>
36 #include <cppuhelper/exc_hlp.hxx>
37 #include <cppuhelper/implbase1.hxx>
39 #include <util/util.hxx>
41 #include "MasterScriptProviderFactory.hxx"
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::script;
47 namespace func_provider
50 MasterScriptProviderFactory::MasterScriptProviderFactory(
51 Reference< XComponentContext > const & xComponentContext )
52 : m_xComponentContext( xComponentContext )
56 MasterScriptProviderFactory::~MasterScriptProviderFactory()
61 //############################################################################
62 // Implementation of XScriptProviderFactory
63 //############################################################################
66 Reference< provider::XScriptProvider > SAL_CALL
67 MasterScriptProviderFactory::createScriptProvider( const Any& context ) throw ( lang::IllegalArgumentException, RuntimeException)
69 Reference< provider::XScriptProvider > xMsp( getActiveMSPList() ->getMSPFromAnyContext( context ), UNO_QUERY_THROW );
70 return xMsp;
73 //############################################################################
74 // Helper methods
75 //############################################################################
77 const rtl::Reference< ActiveMSPList > &
78 MasterScriptProviderFactory::getActiveMSPList() const
80 if ( !m_MSPList.is() )
82 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
83 if ( !m_MSPList.is() )
84 m_MSPList = new ActiveMSPList( m_xComponentContext );
86 return m_MSPList;
89 //############################################################################
90 // Namespace global methods for setting up MasterScriptProviderFactory service
91 //############################################################################
93 Sequence< ::rtl::OUString > SAL_CALL
94 mspf_getSupportedServiceNames( )
95 SAL_THROW( () )
97 ::rtl::OUString str_name = ::rtl::OUString::createFromAscii(
98 "com.sun.star.script.provider.MasterScriptProviderFactory");
100 return Sequence< ::rtl::OUString >( &str_name, 1 );
103 ::rtl::OUString SAL_CALL
104 mspf_getImplementationName( )
105 SAL_THROW( () )
107 return ::rtl::OUString::createFromAscii(
108 "com.sun.star.script.provider.MasterScriptProviderFactory");
111 Reference< XInterface > SAL_CALL
112 mspf_create( Reference< XComponentContext > const & xComponentContext )
113 SAL_THROW( (Exception) )
115 return static_cast< ::cppu::OWeakObject * >(
116 new MasterScriptProviderFactory( xComponentContext ) );
119 //############################################################################
120 // Implementation of XServiceInfo
121 //############################################################################
123 ::rtl::OUString SAL_CALL
124 MasterScriptProviderFactory::getImplementationName()
125 throw (RuntimeException)
127 return mspf_getImplementationName();
130 Sequence< ::rtl::OUString > SAL_CALL
131 MasterScriptProviderFactory::getSupportedServiceNames()
132 throw (RuntimeException)
134 return mspf_getSupportedServiceNames();
137 sal_Bool MasterScriptProviderFactory::supportsService(
138 ::rtl::OUString const & serviceName )
139 throw (RuntimeException)
141 // check();
143 Sequence< ::rtl::OUString > supported_services(
144 getSupportedServiceNames() );
146 ::rtl::OUString const * ar = supported_services.getConstArray();
148 for ( sal_Int32 pos = supported_services.getLength(); pos--; )
150 if (ar[ pos ].equals( serviceName ))
151 return true;
153 return false;
156 } // namespace browsenodefactory