diff options
author | Philipp Lohmann <pl@openoffice.org> | 2001-02-01 13:08:06 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2001-02-01 13:08:06 +0000 |
commit | e206328880cc901b8ba657d78e7158704f21dcfe (patch) | |
tree | dfe2842a9cc073d05387de2a75893abf9bd85a8e /vcl/source/helper | |
parent | 82feb1d25cb877283f9cc87d56c36d35f512a57e (diff) |
implement XDisplayConnection interface
Diffstat (limited to 'vcl/source/helper')
-rw-r--r-- | vcl/source/helper/makefile.mk | 8 | ||||
-rw-r--r-- | vcl/source/helper/xconnection.cxx | 162 |
2 files changed, 168 insertions, 2 deletions
diff --git a/vcl/source/helper/makefile.mk b/vcl/source/helper/makefile.mk index 33619e3bfce8..30d20ffd795d 100644 --- a/vcl/source/helper/makefile.mk +++ b/vcl/source/helper/makefile.mk @@ -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 \ diff --git a/vcl/source/helper/xconnection.cxx b/vcl/source/helper/xconnection.cxx new file mode 100644 index 000000000000..7ef397a92bbe --- /dev/null +++ b/vcl/source/helper/xconnection.cxx @@ -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; +} |