Index: sc/source/ui/view/viewfun5.cxx =================================================================== RCS file: /cvs/sc/sc/source/ui/view/viewfun5.cxx,v --- sc/source/ui/view/viewfun5.cxx 8 Sep 2004 15:56:29 -0000 1.29 +++ sc/source/ui/view/viewfun5.cxx 12 Oct 2004 13:51:30 -0000 @@ -119,6 +119,10 @@ #include "tabvwsh.hxx" // wegen GetViewFrame #include "compiler.hxx" +#include "asciiopt.hxx" +#include "scabstdlg.hxx" +#include "vcl/msgbox.hxx" + #ifndef _SFXVIEWFRM_HXX //autogen #include #endif @@ -272,12 +276,43 @@ ScAddress aPos( nPosX, nPosY, GetViewData()->GetTabNo() ); ScImportExport aObj( GetViewData()->GetDocument(), aPos ); - ::rtl::OUString aStr; + ::rtl::OUString aStr; SotStorageStreamRef xStream; if ( aDataHelper.GetSotStorageStream( nFormatId, xStream ) && xStream.Is() ) bRet = aObj.ImportStream( *xStream, nFormatId ); - else if ( aDataHelper.GetString( nFormatId, aStr ) ) - bRet = aObj.ImportString( aStr, nFormatId ); + + else if ( aDataHelper.GetString( nFormatId, aStr ) ) { + + sal_Int32 newln; + newln = aStr.indexOf ('\n'); +/* ::rtl::OString tmpStr = OUStringToOString + ( aStr, RTL_TEXTENCODING_UTF8 ); + fprintf (stderr, "String is '%s' (%d) [%d]\n", + tmpStr.getStr (), tmpStr.getLength(), newln); */ + if (newln >= 0 && newln != aStr.getLength () - 1) { // do dialog + // FIXME: split me out - if only C++ 'private' didn't suck rocks. + + SvMemoryStream aStrm( (void*)aStr.getStr(), aStr.getLength() * sizeof(sal_Unicode), STREAM_READ ); + aStrm.SetStreamCharSet( RTL_TEXTENCODING_UNICODE ); + // Hack - copied from impex.cxx - we need a helper to do this [!] + aStrm.SetEndianSwap( FALSE ); + + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg + ( NULL, String::CreateFromAscii("Pasted Data"), &aStrm, + ResId(RID_SCDLG_ASCII) ); + + if (pDlg->Execute() == RET_OK) { + ScAsciiOptions aOptions; + pDlg->GetOptions( aOptions ); + aObj.SetExtOptions( aOptions ); + + bRet = aObj.ImportString( aStr, nFormatId ); + } else + bRet = FALSE; + } else + bRet = aObj.ImportString( aStr, nFormatId ); + } InvalidateAttribs(); GetViewData()->UpdateInputHandler();