1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pppoptimizeruno.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
36 #include <osl/mutex.hxx>
37 #include <osl/thread.h>
38 #include <cppuhelper/factory.hxx>
39 #include <pppoptimizer.hxx>
40 #include <pppoptimizerdialog.hxx>
42 using namespace ::rtl
;
43 using namespace ::cppu
;
44 using namespace ::com::sun::star::uno
;
45 using namespace ::com::sun::star::lang
;
46 using namespace ::com::sun::star::registry
;
50 void SAL_CALL
component_getImplementationEnvironment(
51 const sal_Char
** ppEnvTypeName
, uno_Environment
** )
53 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
56 // -------------------------------------------------------------------------
58 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
64 Reference
< XRegistryKey
> xNewKey
;
67 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( PPPOptimizer_getImplementationName() );
68 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
69 const Sequence
< OUString
> & rSNL1
= PPPOptimizer_getSupportedServiceNames();
70 const OUString
* pArray1
= rSNL1
.getConstArray();
71 for ( nPos
= rSNL1
.getLength(); nPos
--; )
72 xNewKey
->createKey( pArray1
[nPos
] );
74 xNewKey
= reinterpret_cast< XRegistryKey
* >( pRegistryKey
)->createKey( PPPOptimizerDialog_getImplementationName() );
75 xNewKey
= xNewKey
->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
76 const Sequence
< OUString
> & rSNL2
= PPPOptimizerDialog_getSupportedServiceNames();
77 const OUString
* pArray2
= rSNL2
.getConstArray();
78 for ( nPos
= rSNL2
.getLength(); nPos
--; )
79 xNewKey
->createKey( pArray2
[nPos
] );
83 catch (InvalidRegistryException
&)
85 OSL_ENSURE( sal_False
, "### InvalidRegistryException!" );
91 // -------------------------------------------------------------------------
93 void* SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
95 OUString
aImplName( OUString::createFromAscii( pImplName
) );
100 Reference
< XSingleComponentFactory
> xFactory
;
101 if( aImplName
.equals( PPPOptimizer_getImplementationName() ) )
103 xFactory
= createSingleComponentFactory(
104 PPPOptimizer_createInstance
,
105 OUString::createFromAscii( pImplName
),
106 PPPOptimizer_getSupportedServiceNames() );
109 else if( aImplName
.equals( PPPOptimizerDialog_getImplementationName() ) )
111 xFactory
= createSingleComponentFactory(
112 PPPOptimizerDialog_createInstance
,
113 OUString::createFromAscii( pImplName
),
114 PPPOptimizerDialog_getSupportedServiceNames() );
119 pRet
= xFactory
.get();