tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / embedserv / source / inprocserv / advisesink.cxx
blobf06cffbf62cdcfc91c8f6422eaf16ed1fa097460
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
24 namespace inprocserv
27 OleWrapperAdviseSink::OleWrapperAdviseSink()
28 : m_nRefCount( 0 )
29 , m_nAspect( DVASPECT_CONTENT )
30 , m_nRegID( 0 )
31 , m_bObjectAdvise( TRUE )
32 , m_nDataRegFlag( 0 )
33 , m_nViewRegFlag( 0 )
34 , m_bHandleClosed( TRUE )
35 , m_bClosed( FALSE )
39 OleWrapperAdviseSink::OleWrapperAdviseSink( const sal::systools::COMReference< IAdviseSink >& pListener )
40 : m_nRefCount( 0 )
41 , m_pListener( pListener )
42 , m_nAspect( DVASPECT_CONTENT )
43 , m_nRegID( 0 )
44 , m_bObjectAdvise( TRUE )
45 , m_nDataRegFlag( 0 )
46 , m_nViewRegFlag( 0 )
47 , m_bHandleClosed( FALSE )
48 , m_bClosed( FALSE )
52 OleWrapperAdviseSink::OleWrapperAdviseSink( const sal::systools::COMReference< IAdviseSink >& pListener, FORMATETC* pFormatEtc, DWORD nDataRegFlag )
53 : m_nRefCount( 0 )
54 , m_pListener( pListener )
55 , m_nAspect( DVASPECT_CONTENT )
56 , m_nRegID( 0 )
57 , m_bObjectAdvise( FALSE )
58 , m_nDataRegFlag( nDataRegFlag )
59 , m_nViewRegFlag( 0 )
60 , m_bHandleClosed( FALSE )
61 , m_bClosed( FALSE )
63 if ( pFormatEtc )
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 )
75 : m_nRefCount( 0 )
76 , m_pListener( pListener )
77 , m_nAspect( nAspect )
78 , m_nRegID( 0 )
79 , m_bObjectAdvise( TRUE )
80 , m_nDataRegFlag( 0 )
81 , m_nViewRegFlag( nViewRegFlag )
82 , m_bHandleClosed( FALSE )
83 , m_bClosed( FALSE )
87 OleWrapperAdviseSink::~OleWrapperAdviseSink()
90 STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv )
92 *ppv=nullptr;
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();
103 return S_OK;
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 )
118 delete this;
120 return nReturn;
123 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( FORMATETC * pFetc, STGMEDIUM * pMedium )
125 if ( m_pListener )
127 m_pListener->OnDataChange( pFetc, pMedium );
131 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect, LONG lindex )
133 if ( m_pListener )
135 m_pListener->OnViewChange( dwAspect, lindex );
139 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( IMoniker * pMoniker )
141 if ( m_pListener )
143 m_pListener->OnRename( pMoniker );
147 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave()
149 if ( m_pListener )
151 m_pListener->OnSave();
155 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose()
157 if ( m_pListener )
159 m_pListener->OnClose();
162 if ( m_bHandleClosed )
163 m_bClosed = TRUE;
166 } // namespace inprocserv
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */