diff options
author | Tino Rachui <tra@openoffice.org> | 2001-03-19 08:12:22 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-03-19 08:12:22 +0000 |
commit | 3e540563aa89605ae701cd7b96e4dca2f01bf12e (patch) | |
tree | 269ce53a001fb027f628cf56a4acb6f57b82adcd /dtrans | |
parent | 04b8820c47a5977f0055dbb8f661cae622c93564 (diff) |
*** empty log message ***
Diffstat (limited to 'dtrans')
-rw-r--r-- | dtrans/source/win32/clipb/WinClipbImpl.cxx | 10 | ||||
-rw-r--r-- | dtrans/source/win32/clipb/WinClipbImpl.hxx | 7 | ||||
-rw-r--r-- | dtrans/source/win32/clipb/WinClipboard.cxx | 174 | ||||
-rw-r--r-- | dtrans/source/win32/clipb/WinClipboard.hxx | 37 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/DataFmtTransl.cxx | 6 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/FetcList.cxx | 121 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/FetcList.hxx | 8 | ||||
-rw-r--r-- | dtrans/source/win32/mtaole/MtaOleClipb.cxx | 6 |
8 files changed, 222 insertions, 147 deletions
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx index 4afc5e8f424e..044845a1e808 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:10:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,6 +115,7 @@ using namespace com::sun::star::datatransfer::clipboard::RenderingCapabilities; // definition of static members CWinClipbImpl* CWinClipbImpl::s_pCWinClipbImpl = NULL; +osl::Mutex CWinClipbImpl::s_aMutex; //------------------------------------------------------------------------ // @@ -139,7 +140,10 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the CWinClipbImpl::~CWinClipbImpl( ) { + ClearableMutexGuard aGuard( s_aMutex ); s_pCWinClipbImpl = NULL; + aGuard.clear( ); + unregisterClipboardViewer( ); } @@ -260,6 +264,8 @@ void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException ) void WINAPI CWinClipbImpl::onClipboardContentChanged( void ) { + MutexGuard aGuard( s_aMutex ); + // reassocition to instance through static member if ( NULL != s_pCWinClipbImpl ) s_pCWinClipbImpl->m_pWinClipboard->notifyAllClipboardListener( ); diff --git a/dtrans/source/win32/clipb/WinClipbImpl.hxx b/dtrans/source/win32/clipb/WinClipbImpl.hxx index a4f55329dab5..7cb7317520b1 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.5 $ + * $Revision: 1.6 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:10:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -155,7 +155,8 @@ private: CMtaOleClipboard m_MtaOleClipboard; CWinClipboard* m_pWinClipboard; CXNotifyingDataObject* m_pCurrentClipContent; - osl::Mutex m_aMutex; + + static osl::Mutex s_aMutex; static CWinClipbImpl* s_pCWinClipbImpl; private: diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx index a497ec4e4b07..052191f6a499 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.8 $ + * $Revision: 1.9 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:10:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,14 @@ #include <com/sun/star/datatransfer/clipboard/ClipboardEvent.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif + #ifndef _WINCLIPBIMPL_HXX_ #include "WinClipbImpl.hxx" #endif @@ -118,7 +126,7 @@ namespace //------------------------------------------------------------------------ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceManager, const OUString& aClipboardName ) : - WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >( m_aCbListenerMutex ), + WeakComponentImplHelper5< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XEventListener, XServiceInfo >( m_aCbListenerMutex ), m_SrvMgr( rServiceManager ) { m_pImpl.reset( new CWinClipbImpl( aClipboardName, this ) ); @@ -139,11 +147,11 @@ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceM Reference< XTransferable > SAL_CALL CWinClipboard::getContents( ) throw( RuntimeException ) { - OSL_ASSERT( m_pImpl.get( ) ); - MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); if ( NULL != m_pImpl.get( ) ) return m_pImpl->getContents( ); @@ -159,11 +167,11 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra const Reference< XClipboardOwner >& xClipboardOwner ) throw( RuntimeException ) { - OSL_ASSERT( m_pImpl.get( ) ); - - ClearableMutexGuard aGuard( m_aMutex ); + MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); if ( NULL != m_pImpl.get( ) ) m_pImpl->setContents( xTransferable, xClipboardOwner ); @@ -175,7 +183,9 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException ) { - OSL_ASSERT( m_pImpl.get( ) ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); if ( NULL != m_pImpl.get( ) ) return m_pImpl->getName( ); @@ -189,10 +199,11 @@ OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException ) void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException ) { - OSL_ASSERT( m_pImpl.get( ) ); - MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" ); + + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); if ( NULL != m_pImpl.get( ) ) m_pImpl->flushClipboard( ); @@ -204,7 +215,9 @@ void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException ) sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeException ) { - OSL_ASSERT( m_pImpl.get( ) ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); if ( NULL != m_pImpl.get( ) ) return m_pImpl->getRenderingCapabilities( ); @@ -223,7 +236,23 @@ sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeExce void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardListener >& listener ) throw( RuntimeException ) { - MutexGuard aGuard( m_aMutex ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); + + // check input parameter + if ( !listener.is( ) ) + throw IllegalArgumentException( OUString::createFromAscii( "empty reference" ), + static_cast< XClipboardEx* >( this ), + 1 ); + + // if the listener supports XComponent then we will register + // as a listener so that we can remove the listener from our + // list in case of disposing if not already done + Reference< XComponent > xComponent( listener, UNO_QUERY ); + if ( xComponent.is( ) ) + xComponent->addEventListener( static_cast< XEventListener* >(this) ); + rBHelper.aLC.addInterface( getCppuType( &listener ), listener ); } @@ -234,7 +263,22 @@ void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardLi void SAL_CALL CWinClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener ) throw( RuntimeException ) { - MutexGuard aGuard( m_aMutex ); + if ( rBHelper.bDisposed ) + throw DisposedException( OUString::createFromAscii( "object is already disposed" ), + static_cast< XClipboardEx* >( this ) ); + + // check input parameter + if ( !listener.is( ) ) + throw IllegalArgumentException( OUString::createFromAscii( "empty reference" ), + static_cast< XClipboardEx* >( this ), + 1 ); + + // remove ourself as an eventlistener from this component if + // it supports XComponent + Reference< XComponent > xComponent( listener, UNO_QUERY ); + if ( xComponent.is( ) ) + xComponent->removeEventListener( static_cast< XEventListener* >(this) ); + rBHelper.aLC.removeInterface( getCppuType( &listener ), listener ); } @@ -244,62 +288,68 @@ 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 ) ); - - if ( pICHelper ) + if ( !rBHelper.bDisposed ) { - OInterfaceIteratorHelper iter( *pICHelper ); - Reference< XTransferable > rXTransf = m_pImpl->getContents( ); - ClipboardEvent aClipbEvent( static_cast< XClipboard* >( this ), rXTransf ); - - while( iter.hasMoreElements( ) ) + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if ( !rBHelper.bDisposed ) { - try - { - Reference< XClipboardListener > xCBListener( iter.next( ), UNO_QUERY ); - if ( xCBListener.is( ) ) - xCBListener->changedContents( aClipbEvent ); - } - catch( RuntimeException& ) - { - OSL_ENSURE( false, "RuntimeException caught" ); - } - catch( ... ) + aGuard.clear( ); + + OInterfaceContainerHelper* pICHelper = rBHelper.aLC.getContainer( + getCppuType( ( Reference< XClipboardListener > * ) 0 ) ); + + if ( pICHelper ) { - OSL_ENSURE( false, "Exception during event dispatching" ); - } - } - } + OInterfaceIteratorHelper iter( *pICHelper ); + Reference< XTransferable > rXTransf = m_pImpl->getContents( ); + ClipboardEvent aClipbEvent( static_cast< XClipboard* >( this ), rXTransf ); + + while( iter.hasMoreElements( ) ) + { + try + { + Reference< XClipboardListener > xCBListener( iter.next( ), UNO_QUERY ); + if ( xCBListener.is( ) ) + xCBListener->changedContents( aClipbEvent ); + } + catch( RuntimeException& ) + { + OSL_ENSURE( false, "RuntimeException caught" ); + } + catch( ... ) + { + OSL_ENSURE( false, "Exception during event dispatching" ); + } + } // while + } // end if + } // end if + } // end if } //------------------------------------------------ -// dispose -// we can't aquire a mutext in this method because -// dispose may flush the clipboard and that leads -// to a lostOwnership message send to the clipboard -// owner, if the clipboard owner would access the -// clipboard and we had aquire a lock here we would -// have a deadlock +// overwritten base class method which will be +// called by the base class dispose method //------------------------------------------------ -void SAL_CALL CWinClipboard::dispose() throw(RuntimeException) +void SAL_CALL CWinClipboard::disposing() { - if ( !( rBHelper.bInDispose || rBHelper.bDisposed ) ) - { - // do my own stuff - m_pImpl->dispose( ); + // do my own stuff + m_pImpl->dispose( ); - // force destruction of the impl class - m_pImpl.reset( NULL ); + // force destruction of the impl class + m_pImpl.reset( NULL ); +} - // call the base class implementation first - WeakComponentImplHelper4< XClipboardEx, - XFlushableClipboard, XClipboardNotifier, - XServiceInfo >::dispose( ); - } +// ------------------------------------------------- +// XEventListener +// ------------------------------------------------- + +void SAL_CALL CWinClipboard::disposing( const EventObject& aEvent ) throw(RuntimeException) +{ + Reference< XClipboardListener > xClipboardListener( aEvent.Source, UNO_QUERY ); + + if ( xClipboardListener.is( ) ) + removeClipboardListener( xClipboardListener ); } // ------------------------------------------------- diff --git a/dtrans/source/win32/clipb/WinClipboard.hxx b/dtrans/source/win32/clipb/WinClipboard.hxx index 429c37d08758..a412312c94e0 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.5 $ + * $Revision: 1.6 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:32:44 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:10:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,8 +76,8 @@ #include <sal/types.h> #endif -#ifndef _CPPUHELPER_COMPBASE3_HXX_ -#include <cppuhelper/compbase4.hxx> +#ifndef _CPPUHELPER_COMPBASE5_HXX_ +#include <cppuhelper/compbase5.hxx> #endif #ifndef _COM_SUN_STAR_DATATRANSFER_XTRANSFERABLE_HPP_ @@ -140,10 +140,11 @@ protected: class CWinClipboard : public CWinClipboardDummy, - public cppu::WeakComponentImplHelper4< + public cppu::WeakComponentImplHelper5< ::com::sun::star::datatransfer::clipboard::XClipboardEx, \ ::com::sun::star::datatransfer::clipboard::XFlushableClipboard, ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, + ::com::sun::star::lang::XEventListener, ::com::sun::star::lang::XServiceInfo > { public: @@ -156,9 +157,12 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents( ) throw( ::com::sun::star::uno::RuntimeException ); - virtual 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 ) + + virtual 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 ); + virtual ::rtl::OUString SAL_CALL getName( ) throw( ::com::sun::star::uno::RuntimeException ); @@ -178,16 +182,27 @@ public: // XClipboardNotifier //------------------------------------------------ - virtual void SAL_CALL addClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) + virtual void SAL_CALL addClipboardListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) + + virtual void SAL_CALL removeClipboardListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) throw( ::com::sun::star::uno::RuntimeException ); //------------------------------------------------ - // XComponent + // overwrite base class method, which is called + // by base class dispose function + //------------------------------------------------ + + virtual void SAL_CALL disposing(); + + //------------------------------------------------ + // XEventListener //------------------------------------------------ - virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) + throw(::com::sun::star::uno::RuntimeException); //------------------------------------------------ // XServiceInfo diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx index 25b7d7191bf3..6bc650a3c496 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:31:04 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:11:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -305,7 +305,7 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard( try { aAny = refXTransferable->getTransferData( aFlavor ); - if ( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) ); + if ( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) ) { Sequence< sal_Int8 > byteStream; aAny >>= byteStream; diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx index e5b1895364b3..aaeadfcfff53 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.8 $ + * $Revision: 1.9 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:31:24 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:11:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,7 +110,6 @@ using namespace std; // //------------------------------------------------------------------------ -HANDLE CFormatRegistrar::m_hEvtEnumLocaleReady = NULL; LCID CFormatRegistrar::m_TxtLocale = 0; sal_uInt32 CFormatRegistrar::m_TxtCodePage = GetACP( ); @@ -163,12 +162,7 @@ sal_Bool CFormatEtcContainer::hasFormatEtc( const CFormatEtc& fetc ) const FormatEtcMap_t::const_iterator iter = find( m_FormatMap.begin(), m_FormatMap.end(), fetc ); - if ( iter != m_FormatMap.end( ) ) - { - return ( ( fetc == CFormatEtc( *iter )) == 1 ); - } - - return sal_False; + return ( iter != m_FormatMap.end( ) ); } //------------------------------------------------------------------------ @@ -204,9 +198,7 @@ sal_uInt32 SAL_CALL CFormatEtcContainer::nextFormatEtc( LPFORMATETC lpFetc, if ( m_EnumIterator != m_FormatMap.end( ) ) { for ( sal_uInt32 i = 0; i < aNum; i++, nFetched++, lpFetc++, ++m_EnumIterator ) - { CopyFormatEtc( lpFetc, *m_EnumIterator ); - } } return nFetched; @@ -242,35 +234,32 @@ CFormatRegistrar::CFormatRegistrar( const Reference< XMultiServiceFactory >& Ser m_bHasSynthesizedLocale( sal_False ), m_SrvMgr( ServiceManager ) { - CFormatRegistrar::m_hEvtEnumLocaleReady = CreateEvent( NULL, - sal_False, - sal_False, - NULL ); - - OSL_ASSERT( CFormatRegistrar::m_hEvtEnumLocaleReady ); } -//------------------------------------------------------------------------ +// ---------------------------------------------------------------------------------------- +// this function converts all DataFlavors of the given FlavorList into +// an appropriate FORMATETC structure, for some formats like unicodetext, +// text and text/html we will offer an accompany format e.g.: // -//------------------------------------------------------------------------ - -CFormatRegistrar::~CFormatRegistrar( ) -{ - if ( CFormatRegistrar::m_hEvtEnumLocaleReady ) - { - sal_Bool bRet = CloseHandle( - CFormatRegistrar::m_hEvtEnumLocaleReady ); - - OSL_ASSERT( bRet ); - } -} - -//------------------------------------------------------------------------ +// DataFlavor | Registered Clipformat | Registered accompany clipformat +// -------------------------|---------------------------|----------------------------------- +// text/plain;charset=ansi | CF_TEXT | CF_UNICODETEXT +// | | CF_LOCALE (if charset != GetACP() +// | | +// text/plain;charset=oem | CF_OEMTEXT | CF_UNICODETEXT +// | | CF_LOCALE (if charset != GetOEMCP() +// | | +// text/plain;charset=utf-16| CF_UNICODETEXT | CF_TEXT +// | | +// text/html | HTML (Hypertext ...) | HTML Format +// | | // -//------------------------------------------------------------------------ +// if some tries to register different text formats with different charsets the last +// registered wins and the others are ignored +// ---------------------------------------------------------------------------------------- -void SAL_CALL CFormatRegistrar::RegisterFormats( const Sequence< DataFlavor >& aFlavorList, - CFormatEtcContainer& aFormatEtcContainer ) +void SAL_CALL CFormatRegistrar::RegisterFormats( + const Sequence< DataFlavor >& aFlavorList, CFormatEtcContainer& aFormatEtcContainer ) { sal_Int32 nFlavors = aFlavorList.getLength( ); sal_Bool bSuccess = sal_False; @@ -283,22 +272,6 @@ void SAL_CALL CFormatRegistrar::RegisterFormats( const Sequence< DataFlavor >& a if ( needsToSynthesizeAccompanyFormats( fetc ) ) { - -#ifdef _DEBUG - CFormatEtc fetcdbg; - - if ( fetc.getClipformat() == CF_TEXT ) - { - fetcdbg = getFormatEtcForClipformat( CF_OEMTEXT ); - OSL_ASSERT( !aFormatEtcContainer.hasFormatEtc( fetcdbg ) ); - } - else if ( fetc.getClipformat() == CF_OEMTEXT ) - { - fetcdbg = getFormatEtcForClipformat( CF_TEXT ); - OSL_ASSERT( !aFormatEtcContainer.hasFormatEtc( fetcdbg ) ); - } -#endif - // we don't validate if the operation succeded // because an accompany format might have be // registered so that it's no problem if the @@ -308,13 +281,35 @@ void SAL_CALL CFormatRegistrar::RegisterFormats( const Sequence< DataFlavor >& a // register unicode text it will fail aFormatEtcContainer.addFormatEtc( fetc ); - synthesizeAndRegisterAccompanyFormats( fetc, aFlavor, aFormatEtcContainer ); + synthesizeAndRegisterAccompanyFormats( + fetc, aFlavor, aFormatEtcContainer ); } else aFormatEtcContainer.addFormatEtc( fetc ); } } +/* + For all Flavors from Transferable + if not is TextFlavor + add Format to FormatList + else if not UnicodeTextRegistred + if isUnicodeText or Transferable Has Unicodetext + add Unicode Format to FormatList + add Text to FormatList + UnicodeTextRegistered = true + else + if findLocaleForTextCharset successful + add Unicode Format to FormatList + add Text or OemText to FormatList + add Locale to FormatList + HasSynthesizedLocale = true + save the TextFlavor so that access is easier in GetData + end if + end if + end if +*/ + //------------------------------------------------------------------------ // //------------------------------------------------------------------------ @@ -408,10 +403,20 @@ void SAL_CALL CFormatRegistrar::synthesizeAndRegisterAccompanyFormats( if ( !isEqualCurrentSystemCodePage( m_TxtCodePage ) ) { - FindLocaleForTextCodePage( ); fetc = getFormatEtcForClipformat( CF_LOCALE ); - aFormatEtcContainer.addFormatEtc( fetc ); - m_bHasSynthesizedLocale = sal_True; + + if ( findLocaleForTextCodePage( ) ) + { + aFormatEtcContainer.addFormatEtc( fetc ); + m_bHasSynthesizedLocale = sal_True; + } + else // could not find a locale for this charset + { + // remove the locale if there is one + // already registered + aFormatEtcContainer.removeFormatEtc( fetc ); + m_bHasSynthesizedLocale = sal_False; + } } // register may fail if we have already @@ -491,10 +496,11 @@ sal_Bool CFormatRegistrar::isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) // //------------------------------------------------------------------------ -void SAL_CALL CFormatRegistrar::FindLocaleForTextCodePage( ) +sal_Bool SAL_CALL CFormatRegistrar::findLocaleForTextCodePage( ) { + m_TxtLocale = 0; EnumSystemLocalesA( CFormatRegistrar::EnumLocalesProc, LCID_SUPPORTED ); - WaitForSingleObject( CFormatRegistrar::m_hEvtEnumLocaleReady, 60000 ); + return ( IsValidLocale( m_TxtLocale, LCID_SUPPORTED ) ); } //------------------------------------------------------------------------ @@ -545,7 +551,6 @@ BOOL CALLBACK CFormatRegistrar::EnumLocalesProc( LPSTR lpLocaleStr ) isLocaleOemCodePage( lcid, CFormatRegistrar::m_TxtCodePage ) ) { CFormatRegistrar::m_TxtLocale = lcid; - SetEvent( CFormatRegistrar::m_hEvtEnumLocaleReady ); return sal_False; // stop enumerating } diff --git a/dtrans/source/win32/dtobj/FetcList.hxx b/dtrans/source/win32/dtobj/FetcList.hxx index c4b33ddbbec9..fed592537147 100644 --- a/dtrans/source/win32/dtobj/FetcList.hxx +++ b/dtrans/source/win32/dtobj/FetcList.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FetcList.hxx,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-19 09:11:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -150,7 +150,6 @@ class CFormatRegistrar public: CFormatRegistrar( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager, const CDataFormatTranslator& aDataFormatTranslator ); - ~CFormatRegistrar( ); void SAL_CALL RegisterFormats( const com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor >& aFlavorList, CFormatEtcContainer& aFormatEtcContainer ); @@ -170,7 +169,7 @@ private: rtl::OUString SAL_CALL getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor ); CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const; - void SAL_CALL FindLocaleForTextCodePage( ); + sal_Bool SAL_CALL findLocaleForTextCodePage( ); static sal_Bool SAL_CALL isLocaleOemCodePage( LCID lcid, sal_uInt32 codepage ); static sal_Bool SAL_CALL isLocaleAnsiCodePage( LCID lcid, sal_uInt32 codepage ); @@ -184,7 +183,6 @@ private: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; - static HANDLE m_hEvtEnumLocaleReady; static LCID m_TxtLocale; static sal_uInt32 m_TxtCodePage; diff --git a/dtrans/source/win32/mtaole/MtaOleClipb.cxx b/dtrans/source/win32/mtaole/MtaOleClipb.cxx index 9d5b64e25b97..6b104ec91ff8 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.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tra $ $Date: 2001-03-16 16:32:57 $ + * last change: $Author: tra $ $Date: 2001-03-19 09:12:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,7 +113,7 @@ const sal_Bool AUTO_RESET = sal_False; const sal_Bool INIT_NONSIGNALED = sal_False; //---------------------------------------------------------------- -// +// we use one condition for every request //---------------------------------------------------------------- typedef struct _MsgCtx |