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: miscservices.cxx,v $
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_svtools.hxx"
33 #include "sal/types.h"
34 #include "rtl/ustring.hxx"
35 #include <cppuhelper/factory.hxx>
36 #include <cppuhelper/weak.hxx>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 #include <com/sun/star/registry/XRegistryKey.hpp>
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::registry
;
43 using namespace ::com::sun::star::lang
;
47 // -------------------------------------------------------------------------------------
49 // for CreateInstance functions implemented elsewhere
50 #define DECLARE_CREATEINSTANCE( ImplName ) \
51 Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& );
53 // for CreateInstance functions implemented elsewhere, while the function is within a namespace
54 #define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \
56 Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); \
59 // -------------------------------------------------------------------------------------
61 DECLARE_CREATEINSTANCE_NAMESPACE( svt
, OAddressBookSourceDialogUno
)
62 DECLARE_CREATEINSTANCE( SvFilterOptionsDialog
)
63 DECLARE_CREATEINSTANCE( PathService
)
65 // -------------------------------------------------------------------------------------
70 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment (
71 const sal_Char
** ppEnvTypeName
, uno_Environment
** /* ppEnv */)
73 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
76 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo (
77 void * /* _pServiceManager */, void * _pRegistryKey
)
81 Reference
< XRegistryKey
> xRegistryKey (
82 reinterpret_cast< XRegistryKey
* >( _pRegistryKey
));
83 Reference
< XRegistryKey
> xNewKey
;
85 xNewKey
= xRegistryKey
->createKey (
86 OUString::createFromAscii( "/com.sun.star.comp.svtools.OAddressBookSourceDialogUno/UNO/SERVICES" ) );
88 OUString::createFromAscii( "com.sun.star.ui.AddressBookSourceDialog" ) );
90 xNewKey
= xRegistryKey
->createKey (
91 OUString::createFromAscii( "/com.sun.star.svtools.SvFilterOptionsDialog/UNO/SERVICES" ) );
93 OUString::createFromAscii( "com.sun.star.ui.dialogs.FilterOptionsDialog" ) );
95 xNewKey
= xRegistryKey
->createKey(
96 OUString::createFromAscii( "/com.sun.star.comp.svtools.PathService/UNO/SERVICES" ) );
98 OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) );
105 SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory (
106 const sal_Char
* pImplementationName
, void * _pServiceManager
, void * /* _pRegistryKey */)
109 if ( _pServiceManager
)
111 Reference
< XSingleServiceFactory
> xFactory
;
112 if (rtl_str_compare (
113 pImplementationName
, "com.sun.star.comp.svtools.OAddressBookSourceDialogUno") == 0)
115 Sequence
< OUString
> aServiceNames(1);
116 aServiceNames
.getArray()[0] =
117 OUString::createFromAscii( "com.sun.star.ui.AddressBookSourceDialog" );
119 xFactory
= ::cppu::createSingleFactory (
120 reinterpret_cast< XMultiServiceFactory
* >( _pServiceManager
),
121 OUString::createFromAscii( pImplementationName
),
122 svt::OAddressBookSourceDialogUno_CreateInstance
,
125 else if (rtl_str_compare (
126 pImplementationName
, "com.sun.star.svtools.SvFilterOptionsDialog") == 0)
128 Sequence
< OUString
> aServiceNames(1);
129 aServiceNames
.getArray()[0] =
130 OUString::createFromAscii( "com.sun.star.ui.dialogs.FilterOptionsDialog" );
132 xFactory
= ::cppu::createSingleFactory (
133 reinterpret_cast< XMultiServiceFactory
* >( _pServiceManager
),
134 OUString::createFromAscii( pImplementationName
),
135 SvFilterOptionsDialog_CreateInstance
,
138 else if (rtl_str_compare (
139 pImplementationName
, "com.sun.star.comp.svtools.PathService") == 0)
141 Sequence
< OUString
> aServiceNames(1);
142 aServiceNames
.getArray()[0] =
143 OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" );
144 xFactory
= ::cppu::createSingleFactory (
145 reinterpret_cast< XMultiServiceFactory
* >( _pServiceManager
),
146 OUString::createFromAscii( pImplementationName
),
147 PathService_CreateInstance
,
153 pResult
= xFactory
.get();