2003-11-13 16:01:50 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* $RCSfile: advisesink.cxx,v $
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2006-10-12 10:21:42 +00:00
|
|
|
* $Revision: 1.5 $
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2006-10-12 10:21:42 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2006-10-12 11:21:42 $
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
2005-09-08 17:40:51 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2003-11-13 16:01:50 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:43:23 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_embeddedobj.hxx"
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#include <advisesink.hxx>
|
|
|
|
#include <olecomponent.hxx>
|
|
|
|
|
|
|
|
OleWrapperAdviseSink::OleWrapperAdviseSink( OleComponent* pOleComp )
|
|
|
|
: m_nRefCount( 0 )
|
|
|
|
, m_pOleComp( pOleComp )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( m_pOleComp, "No ole component is provided!\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
OleWrapperAdviseSink::~OleWrapperAdviseSink()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP OleWrapperAdviseSink::QueryInterface( REFIID riid , void** ppv )
|
|
|
|
{
|
|
|
|
*ppv=NULL;
|
|
|
|
|
|
|
|
if ( riid == IID_IUnknown )
|
|
|
|
*ppv = (IUnknown*)this;
|
|
|
|
|
|
|
|
if ( riid == IID_IAdviseSink )
|
|
|
|
*ppv = (IAdviseSink*)this;
|
|
|
|
|
|
|
|
if ( *ppv != NULL )
|
|
|
|
{
|
|
|
|
((IUnknown*)*ppv)->AddRef();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) OleWrapperAdviseSink::AddRef()
|
|
|
|
{
|
|
|
|
return osl_incrementInterlockedCount( &m_nRefCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) OleWrapperAdviseSink::Release()
|
|
|
|
{
|
|
|
|
ULONG nReturn = --m_nRefCount;
|
|
|
|
if ( m_nRefCount == 0 )
|
|
|
|
delete this;
|
|
|
|
|
|
|
|
return nReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OleWrapperAdviseSink::disconnectOleComponent()
|
|
|
|
{
|
|
|
|
// must not be called from the descructor of OleComponent!!!
|
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
m_pOleComp = NULL;
|
|
|
|
}
|
|
|
|
|
2006-10-12 10:21:42 +00:00
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnDataChange(LPFORMATETC, LPSTGMEDIUM)
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
// Unused for now ( no registration for IDataObject events )
|
|
|
|
}
|
|
|
|
|
2006-10-12 10:21:42 +00:00
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnViewChange(DWORD dwAspect, LONG)
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
OleComponent* pLockComponent = NULL;
|
|
|
|
|
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_pOleComp )
|
|
|
|
{
|
|
|
|
pLockComponent = m_pOleComp;
|
|
|
|
pLockComponent->acquire();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pLockComponent )
|
|
|
|
{
|
|
|
|
pLockComponent->OnViewChange_Impl( dwAspect );
|
|
|
|
pLockComponent->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-12 10:21:42 +00:00
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnRename(LPMONIKER)
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
// handled by default inprocess handler
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave(void)
|
|
|
|
{
|
|
|
|
// TODO: ???
|
2003-12-09 11:52:34 +00:00
|
|
|
// The object knows about document saving already since it contolls it as ClienSite
|
|
|
|
// other interested listeners must be registered for the object
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose(void)
|
|
|
|
{
|
|
|
|
// mainly handled by inprocess handler
|
|
|
|
|
|
|
|
// TODO: sometimes it can be necessary to simulate OnShowWindow( False ) here
|
|
|
|
}
|
|
|
|
|