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: exports.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 ************************************************************************/
34 #include <osl/mutex.hxx>
35 #include <osl/thread.h>
36 #include <cppuhelper/factory.hxx>
37 #include <rtl/ustring.hxx>
38 #include <rtl/ustrbuf.hxx>
39 #include <sal/types.h>
40 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 #include "MyProtocolHandler.h"
43 #include "MyListener.h"
45 namespace css
= ::com::sun::star
;
47 static void writeInfo(const css::uno::Reference
< css::registry::XRegistryKey
>& xRegistryKey
,
48 const char* pImplementationName
,
49 const char* pServiceName
)
51 ::rtl::OUStringBuffer
sKey(256);
52 sKey
.append (::rtl::OUString::createFromAscii(pImplementationName
));
53 sKey
.appendAscii("/UNO/SERVICES/");
54 sKey
.append (::rtl::OUString::createFromAscii(pServiceName
));
56 xRegistryKey
->createKey(sKey
.makeStringAndClear());
61 //==================================================================================================
62 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment(const sal_Char
** ppEnvTypeName
,
63 uno_Environment
** ppEnv
)
65 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
68 //==================================================================================================
69 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo(void* pServiceManager
,
77 css::uno::Reference
< css::registry::XRegistryKey
> xKey(reinterpret_cast< css::registry::XRegistryKey
* >(pRegistryKey
), css::uno::UNO_QUERY
);
79 writeInfo( xKey
, MYLISTENER_IMPLEMENTATIONNAME
, MYLISTENER_SERVICENAME
);
80 writeInfo( xKey
, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME
, MYPROTOCOLHANDLER_SERVICENAME
);
84 catch(const css::registry::InvalidRegistryException
&)
85 { OSL_ENSURE( sal_False
, "### InvalidRegistryException!" ); }
90 //==================================================================================================
91 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
component_getFactory(const sal_Char
* pImplName
,
92 void* pServiceManager
,
95 if ( !pServiceManager
|| !pImplName
)
98 css::uno::Reference
< css::lang::XSingleServiceFactory
> xFactory
;
99 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR (reinterpret_cast< css::lang::XMultiServiceFactory
* >(pServiceManager
), css::uno::UNO_QUERY
);
100 ::rtl::OUString sImplName
= ::rtl::OUString::createFromAscii(pImplName
);
102 if (sImplName
.equalsAscii(MYLISTENER_IMPLEMENTATIONNAME
))
104 css::uno::Sequence
< ::rtl::OUString
> lNames(1);
105 lNames
[0] = ::rtl::OUString::createFromAscii(MYLISTENER_IMPLEMENTATIONNAME
);
106 xFactory
= ::cppu::createSingleFactory(xSMGR
, sImplName
, MyListener::st_createInstance
, lNames
);
109 if (sImplName
.equalsAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME
))
111 css::uno::Sequence
< ::rtl::OUString
> lNames(1);
112 lNames
[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME
);
113 xFactory
= ::cppu::createSingleFactory(xSMGR
, sImplName
, MyProtocolHandler_createInstance
, lNames
);
120 return xFactory
.get();