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_EMBEDSERV_SOURCE_INPROCSERV_ADVISESINK_HXX
21 #define INCLUDED_EMBEDSERV_SOURCE_INPROCSERV_ADVISESINK_HXX
23 #include <sal/config.h>
27 #if !defined WIN32_LEAN_AND_MEAN
28 # define WIN32_LEAN_AND_MEAN
32 #include "smartpointer.hxx"
34 namespace inprocserv
{
36 class OleWrapperAdviseSink
: public IAdviseSink
41 ComSmart
< IAdviseSink
> m_pListener
;
44 std::unique_ptr
<FORMATETC
> m_pFormatEtc
;
48 DWORD m_bObjectAdvise
;
56 // an AdviseSink for own needs, should be created always
57 OleWrapperAdviseSink();
59 // an AdviseSink for IOleObject interface
60 explicit OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
);
62 // an AdviseSink for IDataObject interface
63 OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, FORMATETC
* pFormatEtc
, DWORD nDataRegFlag
);
65 // an AdviseSink for IViewObject interface
66 OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, DWORD nAspect
, DWORD nViewRegFlag
);
68 virtual ~OleWrapperAdviseSink();
70 void SetRegID( DWORD nRegID
) { m_nRegID
= nRegID
; }
71 DWORD
GetRegID() { return m_nRegID
; }
73 BOOL
IsOleAdvise() { return m_bObjectAdvise
; }
74 DWORD
GetDataAdviseFlag() { return m_nDataRegFlag
; }
75 DWORD
GetViewAdviseFlag() { return m_nViewRegFlag
; }
77 FORMATETC
* GetFormatEtc() { return m_pFormatEtc
.get(); }
78 DWORD
GetAspect() { return m_nAspect
; }
79 ComSmart
< IAdviseSink
>& GetOrigAdvise() { return m_pListener
; }
80 void DisconnectOrigAdvise() { m_pListener
= nullptr; }
82 void SetClosed() { m_bClosed
= TRUE
; }
83 void UnsetClosed() { m_bClosed
= FALSE
; }
84 BOOL
IsClosed() { return m_bClosed
; }
86 STDMETHODIMP
QueryInterface(REFIID
, void**) override
;
87 STDMETHODIMP_(ULONG
) AddRef() override
;
88 STDMETHODIMP_(ULONG
) Release() override
;
90 STDMETHODIMP_(void) OnDataChange(FORMATETC
*, STGMEDIUM
*) override
;
91 STDMETHODIMP_(void) OnViewChange(DWORD
, LONG
) override
;
92 STDMETHODIMP_(void) OnRename(IMoniker
*) override
;
93 STDMETHODIMP_(void) OnSave() override
;
94 STDMETHODIMP_(void) OnClose() override
;
97 }; // namespace advisesink
99 #endif // INCLUDED_EMBEDSERV_SOURCE_INPROCSERV_ADVISESINK_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */