diff options
author | Tino Rachui <tra@openoffice.org> | 2001-03-20 12:40:26 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-03-20 12:40:26 +0000 |
commit | 405ea9e6ea8ef8ada07ba206960ace6dc491377f (patch) | |
tree | f828507518521584ca8d9d3b4f5b611da910ed67 /dtrans/source | |
parent | add. include XMuliServiceFactory (diff) | |
download | core-405ea9e6ea8ef8ada07ba206960ace6dc491377f.tar.gz core-405ea9e6ea8ef8ada07ba206960ace6dc491377f.zip |
*** empty log message ***
Diffstat (limited to 'dtrans/source')
-rw-r--r-- | dtrans/source/win32/dtobj/DOTransferable.cxx | 31 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/DataFmtTransl.cxx | 53 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/DataFmtTransl.hxx | 10 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/FetcList.cxx | 16 | ||||
-rw-r--r-- | dtrans/source/win32/dtobj/XTDataObject.cxx | 13 | ||||
-rw-r--r-- | dtrans/source/win32/mtaole/MtaOleClipb.cxx | 8 | ||||
-rw-r--r-- | dtrans/source/win32/workbench/test_wincb.cxx | 43 |
7 files changed, 99 insertions, 75 deletions
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx index 855c4ee10c23..eddf6f5322f7 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.6 $ + * $Revision: 1.7 $ * - * last change: $Author: tra $ $Date: 2001-03-15 10:12:55 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -279,7 +279,32 @@ CFormatEtc SAL_CALL CDOTransferable::dataFlavorToFormatEtc( const DataFlavor& aF //inline DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) { - return m_DataFormatTranslator.getDataFlavorFromFormatEtc( this, aFormatEtc ); + DataFlavor aFlavor; + LCID lcid = GetThreadLocale( ); + + try + { + // for non-unicode text format we must provid a locale to get + // the character-set of the text, if there is no locale on the + // clipboard we assume the text is in a charset appropriate for + // the current thread locale + if ( (CF_TEXT == aFormatEtc.cfFormat) || (CF_OEMTEXT == aFormatEtc.cfFormat) ) + { + CFormatEtc fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_LOCALE ); + ByteSequence_t aLCIDSeq = getClipboardData( fetc ); + lcid = *(reinterpret_cast<LCID*>( aLCIDSeq.getArray( ) ) ); + } + } + catch( UnsupportedFlavorException& ) + { + // no locale on clipboard, we take the default + } + catch(...) + { + OSL_ENSURE( sal_False, "Unexpected" ); + } + + return m_DataFormatTranslator.getDataFlavorFromFormatEtc( aFormatEtc, lcid ); } //------------------------------------------------------------------------ diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx index 9f6845d8f9d2..b5de5aa02624 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.11 $ + * $Revision: 1.12 $ * - * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -183,7 +183,7 @@ CFormatEtc CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& // //------------------------------------------------------------------------ -DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< XTransferable >& refXTransferable, const FORMATETC& aFormatEtc ) const +DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const FORMATETC& aFormatEtc, LCID lcid ) const { DataFlavor aFlavor; @@ -201,7 +201,7 @@ DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< X if ( isOemOrAnsiTextFormat( aClipformat ) ) { aFlavor.MimeType = OUString::createFromAscii( "text/plain;charset=" ); - aFlavor.MimeType += getTextCharsetFromClipboard( refXTransferable, aClipformat ); + aFlavor.MimeType += getTextCharsetFromLCID( lcid, aClipformat ); aFlavor.HumanPresentableName = OUString::createFromAscii( "OEM/ANSI Text" ); aFlavor.DataType = CPPUTYPE_SEQSALINT8; @@ -340,58 +340,16 @@ sal_Bool SAL_CALL CDataFormatTranslator::isTextHtmlFormat( CLIPFORMAT cf ) const } //------------------------------------------------------------------------ -// should be called only if there is realy text on the clipboard -//------------------------------------------------------------------------ - -LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard( - const Reference< XTransferable >& refXTransferable ) const -{ - Any aAny; - CFormatEtc fetc = getFormatEtcForClipformat( CF_LOCALE ); - DataFlavor aFlavor = getDataFlavorFromFormatEtc( refXTransferable, fetc ); - - OSL_ASSERT( aFlavor.MimeType.getLength( ) ); - - LCID lcid = 0; - - try - { - aAny = refXTransferable->getTransferData( aFlavor ); - if ( aAny.hasValue( ) && (aAny.getValueType( ) == CPPUTYPE_SEQSALINT8) ) - { - Sequence< sal_Int8 > byteStream; - aAny >>= byteStream; - - lcid = *reinterpret_cast< LCID* >( byteStream.getArray( ) ); - } - } - catch( UnsupportedFlavorException& ) - { - } - catch( ... ) - { - OSL_ENSURE( sal_False, "Unexpected error" ); - } - - if ( !IsValidLocale( lcid, LCID_SUPPORTED ) ) - lcid = GetThreadLocale( ); - - return lcid; -} - -//------------------------------------------------------------------------ // //------------------------------------------------------------------------ -OUString SAL_CALL CDataFormatTranslator::getTextCharsetFromClipboard( - const Reference< XTransferable >& refXTransferable, CLIPFORMAT aClipformat ) const +OUString SAL_CALL CDataFormatTranslator::getTextCharsetFromLCID( LCID lcid, CLIPFORMAT aClipformat ) const { OSL_ASSERT( isOemOrAnsiTextFormat( aClipformat ) ); OUString charset; if ( CF_TEXT == aClipformat ) { - LCID lcid = getCurrentLocaleFromClipboard( refXTransferable ); charset = getMimeCharsetFromLocaleId( lcid, LOCALE_IDEFAULTANSICODEPAGE, @@ -399,7 +357,6 @@ OUString SAL_CALL CDataFormatTranslator::getTextCharsetFromClipboard( } else if ( CF_OEMTEXT == aClipformat ) { - LCID lcid = getCurrentLocaleFromClipboard( refXTransferable ); charset = getMimeCharsetFromLocaleId( lcid, LOCALE_IDEFAULTCODEPAGE, diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.hxx b/dtrans/source/win32/dtobj/DataFmtTransl.hxx index 53e04eeb07c3..ddc2be2b01d4 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.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,7 +102,7 @@ public: 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; + const FORMATETC& aFormatEtc, LCID lcid = GetThreadLocale( ) ) const; CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const; CFormatEtc SAL_CALL getFormatEtcForClipformatName( const rtl::OUString& aClipFmtName ) const; @@ -115,9 +115,7 @@ public: sal_Bool SAL_CALL isTextFormat( CLIPFORMAT cf ) const; private: - LCID SAL_CALL getCurrentLocaleFromClipboard( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable ) const; - rtl::OUString SAL_CALL getTextCharsetFromClipboard( - const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable, CLIPFORMAT aClipformat ) const; + rtl::OUString SAL_CALL getTextCharsetFromLCID( LCID lcid, CLIPFORMAT aClipformat ) const; private: const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx index 1209300f9574..c8720ac47e9f 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.11 $ + * $Revision: 1.12 $ * - * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -440,7 +440,7 @@ sal_Bool SAL_CALL CFormatRegistrar::hasUnicodeFlavor( const Reference< XTransfer CFormatEtc fetc( CF_UNICODETEXT ); DataFlavor aFlavor = - m_DataFormatTranslator.getDataFlavorFromFormatEtc( aXTransferable, fetc ); + m_DataFormatTranslator.getDataFlavorFromFormatEtc( fetc ); return aXTransferable->isDataFlavorSupported( aFlavor ); } @@ -462,8 +462,8 @@ sal_Bool CFormatRegistrar::isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) sal_Bool SAL_CALL CFormatRegistrar::findLocaleForTextCodePage( ) { m_TxtLocale = 0; - EnumSystemLocalesA( CFormatRegistrar::EnumLocalesProc, LCID_SUPPORTED ); - return ( IsValidLocale( m_TxtLocale, LCID_SUPPORTED ) ); + EnumSystemLocalesA( CFormatRegistrar::EnumLocalesProc, LCID_INSTALLED ); + return ( IsValidLocale( m_TxtLocale, LCID_INSTALLED ) ); } //------------------------------------------------------------------------ @@ -475,9 +475,11 @@ sal_Bool SAL_CALL CFormatRegistrar::isLocaleCodePage( LCID lcid, LCTYPE lctype, char buff[6]; sal_uInt32 localeCodePage; + OSL_ASSERT( IsValidLocale( lcid, LCID_INSTALLED ) ); + // get the ansi codepage of the current locale GetLocaleInfoA( lcid, lctype, buff, sizeof( buff ) ); - localeCodePage = atoi( buff ); + localeCodePage = atol( buff ); return ( localeCodePage == codepage ); } @@ -508,7 +510,7 @@ sal_Bool SAL_CALL CFormatRegistrar::isLocaleAnsiCodePage( LCID lcid, sal_uInt32 BOOL CALLBACK CFormatRegistrar::EnumLocalesProc( LPSTR lpLocaleStr ) { - LCID lcid = atoi( lpLocaleStr ); + LCID lcid = strtol( lpLocaleStr, NULL, 16 ); if ( isLocaleAnsiCodePage( lcid, CFormatRegistrar::m_TxtCodePage ) || isLocaleOemCodePage( lcid, CFormatRegistrar::m_TxtCodePage ) ) diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx index d96949ed19cb..88bf18666069 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.14 $ + * $Revision: 1.15 $ * - * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -605,8 +605,13 @@ CXTDataObject::operator IDataObject*( ) inline DataFlavor SAL_CALL CXTDataObject::formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const { - DataFlavor aFlavor = - m_DataFormatTranslator.getDataFlavorFromFormatEtc( m_XTransferable, aFormatEtc ); + DataFlavor aFlavor; + + if ( m_FormatRegistrar.hasSynthesizedLocale( ) ) + aFlavor = + m_DataFormatTranslator.getDataFlavorFromFormatEtc( aFormatEtc, m_FormatRegistrar.getSynthesizedLocale( ) ); + else + aFlavor = m_DataFormatTranslator.getDataFlavorFromFormatEtc( aFormatEtc ); if ( !aFlavor.MimeType.getLength( ) ) throw UnsupportedFlavorException( ); diff --git a/dtrans/source/win32/mtaole/MtaOleClipb.cxx b/dtrans/source/win32/mtaole/MtaOleClipb.cxx index 7206a5a9333b..07f30e4d0726 100644 --- a/dtrans/source/win32/mtaole/MtaOleClipb.cxx +++ b/dtrans/source/win32/mtaole/MtaOleClipb.cxx @@ -2,9 +2,9 @@ * * $RCSfile: MtaOleClipb.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: tra $ $Date: 2001-03-19 14:08:39 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:39:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -329,8 +329,10 @@ HRESULT CMtaOleClipboard::getClipboard( IDataObject** ppIDataObject ) } if ( SUCCEEDED( hr ) ) + { hr = UnmarshalIDataObjectAndReleaseStream( lpStream, ppIDataObject ); - + lpStream->Release( ); + } return hr; } diff --git a/dtrans/source/win32/workbench/test_wincb.cxx b/dtrans/source/win32/workbench/test_wincb.cxx index 47e4be15617b..61bc6eca6712 100644 --- a/dtrans/source/win32/workbench/test_wincb.cxx +++ b/dtrans/source/win32/workbench/test_wincb.cxx @@ -2,9 +2,9 @@ * * $RCSfile: test_wincb.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: tra $ $Date: 2001-03-14 14:54:58 $ + * last change: $Author: tra $ $Date: 2001-03-20 13:40:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -232,8 +232,11 @@ CTransferable::CTransferable( ) : { DataFlavor df; - df.MimeType = L"text/plain;charset=utf-16"; - df.DataType = getCppuType( ( OUString* )0 ); + //df.MimeType = L"text/plain;charset=utf-16"; + //df.DataType = getCppuType( ( OUString* )0 ); + + df.MimeType = L"text/plain;charset=Windows1252"; + df.DataType = getCppuType( (Sequence< sal_Int8 >*)0 ); m_FlavorList[0] = df; } @@ -247,8 +250,25 @@ Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor ) { Any anyData; + /* if ( aFlavor.MimeType == m_FlavorList[0].MimeType ) anyData = makeAny( m_Data ); + */ + if ( aFlavor.MimeType.equalsIgnoreCase( m_FlavorList[0].MimeType ) ) + { + OString text( + m_Data.getStr( ), + m_Data.getLength( ), + RTL_TEXTENCODING_ASCII_US ); + + Sequence< sal_Int8 > textStream( text.getLength( ) + 1 ); + + rtl_copyMemory( textStream.getArray( ), text.getStr( ), textStream.getLength( ) ); + + anyData = makeAny( textStream ); + } + else + throw UnsupportedFlavorException( ); return anyData; } @@ -303,6 +323,13 @@ int SAL_CALL main( int nArgc, char* Argv[] ) //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); HRESULT hr = CoInitialize( NULL ); + char buff[6]; + + LCID lcid = MAKELCID( MAKELANGID( LANG_GERMAN, SUBLANG_GERMAN ), SORT_DEFAULT ); + + BOOL bValid = IsValidLocale( lcid, LCID_SUPPORTED ); + GetLocaleInfoA( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) ); + //------------------------------------------------- // get the global service-manager //------------------------------------------------- @@ -335,10 +362,18 @@ int SAL_CALL main( int nArgc, char* Argv[] ) Reference< XClipboardListener > rXClipListener( static_cast< XClipboardListener* >( new CClipboardListener() ) ); xClipNotifier->addClipboardListener( rXClipListener ); + MessageBox( NULL, TEXT("Go"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); // set new clipboard content xClipboard->setContents( rXTransf, Reference< XClipboardOwner >( rXTransf, UNO_QUERY ) ); + /* + MessageBox( NULL, TEXT("Clear content"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); + + Reference< XClipboardOwner > rXClipOwner; + Reference< XTransferable > rXEmptyTransf; + xClipboard->setContents( rXEmptyTransf, rXClipOwner ); + */ MessageBox( NULL, TEXT("Stop"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); |