implement XDisplayConnection interface

This commit is contained in:
Philipp Lohmann
2001-02-01 13:08:06 +00:00
parent 82feb1d25c
commit e206328880
6 changed files with 222 additions and 15 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: svapp.cxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: cd $ $Date: 2001-01-31 16:32:51 $
* last change: $Author: pl $ $Date: 2001-02-01 14:08:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -145,6 +145,9 @@
#ifndef _VCL_UNOWRAP_HXX
#include <unowrap.hxx>
#endif
#ifndef _VCL_XCONNECTION_HXX
#include <xconnection.hxx>
#endif
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/awt/XToolkit.hpp>
@@ -1599,6 +1602,18 @@ UnoWrapperBase* Application::GetUnoWrapper()
// -----------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > Application::GetDisplayConnection()
{
#ifndef REMOTE_APPSERVER
ImplSVData* pSVData = ImplGetSVData();
return pSVData->mpDisplayConnection ? pSVData->mpDisplayConnection : new ::vcl::DisplayConnection;
#else
return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection >();
#endif
}
// -----------------------------------------------------------------------
void Application::SetFilterHdl( const Link& rLink )
{
ImplGetSVData()->maGDIData.mpGrfConverter->SetFilterHdl( rLink );

View File

@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.6 $
# $Revision: 1.7 $
#
# last change: $Author: pl $ $Date: 2000-10-27 15:24:45 $
# last change: $Author: pl $ $Date: 2001-02-01 14:08:05 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -80,6 +80,10 @@ SLOFILES=\
$(SLO)$/sunowrap.obj \
$(SLO)$/threadex.obj
.IF "$(remote)" == ""
SLOFILES+=$(SLO)$/xconnection.obj
.ENDIF
.IF "$(GUI)" == "UNX"
SLOFILES+=\
$(SLO)$/ppdparser.obj \

View File

@@ -0,0 +1,162 @@
/*************************************************************************
*
* $RCSfile: xconnection.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: pl $ $Date: 2001-02-01 14:08:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* 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.
*
* 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.
*
* 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
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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 );
}
void SAL_CALL DisplayConnection::addEventHandler( const Any& window, const Reference< XEventHandler >& handler, sal_Int32 eventMask )
{
MutexGuard aGuard( m_aMutex );
m_aHandlers.push_back( handler );
}
void SAL_CALL DisplayConnection::removeEventHandler( const Any& window, const Reference< XEventHandler >& handler )
{
MutexGuard aGuard( m_aMutex );
m_aHandlers.remove( handler );
}
void SAL_CALL DisplayConnection::addErrorHandler( const Reference< XEventHandler >& handler )
{
MutexGuard aGuard( m_aMutex );
m_aErrorHandlers.push_back( handler );
}
void SAL_CALL DisplayConnection::removeErrorHandler( const Reference< XEventHandler >& handler )
{
MutexGuard aGuard( m_aMutex );
m_aErrorHandlers.remove( handler );
}
Any SAL_CALL DisplayConnection::getIdentifier()
{
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;
}

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: salinst.h,v $
*
* $Revision: 1.1.1.1 $
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2000-09-18 17:05:41 $
* last change: $Author: pl $ $Date: 2001-02-01 14:08:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,7 +62,7 @@
// //
// (C) 1997 Star Division GmbH, Hamburg, Germany //
// //
// $Revision: 1.1.1.1 $ $Author: hr $ $Date: 2000-09-18 17:05:41 $ //
// $Revision: 1.2 $ $Author: pl $ $Date: 2001-02-01 14:08:06 $ //
// //
// $Workfile: salinst.h $ //
// $Modtime: 17 Jul 1997 17:21:10 $ //
@@ -106,9 +106,13 @@ class SalInstanceData
public:
void* mpFilterInst;
void* mpFilterCallback;
SalYieldMutex* mpSalYieldMutex;
void* mpFilterInst;
void* mpFilterCallback;
SalYieldMutex* mpSalYieldMutex;
bool(*mpEventCallback)(void*,void*,int);
void* mpEventInst;
bool(*mpErrorEventCallback)(void*,void*,int);
void* mpErrorEventInst;
};
#endif // _SV_SALINST_H

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: saldisp.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: oisin $ $Date: 2001-01-31 15:00:25 $
* last change: $Author: pl $ $Date: 2001-02-01 14:08:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2671,7 +2671,10 @@ final long SalDisplay::Dispatch( XEvent *pEvent )
if ( mpInputMethod->FilterEvent( pEvent, None ) )
return 0;
DtIntegrator::HandleXEvent( pEvent );
// DtIntegrator::HandleXEvent( pEvent );
SalInstance* pInstance = GetSalData()->pFirstInstance_;
if( pInstance->maInstData.mpEventCallback )
pInstance->maInstData.mpEventCallback( pInstance->maInstData.mpEventInst, pEvent, sizeof( XEvent ) );
switch( pEvent->type )
{

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: salinst.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: oisin $ $Date: 2001-01-31 15:00:25 $
* last change: $Author: pl $ $Date: 2001-02-01 14:08:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -354,3 +354,22 @@ void SalInstance::AcquireYieldMutex( ULONG nCount )
final void SalInstance::Yield( BOOL bWait )
{ GetSalData()->GetLib()->Yield( bWait ); }
void SalInstance::SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) )
{
maInstData.mpEventInst = pInstance;
maInstData.mpEventCallback = pCallback;
}
void SalInstance::SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) )
{
maInstData.mpErrorEventInst = pInstance;
maInstData.mpErrorEventCallback = pCallback;
}
void* SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes )
{
static const char* pDisplay = getenv( "DISPLAY" );
rReturnedType = AsciiCString;
rReturnedBytes = pDisplay ? strlen( pDisplay )+1 : 1;
return pDisplay ? pDisplay : "";
}