From 8666a2a5f4dbafbe8af818a1d002b391b021d4b8 Mon Sep 17 00:00:00 2001 From: jp Date: Thu, 8 Mar 2001 20:28:23 +0000 Subject: change: old data transfer API to the new --- sot/source/base/exchange.cxx | 72 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 7 deletions(-) (limited to 'sot') diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx index 1e15336ce693..0cd5da27334c 100644 --- a/sot/source/base/exchange.cxx +++ b/sot/source/base/exchange.cxx @@ -2,9 +2,9 @@ * * $RCSfile: exchange.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: ka $ $Date: 2001-03-08 11:40:01 $ + * last change: $Author: jp $ $Date: 2001-03-08 21:12:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -343,6 +343,63 @@ sal_Bool SotExchange::GetFormatDataFlavor( ULONG nFormat, DataFlavor& rFlavor ) return bRet; } +/************************************************************************* +|* +|* SotExchange::GetFormatMimeType( ULONG nFormat ) +|* +*************************************************************************/ + +String SotExchange::GetFormatMimeType( ULONG nFormat ) +{ + String sMimeType; + if( SOT_FORMATSTR_ID_USER_END >= nFormat ) + sMimeType.AssignAscii( ( aFormatArray_Impl + nFormat )->pMimeType ); + else + { + List& rL = InitFormats_Impl(); + + nFormat -= SOT_FORMATSTR_ID_USER_END + 1; + + if( rL.Count() > nFormat ) + sMimeType = ((DataFlavor*) rL.GetObject( nFormat ))->MimeType; + } + + DBG_ASSERT( sMimeType.Len(), "SotExchange::GetFormatMimeType(): DataFlavor not initialized" ); + + return sMimeType; +} + +/************************************************************************* +|* +|* SotExchange::GetFormatIdFromMimeType( const String& rMimeType ) +|* +*************************************************************************/ + +ULONG SotExchange::GetFormatIdFromMimeType( const String& rMimeType ) +{ + ULONG i, nMax = SOT_FORMAT_FILE_LIST; + for( i = SOT_FORMAT_STRING; i <= nMax; ++i ) + if( rMimeType.EqualsAscii( aFormatArray_Impl[ i ].pMimeType ) ) + return i; + + nMax = SOT_FORMATSTR_ID_USER_END; + for( i = SOT_FORMAT_RTF; i <= nMax; ++i ) + if( rMimeType.EqualsAscii( aFormatArray_Impl[ i ].pMimeType ) ) + return i; + + // dann in der dynamischen Liste + List& rL = InitFormats_Impl(); + ::rtl::OUString aMimeType( rMimeType ); + for( i = 0, nMax = rL.Count(); i < nMax; i++ ) + { + DataFlavor* pFlavor = (DataFlavor*) rL.GetObject( i ); + if( pFlavor && aMimeType == pFlavor->MimeType ) + return i + SOT_FORMATSTR_ID_USER_END + 1; + } + + return 0; +} + /************************************************************************* |* |* SotExchange::GetFormatName() @@ -352,15 +409,16 @@ sal_Bool SotExchange::GetFormatDataFlavor( ULONG nFormat, DataFlavor& rFlavor ) ULONG SotExchange::GetFormat( const DataFlavor& rFlavor ) { // teste zuerst die Standard - Name - const String aMimeType( rFlavor.MimeType ); - ULONG i, nMax = SOT_FORMAT_FILE_LIST; + const ::rtl::OUString& rMimeType = rFlavor.MimeType; + const String aMimeType( rMimeType ); + ULONG i, nMax = SOT_FORMAT_FILE_LIST; for( i = SOT_FORMAT_STRING; i <= nMax; ++i ) - if( COMPARE_EQUAL == aMimeType.CompareToAscii( aFormatArray_Impl[ i ].pMimeType ) ) + if( aMimeType.EqualsAscii( aFormatArray_Impl[ i ].pMimeType ) ) return i; nMax = SOT_FORMATSTR_ID_USER_END; for( i = SOT_FORMAT_RTF; i <= nMax; ++i ) - if( COMPARE_EQUAL == aMimeType.CompareToAscii( aFormatArray_Impl[ i ].pMimeType ) ) + if( aMimeType.EqualsAscii( aFormatArray_Impl[ i ].pMimeType ) ) return i; // dann in der dynamischen Liste @@ -368,7 +426,7 @@ ULONG SotExchange::GetFormat( const DataFlavor& rFlavor ) for( i = 0, nMax = rL.Count(); i < nMax; i++ ) { DataFlavor* pFlavor = (DataFlavor*) rL.GetObject( i ); - if( pFlavor && rFlavor.MimeType == pFlavor->MimeType ) + if( pFlavor && rMimeType == pFlavor->MimeType ) return i + SOT_FORMATSTR_ID_USER_END + 1; } -- cgit