diff options
author | Tino Rachui <tra@openoffice.org> | 2001-03-19 12:03:00 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-03-19 12:03:00 +0000 |
commit | b97f7daa1003c93eb546c17d2fc3790277d02956 (patch) | |
tree | 618a72fae1b461b7d493fa76002fb7817ee89261 /dtrans/source/win32/dtobj/FetcList.cxx | |
parent | fab5a6d72b7c6940a0bb60315354f2161a78db1a (diff) |
*** empty log message ***
Diffstat (limited to 'dtrans/source/win32/dtobj/FetcList.cxx')
-rw-r--r-- | dtrans/source/win32/dtobj/FetcList.cxx | 176 |
1 files changed, 78 insertions, 98 deletions
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx index aaeadfcfff53..c0e0df266960 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.9 $ + * $Revision: 1.10 $ * - * last change: $Author: tra $ $Date: 2001-03-19 09:11:24 $ + * last change: $Author: tra $ $Date: 2001-03-19 13:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -259,10 +259,12 @@ CFormatRegistrar::CFormatRegistrar( const Reference< XMultiServiceFactory >& Ser // ---------------------------------------------------------------------------------------- void SAL_CALL CFormatRegistrar::RegisterFormats( - const Sequence< DataFlavor >& aFlavorList, CFormatEtcContainer& aFormatEtcContainer ) + const Reference< XTransferable >& aXTransferable, CFormatEtcContainer& aFormatEtcContainer ) { - sal_Int32 nFlavors = aFlavorList.getLength( ); - sal_Bool bSuccess = sal_False; + Sequence< DataFlavor > aFlavorList = aXTransferable->getTransferDataFlavors( ); + sal_Int32 nFlavors = aFlavorList.getLength( ); + sal_Bool bSuccess = sal_False; + sal_Bool bUnicodeRegistered = sal_False; DataFlavor aFlavor; for( sal_Int32 i = 0; i < nFlavors; i++ ) @@ -270,46 +272,59 @@ void SAL_CALL CFormatRegistrar::RegisterFormats( aFlavor = aFlavorList[i]; CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor ); - if ( needsToSynthesizeAccompanyFormats( fetc ) ) - { - // we don't validate if the operation succeded - // because an accompany format might have be - // registered so that it's no problem if the - // operation fails because of a duplicate format - // e.g. text was already registered we have also - // registered unicode text, if we later try to - // register unicode text it will fail + if ( !needsToSynthesizeAccompanyFormats( fetc ) ) aFormatEtcContainer.addFormatEtc( fetc ); - - synthesizeAndRegisterAccompanyFormats( - fetc, aFlavor, aFormatEtcContainer ); - } else - aFormatEtcContainer.addFormatEtc( fetc ); + { + // if we haven't registered any text format up to now + if ( isTextFormat( fetc.getClipformat() ) && !bUnicodeRegistered ) + { + // if the transferable supports unicode text we ignore + // any further text format the transferable offers + // because we can create it from Unicode text in addition + // we register CF_TEXT for non unicode clients + if ( isUnicodeTextFormat( fetc.getClipformat() ) ) + { + aFormatEtcContainer.addFormatEtc( fetc ); // add CF_UNICODE + aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_TEXT ) ); // add CF_TEXT + bUnicodeRegistered = sal_True; + } + else if ( !hasUnicodeFlavor( aXTransferable ) ) + { + // we try to investigate the charset and make a valid + // windows codepage from this charset the default + // return value is the result of GetACP( ) + OUString charset = getCharsetFromDataFlavor( aFlavor ); + sal_uInt32 txtCP = getWinCPFromMimeCharset( charset ); + + // we try to get a Locale appropriate for this codepage + if ( findLocaleForTextCodePage( ) ) + { + m_TxtCodePage = txtCP; + + aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_UNICODETEXT ) ); + + if ( !IsOEMCP( m_TxtCodePage ) ) + aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_TEXT ) ); + else + aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_OEMTEXT ) ); + + aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_LOCALE ) ); + + // we save the flavor so it's easier when + // queried for it in XTDataObject::GetData(...) + m_RegisteredTextFlavor = aFlavor; + m_bHasSynthesizedLocale = sal_True; + } + } + } + else // Html (Hyper Text...) + { + } + } } } -/* - For all Flavors from Transferable - if not is TextFlavor - add Format to FormatList - else if not UnicodeTextRegistred - if isUnicodeText or Transferable Has Unicodetext - add Unicode Format to FormatList - add Text to FormatList - UnicodeTextRegistered = true - else - if findLocaleForTextCharset successful - add Unicode Format to FormatList - add Text or OemText to FormatList - add Locale to FormatList - HasSynthesizedLocale = true - save the TextFlavor so that access is easier in GetData - end if - end if - end if -*/ - //------------------------------------------------------------------------ // //------------------------------------------------------------------------ @@ -332,6 +347,15 @@ LCID SAL_CALL CFormatRegistrar::getSynthesizedLocale( ) const // //------------------------------------------------------------------------ +sal_uInt32 SAL_CALL CFormatRegistrar::getRegisteredTextCodePage( ) const +{ + return m_TxtCodePage; +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + inline sal_Bool SAL_CALL CFormatRegistrar::isOemOrAnsiTextFormat( CLIPFORMAT cf ) const { @@ -383,64 +407,6 @@ sal_Bool SAL_CALL CFormatRegistrar::needsToSynthesizeAccompanyFormats( const CFo // //------------------------------------------------------------------------ -void SAL_CALL CFormatRegistrar::synthesizeAndRegisterAccompanyFormats( - CFormatEtc& aFormatEtc, const DataFlavor& aFlavor, CFormatEtcContainer& aFormatEtcContainer ) -{ - CLIPFORMAT cf = aFormatEtc.getClipformat(); - OSL_ASSERT( isOemOrAnsiTextFormat(cf) || isUnicodeTextFormat(cf) ); - - CFormatEtc fetc; - - if ( isOemOrAnsiTextFormat( cf ) ) - { - OUString charset = getCharsetFromDataFlavor( aFlavor ); - if ( charset.getLength( ) ) - m_TxtCodePage = getWinCPFromMimeCharset( charset ); - else - m_TxtCodePage = GetACP( ); - - OSL_ASSERT( IsValidCodePage( m_TxtCodePage ) ); - - if ( !isEqualCurrentSystemCodePage( m_TxtCodePage ) ) - { - fetc = getFormatEtcForClipformat( CF_LOCALE ); - - if ( findLocaleForTextCodePage( ) ) - { - aFormatEtcContainer.addFormatEtc( fetc ); - m_bHasSynthesizedLocale = sal_True; - } - else // could not find a locale for this charset - { - // remove the locale if there is one - // already registered - aFormatEtcContainer.removeFormatEtc( fetc ); - m_bHasSynthesizedLocale = sal_False; - } - } - - // register may fail if we have already - // registered CF_UNICODETEXT but - // then it doesn't matter because in this - // case CF_TEXT is already registered - fetc = getFormatEtcForClipformat( CF_UNICODETEXT ); - aFormatEtcContainer.addFormatEtc( fetc ); - } - else // CF_UNICODETEXT - { - // register may fail if we have already - // registered CF_TEXT or CF_OEMTEXT but - // then it doesn't matter because in this - // case CF_UNICODETEXT is already registered - fetc = getFormatEtcForClipformat( CF_TEXT ); - aFormatEtcContainer.addFormatEtc( fetc ); - } -} - -//------------------------------------------------------------------------ -// -//------------------------------------------------------------------------ - OUString SAL_CALL CFormatRegistrar::getCharsetFromDataFlavor( const DataFlavor& aFlavor ) { OUString charset; @@ -486,6 +452,20 @@ CFormatEtc SAL_CALL CFormatRegistrar::getFormatEtcForClipformat( CLIPFORMAT aCli // //------------------------------------------------------------------------ +sal_Bool SAL_CALL CFormatRegistrar::hasUnicodeFlavor( const Reference< XTransferable >& aXTransferable ) const +{ + CFormatEtc fetc( CF_UNICODETEXT ); + + DataFlavor aFlavor = + m_DataFormatTranslator.getDataFlavorFromFormatEtc( aXTransferable, fetc ); + + return aXTransferable->isDataFlavorSupported( aFlavor ); +} + +//------------------------------------------------------------------------ +// +//------------------------------------------------------------------------ + inline sal_Bool CFormatRegistrar::isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const { |