summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui/imoptdlg.cxx
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2011-01-27 13:25:09 +0100
committerNiklas Nebel <nn@openoffice.org>2011-01-27 13:25:09 +0100
commitd9c1ae54f751c7c9e601a229461f8f4ff34f1e36 (patch)
treef6e3a57c8bbc146ded60ec02f160fb86f08f6ffe /sc/source/ui/dbgui/imoptdlg.cxx
parentdc205fe9d10305dcff17e0e4c3f2130344eb5119 (diff)
csvexport: #i116636# option to leave out unnecessary quotes in CSV export
Diffstat (limited to 'sc/source/ui/dbgui/imoptdlg.cxx')
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index ce5874688..81d3e5a97 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -44,10 +44,20 @@ static const sal_Char pStrFix[] = "FIX";
ScImportOptions::ScImportOptions( const String& rStr )
{
+ // Use the same string format as ScAsciiOptions,
+ // because the import options string is passed here when a CSV file is loaded and saved again.
+ // The old format is still supported because it might be used in macros.
+
bFixedWidth = FALSE;
nFieldSepCode = 0;
- if ( rStr.GetTokenCount(',') >= 3 )
+ nTextSepCode = 0;
+ eCharSet = RTL_TEXTENCODING_DONTKNOW;
+ bSaveAsShown = sal_True; // "true" if not in string (after CSV import)
+ bQuoteAllText = sal_False;
+ xub_StrLen nTokenCount = rStr.GetTokenCount(',');
+ if ( nTokenCount >= 3 )
{
+ // first 3 tokens: common
String aToken( rStr.GetToken( 0, ',' ) );
if( aToken.EqualsIgnoreCaseAscii( pStrFix ) )
bFixedWidth = TRUE;
@@ -56,7 +66,21 @@ ScImportOptions::ScImportOptions( const String& rStr )
nTextSepCode = (sal_Unicode) rStr.GetToken(1,',').ToInt32();
aStrFont = rStr.GetToken(2,',');
eCharSet = ScGlobal::GetCharsetValue(aStrFont);
- bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? TRUE : FALSE);
+
+ if ( nTokenCount == 4 )
+ {
+ // compatibility with old options string: "Save as shown" as 4th token, numeric
+ bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? sal_True : sal_False);
+ bQuoteAllText = sal_True; // use old default then
+ }
+ else
+ {
+ // look at the same positions as in ScAsciiOptions
+ if ( nTokenCount >= 7 )
+ bQuoteAllText = rStr.GetToken(6, ',').EqualsAscii("true");
+ if ( nTokenCount >= 9 )
+ bSaveAsShown = rStr.GetToken(8, ',').EqualsAscii("true");
+ }
}
}
@@ -74,8 +98,11 @@ String ScImportOptions::BuildString() const
aResult += String::CreateFromInt32(nTextSepCode);
aResult += ',';
aResult += aStrFont;
- aResult += ',';
- aResult += String::CreateFromInt32( bSaveAsShown ? 1 : 0 );
+ // use the same string format as ScAsciiOptions:
+ aResult.AppendAscii( ",1,,0," ); // first row, no column info, default language
+ aResult.AppendAscii(bQuoteAllText ? "true" : "false"); // same as "quoted field as text" in ScAsciiOptions
+ aResult.AppendAscii( ",true," ); // "detect special numbers"
+ aResult.AppendAscii(bSaveAsShown ? "true" : "false"); // "save as shown": not in ScAsciiOptions
return aResult;
}