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()
99 STDMETHODIMP
OleWrapperAdviseSink::QueryInterface( REFIID riid
, void** ppv
)
103 if ( riid
== IID_IUnknown
)
104 *ppv
= (IUnknown
*)this;
106 if ( riid
== IID_IAdviseSink
)
107 *ppv
= (IAdviseSink
*)this;
111 ((IUnknown
*)*ppv
)->AddRef();
115 return E_NOINTERFACE
;
118 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::AddRef()
120 return ++m_nRefCount
;
123 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::Release()
125 ULONG nReturn
= --m_nRefCount
;
126 if ( m_nRefCount
== 0 )
132 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( LPFORMATETC pFetc
, LPSTGMEDIUM pMedium
)
136 m_pListener
->OnDataChange( pFetc
, pMedium
);
140 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect
, LONG lindex
)
144 m_pListener
->OnViewChange( dwAspect
, lindex
);
148 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( LPMONIKER pMoniker
)
152 m_pListener
->OnRename( pMoniker
);
156 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave()
160 m_pListener
->OnSave();
164 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose()
168 m_pListener
->OnClose();
171 if ( m_bHandleClosed
)
175 } // namespace inprocserv
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */