1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_OLE_SERVPROV_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_OLE_SERVPROV_HXX
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <cppuhelper/implbase.hxx>
27 #include "ole2uno.hxx"
28 #include "unoconversionutilities.hxx"
30 using namespace com::sun::star::bridge
;
36 Reference
< XInterface
> SAL_CALL
ConverterProvider_CreateInstance( const Reference
<XMultiServiceFactory
> & xSMgr
)
38 Reference
< XInterface
> SAL_CALL
ConverterProvider_CreateInstance2( const Reference
<XMultiServiceFactory
> & xSMgr
)
40 Reference
< XInterface
> SAL_CALL
ConverterProvider_CreateInstanceVar1( const Reference
<XMultiServiceFactory
> & xSMgr
)
42 Reference
<XInterface
> SAL_CALL
OleClient_CreateInstance( const Reference
<XMultiServiceFactory
> & xSMgr
)
44 Reference
<XInterface
> SAL_CALL
OleServer_CreateInstance( const Reference
<XMultiServiceFactory
> & xSMgr
)
46 /*****************************************************************************
48 class declaration IClassFactoryWrapper
50 Specify abstract helper methods on class factories, which provide
51 UNO objects. These methods are used by objects of class OleServer_Impl,
52 to handle the OLE registration of different class factories.
54 *****************************************************************************/
56 class IClassFactoryWrapper
: public IClassFactory
60 virtual sal_Bool
registerClass() = 0;
61 virtual sal_Bool
deregisterClass() = 0;
64 /*****************************************************************************
66 class declaration ProviderOleWrapper_Impl
68 Provides an UNO service provider as OLE class factory. Handle the
69 OLE registration by overriding the abstract methods from
72 Acts as a COM class factory. When IClassFactory::CreateInstance is being called
73 then it creates an service by help of the XSingleServiceFactory member and maps
74 maps it to a COM object.
76 *****************************************************************************/
78 class ProviderOleWrapper_Impl
: public IClassFactoryWrapper
82 ProviderOleWrapper_Impl( const Reference
<XMultiServiceFactory
>& smgr
,
83 const Reference
<XSingleServiceFactory
>& xSFactory
, GUID
* pGuid
);
84 virtual ~ProviderOleWrapper_Impl();
86 sal_Bool
registerClass();
87 sal_Bool
deregisterClass();
89 /* IUnknown methods */
90 STDMETHOD(QueryInterface
)(REFIID riid
, LPVOID FAR
* ppvObj
);
91 STDMETHOD_(ULONG
, AddRef
)();
92 STDMETHOD_(ULONG
, Release
)();
94 /* IClassFactory methods */
95 STDMETHOD(CreateInstance
)(IUnknown FAR
* punkOuter
, REFIID riid
, void FAR
* FAR
* ppv
);
96 STDMETHOD(LockServer
)(int fLock
);
100 oslInterlockedCount m_refCount
;
101 Reference
<XSingleServiceFactory
> m_xSingleServiceFactory
;
103 DWORD m_factoryHandle
;
104 Reference
<XBridgeSupplier2
> m_bridgeSupplier
;
105 Reference
<XMultiServiceFactory
> m_smgr
;
108 /*****************************************************************************
110 class declaration OneInstanceOleWrapper_Impl
112 Provides an single UNO object as OLE object. Handle the
113 OLE registration by overriding the abstract methods from
114 IClassFactoryWrapper.
116 Acts as a COM class factory. When IClassFactory::CreateInstance is being called
117 then it maps the XInstance member it to a COM object.
119 *****************************************************************************/
121 class OneInstanceOleWrapper_Impl
: public IClassFactoryWrapper
125 OneInstanceOleWrapper_Impl( const Reference
<XMultiServiceFactory
>& smgr
, const Reference
<XInterface
>& xInst
, GUID
* pGuid
);
126 virtual ~OneInstanceOleWrapper_Impl();
128 sal_Bool
registerClass();
129 sal_Bool
deregisterClass();
131 /* IUnknown methods */
132 STDMETHOD(QueryInterface
)(REFIID riid
, LPVOID FAR
* ppvObj
);
133 STDMETHOD_(ULONG
, AddRef
)();
134 STDMETHOD_(ULONG
, Release
)();
136 /* IClassFactory methods */
137 STDMETHOD(CreateInstance
)(IUnknown FAR
* punkOuter
, REFIID riid
, void FAR
* FAR
* ppv
);
138 STDMETHOD(LockServer
)(int fLock
);
142 oslInterlockedCount m_refCount
;
143 Reference
<XInterface
> m_xInst
;
145 DWORD m_factoryHandle
;
146 Reference
<XBridgeSupplier2
> m_bridgeSupplier
;
147 Reference
<XMultiServiceFactory
> m_smgr
;
150 /*****************************************************************************
152 class declaration OleConverter_Impl2
154 Implementation of the UNO service com.sun.star.bridge.OleBridgeSupplier2.
156 *****************************************************************************/
158 // This class realizes the service com.sun.star.bridge.OleBridgeSupplier2 and
159 // com.sun.star.bridge.OleBridgeSupplierVar1. The class implements XBridgeSupplier2
160 // instead of XBridgeSuppplier as done by class OleConverter_Impl. The XBridgeSupplier2
161 // interface does not need a Maschine Id in its createBridge function anymore,
162 // If an UNO interface is to be converted then the member m_nUnoWrapperClass determines
163 // what wrapper class is to be used. There are currently InterfaceOleWrapper_Impl and
164 // UnoObjectWrapperRemoteOpt. The first is used for the OleBridgeSupplier2 and the
165 // latter for OleBridgeSupplierVar1.
166 // The m_nComWrapperClass specifies the class which is used as wrapper for COM interfaces.
167 // Currently there is only one class available ( IUnknownWrapper_Impl).
168 class OleConverter_Impl2
: public WeakImplHelper
<XBridgeSupplier2
, XInitialization
, css::lang::XServiceInfo
>,
169 public UnoConversionUtilities
<OleConverter_Impl2
>
172 OleConverter_Impl2( const Reference
<XMultiServiceFactory
>& smgr
);
173 OleConverter_Impl2( const Reference
<XMultiServiceFactory
>& smgr
, sal_uInt8 unoWrapperClass
, sal_uInt8 comWrapperClass
);
174 virtual ~OleConverter_Impl2();
176 // XBridgeSupplier2 ---------------------------------------------------
178 virtual Any SAL_CALL
createBridge(const Any
& modelDepObject
,
179 const Sequence
<sal_Int8
>& ProcessId
,
180 sal_Int16 sourceModelType
,
181 sal_Int16 destModelType
)
182 throw (IllegalArgumentException
, RuntimeException
);
185 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) throw(Exception
, RuntimeException
);
187 OUString SAL_CALL
getImplementationName()
188 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
190 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
191 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
193 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
194 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
196 // Abstract struct UnoConversionUtilities
197 virtual Reference
< XInterface
> createUnoWrapperInstance();
198 virtual Reference
< XInterface
> createComWrapperInstance();
204 /*****************************************************************************
206 class declaration OleClient_Impl
208 Implementation of the UNO service com.sun.star.bridge.OleObjectFactory.
210 *****************************************************************************/
213 class OleClient_Impl
: public WeakImplHelper
<XMultiServiceFactory
, css::lang::XServiceInfo
>,
214 public UnoConversionUtilities
<OleClient_Impl
>
217 OleClient_Impl( const Reference
<XMultiServiceFactory
>& smgr
);
220 // XMultiServiceFactory
221 virtual Reference
<XInterface
> SAL_CALL
createInstance(const OUString
& ServiceSpecifier
) throw( Exception
, RuntimeException
);
222 virtual Reference
<XInterface
> SAL_CALL
createInstanceWithArguments(const OUString
& ServiceSpecifier
, const Sequence
< Any
>& Arguments
) throw (Exception
, RuntimeException
);
223 Sequence
< OUString
> SAL_CALL
getAvailableServiceNames() throw (RuntimeException
);
225 OUString SAL_CALL
getImplementationName()
226 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
228 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
229 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
231 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
232 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
234 // Abstract struct UnoConversionUtilities
235 virtual Reference
< XInterface
> createUnoWrapperInstance();
236 virtual Reference
< XInterface
> createComWrapperInstance();
239 Reference
<XBridgeSupplier2
> m_bridgeSupplier
;
242 /*****************************************************************************
244 class declaration OleServer_Impl
246 Implementation of the UNO service com.sun.star.bridge.OleApplicationRegistration.
247 Register the calling application as OLE automation server for
248 standard OLE object. The objects will be registered while instanciating
249 this implementation and deregistrated, if this implementation is destroyed.
251 *****************************************************************************/
253 class OleServer_Impl
: public cppu::WeakImplHelper
<css::lang::XServiceInfo
>
256 OleServer_Impl( const Reference
<XMultiServiceFactory
> &smgr
);
259 OUString SAL_CALL
getImplementationName()
260 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
262 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
)
263 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
265 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames()
266 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
270 sal_Bool
provideService(const Reference
<XSingleServiceFactory
>& xMulFact
, GUID
* guid
);
271 sal_Bool
provideInstance(const Reference
<XInterface
>& xInst
, GUID
* guid
);
273 list
< IClassFactoryWrapper
* > m_wrapperList
;
274 Reference
< XBridgeSupplier2
> m_bridgeSupplier
;
276 Reference
<XMultiServiceFactory
> m_smgr
;
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */