2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#include <advisesink.hxx>
|
|
|
|
#include <olecomponent.hxx>
|
|
|
|
|
2007-01-23 06:32:45 +00:00
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
|
2003-11-13 16:01:50 +00:00
|
|
|
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()
|
|
|
|
{
|
2012-09-22 01:51:12 -05:00
|
|
|
return osl_atomic_increment( &m_nRefCount);
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2007-01-23 06:32:45 +00:00
|
|
|
::rtl::Reference< OleComponent > xLockComponent;
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_pOleComp )
|
2007-01-23 06:32:45 +00:00
|
|
|
xLockComponent = m_pOleComp;
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-23 06:32:45 +00:00
|
|
|
if ( xLockComponent.is() )
|
|
|
|
xLockComponent->OnViewChange_Impl( dwAspect );
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnSave()
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
|
|
|
// TODO: ???
|
2016-02-02 19:47:20 +01:00
|
|
|
// The object already knows about document saving, since it controls it as ClientSide
|
2003-12-09 11:52:34 +00:00
|
|
|
// other interested listeners must be registered for the object
|
2003-11-13 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
STDMETHODIMP_(void) OleWrapperAdviseSink::OnClose()
|
2003-11-13 16:01:50 +00:00
|
|
|
{
|
2007-01-23 06:32:45 +00:00
|
|
|
::rtl::Reference< OleComponent > xLockComponent;
|
|
|
|
|
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if ( m_pOleComp )
|
|
|
|
xLockComponent = m_pOleComp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( xLockComponent.is() )
|
|
|
|
xLockComponent->OnClose_Impl();
|
2003-11-13 16:01:50 +00:00
|
|
|
|
|
|
|
// TODO: sometimes it can be necessary to simulate OnShowWindow( False ) here
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|