summaryrefslogtreecommitdiff
path: root/dtrans
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-05 05:36:35 +0000
committerTino Rachui <tra@openoffice.org>2001-03-05 05:36:35 +0000
commit9d7ab58ff9df4485455a9c8268aa8e963032b4b8 (patch)
tree21edc4600ed19cb26627f5e8add938da75af527d /dtrans
parentd68448d79d2a8aa6a0986f3f8437546ef282a19d (diff)
*** empty log message ***
Diffstat (limited to 'dtrans')
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.cxx23
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.cxx65
-rw-r--r--dtrans/source/win32/dtobj/DTransHelper.hxx55
-rw-r--r--dtrans/source/win32/dtobj/Fetc.hxx6
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx40
-rw-r--r--dtrans/source/win32/dtobj/FetcList.hxx19
-rw-r--r--dtrans/source/win32/dtobj/FmtFilter.cxx137
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.cxx42
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.hxx11
9 files changed, 207 insertions, 191 deletions
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx
index 5c6b5c6eb334..94010c1a9327 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.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:45:14 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:34:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -118,6 +118,7 @@ using namespace com::sun::star::datatransfer;
using namespace com::sun::star::io;
using namespace com::sun::star::lang;
using namespace com::sun::star::container;
+using CStgTransferHelper::CStgTransferException;
//------------------------------------------------------------------------
//
@@ -162,11 +163,23 @@ Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
MutexGuard aGuard( m_aMutex );
+ //------------------------------------------------
+ // convert dataflavor to formatetc
+ //------------------------------------------------
+
CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor );
OSL_ASSERT( CF_INVALID != fetc.getClipformat() );
+ //------------------------------------------------
+ // get the data from clipboard in a byte stream
+ //------------------------------------------------
+
ByteSequence_t clipDataStream = getClipboardData( fetc );
+ //------------------------------------------------
+ // return the data as any
+ //------------------------------------------------
+
return byteStreamToAny( clipDataStream, aFlavor.DataType );
}
@@ -182,6 +195,8 @@ Sequence< DataFlavor > SAL_CALL CDOTransferable::getTransferDataFlavors( )
//------------------------------------------------------------------------
// isDataFlavorSupported
+// returns true if we find a DataFlavor with the same MimeType and
+// DataType
//------------------------------------------------------------------------
sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFlavor )
@@ -313,10 +328,6 @@ CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( CFormatEtc& a
ReleaseStgMedium( &stgmedium );
throw IOException( );
}
- catch(...)
- {
- OSL_ENSURE( sal_False, "Unexpected error" );
- }
return byteStream;
}
diff --git a/dtrans/source/win32/dtobj/DTransHelper.cxx b/dtrans/source/win32/dtobj/DTransHelper.cxx
index 500be1918ee0..7aa530a9f7c8 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:35:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,16 +77,16 @@
CStgTransferHelper::CStgTransferHelper( sal_Bool bAutoInit,
HGLOBAL hGlob,
- sal_Bool bDeleteStorageOnRelease,
- sal_Bool bReleaseStreamOnDestruction ) :
+ sal_Bool bDelStgOnRelease,
+ sal_Bool bReleaseStreamOnDestr ) :
m_lpStream( NULL ),
- m_bDelStgOnRelease( bDeleteStorageOnRelease ),
- m_bReleaseStreamOnDestr( bReleaseStreamOnDestruction )
+ m_bDelStgOnRelease( bDelStgOnRelease ),
+ m_bReleaseStreamOnDestr( bReleaseStreamOnDestr )
{
- OSL_ASSERT( !(bDeleteStorageOnRelease && !bReleaseStreamOnDestruction) );
+ OSL_ASSERT( !(bDelStgOnRelease && !bReleaseStreamOnDestr) );
if ( bAutoInit )
- init( hGlob, bDeleteStorageOnRelease, bReleaseStreamOnDestruction );
+ init( hGlob, m_bDelStgOnRelease, m_bReleaseStreamOnDestr );
}
//------------------------------------------------------------------------
@@ -104,7 +104,7 @@ CStgTransferHelper::~CStgTransferHelper( )
// TransferData into the
//------------------------------------------------------------------------
-sal_Bool SAL_CALL CStgTransferHelper::write( const void* lpData, ULONG cb, ULONG* cbWritten )
+void SAL_CALL CStgTransferHelper::write( const void* lpData, ULONG cb, ULONG* cbWritten )
{
HRESULT hr = E_FAIL;
@@ -113,15 +113,13 @@ sal_Bool SAL_CALL CStgTransferHelper::write( const void* lpData, ULONG cb, ULONG
if ( FAILED( hr ) )
throw CStgTransferException( hr );
-
- return SUCCEEDED( hr );
}
//------------------------------------------------------------------------
// read
//------------------------------------------------------------------------
-sal_Bool SAL_CALL CStgTransferHelper::read( LPVOID pv, ULONG cb, ULONG* pcbRead )
+void SAL_CALL CStgTransferHelper::read( LPVOID pv, ULONG cb, ULONG* pcbRead )
{
HRESULT hr = E_FAIL;
@@ -130,8 +128,6 @@ sal_Bool SAL_CALL CStgTransferHelper::read( LPVOID pv, ULONG cb, ULONG* pcbRead
if ( FAILED( hr ) )
throw CStgTransferException( hr );
-
- return SUCCEEDED( hr );
}
//------------------------------------------------------------------------
@@ -168,45 +164,46 @@ void SAL_CALL CStgTransferHelper::getIStream( LPSTREAM* ppStream )
// Init
//------------------------------------------------------------------------
-sal_Bool SAL_CALL CStgTransferHelper::init( SIZE_T newSize,
- UINT uiFlags,
- sal_Bool bDeleteStorageOnRelease,
- sal_Bool bReleaseStreamOnDestruction )
+void SAL_CALL CStgTransferHelper::init( SIZE_T newSize,
+ sal_uInt32 uiFlags,
+ sal_Bool bDelStgOnRelease,
+ sal_Bool bReleaseStreamOnDestr )
{
- OSL_ASSERT( !(bDeleteStorageOnRelease && !bReleaseStreamOnDestruction) );
+ OSL_ASSERT( !(bDelStgOnRelease && !bReleaseStreamOnDestr) );
cleanup( );
+
+ m_bDelStgOnRelease = bDelStgOnRelease;
+ m_bReleaseStreamOnDestr = bReleaseStreamOnDestr;
+
HGLOBAL hGlob = GlobalAlloc( uiFlags, newSize );
if ( NULL == hGlob )
throw CStgTransferException( STG_E_MEDIUMFULL );
- HRESULT hr = CreateStreamOnHGlobal( hGlob, bDeleteStorageOnRelease, &m_lpStream );
-
- m_bDelStgOnRelease = bDeleteStorageOnRelease;
- m_bReleaseStreamOnDestr = bReleaseStreamOnDestruction;
+ HRESULT hr = CreateStreamOnHGlobal( hGlob, m_bDelStgOnRelease, &m_lpStream );
- return SUCCEEDED( hr );
+ if ( FAILED( hr ) )
+ throw CStgTransferException( hr );
}
//------------------------------------------------------------------------
// Init
//------------------------------------------------------------------------
-sal_Bool SAL_CALL CStgTransferHelper::init( HGLOBAL hGlob,
- sal_Bool bDeleteStorageOnRelease,
- sal_Bool bReleaseStreamOnDestruction )
+void SAL_CALL CStgTransferHelper::init( HGLOBAL hGlob,
+ sal_Bool bDelStgOnRelease,
+ sal_Bool bReleaseStreamOnDestr )
{
- OSL_ASSERT( !(bDeleteStorageOnRelease && !bReleaseStreamOnDestruction) );
+ OSL_ASSERT( !(bDelStgOnRelease && !bReleaseStreamOnDestr) );
cleanup( );
- HRESULT hr = CreateStreamOnHGlobal( hGlob, bDeleteStorageOnRelease, &m_lpStream );
- if ( hr == E_OUTOFMEMORY )
- throw CStgTransferException( STG_E_MEDIUMFULL );
- m_bDelStgOnRelease = bDeleteStorageOnRelease;
- m_bReleaseStreamOnDestr = bReleaseStreamOnDestruction;
+ m_bDelStgOnRelease = bDelStgOnRelease;
+ m_bReleaseStreamOnDestr = bReleaseStreamOnDestr;
- return SUCCEEDED( hr );
+ HRESULT hr = CreateStreamOnHGlobal( hGlob, m_bDelStgOnRelease, &m_lpStream );
+ if ( FAILED( hr ) )
+ throw CStgTransferException( hr );
}
//------------------------------------------------------------------------
diff --git a/dtrans/source/win32/dtobj/DTransHelper.hxx b/dtrans/source/win32/dtobj/DTransHelper.hxx
index 43283d3d8e5d..19193c9fccd0 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:35:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,13 +82,6 @@
// deklarations
//------------------------------------------------------------------------
-// will be thrown in case of failures
-class CStgTransferException
-{
-public:
- HRESULT m_hr;
- CStgTransferException( HRESULT hr ) : m_hr( hr ) {};
-};
//-------------------------------------------------------------------------
// a helper class to manage a global memory area, the clients can write
@@ -99,27 +92,39 @@ public:
class CStgTransferHelper
{
public:
- CStgTransferHelper( sal_Bool bAutoInit = sal_False,
- HGLOBAL hGlob = NULL,
- sal_Bool bDeleteStorageOnRelease = sal_False,
- sal_Bool bReleaseStreamOnDestruction = sal_True );
+ // will be thrown in case of failures
+ class CStgTransferException
+ {
+ public:
+ HRESULT m_hr;
+ CStgTransferException( HRESULT hr ) : m_hr( hr ) {};
+ };
+
+public:
+ CStgTransferHelper(
+ sal_Bool bAutoInit = sal_False,
+ HGLOBAL hGlob = NULL,
+ sal_Bool bDelStgOnRelease = sal_False,
+ sal_Bool bReleaseStreamOnDestr = sal_True );
~CStgTransferHelper( );
- sal_Bool SAL_CALL write( const void* lpData, ULONG cb, ULONG* cbWritten = NULL );
- sal_Bool SAL_CALL read( LPVOID pv, ULONG cb, ULONG* pcbRead = NULL );
+ void SAL_CALL write( const void* lpData, ULONG cb, ULONG* cbWritten = NULL );
+ void SAL_CALL read( LPVOID pv, ULONG cb, ULONG* pcbRead = NULL );
HGLOBAL SAL_CALL getHGlobal( ) const;
- void SAL_CALL getIStream( LPSTREAM* ppStream );
-
- sal_Bool SAL_CALL init( SIZE_T newSize,
- UINT uiFlags = GMEM_MOVEABLE | GMEM_ZEROINIT,
- sal_Bool bDeleteStorageOnRelease = sal_False,
- sal_Bool bReleasStreamOnDestruction = sal_True );
-
- sal_Bool SAL_CALL init( HGLOBAL hGlob,
- sal_Bool bDeleteStorageOnRelease = sal_False,
- sal_Bool bReleaseStreamOnDestruction = sal_True );
+ void SAL_CALL getIStream( LPSTREAM* ppStream );
+
+ void SAL_CALL init(
+ SIZE_T newSize,
+ sal_uInt32 uiFlags = GMEM_MOVEABLE | GMEM_ZEROINIT,
+ sal_Bool bDelStgOnRelease = sal_False,
+ sal_Bool bReleasStreamOnDestr = sal_True );
+
+ void SAL_CALL init(
+ HGLOBAL hGlob,
+ sal_Bool bDelStgOnRelease = sal_False,
+ sal_Bool bReleaseStreamOnDestr = sal_True );
// returns the size of the managed memory
sal_uInt32 SAL_CALL memSize( ) const;
diff --git a/dtrans/source/win32/dtobj/Fetc.hxx b/dtrans/source/win32/dtobj/Fetc.hxx
index 0d5a90ad3f6b..ecd9abea5302 100644
--- a/dtrans/source/win32/dtobj/Fetc.hxx
+++ b/dtrans/source/win32/dtobj/Fetc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Fetc.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 14:30:54 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:35:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,7 @@ class CFormatEtc
{
public:
CFormatEtc( );
- explicit CFormatEtc( const FORMATETC& aFormatEtc );
+ CFormatEtc( const FORMATETC& aFormatEtc );
CFormatEtc( CLIPFORMAT cf, DWORD tymed, DVTARGETDEVICE* ptd = NULL, DWORD dwAspect = DVASPECT_CONTENT, LONG lindex = -1 );
CFormatEtc( const CFormatEtc& theOther );
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index 7d308c3d65a3..63bbf0c6a9da 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.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:46:11 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:36:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -127,7 +127,7 @@ CFormatEtcContainer::CFormatEtcContainer( )
//
//------------------------------------------------------------------------
-void CFormatEtcContainer::addFormatEtc( const FORMATETC& fetc )
+void CFormatEtcContainer::addFormatEtc( const CFormatEtc& fetc )
{
m_FormatMap.push_back( CFormatEtc( fetc ) );
}
@@ -136,10 +136,10 @@ void CFormatEtcContainer::addFormatEtc( const FORMATETC& fetc )
//
//------------------------------------------------------------------------
-void SAL_CALL CFormatEtcContainer::removeFormatEtc( const FORMATETC& fetc )
+void SAL_CALL CFormatEtcContainer::removeFormatEtc( const CFormatEtc& fetc )
{
FormatEtcMap_t::iterator iter =
- find( m_FormatMap.begin(), m_FormatMap.end(), CFormatEtc( fetc ) );
+ find( m_FormatMap.begin(), m_FormatMap.end(), fetc );
if ( iter != m_FormatMap.end( ) )
m_FormatMap.erase( iter );
@@ -158,14 +158,14 @@ void SAL_CALL CFormatEtcContainer::removeAllFormatEtc( )
//
//------------------------------------------------------------------------
-sal_Bool CFormatEtcContainer::hasFormatEtc( const FORMATETC& fetc ) const
+sal_Bool CFormatEtcContainer::hasFormatEtc( const CFormatEtc& fetc ) const
{
FormatEtcMap_t::const_iterator iter =
- find( m_FormatMap.begin(), m_FormatMap.end(), CFormatEtc( fetc ) );
+ find( m_FormatMap.begin(), m_FormatMap.end(), fetc );
if ( iter != m_FormatMap.end( ) )
{
- return ( (CFormatEtc( fetc ) == CFormatEtc( *iter )) == 1 );
+ return ( ( fetc == CFormatEtc( *iter )) == 1 );
}
return sal_False;
@@ -274,20 +274,20 @@ void SAL_CALL CFormatRegistrar::RegisterFormats( const Sequence< DataFlavor >& a
for( sal_Int32 i = 0; i < nFlavors; i++ )
{
aFlavor = aFlavorList[i];
- FORMATETC fetc = dataFlavorToFormatEtc( aFlavor );
+ CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor );
if ( needsToSynthesizeAccompanyFormats( fetc ) )
{
#ifdef _DEBUG
- FORMATETC fetcdbg;
+ CFormatEtc fetcdbg;
- if ( fetc.cfFormat == CF_TEXT )
+ if ( fetc.getClipformat() == CF_TEXT )
{
fetcdbg = getFormatEtcForClipformat( CF_OEMTEXT );
OSL_ASSERT( !aFormatEtcContainer.hasFormatEtc( fetcdbg ) );
}
- else if ( fetc.cfFormat == CF_OEMTEXT )
+ else if ( fetc.getClipformat() == CF_OEMTEXT )
{
fetcdbg = getFormatEtcForClipformat( CF_TEXT );
OSL_ASSERT( !aFormatEtcContainer.hasFormatEtc( fetcdbg ) );
@@ -363,7 +363,7 @@ sal_Bool SAL_CALL CFormatRegistrar::isTextFormat( CLIPFORMAT cf ) const
//
//------------------------------------------------------------------------
-FORMATETC SAL_CALL CFormatRegistrar::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
+CFormatEtc SAL_CALL CFormatRegistrar::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
{
return m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
}
@@ -373,10 +373,10 @@ FORMATETC SAL_CALL CFormatRegistrar::dataFlavorToFormatEtc( const DataFlavor& aF
//------------------------------------------------------------------------
inline
-sal_Bool SAL_CALL CFormatRegistrar::needsToSynthesizeAccompanyFormats( const FORMATETC& aFormatEtc ) const
+sal_Bool SAL_CALL CFormatRegistrar::needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const
{
- return ( isOemOrAnsiTextFormat( aFormatEtc.cfFormat ) ||
- isUnicodeTextFormat( aFormatEtc.cfFormat ) );
+ return ( isOemOrAnsiTextFormat( aFormatEtc.getClipformat() ) ||
+ isUnicodeTextFormat( aFormatEtc.getClipformat() ) );
}
//------------------------------------------------------------------------
@@ -384,12 +384,12 @@ sal_Bool SAL_CALL CFormatRegistrar::needsToSynthesizeAccompanyFormats( const FOR
//------------------------------------------------------------------------
void SAL_CALL CFormatRegistrar::synthesizeAndRegisterAccompanyFormats(
- FORMATETC& aFormatEtc, const DataFlavor& aFlavor, CFormatEtcContainer& aFormatEtcContainer )
+ CFormatEtc& aFormatEtc, const DataFlavor& aFlavor, CFormatEtcContainer& aFormatEtcContainer )
{
- CLIPFORMAT cf = aFormatEtc.cfFormat;
+ CLIPFORMAT cf = aFormatEtc.getClipformat();
OSL_ASSERT( isOemOrAnsiTextFormat(cf) || isUnicodeTextFormat(cf) );
- FORMATETC fetc;
+ CFormatEtc fetc;
if ( isOemOrAnsiTextFormat( cf ) )
{
@@ -464,7 +464,7 @@ OUString SAL_CALL CFormatRegistrar::getCharsetFromDataFlavor( const DataFlavor&
//------------------------------------------------------------------------
inline
-FORMATETC SAL_CALL CFormatRegistrar::getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const
+CFormatEtc SAL_CALL CFormatRegistrar::getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const
{
return m_DataFormatTranslator.getFormatEtcForClipformat( aClipformat );
}
diff --git a/dtrans/source/win32/dtobj/FetcList.hxx b/dtrans/source/win32/dtobj/FetcList.hxx
index 7f4f696b334a..c4b33ddbbec9 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.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:46:11 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:36:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,15 +97,15 @@ public:
CFormatEtcContainer( );
// duplicates not allowed
- void SAL_CALL addFormatEtc( const FORMATETC& fetc );
+ void SAL_CALL addFormatEtc( const CFormatEtc& fetc );
// removes the specified formatetc
- void SAL_CALL removeFormatEtc( const FORMATETC& fetc );
+ void SAL_CALL removeFormatEtc( const CFormatEtc& fetc );
// removes the formatetc at pos
void SAL_CALL removeAllFormatEtc( );
- sal_Bool SAL_CALL hasFormatEtc( const FORMATETC& fetc ) const;
+ sal_Bool SAL_CALL hasFormatEtc( const CFormatEtc& fetc ) const;
sal_Bool SAL_CALL hasElements( ) const;
@@ -125,7 +125,6 @@ protected:
typedef std::vector< CFormatEtc > FormatEtcMap_t;
private:
- sal_uInt32 m_nCurrentEnumPos;
FormatEtcMap_t m_FormatMap;
FormatEtcMap_t::iterator m_EnumIterator;
};
@@ -162,14 +161,14 @@ private:
sal_Bool SAL_CALL isOemOrAnsiTextFormat( CLIPFORMAT cf ) const;
sal_Bool SAL_CALL isUnicodeTextFormat( CLIPFORMAT cf ) const;
sal_Bool SAL_CALL isTextFormat( CLIPFORMAT cf ) const;
- FORMATETC SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
- sal_Bool SAL_CALL needsToSynthesizeAccompanyFormats( const FORMATETC& aFormatEtc ) const;
- void SAL_CALL synthesizeAndRegisterAccompanyFormats( FORMATETC& aFormatEtc,
+ CFormatEtc SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
+ sal_Bool SAL_CALL needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const;
+ void SAL_CALL synthesizeAndRegisterAccompanyFormats( CFormatEtc& aFormatEtc,
const com::sun::star::datatransfer::DataFlavor& aFlavor,
CFormatEtcContainer& aFormatEtcContainer );
sal_Bool SAL_CALL isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const;
rtl::OUString SAL_CALL getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
- FORMATETC SAL_CALL getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const;
+ CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const;
void SAL_CALL FindLocaleForTextCodePage( );
diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx
index 44ce10ed5a5d..0c9c875a682e 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:36:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,68 +99,69 @@ struct METAFILEHEADER
Sequence< sal_Int8 > SAL_CALL WinMFPictToOOMFPict( Sequence< sal_Int8 >& aMetaFilePict )
{
- OSL_ASSERT( aMetaFilePict.getLength( ) );
+ OSL_ASSERT( aMetaFilePict.getLength( ) == sizeof( METAFILEPICT ) );
+ Sequence< sal_Int8 > mfpictStream;
METAFILEPICT* pMFPict = reinterpret_cast< METAFILEPICT* >( aMetaFilePict.getArray( ) );
-
- OSL_ASSERT( pMFPict );
- OSL_ASSERT( !IsBadReadPtr( pMFPict, sizeof( METAFILEPICT ) ) );
-
HMETAFILE hMf = pMFPict->hMF;
sal_uInt32 nCount = GetMetaFileBitsEx( hMf, 0, NULL );
- Sequence< sal_Int8 > mfpictStream( nCount + sizeof( METAFILEHEADER ) );
-
- METAFILEHEADER* pMFHeader = (METAFILEHEADER*)mfpictStream.getArray( );
- SMALL_RECT aRect = { 0,
- 0,
- static_cast< short >( pMFPict->xExt ),
- static_cast< short >( pMFPict->yExt ) };
- USHORT nInch;
- switch( pMFPict->mm )
+ if ( nCount > 0 )
{
- case MM_TEXT:
- nInch = 72;
- break;
-
- case MM_LOMETRIC:
- nInch = 100;
- break;
-
- case MM_HIMETRIC:
- nInch = 1000;
- break;
-
- case MM_LOENGLISH:
- nInch = 254;
- break;
-
- case MM_HIENGLISH:
- case MM_ISOTROPIC:
- case MM_ANISOTROPIC:
- nInch = 2540;
- break;
-
- case MM_TWIPS:
- nInch = 1440;
- break;
-
- default:
- nInch = 576;
+ mfpictStream.realloc( nCount + sizeof( METAFILEHEADER ) );
+
+ METAFILEHEADER* pMFHeader = reinterpret_cast< METAFILEHEADER* >( mfpictStream.getArray( ) );
+ SMALL_RECT aRect = { 0,
+ 0,
+ static_cast< short >( pMFPict->xExt ),
+ static_cast< short >( pMFPict->yExt ) };
+ USHORT nInch;
+
+ switch( pMFPict->mm )
+ {
+ case MM_TEXT:
+ nInch = 72;
+ break;
+
+ case MM_LOMETRIC:
+ nInch = 100;
+ break;
+
+ case MM_HIMETRIC:
+ nInch = 1000;
+ break;
+
+ case MM_LOENGLISH:
+ nInch = 254;
+ break;
+
+ case MM_HIENGLISH:
+ case MM_ISOTROPIC:
+ case MM_ANISOTROPIC:
+ nInch = 2540;
+ break;
+
+ case MM_TWIPS:
+ nInch = 1440;
+ break;
+
+ default:
+ nInch = 576;
+ }
+
+ pMFHeader->key = 0x9AC6CDD7L;
+ pMFHeader->hmf = 0;
+ pMFHeader->bbox = aRect;
+ pMFHeader->inch = nInch;
+ pMFHeader->reserved = 0;
+ pMFHeader->checksum = 0;
+
+ char* pMFBuff = reinterpret_cast< char* >( mfpictStream.getArray( ) );
+
+ nCount = GetMetaFileBitsEx( pMFPict->hMF, nCount, pMFBuff + sizeof( METAFILEHEADER ) );
+ OSL_ASSERT( nCount > 0 );
}
- pMFHeader->key = 0x9AC6CDD7L;
- pMFHeader->hmf = 0;
- pMFHeader->bbox = aRect;
- pMFHeader->inch = nInch;
- pMFHeader->reserved = 0;
- pMFHeader->checksum = 0;
-
- char* pMFBuff = reinterpret_cast< char* >( mfpictStream.getArray( ) );
-
- nCount = GetMetaFileBitsEx( pMFPict->hMF, nCount, pMFBuff + sizeof( METAFILEHEADER ) );
- OSL_ASSERT( nCount );
-
return mfpictStream;
}
@@ -170,10 +171,11 @@ Sequence< sal_Int8 > SAL_CALL WinMFPictToOOMFPict( Sequence< sal_Int8 >& aMetaFi
HMETAFILE SAL_CALL OOMFPictToWinMFPict( Sequence< sal_Int8 >& aOOMetaFilePict )
{
- OSL_ASSERT( aOOMetaFilePict.getLength( ) );
+ OSL_ASSERT( aOOMetaFilePict.getLength( ) > sizeof( METAFILEHEADER ) );
- return SetMetaFileBitsEx( aOOMetaFilePict.getLength( ) - sizeof( METAFILEHEADER ),
- reinterpret_cast< BYTE* >( aOOMetaFilePict.getArray( ) ) + sizeof( METAFILEHEADER ) );
+ return SetMetaFileBitsEx(
+ aOOMetaFilePict.getLength( ) - sizeof( METAFILEHEADER ),
+ reinterpret_cast< BYTE* >( aOOMetaFilePict.getArray( ) ) + sizeof( METAFILEHEADER ) );
}
//------------------------------------------------------------------------
@@ -182,10 +184,14 @@ HMETAFILE SAL_CALL OOMFPictToWinMFPict( Sequence< sal_Int8 >& aOOMetaFilePict )
Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const Sequence< sal_Int8 >& aWinDIB )
{
- Sequence< sal_Int8 > ooBmpStream( aWinDIB.getLength( ) + sizeof(BITMAPFILEHEADER) );
+ OSL_ASSERT( aWinDIB.getLength( ) > sizeof( BITMAPINFOHEADER ) );
+
+ Sequence< sal_Int8 > ooBmpStream;
+
+ ooBmpStream.realloc( aWinDIB.getLength( ) + sizeof(BITMAPFILEHEADER) );
const BITMAPINFOHEADER *pBmpInfoHdr = (const BITMAPINFOHEADER*)aWinDIB.getConstArray();
- BITMAPFILEHEADER *pBmpFileHdr = (BITMAPFILEHEADER*)ooBmpStream.getArray();
+ BITMAPFILEHEADER *pBmpFileHdr = reinterpret_cast< BITMAPFILEHEADER* >( ooBmpStream.getArray() );
DWORD nOffset = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER );
rtl_copyMemory( pBmpFileHdr + 1, pBmpInfoHdr, aWinDIB.getLength( ) );
@@ -208,11 +214,14 @@ Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const Sequence< sal_Int8 >& aWinDIB
Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( Sequence< sal_Int8 >& aOOBmp )
{
- Sequence< sal_Int8 > winDIBStream( aOOBmp.getLength( ) - sizeof(BITMAPFILEHEADER) );
+ OSL_ASSERT( aOOBmp.getLength( ) >
+ ( sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) ) );
+
+ Sequence< sal_Int8 > winDIBStream( aOOBmp.getLength( ) - sizeof( BITMAPFILEHEADER ) );
rtl_copyMemory( winDIBStream.getArray( ),
- aOOBmp.getArray( ) + sizeof(BITMAPFILEHEADER),
- aOOBmp.getLength( ) - sizeof(BITMAPFILEHEADER) );
+ aOOBmp.getArray( ) + sizeof( BITMAPFILEHEADER ),
+ aOOBmp.getLength( ) - sizeof( BITMAPFILEHEADER ) );
return winDIBStream;
} \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index 6a9eff4840c4..cfcdb61c63dd 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.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 17:40:28 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:36:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -107,6 +107,7 @@ using namespace com::sun::star::datatransfer::clipboard;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace rtl;
+using CStgTransferHelper::CStgTransferException;
//------------------------------------------------------------------------
// a helper class that will be thrown by the function validateFormatEtc
@@ -393,19 +394,27 @@ void SAL_CALL CXTDataObject::transferAnyDataToClipbAndSetupStgMedium(
STDMETHODIMP CXTDataObject::EnumFormatEtc(
DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
{
- if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
+ if ( NULL == ppenumFormatetc )
return E_INVALIDARG;
+ if ( DATADIR_SET == dwDirection )
+ return E_NOTIMPL;
+
*ppenumFormatetc = NULL;
+ HRESULT hr;
if ( DATADIR_GET == dwDirection )
{
*ppenumFormatetc = new CEnumFormatEtc( this, m_FormatEtcContainer );
if ( NULL != *ppenumFormatetc )
static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
+
+ hr = ( NULL != *ppenumFormatetc ) ? S_OK : E_OUTOFMEMORY;
}
+ else
+ hr = E_INVALIDARG;
- return ( NULL != *ppenumFormatetc ) ? S_OK : E_OUTOFMEMORY;
+ return hr;
}
//------------------------------------------------------------------------
@@ -414,12 +423,10 @@ STDMETHODIMP CXTDataObject::EnumFormatEtc(
STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
{
- HRESULT hr = E_INVALIDARG;
-
- if ( NULL != pFormatetc )
- hr = m_FormatEtcContainer.hasFormatEtc( *pFormatetc ) ? S_OK : S_FALSE;
+ if ( (NULL == pFormatetc) || IsBadReadPtr( pFormatetc, sizeof( FORMATETC ) ) )
+ return E_INVALIDARG;
- return hr;
+ return m_FormatEtcContainer.hasFormatEtc( *pFormatetc ) ? S_OK : S_FALSE;
}
//------------------------------------------------------------------------
@@ -714,16 +721,17 @@ STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
STDMETHODIMP CEnumFormatEtc::Next( ULONG nRequested, LPFORMATETC lpDest, ULONG* lpFetched )
{
- if ( (( 0 != nRequested ) && ( NULL == lpDest )) ||
+ if ( ( nRequested < 1 ) ||
+ (( nRequested > 1 ) && ( NULL == lpFetched )) ||
IsBadWritePtr( lpDest, sizeof( FORMATETC ) * nRequested ) )
return E_INVALIDARG;
sal_uInt32 nFetched = m_FormatEtcContainer.nextFormatEtc( lpDest, nRequested );
- if ( lpFetched )
+ if ( NULL != lpFetched )
*lpFetched = nFetched;
- return nFetched == nRequested ? S_OK : S_FALSE;
+ return (nFetched == nRequested) ? S_OK : S_FALSE;
}
//----------------------------------------------------------------------------
@@ -754,15 +762,9 @@ STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
if ( NULL == ppenum )
return E_INVALIDARG;
- *ppenum = NULL;
-
- CEnumFormatEtc* pCEnumFEtc =
- new CEnumFormatEtc( m_lpUnkOuter, m_FormatEtcContainer );
- if ( NULL != pCEnumFEtc )
- {
- *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
+ *ppenum = new CEnumFormatEtc( m_lpUnkOuter, m_FormatEtcContainer );
+ if ( NULL != ppenum )
static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
- }
return ( NULL != *ppenum ) ? S_OK : E_OUTOFMEMORY;
}
diff --git a/dtrans/source/win32/dtobj/XTDataObject.hxx b/dtrans/source/win32/dtobj/XTDataObject.hxx
index 541d9e77152d..8320f36baf42 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.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-01 15:39:15 $
+ * last change: $Author: tra $ $Date: 2001-03-05 06:36:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -145,13 +145,6 @@ public:
// when we flush the clipboard
void SAL_CALL GetAllDataFromSource( );
- // sometimes we need to lock objects of this
- // class for instance during clipboard shutdown
- // it should not be possible to do specific
- // things etc.
- //Lock( );
- //Unlock( );
-
private:
void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;