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 .
22 #include <com/sun/star/lang/XComponent.hpp>
23 #include <com/sun/star/util/XCloseListener.hpp>
24 #include <com/sun/star/frame/XTerminateListener.hpp>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <comphelper/interfacecontainer4.hxx>
28 #include <cppuhelper/weakref.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <rtl/ref.hxx>
33 namespace com::sun::star::embed
{ class XActionsApproval
; }
38 // the service is implemented as a wrapper to be able to die by refcount
39 // the disposing mechanics is required for java related scenarios
40 class OInstanceLocker
: public ::cppu::WeakImplHelper
< css::lang::XComponent
,
41 css::lang::XInitialization
,
42 css::lang::XServiceInfo
>
46 rtl::Reference
< OLockListener
> m_xLockListener
;
48 comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> m_aListenersContainer
; // list of listeners
54 explicit OInstanceLocker();
55 virtual ~OInstanceLocker() override
;
58 virtual void SAL_CALL
dispose() override
;
59 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
60 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
63 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
66 virtual OUString SAL_CALL
getImplementationName( ) override
;
67 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
68 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
73 class OLockListener
: public ::cppu::WeakImplHelper
< css::util::XCloseListener
,
74 css::frame::XTerminateListener
>
77 css::uno::Reference
< css::uno::XInterface
> m_xInstance
;
78 css::uno::Reference
< css::embed::XActionsApproval
> m_xApproval
;
80 css::uno::WeakReference
< css::lang::XComponent
> m_xWrapper
;
88 OLockListener( css::uno::WeakReference
< css::lang::XComponent
> xWrapper
,
89 css::uno::Reference
< css::uno::XInterface
> xInstance
,
91 css::uno::Reference
< css::embed::XActionsApproval
> xApproval
);
93 virtual ~OLockListener() override
;
99 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
102 virtual void SAL_CALL
queryClosing( const css::lang::EventObject
& Source
, sal_Bool GetsOwnership
) override
;
103 virtual void SAL_CALL
notifyClosing( const css::lang::EventObject
& Source
) override
;
105 // XTerminateListener
106 virtual void SAL_CALL
queryTermination( const css::lang::EventObject
& Event
) override
;
107 virtual void SAL_CALL
notifyTermination( const css::lang::EventObject
& Event
) override
;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */