LibreOffice Module stoc (master) 1
dllcomponentloader.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include <osl/diagnose.h>
22#include <rtl/ustring.hxx>
23#include <cppuhelper/weak.hxx>
24#include <cppuhelper/shlib.hxx>
28
29#include <com/sun/star/loader/XImplementationLoader.hpp>
30#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31#include <com/sun/star/lang/XServiceInfo.hpp>
32#include <com/sun/star/lang/XInitialization.hpp>
33#include <com/sun/star/uno/XComponentContext.hpp>
34
35namespace com::sun::star::registry { class XRegistryKey; }
36
37using namespace com::sun::star;
38using namespace css::uno;
39using namespace css::loader;
40using namespace css::lang;
41using namespace css::registry;
42using namespace cppu;
43using namespace osl;
44
45namespace {
46
47class DllComponentLoader
48 : public WeakImplHelper< XImplementationLoader,
49 XInitialization,
50 XServiceInfo >
51{
52public:
53 explicit DllComponentLoader( const Reference<XComponentContext> & xCtx );
54
55 // XServiceInfo
56 virtual OUString SAL_CALL getImplementationName( ) override;
57 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
58 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
59
60 // XInitialization
61 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
62
63 // XImplementationLoader
64 virtual Reference<XInterface> SAL_CALL activate( const OUString& implementationName, const OUString& implementationLoaderUrl, const OUString& locationUrl, const Reference<XRegistryKey>& xKey ) override;
65 virtual sal_Bool SAL_CALL writeRegistryInfo( const Reference<XRegistryKey>& xKey, const OUString& implementationLoaderUrl, const OUString& locationUrl ) override;
66
67private:
68 Reference<XMultiServiceFactory> m_xSMgr;
69};
70
71
72DllComponentLoader::DllComponentLoader( const Reference<XComponentContext> & xCtx )
73{
74 m_xSMgr.set( xCtx->getServiceManager(), UNO_QUERY );
75}
76
77OUString SAL_CALL DllComponentLoader::getImplementationName( )
78{
79 return "com.sun.star.comp.stoc.DLLComponentLoader";
80}
81
82sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceName )
83{
84 return cppu::supportsService(this, ServiceName);
85}
86
87Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames( )
88{
89 return { "com.sun.star.loader.SharedLibrary" };
90}
91
92
93void DllComponentLoader::initialize( const css::uno::Sequence< css::uno::Any >& )
94{
95 OSL_FAIL( "dllcomponentloader::initialize should not be called !" );
96// if( aArgs.getLength() != 1 )
97// {
98// throw IllegalArgumentException();
99// }
100
101// Reference< XMultiServiceFactory > rServiceManager;
102
103// if( aArgs.getConstArray()[0].getValueType().getTypeClass() == TypeClass_INTERFACE )
104// {
105// aArgs.getConstArray()[0] >>= rServiceManager;
106// }
107
108// if( !rServiceManager.is() )
109// {
110// throw IllegalArgumentException();
111// }
112
113// m_xSMgr = rServiceManager;
114}
115
116
117Reference<XInterface> SAL_CALL DllComponentLoader::activate(
118 const OUString & rImplName, const OUString &, const OUString & rLibName,
119 const Reference< XRegistryKey > & )
120{
122 cppu::bootstrap_expandUri(rLibName), OUString(), rImplName, m_xSMgr,
123 css::uno::Reference<css::registry::XRegistryKey>());
124}
125
126
127sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo(
128 const Reference< XRegistryKey > & xKey, const OUString &, const OUString & rLibName )
129{
130#ifdef DISABLE_DYNLOADING
131 (void) xKey;
132 (void) rLibName;
133 OSL_FAIL( "DllComponentLoader::writeRegistryInfo() should not be called I think?" );
134 return sal_False;
135#else
137 cppu::bootstrap_expandUri(rLibName), OUString(), m_xSMgr, xKey );
138 return true;
139#endif
140}
141
142}
143
144extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
146 css::uno::XComponentContext *context,
147 css::uno::Sequence<css::uno::Any> const &)
148{
149 return cppu::acquire(new DllComponentLoader(context));
150}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< lang::XMultiComponentFactory > m_xSMgr
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_stoc_DLLComponentLoader_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
SAL_DLLPUBLIC_EXPORT css::uno::Reference< css::uno::XInterface > SAL_CALL loadSharedLibComponentFactory(OUString const &, OUString const &, OUString const &, css::uno::Reference< css::lang::XMultiServiceFactory > const &, css::uno::Reference< css::registry::XRegistryKey > const &, OUString const &)
CPPUHELPER_DLLPUBLIC void SAL_CALL writeSharedLibComponentInfo(::rtl::OUString const &uri, ::rtl::OUString const &rPath, css::uno::Reference< css::lang::XMultiServiceFactory > const &xMgr, css::uno::Reference< css::registry::XRegistryKey > const &xKey)
OUString bootstrap_expandUri(OUString const &uri)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
#define sal_False
unsigned char sal_Bool