LibreOffice Module extensions (master) 1
servprov.hxx
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#pragma once
21
22#include <functional>
23
24#include <com/sun/star/lang/XInitialization.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
27
28#include "ole2uno.hxx"
30
31using namespace com::sun::star::bridge;
32using namespace cppu;
33
42
43/*****************************************************************************
44
45 OneInstanceOleWrapper
46
47 Provides a single UNO object as OLE object.
48
49 Acts as a COM class factory. When IClassFactory::CreateInstance is being called
50 then it maps the XInstance member it to a COM object.
51
52*****************************************************************************/
53
54class OneInstanceOleWrapper : public IClassFactory
55{
56public:
57
59 std::function<const Reference<XInterface>()> xInstFunction );
60 virtual ~OneInstanceOleWrapper();
61
62 bool registerClass(GUID const * pGuid);
63 bool deregisterClass();
64
65 /* IUnknown methods */
66 STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObj) override;
67 STDMETHOD_(ULONG, AddRef)() override;
68 STDMETHOD_(ULONG, Release)() override;
69
70 /* IClassFactory methods */
71 STDMETHOD(CreateInstance)(IUnknown* punkOuter, REFIID riid, void** ppv) override;
72 STDMETHOD(LockServer)(BOOL fLock) override;
73
74protected:
75 oslInterlockedCount m_refCount;
76 std::function<const Reference<XInterface>()> m_xInstFunction;
80};
81
82// Implementation of the UNO service com.sun.star.bridge.OleBridgeSupplier2.
83
84// This class realizes the service com.sun.star.bridge.OleBridgeSupplier2 and
85// com.sun.star.bridge.OleBridgeSupplierVar1. The class implements XBridgeSupplier2 which
86// interface does not need a Machine Id in its createBridge function anymore,
87// If a UNO interface is to be converted then the member m_nUnoWrapperClass determines
88// what wrapper class is to be used. There are currently InterfaceOleWrapper and
89// UnoObjectWrapperRemoteOpt. The first is used for the OleBridgeSupplier2 and the
90// latter for OleBridgeSupplierVar1.
91// The m_nComWrapperClass specifies the class which is used as wrapper for COM interfaces.
92// Currently there is only one class available (IUnknownWrapper).
93class OleConverter : public WeakImplHelper<XBridgeSupplier2, XInitialization, css::lang::XServiceInfo>,
94 public UnoConversionUtilities<OleConverter>
95{
96public:
97 explicit OleConverter( const Reference<XMultiServiceFactory>& smgr);
98 OleConverter( const Reference<XMultiServiceFactory>& smgr, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass );
99 virtual ~OleConverter() override;
100
101 // XBridgeSupplier2 ---------------------------------------------------
102
103 Any SAL_CALL createBridge(const Any& modelDepObject,
104 const Sequence<sal_Int8>& ProcessId,
105 sal_Int16 sourceModelType,
106 sal_Int16 destModelType) override;
107
108 // XInitialization
109 void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
110
111 OUString SAL_CALL getImplementationName() override;
112
113 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
114
115 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
116
117 // UnoConversionUtilities
120protected:
121
122};
123
124// Implementation of the UNO service com.sun.star.bridge.OleObjectFactory.
125
126class OleClient : public WeakImplHelper<XMultiServiceFactory, css::lang::XServiceInfo>,
127 public UnoConversionUtilities<OleClient>
128{
129public:
130 explicit OleClient( const Reference<XMultiServiceFactory>& smgr);
131 ~OleClient() override;
132
133 // XMultiServiceFactory
134 Reference<XInterface> SAL_CALL createInstance(const OUString& ServiceSpecifier) override;
135 Reference<XInterface> SAL_CALL createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& Arguments) override;
137
138 OUString SAL_CALL getImplementationName() override;
139
140 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
141
142 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
143
144 // UnoConversionUtilities
147
148protected:
150};
151
152/*****************************************************************************
153
154 OleServer
155
156 Implementation of the UNO service com.sun.star.bridge.OleApplicationRegistration.
157 Register the calling application as OLE automation server for
158 standard OLE object. The objects will be registered while instantiating
159 this implementation and deregistered, if this implementation is destroyed.
160
161*****************************************************************************/
162
163class OleServer : public cppu::WeakImplHelper<css::lang::XServiceInfo>
164{
165public:
166 explicit OleServer( const Reference<XMultiServiceFactory> &smgr);
167 ~OleServer() override;
168
169 OUString SAL_CALL getImplementationName() override;
170
171 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
172
173 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
174
175protected:
176 bool provideInstance(std::function<const Reference<XInterface>()> xInstFunction, GUID const * guid);
177
178 std::list< OneInstanceOleWrapper* > m_wrapperList;
180
182};
183
184/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
~OleClient() override
Definition: servprov.cxx:362
Reference< XBridgeSupplier2 > m_bridgeSupplier
Definition: servprov.hxx:149
Reference< XInterface > createComWrapperInstance() override
Definition: servprov.cxx:461
Reference< XInterface > SAL_CALL createInstance(const OUString &ServiceSpecifier) override
Definition: servprov.cxx:390
Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: servprov.cxx:366
Reference< XInterface > createUnoWrapperInstance() override
Definition: servprov.cxx:443
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: servprov.cxx:378
Reference< XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const Sequence< Any > &Arguments) override
Definition: servprov.cxx:437
OleClient(const Reference< XMultiServiceFactory > &smgr)
Definition: servprov.cxx:350
OUString SAL_CALL getImplementationName() override
Definition: servprov.cxx:373
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: servprov.cxx:383
Any SAL_CALL createBridge(const Any &modelDepObject, const Sequence< sal_Int8 > &ProcessId, sal_Int16 sourceModelType, sal_Int16 destModelType) override
Definition: servprov.cxx:202
Reference< XInterface > createComWrapperInstance() override
Definition: servprov.cxx:343
OUString SAL_CALL getImplementationName() override
Definition: servprov.cxx:288
virtual ~OleConverter() override
Definition: servprov.cxx:197
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: servprov.cxx:295
OleConverter(const Reference< XMultiServiceFactory > &smgr)
Definition: servprov.cxx:184
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: servprov.cxx:300
Reference< XInterface > createUnoWrapperInstance() override
Definition: servprov.cxx:325
void SAL_CALL initialize(const Sequence< Any > &aArguments) override
Definition: servprov.cxx:313
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: servprov.cxx:530
std::list< OneInstanceOleWrapper * > m_wrapperList
Definition: servprov.hxx:178
bool provideInstance(std::function< const Reference< XInterface >()> xInstFunction, GUID const *guid)
Definition: servprov.cxx:537
~OleServer() override
Definition: servprov.cxx:510
Reference< XBridgeSupplier2 > m_bridgeSupplier
Definition: servprov.hxx:179
OleServer(const Reference< XMultiServiceFactory > &smgr)
Definition: servprov.cxx:468
OUString SAL_CALL getImplementationName() override
Definition: servprov.cxx:520
Reference< XMultiServiceFactory > m_smgr
Definition: servprov.hxx:181
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: servprov.cxx:525
Reference< XBridgeSupplier2 > m_bridgeSupplier
Definition: servprov.hxx:78
bool registerClass(GUID const *pGuid)
Definition: servprov.cxx:81
STDMETHOD_(ULONG, AddRef)() override
STDMETHOD_(ULONG, Release)() override
virtual ~OneInstanceOleWrapper()
Definition: servprov.cxx:77
OneInstanceOleWrapper(const Reference< XMultiServiceFactory > &smgr, std::function< const Reference< XInterface >()> xInstFunction)
Definition: servprov.cxx:61
STDMETHOD() CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv) override
Definition: servprov.cxx:140
Reference< XMultiServiceFactory > m_smgr
Definition: servprov.hxx:79
STDMETHOD() QueryInterface(REFIID riid, void **ppvObj) override
Definition: servprov.cxx:104
STDMETHOD() LockServer(BOOL fLock) override
Definition: servprov.cxx:179
std::function< const Reference< XInterface >()> m_xInstFunction
Definition: servprov.hxx:76
oslInterlockedCount m_refCount
Definition: servprov.hxx:75
All methods are allowed to throw at least a BridgeRuntimeError.
Sequence< PropertyValue > aArguments
const wchar_t *typedef BOOL
Reference< XInterface > OleClient_CreateInstance(const Reference< XMultiServiceFactory > &xSMgr)
Definition: servreg.cxx:40
Reference< XInterface > OleServer_CreateInstance(const Reference< XMultiServiceFactory > &xSMgr)
Definition: servreg.cxx:46
Reference< XInterface > ConverterProvider_CreateInstanceVar1(const Reference< XMultiServiceFactory > &xSMgr)
Definition: servreg.cxx:34
Reference< XInterface > ConverterProvider_CreateInstance2(const Reference< XMultiServiceFactory > &xSMgr)
Definition: servreg.cxx:28
unsigned char sal_uInt8
unsigned char sal_Bool