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 <sal/config.h>
26 #if !defined WIN32_LEAN_AND_MEAN
27 #define WIN32_LEAN_AND_MEAN
31 #include <systools/win32/comtools.hxx>
35 class OleWrapperAdviseSink
: public IAdviseSink
40 sal::systools::COMReference
<IAdviseSink
> m_pListener
;
43 std::unique_ptr
<FORMATETC
> m_pFormatEtc
;
47 DWORD m_bObjectAdvise
;
55 // an AdviseSink for own needs, should be created always
56 OleWrapperAdviseSink();
58 // an AdviseSink for IOleObject interface
59 explicit OleWrapperAdviseSink(const sal::systools::COMReference
<IAdviseSink
>& pListener
);
61 // an AdviseSink for IDataObject interface
62 OleWrapperAdviseSink(const sal::systools::COMReference
<IAdviseSink
>& pListener
,
63 FORMATETC
* pFormatEtc
, DWORD nDataRegFlag
);
65 // an AdviseSink for IViewObject interface
66 OleWrapperAdviseSink(const sal::systools::COMReference
<IAdviseSink
>& pListener
, DWORD nAspect
,
69 virtual ~OleWrapperAdviseSink();
71 void SetRegID(DWORD nRegID
) { m_nRegID
= nRegID
; }
72 DWORD
GetRegID() { return m_nRegID
; }
74 bool IsOleAdvise() { return m_bObjectAdvise
; }
75 DWORD
GetDataAdviseFlag() { return m_nDataRegFlag
; }
76 DWORD
GetViewAdviseFlag() { return m_nViewRegFlag
; }
78 FORMATETC
* GetFormatEtc() { return m_pFormatEtc
.get(); }
79 DWORD
GetAspect() { return m_nAspect
; }
80 sal::systools::COMReference
<IAdviseSink
>& GetOrigAdvise() { return m_pListener
; }
81 void DisconnectOrigAdvise() { m_pListener
= nullptr; }
83 void SetClosed() { m_bClosed
= TRUE
; }
84 void UnsetClosed() { m_bClosed
= FALSE
; }
85 BOOL
IsClosed() { return m_bClosed
; }
87 STDMETHODIMP
QueryInterface(REFIID
, void**) override
;
88 STDMETHODIMP_(ULONG
) AddRef() override
;
89 STDMETHODIMP_(ULONG
) Release() override
;
91 STDMETHODIMP_(void) OnDataChange(FORMATETC
*, STGMEDIUM
*) override
;
92 STDMETHODIMP_(void) OnViewChange(DWORD
, LONG
) override
;
93 STDMETHODIMP_(void) OnRename(IMoniker
*) override
;
94 STDMETHODIMP_(void) OnSave() override
;
95 STDMETHODIMP_(void) OnClose() override
;
98 }; // namespace advisesink
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */