summaryrefslogtreecommitdiff
path: root/dtrans/source/win32
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-06 11:27:24 +0000
committerTino Rachui <tra@openoffice.org>2001-03-06 11:27:24 +0000
commit6a4bedd820a83fc08410ec0bc425088eca454f7c (patch)
tree05487a75fa2fac2efa211013a4bfd64ad4a8215d /dtrans/source/win32
parentd51da1746f9df261429ae6a862a95cf8f58d0e38 (diff)
*** empty log message ***
Diffstat (limited to 'dtrans/source/win32')
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.cxx82
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.hxx22
-rw-r--r--dtrans/source/win32/clipb/WinClipboard.cxx58
-rw-r--r--dtrans/source/win32/clipb/WinClipboard.hxx19
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.cxx29
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.hxx6
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx5
7 files changed, 136 insertions, 85 deletions
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx
index 3a6d30743525..5c79eeb5efd5 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:37:30 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:27:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,15 +122,26 @@ CWinClipbImpl* CWinClipbImpl::s_pCWinClipbImpl = NULL;
CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* theWinClipboard ) :
m_itsName( aClipboardName ),
- m_pClipboardContent( NULL ),
m_pWinClipboard( theWinClipboard ),
- m_bInDispose( sal_False )
+ m_bInDispose( sal_False ),
+ m_bSelfTriggered( sal_False )
{
OSL_ASSERT( NULL != m_pWinClipboard );
// necessary to reassociate from
// the static callback function
s_pCWinClipbImpl = this;
+
+ registerClipboardViewer( );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+CWinClipbImpl::~CWinClipbImpl( )
+{
+ unregisterClipboardViewer( );
}
//------------------------------------------------------------------------
@@ -139,11 +150,11 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the
Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( RuntimeException )
{
- if ( NULL != m_pClipboardContent )
+ MutexGuard aGuard( m_aMutex );
+
+ if ( m_rCurrentClipbContent.is( ) )
{
- //return Reference< XTransferable >( m_pClipbContent->m_rXTDataSource );
- //return m_pClipboardContent->m_rXTDataSource;
- return Reference< XTransferable >( );
+ return m_rCurrentClipbContent;
}
else
{
@@ -158,7 +169,6 @@ Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( Runtime
CDTransObjFactory objFactory;
// remeber pIDo destroys itself due to the smart pointer
- //return Reference< XTransferable >( static_cast< XTransferable* >( new CDOTransferable( pIDo ) ) );
return objFactory.createTransferableFromDataObj( m_pWinClipboard->m_SrvMgr, pIDo );
}
}
@@ -173,8 +183,17 @@ void SAL_CALL CWinClipbImpl::setContents( const Reference< XTransferable >& xTra
{
CDTransObjFactory objFactory;
+ m_rOldClipbContent = m_rCurrentClipbContent;
+ m_rOldClipbOwner = m_rCurrentClipbOwner;
+
+ m_rCurrentClipbContent = xTransferable;
+ m_rCurrentClipbOwner = xClipboardOwner;
+
IDataObjectPtr pIDataObj( objFactory.createDataObjFromTransferable(
- m_pWinClipboard->m_SrvMgr , xTransferable ) );
+ m_pWinClipboard->m_SrvMgr , m_rCurrentClipbContent ) );
+
+ // used to differentiate in ClipboardContent changed handler
+ m_bSelfTriggered = sal_True;
MTASetClipboard( pIDataObj );
}
@@ -212,8 +231,7 @@ void SAL_CALL CWinClipbImpl::flushClipboard( ) throw( RuntimeException )
void SAL_CALL CWinClipbImpl::registerClipboardViewer( ) const
{
- if ( m_pWinClipboard->hasClipboardListener( ) )
- MTARegisterClipboardViewer( CWinClipbImpl::onClipboardContentChanged );
+ MTARegisterClipboardViewer( CWinClipbImpl::onClipboardContentChanged );
}
//------------------------------------------------------------------------
@@ -222,8 +240,7 @@ void SAL_CALL CWinClipbImpl::registerClipboardViewer( ) const
void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( ) const
{
- if ( !m_pWinClipboard->hasClipboardListener( ) )
- MTARegisterClipboardViewer( NULL );
+ MTARegisterClipboardViewer( NULL );
}
//------------------------------------------------------------------------
@@ -232,6 +249,11 @@ void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( ) const
void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
{
+ OSL_ENSURE( !m_rOldClipbContent.is( ) &&
+ !m_rOldClipbOwner.is( ) &&
+ !m_rCurrentClipbContent.is( ) &&
+ !m_rCurrentClipbOwner.is( ),
+ "Clipboard was not flushed before!" );
}
//------------------------------------------------------------------------
@@ -240,6 +262,38 @@ void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
void CALLBACK CWinClipbImpl::onClipboardContentChanged( void )
{
+ ClearableMutexGuard aGuard( s_pCWinClipbImpl->m_aMutex );
+
+ Reference< XTransferable > xClipbContent;
+ Reference< XClipboardOwner > xClipbOwner;
+
+ if ( s_pCWinClipbImpl->m_rOldClipbContent.is( ) && 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 >( );
+ }
+ else if ( !s_pCWinClipbImpl->m_bSelfTriggered &&
+ ( s_pCWinClipbImpl->m_rCurrentClipbContent.is( ) &&
+ s_pCWinClipbImpl->m_rCurrentClipbOwner.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 mutex, so that a getContent call would succeed
+ aGuard.clear( );
+
+ // notify the old ClipboardOwner
+ xClipbOwner->lostOwnership( s_pCWinClipbImpl->m_pWinClipboard, xClipbContent );
+ }
+
+ s_pCWinClipbImpl->m_bSelfTriggered = sal_False;
+
// reassocition to instance through static member
s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( );
}
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.hxx b/dtrans/source/win32/clipb/WinClipbImpl.hxx
index 8b8fea0ef726..51641d4136c9 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.hxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:37:23 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:27:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,6 +99,9 @@ class CWinClipboard;
class CWinClipbImpl
{
+public:
+ ~CWinClipbImpl( );
+
protected:
CWinClipbImpl( const ::rtl::OUString& aClipboardName, CWinClipboard* theWinClipboard );
@@ -140,11 +143,16 @@ protected:
sal_Bool SAL_CALL isInDispose( ) const;
- ::rtl::OUString m_itsName;
- IDataObjectPtr m_pClipboardContent;
- static CWinClipbImpl* s_pCWinClipbImpl;
- CWinClipboard* m_pWinClipboard;
- sal_Bool m_bInDispose;
+ ::rtl::OUString m_itsName;
+ 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;
};
diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx
index f72fb50b7b27..a62ea21af8d6 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:37:56 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:27:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -200,16 +200,7 @@ sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeExce
void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
- MutexGuard aGuard( rBHelper.rMutex );
-
- OSL_ENSURE( !rBHelper.bInDispose, "Do not add listeners in the dispose call" );
- OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
-
- if ( !rBHelper.bInDispose && !rBHelper.bDisposed )
- {
- rBHelper.aLC.addInterface( getCppuType( ( Reference< XClipboardListener > * ) 0 ), listener );
- m_pImpl->registerClipboardViewer( );
- }
+ rBHelper.aLC.addInterface( getCppuType( &listener ), listener );
}
//------------------------------------------------------------------------
@@ -219,23 +210,14 @@ void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardLi
void SAL_CALL CWinClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
- MutexGuard aGuard( rBHelper.rMutex );
-
- OSL_ENSURE( !rBHelper.bInDispose, "Do not add listeners in the dispose call" );
- OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
-
- if ( !rBHelper.bInDispose && !rBHelper.bDisposed )
- {
- rBHelper.aLC.removeInterface( getCppuType( ( Reference< XClipboardListener > * ) 0 ), listener );
- m_pImpl->unregisterClipboardViewer( );
- }
+ rBHelper.aLC.removeInterface( getCppuType( &listener ), listener );
}
//------------------------------------------------------------------------
// getName
//------------------------------------------------------------------------
-void SAL_CALL CWinClipboard::notifyAllClipboardListener( ) const
+void SAL_CALL CWinClipboard::notifyAllClipboardListener( )
{
OInterfaceContainerHelper* pICHelper = rBHelper.aLC.getContainer(
getCppuType( ( Reference< XClipboardListener > * ) 0 ) );
@@ -243,10 +225,7 @@ void SAL_CALL CWinClipboard::notifyAllClipboardListener( ) const
if ( pICHelper )
{
OInterfaceIteratorHelper iter( *pICHelper );
-
- // todo !!!
- // have to construct a transferable ...
- ClipboardEvent aCBEvent;
+ ClipboardEvent aClipbEvent( *this, m_pImpl->getContents( ) );
while( iter.hasMoreElements( ) )
{
@@ -254,7 +233,7 @@ void SAL_CALL CWinClipboard::notifyAllClipboardListener( ) const
{
Reference< XClipboardListener > xCBListener( iter.next( ), UNO_QUERY );
if ( xCBListener.is( ) )
- xCBListener->changedContents( aCBEvent );
+ xCBListener->changedContents( aClipbEvent );
}
catch( ... )
{
@@ -264,23 +243,6 @@ void SAL_CALL CWinClipboard::notifyAllClipboardListener( ) const
}
}
-//------------------------------------------------------------------------
-// determine if there are any clipboard listener
-//------------------------------------------------------------------------
-
-sal_Bool SAL_CALL CWinClipboard::hasClipboardListener( ) const
-{
- sal_Bool bRet = sal_False;
-
- OInterfaceContainerHelper* pICHelper =
- rBHelper.aLC.getContainer( getCppuType( ( Reference< XClipboardListener > * ) 0 ) );
-
- if ( pICHelper )
- bRet = ( pICHelper->getLength( ) > 0 );
-
- return bRet;
-}
-
//------------------------------------------------
// dispose
// we can't aquire a mutext in this method because
@@ -293,15 +255,15 @@ sal_Bool SAL_CALL CWinClipboard::hasClipboardListener( ) const
void SAL_CALL CWinClipboard::dispose() throw(RuntimeException)
{
- MutexGuard aGuard( m_aMtxForDispose );
-
if ( !( rBHelper.bInDispose || rBHelper.bDisposed ) )
{
// do my own stuff
m_pImpl->dispose( );
// call the base class implementation first
- WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >::dispose( );
+ WeakComponentImplHelper4< XClipboardEx,
+ XFlushableClipboard, XClipboardNotifier,
+ XServiceInfo >::dispose( );
}
}
diff --git a/dtrans/source/win32/clipb/WinClipboard.hxx b/dtrans/source/win32/clipb/WinClipboard.hxx
index aac9afaadf70..a11f3c471edb 100644
--- a/dtrans/source/win32/clipb/WinClipboard.hxx
+++ b/dtrans/source/win32/clipb/WinClipboard.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:38:02 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:27:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,7 +124,17 @@ class CWinClipbImpl;
// by this class!
//------------------------------------------------------------------------
+// helper class, so that the mutex is constructed
+// before the constructor of WeakComponentImplHelper
+// will be called and initialized with this mutex
+class CWinClipboardDummy
+{
+protected:
+ ::osl::Mutex m_aMutex;
+};
+
class CWinClipboard :
+ public CWinClipboardDummy,
public cppu::WeakComponentImplHelper4<
::com::sun::star::datatransfer::clipboard::XClipboardEx, \
::com::sun::star::datatransfer::clipboard::XFlushableClipboard,
@@ -188,12 +198,9 @@ public:
throw(::com::sun::star::uno::RuntimeException);
private:
- void SAL_CALL notifyAllClipboardListener( ) const;
- sal_Bool SAL_CALL hasClipboardListener( ) const;
+ void SAL_CALL notifyAllClipboardListener( );
private:
- ::osl::Mutex m_aMutex;
- ::osl::Mutex m_aMtxForDispose;
::std::auto_ptr< CWinClipbImpl > m_pImpl;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr;
diff --git a/dtrans/source/win32/dtobj/DTransHelper.cxx b/dtrans/source/win32/dtobj/DTransHelper.cxx
index 7aa530a9f7c8..eea454e2962e 100644
--- a/dtrans/source/win32/dtobj/DTransHelper.cxx
+++ b/dtrans/source/win32/dtobj/DTransHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DTransHelper.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-05 06:35:15 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:24:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,6 +113,16 @@ void SAL_CALL CStgTransferHelper::write( const void* lpData, ULONG cb, ULONG* cb
if ( FAILED( hr ) )
throw CStgTransferException( hr );
+
+#ifdef _DEBUG
+ HGLOBAL hGlob;
+ hr = GetHGlobalFromStream( m_lpStream, &hGlob );
+ OSL_ASSERT( SUCCEEDED( hr ) );
+
+ DWORD dwSize = GlobalSize( hGlob );
+ LPVOID lpdbgData = GlobalLock( hGlob );
+ GlobalUnlock( hGlob );
+#endif
}
//------------------------------------------------------------------------
@@ -181,9 +191,18 @@ void SAL_CALL CStgTransferHelper::init( SIZE_T newSize,
throw CStgTransferException( STG_E_MEDIUMFULL );
HRESULT hr = CreateStreamOnHGlobal( hGlob, m_bDelStgOnRelease, &m_lpStream );
-
if ( FAILED( hr ) )
+ {
+ GlobalFree( hGlob );
+ m_lpStream = NULL;
throw CStgTransferException( hr );
+ }
+
+#ifdef _DEBUG
+ STATSTG statstg;
+ hr = m_lpStream->Stat( &statstg, STATFLAG_DEFAULT );
+ OSL_ASSERT( SUCCEEDED( hr ) );
+#endif
}
//------------------------------------------------------------------------
@@ -191,8 +210,8 @@ void SAL_CALL CStgTransferHelper::init( SIZE_T newSize,
//------------------------------------------------------------------------
void SAL_CALL CStgTransferHelper::init( HGLOBAL hGlob,
- sal_Bool bDelStgOnRelease,
- sal_Bool bReleaseStreamOnDestr )
+ sal_Bool bDelStgOnRelease,
+ sal_Bool bReleaseStreamOnDestr )
{
OSL_ASSERT( !(bDelStgOnRelease && !bReleaseStreamOnDestr) );
diff --git a/dtrans/source/win32/dtobj/DTransHelper.hxx b/dtrans/source/win32/dtobj/DTransHelper.hxx
index 19193c9fccd0..6f646ef6dcd1 100644
--- a/dtrans/source/win32/dtobj/DTransHelper.hxx
+++ b/dtrans/source/win32/dtobj/DTransHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DTransHelper.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-05 06:35:15 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:24:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -117,7 +117,7 @@ public:
void SAL_CALL init(
SIZE_T newSize,
- sal_uInt32 uiFlags = GMEM_MOVEABLE | GMEM_ZEROINIT,
+ sal_uInt32 uiFlags = GHND,
sal_Bool bDelStgOnRelease = sal_False,
sal_Bool bReleasStreamOnDestr = sal_True );
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index 63bbf0c6a9da..c88551dd8519 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.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: tra $ $Date: 2001-03-05 06:36:04 $
+ * last change: $Author: tra $ $Date: 2001-03-06 12:25:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -450,6 +450,7 @@ OUString SAL_CALL CFormatRegistrar::getCharsetFromDataFlavor( const DataFlavor&
catch(NoSuchElementException&)
{
OSL_ENSURE( sal_False, "Text data flavor without charset not allowed" );
+ charset = OUString::createFromAscii( "windows-1252" );
}
catch(...)
{