summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-01 14:39:41 +0000
committerTino Rachui <tra@openoffice.org>2001-03-01 14:39:41 +0000
commit62b1f1f8e8a221b20a9bf0568feffffb6d102ec6 (patch)
tree15917b7d0c6e1327cda636ae1c9bb561f5ad4d07
parent62ac7487861160ed387e0b2176b7065711e9f5a6 (diff)
*** empty log message ***
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.cxx74
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.hxx21
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.cxx23
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.hxx12
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.cxx51
-rw-r--r--dtrans/source/win32/dtobj/DtObjFactory.cxx22
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx33
-rw-r--r--dtrans/source/win32/dtobj/FetcList.hxx12
-rw-r--r--dtrans/source/win32/dtobj/FmtFilter.cxx7
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.cxx468
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.hxx31
-rw-r--r--dtrans/source/win32/dtobj/makefile.mk7
-rw-r--r--dtrans/source/win32/ftransl/ftransl.cxx48
13 files changed, 443 insertions, 366 deletions
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx
index 82bac927821c..9c65b6889831 100644
--- a/dtrans/source/win32/dtobj/DOTransferable.cxx
+++ b/dtrans/source/win32/dtobj/DOTransferable.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DOTransferable.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:54:17 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -126,7 +126,6 @@ const Type CPPUTYPE_OUSTRING = getCppuType( (OUString*)0 );
CDOTransferable::CDOTransferable( const Reference< XMultiServiceFactory >& ServiceManager, IDataObjectPtr rDataObject ) :
m_rDataObject( rDataObject ),
- m_bFlavorListInitialized( sal_False ),
m_SrvMgr( ServiceManager ),
m_DataFormatTranslator( m_SrvMgr )
{
@@ -139,19 +138,13 @@ CDOTransferable::CDOTransferable( const Reference< XMultiServiceFactory >& Servi
Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
throw( UnsupportedFlavorException, IOException, RuntimeException )
{
- initFlavorList( );
+ MutexGuard aGuard( m_aMutex );
FORMATETC fetc = dataFlavorToFormatEtc( aFlavor );
OSL_ASSERT( CF_INVALID != fetc.cfFormat );
ByteSequence_t clipDataStream = getClipboardData( fetc );
- // format conversion if necessary
- if ( CF_DIB == fetc.cfFormat )
- clipDataStream = WinDIBToOOBMP( clipDataStream );
- else if ( CF_METAFILEPICT == fetc.cfFormat )
- clipDataStream = WinMFPictToOOMFPict( clipDataStream );
-
return byteStreamToAny( clipDataStream, aFlavor.DataType );
}
@@ -162,7 +155,7 @@ Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
Sequence< DataFlavor > SAL_CALL CDOTransferable::getTransferDataFlavors( )
throw( RuntimeException )
{
- initFlavorList( );
+ MutexGuard aGuard( m_aMutex );
return m_FlavorList;
}
@@ -173,7 +166,7 @@ Sequence< DataFlavor > SAL_CALL CDOTransferable::getTransferDataFlavors( )
sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
throw( RuntimeException )
{
- initFlavorList( );
+ MutexGuard aGuard( m_aMutex );
for ( sal_Int32 i = 0; i < m_FlavorList.getLength( ); i++ )
if ( aFlavor == m_FlavorList[i] )
@@ -192,39 +185,28 @@ sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFla
void SAL_CALL CDOTransferable::initFlavorList( )
{
- // using double checked locking
- if ( m_bFlavorListInitialized )
- return;
-
- MutexGuard aGuard( m_aMutex );
-
- if ( !m_bFlavorListInitialized )
+ IEnumFORMATETCPtr pEnumFormatEtc;
+ HRESULT hr = m_rDataObject->EnumFormatEtc( DATADIR_GET, &pEnumFormatEtc );
+ if ( SUCCEEDED( hr ) )
{
- IEnumFORMATETCPtr pEnumFormatEtc;
- HRESULT hr = m_rDataObject->EnumFormatEtc( DATADIR_GET, &pEnumFormatEtc );
- if ( SUCCEEDED( hr ) )
- {
- pEnumFormatEtc->Reset( );
-
- FORMATETC fetc;
- while ( S_FALSE != pEnumFormatEtc->Next( 1, &fetc, NULL ) )
- {
- // we use locales only to determine the
- // charset if there is text on the cliboard
- // we don't offer this format
- if ( CF_LOCALE == fetc.cfFormat )
- continue;
+ pEnumFormatEtc->Reset( );
- DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
+ FORMATETC fetc;
+ while ( S_FALSE != pEnumFormatEtc->Next( 1, &fetc, NULL ) )
+ {
+ // we use locales only to determine the
+ // charset if there is text on the cliboard
+ // we don't offer this format
+ if ( CF_LOCALE == fetc.cfFormat )
+ continue;
- addSupportedFlavor( aFlavor );
+ DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
- // see MSDN IEnumFORMATETC
- if ( fetc.ptd )
- CoTaskMemFree( fetc.ptd );
- }
+ addSupportedFlavor( aFlavor );
- m_bFlavorListInitialized = sal_True;
+ // see MSDN IEnumFORMATETC
+ if ( fetc.ptd )
+ CoTaskMemFree( fetc.ptd );
}
}
}
@@ -233,10 +215,10 @@ void SAL_CALL CDOTransferable::initFlavorList( )
//
//------------------------------------------------------------------------
-inline
+//inline
void SAL_CALL CDOTransferable::addSupportedFlavor( const DataFlavor& aFlavor )
{
- // we irgnore all formats that can't be translated
+ // we ignore all formats that can't be translated
if ( aFlavor.MimeType.getLength( ) )
{
m_FlavorList.realloc( m_FlavorList.getLength( ) + 1 );
@@ -258,7 +240,7 @@ FORMATETC SAL_CALL CDOTransferable::dataFlavorToFormatEtc( const DataFlavor& aFl
// helper function
//------------------------------------------------------------------------
-inline
+//inline
DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFormatEtc )
{
return m_DataFormatTranslator.getDataFlavorFromFormatEtc( this, aFormatEtc );
@@ -296,6 +278,12 @@ CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( const FORMATE
throw RuntimeException( );
}
+ // format conversion if necessary
+ if ( CF_DIB == aFormatEtc.cfFormat )
+ byteStream = WinDIBToOOBMP( byteStream );
+ else if ( CF_METAFILEPICT == aFormatEtc.cfFormat )
+ byteStream = WinMFPictToOOMFPict( byteStream );
+
ReleaseStgMedium( &stgmedium );
return byteStream;
diff --git a/dtrans/source/win32/dtobj/DOTransferable.hxx b/dtrans/source/win32/dtobj/DOTransferable.hxx
index d9e0135e3c3a..ca7a322ea174 100644
--- a/dtrans/source/win32/dtobj/DOTransferable.hxx
+++ b/dtrans/source/win32/dtobj/DOTransferable.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DOTransferable.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:54:25 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,17 +85,14 @@
// deklarations
//------------------------------------------------------------------------
+// forward
+class CDTransObjFactory;
+
class CDOTransferable : public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::XTransferable >
{
public:
typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t;
-public:
- // the DataObject should be the one returned by OleGetClipboard!!!
- explicit CDOTransferable(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager,
- IDataObjectPtr rDataObject );
-
//------------------------------------------------------------------------
// XTransferable
//------------------------------------------------------------------------
@@ -110,12 +107,17 @@ public:
throw( ::com::sun::star::uno::RuntimeException );
private:
+ // should be created only by CDTransObjFactory
+ explicit CDOTransferable(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager,
+ IDataObjectPtr rDataObject );
//------------------------------------------------------------------------
// some helper functions
//------------------------------------------------------------------------
void SAL_CALL initFlavorList( );
+
void SAL_CALL addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
FORMATETC SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc );
@@ -128,7 +130,6 @@ private:
private:
IDataObjectPtr m_rDataObject;
com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > m_FlavorList;
- sal_Bool m_bFlavorListInitialized;
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr;
CDataFormatTranslator m_DataFormatTranslator;
::osl::Mutex m_aMutex;
@@ -137,6 +138,8 @@ private:
private:
CDOTransferable( const CDOTransferable& );
CDOTransferable& operator=( const CDOTransferable& );
+
+ friend class CDTransObjFactory;
};
#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/DTransHelper.cxx b/dtrans/source/win32/dtobj/DTransHelper.cxx
index 851dbbc7ea82..500be1918ee0 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:50:29 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,7 +86,7 @@ CStgTransferHelper::CStgTransferHelper( sal_Bool bAutoInit,
OSL_ASSERT( !(bDeleteStorageOnRelease && !bReleaseStreamOnDestruction) );
if ( bAutoInit )
- init( hGlob, bDeleteStorageOnRelease );
+ init( hGlob, bDeleteStorageOnRelease, bReleaseStreamOnDestruction );
}
//------------------------------------------------------------------------
@@ -111,6 +111,9 @@ sal_Bool SAL_CALL CStgTransferHelper::write( const void* lpData, ULONG cb, ULONG
if ( m_lpStream )
hr = m_lpStream->Write( lpData, cb, cbWritten );
+ if ( FAILED( hr ) )
+ throw CStgTransferException( hr );
+
return SUCCEEDED( hr );
}
@@ -125,6 +128,9 @@ sal_Bool SAL_CALL CStgTransferHelper::read( LPVOID pv, ULONG cb, ULONG* pcbRead
if ( m_lpStream )
hr = m_lpStream->Read( pv, cb , pcbRead );
+ if ( FAILED( hr ) )
+ throw CStgTransferException( hr );
+
return SUCCEEDED( hr );
}
@@ -172,7 +178,7 @@ sal_Bool SAL_CALL CStgTransferHelper::init( SIZE_T newSize,
cleanup( );
HGLOBAL hGlob = GlobalAlloc( uiFlags, newSize );
if ( NULL == hGlob )
- throw COutOfMemoryException();
+ throw CStgTransferException( STG_E_MEDIUMFULL );
HRESULT hr = CreateStreamOnHGlobal( hGlob, bDeleteStorageOnRelease, &m_lpStream );
@@ -195,7 +201,7 @@ sal_Bool SAL_CALL CStgTransferHelper::init( HGLOBAL hGlob,
cleanup( );
HRESULT hr = CreateStreamOnHGlobal( hGlob, bDeleteStorageOnRelease, &m_lpStream );
if ( hr == E_OUTOFMEMORY )
- throw COutOfMemoryException();
+ throw CStgTransferException( STG_E_MEDIUMFULL );
m_bDelStgOnRelease = bDeleteStorageOnRelease;
m_bReleaseStreamOnDestr = bReleaseStreamOnDestruction;
@@ -216,8 +222,11 @@ void SAL_CALL CStgTransferHelper::cleanup( )
GlobalFree( hGlob );
}
- m_lpStream->Release( );
- m_lpStream = NULL;
+ if ( m_lpStream )
+ {
+ m_lpStream->Release( );
+ m_lpStream = NULL;
+ }
}
//------------------------------------------------------------------------
diff --git a/dtrans/source/win32/dtobj/DTransHelper.hxx b/dtrans/source/win32/dtobj/DTransHelper.hxx
index 217f7d15718e..43283d3d8e5d 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:50:37 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,10 +82,12 @@
// deklarations
//------------------------------------------------------------------------
-// will be thrown of allocation of
-// memory fails
-class COutOfMemoryException
+// will be thrown in case of failures
+class CStgTransferException
{
+public:
+ HRESULT m_hr;
+ CStgTransferException( HRESULT hr ) : m_hr( hr ) {};
};
//-------------------------------------------------------------------------
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
index fc2b4da2db78..76e1792b973b 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:52:05 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -132,7 +132,7 @@ CDataFormatTranslator::CDataFormatTranslator( const Reference< XMultiServiceFact
m_XDataFormatTranslator = Reference< XDataFormatTranslator >(
m_SrvMgr->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.DataFormatTranslator" ) ), UNO_QUERY );
- OSL_ASSERT( !m_XDataFormatTranslator.is( ) );
+ OSL_ASSERT( m_XDataFormatTranslator.is( ) );
}
//------------------------------------------------------------------------
@@ -141,7 +141,7 @@ CDataFormatTranslator::CDataFormatTranslator( const Reference< XMultiServiceFact
FORMATETC CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& aDataFlavor ) const
{
- CLIPFORMAT cf = CF_INVALID;
+ sal_Int32 cf = CF_INVALID;
try
{
@@ -194,7 +194,7 @@ DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< X
aFlavor.MimeType += getTextCharsetFromClipboard( refXTransferable, aClipformat );
aFlavor.HumanPresentableName = OUString::createFromAscii( "OEM/ANSI Text" );
- aFlavor.DataType = CPPUTYPE_SALINT8;
+ aFlavor.DataType = CPPUTYPE_SEQSALINT8;
}
else
{
@@ -202,8 +202,20 @@ DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< X
if ( !aFlavor.MimeType.getLength( ) )
{
- aAny <<= getClipboardFormatName( aClipformat );
- aFlavor = m_XDataFormatTranslator->getDataFlavorFromSystemDataType( aAny );
+ // lookup of DataFlavor from clipboard format id
+ // failed, so we try to resolve via clipboard
+ // format name
+ OUString clipFormatName = getClipboardFormatName( aClipformat );
+
+ // if we could not get a clipboard format name an
+ // error must have occured or it is a standard
+ // clipboard format that we don't translate, e.g.
+ // CF_BITMAP (the office only uses CF_DIB)
+ if ( clipFormatName.getLength( ) )
+ {
+ aAny <<= clipFormatName;
+ aFlavor = m_XDataFormatTranslator->getDataFlavorFromSystemDataType( aAny );
+ }
}
}
}
@@ -295,9 +307,7 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
const Reference< XTransferable >& refXTransferable ) const
{
Any aAny;
- FORMATETC fetc;
-
- fetc.cfFormat = CF_LOCALE;
+ FORMATETC fetc = getFormatEtcForClipformat( CF_LOCALE );
DataFlavor aFlavor = getDataFlavorFromFormatEtc( refXTransferable, fetc );
OSL_ASSERT( aFlavor.MimeType.getLength( ) );
@@ -306,19 +316,20 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
try
{
- if ( refXTransferable->isDataFlavorSupported( aFlavor ) )
+ aAny = refXTransferable->getTransferData( aFlavor );
+ if ( aAny.hasValue( ) )
{
- aAny = refXTransferable->getTransferData( aFlavor );
- if ( aAny.hasValue( ) )
- {
- OSL_ASSERT( aAny.getValueType( ) == CPPUTYPE_SEQSALINT8 );
- Sequence< sal_Int8 > seqSalInt8;
- aAny >>= seqSalInt8;
+ OSL_ASSERT( aAny.getValueType( ) == CPPUTYPE_SEQSALINT8 );
+ Sequence< sal_Int8 > byteStream;
+ aAny >>= byteStream;
- lcid = *reinterpret_cast< sal_Int32* >( seqSalInt8.getArray( ) );
- }
+ lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) );
}
}
+ catch( UnsupportedFlavorException& )
+ {
+ lcid = GetThreadLocale( );
+ }
catch( ... )
{
OSL_ENSURE( sal_False, "Unexpected error" );
@@ -339,7 +350,7 @@ OUString SAL_CALL CDataFormatTranslator::makeMimeCharsetFromLocaleId(
LCID lcid, LCTYPE lcType, const OUString& aCharsetValuePrefix ) const
{
OUString charset = getCodePageFromLocaleId( lcid, lcType );
- return OUString::createFromAscii( "charset=" ) + charset;
+ return aCharsetValuePrefix + charset;
}
//------------------------------------------------------------------------
diff --git a/dtrans/source/win32/dtobj/DtObjFactory.cxx b/dtrans/source/win32/dtobj/DtObjFactory.cxx
index d90cbc1d593c..152b5bcae435 100644
--- a/dtrans/source/win32/dtobj/DtObjFactory.cxx
+++ b/dtrans/source/win32/dtobj/DtObjFactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DtObjFactory.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:52:43 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,10 @@
#include "DOTransferable.hxx"
#endif
+#ifndef _WRPDOTRANSFERABLE_HXX_
+#include "WrpDOTransferable.hxx"
+#endif
+
//------------------------------------------------------------------------
// namespace directives
//------------------------------------------------------------------------
@@ -90,12 +94,22 @@ using namespace com::sun::star::lang;
IDataObjectPtr SAL_CALL CDTransObjFactory::createDataObjFromTransferable( const Reference< XMultiServiceFactory >& aServiceManager,
const Reference< XTransferable >& refXTransferable )
{
- return ( IDataObjectPtr( new CXTDataObject( aServiceManager, refXTransferable ) ) );
+ Reference< XTransferable > wrpTransf( new CWrpDOTransferable( aServiceManager, refXTransferable, sal_False ) );
+ return ( IDataObjectPtr( new CXTDataObject( aServiceManager, wrpTransf ) ) );
}
Reference< XTransferable > SAL_CALL CDTransObjFactory::createTransferableFromDataObj( const Reference< XMultiServiceFactory >& aServiceManager,
IDataObject* pIDataObject )
{
- return Reference< XTransferable >( new CDOTransferable( aServiceManager, pIDataObject ) );
+ CDOTransferable* pTransf = new CDOTransferable( aServiceManager, pIDataObject );
+ Reference< XTransferable > refDOTransf( pTransf );
+
+ pTransf->acquire( );
+ pTransf->initFlavorList( );
+ pTransf->release( );
+
+ return Reference< XTransferable >( new CWrpDOTransferable( aServiceManager, refDOTransf ) );
+
+ //return refDOTransf;
}
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index 836bafb87ecb..a362f7ed6f52 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:51:10 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,10 +124,7 @@ CFormatEtc::CFormatEtc( const FORMATETC& aFormatEtc )
CFormatEtc::CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd, DWORD dwAspect, LONG lindex )
{
m_FormatEtc.cfFormat = cf;
-
- if ( ptd )
- m_FormatEtc.ptd = CopyTargetDevice( ptd );
-
+ m_FormatEtc.ptd = CopyTargetDevice( ptd );
m_FormatEtc.dwAspect = dwAspect;
m_FormatEtc.lindex = lindex;
m_FormatEtc.tymed = tymed;
@@ -140,10 +137,7 @@ CFormatEtc::CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd, DWORD d
CFormatEtc::CFormatEtc( const CFormatEtc& theOther )
{
m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
-
- if ( theOther.m_FormatEtc.ptd )
- m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
-
+ m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
m_FormatEtc.lindex = theOther.m_FormatEtc.lindex;
m_FormatEtc.tymed = theOther.m_FormatEtc.tymed;
@@ -155,8 +149,7 @@ CFormatEtc::CFormatEtc( const CFormatEtc& theOther )
CFormatEtc::~CFormatEtc( )
{
- if ( m_FormatEtc.ptd )
- DeleteTargetDevice( m_FormatEtc.ptd );
+ DeleteTargetDevice( m_FormatEtc.ptd );
}
//------------------------------------------------------------------------
@@ -167,14 +160,10 @@ CFormatEtc& CFormatEtc::operator=( const CFormatEtc& theOther )
{
if ( this != &theOther )
{
- if ( m_FormatEtc.ptd )
- DeleteTargetDevice( m_FormatEtc.ptd );
+ DeleteTargetDevice( m_FormatEtc.ptd );
m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
-
- if ( theOther.m_FormatEtc.ptd )
- m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
-
+ m_FormatEtc.ptd = CopyTargetDevice( theOther.m_FormatEtc.ptd );
m_FormatEtc.dwAspect = theOther.m_FormatEtc.dwAspect;
m_FormatEtc.lindex = theOther.m_FormatEtc.lindex;
m_FormatEtc.tymed = theOther.m_FormatEtc.tymed;
@@ -259,7 +248,7 @@ LONG CFormatEtc::getLindex( ) const
//
//------------------------------------------------------------------------
-sal_Bool operator==( CFormatEtc& lhs, CFormatEtc& rhs )
+sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs )
{
return CompareFormatEtc( &lhs.m_FormatEtc, &rhs.m_FormatEtc );
}
@@ -268,9 +257,9 @@ sal_Bool operator==( CFormatEtc& lhs, CFormatEtc& rhs )
//
//------------------------------------------------------------------------
-sal_Bool operator!=( CFormatEtc& lhs, CFormatEtc& rhs )
+sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs )
{
- return ( !( lhs == rhs ) );
+ return ( ( lhs == rhs ) != 1 );
}
@@ -365,7 +354,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++ )
+ for ( sal_uInt32 i = 0; i < aNum; i++, nFetched++, lpFetc++, ++m_EnumIterator )
{
CopyFormatEtc( lpFetc, m_EnumIterator->second );
}
diff --git a/dtrans/source/win32/dtobj/FetcList.hxx b/dtrans/source/win32/dtobj/FetcList.hxx
index ca27cdbc7242..c6ed8eef1a85 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.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:51:04 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,12 +113,12 @@ public:
private:
FORMATETC m_FormatEtc;
- friend sal_Bool operator==( CFormatEtc& lhs, CFormatEtc& rhs );
- friend sal_Bool operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
+ friend sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs );
+ friend sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
};
-sal_Bool operator==( CFormatEtc& lhs, CFormatEtc& rhs );
-sal_Bool operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
+sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs );
+sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
/*****************************************************************
a simple container for FORMATECT structures
diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx
index fe5be0891411..44ce10ed5a5d 100644
--- a/dtrans/source/win32/dtobj/FmtFilter.cxx
+++ b/dtrans/source/win32/dtobj/FmtFilter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FmtFilter.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:53:46 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,7 +106,8 @@ Sequence< sal_Int8 > SAL_CALL WinMFPictToOOMFPict( Sequence< sal_Int8 >& aMetaFi
OSL_ASSERT( pMFPict );
OSL_ASSERT( !IsBadReadPtr( pMFPict, sizeof( METAFILEPICT ) ) );
- sal_uInt32 nCount = GetMetaFileBitsEx( pMFPict->hMF, 0, NULL );
+ HMETAFILE hMf = pMFPict->hMF;
+ sal_uInt32 nCount = GetMetaFileBitsEx( hMf, 0, NULL );
Sequence< sal_Int8 > mfpictStream( nCount + sizeof( METAFILEHEADER ) );
METAFILEHEADER* pMFHeader = (METAFILEHEADER*)mfpictStream.getArray( );
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index d012bd72d4e1..f70e6ca45ccc 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.cxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:53:22 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,6 +109,17 @@ using namespace com::sun::star::lang;
using namespace rtl;
//------------------------------------------------------------------------
+// a helper class that will be thrown by the function validateFormatEtc
+//------------------------------------------------------------------------
+
+class CInvalidFormatEtcException
+{
+public:
+ HRESULT m_hr;
+ CInvalidFormatEtcException( HRESULT hr ) : m_hr( hr ) {};
+};
+
+//------------------------------------------------------------------------
// ctor
//------------------------------------------------------------------------
@@ -175,155 +186,41 @@ STDMETHODIMP_(ULONG) CXTDataObject::Release( )
//
//------------------------------------------------------------------------
-inline
-sal_Bool CXTDataObject::isRequestForLocale( LPFORMATETC lpFormatEtc ) const
-{
- return ( CF_LOCALE == lpFormatEtc->cfFormat );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-inline
-DataFlavor SAL_CALL CXTDataObject::formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const
-{
- return m_DataFormatTranslator.getDataFlavorFromFormatEtc( m_XTransferable, aFormatEtc );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-sal_Bool SAL_CALL CXTDataObject::isSynthesizeableFormat( LPFORMATETC lpFormatEtc ) const
-{
- return ( (lpFormatEtc->cfFormat == CF_TEXT) ||
- (lpFormatEtc->cfFormat == CF_OEMTEXT) ||
- (lpFormatEtc->cfFormat == CF_UNICODETEXT) );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
{
if ( !(pFormatetc && pmedium) )
return E_INVALIDARG;
- HRESULT hr = validateFormatEtc( pFormatetc );
- if ( FAILED( hr ) )
- return hr;
-
- DataFlavor aFlavor;
-
try
{
- if ( isRequestForLocale( pFormatetc ) )
- {
- if ( m_FormatRegistrar.hasSynthesizedLocale( ) )
- {
- LCID lcid = m_FormatRegistrar.getSynthesizedLocale( );
- TransferDataToStorageAndSetupStgMedium( reinterpret_cast< sal_Int8* >( &lcid ),
- *pFormatetc,
- 0,
- sizeof( LCID ),
- *pmedium );
- return S_OK;
- }
- else
- return DV_E_FORMATETC;
- }
-
- aFlavor = formatEtcToDataFlavor( *pFormatetc );
-
- if ( CF_UNICODETEXT == pFormatetc->cfFormat )
- {
- OUString aText;
- m_XTransferable->getTransferData( aFlavor ) >>= aText;
-
- sal_uInt32 nRequiredMemSize = aText.getLength( ) * sizeof( sal_Unicode ) + 1;
- sal_uInt32 nBytesToTransfer = aText.getLength( ) * sizeof( sal_Unicode );
- hr = TransferDataToStorageAndSetupStgMedium( reinterpret_cast< const sal_Int8* >( aText.getStr( ) ),
- *pFormatetc,
- nRequiredMemSize,
- nBytesToTransfer,
- *pmedium );
- }
+ invalidateStgMedium( *pmedium );
+ validateFormatEtc( pFormatetc );
+
+ // handle locale request, because locale is a artificial format for us
+ if ( CF_LOCALE == pFormatetc->cfFormat )
+ transferLocaleToClipbAndSetupStgMedium( *pFormatetc, *pmedium );
+ else if ( CF_UNICODETEXT == pFormatetc->cfFormat )
+ transferUnicodeToClipbAndSetupStgMedium( *pFormatetc, *pmedium );
else
- {
- Sequence< sal_Int8 > clipDataStream;
- m_XTransferable->getTransferData( aFlavor ) >>= clipDataStream;
-
- sal_uInt32 nRequiredMemSize = 0;
- if ( (CF_TEXT == pFormatetc->cfFormat) || (CF_OEMTEXT == pFormatetc->cfFormat) )
- nRequiredMemSize = sizeof( sal_Int8 ) * clipDataStream.getLength( ) + 1;
-
- // prepare data for transmision
- if ( CF_DIB == pFormatetc->cfFormat )
- {
- clipDataStream = OOBmpToWinDIB( clipDataStream );
- }
-
- if ( CF_METAFILEPICT == pFormatetc->cfFormat )
- {
- HMETAFILE hMfPict = OOMFPictToWinMFPict( clipDataStream );
- TransferDataToStorageAndSetupStgMedium( reinterpret_cast< sal_Int8* >( &hMfPict ),
- *pFormatetc,
- 0,
- sizeof( HMETAFILE ),
- *pmedium );
- }
- else
- TransferDataToStorageAndSetupStgMedium( clipDataStream.getArray( ),
- *pFormatetc,
- nRequiredMemSize,
- clipDataStream.getLength( ),
- *pmedium );
- }
+ transferAnyDataToClipbAndSetupStgMedium( *pFormatetc, *pmedium );
}
catch(UnsupportedFlavorException&)
{
if ( isSynthesizeableFormat( pFormatetc ) )
{
- /*
- FORMATETC fetc;
-
- synthesize format
- if ( requested format is unicodetext ) // implies the transferable has really only text
- {
- fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT );
- aFlavor = formatEtcToDataFlavor( fetc );
-
- get transfer data
- convert transfer data to unicode text
- transfer result to storage
- }
- else // implies the transferable has really only unicodetext
- {
- fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT );
- aFlavor = formatEtcToDataFlavor( fetc );
-
- get transfer data
- if ( request is for ansi text )
- convert transfer data to text using the CP_ACP
- else
- convert transfer data to oemtext using CP_OEMCP
-
- transfer result to storage
- }
-
- transfer data to storage
- */
-
+ // synthesize format
return S_OK;
}
return DV_E_FORMATETC;
}
- catch(COutOfMemoryException&)
+ catch( CInvalidFormatEtcException& ex )
+ {
+ return ex.m_hr;
+ }
+ catch( CStgTransferException& ex )
{
- return STG_E_MEDIUMFULL;
+ return translateStgExceptionCode( ex.m_hr );
}
catch(...)
{
@@ -333,46 +230,151 @@ STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium
return S_OK;
}
+/*
+ FORMATETC fetc;
+
+ synthesize format
+ if ( requested format is unicodetext ) // implies the transferable has really only text
+ {
+ fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT );
+ aFlavor = formatEtcToDataFlavor( fetc );
+
+ get transfer data
+ convert transfer data to unicode text
+ transfer result to storage
+ }
+ else // implies the transferable has really only unicodetext
+ {
+ fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT );
+ aFlavor = formatEtcToDataFlavor( fetc );
+
+ get transfer data
+ if ( request is for ansi text )
+ convert transfer data to text using the CP_ACP
+ else
+ convert transfer data to oemtext using CP_OEMCP
+
+ transfer result to storage
+ }
+
+ transfer data to storage
+*/
+
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
-HRESULT SAL_CALL CXTDataObject::TransferDataToStorageAndSetupStgMedium( const sal_Int8* lpStorage,
+// inline
+void SAL_CALL CXTDataObject::transferDataToStorageAndSetupStgMedium( const sal_Int8* lpStorage,
const FORMATETC& fetc,
sal_uInt32 nInitStgSize,
sal_uInt32 nBytesToTransfer,
STGMEDIUM& stgmedium )
{
- HRESULT hr = S_OK;
+ OSL_PRECOND( !nInitStgSize || nInitStgSize && (nInitStgSize >= nBytesToTransfer),
+ "Memory size less than number of bytes to transfer" );
+
+ // if the client wants the data only via IStream we setup the storage transfer
+ // helper so that the stream will not be released on destruction
+ sal_Bool bShouldReleaseStream = ((fetc.tymed & TYMED_HGLOBAL) || !(fetc.tymed & TYMED_ISTREAM));
+ CStgTransferHelper stgTransfHelper( AUTO_INIT,
+ NULL,
+ sal_False,
+ bShouldReleaseStream );
+
+ // setup storage size
+ if ( nInitStgSize > 0 )
+ stgTransfHelper.init( nInitStgSize,
+ GMEM_MOVEABLE | GMEM_ZEROINIT,
+ sal_False,
+ bShouldReleaseStream );
+
+ stgTransfHelper.write( lpStorage, nBytesToTransfer );
+
+ setupStgMedium( fetc, stgTransfHelper, stgmedium );
+}
- if ( isValidTymedForClipformat( fetc ) )
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+//inline
+void SAL_CALL CXTDataObject::transferLocaleToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
+{
+ if ( m_FormatRegistrar.hasSynthesizedLocale( ) )
{
- // if the client wants the data only via IStream we setup the storage transfer
- // helper so that the stream will not be released on destruction
- sal_Bool bShouldReleaseStream =
- ( (fetc.tymed & TYMED_ISTREAM) && !(fetc.tymed & TYMED_HGLOBAL) );
- CStgTransferHelper stgTransfHelper( AUTO_INIT,
- NULL,
- sal_False,
- bShouldReleaseStream );
-
- // setup storage size
- if ( nInitStgSize > 0 )
- stgTransfHelper.init( nInitStgSize,
- GMEM_MOVEABLE | GMEM_ZEROINIT,
- sal_False,
- bShouldReleaseStream );
-
- sal_Bool bResult = stgTransfHelper.write( lpStorage, nBytesToTransfer );
-
- setupStgMedium( bResult, fetc, stgTransfHelper, stgmedium );
- if ( !bResult )
- hr = E_UNEXPECTED;
+ LCID lcid = m_FormatRegistrar.getSynthesizedLocale( );
+ transferDataToStorageAndSetupStgMedium(
+ reinterpret_cast< sal_Int8* >( &lcid ),
+ fetc,
+ 0,
+ sizeof( LCID ),
+ stgmedium );
}
else
- hr = DV_E_FORMATETC;
+ throw CInvalidFormatEtcException( DV_E_FORMATETC );
+}
- return hr;
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+//inline
+void SAL_CALL CXTDataObject::transferUnicodeToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
+{
+ DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
+
+ OUString aText;
+ m_XTransferable->getTransferData( aFlavor ) >>= aText;
+
+ sal_uInt32 nBytesToTransfer = aText.getLength( ) * sizeof( sal_Unicode );
+ sal_uInt32 nRequiredMemSize = nBytesToTransfer + 1;
+
+ transferDataToStorageAndSetupStgMedium(
+ reinterpret_cast< const sal_Int8* >( aText.getStr( ) ),
+ fetc,
+ nRequiredMemSize,
+ nBytesToTransfer,
+ stgmedium );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+//inline
+void SAL_CALL CXTDataObject::transferAnyDataToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
+{
+ DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
+
+ Sequence< sal_Int8 > clipDataStream;
+ m_XTransferable->getTransferData( aFlavor ) >>= clipDataStream;
+
+ sal_uInt32 nRequiredMemSize = 0;
+ if ( isOemOrAnsiTextFormat( fetc.cfFormat ) )
+ nRequiredMemSize = sizeof( sal_Int8 ) * clipDataStream.getLength( ) + 1;
+
+ // prepare data for transmision
+ if ( CF_DIB == fetc.cfFormat )
+ clipDataStream = OOBmpToWinDIB( clipDataStream );
+
+ if ( CF_METAFILEPICT == fetc.cfFormat )
+ {
+ HMETAFILE hMfPict = OOMFPictToWinMFPict( clipDataStream );
+ transferDataToStorageAndSetupStgMedium(
+ reinterpret_cast< sal_Int8* >( &hMfPict ),
+ fetc,
+ 0,
+ sizeof( HMETAFILE ),
+ stgmedium );
+ }
+ else
+ transferDataToStorageAndSetupStgMedium(
+ clipDataStream.getArray( ),
+ fetc,
+ nRequiredMemSize,
+ clipDataStream.getLength( ),
+ stgmedium );
}
//------------------------------------------------------------------------
@@ -496,26 +498,26 @@ void SAL_CALL CXTDataObject::GetAllDataFromSource( )
//------------------------------------------------------------------------
inline
-STDMETHODIMP CXTDataObject::validateFormatEtc( LPFORMATETC lpFormatEtc ) const
+DataFlavor SAL_CALL CXTDataObject::formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const
{
- OSL_ASSERT( lpFormatEtc );
+ DataFlavor aFlavor =
+ m_DataFormatTranslator.getDataFlavorFromFormatEtc( m_XTransferable, aFormatEtc );
- if ( lpFormatEtc->lindex != -1 )
- return DV_E_LINDEX;
+ if ( !aFlavor.MimeType.getLength( ) )
+ throw UnsupportedFlavorException( );
- if ( (lpFormatEtc->dwAspect != DVASPECT_CONTENT) ||
- (lpFormatEtc->dwAspect != DVASPECT_COPY) ||
- (lpFormatEtc->dwAspect != DVASPECT_LINK) ||
- (lpFormatEtc->dwAspect != DVASPECT_SHORTNAME) )
- return DV_E_DVASPECT;
+ return aFlavor;
+}
- if ( (lpFormatEtc->tymed != TYMED_HGLOBAL) ||
- (lpFormatEtc->tymed != TYMED_ISTREAM) ||
- (lpFormatEtc->tymed != TYMED_MFPICT) ||
- (lpFormatEtc->tymed != TYMED_ENHMF) )
- return DV_E_TYMED;
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
- return S_OK;
+sal_Bool SAL_CALL CXTDataObject::isSynthesizeableFormat( LPFORMATETC lpFormatEtc ) const
+{
+ return ( (lpFormatEtc->cfFormat == CF_TEXT) ||
+ (lpFormatEtc->cfFormat == CF_OEMTEXT) ||
+ (lpFormatEtc->cfFormat == CF_UNICODETEXT) );
}
//------------------------------------------------------------------------
@@ -523,40 +525,67 @@ STDMETHODIMP CXTDataObject::validateFormatEtc( LPFORMATETC lpFormatEtc ) const
//------------------------------------------------------------------------
inline
-void SAL_CALL CXTDataObject::setupStgMedium( sal_Bool bTransferSuccessful,
- const FORMATETC& fetc,
+void CXTDataObject::validateFormatEtc( LPFORMATETC lpFormatEtc ) const
+{
+ OSL_ASSERT( lpFormatEtc );
+
+ if ( lpFormatEtc->lindex != -1 )
+ throw CInvalidFormatEtcException( DV_E_LINDEX );
+
+ if ( !(lpFormatEtc->dwAspect & DVASPECT_CONTENT) &&
+ !(lpFormatEtc->dwAspect & DVASPECT_COPY) &&
+ !(lpFormatEtc->dwAspect & DVASPECT_LINK) &&
+ !(lpFormatEtc->dwAspect & DVASPECT_SHORTNAME) )
+ throw CInvalidFormatEtcException( DV_E_DVASPECT );
+
+ if ( !(lpFormatEtc->tymed & TYMED_HGLOBAL) &&
+ !(lpFormatEtc->tymed & TYMED_ISTREAM) &&
+ !(lpFormatEtc->tymed & TYMED_MFPICT) &&
+ !(lpFormatEtc->tymed & TYMED_ENHMF) )
+ throw CInvalidFormatEtcException( DV_E_TYMED );
+
+ if ( lpFormatEtc->cfFormat == CF_METAFILEPICT &&
+ !(lpFormatEtc->tymed & TYMED_MFPICT) )
+ throw CInvalidFormatEtcException( DV_E_TYMED );
+
+ if ( lpFormatEtc->cfFormat == CF_ENHMETAFILE &&
+ !(lpFormatEtc->tymed & TYMED_ENHMF) )
+ throw CInvalidFormatEtcException( DV_E_TYMED );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+//inline
+void SAL_CALL CXTDataObject::setupStgMedium( const FORMATETC& fetc,
CStgTransferHelper& stgTransHlp,
STGMEDIUM& stgmedium )
{
stgmedium.pUnkForRelease = NULL;
- if ( bTransferSuccessful )
+ if ( fetc.tymed & TYMED_MFPICT )
{
- if ( fetc.tymed & TYMED_MFPICT )
- {
- stgmedium.tymed = TYMED_MFPICT;
- stgmedium.hMetaFilePict = static_cast< HMETAFILEPICT >( stgTransHlp.getHGlobal( ) );
- }
- else if ( fetc.tymed & TYMED_ENHMF )
- {
- stgmedium.tymed = TYMED_ENHMF;
- stgmedium.hEnhMetaFile = static_cast< HENHMETAFILE >( stgTransHlp.getHGlobal( ) );
- }
- else if ( fetc.tymed & TYMED_HGLOBAL )
- {
- stgmedium.tymed = TYMED_HGLOBAL;
- stgmedium.hGlobal = stgTransHlp.getHGlobal( );
- }
- else if ( fetc.tymed & TYMED_ISTREAM )
- {
- stgmedium.tymed = TYMED_ISTREAM;
- stgTransHlp.getIStream( &stgmedium.pstm );
- }
- else
- OSL_ASSERT( sal_False );
+ stgmedium.tymed = TYMED_MFPICT;
+ stgmedium.hMetaFilePict = static_cast< HMETAFILEPICT >( stgTransHlp.getHGlobal( ) );
+ }
+ else if ( fetc.tymed & TYMED_ENHMF )
+ {
+ stgmedium.tymed = TYMED_ENHMF;
+ stgmedium.hEnhMetaFile = static_cast< HENHMETAFILE >( stgTransHlp.getHGlobal( ) );
+ }
+ else if ( fetc.tymed & TYMED_HGLOBAL )
+ {
+ stgmedium.tymed = TYMED_HGLOBAL;
+ stgmedium.hGlobal = stgTransHlp.getHGlobal( );
+ }
+ else if ( fetc.tymed & TYMED_ISTREAM )
+ {
+ stgmedium.tymed = TYMED_ISTREAM;
+ stgTransHlp.getIStream( &stgmedium.pstm );
}
else
- stgmedium.tymed = TYMED_NULL;
+ OSL_ASSERT( sal_False );
}
//------------------------------------------------------------------------
@@ -564,19 +593,42 @@ void SAL_CALL CXTDataObject::setupStgMedium( sal_Bool bTransferSuccessful,
//------------------------------------------------------------------------
inline
-sal_Bool SAL_CALL CXTDataObject::isValidTymedForClipformat( const FORMATETC& fetc ) const
+void SAL_CALL CXTDataObject::invalidateStgMedium( STGMEDIUM& stgmedium ) const
{
- if ( fetc.cfFormat == CF_METAFILEPICT && !(fetc.tymed & TYMED_MFPICT) )
- return sal_False;
+ stgmedium.tymed = TYMED_NULL;
+}
- if ( fetc.cfFormat == CF_ENHMETAFILE && !(fetc.tymed & TYMED_ENHMF) )
- return sal_False;
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
- if ( !(fetc.tymed & TYMED_HGLOBAL) ||
- !(fetc.tymed & TYMED_ISTREAM) )
- return sal_False;
+inline
+sal_Bool SAL_CALL CXTDataObject::isOemOrAnsiTextFormat( const CLIPFORMAT& aClipformat ) const
+{
+ return ( (aClipformat == CF_TEXT) || (aClipformat == CF_OEMTEXT) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+inline
+HRESULT SAL_CALL CXTDataObject::translateStgExceptionCode( HRESULT hr ) const
+{
+ HRESULT hrTransl;
+
+ switch( hr )
+ {
+ case STG_E_MEDIUMFULL:
+ hrTransl = hr;
+ break;
+
+ default:
+ hrTransl = E_UNEXPECTED;
+ break;
+ }
- return sal_True;
+ return hrTransl;
}
//============================================================================
diff --git a/dtrans/source/win32/dtobj/XTDataObject.hxx b/dtrans/source/win32/dtobj/XTDataObject.hxx
index ad79d670717c..541d9e77152d 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.hxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:53:16 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -153,22 +153,27 @@ public:
//Unlock( );
private:
- STDMETHODIMP validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
- sal_Bool SAL_CALL isRequestForLocale( LPFORMATETC lpFormatEtc ) const;
+ void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;
sal_Bool SAL_CALL isSynthesizeableFormat( LPFORMATETC lpFormatEtc ) const;
- HRESULT SAL_CALL TransferDataToStorageAndSetupStgMedium( const sal_Int8* lpStorage,
- const FORMATETC& fetc,
- sal_uInt32 nInitStgSize,
- sal_uInt32 nBytesToTransfer,
- STGMEDIUM& stgmedium );
-
- void SAL_CALL setupStgMedium( sal_Bool bTransferSuccessful,
- const FORMATETC& fetc,
+ void SAL_CALL transferDataToStorageAndSetupStgMedium( const sal_Int8* lpStorage,
+ const FORMATETC& fetc,
+ sal_uInt32 nInitStgSize,
+ sal_uInt32 nBytesToTransfer,
+ STGMEDIUM& stgmedium );
+
+ void SAL_CALL transferLocaleToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+ void SAL_CALL transferUnicodeToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+ void SAL_CALL transferAnyDataToClipbAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+
+ void SAL_CALL setupStgMedium( const FORMATETC& fetc,
CStgTransferHelper& stgTransHlp,
STGMEDIUM& stgmedium );
- sal_Bool SAL_CALL isValidTymedForClipformat( const FORMATETC& fetc ) const;
+ void SAL_CALL invalidateStgMedium( STGMEDIUM& stgmedium ) const;
+
+ sal_Bool SAL_CALL isOemOrAnsiTextFormat( const CLIPFORMAT& aClipformat ) const;
+ HRESULT SAL_CALL translateStgExceptionCode( HRESULT hr ) const;
private:
LONG m_nRefCnt;
diff --git a/dtrans/source/win32/dtobj/makefile.mk b/dtrans/source/win32/dtobj/makefile.mk
index d070d2d77b85..0bb49c03ed37 100644
--- a/dtrans/source/win32/dtobj/makefile.mk
+++ b/dtrans/source/win32/dtobj/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: tra $ $Date: 2001-02-27 07:52:58 $
+# last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -85,7 +85,8 @@ SLOFILES=$(SLO)$/DtObjFactory.obj\
$(SLO)$/TxtCnvtHlp.obj\
$(SLO)$/DataFmtTransl.obj\
$(SLO)$/FmtFilter.obj\
- $(SLO)$/FetcList.obj
+ $(SLO)$/FetcList.obj\
+ $(SLO)$/WrpDOTransferable.obj
LIB1TARGET=$(SLB)$/$(TARGET).lib
LIB1OBJFILES=$(SLOFILES)
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index d320dc02ea6f..482ee744fd0a 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:38:03 $
+ * last change: $Author: tra $ $Date: 2001-03-01 15:39:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,6 +87,7 @@
#define IMPL_NAME "com.sun.star.datatransfer.DataFormatTranslator"
+#define MODULE_PRIVATE
#define CPPUTYPE_SEQSALINT8 getCppuType( (const Sequence< sal_Int8 >*) 0 )
#define CPPUTYPE_OUSTR getCppuType( (const ::rtl::OUString*) 0 )
#define CPPUTYPE_SALINT32 getCppuType( ( sal_Int32 * ) 0 )
@@ -95,7 +96,7 @@
#define EMPTY_OUSTR OUString::createFromAscii( "" )
#define _PARAM_WINFORMATNAME "windows_formatname"
-#define PRIVATE_OO( native_fmt ) OUString::createFromAscii( "application/x-openoffice;" _PARAM_WINFORMATNAME "=" #native_fmt )
+#define PRIVATE_OO OUString::createFromAscii( "application/x-openoffice;" _PARAM_WINFORMATNAME "=" )
#define PARAM_WINFORMATNAME OUString::createFromAscii( _PARAM_WINFORMATNAME )
//------------------------------------------------------------------------
@@ -115,7 +116,7 @@ using namespace com::sun::star::container;
// helper functions
//------------------------------------------------------------------------
-namespace
+namespace MODULE_PRIVATE
{
Sequence< OUString > SAL_CALL DataFormatTranslator_getSupportedServiceNames( )
{
@@ -158,20 +159,20 @@ Any SAL_CALL CDataFormatTranslator::getSystemDataTypeFromDataFlavor( const DataF
OUString fullMediaType = refXMimeCntType->getFullMediaType( );
if ( isTextPlainMediaType( fullMediaType ) )
{
+ // default is CF_TEXT
aAny <<= static_cast< sal_Int32 >( CF_TEXT );
- if ( refXMimeCntType->hasParameter( OUSTR( charset ) ) )
- {
- OUString charset = refXMimeCntType->getParameterValue( OUSTR( charset ) );
- findStandardFormatIdForCharset( charset, aAny );
- }
+ // but maybe it is unicode text or oem text
+ OUString charset = refXMimeCntType->getParameterValue( OUSTR( charset ) );
+ findStandardFormatIdForCharset( charset, aAny );
}
else
{
if ( refXMimeCntType->hasParameter( PARAM_WINFORMATNAME ) )
{
- OUString winfmtname = refXMimeCntType->getParameterValue( OUSTR( PARAM_WINFORMATNAME ) );
+ OUString winfmtname = refXMimeCntType->getParameterValue( PARAM_WINFORMATNAME );
aAny <<= winfmtname;
+
setStandardFormatIdForNativeFormatName( winfmtname, aAny );
}
else
@@ -184,11 +185,11 @@ Any SAL_CALL CDataFormatTranslator::getSystemDataTypeFromDataFlavor( const DataF
}
catch( NoSuchElementException& )
{
- OSL_ASSERT( sal_False );
+ OSL_ENSURE( sal_False, "text/plain Contenttype without charset parameter detected" );
}
catch( ... )
{
- OSL_ASSERT( sal_False );
+ OSL_ENSURE( sal_False, "Unexpected error" );
throw;
}
@@ -277,6 +278,7 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable( )
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(Bitmap), CF_DIB ) );// SOT_FORMAT_BITMAP
m_TranslTable.push_back( mkPublicFormatEntry( OUSTR(text/plain;charset=utf-16), EMPTY_OUSTR, CF_UNICODETEXT, OUSTR(Unicode-Text), CPPUTYPE_OUSTR) );
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(Locale), CF_LOCALE ) );
+ m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(Image WMF), CF_METAFILEPICT ) );// SOT_FORMAT_WMF
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(GDIMetaFile) ) );// SOT_FORMAT_GDIMETAFILE
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(Private) ) );// SOT_FORMAT_PRIVATE
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(FileName) ) );// SOT_FORMAT_FILE
@@ -334,6 +336,7 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable( )
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(StarDraw TabBar) ) ); //SOT_FORMATSTR_ID_STARDRAW_TABBAR
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(SONLK (StarOffice Navi Link)) ) );//SOT_FORMATSTR_ID_SONLK
m_TranslTable.push_back( mkPublicFormatEntry( OUSTR(application/msword), OUSTR(MSWordDoc) ) ); //SOT_FORMATSTR_ID_MSWORD_DOC
+ //m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(MSWordDoc) ) ); //SOT_FORMATSTR_ID_MSWORD_DOC
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(StarFrameSetDocument) ) );//SOT_FORMATSTR_ID_STAR_FRAMESET_DOC
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(OfficeDocument) ) );//SOT_FORMATSTR_ID_OFFICE_DOC
m_TranslTable.push_back( mkPrivateFormatEntry( OUSTR(NotesDocInfo) ) ); //SOT_FORMATSTR_ID_NOTES_DOCINFO
@@ -422,7 +425,9 @@ void SAL_CALL CDataFormatTranslator::findDataFlavorForStandardFormatId( sal_Int3
void SAL_CALL CDataFormatTranslator::findDataFlavorForNativeFormatName( const OUString& aNativeFormatName, DataFlavor& aDataFlavor ) const
{
vector< FormatEntry >::const_iterator citer_end = m_TranslTable.end( );
- for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( ); citer != citer_end; ++citer )
+ for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( );
+ citer != citer_end;
+ ++citer )
{
if ( aNativeFormatName.equalsIgnoreCase( citer->aNativeFormatName ) )
{
@@ -458,7 +463,7 @@ void SAL_CALL CDataFormatTranslator::setStandardFormatIdForNativeFormatName( con
for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( ); citer != citer_end; ++citer )
{
if ( aNativeFormatName.equalsIgnoreCase( citer->aNativeFormatName ) &&
- CF_INVALID != citer->aStandardFormatId )
+ (CF_INVALID != citer->aStandardFormatId) )
{
aAny <<= citer->aStandardFormatId;
break;
@@ -543,18 +548,14 @@ FormatEntry CDataFormatTranslator::mkFormatEntry( const DataFlavor& aDataFlavor,
FormatEntry CDataFormatTranslator::mkPrivateFormatEntry( const OUString& aNativeFormatName, CLIPFORMAT aClipformat, const OUString& aHpName, Type aCppuType )
{
DataFlavor aDFlv;
+ OUString quotedFName = OUString::createFromAscii( "\"" ) + aNativeFormatName + OUString::createFromAscii( "\"" );
if ( aHpName.getLength( ) )
- aDFlv = mkDataFlv( PRIVATE_OO( aNativeFormatName ), aHpName, aCppuType );
+ aDFlv = mkDataFlv( PRIVATE_OO + quotedFName, aHpName, aCppuType );
else
- aDFlv = mkDataFlv( PRIVATE_OO( aNativeFormatName ), aNativeFormatName, aCppuType );
-
- FormatEntry fmtentry;
+ aDFlv = mkDataFlv( PRIVATE_OO + quotedFName, aNativeFormatName, aCppuType );
- if ( CF_INVALID == aClipformat )
- fmtentry = mkFormatEntry( aDFlv, aNativeFormatName, aClipformat );
- else
- fmtentry = mkFormatEntry( aDFlv, EMPTY_OUSTR, aClipformat );
+ FormatEntry fmtentry = mkFormatEntry( aDFlv, aNativeFormatName, aClipformat );
return fmtentry;
}
@@ -566,11 +567,12 @@ FormatEntry CDataFormatTranslator::mkPrivateFormatEntry( const OUString& aNative
FormatEntry CDataFormatTranslator::mkPublicFormatEntry( const OUString& aContentType, const OUString& aNativeFormatName, CLIPFORMAT aClipformat, const OUString& aHpName, Type aCppuType )
{
DataFlavor aDFlv;
+ OUString quotedFName = OUString::createFromAscii( "\"" ) + aNativeFormatName + OUString::createFromAscii( "\"" );
if ( aHpName.getLength( ) )
aDFlv = mkDataFlv( aContentType, aHpName, aCppuType );
else
- aDFlv = mkDataFlv( aContentType, aNativeFormatName, aCppuType );
+ aDFlv = mkDataFlv( aContentType, quotedFName, aCppuType );
return mkFormatEntry( aDFlv, aNativeFormatName, aClipformat );
}