update dev300-m58
[ooovba.git] / writerperfect / source / wpdimp / wpft_genericfilter.cxx
blob0acb01432016c6fb05ce90814642291c89811618
1 /* genericfilter: mostly generic code for registering the filter
3 * Portions of this code Copyright 2000 by Sun Microsystems, Inc.
4 * Rest is Copyright (C) 2002 William Lachance (wlach@interlog.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
22 /* "This product is not manufactured, approved, or supported by
23 * Corel Corporation or Corel Corporation Limited."
25 #include <stdio.h>
27 #include <osl/mutex.hxx>
28 #include <osl/thread.h>
29 #include <cppuhelper/factory.hxx>
30 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
32 #include "WordPerfectImportFilter.hxx"
34 using namespace ::rtl;
35 using namespace ::cppu;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::registry;
40 extern "C"
42 //==================================================================================================
43 void SAL_CALL component_getImplementationEnvironment(
44 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
46 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
48 //==================================================================================================
49 sal_Bool SAL_CALL component_writeInfo(
50 void * /* pServiceManager */, void * pRegistryKey )
52 if (pRegistryKey)
54 try
56 sal_Int32 nPos = 0;
57 Reference< XRegistryKey > xNewKey(
58 reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( WordPerfectImportFilter_getImplementationName() ) );
59 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
61 const Sequence< OUString > & rSNL = WordPerfectImportFilter_getSupportedServiceNames();
62 const OUString * pArray = rSNL.getConstArray();
63 for ( nPos = rSNL.getLength(); nPos--; )
64 xNewKey->createKey( pArray[nPos] );
66 return sal_True;
68 catch (InvalidRegistryException &)
70 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
73 return sal_False;
75 //==================================================================================================
76 void * SAL_CALL component_getFactory(
77 const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
79 void * pRet = 0;
81 OUString implName = OUString::createFromAscii( pImplName );
82 if ( pServiceManager && implName.equals(WordPerfectImportFilter_getImplementationName()) )
84 Reference< XSingleServiceFactory > xFactory( createSingleFactory(
85 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
86 OUString::createFromAscii( pImplName ),
87 WordPerfectImportFilter_createInstance, WordPerfectImportFilter_getSupportedServiceNames() ) );
89 if (xFactory.is())
91 xFactory->acquire();
92 pRet = xFactory.get();
96 return pRet;