From 44ccce1e58ad84329f5d5d9f233c5ae844422218 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 11:27:09 -0400 Subject: #i3687# #i97416#: initial porting of patches from ooo-build. --- sc/source/ui/dbgui/scuiasciiopt.cxx | 166 +++++++++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 13 deletions(-) (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx') diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 6bc96c13d5b6..9d782347b5ea 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -44,6 +44,12 @@ // ause #include "editutil.hxx" +#include +#include +#include +#include "miscuno.hxx" + + //! TODO make dynamic #ifdef WIN const SCSIZE ASCIIDLG_MAXROWS = 10000; @@ -51,6 +57,20 @@ const SCSIZE ASCIIDLG_MAXROWS = 10000; const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT; #endif + +using namespace rtl; +using namespace com::sun::star::uno; + +// Defines - CSV Import Preserve Options +#define FIXED_WIDTH "FixedWidth" +#define FROM_ROW "FromRow" +#define CHAR_SET "CharSet" +#define SEPARATORS "Separators" +#define TEXT_SEPARATORS "TextSeparators" +#define MERGE_DELIMITERS "MergeDelimiters" +#define QUOTED_AS_TEXT "QuotedFieldAsText" +#define SEP_PATH "Office.Calc/Dialogs/CSVImport" + // ============================================================================ void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect ) @@ -98,11 +118,82 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) return c; } +static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, + bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth, + sal_Int32 &nFromRow, sal_Int32 &nCharSet ) +{ + SequenceaValues; + const Any *pProperties; + Sequence aNames(7); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS ); + pNames[1] = OUString::createFromAscii( SEPARATORS ); + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS ); + pNames[3] = OUString::createFromAscii( FIXED_WIDTH ); + pNames[4] = OUString::createFromAscii( FROM_ROW ); + pNames[5] = OUString::createFromAscii( CHAR_SET ); + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getConstArray(); + if( pProperties[1].hasValue() ) + pProperties[1] >>= sFieldSeparators; + + if( pProperties[2].hasValue() ) + pProperties[2] >>= sTextSeparators; + + if( pProperties[0].hasValue() ) + bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] ); + + if( pProperties[3].hasValue() ) + bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] ); + + if( pProperties[4].hasValue() ) + pProperties[4] >>= nFromRow; + + if( pProperties[5].hasValue() ) + pProperties[5] >>= nCharSet; + + if ( pProperties[6].hasValue() ) + pProperties[6] >>= bQuotedAsText; +} + +static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, + bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet ) +{ + OUString sFieldSeparators = OUString( maSeparators ); + OUString sTextSeparators = OUString( maTxtSep ); + Sequence aValues; + Any *pProperties; + Sequence aNames(7); + OUString* pNames = aNames.getArray(); + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); + + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS ); + pNames[1] = OUString::createFromAscii( SEPARATORS ); + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS ); + pNames[3] = OUString::createFromAscii( FIXED_WIDTH ); + pNames[4] = OUString::createFromAscii( FROM_ROW ); + pNames[5] = OUString::createFromAscii( CHAR_SET ); + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + aValues = aItem.GetProperties( aNames ); + pProperties = aValues.getArray(); + pProperties[1] <<= sFieldSeparators; + pProperties[2] <<= sTextSeparators; + ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters ); + ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth ); + pProperties[4] <<= nFromRow; + pProperties[5] <<= nCharSet; + pProperties[6] <<= static_cast(bQuotedAsText); + + aItem.PutProperties(aNames, aValues); +} // ---------------------------------------------------------------------------- ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, - SvStream* pInStream, sal_Unicode cSep ) : + SvStream* pInStream, sal_Unicode /*cSep*/ ) : ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ), mpDatStream ( pInStream ), mnStreamPos( pInStream ? pInStream->Tell() : 0 ), @@ -128,6 +219,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbOther ( this, ScResId( CKB_OTHER ) ), aEdOther ( this, ScResId( ED_OTHER ) ), aCkbAsOnce ( this, ScResId( CB_ASONCE) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), @@ -146,14 +238,15 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aFldSepList ( ScResId( SCSTR_FIELDSEP ) ), aTextSepList( ScResId( SCSTR_TEXTSEP ) ), mcTextSep ( ScAsciiOptions::cDefaultTextSep ), - maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ) + maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ), + mbFileImport(true) { FreeResource(); + mbFileImport = aDatName.Len() > 0; String aName = GetText(); // aDatName is empty if invoked during paste from clipboard. - BOOL bClipboard = (aDatName.Len() == 0); - if (!bClipboard) + if (mbFileImport) { aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - [")); aName += aDatName; @@ -161,20 +254,51 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, } SetText( aName ); - switch(cSep) + + OUString sFieldSeparators; + OUString sTextSeparators; + bool bMergeDelimiters = false; + bool bFixedWidth = false; + bool bQuotedFieldAsText = true; + sal_Int32 nFromRow = 1; + sal_Int32 nCharSet = -1; + if (mbFileImport) + // load separators only when importing csv files. + load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, + bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet); + maFieldSeparators = String(sFieldSeparators); + + if( bMergeDelimiters ) + aCkbAsOnce.Check(); + if (bQuotedFieldAsText) + aCkbQuotedAsText.Check(); + if( bFixedWidth ) + aRbFixed.Check(); + if( nFromRow != 1 ) + aNfRow.SetValue( nFromRow ); + + ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252); + const sal_Char *aSep = bString.GetBuffer(); + int len = maFieldSeparators.Len(); + for (int i = 0; i < len; ++i) { - case '\t': aCkbTab.Check(); break; - case ';': aCkbSemicolon.Check(); break; - case ',': aCkbComma.Check(); break; - case ' ': aCkbSpace.Check(); break; - default: - aCkbOther.Check(); - aEdOther.SetText( cSep ); + switch( aSep[i] ) + { + case '\t': aCkbTab.Check(); break; + case ';': aCkbSemicolon.Check(); break; + case ',': aCkbComma.Check(); break; + case ' ': aCkbSpace.Check(); break; + default: + aCkbOther.Check(); + aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) ); + } } + + // Get Separators from the dialog maFieldSeparators = GetSeparators(); // Clipboard is always Unicode, else detect. - BOOL bPreselectUnicode = bClipboard; + bool bPreselectUnicode = !mbFileImport; // Sniff for Unicode / not if( !bPreselectUnicode && mpDatStream ) { @@ -210,6 +334,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, // *** Separator characters *** lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep ); + aCbTextSep.SetText( sTextSeparators ); Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl ); aCbTextSep.SetSelectHdl( aSeparatorHdl ); @@ -218,6 +343,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbSemicolon.SetClickHdl( aSeparatorHdl ); aCkbComma.SetClickHdl( aSeparatorHdl ); aCkbAsOnce.SetClickHdl( aSeparatorHdl ); + aCkbQuotedAsText.SetClickHdl( aSeparatorHdl ); aCkbSpace.SetClickHdl( aSeparatorHdl ); aCkbOther.SetClickHdl( aSeparatorHdl ); aEdOther.SetModifyHdl( aSeparatorHdl ); @@ -230,6 +356,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser ); aLbCharSet.SelectTextEncoding( bPreselectUnicode ? RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() ); + + if( nCharSet >= 0 ) + aLbCharSet.SelectEntryPos( nCharSet ); + SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); @@ -261,6 +391,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, ScImportAsciiDlg::~ScImportAsciiDlg() { + if (mbFileImport) + save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), + aCkbQuotedAsText.IsChecked(), aRbFixed.IsChecked(), + aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos()); delete[] mpRowPosArray; } @@ -346,6 +480,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetFieldSeps( GetSeparators() ); rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() ); + rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) ); } } @@ -357,6 +492,10 @@ void ScImportAsciiDlg::SetTextToColumnsMode() aLbCharSet.Disable(); aFtRow.Disable(); aNfRow.Disable(); + + // Quoted field as text option is not used for text to columns mode. + aCkbQuotedAsText.Check(false); + aCkbQuotedAsText.Disable(); } void ScImportAsciiDlg::SetSelectedCharSet() @@ -393,6 +532,7 @@ void ScImportAsciiDlg::SetupSeparatorCtrls() aCkbOther.Enable( bEnable ); aEdOther.Enable( bEnable ); aCkbAsOnce.Enable( bEnable ); + aCkbQuotedAsText.Enable( bEnable ); aFtTextSep.Enable( bEnable ); aCbTextSep.Enable( bEnable ); } -- cgit v1.2.3 From a1bfe5a5d9abacf9e68f7b87d9b213d65efdbb75 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 27 Jul 2009 11:43:32 -0400 Subject: #i97416# initial porting of patches from ooo-build, to implement modified csv import option dialog. --- sc/source/core/tool/stringutil.cxx | 42 ++++++- sc/source/ui/dbgui/asciiopt.cxx | 38 +++++- sc/source/ui/dbgui/asciiopt.hrc | 72 ++++++----- sc/source/ui/dbgui/asciiopt.src | 231 +++++++++++++++++++++--------------- sc/source/ui/dbgui/scuiasciiopt.cxx | 65 ++++++++-- sc/source/ui/docshell/impex.cxx | 62 ++++++---- sc/source/ui/inc/asciiopt.hxx | 8 +- sc/source/ui/inc/scuiasciiopt.hxx | 9 ++ 8 files changed, 355 insertions(+), 172 deletions(-) (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx') diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx index e78c6edc88d7..28a4bc6755c2 100644 --- a/sc/source/core/tool/stringutil.cxx +++ b/sc/source/core/tool/stringutil.cxx @@ -35,6 +35,7 @@ #include "stringutil.hxx" #include "rtl/ustrbuf.hxx" +#include "rtl/math.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -42,17 +43,28 @@ using ::rtl::OUStringBuffer; bool ScStringUtil::parseSimpleNumber( const OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal) { + if (gsep == 0x00A0) + // unicode space to ascii space + gsep = 0x0020; + OUStringBuffer aBuf; sal_Int32 n = rStr.getLength(); const sal_Unicode* p = rStr.getStr(); sal_Int32 nPosDSep = -1, nPosGSep = -1; + sal_uInt32 nDigitCount = 0; + for (sal_Int32 i = 0; i < n; ++i) { sal_Unicode c = p[i]; + if (c == 0x00A0) + // unicode space to ascii space + c = 0x0020; + if (sal_Unicode('0') <= c && c <= sal_Unicode('9')) { // this is a digit. aBuf.append(c); + ++nDigitCount; } else if (c == dsep) { @@ -61,28 +73,35 @@ bool ScStringUtil::parseSimpleNumber( if (nPosDSep >= 0) // a second decimal separator -> not a valid number. return false; + if (nPosGSep >= 0 && i - nPosGSep != 4) // the number has a group separator and the decimal sep is not // positioned correctly. return false; nPosDSep = i; + nPosGSep = -1; aBuf.append(c); + nDigitCount = 0; } else if (c == gsep) { // this is a group (thousand) separator. + if (i == 0) + // not allowed as the first character. return false; - if (nPosGSep >= 0 && i - nPosGSep != 4) - { - // this group separator is not positioned correctly relative - // to the last group separator. + if (nPosDSep >= 0) + // not allowed after the decimal separator. + return false; + + if (nPosGSep >= 0 && nDigitCount != 3) + // must be exactly 3 digits since the last group separator. return false; - } nPosGSep = i; + nDigitCount = 0; } else if (c == sal_Unicode('-') || c == sal_Unicode('+')) { @@ -96,6 +115,17 @@ bool ScStringUtil::parseSimpleNumber( return false; } - rVal = aBuf.makeStringAndClear().toDouble(); + // finished parsing the number. + + if (nPosGSep >= 0 && nDigitCount != 3) + // must be exactly 3 digits since the last group separator. + return false; + + rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok; + sal_Int32 nParseEnd = 0; + rVal = ::rtl::math::stringToDouble(aBuf.makeStringAndClear(), dsep, gsep, &eStatus, &nParseEnd); + if (eStatus != rtl_math_ConversionStatus_Ok) + return false; + return true; } diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index fbe13bbd0370..8af7e3e97b06 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -57,8 +57,10 @@ ScAsciiOptions::ScAsciiOptions() : aFieldSeps ( ';' ), bMergeFieldSeps ( FALSE ), bQuotedFieldAsText(false), + bDetectSpecialNumber(false), cTextSep ( cDefaultTextSep ), eCharSet ( gsl_getSystemTextEncoding() ), + eLang ( LANGUAGE_SYSTEM ), bCharSetSystem ( FALSE ), nStartRow ( 1 ), nInfoCount ( 0 ), @@ -73,8 +75,10 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : aFieldSeps ( rOpt.aFieldSeps ), bMergeFieldSeps ( rOpt.bMergeFieldSeps ), bQuotedFieldAsText(rOpt.bQuotedFieldAsText), + bDetectSpecialNumber(rOpt.bDetectSpecialNumber), cTextSep ( rOpt.cTextSep ), eCharSet ( rOpt.eCharSet ), + eLang ( rOpt.eLang ), bCharSetSystem ( rOpt.bCharSetSystem ), nStartRow ( rOpt.nStartRow ), nInfoCount ( rOpt.nInfoCount ) @@ -252,13 +256,20 @@ void ScAsciiOptions::ReadFromString( const String& rString ) eCharSet = ScGlobal::GetCharsetValue( aToken ); } + // Language + if (nCount >= 4) + { + aToken = rString.GetToken(3, ','); + eLang = static_cast(aToken.ToInt32()); + } + // // Startzeile // - if ( nCount >= 4 ) + if ( nCount >= 5 ) { - aToken = rString.GetToken(3,','); + aToken = rString.GetToken(4,','); nStartRow = aToken.ToInt32(); } @@ -266,12 +277,12 @@ void ScAsciiOptions::ReadFromString( const String& rString ) // Spalten-Infos // - if ( nCount >= 5 ) + if ( nCount >= 6 ) { delete[] pColStart; delete[] pColFormat; - aToken = rString.GetToken(4,','); + aToken = rString.GetToken(5,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) @@ -292,11 +303,18 @@ void ScAsciiOptions::ReadFromString( const String& rString ) } // Import quoted field as text. - if (nCount >= 6) + if (nCount >= 7) { - aToken = rString.GetToken(5, ','); + aToken = rString.GetToken(6, ','); bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false; } + + // Detect special nubmers. + if (nCount >= 8) + { + aToken = rString.GetToken(7, ','); + bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false; + } } @@ -347,6 +365,10 @@ String ScAsciiOptions::WriteToString() const aOutStr += ScGlobal::GetCharsetString( eCharSet ); aOutStr += ','; // Token-Ende + // Language + aOutStr += String::CreateFromInt32(eLang); + aOutStr += ','; + // // Startzeile // @@ -372,6 +394,10 @@ String ScAsciiOptions::WriteToString() const // Import quoted field as text. aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false"); + aOutStr += ','; + + // Detect special nubmers. + aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false"); return aOutStr; } diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc index 3177a1be7b78..0264fd0fb4ec 100644 --- a/sc/source/ui/dbgui/asciiopt.hrc +++ b/sc/source/ui/dbgui/asciiopt.hrc @@ -29,32 +29,46 @@ ************************************************************************/ #include "sc.hrc" //#define RID_SCDLG_ASCII 256 -#define RB_SEPARATED 1 -#define RB_FIXED 2 -#define FT_CHARSET 3 -#define LB_CHARSET 4 -#define FL_SEPOPT 5 -#define FT_FIELDSEP 6 -#define CB_FIELDSEP 7 -#define FT_TEXTSEP 8 -#define CB_TEXTSEP 9 -#define FL_FIELDOPT 10 -#define FT_TYPE 12 -#define FT_PREVIEW 13 -#define LB_TYPE1 23 -#define FL_WIDTH 30 -#define BTN_OK 31 -#define BTN_CANCEL 32 -#define BTN_HELP 33 -#define CTR_TABLEBOX 41 -#define CKB_TAB 51 -#define CKB_SPACE 52 -#define CKB_SEMICOLON 53 -#define CKB_COMMA 54 -#define CKB_OTHER 55 -#define ED_OTHER 56 -#define FT_AT_ROW 59 -#define NF_AT_ROW 60 -#define CB_ASONCE 90 -#define CB_QUOTED_AS_TEXT 91 -#define STR_TEXTTOCOLUMNS 100 +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 + +#define FL_FIELDOPT 4 +#define FT_CHARSET 5 +#define LB_CHARSET 6 +#define FT_CUSTOMLANG 7 +#define LB_CUSTOMLANG 8 +#define FT_AT_ROW 9 +#define NF_AT_ROW 10 + +#define FL_SEPOPT 11 +#define RB_FIXED 12 +#define RB_SEPARATED 13 +#define CKB_TAB 14 +#define CKB_COMMA 15 +#define CKB_OTHER 16 +#define ED_OTHER 17 +#define CKB_SEMICOLON 18 +#define CKB_SPACE 19 +#define CB_ASONCE 20 +#define CB_TEXTSEP 21 +#define FT_TEXTSEP 22 + +#define FL_OTHER_OPTIONS 23 +#define CB_QUOTED_AS_TEXT 24 +#define CB_DETECT_SPECIAL_NUMBER 25 + +#define FL_WIDTH 26 +#define FT_TYPE 27 +#define LB_TYPE1 28 +#define CTR_TABLEBOX 29 +#define STR_TEXTTOCOLUMNS 30 + + + + + + + + + diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src index a510471bb799..57c338f0f70d 100644 --- a/sc/source/ui/dbgui/asciiopt.src +++ b/sc/source/ui/dbgui/asciiopt.src @@ -34,55 +34,44 @@ ModalDialog RID_SCDLG_ASCII { OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 320 , 264 ) ; + Size = MAP_APPFONT ( 320 , 305 ) ; Text [ en-US ] = "Text Import" ; Moveable = TRUE ; - FixedLine FL_WIDTH - { - Pos = MAP_APPFONT ( 6 , 147 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Fields" ; - }; - FixedText FT_TYPE - { - Pos = MAP_APPFONT ( 12 , 160 ) ; - Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "Column t~ype"; - }; - ListBox LB_TYPE1 + + OKButton BTN_OK { - Pos = MAP_APPFONT ( 76 , 158 ) ; - Size = MAP_APPFONT ( 60 , 68 ) ; + Pos = MAP_APPFONT ( 264 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; - DropDown = TRUE ; + DefButton = TRUE ; }; - FixedLine FL_SEPOPT + CancelButton BTN_CANCEL { - Pos = MAP_APPFONT ( 6 , 48 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Separator options" ; + Pos = MAP_APPFONT ( 264 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; }; - RadioButton RB_FIXED + HelpButton BTN_HELP { - Pos = MAP_APPFONT ( 12 , 59 ) ; - Size = MAP_APPFONT ( 243 , 10 ) ; - Text [ en-US ] = "~Fixed width" ; + Pos = MAP_APPFONT ( 264 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; - RadioButton RB_SEPARATED + + FixedLine FL_FIELDOPT { - Pos = MAP_APPFONT ( 12 , 73 ) ; - Size = MAP_APPFONT ( 243 , 10 ) ; - Text [ en-US ] = "~Separated by" ; - TabStop = TRUE ; - Check = TRUE ; + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Import" ; }; + FixedText FT_CHARSET { Pos = MAP_APPFONT ( 12 , 16 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; Text [ en-US ] = "Ch~aracter set" ; }; + ListBox LB_CHARSET { Pos = MAP_APPFONT ( 76 , 14 ) ; @@ -91,75 +80,81 @@ ModalDialog RID_SCDLG_ASCII DropDown = TRUE ; Sort = TRUE; }; - FixedLine FL_FIELDOPT - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 252 , 8 ) ; - Text [ en-US ] = "Import" ; - }; - FixedText FT_TEXTSEP + + FixedText FT_CUSTOMLANG { - Pos = MAP_APPFONT ( 156 , 114 ) ; + Pos = MAP_APPFONT ( 12 , 32 ) ; Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "Te~xt delimiter" ; + Text [ en-US ] = "Language" ; }; - ComboBox CB_TEXTSEP + + ListBox LB_CUSTOMLANG { - Pos = MAP_APPFONT ( 218 , 112 ) ; - Size = MAP_APPFONT ( 37 , 94 ) ; + Pos = MAP_APPFONT ( 76 , 30 ) ; + Size = MAP_APPFONT ( 130 , 61 ) ; TabStop = TRUE ; DropDown = TRUE ; + Sort = TRUE; }; - OKButton BTN_OK + + FixedText FT_AT_ROW { - Pos = MAP_APPFONT ( 264 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; + Pos = MAP_APPFONT ( 12 , 48 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "From ro~w" ; }; - CancelButton BTN_CANCEL + + NumericField NF_AT_ROW { - Pos = MAP_APPFONT ( 264 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 76 , 46 ) ; + Size = MAP_APPFONT ( 30 , 12 ) ; TabStop = TRUE ; + Spin = TRUE ; + Repeat = TRUE ; + Minimum = 1 ; }; - HelpButton BTN_HELP + + FixedLine FL_SEPOPT { - Pos = MAP_APPFONT ( 264 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; + Pos = MAP_APPFONT ( 6 , 63 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Separator options" ; }; - CheckBox CKB_TAB + RadioButton RB_FIXED { - Pos = MAP_APPFONT ( 20 , 86 ) ; - Size = MAP_APPFONT ( 68 , 10 ) ; + Pos = MAP_APPFONT ( 12 , 75 ) ; + Size = MAP_APPFONT ( 243 , 10 ) ; + Text [ en-US ] = "~Fixed width" ; TabStop = TRUE ; - Text [ en-US ] = "~Tab" ; }; - CheckBox CKB_SEMICOLON + RadioButton RB_SEPARATED { - Pos = MAP_APPFONT ( 20 , 99 ) ; - Size = MAP_APPFONT ( 68 , 10 ) ; + Pos = MAP_APPFONT ( 12 , 89 ) ; + Size = MAP_APPFONT ( 243 , 10 ) ; + Text [ en-US ] = "~Separated by" ; TabStop = TRUE ; - Text [ en-US ] = "S~emicolon" ; + Check = TRUE ; }; - CheckBox CKB_COMMA + + CheckBox CKB_TAB { - Pos = MAP_APPFONT ( 92 , 86 ) ; + Pos = MAP_APPFONT ( 20 , 102 ) ; Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "~Comma" ; + Text [ en-US ] = "~Tab" ; }; - CheckBox CKB_SPACE + CheckBox CKB_COMMA { - Pos = MAP_APPFONT ( 92 , 99 ) ; + Pos = MAP_APPFONT ( 92 , 102 ) ; Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "S~pace" ; + Text [ en-US ] = "~Comma" ; }; CheckBox CKB_OTHER { - Pos = MAP_APPFONT ( 164 , 86 ) ; + Pos = MAP_APPFONT ( 164 , 102 ) ; Size = MAP_APPFONT ( 50 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Other" ; @@ -167,50 +162,100 @@ ModalDialog RID_SCDLG_ASCII Edit ED_OTHER { Border = TRUE ; - Pos = MAP_APPFONT ( 218 , 84 ) ; + Pos = MAP_APPFONT ( 218 , 100 ) ; Size = MAP_APPFONT ( 37 , 12 ) ; TabStop = TRUE ; MaxTextLength = 10 ; }; - FixedText FT_AT_ROW - { - Pos = MAP_APPFONT ( 12 , 32 ) ; - Size = MAP_APPFONT ( 60 , 8 ) ; - Text [ en-US ] = "From ro~w" ; - }; - NumericField NF_AT_ROW + + CheckBox CKB_SEMICOLON { - Border = TRUE ; - SVLook = TRUE ; - Pos = MAP_APPFONT ( 76 , 30 ) ; - Size = MAP_APPFONT ( 30 , 12 ) ; + Pos = MAP_APPFONT ( 20 , 115 ) ; + Size = MAP_APPFONT ( 68 , 10 ) ; TabStop = TRUE ; - Spin = TRUE ; - Repeat = TRUE ; - Minimum = 1 ; + Text [ en-US ] = "S~emicolon" ; }; - Control CTR_TABLEBOX + CheckBox CKB_SPACE { - HelpId = HID_SC_ASCII_TABCTR ; - Border = TRUE ; - DialogControl = TRUE ; - Pos = MAP_APPFONT ( 12 , 176 ) ; - Size = MAP_APPFONT ( 243 , 82 ) ; + Pos = MAP_APPFONT ( 92 , 115 ) ; + Size = MAP_APPFONT ( 68 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "S~pace" ; }; + CheckBox CB_ASONCE { - Pos = MAP_APPFONT ( 20 , 114 ) ; + Pos = MAP_APPFONT ( 20 , 130 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Merge ~delimiters" ; }; + + ComboBox CB_TEXTSEP + { + Pos = MAP_APPFONT ( 218 , 128 ) ; + Size = MAP_APPFONT ( 37 , 94 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + FixedText FT_TEXTSEP + { + Pos = MAP_APPFONT ( 156 , 130 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Te~xt delimiter" ; + }; + + FixedLine FL_OTHER_OPTIONS + { + Pos = MAP_APPFONT ( 6 , 146 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Other options" ; + }; + CheckBox CB_QUOTED_AS_TEXT { - Pos = MAP_APPFONT ( 20 , 129 ) ; + Pos = MAP_APPFONT ( 20 , 158 ) ; Size = MAP_APPFONT ( 130 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Quoted field as text" ; }; + + CheckBox CB_DETECT_SPECIAL_NUMBER + { + Pos = MAP_APPFONT ( 20 , 171 ) ; + Size = MAP_APPFONT ( 130 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Detect special numbers" ; + }; + + FixedLine FL_WIDTH + { + Pos = MAP_APPFONT ( 6 , 187 ) ; + Size = MAP_APPFONT ( 252 , 8 ) ; + Text [ en-US ] = "Fields" ; + }; + FixedText FT_TYPE + { + Pos = MAP_APPFONT ( 12 , 200 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "Column t~ype"; + }; + ListBox LB_TYPE1 + { + Pos = MAP_APPFONT ( 76 , 198 ) ; + Size = MAP_APPFONT ( 60 , 68 ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + Control CTR_TABLEBOX + { + HelpId = HID_SC_ASCII_TABCTR ; + Border = TRUE ; + DialogControl = TRUE ; + Pos = MAP_APPFONT ( 12 , 216 ) ; + Size = MAP_APPFONT ( 243 , 82 ) ; + }; + String STR_TEXTTOCOLUMNS { Text [ en-US ] = "Text to Columns" ; diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 9d782347b5ea..0136e29ccc91 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -69,6 +69,8 @@ using namespace com::sun::star::uno; #define TEXT_SEPARATORS "TextSeparators" #define MERGE_DELIMITERS "MergeDelimiters" #define QUOTED_AS_TEXT "QuotedFieldAsText" +#define DETECT_SPECIAL_NUM "DetectSpecialNumbers" +#define LANGUAGE "Language" #define SEP_PATH "Office.Calc/Dialogs/CSVImport" // ============================================================================ @@ -119,12 +121,13 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) } static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, - bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth, - sal_Int32 &nFromRow, sal_Int32 &nCharSet ) + bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum, + bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet, + sal_Int32& nLanguage ) { SequenceaValues; const Any *pProperties; - Sequence aNames(7); + Sequence aNames(9); OUString* pNames = aNames.getArray(); ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); @@ -135,6 +138,8 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato pNames[4] = OUString::createFromAscii( FROM_ROW ); pNames[5] = OUString::createFromAscii( CHAR_SET ); pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM ); + pNames[8] = OUString::createFromAscii( LANGUAGE ); aValues = aItem.GetProperties( aNames ); pProperties = aValues.getConstArray(); if( pProperties[1].hasValue() ) @@ -157,16 +162,23 @@ static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparato if ( pProperties[6].hasValue() ) pProperties[6] >>= bQuotedAsText; + + if ( pProperties[7].hasValue() ) + pProperties[7] >>= bDetectSpecialNum; + + if ( pProperties[8].hasValue() ) + pProperties[8] >>= nLanguage; } -static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, - bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet ) +static void save_Separators( + String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText, + bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage ) { OUString sFieldSeparators = OUString( maSeparators ); OUString sTextSeparators = OUString( maTxtSep ); Sequence aValues; Any *pProperties; - Sequence aNames(7); + Sequence aNames(9); OUString* pNames = aNames.getArray(); ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) ); @@ -177,6 +189,8 @@ static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDe pNames[4] = OUString::createFromAscii( FROM_ROW ); pNames[5] = OUString::createFromAscii( CHAR_SET ); pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT ); + pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM ); + pNames[8] = OUString::createFromAscii( LANGUAGE ); aValues = aItem.GetProperties( aNames ); pProperties = aValues.getArray(); pProperties[1] <<= sFieldSeparators; @@ -186,6 +200,8 @@ static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDe pProperties[4] <<= nFromRow; pProperties[5] <<= nCharSet; pProperties[6] <<= static_cast(bQuotedAsText); + pProperties[7] <<= static_cast(bDetectSpecialNum); + pProperties[8] <<= nLanguage; aItem.PutProperties(aNames, aValues); } @@ -204,6 +220,8 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ), aFtCharSet ( this, ScResId( FT_CHARSET ) ), aLbCharSet ( this, ScResId( LB_CHARSET ) ), + aFtCustomLang( this, ScResId( FT_CUSTOMLANG ) ), + aLbCustomLang( this, ScResId( LB_CUSTOMLANG ) ), aFtRow ( this, ScResId( FT_AT_ROW ) ), aNfRow ( this, ScResId( NF_AT_ROW ) ), @@ -219,7 +237,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbOther ( this, ScResId( CKB_OTHER ) ), aEdOther ( this, ScResId( ED_OTHER ) ), aCkbAsOnce ( this, ScResId( CB_ASONCE) ), + aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), + aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), @@ -260,18 +281,22 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, bool bMergeDelimiters = false; bool bFixedWidth = false; bool bQuotedFieldAsText = true; + bool bDetectSpecialNum = false; sal_Int32 nFromRow = 1; sal_Int32 nCharSet = -1; + sal_Int32 nLanguage = 0; if (mbFileImport) // load separators only when importing csv files. load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, - bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet); + bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage); maFieldSeparators = String(sFieldSeparators); if( bMergeDelimiters ) aCkbAsOnce.Check(); if (bQuotedFieldAsText) aCkbQuotedAsText.Check(); + if (bDetectSpecialNum) + aCkbDetectNumber.Check(); if( bFixedWidth ) aRbFixed.Check(); if( nFromRow != 1 ) @@ -344,6 +369,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbComma.SetClickHdl( aSeparatorHdl ); aCkbAsOnce.SetClickHdl( aSeparatorHdl ); aCkbQuotedAsText.SetClickHdl( aSeparatorHdl ); + aCkbDetectNumber.SetClickHdl( aSeparatorHdl ); aCkbSpace.SetClickHdl( aSeparatorHdl ); aCkbOther.SetClickHdl( aSeparatorHdl ); aEdOther.SetModifyHdl( aSeparatorHdl ); @@ -363,6 +389,11 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); + aLbCustomLang.SetLanguageList( + LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false); + aLbCustomLang.InsertLanguage(LANGUAGE_SYSTEM); + aLbCustomLang.SelectLanguage(static_cast(nLanguage), true); + // *** column type ListBox *** xub_StrLen nCount = aColumnUser.GetTokenCount(); for (xub_StrLen i=0; i(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } @@ -473,6 +505,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetCharSet( meCharSet ); rOpt.SetCharSetSystem( mbCharSetSystem ); + rOpt.SetLanguage(aLbCustomLang.GetSelectLanguage()); rOpt.SetFixedLen( aRbFixed.IsChecked() ); rOpt.SetStartRow( (long)aNfRow.GetValue() ); maTableBox.FillColumnData( rOpt ); @@ -480,9 +513,11 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) { rOpt.SetFieldSeps( GetSeparators() ); rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() ); - rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) ); } + + rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked()); + rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked()); } void ScImportAsciiDlg::SetTextToColumnsMode() @@ -490,12 +525,19 @@ void ScImportAsciiDlg::SetTextToColumnsMode() SetText( maStrTextToColumns ); aFtCharSet.Disable(); aLbCharSet.Disable(); + aFtCustomLang.Disable(); + aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM); + aLbCustomLang.Disable(); aFtRow.Disable(); aNfRow.Disable(); - // Quoted field as text option is not used for text to columns mode. + // Quoted field as text option is not used for text-to-columns mode. aCkbQuotedAsText.Check(false); aCkbQuotedAsText.Disable(); + + // Always detect special numbers for text-to-columns mode. + aCkbDetectNumber.Check(); + aCkbDetectNumber.Disable(); } void ScImportAsciiDlg::SetSelectedCharSet() @@ -532,7 +574,6 @@ void ScImportAsciiDlg::SetupSeparatorCtrls() aCkbOther.Enable( bEnable ); aEdOther.Enable( bEnable ); aCkbAsOnce.Enable( bEnable ); - aCkbQuotedAsText.Enable( bEnable ); aFtTextSep.Enable( bEnable ); aCbTextSep.Enable( bEnable ); } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 288ad755cb52..5b70cf2f02ae 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -907,6 +907,7 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm ) static bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat, + SvNumberFormatter* pFormatter, bool bDetectNumFormat, ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar, ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar ) { @@ -924,10 +925,10 @@ static bool lcl_PutString( { //! SetString mit Extra-Flag ??? - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US); + SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable(); + sal_uInt32 nEnglish = pDocFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US); double fVal; - if ( pFormatter->IsNumberFormat( rStr, nEnglish, fVal ) ) + if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) ) { // Zahlformat wird nicht auf englisch gesetzt pDoc->SetValue( nCol, nRow, nTab, fVal ); @@ -1063,9 +1064,9 @@ static bool lcl_PutString( } } - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable(); if ( nYear < 100 ) - nYear = pFormatter->ExpandTwoDigitYear( nYear ); + nYear = pDocFormatter->ExpandTwoDigitYear( nYear ); CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar); sal_Int16 nNumMonths = pCalendar->getNumberOfMonthsInYear(); @@ -1101,7 +1102,7 @@ static bool lcl_PutString( pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli ); if ( pCalendar->isValid() ) { - double fDiff = DateTime(*pFormatter->GetNullDate()) - + double fDiff = DateTime(*pDocFormatter->GetNullDate()) - pCalendar->getEpochStart(); // #i14974# must use getLocalDateTime to get the same // date values as set above @@ -1113,10 +1114,10 @@ static bool lcl_PutString( LanguageType eDocLang = eLatin; //! which language for date formats? short nType = (nFound > 3 ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE); - ULONG nFormat = pFormatter->GetStandardFormat( nType, eDocLang ); + ULONG nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang ); // maybe there is a special format including seconds or milliseconds if (nFound > 5) - nFormat = pFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang); + nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang); pDoc->PutCell( nCol, nRow, nTab, new ScValueCell(fDays), nFormat, FALSE ); @@ -1128,7 +1129,7 @@ static bool lcl_PutString( // Standard or date not determined -> SetString / EditCell if( rStr.Search( _LF ) == STRING_NOTFOUND ) - pDoc->SetString( nCol, nRow, nTab, rStr ); + pDoc->SetString( nCol, nRow, nTab, rStr, pFormatter, bDetectNumFormat ); else { bMultiLine = true; @@ -1138,7 +1139,7 @@ static bool lcl_PutString( } -String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext ) +String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext, bool& rbIsQuoted ) { xub_StrLen nLen = rLine.Len(); if (nNext > nLen) @@ -1152,7 +1153,11 @@ String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext ) while ( nSpace > nStart && pStr[nSpace-1] == ' ' ) --nSpace; - return rLine.Copy( nStart, nSpace-nStart ); + rbIsQuoted = (pStr[nStart] == sal_Unicode('"') && pStr[nSpace-1] == sal_Unicode('"')); + if (rbIsQuoted) + return rLine.Copy(nStart+1, nSpace-nStart-2); + else + return rLine.Copy(nStart, nSpace-nStart); } BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) @@ -1185,9 +1190,9 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) const BYTE* pColFormat = pExtOptions->GetColFormat(); long nSkipLines = pExtOptions->GetStartRow(); - LanguageType eLatin, eCjk, eCtl; - pDoc->GetLanguage( eLatin, eCjk, eCtl ); - LanguageType eDocLang = eLatin; //! which language for date formats? + LanguageType eDocLang = pExtOptions->GetLanguage(); + SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eDocLang); + bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber(); // For date recognition ::utl::TransliterationWrapper aTransliteration( @@ -1229,6 +1234,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // survives the toggle of bDetermineRange down at the end of the do{} loop. bool bRangeIsDetermined = bDetermineRange; + bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText(); + ULONG nOriginalStreamPos = rStrm.Tell(); do @@ -1250,7 +1257,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) // SC_COL_SKIP. for ( i=0; i MAXCOL) bOverflow = TRUE; // display warning on import @@ -1258,11 +1266,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) { xub_StrLen nStart = pColStart[i]; xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen; - aCell = lcl_GetFixed( aLine, nStart, nNext ); - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, - nTab, aCell, pColFormat[i], - aTransliteration, aCalendar, - pEnglishTransliteration, pEnglishCalendar); + bool bIsQuoted = false; + aCell = lcl_GetFixed( aLine, nStart, nNext, bIsQuoted ); + if (bIsQuoted && bQuotedAsText) + nFmt = SC_COL_TEXT; + + bMultiLine |= lcl_PutString( + pDoc, nCol, nRow, nTab, aCell, nFmt, + &aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar, + pEnglishTransliteration, pEnglishCalendar); } ++nCol; } @@ -1298,13 +1310,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) bOverflow = TRUE; // display warning on import else if (!bDetermineRange) { - if (bIsQuoted && pExtOptions && pExtOptions->IsQuotedAsText()) + if (bIsQuoted && bQuotedAsText) nFmt = SC_COL_TEXT; - bMultiLine |= lcl_PutString( pDoc, nCol, nRow, - nTab, aCell, nFmt, aTransliteration, - aCalendar, pEnglishTransliteration, - pEnglishCalendar); + bMultiLine |= lcl_PutString( + pDoc, nCol, nRow, nTab, aCell, nFmt, + &aNumFormatter, bDetectNumFormat, aTransliteration, + aCalendar, pEnglishTransliteration, pEnglishCalendar); } ++nCol; } diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx index 40c95f0f0702..54885eae2ccd 100644 --- a/sc/source/ui/inc/asciiopt.hxx +++ b/sc/source/ui/inc/asciiopt.hxx @@ -55,7 +55,7 @@ #include #include #include "csvtablebox.hxx" - +#include "i18npool/lang.h" // ============================================================================ @@ -66,8 +66,10 @@ private: String aFieldSeps; BOOL bMergeFieldSeps; bool bQuotedFieldAsText; + bool bDetectSpecialNumber; sal_Unicode cTextSep; CharSet eCharSet; + LanguageType eLang; BOOL bCharSetSystem; long nStartRow; USHORT nInfoCount; @@ -95,12 +97,14 @@ public: const String& GetFieldSeps() const { return aFieldSeps; } BOOL IsMergeSeps() const { return bMergeFieldSeps; } bool IsQuotedAsText() const { return bQuotedFieldAsText; } + bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; } sal_Unicode GetTextSep() const { return cTextSep; } BOOL IsFixedLen() const { return bFixedLen; } USHORT GetInfoCount() const { return nInfoCount; } const xub_StrLen* GetColStart() const { return pColStart; } const BYTE* GetColFormat() const { return pColFormat; } long GetStartRow() const { return nStartRow; } + LanguageType GetLanguage() const { return eLang; } void SetCharSet( CharSet eNew ) { eCharSet = eNew; } void SetCharSetSystem( BOOL bSet ) { bCharSetSystem = bSet; } @@ -108,8 +112,10 @@ public: void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; } void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; } void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } + void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; } void SetTextSep( sal_Unicode c ) { cTextSep = c; } void SetStartRow( long nRow) { nStartRow= nRow; } + void SetLanguage(LanguageType e) { eLang = e; } void SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat ); void SetColumnInfo( const ScCsvExpDataVec& rDataVec ); diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 33bc48b7122a..82963d2904af 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -35,6 +35,8 @@ #include "asciiopt.hxx" +#include "svx/langbox.hxx" + // ============================================================================ class ScImportAsciiDlg : public ModalDialog @@ -49,6 +51,8 @@ class ScImportAsciiDlg : public ModalDialog FixedLine aFlFieldOpt; FixedText aFtCharSet; SvxTextEncodingBox aLbCharSet; + FixedText aFtCustomLang; + SvxLanguageBox aLbCustomLang; FixedText aFtRow; NumericField aNfRow; @@ -64,7 +68,12 @@ class ScImportAsciiDlg : public ModalDialog CheckBox aCkbOther; Edit aEdOther; CheckBox aCkbAsOnce; + + FixedLine aFlOtherOpt; + CheckBox aCkbQuotedAsText; + CheckBox aCkbDetectNumber; + FixedText aFtTextSep; ComboBox aCbTextSep; -- cgit v1.2.3 From b64c9b3602f3b603d57acff8549859212374ede2 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 20 Jan 2010 09:41:47 -0500 Subject: koheicsvimport: more static_cast's to keep MSVC compiler happy. --- sc/source/ui/dbgui/scuiasciiopt.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx') diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 2b244d378197..40fc410ec47c 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -384,7 +384,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() ); if( nCharSet >= 0 ) - aLbCharSet.SelectEntryPos( nCharSet ); + aLbCharSet.SelectEntryPos( static_cast(nCharSet) ); SetSelectedCharSet(); aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) ); @@ -425,7 +425,9 @@ ScImportAsciiDlg::~ScImportAsciiDlg() if (mbFileImport) save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), - aRbFixed.IsChecked(), aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos(), + aRbFixed.IsChecked(), + static_cast(aNfRow.GetValue()), + static_cast(aLbCharSet.GetSelectEntryPos()), static_cast(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } -- cgit v1.2.3 From 83ccb404e2829cba98cf0bb1290da489fd1f4c6c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 25 Jan 2010 15:57:05 -0500 Subject: koheicsvimport: #i108645# Store the dialog parameters only when the OK is pressed. --- sc/inc/scabstdlg.hxx | 1 + sc/source/ui/attrdlg/scdlgfact.cxx | 5 +++++ sc/source/ui/attrdlg/scdlgfact.hxx | 1 + sc/source/ui/dbgui/scuiasciiopt.cxx | 21 ++++++++++++++------- sc/source/ui/inc/scuiasciiopt.hxx | 1 + sc/source/ui/unoobj/filtuno.cxx | 1 + 6 files changed, 23 insertions(+), 7 deletions(-) (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx') diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 98ec2b6b5a71..824761804349 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -69,6 +69,7 @@ class AbstractScImportAsciiDlg : public VclAbstractDialog //add for ScImportAsc public: virtual void GetOptions( ScAsciiOptions& rOpt ) = 0; virtual void SetTextToColumnsMode() = 0; + virtual void SaveParameters() = 0; }; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index d52a1f653c5c..66abfa79116e 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -198,6 +198,11 @@ void AbstractScImportAsciiDlg_Impl::SetTextToColumnsMode() pDlg->SetTextToColumnsMode(); } +void AbstractScImportAsciiDlg_Impl::SaveParameters() +{ + pDlg->SaveParameters(); +} + // AbstractScImportAsciiDlg_Impl end //AbstractScAutoFormatDlg_Impl begin diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index f9d06360d36c..36b7d89cceba 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -120,6 +120,7 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg //add for DECL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl, ScImportAsciiDlg) virtual void GetOptions( ScAsciiOptions& rOpt ); virtual void SetTextToColumnsMode(); + virtual void SaveParameters(); }; class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg //add for ScAutoFormatDlg diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 40fc410ec47c..244b2e785a72 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -422,13 +422,6 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, ScImportAsciiDlg::~ScImportAsciiDlg() { - if (mbFileImport) - save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), - aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), - aRbFixed.IsChecked(), - static_cast(aNfRow.GetValue()), - static_cast(aLbCharSet.GetSelectEntryPos()), - static_cast(aLbCustomLang.GetSelectLanguage()) ); delete[] mpRowPosArray; } @@ -542,6 +535,20 @@ void ScImportAsciiDlg::SetTextToColumnsMode() aCkbDetectNumber.Disable(); } +void ScImportAsciiDlg::SaveParameters() +{ + if (!mbFileImport) + // We save parameters only for file import. + return; + + save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), + aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(), + aRbFixed.IsChecked(), + static_cast(aNfRow.GetValue()), + static_cast(aLbCharSet.GetSelectEntryPos()), + static_cast(aLbCustomLang.GetSelectLanguage()) ); +} + void ScImportAsciiDlg::SetSelectedCharSet() { meCharSet = aLbCharSet.GetSelectTextEncoding(); diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 82963d2904af..73dac06a3ed8 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -107,6 +107,7 @@ public: void GetOptions( ScAsciiOptions& rOpt ); void SetTextToColumnsMode(); + void SaveParameters(); private: /** Sets the selected char set data to meCharSet and mbCharSetSystem. */ diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index c8248b754708..90c86bca0cfb 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -179,6 +179,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException) { ScAsciiOptions aOptions; pDlg->GetOptions( aOptions ); + pDlg->SaveParameters(); aFilterOptions = aOptions.WriteToString(); nRet = ui::dialogs::ExecutableDialogResults::OK; } -- cgit v1.2.3 From 0deefb5d0a6eec79a49602fa02d3dce46231a90a Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 29 Jan 2010 13:21:33 -0500 Subject: koheicsvimport: #i108756# Fixed the tab order of controls in the CSV options dialog. --- sc/source/ui/dbgui/scuiasciiopt.cxx | 5 +++-- sc/source/ui/inc/scuiasciiopt.hxx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx') diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 244b2e785a72..a2cf247fda84 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -239,11 +239,12 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, aCkbAsOnce ( this, ScResId( CB_ASONCE) ), aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ), - aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), - aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), aFtTextSep ( this, ScResId( FT_TEXTSEP ) ), aCbTextSep ( this, ScResId( CB_TEXTSEP ) ), + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ), + aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ), + aFlWidth ( this, ScResId( FL_WIDTH ) ), aFtType ( this, ScResId( FT_TYPE ) ), aLbType ( this, ScResId( LB_TYPE1 ) ), diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx index 73dac06a3ed8..1a8086488043 100644 --- a/sc/source/ui/inc/scuiasciiopt.hxx +++ b/sc/source/ui/inc/scuiasciiopt.hxx @@ -71,12 +71,12 @@ class ScImportAsciiDlg : public ModalDialog FixedLine aFlOtherOpt; - CheckBox aCkbQuotedAsText; - CheckBox aCkbDetectNumber; - FixedText aFtTextSep; ComboBox aCbTextSep; + CheckBox aCkbQuotedAsText; + CheckBox aCkbDetectNumber; + FixedLine aFlWidth; FixedText aFtType; ListBox aLbType; -- cgit v1.2.3