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 .
21 #pragma warning(disable : 4668)
24 #include <advisesink.hxx>
29 OleWrapperAdviseSink::OleWrapperAdviseSink()
31 , m_pFormatEtc( NULL
)
32 , m_nAspect( DVASPECT_CONTENT
)
34 , m_bObjectAdvise( TRUE
)
37 , m_bHandleClosed( TRUE
)
42 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
)
44 , m_pListener( pListener
)
45 , m_pFormatEtc( NULL
)
46 , m_nAspect( DVASPECT_CONTENT
)
48 , m_bObjectAdvise( TRUE
)
51 , m_bHandleClosed( FALSE
)
56 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, FORMATETC
* pFormatEtc
, DWORD nDataRegFlag
)
58 , m_pListener( pListener
)
59 , m_pFormatEtc( NULL
)
60 , m_nAspect( DVASPECT_CONTENT
)
62 , m_bObjectAdvise( FALSE
)
63 , m_nDataRegFlag( nDataRegFlag
)
65 , m_bHandleClosed( FALSE
)
70 m_pFormatEtc
= new FORMATETC
;
71 m_pFormatEtc
->cfFormat
= pFormatEtc
->cfFormat
;
72 m_pFormatEtc
->ptd
= NULL
;
73 m_pFormatEtc
->dwAspect
= pFormatEtc
->dwAspect
;
74 m_pFormatEtc
->lindex
= pFormatEtc
->lindex
;
75 m_pFormatEtc
->tymed
= pFormatEtc
->tymed
;
79 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, DWORD nAspect
, DWORD nViewRegFlag
)
81 , m_pListener( pListener
)
82 , m_pFormatEtc( NULL
)
83 , m_nAspect( nAspect
)
85 , m_bObjectAdvise( TRUE
)
87 , m_nViewRegFlag( nViewRegFlag
)
88 , m_bHandleClosed( FALSE
)
93 OleWrapperAdviseSink::~OleWrapperAdviseSink()
98 STDMETHODIMP
OleWrapperAdviseSink::QueryInterface( REFIID riid
, void** ppv
)
102 if ( riid
== IID_IUnknown
)
103 *ppv
= (IUnknown
*)this;
105 if ( riid
== IID_IAdviseSink
)
106 *ppv
= (IAdviseSink
*)this;
110 ((IUnknown
*)*ppv
)->AddRef();
114 return E_NOINTERFACE
;
117 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::AddRef()
119 return ++m_nRefCount
;
122 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::Release()
124 ULONG nReturn
= --m_nRefCount
;
125 if ( m_nRefCount
== 0 )
131 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( LPFORMATETC pFetc
, LPSTGMEDIUM pMedium
)
135 m_pListener
->OnDataChange( pFetc
, pMedium
);
139 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect
, LONG lindex
)
143 m_pListener
->OnViewChange( dwAspect
, lindex
);
147 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( LPMONIKER pMoniker
)
151 m_pListener
->OnRename( pMoniker
);
155 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave()
159 m_pListener
->OnSave();
163 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose()
167 m_pListener
->OnClose();
170 if ( m_bHandleClosed
)
174 } // namespace inprocserv
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */