summaryrefslogtreecommitdiffstats
path: root/dtrans/source
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-16 08:02:25 +0000
committerTino Rachui <tra@openoffice.org>2001-03-16 08:02:25 +0000
commit3c0b46ee8ec56ee9a4cc8eb771e708c523d9f5c5 (patch)
tree049e50bd52648f19dc9f5370485c5e31a55ef9da /dtrans/source
parentUpdate library name and symbol renaming (diff)
downloadcore-3c0b46ee8ec56ee9a4cc8eb771e708c523d9f5c5.tar.gz
core-3c0b46ee8ec56ee9a4cc8eb771e708c523d9f5c5.zip
*** empty log message ***
Diffstat (limited to 'dtrans/source')
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.cxx91
-rw-r--r--dtrans/source/win32/clipb/WinClipboard.cxx42
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.cxx23
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx11
-rw-r--r--dtrans/source/win32/dtobj/MimeAttrib.hxx6
-rw-r--r--dtrans/source/win32/ftransl/ftransl.cxx10
-rw-r--r--dtrans/source/win32/ftransl/makefile.mk7
-rw-r--r--dtrans/source/win32/misc/ImplHelper.cxx50
-rw-r--r--dtrans/source/win32/mtaole/MtaOleClipb.cxx81
9 files changed, 223 insertions, 98 deletions
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx
index 8755f4f8d844..64bcbb018db3 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.cxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tra $ $Date: 2001-03-15 10:12:12 $
+ * last change: $Author: tra $ $Date: 2001-03-16 08:59:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -137,6 +137,7 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the
CWinClipbImpl::~CWinClipbImpl( )
{
+ unregisterClipboardViewer( );
}
//------------------------------------------------------------------------
@@ -261,8 +262,6 @@ void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( )
void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
{
- unregisterClipboardViewer( );
-
OSL_ENSURE( !m_rOldClipbContent.is( ) &&
!m_rOldClipbOwner.is( ) &&
!m_rCurrentClipbContent.is( ) &&
@@ -276,44 +275,58 @@ void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
void WINAPI CWinClipbImpl::onClipboardContentChanged( void )
{
- ClearableMutexGuard aGuard( s_pCWinClipbImpl->m_aMutex );
-
- Reference< XTransferable > xClipbContent;
- Reference< XClipboardOwner > xClipbOwner;
-
- if ( s_pCWinClipbImpl->m_rOldClipbContent.is( ) )
+ try
{
- // 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 ( s_pCWinClipbImpl->m_rOldClipbOwner.is( ) )
- s_pCWinClipbImpl->m_rOldClipbOwner->lostOwnership(
- s_pCWinClipbImpl->m_pWinClipboard, s_pCWinClipbImpl->m_rOldClipbContent );
-
- s_pCWinClipbImpl->m_rOldClipbOwner = Reference< XClipboardOwner >( );
- s_pCWinClipbImpl->m_rOldClipbContent = Reference< XTransferable >( );
+ 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 );
+ }
}
- else if ( !s_pCWinClipbImpl->m_bSelfTriggered &&
- s_pCWinClipbImpl->m_rCurrentClipbContent.is( ) )
+ catch( RuntimeException& )
{
- // 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 );
+ OSL_ENSURE( sal_False, "RuntimeException caught" );
+ }
+ catch(...)
+ {
+ OSL_ENSURE( sal_False, "Unknown exception caught" );
}
s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx
index 5c56c5fc20d6..294ab20bfd4d 100644
--- a/dtrans/source/win32/clipb/WinClipboard.cxx
+++ b/dtrans/source/win32/clipb/WinClipboard.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tra $ $Date: 2001-03-14 14:43:32 $
+ * last change: $Author: tra $ $Date: 2001-03-16 08:59:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -140,12 +140,18 @@ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceM
Reference< XTransferable > SAL_CALL CWinClipboard::getContents( ) throw( RuntimeException )
{
+ OSL_ASSERT( m_pImpl.get( ) );
+
m_aCondition.wait( );
MutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
- return m_pImpl->getContents( );
+
+ if ( NULL != m_pImpl.get( ) )
+ return m_pImpl->getContents( );
+
+ return Reference< XTransferable >( );
}
//------------------------------------------------------------------------
@@ -156,12 +162,16 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra
const Reference< XClipboardOwner >& xClipboardOwner )
throw( RuntimeException )
{
+ OSL_ASSERT( m_pImpl.get( ) );
+
m_aCondition.wait( );
ClearableMutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
- m_pImpl->setContents( xTransferable, xClipboardOwner, aGuard );
+
+ if ( NULL != m_pImpl.get( ) )
+ m_pImpl->setContents( xTransferable, xClipboardOwner, aGuard );
}
//------------------------------------------------------------------------
@@ -170,7 +180,12 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra
OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException )
{
- return m_pImpl->getName( );
+ OSL_ASSERT( m_pImpl.get( ) );
+
+ if ( NULL != m_pImpl.get( ) )
+ return m_pImpl->getName( );
+
+ return OUString::createFromAscii( "" );
}
//========================================================================
@@ -179,12 +194,15 @@ OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException )
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" );
- m_pImpl->flushClipboard( );
+ if ( NULL != m_pImpl.get( ) )
+ m_pImpl->flushClipboard( );
}
//========================================================================
@@ -193,7 +211,12 @@ void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException )
sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeException )
{
- return m_pImpl->getRenderingCapabilities( );
+ OSL_ASSERT( m_pImpl.get( ) );
+
+ if ( NULL != m_pImpl.get( ) )
+ return m_pImpl->getRenderingCapabilities( );
+
+ return 0;
}
//========================================================================
@@ -232,6 +255,8 @@ void SAL_CALL CWinClipboard::removeClipboardListener( const Reference< XClipboar
void SAL_CALL CWinClipboard::notifyAllClipboardListener( )
{
+ OSL_ASSERT( NULL != m_pImpl.get( ) );
+
OInterfaceContainerHelper* pICHelper = rBHelper.aLC.getContainer(
getCppuType( ( Reference< XClipboardListener > * ) 0 ) );
@@ -278,6 +303,9 @@ void SAL_CALL CWinClipboard::dispose() throw(RuntimeException)
// do my own stuff
m_pImpl->dispose( );
+ // force destruction of the impl class
+ m_pImpl.reset( NULL );
+
// call the base class implementation first
WeakComponentImplHelper4< XClipboardEx,
XFlushableClipboard, XClipboardNotifier,
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
index f6d831345415..570347b7a8e0 100644
--- a/dtrans/source/win32/dtobj/DataFmtTransl.cxx
+++ b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataFmtTransl.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tra $ $Date: 2001-03-15 10:13:24 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:00:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -295,28 +295,25 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
const Reference< XTransferable >& refXTransferable ) const
{
Any aAny;
- CFormatEtc fetc = getFormatEtcForClipformat( CF_LOCALE );
+ CFormatEtc fetc = getFormatEtcForClipformat( CF_LOCALE );
DataFlavor aFlavor = getDataFlavorFromFormatEtc( refXTransferable, fetc );
OSL_ASSERT( aFlavor.MimeType.getLength( ) );
- LCID lcid;
+ LCID lcid = 0;
try
{
aAny = refXTransferable->getTransferData( aFlavor );
- if ( aAny.hasValue( ) )
- {
- OSL_ASSERT( aAny.getValueType( ) == CPPUTYPE_SEQSALINT8 );
- Sequence< sal_Int8 > byteStream;
- aAny >>= byteStream;
+ OSL_ASSERT( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) );
- lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) );
- }
+ Sequence< sal_Int8 > byteStream;
+ aAny >>= byteStream;
+
+ lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) );
}
catch( UnsupportedFlavorException& )
{
- lcid = GetThreadLocale( );
}
catch( ... )
{
@@ -324,7 +321,7 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
}
if ( !IsValidLocale( lcid, LCID_SUPPORTED ) )
- lcid = GetThreadLocale( );
+ lcid = GetThreadLocale( );
return lcid;
}
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index 9deaf947b032..fa144791fd6f 100644
--- a/dtrans/source/win32/dtobj/FetcList.cxx
+++ b/dtrans/source/win32/dtobj/FetcList.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FetcList.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tra $ $Date: 2001-03-09 08:47:21 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:00:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -257,7 +257,12 @@ CFormatRegistrar::CFormatRegistrar( const Reference< XMultiServiceFactory >& Ser
CFormatRegistrar::~CFormatRegistrar( )
{
if ( CFormatRegistrar::m_hEvtEnumLocaleReady )
- CloseHandle( CFormatRegistrar::m_hEvtEnumLocaleReady );
+ {
+ sal_Bool bRet = CloseHandle(
+ CFormatRegistrar::m_hEvtEnumLocaleReady );
+
+ OSL_ASSERT( bRet );
+ }
}
//------------------------------------------------------------------------
diff --git a/dtrans/source/win32/dtobj/MimeAttrib.hxx b/dtrans/source/win32/dtobj/MimeAttrib.hxx
index dc2e64501717..81e6ee26a60e 100644
--- a/dtrans/source/win32/dtobj/MimeAttrib.hxx
+++ b/dtrans/source/win32/dtobj/MimeAttrib.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MimeAttrib.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:51:36 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:00:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,7 +77,7 @@
const rtl::OUString TEXTPLAIN_PARAM_CHARSET = rtl::OUString::createFromAscii( "charset" );
-const rtl::OUString PRE_WINDOWS_CODEPAGE = rtl::OUString::createFromAscii( "windows-" );
+const rtl::OUString PRE_WINDOWS_CODEPAGE = rtl::OUString::createFromAscii( "windows" );
const rtl::OUString PRE_OEM_CODEPAGE = rtl::OUString::createFromAscii( "cp" );
const rtl::OUString CHARSET_UTF16 = rtl::OUString::createFromAscii( "utf-16" );
const rtl::OUString CHARSET_UNICODE = rtl::OUString::createFromAscii( "unicode" );
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index 67abd9183492..da90d81ebf25 100644
--- a/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/dtrans/source/win32/ftransl/ftransl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ftransl.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: tra $ $Date: 2001-03-09 08:48:02 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:01:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -214,8 +214,8 @@ DataFlavor SAL_CALL CDataFormatTranslator::getDataFlavorFromSystemDataType( cons
{
sal_Int32 clipformat;
aSysDataType >>= clipformat;
-
- findDataFlavorForStandardFormatId( clipformat, aFlavor );
+ if ( CF_INVALID != clipformat )
+ findDataFlavorForStandardFormatId( clipformat, aFlavor );
}
else if ( aSysDataType.getValueType( ) == CPPUTYPE_OUSTR )
{
@@ -225,7 +225,7 @@ DataFlavor SAL_CALL CDataFormatTranslator::getDataFlavorFromSystemDataType( cons
findDataFlavorForNativeFormatName( nativeFormatName, aFlavor );
}
else
- OSL_ASSERT( false );
+ OSL_ENSURE( sal_False, "Invalid data type received" );
return aFlavor;
}
diff --git a/dtrans/source/win32/ftransl/makefile.mk b/dtrans/source/win32/ftransl/makefile.mk
index 50008a34973a..3d74b701362c 100644
--- a/dtrans/source/win32/ftransl/makefile.mk
+++ b/dtrans/source/win32/ftransl/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: tra $ $Date: 2001-02-27 06:55:00 $
+# last change: $Author: tra $ $Date: 2001-03-16 09:02:00 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -93,7 +93,8 @@ SHL1STDLIBS= \
$(SALLIB) \
$(CPPULIB) \
$(CPPUHELPERLIB)\
- ole32.lib
+ ole32.lib\
+ gdi32.lib
SHL1TARGET=$(TARGET)
SHL1IMPLIB=i$(SHL1TARGET)
diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx
index 3c21d99a8efc..59e5d423aaee 100644
--- a/dtrans/source/win32/misc/ImplHelper.cxx
+++ b/dtrans/source/win32/misc/ImplHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ImplHelper.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tra $ $Date: 2001-03-15 08:10:38 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:02:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,6 +80,7 @@
#include <rtl/memory.h>
#endif
+#include <memory>
#include <windows.h>
#include <systools/win32/user9x.h>
@@ -107,12 +108,23 @@ using ::rtl::OString;
sal_uInt32 SAL_CALL getWinCPFromMimeCharset( const OUString& charset )
{
- OString osCharset( charset.getStr( ), charset.getLength( ), CP_ACP );
+ OString osCharset(
+ charset.getStr( ), charset.getLength( ), RTL_TEXTENCODING_ASCII_US );
- rtl_TextEncoding textEnc =
+ rtl_TextEncoding txtEnc =
rtl_getTextEncodingFromMimeCharset( osCharset.getStr( ) );
- return rtl_getBestPCCodePageFromTextEncoding( textEnc );
+ sal_uInt32 winChrs = rtl_getBestWindowsCharsetFromTextEncoding( txtEnc );
+
+ CHARSETINFO chrsInf;
+ sal_Bool bRet = TranslateCharsetInfo(
+ (DWORD*)winChrs, &chrsInf, TCI_SRCCHARSET );
+
+ sal_uInt32 winCP = GetACP( );
+ if ( bRet )
+ winCP = chrsInf.ciACP;
+
+ return winCP;
}
//--------------------------------------------------
@@ -127,10 +139,32 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
// we use the GetLocaleInfoA because don't want to provide
// a unicode wrapper function for Win9x in sal/systools
char buff[6];
- GetLocaleInfoA( lcid, lctype, buff, sizeof( buff ) );
- rtl_TextEncoding tenc = rtl_getTextEncodingFromPCCodePage( CP_ACP );
+ sal_Int32 nResult = GetLocaleInfoA(
+ lcid, lctype | LOCALE_USE_CP_ACP, buff, sizeof( buff ) );
+
+ OSL_ASSERT( nResult );
+
+ OUString winCP;
+
+ if ( nResult )
+ {
+ sal_Int32 len = MultiByteToWideChar(
+ CP_ACP, 0, buff, -1, NULL, 0 );
+
+ OSL_ASSERT( len > 0 );
+
+ std::auto_ptr< sal_Unicode > lpwchBuff( new sal_Unicode[len] );
+
+ if ( NULL != lpwchBuff.get( ) )
+ {
+ len = MultiByteToWideChar(
+ CP_ACP, 0, buff, -1, lpwchBuff.get( ), len );
+
+ winCP = OUString( lpwchBuff.get( ), (len - 1) );
+ }
+ }
- return OUString( buff, rtl_str_getLength( buff ), tenc );
+ return winCP;
}
//--------------------------------------------------
diff --git a/dtrans/source/win32/mtaole/MtaOleClipb.cxx b/dtrans/source/win32/mtaole/MtaOleClipb.cxx
index 28297c77c1ca..d4fa80a785c9 100644
--- a/dtrans/source/win32/mtaole/MtaOleClipb.cxx
+++ b/dtrans/source/win32/mtaole/MtaOleClipb.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MtaOleClipb.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-15 08:11:12 $
+ * last change: $Author: tra $ $Date: 2001-03-16 09:01:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,7 +94,7 @@ const sal_uInt32 MSG_FLUSHCLIPBOARD = WM_USER + 0x0004;
const sal_uInt32 MSG_SHUTDOWN = WM_USER + 0x0006;
const sal_uInt32 MAX_WAITTIME = 60000;
-const sal_uInt32 MAX_OPCOMPLET_WAITTIME = 60000;
+const sal_uInt32 MAX_OPCOMPLET_WAITTIME = 30000;
const sal_uInt32 MAX_WAIT_SHUTDOWN = 30000;
const sal_uInt32 MAX_CLIPEVENT_PROCESSING_TIME = 5000;
@@ -173,12 +173,17 @@ CMtaOleClipboard::CMtaOleClipboard( ) :
m_hwndMtaOleReqWnd( NULL ),
m_hwndNextClipViewer( NULL ),
m_pfncClipViewerCallback( NULL ),
- m_bInCallbackTriggerOperation( sal_False )
+ m_bInCallbackTriggerOperation( sal_False ),
+ m_hEvtWmDrawClipboardReady( NULL )
{
// signals that the thread was successfully set up
- m_hEvtThrdReady = CreateEvent( 0, MANUAL_RESET, INIT_NONSIGNALED, NULL );
- m_hEvtOpComplete = CreateEvent( 0, AUTO_RESET, INIT_NONSIGNALED, NULL );
- OSL_ASSERT( (NULL != m_hEvtThrdReady) && (NULL != m_hEvtOpComplete) );
+ m_hEvtThrdReady = CreateEventA( 0, MANUAL_RESET, INIT_NONSIGNALED, NULL );
+ m_hEvtOpComplete = CreateEventA( 0, AUTO_RESET, INIT_NONSIGNALED, NULL );
+ m_hEvtWmDrawClipboardReady = CreateEventA( 0, AUTO_RESET, INIT_NONSIGNALED, NULL );
+
+ OSL_ASSERT( (NULL != m_hEvtThrdReady) &&
+ (NULL != m_hEvtOpComplete) &&
+ (NULL != m_hEvtWmDrawClipboardReady) );
s_theMtaOleClipboardInst = this;
@@ -218,6 +223,9 @@ CMtaOleClipboard::~CMtaOleClipboard( )
if ( NULL != m_hEvtOpComplete )
CloseHandle( m_hEvtOpComplete );
+ if ( NULL != m_hEvtWmDrawClipboardReady )
+ CloseHandle( m_hEvtWmDrawClipboardReady );
+
OSL_ENSURE( ( NULL == m_pfncClipViewerCallback ) &&
!IsWindow( m_hwndNextClipViewer ), \
"Clipboard viewer not properly unregistered" );
@@ -249,8 +257,11 @@ HRESULT CMtaOleClipboard::flushClipboard( )
static_cast< WPARAM >( 0 ),
reinterpret_cast< LPARAM >( &hr ) );
- if ( !WaitOpComplete( ) )
+ if ( !WaitCallbackOpComplete( ) )
+ {
+ OSL_ENSURE( sal_False, "Operation timeout" );
hr = E_FAIL;
+ }
}
m_bInCallbackTriggerOperation = sal_False;
@@ -275,6 +286,8 @@ HRESULT CMtaOleClipboard::getClipboard( IDataObject** ppIDataObject )
LPSTREAM lpStream;
HRESULT hr;
+ *ppIDataObject = NULL;
+
// we don't need to post the request if we are
// the ole thread self
if ( GetCurrentThreadId( ) == m_uOleThreadId )
@@ -286,7 +299,10 @@ HRESULT CMtaOleClipboard::getClipboard( IDataObject** ppIDataObject )
reinterpret_cast< LPARAM >( &hr ) );
if ( !WaitOpComplete( ) )
+ {
+ OSL_ENSURE( sal_False, "Operation timeout" );
hr = E_FAIL;
+ }
}
if ( SUCCEEDED( hr ) )
@@ -320,8 +336,11 @@ HRESULT CMtaOleClipboard::setClipboard( IDataObject* pIDataObject )
reinterpret_cast< WPARAM >( pIDataObject ),
reinterpret_cast< LPARAM >( &hr ) );
- if ( !WaitOpComplete( ) )
+ if ( !WaitCallbackOpComplete( ) )
+ {
+ OSL_ENSURE( sal_False, "Operation timeout" );
hr = E_FAIL;
+ }
}
m_bInCallbackTriggerOperation = sal_False;
@@ -350,8 +369,11 @@ sal_Bool CMtaOleClipboard::registerClipViewer( LPFNC_CLIPVIEWER_CALLBACK_t pfncC
reinterpret_cast<WPARAM>( pfncClipViewerCallback ),
reinterpret_cast<LPARAM>(&bRet) );
- if ( !WaitOpComplete( ) )
+ if ( !WaitCallbackOpComplete( ) )
+ {
+ OSL_ENSURE( sal_False, "Operation timeout" );
bRet = sal_False;
+ }
}
m_bInCallbackTriggerOperation = sal_False;
@@ -399,6 +421,7 @@ sal_Bool CMtaOleClipboard::onRegisterClipViewer( LPFNC_CLIPVIEWER_CALLBACK_t pfn
// WM_DRAWCLIPBOARD message we have to release the
// waiting thread exclusively
SetEvent( m_hEvtOpComplete );
+ SetEvent( m_hEvtWmDrawClipboardReady );
}
return bRet;
@@ -410,8 +433,7 @@ sal_Bool CMtaOleClipboard::onRegisterClipViewer( LPFNC_CLIPVIEWER_CALLBACK_t pfn
LRESULT CMtaOleClipboard::onSetClipboard( IDataObject* pIDataObject )
{
- HRESULT hr = OleSetClipboard( pIDataObject );
- return static_cast<LRESULT>(hr);
+ return static_cast<LRESULT>( OleSetClipboard( pIDataObject ) );
}
//--------------------------------------------------------------------
@@ -438,9 +460,6 @@ LRESULT CMtaOleClipboard::onGetClipboard( LPSTREAM* ppStream )
LRESULT CMtaOleClipboard::onFlushClipboard( )
{
- // the call will be block until the
- // WM_DRAWCLIPBOARD message has been
- // processed
return static_cast<LRESULT>( OleFlushClipboard( ) );
}
@@ -503,7 +522,7 @@ LRESULT CMtaOleClipboard::onDrawClipboard( )
// clipboard operation so the call becomes synchronous
// for the caller
if ( m_bInCallbackTriggerOperation )
- SetEvent( m_hEvtOpComplete );
+ SetEvent( m_hEvtWmDrawClipboardReady );
return 0;
}
@@ -546,6 +565,7 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
case MSG_SETCLIPBOARD:
*(reinterpret_cast< HRESULT* >( lParam )) =
pImpl->onSetClipboard( reinterpret_cast< IDataObject* >(wParam) );
+ SetEvent( pImpl->m_hEvtOpComplete );
break;
case MSG_GETCLIPBOARD:
@@ -556,11 +576,13 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
case MSG_FLUSHCLIPBOARD:
*(reinterpret_cast< HRESULT* >( lParam )) = pImpl->onFlushClipboard( );
+ SetEvent( pImpl->m_hEvtOpComplete );
break;
case MSG_REGCLIPVIEWER:
*(reinterpret_cast<sal_Bool*>(lParam)) = pImpl->onRegisterClipViewer(
reinterpret_cast<LPFNC_CLIPVIEWER_CALLBACK_t>(wParam) );
+ SetEvent( pImpl->m_hEvtOpComplete );
break;
case WM_CHANGECBCHAIN:
@@ -662,6 +684,7 @@ unsigned int WINAPI CMtaOleClipboard::oleThreadProc( LPVOID pParam )
//
//--------------------------------------------------------------------
+inline
sal_Bool CMtaOleClipboard::WaitForThreadReady( ) const
{
sal_Bool bRet = sal_False;
@@ -680,6 +703,7 @@ sal_Bool CMtaOleClipboard::WaitForThreadReady( ) const
//
//--------------------------------------------------------------------
+inline
sal_Bool CMtaOleClipboard::WaitOpComplete( ) const
{
sal_Bool bRet = sal_False;
@@ -692,4 +716,27 @@ sal_Bool CMtaOleClipboard::WaitOpComplete( ) const
}
return bRet;
-} \ No newline at end of file
+}
+
+//--------------------------------------------------------------------
+//
+//--------------------------------------------------------------------
+
+sal_Bool CMtaOleClipboard::WaitCallbackOpComplete( ) const
+{
+ sal_Bool bRet = sal_False;
+
+ if ( (NULL != m_hEvtOpComplete) && (NULL != m_hEvtWmDrawClipboardReady) )
+ {
+ HANDLE hEvt[2];
+ hEvt[0] = m_hEvtOpComplete;
+ hEvt[1] = m_hEvtWmDrawClipboardReady;
+
+ DWORD dwResult =
+ WaitForMultipleObjects( 2, &hEvt[0], TRUE, MAX_OPCOMPLET_WAITTIME );
+
+ bRet = ( dwResult == WAIT_OBJECT_0 );
+ }
+
+ return bRet;
+}