Update ooo320-m1
[ooovba.git] / ucb / source / core / ucbserv.cxx
blob747571d042b691de985d2514922fa9d28b19462b
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: ucbserv.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_ucb.hxx"
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
35 #include <com/sun/star/registry/XRegistryKey.hpp>
36 #include "ucb.hxx"
37 #include "ucbstore.hxx"
38 #include "ucbprops.hxx"
39 #include "provprox.hxx"
41 using namespace rtl;
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::lang;
44 using namespace com::sun::star::registry;
46 //=========================================================================
47 static sal_Bool writeInfo( void * pRegistryKey,
48 const OUString & rImplementationName,
49 Sequence< OUString > const & rServiceNames )
51 OUString aKeyName( OUString::createFromAscii( "/" ) );
52 aKeyName += rImplementationName;
53 aKeyName += OUString::createFromAscii( "/UNO/SERVICES" );
55 Reference< XRegistryKey > xKey;
56 try
58 xKey = static_cast< XRegistryKey * >(
59 pRegistryKey )->createKey( aKeyName );
61 catch ( InvalidRegistryException const & )
65 if ( !xKey.is() )
66 return sal_False;
68 sal_Bool bSuccess = sal_True;
70 for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
72 try
74 xKey->createKey( rServiceNames[ n ] );
76 catch ( InvalidRegistryException const & )
78 bSuccess = sal_False;
79 break;
82 return bSuccess;
85 //=========================================================================
86 extern "C" void SAL_CALL component_getImplementationEnvironment(
87 const sal_Char ** ppEnvTypeName, uno_Environment ** )
89 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
92 //=========================================================================
93 extern "C" sal_Bool SAL_CALL component_writeInfo( void *, void * pRegistryKey )
95 return pRegistryKey &&
97 //////////////////////////////////////////////////////////////////////
98 // Universal Content Broker.
99 //////////////////////////////////////////////////////////////////////
101 writeInfo( pRegistryKey,
102 UniversalContentBroker::getImplementationName_Static(),
103 UniversalContentBroker::getSupportedServiceNames_Static() ) &&
105 //////////////////////////////////////////////////////////////////////
106 // UCB Store.
107 //////////////////////////////////////////////////////////////////////
109 writeInfo( pRegistryKey,
110 UcbStore::getImplementationName_Static(),
111 UcbStore::getSupportedServiceNames_Static() ) &&
113 //////////////////////////////////////////////////////////////////////
114 // UCB PropertiesManager.
115 //////////////////////////////////////////////////////////////////////
117 writeInfo( pRegistryKey,
118 UcbPropertiesManager::getImplementationName_Static(),
119 UcbPropertiesManager::getSupportedServiceNames_Static() ) &&
121 //////////////////////////////////////////////////////////////////////
122 // UCP Proxy Factory.
123 //////////////////////////////////////////////////////////////////////
125 writeInfo( pRegistryKey,
126 UcbContentProviderProxyFactory::getImplementationName_Static(),
127 UcbContentProviderProxyFactory::getSupportedServiceNames_Static() );
130 //=========================================================================
131 extern "C" void * SAL_CALL component_getFactory(
132 const sal_Char * pImplName, void * pServiceManager, void * )
134 void * pRet = 0;
136 Reference< XMultiServiceFactory > xSMgr(
137 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
138 Reference< XSingleServiceFactory > xFactory;
140 //////////////////////////////////////////////////////////////////////
141 // Universal Content Broker.
142 //////////////////////////////////////////////////////////////////////
144 if ( UniversalContentBroker::getImplementationName_Static().
145 compareToAscii( pImplName ) == 0 )
147 xFactory = UniversalContentBroker::createServiceFactory( xSMgr );
150 //////////////////////////////////////////////////////////////////////
151 // UCB Store.
152 //////////////////////////////////////////////////////////////////////
154 else if ( UcbStore::getImplementationName_Static().
155 compareToAscii( pImplName ) == 0 )
157 xFactory = UcbStore::createServiceFactory( xSMgr );
160 //////////////////////////////////////////////////////////////////////
161 // UCB PropertiesManager.
162 //////////////////////////////////////////////////////////////////////
164 else if ( UcbPropertiesManager::getImplementationName_Static().
165 compareToAscii( pImplName ) == 0 )
167 xFactory = UcbPropertiesManager::createServiceFactory( xSMgr );
170 //////////////////////////////////////////////////////////////////////
171 // UCP Proxy Factory.
172 //////////////////////////////////////////////////////////////////////
174 else if ( UcbContentProviderProxyFactory::getImplementationName_Static().
175 compareToAscii( pImplName ) == 0 )
177 xFactory
178 = UcbContentProviderProxyFactory::createServiceFactory( xSMgr );
181 //////////////////////////////////////////////////////////////////////
183 if ( xFactory.is() )
185 xFactory->acquire();
186 pRet = xFactory.get();
189 return pRet;