*** empty log message ***

This commit is contained in:
Tino Rachui 2001-03-16 15:33:30 +00:00
parent 1434b5f436
commit 52dbacf7cd
12 changed files with 604 additions and 191 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: MtaOleClipb.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: tra $ $Date: 2001-03-15 10:11:35 $
* last change: $Author: tra $ $Date: 2001-03-16 16:33:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -128,21 +128,17 @@ private:
static unsigned int WINAPI oleThreadProc( LPVOID pParam );
sal_Bool WaitForThreadReady( ) const;
sal_Bool WaitOpComplete( ) const;
private:
HANDLE m_hOleThread;
unsigned m_uOleThreadId;
HANDLE m_hEvtThrdReady;
HANDLE m_hEvtOpComplete;
//HANDLE m_hEvtWmDrawClipboardReady;
HWND m_hwndMtaOleReqWnd;
HWND m_hwndNextClipViewer;
LPFNC_CLIPVIEWER_CALLBACK_t m_pfncClipViewerCallback;
sal_Bool m_bInRegisterClipViewer;
sal_Bool m_bInCallbackTriggerOperation;
static CMtaOleClipboard* s_theMtaOleClipboardInst;
static CMtaOleClipboard* s_theMtaOleClipboardInst;
// not allowed
private:

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.cxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: tra $ $Date: 2001-03-16 08:59:04 $
* last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -87,6 +87,10 @@
#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
#endif
#ifndef _XNOTIFYINGDATAOBJECT_HXX_
#include "..\dtobj\XNotifyingDataObject.hxx"
#endif
#include <windows.h>
#include <ole2.h>
#include <objidl.h>
@ -119,15 +123,13 @@ CWinClipbImpl* CWinClipbImpl::s_pCWinClipbImpl = NULL;
CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* theWinClipboard ) :
m_itsName( aClipboardName ),
m_pWinClipboard( theWinClipboard ),
m_bInDispose( sal_False ),
m_bSelfTriggered( sal_False )
m_pCurrentClipContent( NULL )
{
OSL_ASSERT( NULL != m_pWinClipboard );
// necessary to reassociate from
// the static callback function
s_pCWinClipbImpl = this;
registerClipboardViewer( );
}
@ -137,6 +139,7 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the
CWinClipbImpl::~CWinClipbImpl( )
{
s_pCWinClipbImpl = NULL;
unregisterClipboardViewer( );
}
@ -146,12 +149,10 @@ CWinClipbImpl::~CWinClipbImpl( )
Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( RuntimeException )
{
MutexGuard aGuard( m_aMutex );
Reference< XTransferable > rClipContent;
if ( m_rCurrentClipbContent.is( ) )
rClipContent = m_rCurrentClipbContent;
if ( NULL != m_pCurrentClipContent )
rClipContent = m_pCurrentClipContent->m_XTransferable;
else
{
// get the current dataobject from clipboard
@ -175,37 +176,24 @@ Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( Runtime
// setContent
//------------------------------------------------------------------------
void SAL_CALL CWinClipbImpl::setContents( const Reference< XTransferable >& xTransferable,
const Reference< XClipboardOwner >& xClipboardOwner,
ClearableMutexGuard& aGuard )
throw( RuntimeException )
void SAL_CALL CWinClipbImpl::setContents(
const Reference< XTransferable >& xTransferable,
const Reference< XClipboardOwner >& xClipboardOwner )
throw( RuntimeException )
{
CDTransObjFactory objFactory;
m_rOldClipbContent = m_rCurrentClipbContent;
m_rOldClipbOwner = m_rCurrentClipbOwner;
m_rCurrentClipbContent = xTransferable;
m_rCurrentClipbOwner = xClipboardOwner;
IDataObjectPtr pIDataObj;
IDataObjectPtr pIDataObj;
if ( xTransferable.is( ) )
pIDataObj = objFactory.createDataObjFromTransferable(
m_pWinClipboard->m_SrvMgr , m_rCurrentClipbContent );
else
// we don't even need to save a potential clip-owner
m_rCurrentClipbOwner = Reference< XClipboardOwner >( );
{
m_pCurrentClipContent = new CXNotifyingDataObject(
objFactory.createDataObjFromTransferable( m_pWinClipboard->m_SrvMgr , xTransferable ),
xTransferable,
xClipboardOwner,
this );
// used to differentiate in ClipboardContentChanged handler
m_bSelfTriggered = sal_True;
// block other threads via a condition
// release the mutex before calling into
// windows, because another thread can't
// do it
m_pWinClipboard->m_aCondition.reset( );
aGuard.clear( );
pIDataObj = IDataObjectPtr( m_pCurrentClipContent );
}
m_MtaOleClipboard.setClipboard( pIDataObj );
}
@ -234,7 +222,7 @@ sal_Int8 SAL_CALL CWinClipbImpl::getRenderingCapabilities( ) throw( RuntimeExce
void SAL_CALL CWinClipbImpl::flushClipboard( ) throw( RuntimeException )
{
if ( m_rCurrentClipbContent.is( ) )
if ( NULL != m_pCurrentClipContent )
m_MtaOleClipboard.flushClipboard( );
}
@ -262,10 +250,7 @@ void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( )
void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
{
OSL_ENSURE( !m_rOldClipbContent.is( ) &&
!m_rOldClipbOwner.is( ) &&
!m_rCurrentClipbContent.is( ) &&
!m_rCurrentClipbOwner.is( ),
OSL_ENSURE( (NULL != m_pCurrentClipContent),
"Clipboard was not flushed before shutdown!" );
}
@ -275,73 +260,25 @@ void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
void WINAPI CWinClipbImpl::onClipboardContentChanged( void )
{
try
{
ClearableMutexGuard aGuard( s_pCWinClipbImpl->m_aMutex );
Reference< XTransferable > xClipbContent;
Reference< XClipboardOwner > xClipbOwner;
if ( s_pCWinClipbImpl->m_rOldClipbContent.is( ) )
{
xClipbContent = s_pCWinClipbImpl->m_rOldClipbContent;
xClipbOwner = s_pCWinClipbImpl->m_rOldClipbOwner;
s_pCWinClipbImpl->m_rOldClipbOwner = Reference< XClipboardOwner >( );
s_pCWinClipbImpl->m_rOldClipbContent = Reference< XTransferable >( );
// release the condition because of expected callbacks
// to the clipboard service (remeber: the mutex is already
// released)
s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
// notify the old ClipboardOwner
if ( xClipbOwner.is( ) )
xClipbOwner->lostOwnership(
s_pCWinClipbImpl->m_pWinClipboard, xClipbContent );
}
else if ( !s_pCWinClipbImpl->m_bSelfTriggered &&
s_pCWinClipbImpl->m_rCurrentClipbContent.is( ) )
{
// save the state variables locally
xClipbContent = s_pCWinClipbImpl->m_rCurrentClipbContent;
xClipbOwner = s_pCWinClipbImpl->m_rCurrentClipbOwner;
s_pCWinClipbImpl->m_rCurrentClipbOwner = Reference< XClipboardOwner >( );
s_pCWinClipbImpl->m_rCurrentClipbContent = Reference< XTransferable >( );
// release the condition because of expected callbacks
// to the clipboard service (remeber: the mutex is already
// released)
s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
// notify the old ClipboardOwner
if ( xClipbOwner.is( ) )
xClipbOwner->lostOwnership( s_pCWinClipbImpl->m_pWinClipboard, xClipbContent );
}
}
catch( RuntimeException& )
{
OSL_ENSURE( sal_False, "RuntimeException caught" );
}
catch(...)
{
OSL_ENSURE( sal_False, "Unknown exception caught" );
}
s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
s_pCWinClipbImpl->m_bSelfTriggered = sal_False;
// reassocition to instance through static member
s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( );
if ( NULL != s_pCWinClipbImpl )
s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( );
}
//------------------------------------------------------------------------
// returns wether we are in dispose or not, is important for the
// XTDataObject so that we ignore the "Link" format during FlushClipboard
//
//------------------------------------------------------------------------
sal_Bool SAL_CALL CWinClipbImpl::isInDispose( ) const
void SAL_CALL CWinClipbImpl::onReleaseDataObject( CXNotifyingDataObject* theCaller )
{
return m_bInDispose;
}
OSL_ASSERT( NULL != theCaller );
if ( theCaller )
theCaller->lostOwnership( );
// if the current caller is the one we currently
// hold, then set it to NULL because an external
// source must be the clipboardowner now
if ( m_pCurrentClipContent == theCaller )
m_pCurrentClipContent = NULL;
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: tra $ $Date: 2001-03-14 14:43:14 $
* last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -95,6 +95,7 @@
#include <comdef.h>
class CWinClipboard;
class CXNotifyingDataObject;
//---------------------------------------------------
// impl class to avoid deadlocks between XTDataObject
@ -112,10 +113,10 @@ protected:
::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents( )
throw( ::com::sun::star::uno::RuntimeException );
void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner,
osl::ClearableMutexGuard& aGuard )
throw( ::com::sun::star::uno::RuntimeException );
void SAL_CALL setContents(
const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
throw( ::com::sun::star::uno::RuntimeException );
::rtl::OUString SAL_CALL getName( ) throw( ::com::sun::star::uno::RuntimeException );
@ -146,25 +147,23 @@ protected:
static void WINAPI onClipboardContentChanged( void );
sal_Bool SAL_CALL isInDispose( ) const;
private:
void SAL_CALL onReleaseDataObject( CXNotifyingDataObject* theCaller );
::rtl::OUString m_itsName;
CMtaOleClipboard m_MtaOleClipboard;
static CWinClipbImpl* s_pCWinClipbImpl;
CWinClipboard* m_pWinClipboard;
sal_Bool m_bInDispose;
com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > m_rCurrentClipbContent;
com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > m_rOldClipbContent;
com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner > m_rCurrentClipbOwner;
com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner > m_rOldClipbOwner;
sal_Bool m_bSelfTriggered;
osl::Mutex m_aMutex;
friend class CWinClipboard;
private:
::rtl::OUString m_itsName;
CMtaOleClipboard m_MtaOleClipboard;
CWinClipboard* m_pWinClipboard;
CXNotifyingDataObject* m_pCurrentClipContent;
osl::Mutex m_aMutex;
static CWinClipbImpl* s_pCWinClipbImpl;
private:
CWinClipbImpl( const CWinClipbImpl& );
CWinClipbImpl& operator=( const CWinClipbImpl& );
friend class CWinClipboard;
friend class CXNotifyingDataObject;
};
#endif

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: tra $ $Date: 2001-03-16 08:59:04 $
* last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -121,7 +121,6 @@ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceM
WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >( m_aCbListenerMutex ),
m_SrvMgr( rServiceManager )
{
m_aCondition.set( );
m_pImpl.reset( new CWinClipbImpl( aClipboardName, this ) );
}
@ -142,8 +141,6 @@ Reference< XTransferable > SAL_CALL CWinClipboard::getContents( ) throw( Runtime
{
OSL_ASSERT( m_pImpl.get( ) );
m_aCondition.wait( );
MutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
@ -164,14 +161,12 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra
{
OSL_ASSERT( m_pImpl.get( ) );
m_aCondition.wait( );
ClearableMutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
if ( NULL != m_pImpl.get( ) )
m_pImpl->setContents( xTransferable, xClipboardOwner, aGuard );
m_pImpl->setContents( xTransferable, xClipboardOwner );
}
//------------------------------------------------------------------------
@ -196,8 +191,6 @@ void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException )
{
OSL_ASSERT( m_pImpl.get( ) );
m_aCondition.wait( );
MutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
@ -230,8 +223,6 @@ sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeExce
void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
m_aCondition.wait( );
MutexGuard aGuard( m_aMutex );
rBHelper.aLC.addInterface( getCppuType( &listener ), listener );
}
@ -243,8 +234,6 @@ void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardLi
void SAL_CALL CWinClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
m_aCondition.wait( );
MutexGuard aGuard( m_aMutex );
rBHelper.aLC.removeInterface( getCppuType( &listener ), listener );
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: tra $ $Date: 2001-03-07 11:23:10 $
* last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -136,7 +136,6 @@ class CWinClipboardDummy
protected:
osl::Mutex m_aMutex;
osl::Mutex m_aCbListenerMutex;
osl::Condition m_aCondition;
};
class CWinClipboard :

View file

@ -2,9 +2,9 @@
*
* $RCSfile: DataFmtTransl.cxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: tra $ $Date: 2001-03-16 09:00:32 $
* last change: $Author: tra $ $Date: 2001-03-16 16:31:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -305,12 +305,13 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
try
{
aAny = refXTransferable->getTransferData( aFlavor );
OSL_ASSERT( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) );
if ( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) );
{
Sequence< sal_Int8 > byteStream;
aAny >>= byteStream;
Sequence< sal_Int8 > byteStream;
aAny >>= byteStream;
lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) );
lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) );
}
}
catch( UnsupportedFlavorException& )
{

View file

@ -2,9 +2,9 @@
*
* $RCSfile: FetcList.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: tra $ $Date: 2001-03-16 09:00:32 $
* last change: $Author: tra $ $Date: 2001-03-16 16:31:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -494,7 +494,7 @@ sal_Bool CFormatRegistrar::isEqualCurrentSystemCodePage( sal_uInt32 aCodePage )
void SAL_CALL CFormatRegistrar::FindLocaleForTextCodePage( )
{
EnumSystemLocalesA( CFormatRegistrar::EnumLocalesProc, LCID_SUPPORTED );
WaitForSingleObject( CFormatRegistrar::m_hEvtEnumLocaleReady, INFINITE );
WaitForSingleObject( CFormatRegistrar::m_hEvtEnumLocaleReady, 60000 );
}
//------------------------------------------------------------------------

View file

@ -0,0 +1,382 @@
/*************************************************************************
*
* $RCSfile: XNotifyingDataObject.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2001-03-16 16:31:54 $
*
* 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): _______________________________________
*
*
************************************************************************/
//------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
/*
#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_
#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
#endif
*/
#ifndef _XNOTIFYINGDATAOBJECT_HXX_
#include "XNotifyingDataObject.hxx"
#endif
#ifndef _WINCLIPBIMPL_HXX_
#include "..\clipb\WinClipbImpl.hxx"
#endif
#ifndef _WINCLIPBOARD_HXX_
#include "..\clipb\WinClipboard.hxx"
#endif
#ifndef _DTOBJFACTORY_HXX_
#include "..\..\inc\DtObjFactory.hxx"
#endif
//------------------------------------------------------------------------
// namespace directives
//------------------------------------------------------------------------
using namespace com::sun::star::datatransfer;
using namespace com::sun::star::datatransfer::clipboard;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::Reference;
//------------------------------------------------------------------------
// ctor
//------------------------------------------------------------------------
CXNotifyingDataObject::CXNotifyingDataObject(
const IDataObjectPtr& aIDataObject,
const Reference< XTransferable >& aXTransferable,
const Reference< XClipboardOwner >& aXClipOwner,
CWinClipbImpl* theWinClipImpl ) :
m_nRefCnt( 0 ),
m_aIDataObject( aIDataObject ),
m_XTransferable( aXTransferable ),
m_XClipboardOwner( aXClipOwner ),
m_pWinClipImpl( theWinClipImpl )
{
}
//------------------------------------------------------------------------
// IUnknown->QueryInterface
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
{
if ( NULL == ppvObject )
return E_INVALIDARG;
HRESULT hr = E_NOINTERFACE;
*ppvObject = NULL;
if ( ( __uuidof( IUnknown ) == iid ) ||
( __uuidof( IDataObject ) == iid ) )
{
*ppvObject = static_cast< IUnknown* >( this );
( (LPUNKNOWN)*ppvObject )->AddRef( );
hr = S_OK;
}
return hr;
}
//------------------------------------------------------------------------
// IUnknown->AddRef
//------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CXNotifyingDataObject::AddRef( )
{
return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
}
//------------------------------------------------------------------------
// IUnknown->Release
//------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CXNotifyingDataObject::Release( )
{
ULONG nRefCnt =
static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
if ( 0 == nRefCnt )
{
if ( m_pWinClipImpl )
m_pWinClipImpl->onReleaseDataObject( this );
delete this;
}
return nRefCnt;
}
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
{
HRESULT hr;
try
{
hr = m_aIDataObject->GetData( pFormatetc, pmedium );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->EnumFormatEtc
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::EnumFormatEtc(
DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
{
HRESULT hr;
try
{
hr = m_aIDataObject->EnumFormatEtc(
dwDirection, ppenumFormatetc );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->QueryGetData
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::QueryGetData( LPFORMATETC pFormatetc )
{
HRESULT hr;
try
{
hr = m_aIDataObject->QueryGetData( pFormatetc );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->GetDataHere
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::GetDataHere( LPFORMATETC lpFetc, LPSTGMEDIUM lpStgMedium )
{
HRESULT hr;
try
{
hr = m_aIDataObject->GetDataHere( lpFetc, lpStgMedium );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->GetCanonicalFormatEtc
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::GetCanonicalFormatEtc( LPFORMATETC lpFetc, LPFORMATETC lpCanonicalFetc )
{
HRESULT hr;
try
{
hr = m_aIDataObject->GetCanonicalFormatEtc( lpFetc, lpCanonicalFetc );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->SetData
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::SetData( LPFORMATETC lpFetc, LPSTGMEDIUM lpStgMedium, BOOL bRelease )
{
HRESULT hr;
try
{
hr = m_aIDataObject->SetData( lpFetc, lpStgMedium, bRelease );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->DAdvise
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::DAdvise(
LPFORMATETC lpFetc, DWORD advf, LPADVISESINK lpAdvSink, DWORD* pdwConnection )
{
HRESULT hr;
try
{
hr = m_aIDataObject->DAdvise( lpFetc, advf, lpAdvSink, pdwConnection );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->DUnadvise
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::DUnadvise( DWORD dwConnection )
{
HRESULT hr;
try
{
hr = m_aIDataObject->DUnadvise( dwConnection );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// IDataObject->EnumDAdvise
//------------------------------------------------------------------------
STDMETHODIMP CXNotifyingDataObject::EnumDAdvise( LPENUMSTATDATA * ppenumAdvise )
{
HRESULT hr;
try
{
hr = m_aIDataObject->EnumDAdvise( ppenumAdvise );
}
catch( _com_error& ex )
{
hr = ex.Error( );
}
return hr;
}
//------------------------------------------------------------------------
// for our convenience
//------------------------------------------------------------------------
CXNotifyingDataObject::operator IDataObject*( )
{
return static_cast< IDataObject* >( this );
}
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
void SAL_CALL CXNotifyingDataObject::lostOwnership( )
{
try
{
if ( m_XClipboardOwner.is( ) )
m_XClipboardOwner->lostOwnership(
static_cast< XClipboardEx* >( m_pWinClipImpl->m_pWinClipboard ), m_XTransferable );
}
catch( RuntimeException& )
{
OSL_ENSURE( sal_False, "RuntimeException caught" );
}
catch(...)
{
OSL_ENSURE( sal_False, "Unknown exception caught" );
}
}

View file

@ -0,0 +1,135 @@
/*************************************************************************
*
* $RCSfile: XNotifyingDataObject.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2001-03-16 16:31:48 $
*
* 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): _______________________________________
*
*
************************************************************************/
#ifndef _XNOTIFYINGDATAOBJECT_HXX_
#define _XNOTIFYINGDATAOBJECT_HXX_
//------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------
#ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_
#include <com/sun/star/datatransfer/XTransferable.hpp>
#endif
#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDOWNER_HPP_
#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
#endif
#include <objidl.h>
#include <windows.h>
#include <comdef.h>
/*--------------------------------------------------------------------------
To implement the lostOwnership mechanism cleanly we need this wrapper
object
----------------------------------------------------------------------------*/
// forward
class CWinClipbImpl;
class CXNotifyingDataObject : public IDataObject
{
public:
CXNotifyingDataObject(
const IDataObjectPtr& aIDataObject,
const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable,
const com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner >& aXClipOwner,
CWinClipbImpl* theWinClipImpl );
//-----------------------------------------------------------------
// ole interface implementation
//-----------------------------------------------------------------
//IUnknown interface methods
STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
STDMETHODIMP_( ULONG ) AddRef( );
STDMETHODIMP_( ULONG ) Release( );
// IDataObject interface methods
STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
STDMETHODIMP DUnadvise( DWORD dwConnection );
STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
operator IDataObject*( );
private:
void SAL_CALL lostOwnership( );
private:
sal_Int32 m_nRefCnt;
IDataObjectPtr m_aIDataObject;
const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > m_XTransferable;
const com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner > m_XClipboardOwner;
CWinClipbImpl* m_pWinClipImpl;
friend class CWinClipbImpl;
};
#endif

View file

@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.cxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: ka $ $Date: 2001-03-16 12:57:31 $
* last change: $Author: tra $ $Date: 2001-03-16 16:31:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -67,7 +67,7 @@
#include <osl/diagnose.h>
#endif
#ifndef _TWRAPPERDATAOBJECT_HXX_
#ifndef _TXDATAOBJECT_HXX_
#include "XTDataObject.hxx"
#endif
@ -509,25 +509,6 @@ CXTDataObject::operator IDataObject*( )
return static_cast< IDataObject* >( this );
}
//------------------------------------------------------------------------
// aks for the total size of all available and renderable clipboard
// formats
//------------------------------------------------------------------------
sal_Int64 SAL_CALL CXTDataObject::QueryDataSize( )
{
return 0;
}
//------------------------------------------------------------------------
// in preparation of clipboard flushing transfer all data from remote
// to here
//------------------------------------------------------------------------
void SAL_CALL CXTDataObject::GetAllDataFromSource( )
{
}
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------

View file

@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: tra $ $Date: 2001-03-05 12:26:17 $
* last change: $Author: tra $ $Date: 2001-03-16 16:31:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -138,13 +138,6 @@ public:
operator IDataObject*( );
sal_Int64 SAL_CALL QueryDataSize( );
// retrieve the data from the source
// necessary so that we have all data
// when we flush the clipboard
void SAL_CALL GetAllDataFromSource( );
private:
void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;

View file

@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.6 $
# $Revision: 1.7 $
#
# last change: $Author: tra $ $Date: 2001-03-14 14:45:41 $
# last change: $Author: tra $ $Date: 2001-03-16 16:31:24 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@ -86,7 +86,8 @@ SLOFILES=$(SLO)$/DtObjFactory.obj\
$(SLO)$/DataFmtTransl.obj\
$(SLO)$/FmtFilter.obj\
$(SLO)$/FetcList.obj\
$(SLO)$/Fetc.obj
$(SLO)$/Fetc.obj\
$(SLO)$/XNotifyingDataObject.obj
LIB1TARGET=$(SLB)$/$(TARGET).lib
LIB1OBJFILES=$(SLOFILES)