diff options
author | Niklas Nebel <nn@openoffice.org> | 2011-01-27 13:25:09 +0100 |
---|---|---|
committer | Niklas Nebel <nn@openoffice.org> | 2011-01-27 13:25:09 +0100 |
commit | d9c1ae54f751c7c9e601a229461f8f4ff34f1e36 (patch) | |
tree | f6e3a57c8bbc146ded60ec02f160fb86f08f6ffe /sc/source/ui/dbgui | |
parent | dc205fe9d10305dcff17e0e4c3f2130344eb5119 (diff) |
csvexport: #i116636# option to leave out unnecessary quotes in CSV export
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r-- | sc/source/ui/dbgui/asciiopt.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/dbgui/imoptdlg.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/dbgui/imoptdlg.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/dbgui/imoptdlg.src | 12 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scuiasciiopt.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scuiimoptdlg.cxx | 10 |
6 files changed, 57 insertions, 9 deletions
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index 54bc80746..8a0b67394 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -312,6 +312,10 @@ void ScAsciiOptions::ReadFromString( const String& rString ) aToken = rString.GetToken(7, ','); bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false; } + else + bDetectSpecialNumber = sal_True; // default of versions that didn't add the parameter + + // 9th token is used for "Save as shown" in export options } @@ -399,6 +403,8 @@ String ScAsciiOptions::WriteToString() const // Detect special nubmers. aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false"); + // 9th token is used for "Save as shown" in export options + return aOutStr; } 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; } diff --git a/sc/source/ui/dbgui/imoptdlg.hrc b/sc/source/ui/dbgui/imoptdlg.hrc index b6f1bf555..6d67abb70 100644 --- a/sc/source/ui/dbgui/imoptdlg.hrc +++ b/sc/source/ui/dbgui/imoptdlg.hrc @@ -41,4 +41,5 @@ #define FL_FIELDOPT 11 #define CB_FIXEDWIDTH 12 #define CB_SAVESHOWN 13 +#define CB_QUOTEALL 14 diff --git a/sc/source/ui/dbgui/imoptdlg.src b/sc/source/ui/dbgui/imoptdlg.src index 7c5af149f..06b3af2e8 100644 --- a/sc/source/ui/dbgui/imoptdlg.src +++ b/sc/source/ui/dbgui/imoptdlg.src @@ -96,7 +96,7 @@ ModalDialog RID_SCDLG_IMPORTOPT CheckBox CB_FIXEDWIDTH { HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_FIXEDWIDTH"; - Pos = MAP_APPFONT( 12, 80 ); + Pos = MAP_APPFONT( 12, 92 ); Size = MAP_APPFONT( 172, 10 ); Hide = TRUE; Text [ en-US ] = "Fixed column ~width"; @@ -104,12 +104,20 @@ ModalDialog RID_SCDLG_IMPORTOPT CheckBox CB_SAVESHOWN { HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_SAVESHOWN"; - Pos = MAP_APPFONT( 12, 66 ); + Pos = MAP_APPFONT( 12, 78 ); Size = MAP_APPFONT( 172, 10 ); TabStop = TRUE; Hide = TRUE; Text [ en-US ] = "Save cell content as ~shown"; }; + CheckBox CB_QUOTEALL + { + HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_QUOTEALL"; + Pos = MAP_APPFONT( 20, 64 ); + Size = MAP_APPFONT( 164, 10 ); + Hide = TRUE; + Text [ en-US ] = "~Quote all text cells"; + }; OKButton BTN_OK { Pos = MAP_APPFONT ( 202 , 6 ) ; diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 7414e672f..ff6af622c 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -273,7 +273,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, OUString sTextSeparators; bool bMergeDelimiters = false; bool bFixedWidth = false; - bool bQuotedFieldAsText = true; + bool bQuotedFieldAsText = false; bool bDetectSpecialNum = false; sal_Int32 nFromRow = 1; sal_Int32 nCharSet = -1; diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx index 3edb76f0b..58a8f22b6 100644 --- a/sc/source/ui/dbgui/scuiimoptdlg.cxx +++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx @@ -132,11 +132,12 @@ ScImportOptionsDlg::ScImportOptionsDlg( aEdFieldSep ( this, ScResId( ED_FIELDSEP ) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aEdTextSep ( this, ScResId( ED_TEXTSEP ) ), + aCbQuoteAll ( this, ScResId( CB_QUOTEALL ) ), + aCbShown ( this, ScResId( CB_SAVESHOWN ) ), aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ), aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), - aBtnHelp ( this, ScResId( BTN_HELP ) ), - aCbShown ( this, ScResId( CB_SAVESHOWN ) ) + aBtnHelp ( this, ScResId( BTN_HELP ) ) { // im Ctor-Initializer nicht moeglich (MSC kann das nicht): pFieldSepTab = new ScDelimiterTable( String(ScResId(SCSTR_FIELDSEP)) ); @@ -214,6 +215,8 @@ ScImportOptionsDlg::ScImportOptionsDlg( aCbFixed.Check( FALSE ); aCbShown.Show(); aCbShown.Check( TRUE ); + aCbQuoteAll.Show(); + aCbQuoteAll.Check( sal_False ); } else { @@ -225,6 +228,7 @@ ScImportOptionsDlg::ScImportOptionsDlg( aEdTextSep.Hide(); aCbFixed.Hide(); aCbShown.Hide(); + aCbQuoteAll.Hide(); aLbFont.GrabFocus(); aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) ); } @@ -259,6 +263,7 @@ void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const rOptions.nTextSepCode = GetCodeFromCombo( aEdTextSep ); rOptions.bFixedWidth = aCbFixed.IsChecked(); rOptions.bSaveAsShown = aCbShown.IsChecked(); + rOptions.bQuoteAllText = aCbQuoteAll.IsChecked(); } } @@ -302,6 +307,7 @@ IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox ) aFtTextSep.Enable( bEnable ); aEdTextSep.Enable( bEnable ); aCbShown.Enable( bEnable ); + aCbQuoteAll.Enable( bEnable ); } return 0; } |