1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: advisesink.cxx,v $
9 * last change: $Author: mav $ $Date: 2008/10/30 11:59:06 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #pragma warning(disable : 4668)
38 #include <advisesink.hxx>
43 OleWrapperAdviseSink::OleWrapperAdviseSink()
45 , m_pFormatEtc( NULL
)
46 , m_nAspect( DVASPECT_CONTENT
)
48 , m_bObjectAdvise( TRUE
)
51 , m_bHandleClosed( TRUE
)
56 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
)
58 , m_pListener( pListener
)
59 , m_pFormatEtc( NULL
)
60 , m_nAspect( DVASPECT_CONTENT
)
62 , m_bObjectAdvise( TRUE
)
65 , m_bHandleClosed( FALSE
)
70 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, FORMATETC
* pFormatEtc
, DWORD nDataRegFlag
)
72 , m_pListener( pListener
)
73 , m_pFormatEtc( NULL
)
74 , m_nAspect( DVASPECT_CONTENT
)
76 , m_bObjectAdvise( FALSE
)
77 , m_nDataRegFlag( nDataRegFlag
)
79 , m_bHandleClosed( FALSE
)
84 m_pFormatEtc
= new FORMATETC
;
85 m_pFormatEtc
->cfFormat
= pFormatEtc
->cfFormat
;
86 m_pFormatEtc
->ptd
= NULL
;
87 m_pFormatEtc
->dwAspect
= pFormatEtc
->dwAspect
;
88 m_pFormatEtc
->lindex
= pFormatEtc
->lindex
;
89 m_pFormatEtc
->tymed
= pFormatEtc
->tymed
;
93 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart
< IAdviseSink
>& pListener
, DWORD nAspect
, DWORD nViewRegFlag
)
95 , m_pListener( pListener
)
96 , m_pFormatEtc( NULL
)
97 , m_nAspect( nAspect
)
99 , m_bObjectAdvise( TRUE
)
100 , m_nDataRegFlag( 0 )
101 , m_nViewRegFlag( nViewRegFlag
)
102 , m_bHandleClosed( FALSE
)
107 OleWrapperAdviseSink::~OleWrapperAdviseSink()
113 STDMETHODIMP
OleWrapperAdviseSink::QueryInterface( REFIID riid
, void** ppv
)
117 if ( riid
== IID_IUnknown
)
118 *ppv
= (IUnknown
*)this;
120 if ( riid
== IID_IAdviseSink
)
121 *ppv
= (IAdviseSink
*)this;
125 ((IUnknown
*)*ppv
)->AddRef();
129 return E_NOINTERFACE
;
132 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::AddRef()
134 return ++m_nRefCount
;
137 STDMETHODIMP_(ULONG
) OleWrapperAdviseSink::Release()
139 ULONG nReturn
= --m_nRefCount
;
140 if ( m_nRefCount
== 0 )
146 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( LPFORMATETC pFetc
, LPSTGMEDIUM pMedium
)
150 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnDataChange():" );
151 m_pListener
->OnDataChange( pFetc
, pMedium
);
155 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect
, LONG lindex
)
159 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnViewChange():" );
160 m_pListener
->OnViewChange( dwAspect
, lindex
);
164 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( LPMONIKER pMoniker
)
168 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnRename():" );
169 m_pListener
->OnRename( pMoniker
);
173 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave(void)
177 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnSave():" );
178 m_pListener
->OnSave();
182 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose(void)
186 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnClose():" );
187 m_pListener
->OnClose();
190 if ( m_bHandleClosed
)
194 } // namespace inprocserv