Fixed for i#103021
[ooovba.git] / applied_patches / 0130-csv-import-preserve-options-sc.diff
blob05709916a08668c6c2670c0fed39df82c0edc7d4
1 diff --git sc/source/ui/dbgui/asciiopt.cxx sc/source/ui/dbgui/asciiopt.cxx
2 index bf6521e..df25128 100644
3 --- sc/source/ui/dbgui/asciiopt.cxx
4 +++ sc/source/ui/dbgui/asciiopt.cxx
5 @@ -56,6 +56,7 @@ ScAsciiOptions::ScAsciiOptions() :
6 bFixedLen ( FALSE ),
7 aFieldSeps ( ';' ),
8 bMergeFieldSeps ( FALSE ),
9 + bQuotedFieldAsText(false),
10 cTextSep ( cDefaultTextSep ),
11 eCharSet ( gsl_getSystemTextEncoding() ),
12 bCharSetSystem ( FALSE ),
13 @@ -71,6 +72,7 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) :
14 bFixedLen ( rOpt.bFixedLen ),
15 aFieldSeps ( rOpt.aFieldSeps ),
16 bMergeFieldSeps ( rOpt.bMergeFieldSeps ),
17 + bQuotedFieldAsText(rOpt.bQuotedFieldAsText),
18 cTextSep ( rOpt.cTextSep ),
19 eCharSet ( rOpt.eCharSet ),
20 bCharSetSystem ( rOpt.bCharSetSystem ),
21 @@ -155,6 +157,7 @@ ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy )
22 bFixedLen = rCpy.bFixedLen;
23 aFieldSeps = rCpy.aFieldSeps;
24 bMergeFieldSeps = rCpy.bMergeFieldSeps;
25 + bQuotedFieldAsText = rCpy.bQuotedFieldAsText;
26 cTextSep = rCpy.cTextSep;
27 eCharSet = rCpy.eCharSet;
28 bCharSetSystem = rCpy.bCharSetSystem;
29 @@ -169,6 +172,7 @@ BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const
30 if ( bFixedLen == rCmp.bFixedLen &&
31 aFieldSeps == rCmp.aFieldSeps &&
32 bMergeFieldSeps == rCmp.bMergeFieldSeps &&
33 + bQuotedFieldAsText == rCmp.bQuotedFieldAsText &&
34 cTextSep == rCmp.cTextSep &&
35 eCharSet == rCmp.eCharSet &&
36 bCharSetSystem == rCmp.bCharSetSystem &&
37 @@ -286,6 +290,13 @@ void ScAsciiOptions::ReadFromString( const String& rString )
38 pColFormat = NULL;
42 + // Import quoted field as text.
43 + if (nCount >= 6)
44 + {
45 + aToken = rString.GetToken(5, ',');
46 + bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false;
47 + }
51 @@ -357,6 +368,11 @@ String ScAsciiOptions::WriteToString() const
52 aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
55 + aOutStr += ',';
57 + // Import quoted field as text.
58 + aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false");
60 return aOutStr;
63 diff --git sc/source/ui/dbgui/asciiopt.hrc sc/source/ui/dbgui/asciiopt.hrc
64 index 2dcfe00..60c8500 100644
65 --- sc/source/ui/dbgui/asciiopt.hrc
66 +++ sc/source/ui/dbgui/asciiopt.hrc
67 @@ -56,4 +56,5 @@
68 #define FT_AT_ROW 59
69 #define NF_AT_ROW 60
70 #define CB_ASONCE 90
71 +#define CB_QUOTED_AS_TEXT 91
72 #define STR_TEXTTOCOLUMNS 100
73 diff --git sc/source/ui/dbgui/asciiopt.src sc/source/ui/dbgui/asciiopt.src
74 index e6cc493..da10a39 100644
75 --- sc/source/ui/dbgui/asciiopt.src
76 +++ sc/source/ui/dbgui/asciiopt.src
77 @@ -34,24 +34,24 @@ ModalDialog RID_SCDLG_ASCII
79 OutputSize = TRUE ;
80 SVLook = TRUE ;
81 - Size = MAP_APPFONT ( 320 , 247 ) ;
82 + Size = MAP_APPFONT ( 320 , 264 ) ;
83 Text [ en-US ] = "Text Import" ;
84 Moveable = TRUE ;
85 FixedLine FL_WIDTH
87 - Pos = MAP_APPFONT ( 6 , 132 ) ;
88 + Pos = MAP_APPFONT ( 6 , 147 ) ;
89 Size = MAP_APPFONT ( 252 , 8 ) ;
90 Text [ en-US ] = "Fields" ;
92 FixedText FT_TYPE
94 - Pos = MAP_APPFONT ( 12 , 145 ) ;
95 + Pos = MAP_APPFONT ( 12 , 160 ) ;
96 Size = MAP_APPFONT ( 60 , 8 ) ;
97 Text [ en-US ] = "Column t~ype";
99 ListBox LB_TYPE1
101 - Pos = MAP_APPFONT ( 76 , 143 ) ;
102 + Pos = MAP_APPFONT ( 76 , 158 ) ;
103 Size = MAP_APPFONT ( 60 , 68 ) ;
104 TabStop = TRUE ;
105 DropDown = TRUE ;
106 @@ -194,7 +194,7 @@ ModalDialog RID_SCDLG_ASCII
107 HelpId = HID_SC_ASCII_TABCTR ;
108 Border = TRUE ;
109 DialogControl = TRUE ;
110 - Pos = MAP_APPFONT ( 12 , 159 ) ;
111 + Pos = MAP_APPFONT ( 12 , 176 ) ;
112 Size = MAP_APPFONT ( 243 , 82 ) ;
114 CheckBox CB_ASONCE
115 @@ -204,6 +204,13 @@ ModalDialog RID_SCDLG_ASCII
116 TabStop = TRUE ;
117 Text [ en-US ] = "Merge ~delimiters" ;
119 + CheckBox CB_QUOTED_AS_TEXT
121 + Pos = MAP_APPFONT ( 20 , 129 ) ;
122 + Size = MAP_APPFONT ( 130 , 10 ) ;
123 + TabStop = TRUE ;
124 + Text [ en-US ] = "~Quoted field as text" ;
125 + };
126 String STR_TEXTTOCOLUMNS
128 Text [ en-US ] = "Text to Columns" ;
129 diff --git sc/source/ui/dbgui/csvgrid.cxx sc/source/ui/dbgui/csvgrid.cxx
130 index ddbfb44..5725645 100644
131 --- sc/source/ui/dbgui/csvgrid.cxx
132 +++ sc/source/ui/dbgui/csvgrid.cxx
133 @@ -737,7 +737,8 @@ void ScCsvGrid::ImplSetTextLineSep(
134 while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
136 // scan for next cell text
137 - pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep );
138 + bool bIsQuoted = false;
139 + pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted );
141 // update column width
142 sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
143 diff --git sc/source/ui/dbgui/csvruler.cxx sc/source/ui/dbgui/csvruler.cxx
144 index 5437f9b..b42ebaf 100644
145 --- sc/source/ui/dbgui/csvruler.cxx
146 +++ sc/source/ui/dbgui/csvruler.cxx
147 @@ -37,8 +37,76 @@
148 #include "AccessibleCsvControl.hxx"
151 +#include <optutil.hxx>
152 +#include <com/sun/star/uno/Any.hxx>
153 +#include <com/sun/star/uno/Sequence.hxx>
154 +#include "miscuno.hxx"
156 +using namespace rtl;
157 +using namespace com::sun::star::uno;
161 +// ============================================================================
162 +#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
163 +#define FIXED_WIDTH_LIST "FixedWidthList"
166 // ============================================================================
168 +static void load_FixedWidthList(ScCsvSplits &aSplits)
170 + String sSplits;
171 + OUString sFixedWidthLists;
173 + Sequence<Any>aValues;
174 + const Any *pProperties;
175 + Sequence<OUString> aNames(1);
176 + OUString* pNames = aNames.getArray();
177 + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
179 + pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
180 + aValues = aItem.GetProperties( aNames );
181 + pProperties = aValues.getConstArray();
183 + if( pProperties[0].hasValue() )
185 + aSplits.Clear();
186 + pProperties[0] >>= sFixedWidthLists;
188 + sSplits = String( sFixedWidthLists );
190 + // String ends with a semi-colon so there is no 'int' after the last one.
191 + for(int i=0;i<sSplits.GetTokenCount()-1;i++ )
192 + aSplits.Insert( sSplits.GetToken(i).ToInt32() );
195 +static void save_FixedWidthList(ScCsvSplits aSplits)
197 + String sSplits;
198 + // Create a semi-colon separated string to save the splits
199 + sal_uInt32 n = aSplits.Count();
200 + for (sal_uInt32 i = 0; i < n; ++i)
202 + sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
203 + sSplits.Append((char)';');
206 + OUString sFixedWidthLists = OUString( sSplits );
207 + Sequence<Any> aValues;
208 + Any *pProperties;
209 + Sequence<OUString> aNames(1);
210 + OUString* pNames = aNames.getArray();
211 + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
213 + pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
214 + aValues = aItem.GetProperties( aNames );
215 + pProperties = aValues.getArray();
216 + pProperties[0] <<= sFixedWidthLists;
218 + aItem.PutProperties(aNames, aValues);
221 ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
222 ScCsvControl( rParent ),
223 mnPosCursorLast( 1 )
224 @@ -48,6 +116,13 @@ ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
225 InitSizeData();
226 maBackgrDev.SetFont( GetFont() );
227 maRulerDev.SetFont( GetFont() );
229 + load_FixedWidthList( maSplits );
232 +ScCsvRuler::~ScCsvRuler()
234 + save_FixedWidthList( maSplits );
238 diff --git sc/source/ui/dbgui/scuiasciiopt.cxx sc/source/ui/dbgui/scuiasciiopt.cxx
239 index 2c31e08..a10e8fb 100644
240 --- sc/source/ui/dbgui/scuiasciiopt.cxx
241 +++ sc/source/ui/dbgui/scuiasciiopt.cxx
242 @@ -44,6 +44,12 @@
243 // ause
244 #include "editutil.hxx"
246 +#include <optutil.hxx>
247 +#include <com/sun/star/uno/Any.hxx>
248 +#include <com/sun/star/uno/Sequence.hxx>
249 +#include "miscuno.hxx"
252 //! TODO make dynamic
253 #ifdef WIN
254 const SCSIZE ASCIIDLG_MAXROWS = 10000;
255 @@ -51,6 +57,20 @@ const SCSIZE ASCIIDLG_MAXROWS = 10000;
256 const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT;
257 #endif
260 +using namespace rtl;
261 +using namespace com::sun::star::uno;
263 +// Defines - CSV Import Preserve Options
264 +#define FIXED_WIDTH "FixedWidth"
265 +#define FROM_ROW "FromRow"
266 +#define CHAR_SET "CharSet"
267 +#define SEPARATORS "Separators"
268 +#define TEXT_SEPARATORS "TextSeparators"
269 +#define MERGE_DELIMITERS "MergeDelimiters"
270 +#define QUOTED_AS_TEXT "QuotedFieldAsText"
271 +#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
273 // ============================================================================
275 void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
276 @@ -98,11 +118,82 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList )
277 return c;
280 +static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators,
281 + bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth,
282 + sal_Int32 &nFromRow, sal_Int32 &nCharSet )
284 + Sequence<Any>aValues;
285 + const Any *pProperties;
286 + Sequence<OUString> aNames(7);
287 + OUString* pNames = aNames.getArray();
288 + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
290 + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
291 + pNames[1] = OUString::createFromAscii( SEPARATORS );
292 + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
293 + pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
294 + pNames[4] = OUString::createFromAscii( FROM_ROW );
295 + pNames[5] = OUString::createFromAscii( CHAR_SET );
296 + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
297 + aValues = aItem.GetProperties( aNames );
298 + pProperties = aValues.getConstArray();
299 + if( pProperties[1].hasValue() )
300 + pProperties[1] >>= sFieldSeparators;
302 + if( pProperties[2].hasValue() )
303 + pProperties[2] >>= sTextSeparators;
305 + if( pProperties[0].hasValue() )
306 + bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
308 + if( pProperties[3].hasValue() )
309 + bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
311 + if( pProperties[4].hasValue() )
312 + pProperties[4] >>= nFromRow;
314 + if( pProperties[5].hasValue() )
315 + pProperties[5] >>= nCharSet;
317 + if ( pProperties[6].hasValue() )
318 + pProperties[6] >>= bQuotedAsText;
321 +static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
322 + bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet )
324 + OUString sFieldSeparators = OUString( maSeparators );
325 + OUString sTextSeparators = OUString( maTxtSep );
326 + Sequence<Any> aValues;
327 + Any *pProperties;
328 + Sequence<OUString> aNames(7);
329 + OUString* pNames = aNames.getArray();
330 + ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
332 + pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
333 + pNames[1] = OUString::createFromAscii( SEPARATORS );
334 + pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
335 + pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
336 + pNames[4] = OUString::createFromAscii( FROM_ROW );
337 + pNames[5] = OUString::createFromAscii( CHAR_SET );
338 + pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
339 + aValues = aItem.GetProperties( aNames );
340 + pProperties = aValues.getArray();
341 + pProperties[1] <<= sFieldSeparators;
342 + pProperties[2] <<= sTextSeparators;
343 + ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
344 + ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
345 + pProperties[4] <<= nFromRow;
346 + pProperties[5] <<= nCharSet;
347 + pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
349 + aItem.PutProperties(aNames, aValues);
352 // ----------------------------------------------------------------------------
354 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
355 - SvStream* pInStream, sal_Unicode cSep ) :
356 + SvStream* pInStream, sal_Unicode /*cSep*/ ) :
357 ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ),
358 mpDatStream ( pInStream ),
359 mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
360 @@ -128,6 +215,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
361 aCkbOther ( this, ScResId( CKB_OTHER ) ),
362 aEdOther ( this, ScResId( ED_OTHER ) ),
363 aCkbAsOnce ( this, ScResId( CB_ASONCE) ),
364 + aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ),
365 aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
366 aCbTextSep ( this, ScResId( CB_TEXTSEP ) ),
368 @@ -146,14 +234,15 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
369 aFldSepList ( ScResId( SCSTR_FIELDSEP ) ),
370 aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
371 mcTextSep ( ScAsciiOptions::cDefaultTextSep ),
372 - maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) )
373 + maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
374 + mbFileImport(true)
376 FreeResource();
377 + mbFileImport = aDatName.Len() > 0;
379 String aName = GetText();
380 // aDatName is empty if invoked during paste from clipboard.
381 - BOOL bClipboard = (aDatName.Len() == 0);
382 - if (!bClipboard)
383 + if (mbFileImport)
385 aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
386 aName += aDatName;
387 @@ -161,20 +250,51 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
389 SetText( aName );
391 - switch(cSep)
393 + OUString sFieldSeparators;
394 + OUString sTextSeparators;
395 + bool bMergeDelimiters = false;
396 + bool bFixedWidth = false;
397 + bool bQuotedFieldAsText = true;
398 + sal_Int32 nFromRow = 1;
399 + sal_Int32 nCharSet = -1;
400 + if (mbFileImport)
401 + // load separators only when importing csv files.
402 + load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
403 + bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet);
404 + maFieldSeparators = String(sFieldSeparators);
406 + if( bMergeDelimiters )
407 + aCkbAsOnce.Check();
408 + if (bQuotedFieldAsText)
409 + aCkbQuotedAsText.Check();
410 + if( bFixedWidth )
411 + aRbFixed.Check();
412 + if( nFromRow != 1 )
413 + aNfRow.SetValue( nFromRow );
415 + ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
416 + const sal_Char *aSep = bString.GetBuffer();
417 + int len = maFieldSeparators.Len();
418 + for (int i = 0; i < len; ++i)
420 - case '\t': aCkbTab.Check(); break;
421 - case ';': aCkbSemicolon.Check(); break;
422 - case ',': aCkbComma.Check(); break;
423 - case ' ': aCkbSpace.Check(); break;
424 - default:
425 - aCkbOther.Check();
426 - aEdOther.SetText( cSep );
427 + switch( aSep[i] )
429 + case '\t': aCkbTab.Check(); break;
430 + case ';': aCkbSemicolon.Check(); break;
431 + case ',': aCkbComma.Check(); break;
432 + case ' ': aCkbSpace.Check(); break;
433 + default:
434 + aCkbOther.Check();
435 + aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
439 + // Get Separators from the dialog
440 maFieldSeparators = GetSeparators();
442 // Clipboard is always Unicode, else detect.
443 - BOOL bPreselectUnicode = bClipboard;
444 + bool bPreselectUnicode = !mbFileImport;
445 // Sniff for Unicode / not
446 if( !bPreselectUnicode && mpDatStream )
448 @@ -210,6 +330,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
450 // *** Separator characters ***
451 lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
452 + aCbTextSep.SetText( sTextSeparators );
454 Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
455 aCbTextSep.SetSelectHdl( aSeparatorHdl );
456 @@ -218,6 +339,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
457 aCkbSemicolon.SetClickHdl( aSeparatorHdl );
458 aCkbComma.SetClickHdl( aSeparatorHdl );
459 aCkbAsOnce.SetClickHdl( aSeparatorHdl );
460 + aCkbQuotedAsText.SetClickHdl( aSeparatorHdl );
461 aCkbSpace.SetClickHdl( aSeparatorHdl );
462 aCkbOther.SetClickHdl( aSeparatorHdl );
463 aEdOther.SetModifyHdl( aSeparatorHdl );
464 @@ -230,6 +352,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
465 aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
466 aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
467 RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
469 + if( nCharSet >= 0 )
470 + aLbCharSet.SelectEntryPos( nCharSet );
472 SetSelectedCharSet();
473 aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
475 @@ -261,6 +387,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
477 ScImportAsciiDlg::~ScImportAsciiDlg()
479 + if (mbFileImport)
480 + save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
481 + aCkbQuotedAsText.IsChecked(), aRbFixed.IsChecked(),
482 + aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos());
483 delete[] mpRowPosArray;
486 @@ -346,6 +476,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
488 rOpt.SetFieldSeps( GetSeparators() );
489 rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
490 + rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked());
491 rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
494 @@ -357,6 +488,10 @@ void ScImportAsciiDlg::SetTextToColumnsMode()
495 aLbCharSet.Disable();
496 aFtRow.Disable();
497 aNfRow.Disable();
499 + // Quoted field as text option is not used for text to columns mode.
500 + aCkbQuotedAsText.Check(false);
501 + aCkbQuotedAsText.Disable();
504 void ScImportAsciiDlg::SetSelectedCharSet()
505 @@ -393,6 +528,7 @@ void ScImportAsciiDlg::SetupSeparatorCtrls()
506 aCkbOther.Enable( bEnable );
507 aEdOther.Enable( bEnable );
508 aCkbAsOnce.Enable( bEnable );
509 + aCkbQuotedAsText.Enable( bEnable );
510 aFtTextSep.Enable( bEnable );
511 aCbTextSep.Enable( bEnable );
513 diff --git sc/source/ui/docshell/impex.cxx sc/source/ui/docshell/impex.cxx
514 index 344dcae..d2cb0cd 100644
515 --- sc/source/ui/docshell/impex.cxx
516 +++ sc/source/ui/docshell/impex.cxx
517 @@ -792,12 +792,10 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm )
521 -bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
522 - const String& rStr, BYTE nColFormat,
523 - ::utl::TransliterationWrapper& rTransliteration,
524 - CalendarWrapper& rCalendar,
525 - ::utl::TransliterationWrapper* pSecondTransliteration,
526 - CalendarWrapper* pSecondCalendar )
527 +static bool lcl_PutString(
528 + ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat,
529 + ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
530 + ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
532 bool bMultiLine = false;
533 if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
534 @@ -1168,7 +1166,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
535 // SC_COL_SKIP.
536 while (*p && nCol <= MAXCOL+1)
538 - p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge );
539 + bool bIsQuoted = false;
540 + p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted );
542 BYTE nFmt = SC_COL_STANDARD;
543 for ( i=nInfoStart; i<nInfoCount; i++ )
544 @@ -1185,10 +1184,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
545 if (nCol > MAXCOL)
546 bOverflow = TRUE; // display warning on import
547 else if (!bDetermineRange)
549 + if (bIsQuoted && pExtOptions && pExtOptions->IsQuotedAsText())
550 + nFmt = SC_COL_TEXT;
552 bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
553 nTab, aCell, nFmt, aTransliteration,
554 aCalendar, pEnglishTransliteration,
555 pEnglishCalendar);
557 ++nCol;
560 @@ -1262,11 +1266,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
562 // static
563 const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
564 - String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps )
565 + String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted )
567 + rbIsQuoted = false;
568 rField.Erase();
569 if ( *p == cStr ) // String in Anfuehrungszeichen
571 + rbIsQuoted = true;
572 const sal_Unicode* p1;
573 p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
574 while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
575 diff --git sc/source/ui/inc/asciiopt.hxx sc/source/ui/inc/asciiopt.hxx
576 index 1d12606..394f2dc 100644
577 --- sc/source/ui/inc/asciiopt.hxx
578 +++ sc/source/ui/inc/asciiopt.hxx
579 @@ -65,6 +65,7 @@ private:
580 BOOL bFixedLen;
581 String aFieldSeps;
582 BOOL bMergeFieldSeps;
583 + bool bQuotedFieldAsText;
584 sal_Unicode cTextSep;
585 CharSet eCharSet;
586 BOOL bCharSetSystem;
587 @@ -93,6 +94,7 @@ public:
588 BOOL GetCharSetSystem() const { return bCharSetSystem; }
589 const String& GetFieldSeps() const { return aFieldSeps; }
590 BOOL IsMergeSeps() const { return bMergeFieldSeps; }
591 + bool IsQuotedAsText() const { return bQuotedFieldAsText; }
592 sal_Unicode GetTextSep() const { return cTextSep; }
593 BOOL IsFixedLen() const { return bFixedLen; }
594 USHORT GetInfoCount() const { return nInfoCount; }
595 @@ -105,6 +107,7 @@ public:
596 void SetFixedLen( BOOL bSet ) { bFixedLen = bSet; }
597 void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; }
598 void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; }
599 + void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; }
600 void SetTextSep( sal_Unicode c ) { cTextSep = c; }
601 void SetStartRow( long nRow) { nStartRow= nRow; }
603 diff --git sc/source/ui/inc/csvruler.hxx sc/source/ui/inc/csvruler.hxx
604 index c251831..cd67708 100644
605 --- sc/source/ui/inc/csvruler.hxx
606 +++ sc/source/ui/inc/csvruler.hxx
607 @@ -71,6 +71,7 @@ private:
608 // ------------------------------------------------------------------------
609 public:
610 explicit ScCsvRuler( ScCsvControl& rParent );
611 + ~ScCsvRuler();
613 // common ruler handling --------------------------------------------------
614 public:
615 diff --git sc/source/ui/inc/impex.hxx sc/source/ui/inc/impex.hxx
616 index 515063a..aaddeeb 100644
617 --- sc/source/ui/inc/impex.hxx
618 +++ sc/source/ui/inc/impex.hxx
619 @@ -98,7 +98,7 @@ public:
621 static BOOL IsFormatSupported( ULONG nFormat );
622 static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
623 - String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps );
624 + String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted );
625 static void WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE );
626 static void WriteUnicodeOrByteEndl( SvStream& rStrm );
627 static inline BOOL IsEndianSwap( const SvStream& rStrm );
628 diff --git sc/source/ui/inc/scuiasciiopt.hxx sc/source/ui/inc/scuiasciiopt.hxx
629 index 6712193..45c3e71 100644
630 --- sc/source/ui/inc/scuiasciiopt.hxx
631 +++ sc/source/ui/inc/scuiasciiopt.hxx
632 @@ -64,6 +64,7 @@ class ScImportAsciiDlg : public ModalDialog
633 CheckBox aCkbOther;
634 Edit aEdOther;
635 CheckBox aCkbAsOnce;
636 + CheckBox aCkbQuotedAsText;
637 FixedText aFtTextSep;
638 ComboBox aCbTextSep;
640 @@ -87,6 +88,7 @@ class ScImportAsciiDlg : public ModalDialog
642 CharSet meCharSet; /// Selected char set.
643 bool mbCharSetSystem; /// Is System char set selected?
644 + bool mbFileImport; /// Is this dialog involked for csv file import ?
646 public:
647 ScImportAsciiDlg(