update dev300-m58
[ooovba.git] / embedserv / source / inprocserv / advisesink.cxx
blobea61f866c372f6fb9292841e4cfbe3143c34200f
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: advisesink.cxx,v $
7 * $Revision: 1.1.8.2 $
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,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 #pragma warning(disable : 4668)
38 #include <advisesink.hxx>
40 namespace inprocserv
43 OleWrapperAdviseSink::OleWrapperAdviseSink()
44 : m_nRefCount( 0 )
45 , m_pFormatEtc( NULL )
46 , m_nAspect( DVASPECT_CONTENT )
47 , m_nRegID( 0 )
48 , m_bObjectAdvise( TRUE )
49 , m_nDataRegFlag( 0 )
50 , m_nViewRegFlag( 0 )
51 , m_bHandleClosed( TRUE )
52 , m_bClosed( FALSE )
56 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener )
57 : m_nRefCount( 0 )
58 , m_pListener( pListener )
59 , m_pFormatEtc( NULL )
60 , m_nAspect( DVASPECT_CONTENT )
61 , m_nRegID( 0 )
62 , m_bObjectAdvise( TRUE )
63 , m_nDataRegFlag( 0 )
64 , m_nViewRegFlag( 0 )
65 , m_bHandleClosed( FALSE )
66 , m_bClosed( FALSE )
70 OleWrapperAdviseSink::OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, FORMATETC* pFormatEtc, DWORD nDataRegFlag )
71 : m_nRefCount( 0 )
72 , m_pListener( pListener )
73 , m_pFormatEtc( NULL )
74 , m_nAspect( DVASPECT_CONTENT )
75 , m_nRegID( 0 )
76 , m_bObjectAdvise( FALSE )
77 , m_nDataRegFlag( nDataRegFlag )
78 , m_nViewRegFlag( 0 )
79 , m_bHandleClosed( FALSE )
80 , m_bClosed( FALSE )
82 if ( pFormatEtc )
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 )
94 : m_nRefCount( 0 )
95 , m_pListener( pListener )
96 , m_pFormatEtc( NULL )
97 , m_nAspect( nAspect )
98 , m_nRegID( 0 )
99 , m_bObjectAdvise( TRUE )
100 , m_nDataRegFlag( 0 )
101 , m_nViewRegFlag( nViewRegFlag )
102 , m_bHandleClosed( FALSE )
103 , m_bClosed( FALSE )
107 OleWrapperAdviseSink::~OleWrapperAdviseSink()
109 if ( m_pFormatEtc )
110 delete m_pFormatEtc;
113 STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv )
115 *ppv=NULL;
117 if ( riid == IID_IUnknown )
118 *ppv = (IUnknown*)this;
120 if ( riid == IID_IAdviseSink )
121 *ppv = (IAdviseSink*)this;
123 if ( *ppv != NULL )
125 ((IUnknown*)*ppv)->AddRef();
126 return S_OK;
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 )
141 delete this;
143 return nReturn;
146 STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange( LPFORMATETC pFetc, LPSTGMEDIUM pMedium )
148 if ( m_pListener )
150 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnDataChange():" );
151 m_pListener->OnDataChange( pFetc, pMedium );
155 STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange( DWORD dwAspect, LONG lindex )
157 if ( m_pListener )
159 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnViewChange():" );
160 m_pListener->OnViewChange( dwAspect, lindex );
164 STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename( LPMONIKER pMoniker )
166 if ( m_pListener )
168 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnRename():" );
169 m_pListener->OnRename( pMoniker );
173 STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave(void)
175 if ( m_pListener )
177 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnSave():" );
178 m_pListener->OnSave();
182 STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose(void)
184 if ( m_pListener )
186 WRITEDEBUGINFO( "OleWrapperAdviseSink::OnClose():" );
187 m_pListener->OnClose();
190 if ( m_bHandleClosed )
191 m_bClosed = TRUE;
194 } // namespace inprocserv