merge the formfield patch from ooo-build
[ooovba.git] / filter / source / xmlfilteradaptor / genericfilter.cxx
blobed1c72561208d6d2beb53575e44190141e48a925
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: genericfilter.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>
38 #include <osl/mutex.hxx>
40 #include <osl/thread.h>
42 #include <cppuhelper/factory.hxx>
46 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
48 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
50 #endif
54 #include "XmlFilterAdaptor.hxx"
58 using namespace ::rtl;
60 using namespace ::cppu;
62 using namespace ::com::sun::star::uno;
64 using namespace ::com::sun::star::lang;
66 using namespace ::com::sun::star::registry;
70 extern "C"
74 //==================================================================================================
76 void SAL_CALL component_getImplementationEnvironment(
78 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
82 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
86 //==================================================================================================
88 sal_Bool SAL_CALL component_writeInfo(
90 void * /* pServiceManager */, void * pRegistryKey )
94 if (pRegistryKey)
98 try
102 Reference< XRegistryKey > xNewKey(
104 reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( XmlFilterAdaptor_getImplementationName() ) );
106 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
110 const Sequence< OUString > & rSNL = XmlFilterAdaptor_getSupportedServiceNames();
112 const OUString * pArray = rSNL.getConstArray();
114 for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
116 xNewKey->createKey( pArray[nPos] );
120 return sal_True;
124 catch (InvalidRegistryException &)
128 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
134 return sal_False;
138 //==================================================================================================
140 void * SAL_CALL component_getFactory(
142 const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
146 void * pRet = 0;
150 OUString implName = OUString::createFromAscii( pImplName );
152 if ( pServiceManager && implName.equals(XmlFilterAdaptor_getImplementationName()) )
156 Reference< XSingleServiceFactory > xFactory( createSingleFactory(
158 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
160 OUString::createFromAscii( pImplName ),
162 XmlFilterAdaptor_createInstance, XmlFilterAdaptor_getSupportedServiceNames() ) );
166 if (xFactory.is())
170 xFactory->acquire();
172 pRet = xFactory.get();
178 return pRet;