summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-12-14 17:27:55 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-12-14 17:30:18 -0500
commitcdcd262ea4aa3c3e407b14ed533e514f75de2d3a (patch)
tree8b920036a1c53e17db35a2b7512336abe3b0fc28
parent15124f0b2476ed4a9d499331fc154a9602205dae (diff)
Fixed unformatted text paste. (fdo#32213)
* Changed default option settings for CSV import options to something sensible. * Set explicit multi-line cell handling policy during unformatted text pasting.
-rw-r--r--sc/source/ui/app/transobj.cxx9
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx6
-rw-r--r--sc/source/ui/docshell/impex.cxx36
3 files changed, 43 insertions, 8 deletions
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index d29782103..05abff424 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -311,8 +311,15 @@ sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor )
BOOL bIncludeFiltered = pDoc->IsCutMode() || bUsedForLink;
ScImportExport aObj( pDoc, aBlock );
+ ScExportTextOptions aTextOptions(ScExportTextOptions::None, 0, true);
if ( bUsedForLink )
- aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, ' ', false ) );
+ {
+ // For a DDE link, convert line breaks and separators to space.
+ aTextOptions.meNewlineConversion = ScExportTextOptions::ToSpace;
+ aTextOptions.mcSeparatorConvertTo = ' ';
+ aTextOptions.mbAddQuotes = false;
+ }
+ aObj.SetExportTextOptions(aTextOptions);
aObj.SetFormulas( pDoc->GetViewOptions().GetOption( VOPT_FORMULAS ) );
aObj.SetIncludeFiltered( bIncludeFiltered );
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 09e1dfb42..2a9e07154 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -274,9 +274,9 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
}
SetText( aName );
-
- OUString sFieldSeparators;
- OUString sTextSeparators;
+ // Default options
+ OUString sFieldSeparators(RTL_CONSTASCII_USTRINGPARAM("\t"));
+ OUString sTextSeparators(mcTextSep);
bool bMergeDelimiters = false;
bool bFixedWidth = false;
bool bQuotedFieldAsText = true;
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index fb242f234..ba9c36e90 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1398,10 +1398,38 @@ const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p
return p;
}
- //
- //
- //
+namespace {
+
+/**
+ * Check if a given string has any line break characters or separators.
+ *
+ * @param rStr string to inspect.
+ * @param cSep separator character.
+ */
+bool hasLineBreaksOrSeps( const String& rStr, sal_Unicode cSep )
+{
+ const sal_Unicode* p = rStr.GetBuffer();
+ for (xub_StrLen i = 0, n = rStr.Len(); i < n; ++i, ++p)
+ {
+ sal_Unicode c = *p;
+ if (c == cSep)
+ // separator found.
+ return true;
+ switch (c)
+ {
+ case _LF:
+ case _CR:
+ // line break found.
+ return true;
+ default:
+ ;
+ }
+ }
+ return false;
+}
+
+}
BOOL ScImportExport::Doc2Text( SvStream& rStrm )
{
@@ -1482,7 +1510,7 @@ BOOL ScImportExport::Doc2Text( SvStream& rStrm )
if( mExportTextOptions.mcSeparatorConvertTo && cSep )
aCell.SearchAndReplaceAll( cSep, mExportTextOptions.mcSeparatorConvertTo );
- if( mExportTextOptions.mbAddQuotes && ( aCell.Search( cSep ) != STRING_NOTFOUND ) )
+ if( mExportTextOptions.mbAddQuotes && hasLineBreaksOrSeps(aCell, cSep) )
lcl_WriteString( rStrm, aCell, cStr, cStr );
else
lcl_WriteSimpleString( rStrm, aCell );