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 #include <sal/config.h>
22 #include "advisesink.hxx"
27 OleWrapperAdviseSink::OleWrapperAdviseSink()
29 , m_nAspect( DVASPECT_CONTENT
)
31 , m_bObjectAdvise( TRUE
)
34 , m_bHandleClosed( TRUE
)
39 OleWrapperAdviseSink::OleWrapperAdviseSink( const sal::systools::COMReference
< IAdviseSink
>& pListener
)
41 , m_pListener( pListener
)
42 , m_nAspect( DVASPECT_CONTENT
)
44 , m_bObjectAdvise( TRUE
)
47 , m_bHandleClosed( FALSE
)
52 OleWrapperAdviseSink::OleWrapperAdviseSink( const sal::systools::COMReference
< IAdviseSink
>& pListener
, FORMATETC
* pFormatEtc
, DWORD nDataRegFlag
)
54 , m_pListener( pListener
)
55 , m_nAspect( DVASPECT_CONTENT
)
57 , m_bObjectAdvise( FALSE
)
58 , m_nDataRegFlag( nDataRegFlag
)
60 , m_bHandleClosed( FALSE
)
65 m_pFormatEtc
= std::make_unique
<FORMATETC
>();
66 m_pFormatEtc
->cfFormat
= pFormatEtc
->cfFormat
;
67 m_pFormatEtc
->ptd
= nullptr;
68 m_pFormatEtc
->dwAspect
= pFormatEtc
->dwAspect
;
69 m_pFormatEtc
->lindex
= pFormatEtc
->lindex
;
70 m_pFormatEtc
->tymed
= pFormatEtc
->tymed
;
74 OleWrapperAdviseSink::OleWrapperAdviseSink( const sal::systools::COMReference
< IAdviseSink
>& pListener
, DWORD nAspect
, DWORD nViewRegFlag
)
76 , m_pListener( pListener
)
77 , m_nAspect( nAspect
)
79 , m_bObjectAdvise( TRUE
)
81 , m_nViewRegFlag( nViewRegFlag
)
82 , m_bHandleClosed( FALSE
)
87 OleWrapperAdviseSink::~OleWrapperAdviseSink()
90 STDMETHODIMP
OleWrapperAdviseSink::QueryInterface( REFIID riid
, void** ppv
)
94 if ( riid
== IID_IUnknown
)
95 *ppv
= static_cast<IUnknown
*>(this);
97 if ( riid
== IID_IAdviseSink
)
98 *ppv
= static_cast<IAdviseSink
*>(this);
100 if ( *ppv
!= nullptr )
102 static_cast<IUnknown
*>(*ppv
)->AddRef();
106 return E_NOINTERFACE
;
109 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::AddRef()
111 return ++m_nRefCount
;
114 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::Release()
116 ULONG nReturn
= --m_nRefCount
;
117 if ( m_nRefCount
== 0 )
123 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( FORMATETC
* pFetc
, STGMEDIUM
* pMedium
)
127 m_pListener
->OnDataChange( pFetc
, pMedium
);
131 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect
, LONG lindex
)
135 m_pListener
->OnViewChange( dwAspect
, lindex
);
139 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( IMoniker
* pMoniker
)
143 m_pListener
->OnRename( pMoniker
);
147 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave()
151 m_pListener
->OnSave();
155 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose()
159 m_pListener
->OnClose();
162 if ( m_bHandleClosed
)
166 } // namespace inprocserv
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */