update dev300-m58
[ooovba.git] / filter / source / placeware / uno.cxx
blob9962edc928b1704b2f1779639ead0aa8ad1b9713
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: uno.cxx,v $
10 * $Revision: 1.6 $
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_filter.hxx"
34 #include <stdio.h>
36 #include <osl/mutex.hxx>
37 #include <osl/thread.h>
38 #include <cppuhelper/factory.hxx>
39 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
41 using namespace ::rtl;
42 using namespace ::cppu;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::registry;
47 namespace pwp {
48 extern OUString PlaceWareExportFilter_getImplementationName() throw ( RuntimeException );
49 extern sal_Bool SAL_CALL PlaceWareExportFilter_supportsService( const OUString& ServiceName ) throw ( RuntimeException );
50 extern Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames() throw ( RuntimeException );
51 extern Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw ( Exception );
54 using namespace ::pwp;
56 extern "C"
58 //==================================================================================================
59 void SAL_CALL component_getImplementationEnvironment(
60 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
62 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
64 //==================================================================================================
65 sal_Bool SAL_CALL component_writeInfo(
66 void * /* pServiceManager */, void * pRegistryKey )
68 if (pRegistryKey)
70 try
72 Reference< XRegistryKey > xNewKey(
73 reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PlaceWareExportFilter_getImplementationName() ) );
74 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
76 const Sequence< OUString > & rSNL = PlaceWareExportFilter_getSupportedServiceNames();
77 const OUString * pArray = rSNL.getConstArray();
78 for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
79 xNewKey->createKey( pArray[nPos] );
81 return sal_True;
83 catch (InvalidRegistryException &)
85 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
88 return sal_False;
90 //==================================================================================================
91 void * SAL_CALL component_getFactory(
92 const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
94 void * pRet = 0;
96 OUString implName = OUString::createFromAscii( pImplName );
97 if ( pServiceManager && implName.equals(PlaceWareExportFilter_getImplementationName()) )
99 Reference< XSingleServiceFactory > xFactory( createSingleFactory(
100 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
101 OUString::createFromAscii( pImplName ),
102 PlaceWareExportFilter_createInstance, PlaceWareExportFilter_getSupportedServiceNames() ) );
104 if (xFactory.is())
106 xFactory->acquire();
107 pRet = xFactory.get();
111 return pRet;