pppoptimizeruno.cxx (e4a7f284) pppoptimizeruno.cxx (880c69c6)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
20 *************************************************************/
21
22
23
22// MARKER(update_precomp.py): autogen include statement, do not remove
23#include "precompiled_sdext.hxx"
24
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_sdext.hxx"
26
25#include "pppoptimizer.hxx"
26#include "pppoptimizerdialog.hxx"
27
27#include <stdio.h>
28#include <osl/mutex.hxx>
29#include <osl/thread.h>
28#include <cppuhelper/factory.hxx>
30#include <cppuhelper/factory.hxx>
29#include <cppuhelper/implementationentry.hxx>
31#include <pppoptimizer.hxx>
32#include <pppoptimizerdialog.hxx>
30
33
34using namespace ::rtl;
35using namespace ::cppu;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::lang;
38using namespace ::com::sun::star::registry;
31
39
32namespace sdext_presentation_minimizer
40extern "C"
33{
41{
34 static struct cppu::ImplementationEntry g_entries[] =
42 void SAL_CALL component_getImplementationEnvironment(
43 const sal_Char ** ppEnvTypeName, uno_Environment ** )
35 {
44 {
36 {
37 PPPOptimizer_createInstance,
38 PPPOptimizer_getImplementationName,
39 PPPOptimizer_getSupportedServiceNames,
40 cppu::createSingleComponentFactory,
41 0,
42 0
43 },
44 {
45 PPPOptimizerDialog_createInstance,
46 PPPOptimizerDialog_getImplementationName,
47 PPPOptimizer_getSupportedServiceNames,
48 cppu::createSingleComponentFactory,
49 0,
50 0
51 },
52 { 0, 0, 0, 0, 0, 0 }
53 };
54}
45 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
46 }
55
47
56extern "C"
57{
58 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
59 const sal_Char **ppEnvTypeName, uno_Environment **/*ppEnv*/ )
48 // -------------------------------------------------------------------------
49
50 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
60 {
51 {
61 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
52 if (pRegistryKey)
53 {
54 try
55 {
56 Reference< XRegistryKey > xNewKey;
57 sal_Int32 nPos;
58
59 xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PPPOptimizer_getImplementationName() );
60 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
61 const Sequence< OUString > & rSNL1 = PPPOptimizer_getSupportedServiceNames();
62 const OUString * pArray1 = rSNL1.getConstArray();
63 for ( nPos = rSNL1.getLength(); nPos--; )
64 xNewKey->createKey( pArray1[nPos] );
65
66 xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PPPOptimizerDialog_getImplementationName() );
67 xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
68 const Sequence< OUString > & rSNL2 = PPPOptimizerDialog_getSupportedServiceNames();
69 const OUString * pArray2 = rSNL2.getConstArray();
70 for ( nPos = rSNL2.getLength(); nPos--; )
71 xNewKey->createKey( pArray2[nPos] );
72
73 return sal_True;
74 }
75 catch (InvalidRegistryException &)
76 {
77 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
78 }
79 }
80 return sal_False;
62 }
63
81 }
82
64 SAL_DLLPUBLIC_EXPORT void *SAL_CALL component_getFactory(
65 const sal_Char *pImplName, void *pServiceManager, void *pRegistryKey )
83 // -------------------------------------------------------------------------
84
85 void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
66 {
86 {
67 return ::cppu::component_getFactoryHelper( pImplName,
68 pServiceManager,
69 pRegistryKey ,
70 sdext_presentation_minimizer::g_entries );
87 OUString aImplName( OUString::createFromAscii( pImplName ) );
88 void* pRet = 0;
89
90 if( pServiceManager )
91 {
92 Reference< XSingleComponentFactory > xFactory;
93 if( aImplName.equals( PPPOptimizer_getImplementationName() ) )
94 {
95 xFactory = createSingleComponentFactory(
96 PPPOptimizer_createInstance,
97 OUString::createFromAscii( pImplName ),
98 PPPOptimizer_getSupportedServiceNames() );
99
100 }
101 else if( aImplName.equals( PPPOptimizerDialog_getImplementationName() ) )
102 {
103 xFactory = createSingleComponentFactory(
104 PPPOptimizerDialog_createInstance,
105 OUString::createFromAscii( pImplName ),
106 PPPOptimizerDialog_getSupportedServiceNames() );
107 }
108 if( xFactory.is() )
109 {
110 xFactory->acquire();
111 pRet = xFactory.get();
112 }
113 }
114 return pRet;
71 }
72}
115 }
116}