1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include <stdio.h>
25
26 #include <osl/mutex.hxx>
27 #include <osl/thread.h>
28 #include <cppuhelper/factory.hxx>
29 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30
31 #include "filterdetect.hxx"
32
33 using namespace ::rtl;
34 using namespace ::cppu;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::registry;
38
39 extern "C"
40 {
41 //==================================================================================================
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment ** ppEnv)42 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
43 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
44 {
45 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
46 }
47
48 // This method not longer necessary since OOo 3.4 where the component registration was
49 // was changed to passive component registration. For more details see
50 // https://wiki.openoffice.org/wiki/Passive_Component_Registration
51 //==================================================================================================
52 // SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
53 // void * pServiceManager, void * pRegistryKey )
54 // {
55 // if (pRegistryKey)
56 // {
57 // try
58 // {
59 // Reference< XRegistryKey > xNewKey(
60 // reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( FilterDetect_getImplementationName() ) );
61 // xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
62
63 // const Sequence< OUString > & rSNL = FilterDetect_getSupportedServiceNames();
64 // const OUString * pArray = rSNL.getConstArray();
65 // for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
66 // xNewKey->createKey( pArray[nPos] );
67
68 // return sal_True;
69 // }
70 // catch (InvalidRegistryException &)
71 // {
72 // OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
73 // }
74 // }
75 // return sal_False;
76 // }
77
78 //==================================================================================================
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void * pRegistryKey)79 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
80 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
81 {
82 void * pRet = 0;
83
84 OUString implName = OUString::createFromAscii( pImplName );
85 if ( pServiceManager && implName.equals(FilterDetect_getImplementationName()) )
86 {
87 Reference< XSingleServiceFactory > xFactory( createSingleFactory(
88 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
89 OUString::createFromAscii( pImplName ),
90 FilterDetect_createInstance, FilterDetect_getSupportedServiceNames() ) );
91
92 if (xFactory.is())
93 {
94 xFactory->acquire();
95 pRet = xFactory.get();
96 }
97 }
98 return pRet;
99 }
100
101 }
102
103