summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2009-07-27 11:43:32 -0400
committerKohei Yoshida <kyoshida@novell.com>2009-07-27 11:43:32 -0400
commita1bfe5a5d9abacf9e68f7b87d9b213d65efdbb75 (patch)
tree7a22f121ebea7cb326e0dffd30b63f94591ad33c /sc/source/ui
parentb559137b68a273ef543711995ebf4f140cfe9149 (diff)
#i97416# initial porting of patches from ooo-build, to implement modified
csv import option dialog.
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx38
-rw-r--r--sc/source/ui/dbgui/asciiopt.hrc72
-rw-r--r--sc/source/ui/dbgui/asciiopt.src231
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx65
-rw-r--r--sc/source/ui/docshell/impex.cxx62
-rw-r--r--sc/source/ui/inc/asciiopt.hxx8
-rw-r--r--sc/source/ui/inc/scuiasciiopt.hxx9
7 files changed, 319 insertions, 166 deletions
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<LanguageType>(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 )
{
Sequence<Any>aValues;
const Any *pProperties;
- Sequence<OUString> aNames(7);
+ Sequence<OUString> 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<Any> aValues;
Any *pProperties;
- Sequence<OUString> aNames(7);
+ Sequence<OUString> 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<sal_Bool>(bQuotedAsText);
+ pProperties[7] <<= static_cast<sal_Bool>(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<LanguageType>(nLanguage), true);
+
// *** column type ListBox ***
xub_StrLen nCount = aColumnUser.GetTokenCount();
for (xub_StrLen i=0; i<nCount; i++)
@@ -393,8 +424,9 @@ ScImportAsciiDlg::~ScImportAsciiDlg()
{
if (mbFileImport)
save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
- aCkbQuotedAsText.IsChecked(), aRbFixed.IsChecked(),
- aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos());
+ aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(),
+ aRbFixed.IsChecked(), aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos(),
+ static_cast<sal_Int32>(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<nInfoCount && nCol <= MAXCOL+1; i++ )
{
- if ( pColFormat[i] != SC_COL_SKIP ) // sonst auch nCol nicht hochzaehlen
+ BYTE nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // sonst auch nCol nicht hochzaehlen
{
if (nCol > 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 <tools/stream.hxx>
#include <svx/txencbox.hxx>
#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;