2001-02-01 13:08:06 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 11:17:10 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2005-09-09 11:17:10 +00:00
|
|
|
* $RCSfile: xconnection.cxx,v $
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2006-06-19 18:34:27 +00:00
|
|
|
* $Revision: 1.5 $
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2006-06-19 18:34:27 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2006-06-19 19:34:27 $
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2005-09-09 11:17:10 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 11:17:10 +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
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2005-09-09 11:17:10 +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.
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2005-09-09 11:17:10 +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.
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
2005-09-09 11:17:10 +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
|
2001-02-01 13:08:06 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2001-02-05 15:41:16 +00:00
|
|
|
#ifndef _SV_SVSYS_HXX
|
|
|
|
#include <svsys.h>
|
|
|
|
#endif
|
2001-02-01 13:08:06 +00:00
|
|
|
#include <xconnection.hxx>
|
|
|
|
#include <svdata.hxx>
|
|
|
|
#include <salinst.hxx>
|
|
|
|
|
|
|
|
using namespace rtl;
|
|
|
|
using namespace osl;
|
|
|
|
using namespace vcl;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::awt;
|
|
|
|
|
|
|
|
DisplayConnection::DisplayConnection()
|
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
pSVData->mpDisplayConnection = this;
|
|
|
|
pSVData->mpDefInst->SetEventCallback( this, dispatchEvent );
|
|
|
|
pSVData->mpDefInst->SetErrorEventCallback( this, dispatchErrorEvent );
|
|
|
|
|
|
|
|
SalInstance::ConnectionIdentifierType eType;
|
|
|
|
int nBytes;
|
|
|
|
void* pBytes = pSVData->mpDefInst->GetConnectionIdentifier( eType, nBytes );
|
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case SalInstance::AsciiCString:
|
|
|
|
m_aAny <<= OUString::createFromAscii( (sal_Char*)pBytes );
|
|
|
|
break;
|
|
|
|
case SalInstance::Blob:
|
|
|
|
m_aAny <<= Sequence< sal_Int8 >( (sal_Int8*)pBytes, nBytes );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayConnection::~DisplayConnection()
|
|
|
|
{
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
|
|
pSVData->mpDisplayConnection = NULL;
|
|
|
|
pSVData->mpDefInst->SetEventCallback( NULL, NULL );
|
|
|
|
pSVData->mpDefInst->SetErrorEventCallback( NULL, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-19 18:34:27 +00:00
|
|
|
void SAL_CALL DisplayConnection::addEventHandler( const Any& /*window*/, const Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ ) throw()
|
2001-02-01 13:08:06 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
m_aHandlers.push_back( handler );
|
|
|
|
}
|
|
|
|
|
2006-06-19 18:34:27 +00:00
|
|
|
void SAL_CALL DisplayConnection::removeEventHandler( const Any& /*window*/, const Reference< XEventHandler >& handler ) throw()
|
2001-02-01 13:08:06 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
m_aHandlers.remove( handler );
|
|
|
|
}
|
|
|
|
|
2001-09-11 14:52:22 +00:00
|
|
|
void SAL_CALL DisplayConnection::addErrorHandler( const Reference< XEventHandler >& handler ) throw()
|
2001-02-01 13:08:06 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
m_aErrorHandlers.push_back( handler );
|
|
|
|
}
|
|
|
|
|
2001-09-11 14:52:22 +00:00
|
|
|
void SAL_CALL DisplayConnection::removeErrorHandler( const Reference< XEventHandler >& handler ) throw()
|
2001-02-01 13:08:06 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
m_aErrorHandlers.remove( handler );
|
|
|
|
}
|
|
|
|
|
2001-09-11 14:52:22 +00:00
|
|
|
Any SAL_CALL DisplayConnection::getIdentifier() throw()
|
2001-02-01 13:08:06 +00:00
|
|
|
{
|
|
|
|
return m_aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayConnection::dispatchEvent( void* pThis, void* pData, int nBytes )
|
|
|
|
{
|
|
|
|
DisplayConnection* This = (DisplayConnection*)pThis;
|
|
|
|
MutexGuard aGuard( This->m_aMutex );
|
|
|
|
|
|
|
|
Sequence< sal_Int8 > aSeq( (sal_Int8*)pData, nBytes );
|
|
|
|
Any aEvent;
|
|
|
|
aEvent <<= aSeq;
|
|
|
|
for( ::std::list< Reference< XEventHandler > >::const_iterator it = This->m_aHandlers.begin(); it != This->m_aHandlers.end(); ++it )
|
|
|
|
if( (*it)->handleEvent( aEvent ) )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayConnection::dispatchErrorEvent( void* pThis, void* pData, int nBytes )
|
|
|
|
{
|
|
|
|
DisplayConnection* This = (DisplayConnection*)pThis;
|
|
|
|
MutexGuard aGuard( This->m_aMutex );
|
|
|
|
|
|
|
|
Sequence< sal_Int8 > aSeq( (sal_Int8*)pData, nBytes );
|
|
|
|
Any aEvent;
|
|
|
|
aEvent <<= aSeq;
|
|
|
|
for( ::std::list< Reference< XEventHandler > >::const_iterator it = This->m_aErrorHandlers.begin(); it != This->m_aErrorHandlers.end(); ++it )
|
|
|
|
if( (*it)->handleEvent( aEvent ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|