summaryrefslogtreecommitdiffstats
path: root/dtrans/source
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-02 14:46:44 +0000
committerTino Rachui <tra@openoffice.org>2001-03-02 14:46:44 +0000
commitd07363cb70cc14428f687c09a6c53b1b4b793071 (patch)
tree0e17155a66f4cfba287e94f38d320ba7ccc9eeb2 /dtrans/source
parent*** empty log message *** (diff)
downloadcore-d07363cb70cc14428f687c09a6c53b1b4b793071.tar.gz
core-d07363cb70cc14428f687c09a6c53b1b4b793071.zip
*** empty log message ***
Diffstat (limited to 'dtrans/source')
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.cxx198
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.hxx30
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.cxx29
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.hxx10
-rw-r--r--dtrans/source/win32/dtobj/DtObjFactory.cxx6
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx195
-rw-r--r--dtrans/source/win32/dtobj/FetcList.hxx56
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.cxx12
-rw-r--r--dtrans/source/win32/dtobj/makefile.mk5
9 files changed, 250 insertions, 291 deletions
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx
index 9c65b6889831..5c6b5c6eb334 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:45:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -95,6 +95,10 @@
#include "FmtFilter.hxx"
#endif
+#ifndef _FETC_HXX_
+#include "Fetc.hxx"
+#endif
+
#include <olestd.h>
#define STR2(x) #x
@@ -113,18 +117,34 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::datatransfer;
using namespace com::sun::star::io;
using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
-const Type CPPUTYPE_OUSTRING = getCppuType( (OUString*)0 );
+namespace
+{
+ const Type CPPUTYPE_SEQINT8 = getCppuType( ( Sequence< sal_Int8 >* )0 );
+ const Type CPPUTYPE_OUSTRING = getCppuType( (OUString*)0 );
+
+ inline
+ sal_Bool isValidFlavor( const DataFlavor& aFlavor )
+ {
+ return ( aFlavor.MimeType.getLength( ) &&
+ ( ( aFlavor.DataType == CPPUTYPE_SEQINT8 ) ||
+ ( aFlavor.DataType == CPPUTYPE_OUSTRING ) ) );
+ }
+
+} // end namespace
+
//------------------------------------------------------------------------
// ctor
//------------------------------------------------------------------------
-CDOTransferable::CDOTransferable( const Reference< XMultiServiceFactory >& ServiceManager, IDataObjectPtr rDataObject ) :
+CDOTransferable::CDOTransferable(
+ const Reference< XMultiServiceFactory >& ServiceManager, IDataObjectPtr rDataObject ) :
m_rDataObject( rDataObject ),
m_SrvMgr( ServiceManager ),
m_DataFormatTranslator( m_SrvMgr )
@@ -138,10 +158,12 @@ CDOTransferable::CDOTransferable( const Reference< XMultiServiceFactory >& Servi
Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
throw( UnsupportedFlavorException, IOException, RuntimeException )
{
+ OSL_ASSERT( isValidFlavor( aFlavor ) );
+
MutexGuard aGuard( m_aMutex );
- FORMATETC fetc = dataFlavorToFormatEtc( aFlavor );
- OSL_ASSERT( CF_INVALID != fetc.cfFormat );
+ CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor );
+ OSL_ASSERT( CF_INVALID != fetc.getClipformat() );
ByteSequence_t clipDataStream = getClipboardData( fetc );
@@ -155,7 +177,6 @@ Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
Sequence< DataFlavor > SAL_CALL CDOTransferable::getTransferDataFlavors( )
throw( RuntimeException )
{
- MutexGuard aGuard( m_aMutex );
return m_FlavorList;
}
@@ -166,10 +187,10 @@ Sequence< DataFlavor > SAL_CALL CDOTransferable::getTransferDataFlavors( )
sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
throw( RuntimeException )
{
- MutexGuard aGuard( m_aMutex );
+ OSL_ASSERT( isValidFlavor( aFlavor ) );
for ( sal_Int32 i = 0; i < m_FlavorList.getLength( ); i++ )
- if ( aFlavor == m_FlavorList[i] )
+ if ( compareDataFlavors( aFlavor, m_FlavorList[i] ) )
return sal_True;
return sal_False;
@@ -201,12 +222,10 @@ void SAL_CALL CDOTransferable::initFlavorList( )
continue;
DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
-
addSupportedFlavor( aFlavor );
// see MSDN IEnumFORMATETC
- if ( fetc.ptd )
- CoTaskMemFree( fetc.ptd );
+ CoTaskMemFree( fetc.ptd );
}
}
}
@@ -218,9 +237,11 @@ void SAL_CALL CDOTransferable::initFlavorList( )
//inline
void SAL_CALL CDOTransferable::addSupportedFlavor( const DataFlavor& aFlavor )
{
- // we ignore all formats that can't be translated
+ // we ignore all formats that couldn't be translated
if ( aFlavor.MimeType.getLength( ) )
{
+ OSL_ASSERT( isValidFlavor( aFlavor ) );
+
m_FlavorList.realloc( m_FlavorList.getLength( ) + 1 );
m_FlavorList[m_FlavorList.getLength( ) - 1] = aFlavor;
}
@@ -231,7 +252,7 @@ void SAL_CALL CDOTransferable::addSupportedFlavor( const DataFlavor& aFlavor )
//------------------------------------------------------------------------
inline
-FORMATETC SAL_CALL CDOTransferable::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
+CFormatEtc SAL_CALL CDOTransferable::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
{
return m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
}
@@ -247,44 +268,55 @@ DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFo
}
//------------------------------------------------------------------------
-//
+// i think it's not necessary to call ReleaseStgMedium
+// in case of failures because nothing should have been
+// allocated etc.
//------------------------------------------------------------------------
-CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( const FORMATETC& aFormatEtc )
+CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( CFormatEtc& aFormatEtc )
{
STGMEDIUM stgmedium;
- HRESULT hr = m_rDataObject->GetData( &const_cast< FORMATETC& >( aFormatEtc ), &stgmedium );
+ HRESULT hr = m_rDataObject->GetData( aFormatEtc, &stgmedium );
if ( FAILED( hr ) )
{
- /*
- i think it's not necessary to call ReleaseStgMedium
- in case of failures because nothing should have been
- allocated etc.
- */
- OSL_ASSERT( (hr != E_INVALIDARG) || (hr != DV_E_DVASPECT) );
+ OSL_ASSERT( (hr != E_INVALIDARG) &&
+ (hr != DV_E_DVASPECT) &&
+ (hr != DV_E_LINDEX) &&
+ (hr != DV_E_TYMED) &&
+ (hr != DV_E_FORMATETC) );
if ( DV_E_FORMATETC == hr )
throw UnsupportedFlavorException( );
+ else if ( STG_E_MEDIUMFULL == hr )
+ throw IOException( );
else
throw RuntimeException( );
}
ByteSequence_t byteStream;
- sal_Bool bSuccess = clipDataToByteStream( stgmedium, byteStream );
- if ( !bSuccess )
+
+ try
{
- ReleaseStgMedium( &stgmedium );
- throw RuntimeException( );
- }
+ clipDataToByteStream( stgmedium, byteStream );
- // format conversion if necessary
- if ( CF_DIB == aFormatEtc.cfFormat )
- byteStream = WinDIBToOOBMP( byteStream );
- else if ( CF_METAFILEPICT == aFormatEtc.cfFormat )
- byteStream = WinMFPictToOOMFPict( byteStream );
+ // format conversion if necessary
+ if ( CF_DIB == aFormatEtc.getClipformat() )
+ byteStream = WinDIBToOOBMP( byteStream );
+ else if ( CF_METAFILEPICT == aFormatEtc.getClipformat() )
+ byteStream = WinMFPictToOOMFPict( byteStream );
- ReleaseStgMedium( &stgmedium );
+ ReleaseStgMedium( &stgmedium );
+ }
+ catch( CStgTransferException& )
+ {
+ ReleaseStgMedium( &stgmedium );
+ throw IOException( );
+ }
+ catch(...)
+ {
+ OSL_ENSURE( sal_False, "Unexpected error" );
+ }
return byteStream;
}
@@ -293,7 +325,7 @@ CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( const FORMATE
//
//------------------------------------------------------------------------
-sal_Bool CDOTransferable::clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence )
+void CDOTransferable::clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence )
{
CStgTransferHelper memTransferHelper;
@@ -316,14 +348,13 @@ sal_Bool CDOTransferable::clipDataToByteStream( STGMEDIUM stgmedium, ByteSequenc
break;
default:
- OSL_ENSURE( sal_False, "Unsupported tymed" );
- return sal_False;
+ throw UnsupportedFlavorException( );
+ break;
}
int nMemSize = memTransferHelper.memSize( );
aByteSequence.realloc( nMemSize );
-
- return memTransferHelper.read( aByteSequence.getArray( ), nMemSize );
+ memTransferHelper.read( aByteSequence.getArray( ), nMemSize );
}
//------------------------------------------------------------------------
@@ -366,3 +397,92 @@ OUString CDOTransferable::byteStreamToOUString( ByteSequence_t& aByteStream )
return OUString( reinterpret_cast< sal_Unicode* >( aByteStream.getArray( ) ), nWChars );
}
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDOTransferable::compareDataFlavors(
+ const DataFlavor& lhs, const DataFlavor& rhs )
+{
+ if ( !m_rXMimeCntFactory.is( ) )
+ {
+ m_rXMimeCntFactory = Reference< XMimeContentTypeFactory >( m_SrvMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.datatransfer.MimeContentTypeFactory" ) ), UNO_QUERY );
+ }
+ OSL_ASSERT( m_rXMimeCntFactory.is( ) );
+
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ Reference< XMimeContentType > xLhs( m_rXMimeCntFactory->createMimeContentType( lhs.MimeType ) );
+ Reference< XMimeContentType > xRhs( m_rXMimeCntFactory->createMimeContentType( rhs.MimeType ) );
+
+ if ( cmpFullMediaType( xLhs, xRhs ) )
+ {
+ bRet = cmpAllContentTypeParameter( xLhs, xRhs );
+ }
+ }
+ catch( IllegalArgumentException& )
+ {
+ OSL_ENSURE( sal_False, "Invalid content type detected" );
+ bRet = sal_False;
+ }
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDOTransferable::cmpFullMediaType(
+ const Reference< XMimeContentType >& xLhs, const Reference< XMimeContentType >& xRhs ) const
+{
+ return xLhs->getFullMediaType().equalsIgnoreCase( xRhs->getFullMediaType( ) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDOTransferable::cmpAllContentTypeParameter(
+ const Reference< XMimeContentType >& xLhs, const Reference< XMimeContentType >& xRhs ) const
+{
+ Sequence< OUString > xLhsFlavors = xLhs->getParameters( );
+ Sequence< OUString > xRhsFlavors = xRhs->getParameters( );
+ sal_Bool bRet = sal_True;
+
+ try
+ {
+ if ( xLhsFlavors.getLength( ) == xRhsFlavors.getLength( ) )
+ {
+ OUString pLhs;
+ OUString pRhs;
+
+ for ( sal_Int32 i = 0; i < xLhsFlavors.getLength( ); i++ )
+ {
+ pLhs = xLhs->getParameterValue( xLhsFlavors[i] );
+ pRhs = xRhs->getParameterValue( xLhsFlavors[i] );
+
+ if ( !pLhs.equalsIgnoreCase( pRhs ) )
+ {
+ bRet = sal_False;
+ break;
+ }
+ }
+ }
+ else
+ bRet = sal_False;
+ }
+ catch( NoSuchElementException& )
+ {
+ bRet = sal_False;
+ }
+ catch( IllegalArgumentException& )
+ {
+ bRet = sal_False;
+ }
+
+ return bRet;
+} \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/DOTransferable.hxx b/dtrans/source/win32/dtobj/DOTransferable.hxx
index ca7a322ea174..decd239adc29 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:45:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,14 @@
#include "DataFmtTransl.hxx"
#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPEFACTORY_HPP_
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPE_HPP_
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#endif
+
#include <comdef.h>
//------------------------------------------------------------------------
@@ -87,6 +95,7 @@
// forward
class CDTransObjFactory;
+class CFormatEtc;
class CDOTransferable : public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::XTransferable >
{
@@ -119,19 +128,30 @@ private:
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;
+ CFormatEtc SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc );
- ByteSequence_t SAL_CALL getClipboardData( const FORMATETC& aFormatEtc );
- sal_Bool SAL_CALL clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence );
+ ByteSequence_t SAL_CALL getClipboardData( CFormatEtc& aFormatEtc );
+ void SAL_CALL clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence );
+
::com::sun::star::uno::Any SAL_CALL byteStreamToAny( ByteSequence_t& aByteStream, const com::sun::star::uno::Type& aRequestedDataType );
rtl::OUString SAL_CALL byteStreamToOUString( ByteSequence_t& aByteStream );
+ sal_Bool SAL_CALL compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
+ const com::sun::star::datatransfer::DataFlavor& rhs );
+
+ sal_Bool SAL_CALL cmpFullMediaType( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs,
+ const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const;
+
+ sal_Bool SAL_CALL cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs,
+ const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const;
+
private:
IDataObjectPtr m_rDataObject;
com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > m_FlavorList;
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr;
CDataFormatTranslator m_DataFormatTranslator;
+ com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory > m_rXMimeCntFactory;
::osl::Mutex m_aMutex;
// non supported operations
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
index 76e1792b973b..3bdf43477cef 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:45:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,6 +99,10 @@
#include <rtl/string.h>
#endif
+#ifndef _FETC_HXX_
+#include "Fetc.hxx"
+#endif
+
#include <windows.h>
#include <olestd.h>
@@ -139,7 +143,7 @@ CDataFormatTranslator::CDataFormatTranslator( const Reference< XMultiServiceFact
//
//------------------------------------------------------------------------
-FORMATETC CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& aDataFlavor ) const
+CFormatEtc CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& aDataFlavor ) const
{
sal_Int32 cf = CF_INVALID;
@@ -245,27 +249,22 @@ OUString CDataFormatTranslator::getClipboardFormatName( CLIPFORMAT aClipformat )
//
//------------------------------------------------------------------------
-FORMATETC SAL_CALL CDataFormatTranslator::getFormatEtcForClipformat( CLIPFORMAT cf ) const
+CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformat( CLIPFORMAT cf ) const
{
- FORMATETC fetc;
-
- fetc.cfFormat = cf;
- fetc.ptd = NULL;
- fetc.dwAspect = DVASPECT_CONTENT;
- fetc.lindex = -1;
+ CFormatEtc fetc( cf, TYMED_NULL, NULL, DVASPECT_CONTENT );;
switch( cf )
{
case CF_METAFILEPICT:
- fetc.tymed = TYMED_MFPICT;
+ fetc.setTymed( TYMED_MFPICT );
break;
case CF_ENHMETAFILE:
- fetc.tymed = TYMED_ENHMF;
+ fetc.setTymed( TYMED_ENHMF );
break;
default:
- fetc.tymed = TYMED_HGLOBAL | TYMED_ISTREAM;
+ fetc.setTymed( TYMED_HGLOBAL | TYMED_ISTREAM );
}
return fetc;
@@ -306,8 +305,8 @@ OUString SAL_CALL CDataFormatTranslator::getCodePageFromLocaleId( LCID locale, L
LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
const Reference< XTransferable >& refXTransferable ) const
{
- Any aAny;
- FORMATETC fetc = getFormatEtcForClipformat( CF_LOCALE );
+ Any aAny;
+ CFormatEtc fetc = getFormatEtcForClipformat( CF_LOCALE );
DataFlavor aFlavor = getDataFlavorFromFormatEtc( refXTransferable, fetc );
OSL_ASSERT( aFlavor.MimeType.getLength( ) );
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.hxx b/dtrans/source/win32/dtobj/DataFmtTransl.hxx
index f64492627781..50cc5cafbed2 100644
--- a/dtrans/source/win32/dtobj/DataFmtTransl.hxx
+++ b/dtrans/source/win32/dtobj/DataFmtTransl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataFmtTransl.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:51:59 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:45:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,16 +93,18 @@
// declaration
//-----------------------------------------------
+class CFormatEtc;
+
class CDataFormatTranslator
{
public:
CDataFormatTranslator( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& aServiceManager );
- FORMATETC getFormatEtcFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
+ CFormatEtc getFormatEtcFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
com::sun::star::datatransfer::DataFlavor getDataFlavorFromFormatEtc(
const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable, const FORMATETC& aFormatEtc ) const;
- FORMATETC SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const;
+ CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const;
private:
rtl::OUString SAL_CALL getClipboardFormatName( CLIPFORMAT aClipformat ) const;
diff --git a/dtrans/source/win32/dtobj/DtObjFactory.cxx b/dtrans/source/win32/dtobj/DtObjFactory.cxx
index 152b5bcae435..a7528f034cd4 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:45:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,7 +64,7 @@
//------------------------------------------------------------------------
#ifndef _DTOBJFACTORY_HXX_
-#include "DtObjFactory.hxx"
+#include "..\..\inc\DtObjFactory.hxx"
#endif
#ifndef _TWRAPPERDATAOBJECT_HXX_
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index a362f7ed6f52..7d308c3d65a3 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:46:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,6 +71,10 @@
#include "FetcList.hxx"
#endif
+#ifndef _FETC_HXX_
+#include "Fetc.hxx"
+#endif
+
#ifndef _COM_SUN_STAR_DATATRANSFER_XMIMECONTENTTYPEFACTORY_HPP_
#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
#endif
@@ -87,6 +91,8 @@
#include "..\misc\ImplHelper.hxx"
#endif
+#include <algorithm>
+
#include "MimeAttrib.hxx"
//------------------------------------------------------------------------
@@ -112,164 +118,6 @@ sal_uInt32 CFormatRegistrar::m_TxtCodePage = GetACP( );
//
//------------------------------------------------------------------------
-CFormatEtc::CFormatEtc( const FORMATETC& aFormatEtc )
-{
- CopyFormatEtc( &m_FormatEtc, &const_cast< FORMATETC& >( aFormatEtc ) );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CFormatEtc::CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd, DWORD dwAspect, LONG lindex )
-{
- m_FormatEtc.cfFormat = cf;
- m_FormatEtc.ptd = CopyTargetDevice( ptd );
- m_FormatEtc.dwAspect = dwAspect;
- m_FormatEtc.lindex = lindex;
- m_FormatEtc.tymed = tymed;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CFormatEtc::CFormatEtc( const CFormatEtc& theOther )
-{
- m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
- 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;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CFormatEtc::~CFormatEtc( )
-{
- DeleteTargetDevice( m_FormatEtc.ptd );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CFormatEtc& CFormatEtc::operator=( const CFormatEtc& theOther )
-{
- if ( this != &theOther )
- {
- DeleteTargetDevice( m_FormatEtc.ptd );
-
- m_FormatEtc.cfFormat = theOther.m_FormatEtc.cfFormat;
- 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;
- }
-
- return *this;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CFormatEtc::operator FORMATETC*( )
-{
- return &m_FormatEtc;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-void CFormatEtc::getFORMATETC( LPFORMATETC lpFormatEtc )
-{
- OSL_ASSERT( lpFormatEtc );
- OSL_ASSERT( !IsBadWritePtr( lpFormatEtc, sizeof( FORMATETC ) ) );
-
- CopyFormatEtc( lpFormatEtc, &m_FormatEtc );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-CLIPFORMAT CFormatEtc::getClipformat( ) const
-{
- return m_FormatEtc.cfFormat;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-DWORD CFormatEtc::getTymed( ) const
-{
- return m_FormatEtc.tymed;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-void CFormatEtc::getTargetDevice( DVTARGETDEVICE** lpDvTargetDevice ) const
-{
- OSL_ASSERT( lpDvTargetDevice );
- OSL_ASSERT( !IsBadWritePtr( lpDvTargetDevice, sizeof( DVTARGETDEVICE ) ) );
-
- *lpDvTargetDevice = NULL;
-
- if ( m_FormatEtc.ptd )
- *lpDvTargetDevice = CopyTargetDevice( m_FormatEtc.ptd );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-DWORD CFormatEtc::getAspect( ) const
-{
- return m_FormatEtc.dwAspect;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-LONG CFormatEtc::getLindex( ) const
-{
- return m_FormatEtc.lindex;
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs )
-{
- return CompareFormatEtc( &lhs.m_FormatEtc, &rhs.m_FormatEtc );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs )
-{
- return ( ( lhs == rhs ) != 1 );
-}
-
-
-//#########################################################################
-
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
CFormatEtcContainer::CFormatEtcContainer( )
{
m_EnumIterator = m_FormatMap.begin( );
@@ -279,10 +127,9 @@ CFormatEtcContainer::CFormatEtcContainer( )
//
//------------------------------------------------------------------------
-sal_Bool CFormatEtcContainer::addFormatEtc( const FORMATETC& fetc )
+void CFormatEtcContainer::addFormatEtc( const FORMATETC& fetc )
{
- return m_FormatMap.insert(
- make_pair( fetc.cfFormat, CFormatEtc( fetc ) ) ).second;
+ m_FormatMap.push_back( CFormatEtc( fetc ) );
}
//------------------------------------------------------------------------
@@ -291,7 +138,8 @@ sal_Bool CFormatEtcContainer::addFormatEtc( const FORMATETC& fetc )
void SAL_CALL CFormatEtcContainer::removeFormatEtc( const FORMATETC& fetc )
{
- FormatEtcMap_t::iterator iter = m_FormatMap.find( fetc.cfFormat );
+ FormatEtcMap_t::iterator iter =
+ find( m_FormatMap.begin(), m_FormatMap.end(), CFormatEtc( fetc ) );
if ( iter != m_FormatMap.end( ) )
m_FormatMap.erase( iter );
@@ -312,11 +160,12 @@ void SAL_CALL CFormatEtcContainer::removeAllFormatEtc( )
sal_Bool CFormatEtcContainer::hasFormatEtc( const FORMATETC& fetc ) const
{
- FormatEtcMap_t::const_iterator iter = m_FormatMap.find( fetc.cfFormat );
+ FormatEtcMap_t::const_iterator iter =
+ find( m_FormatMap.begin(), m_FormatMap.end(), CFormatEtc( fetc ) );
if ( iter != m_FormatMap.end( ) )
{
- return CFormatEtc( fetc ) == CFormatEtc( iter->second );
+ return ( (CFormatEtc( fetc ) == CFormatEtc( *iter )) == 1 );
}
return sal_False;
@@ -356,7 +205,7 @@ sal_uInt32 SAL_CALL CFormatEtcContainer::nextFormatEtc( LPFORMATETC lpFetc,
{
for ( sal_uInt32 i = 0; i < aNum; i++, nFetched++, lpFetc++, ++m_EnumIterator )
{
- CopyFormatEtc( lpFetc, m_EnumIterator->second );
+ CopyFormatEtc( lpFetc, *m_EnumIterator );
}
}
@@ -370,8 +219,11 @@ sal_uInt32 SAL_CALL CFormatEtcContainer::nextFormatEtc( LPFORMATETC lpFetc,
sal_Bool SAL_CALL CFormatEtcContainer::skipFormatEtc( sal_uInt32 aNum )
{
- for ( sal_uInt32 i = 0; i < aNum; i++, ++m_EnumIterator )
- /* intentionally left empty */;
+ FormatEtcMap_t::const_iterator iter_end = m_FormatMap.end( );
+ for ( sal_uInt32 i = 0;
+ (i < aNum) && (m_EnumIterator != iter_end);
+ i++, ++m_EnumIterator )
+ ;/* intentionally left empty */
return ( m_EnumIterator != m_FormatMap.end( ) );
}
@@ -454,10 +306,7 @@ void SAL_CALL CFormatRegistrar::RegisterFormats( const Sequence< DataFlavor >& a
synthesizeAndRegisterAccompanyFormats( fetc, aFlavor, aFormatEtcContainer );
}
else
- {
- bSuccess = aFormatEtcContainer.addFormatEtc( fetc );
- OSL_ASSERT( bSuccess );
- }
+ aFormatEtcContainer.addFormatEtc( fetc );
}
}
diff --git a/dtrans/source/win32/dtobj/FetcList.hxx b/dtrans/source/win32/dtobj/FetcList.hxx
index c6ed8eef1a85..7f4f696b334a 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:46:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,46 +79,12 @@
#include <com/sun/star/datatransfer/DataFlavor.hpp>
#endif
-#include <windows.h>
-#include <map>
-
-/**********************************************************************
- stl container elements must fulfill the following requirements:
- 1. they need a copy ctor and assignement operator(?)
- 2. they must be compareable
- because the FORMATETC structure has a pointer to a TARGETDEVICE
- structure we need a simple wrapper class to fulfill these needs
-***********************************************************************/
-
-class CFormatEtc
-{
-public:
- CFormatEtc( const FORMATETC& aFormatEtc );
- CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd = NULL, DWORD dwAspect = DVASPECT_CONTENT, LONG lindex = -1 );
- CFormatEtc( const CFormatEtc& theOther );
-
- ~CFormatEtc( );
-
- CFormatEtc& operator=( const CFormatEtc& theOther );
- operator FORMATETC*( );
-
- void getFORMATETC( LPFORMATETC lpFormatEtc );
-
- CLIPFORMAT getClipformat( ) const;
- DWORD getTymed( ) const;
- void getTargetDevice( DVTARGETDEVICE** ptd ) const;
- DWORD getAspect( ) const;
- LONG getLindex( ) const;
-
-private:
- FORMATETC m_FormatEtc;
-
- friend sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs );
- friend sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
-};
+#ifndef _FETC_HXX_
+#include "Fetc.hxx"
+#endif
-sal_Int32 operator==( CFormatEtc& lhs, CFormatEtc& rhs );
-sal_Int32 operator!=( CFormatEtc& lhs, CFormatEtc& rhs );
+#include <windows.h>
+#include <vector>
/*****************************************************************
a simple container for FORMATECT structures
@@ -131,7 +97,7 @@ public:
CFormatEtcContainer( );
// duplicates not allowed
- sal_Bool SAL_CALL addFormatEtc( const FORMATETC& fetc );
+ void SAL_CALL addFormatEtc( const FORMATETC& fetc );
// removes the specified formatetc
void SAL_CALL removeFormatEtc( const FORMATETC& fetc );
@@ -156,16 +122,12 @@ public:
sal_Bool SAL_CALL skipFormatEtc( sal_uInt32 aNum );
protected:
- typedef std::map< CLIPFORMAT, CFormatEtc > FormatEtcMap_t;
+ typedef std::vector< CFormatEtc > FormatEtcMap_t;
private:
sal_uInt32 m_nCurrentEnumPos;
FormatEtcMap_t m_FormatMap;
FormatEtcMap_t::iterator m_EnumIterator;
-
-private:
- //CFormatEtcContainer( const CFormatEtcContainer& );
- //CFormatEtcContainer& operator=( const CFormatEtcContainer& );
};
/*****************************************************************
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index c2acd7ccebfb..de9c43f94814 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.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 06:57:52 $
+ * last change: $Author: tra $ $Date: 2001-03-02 15:46:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -286,7 +286,13 @@ void SAL_CALL CXTDataObject::transferDataToStorageAndSetupStgMedium(
stgTransfHelper.init(
nInitStgSize, GMEM_MOVEABLE | GMEM_ZEROINIT, sal_False, bShouldReleaseStream );
+#ifndef _DEBUG
stgTransfHelper.write( lpStorage, nBytesToTransfer );
+#else
+ sal_uInt32 nBytesWritten = 0;
+ stgTransfHelper.write( lpStorage, nBytesToTransfer, &nBytesWritten );
+ OSL_ASSERT( nBytesWritten == nBytesToTransfer );
+#endif
setupStgMedium( fetc, stgTransfHelper, stgmedium );
}
@@ -329,7 +335,7 @@ void SAL_CALL CXTDataObject::transferUnicodeToClipbAndSetupStgMedium(
sal_uInt32 nBytesToTransfer = aText.getLength( ) * sizeof( sal_Unicode );
// to be sure there is an ending 0
- sal_uInt32 nRequiredMemSize = nBytesToTransfer + 1;
+ sal_uInt32 nRequiredMemSize = nBytesToTransfer + sizeof( sal_Unicode );
transferDataToStorageAndSetupStgMedium(
reinterpret_cast< const sal_Int8* >( aText.getStr( ) ),
diff --git a/dtrans/source/win32/dtobj/makefile.mk b/dtrans/source/win32/dtobj/makefile.mk
index 0bb49c03ed37..34de17364176 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.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+# last change: $Author: tra $ $Date: 2001-03-02 15:46:44 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -86,6 +86,7 @@ SLOFILES=$(SLO)$/DtObjFactory.obj\
$(SLO)$/DataFmtTransl.obj\
$(SLO)$/FmtFilter.obj\
$(SLO)$/FetcList.obj\
+ $(SLO)$/Fetc.obj\
$(SLO)$/WrpDOTransferable.obj
LIB1TARGET=$(SLB)$/$(TARGET).lib