View | Details | Raw Unified | Return to issue 97416
Collapse All | Expand All

(-)sc/source/ui/dbgui/asciiopt.cxx (+16 lines)
Lines 56-61 ScAsciiOptions::ScAsciiOptions() : Link Here
56
	bFixedLen		( FALSE ),
56
	bFixedLen		( FALSE ),
57
	aFieldSeps		( ';' ),
57
	aFieldSeps		( ';' ),
58
	bMergeFieldSeps	( FALSE ),
58
	bMergeFieldSeps	( FALSE ),
59
    bQuotedFieldAsText(false),
59
	cTextSep		( cDefaultTextSep ),
60
	cTextSep		( cDefaultTextSep ),
60
	eCharSet		( gsl_getSystemTextEncoding() ),
61
	eCharSet		( gsl_getSystemTextEncoding() ),
61
	bCharSetSystem	( FALSE ),
62
	bCharSetSystem	( FALSE ),
Lines 71-76 ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : Link Here
71
	bFixedLen		( rOpt.bFixedLen ),
72
	bFixedLen		( rOpt.bFixedLen ),
72
	aFieldSeps		( rOpt.aFieldSeps ),
73
	aFieldSeps		( rOpt.aFieldSeps ),
73
	bMergeFieldSeps	( rOpt.bMergeFieldSeps ),
74
	bMergeFieldSeps	( rOpt.bMergeFieldSeps ),
75
    bQuotedFieldAsText(rOpt.bQuotedFieldAsText),
74
	cTextSep		( rOpt.cTextSep ),
76
	cTextSep		( rOpt.cTextSep ),
75
	eCharSet		( rOpt.eCharSet ),
77
	eCharSet		( rOpt.eCharSet ),
76
	bCharSetSystem	( rOpt.bCharSetSystem ),
78
	bCharSetSystem	( rOpt.bCharSetSystem ),
Lines 155-160 ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy ) Link Here
155
	bFixedLen		= rCpy.bFixedLen;
157
	bFixedLen		= rCpy.bFixedLen;
156
	aFieldSeps		= rCpy.aFieldSeps;
158
	aFieldSeps		= rCpy.aFieldSeps;
157
	bMergeFieldSeps	= rCpy.bMergeFieldSeps;
159
	bMergeFieldSeps	= rCpy.bMergeFieldSeps;
160
    bQuotedFieldAsText = rCpy.bQuotedFieldAsText;
158
	cTextSep		= rCpy.cTextSep;
161
	cTextSep		= rCpy.cTextSep;
159
	eCharSet		= rCpy.eCharSet;
162
	eCharSet		= rCpy.eCharSet;
160
	bCharSetSystem	= rCpy.bCharSetSystem;
163
	bCharSetSystem	= rCpy.bCharSetSystem;
Lines 169-174 BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const Link Here
169
	if ( bFixedLen		 == rCmp.bFixedLen &&
172
	if ( bFixedLen		 == rCmp.bFixedLen &&
170
		 aFieldSeps		 == rCmp.aFieldSeps &&
173
		 aFieldSeps		 == rCmp.aFieldSeps &&
171
		 bMergeFieldSeps == rCmp.bMergeFieldSeps &&
174
		 bMergeFieldSeps == rCmp.bMergeFieldSeps &&
175
         bQuotedFieldAsText == rCmp.bQuotedFieldAsText &&
172
		 cTextSep		 == rCmp.cTextSep &&
176
		 cTextSep		 == rCmp.cTextSep &&
173
		 eCharSet		 == rCmp.eCharSet &&
177
		 eCharSet		 == rCmp.eCharSet &&
174
		 bCharSetSystem  == rCmp.bCharSetSystem &&
178
		 bCharSetSystem  == rCmp.bCharSetSystem &&
Lines 286-291 void ScAsciiOptions::ReadFromString( const String& rString ) Link Here
286
			pColFormat = NULL;
290
			pColFormat = NULL;
287
		}
291
		}
288
	}
292
	}
293
294
    // Import quoted field as text.
295
    if (nCount >= 6)
296
    {
297
        aToken = rString.GetToken(5, ',');
298
        bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false;
299
    }
289
}
300
}
290
301
291
302
Lines 357-362 String ScAsciiOptions::WriteToString() const Link Here
357
		aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
368
		aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
358
	}
369
	}
359
370
371
    aOutStr += ',';
372
373
    // Import quoted field as text.
374
    aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false");
375
360
	return aOutStr;
376
	return aOutStr;
361
}
377
}
362
378
(-)sc/source/ui/dbgui/asciiopt.hrc (+1 lines)
Lines 56-59 Link Here
56
#define FT_AT_ROW 59
56
#define FT_AT_ROW 59
57
#define NF_AT_ROW 60
57
#define NF_AT_ROW 60
58
#define CB_ASONCE 90
58
#define CB_ASONCE 90
59
#define CB_QUOTED_AS_TEXT 91
59
#define STR_TEXTTOCOLUMNS 100
60
#define STR_TEXTTOCOLUMNS 100
(-)sc/source/ui/dbgui/asciiopt.src (-5 / +12 lines)
Lines 34-57 ModalDialog RID_SCDLG_ASCII Link Here
34
{
34
{
35
	OutputSize = TRUE ;
35
	OutputSize = TRUE ;
36
	SVLook = TRUE ;
36
	SVLook = TRUE ;
37
    Size = MAP_APPFONT ( 320 , 247 ) ;
37
    Size = MAP_APPFONT ( 320 , 264 ) ;
38
	Text [ en-US ] = "Text Import" ;
38
	Text [ en-US ] = "Text Import" ;
39
	Moveable = TRUE ;
39
	Moveable = TRUE ;
40
    FixedLine FL_WIDTH
40
    FixedLine FL_WIDTH
41
	{
41
	{
42
        Pos = MAP_APPFONT ( 6 , 132 ) ;
42
        Pos = MAP_APPFONT ( 6 , 147 ) ;
43
        Size = MAP_APPFONT ( 252 , 8 ) ;
43
        Size = MAP_APPFONT ( 252 , 8 ) ;
44
		Text [ en-US ] = "Fields" ;
44
		Text [ en-US ] = "Fields" ;
45
	};
45
	};
46
	FixedText FT_TYPE
46
	FixedText FT_TYPE
47
	{
47
	{
48
        Pos = MAP_APPFONT ( 12 , 145 ) ;
48
        Pos = MAP_APPFONT ( 12 , 160 ) ;
49
        Size = MAP_APPFONT ( 60 , 8 ) ;
49
        Size = MAP_APPFONT ( 60 , 8 ) ;
50
		Text [ en-US ] = "Column t~ype";
50
		Text [ en-US ] = "Column t~ype";
51
	};
51
	};
52
	ListBox LB_TYPE1
52
	ListBox LB_TYPE1
53
	{
53
	{
54
        Pos = MAP_APPFONT ( 76 , 143 ) ;
54
        Pos = MAP_APPFONT ( 76 , 158 ) ;
55
        Size = MAP_APPFONT ( 60 , 68 ) ;
55
        Size = MAP_APPFONT ( 60 , 68 ) ;
56
		TabStop = TRUE ;
56
		TabStop = TRUE ;
57
		DropDown = TRUE ;
57
		DropDown = TRUE ;
Lines 194-200 ModalDialog RID_SCDLG_ASCII Link Here
194
		HelpId = HID_SC_ASCII_TABCTR ;
194
		HelpId = HID_SC_ASCII_TABCTR ;
195
		Border = TRUE ;
195
		Border = TRUE ;
196
        DialogControl = TRUE ;
196
        DialogControl = TRUE ;
197
        Pos = MAP_APPFONT ( 12 , 159 ) ;
197
        Pos = MAP_APPFONT ( 12 , 176 ) ;
198
        Size = MAP_APPFONT ( 243 , 82 ) ;
198
        Size = MAP_APPFONT ( 243 , 82 ) ;
199
	};
199
	};
200
	CheckBox CB_ASONCE
200
	CheckBox CB_ASONCE
Lines 204-209 ModalDialog RID_SCDLG_ASCII Link Here
204
		TabStop = TRUE ;
204
		TabStop = TRUE ;
205
		Text [ en-US ] = "Merge ~delimiters" ;
205
		Text [ en-US ] = "Merge ~delimiters" ;
206
	};
206
	};
207
    CheckBox CB_QUOTED_AS_TEXT
208
    {
209
        Pos = MAP_APPFONT ( 20 , 129 ) ;
210
        Size = MAP_APPFONT ( 130 , 10 ) ;
211
        TabStop = TRUE ;
212
        Text [ en-US ] = "~Quoted field as text" ;
213
    };
207
    String STR_TEXTTOCOLUMNS
214
    String STR_TEXTTOCOLUMNS
208
    {
215
    {
209
        Text [ en-US ] = "Text to Columns" ;
216
        Text [ en-US ] = "Text to Columns" ;
(-)sc/source/ui/dbgui/csvgrid.cxx (-1 / +2 lines)
Lines 737-743 void ScCsvGrid::ImplSetTextLineSep( Link Here
737
    while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
737
    while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
738
    {
738
    {
739
        // scan for next cell text
739
        // scan for next cell text
740
        pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep );
740
        bool bIsQuoted = false;
741
        pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted );
741
742
742
        // update column width
743
        // update column width
743
        sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
744
        sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
(-)sc/source/ui/dbgui/csvruler.cxx (+75 lines)
Lines 37-44 Link Here
37
#include "AccessibleCsvControl.hxx"
37
#include "AccessibleCsvControl.hxx"
38
38
39
39
40
#include <optutil.hxx>
41
#include <com/sun/star/uno/Any.hxx>
42
#include <com/sun/star/uno/Sequence.hxx>
43
#include "miscuno.hxx"
44
45
using namespace rtl;
46
using namespace com::sun::star::uno;
47
48
49
50
// ============================================================================
51
#define SEP_PATH            "Office.Calc/Dialogs/CSVImport"
52
#define FIXED_WIDTH_LIST    "FixedWidthList"
53
54
40
// ============================================================================
55
// ============================================================================
41
56
57
static void load_FixedWidthList(ScCsvSplits &aSplits)
58
{
59
    String sSplits;
60
    OUString sFixedWidthLists;
61
62
    Sequence<Any>aValues;
63
    const Any *pProperties;
64
    Sequence<OUString> aNames(1);
65
    OUString* pNames = aNames.getArray();
66
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
67
68
    pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
69
    aValues = aItem.GetProperties( aNames );
70
    pProperties = aValues.getConstArray();
71
72
    if( pProperties[0].hasValue() )
73
    {
74
        aSplits.Clear();
75
        pProperties[0] >>= sFixedWidthLists;
76
77
        sSplits = String( sFixedWidthLists );
78
79
        // String ends with a semi-colon so there is no 'int' after the last one.
80
        for(int i=0;i<sSplits.GetTokenCount()-1;i++ )
81
            aSplits.Insert( sSplits.GetToken(i).ToInt32() );
82
    }
83
}
84
static void save_FixedWidthList(ScCsvSplits aSplits)
85
{
86
    int i;
87
    String sSplits;
88
    // Create a semi-colon separated string to save the splits
89
    for(i=0;i<aSplits.Count();i++)
90
    {
91
        sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
92
        sSplits.Append((char)';');
93
    }
94
95
    OUString sFixedWidthLists = OUString( sSplits );
96
    Sequence<Any> aValues;
97
    Any *pProperties;
98
    Sequence<OUString> aNames(1);
99
    OUString* pNames = aNames.getArray();
100
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
101
102
    pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
103
    aValues = aItem.GetProperties( aNames );
104
    pProperties = aValues.getArray();
105
    pProperties[0] <<= sFixedWidthLists;
106
107
    aItem.PutProperties(aNames, aValues);
108
}
109
42
ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
110
ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
43
    ScCsvControl( rParent ),
111
    ScCsvControl( rParent ),
44
    mnPosCursorLast( 1 )
112
    mnPosCursorLast( 1 )
Lines 48-53 ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) : Link Here
48
    InitSizeData();
116
    InitSizeData();
49
    maBackgrDev.SetFont( GetFont() );
117
    maBackgrDev.SetFont( GetFont() );
50
    maRulerDev.SetFont( GetFont() );
118
    maRulerDev.SetFont( GetFont() );
119
120
    load_FixedWidthList( maSplits );
121
}
122
123
ScCsvRuler::~ScCsvRuler()
124
{
125
    save_FixedWidthList( maSplits );
51
}
126
}
52
127
53
128
(-)sc/source/ui/dbgui/scuiasciiopt.cxx (-13 / +153 lines)
Lines 44-49 Link Here
44
// ause
44
// ause
45
#include "editutil.hxx"
45
#include "editutil.hxx"
46
46
47
#include <optutil.hxx>
48
#include <com/sun/star/uno/Any.hxx>
49
#include <com/sun/star/uno/Sequence.hxx>
50
#include "miscuno.hxx"
51
52
47
//! TODO make dynamic
53
//! TODO make dynamic
48
#ifdef WIN
54
#ifdef WIN
49
const SCSIZE ASCIIDLG_MAXROWS                = 10000;
55
const SCSIZE ASCIIDLG_MAXROWS                = 10000;
Lines 51-56 const SCSIZE ASCIIDLG_MAXROWS = 10000; Link Here
51
const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
57
const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
52
#endif
58
#endif
53
59
60
61
using namespace rtl;
62
using namespace com::sun::star::uno;
63
64
// Defines - CSV Import Preserve Options
65
#define FIXED_WIDTH         "FixedWidth"
66
#define FROM_ROW            "FromRow"
67
#define CHAR_SET            "CharSet"
68
#define SEPARATORS          "Separators"
69
#define TEXT_SEPARATORS     "TextSeparators"
70
#define MERGE_DELIMITERS    "MergeDelimiters"
71
#define QUOTED_AS_TEXT      "QuotedFieldAsText"
72
#define SEP_PATH            "Office.Calc/Dialogs/CSVImport"
73
54
// ============================================================================
74
// ============================================================================
55
75
56
void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
76
void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
Lines 98-108 sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList ) Link Here
98
	return c;
118
	return c;
99
}
119
}
100
120
121
static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, 
122
                             bool &bMergeDelimiters, bool& bQuotedAsText, bool &bFixedWidth, 
123
                             sal_Int32 &nFromRow, sal_Int32 &nCharSet )
124
{
125
    Sequence<Any>aValues;
126
    const Any *pProperties;
127
    Sequence<OUString> aNames(7);
128
    OUString* pNames = aNames.getArray();
129
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
130
131
    pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
132
    pNames[1] = OUString::createFromAscii( SEPARATORS );
133
    pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
134
    pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
135
    pNames[4] = OUString::createFromAscii( FROM_ROW );
136
    pNames[5] = OUString::createFromAscii( CHAR_SET );
137
    pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
138
    aValues = aItem.GetProperties( aNames );
139
    pProperties = aValues.getConstArray();
140
    if( pProperties[1].hasValue() )
141
        pProperties[1] >>= sFieldSeparators;
142
143
    if( pProperties[2].hasValue() )
144
        pProperties[2] >>= sTextSeparators;
145
146
    if( pProperties[0].hasValue() )
147
        bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
148
149
    if( pProperties[3].hasValue() )
150
        bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
151
152
    if( pProperties[4].hasValue() )
153
        pProperties[4] >>= nFromRow;
154
155
    if( pProperties[5].hasValue() )
156
        pProperties[5] >>= nCharSet;
157
 
158
    if ( pProperties[6].hasValue() )
159
        pProperties[6] >>= bQuotedAsText;
160
}
161
162
static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
163
                             bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet )
164
{
165
    OUString sFieldSeparators = OUString( maSeparators );
166
    OUString sTextSeparators = OUString( maTxtSep );
167
    Sequence<Any> aValues;
168
    Any *pProperties;
169
    Sequence<OUString> aNames(7);
170
    OUString* pNames = aNames.getArray();
171
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
172
173
    pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
174
    pNames[1] = OUString::createFromAscii( SEPARATORS );
175
    pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
176
    pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
177
    pNames[4] = OUString::createFromAscii( FROM_ROW );
178
    pNames[5] = OUString::createFromAscii( CHAR_SET );
179
    pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
180
    aValues = aItem.GetProperties( aNames );
181
    pProperties = aValues.getArray();
182
    pProperties[1] <<= sFieldSeparators;
183
    pProperties[2] <<= sTextSeparators;
184
    ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
185
    ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
186
    pProperties[4] <<= nFromRow;
187
    pProperties[5] <<= nCharSet;
188
    pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
189
190
    aItem.PutProperties(aNames, aValues);
191
}
101
192
102
// ----------------------------------------------------------------------------
193
// ----------------------------------------------------------------------------
103
194
104
ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
195
ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
105
									SvStream* pInStream, sal_Unicode cSep ) :
196
                                    SvStream* pInStream, sal_Unicode /*cSep*/ ) :
106
		ModalDialog	( pParent, ScResId( RID_SCDLG_ASCII ) ),
197
		ModalDialog	( pParent, ScResId( RID_SCDLG_ASCII ) ),
107
        mpDatStream  ( pInStream ),
198
        mpDatStream  ( pInStream ),
108
        mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
199
        mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
Lines 128-133 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
128
		aCkbOther	( this, ScResId( CKB_OTHER ) ),
215
		aCkbOther	( this, ScResId( CKB_OTHER ) ),
129
		aEdOther	( this, ScResId( ED_OTHER ) ),
216
		aEdOther	( this, ScResId( ED_OTHER ) ),
130
		aCkbAsOnce	( this, ScResId( CB_ASONCE) ),
217
		aCkbAsOnce	( this, ScResId( CB_ASONCE) ),
218
        aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ),
131
		aFtTextSep	( this, ScResId( FT_TEXTSEP ) ),
219
		aFtTextSep	( this, ScResId( FT_TEXTSEP ) ),
132
		aCbTextSep	( this, ScResId( CB_TEXTSEP ) ),
220
		aCbTextSep	( this, ScResId( CB_TEXTSEP ) ),
133
221
Lines 146-159 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
146
		aFldSepList	( ScResId( SCSTR_FIELDSEP ) ),
234
		aFldSepList	( ScResId( SCSTR_FIELDSEP ) ),
147
		aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
235
		aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
148
        mcTextSep   ( ScAsciiOptions::cDefaultTextSep ),
236
        mcTextSep   ( ScAsciiOptions::cDefaultTextSep ),
149
        maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) )
237
        maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
238
        mbFileImport(true)
150
{
239
{
151
	FreeResource();
240
	FreeResource();
241
    mbFileImport = aDatName.Len() > 0;
152
242
153
	String aName = GetText();
243
	String aName = GetText();
154
    // aDatName is empty if invoked during paste from clipboard.
244
    // aDatName is empty if invoked during paste from clipboard.
155
    BOOL bClipboard = (aDatName.Len() == 0);
245
    if (mbFileImport)
156
    if (!bClipboard)
157
    {
246
    {
158
        aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
247
        aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
159
        aName += aDatName;
248
        aName += aDatName;
Lines 161-180 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
161
    }
250
    }
162
	SetText( aName );
251
	SetText( aName );
163
252
164
	switch(cSep)
253
254
    OUString sFieldSeparators;
255
    OUString sTextSeparators;
256
    bool bMergeDelimiters = false;
257
    bool bFixedWidth = false;
258
    bool bQuotedFieldAsText = false;
259
    sal_Int32 nFromRow = 1;
260
    sal_Int32 nCharSet = -1;
261
    if (mbFileImport)
262
        // load separators only when importing csv files.
263
        load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, 
264
                         bQuotedFieldAsText, bFixedWidth, nFromRow, nCharSet);
265
    maFieldSeparators = String(sFieldSeparators);
266
267
    if( bMergeDelimiters )
268
        aCkbAsOnce.Check();
269
    if (bQuotedFieldAsText)
270
        aCkbQuotedAsText.Check();
271
    if( bFixedWidth )
272
        aRbFixed.Check();
273
    if( nFromRow != 1 )
274
        aNfRow.SetValue( nFromRow );
275
276
    ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
277
    const sal_Char *aSep = bString.GetBuffer();
278
    int len = maFieldSeparators.Len();
279
    for (int i = 0; i < len; ++i)
165
    {
280
    {
166
        case '\t':  aCkbTab.Check();        break;
281
        switch( aSep[i] )
167
        case ';':   aCkbSemicolon.Check();  break;
282
        {
168
        case ',':   aCkbComma.Check();      break;
283
            case '\t':  aCkbTab.Check();        break;
169
        case ' ':   aCkbSpace.Check();      break;
284
            case ';':   aCkbSemicolon.Check();  break;
170
        default:
285
            case ',':   aCkbComma.Check();      break;
171
            aCkbOther.Check();
286
            case ' ':   aCkbSpace.Check();      break;
172
            aEdOther.SetText( cSep );
287
            default:
288
                aCkbOther.Check();
289
                aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
290
        }
173
    }
291
    }
292
    
293
    // Get Separators from the dialog
174
    maFieldSeparators = GetSeparators();
294
    maFieldSeparators = GetSeparators();
175
295
176
    // Clipboard is always Unicode, else detect.
296
    // Clipboard is always Unicode, else detect.
177
	BOOL bPreselectUnicode = bClipboard;
297
    bool bPreselectUnicode = !mbFileImport;
178
	// Sniff for Unicode / not
298
	// Sniff for Unicode / not
179
    if( !bPreselectUnicode && mpDatStream )
299
    if( !bPreselectUnicode && mpDatStream )
180
	{
300
	{
Lines 210-215 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
210
330
211
    // *** Separator characters ***
331
    // *** Separator characters ***
212
    lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
332
    lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
333
    aCbTextSep.SetText( sTextSeparators );
213
334
214
    Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
335
    Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
215
    aCbTextSep.SetSelectHdl( aSeparatorHdl );
336
    aCbTextSep.SetSelectHdl( aSeparatorHdl );
Lines 218-223 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
218
    aCkbSemicolon.SetClickHdl( aSeparatorHdl );
339
    aCkbSemicolon.SetClickHdl( aSeparatorHdl );
219
    aCkbComma.SetClickHdl( aSeparatorHdl );
340
    aCkbComma.SetClickHdl( aSeparatorHdl );
220
    aCkbAsOnce.SetClickHdl( aSeparatorHdl );
341
    aCkbAsOnce.SetClickHdl( aSeparatorHdl );
342
    aCkbQuotedAsText.SetClickHdl( aSeparatorHdl );
221
    aCkbSpace.SetClickHdl( aSeparatorHdl );
343
    aCkbSpace.SetClickHdl( aSeparatorHdl );
222
    aCkbOther.SetClickHdl( aSeparatorHdl );
344
    aCkbOther.SetClickHdl( aSeparatorHdl );
223
    aEdOther.SetModifyHdl( aSeparatorHdl );
345
    aEdOther.SetModifyHdl( aSeparatorHdl );
Lines 230-235 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
230
	aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
352
	aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
231
	aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
353
	aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
232
		RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
354
		RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
355
356
    if( nCharSet >= 0 )
357
        aLbCharSet.SelectEntryPos( nCharSet );
358
233
    SetSelectedCharSet();
359
    SetSelectedCharSet();
234
	aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
360
	aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
235
361
Lines 261-266 ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName, Link Here
261
387
262
ScImportAsciiDlg::~ScImportAsciiDlg()
388
ScImportAsciiDlg::~ScImportAsciiDlg()
263
{
389
{
390
    if (mbFileImport)
391
        save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), 
392
                         aCkbQuotedAsText.IsChecked(), aRbFixed.IsChecked(), 
393
                         aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos());
264
	delete[] mpRowPosArray;
394
	delete[] mpRowPosArray;
265
}
395
}
266
396
Lines 346-351 void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) Link Here
346
    {
476
    {
347
        rOpt.SetFieldSeps( GetSeparators() );
477
        rOpt.SetFieldSeps( GetSeparators() );
348
        rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
478
        rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
479
        rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked());
349
        rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
480
        rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
350
    }
481
    }
351
}
482
}
Lines 357-362 void ScImportAsciiDlg::SetTextToColumnsMode() Link Here
357
    aLbCharSet.Disable();
488
    aLbCharSet.Disable();
358
    aFtRow.Disable();
489
    aFtRow.Disable();
359
    aNfRow.Disable();
490
    aNfRow.Disable();
491
492
    // Quoted field as text option is not used for text to columns mode.
493
    aCkbQuotedAsText.Check(false);
494
    aCkbQuotedAsText.Disable();
360
}
495
}
361
496
362
void ScImportAsciiDlg::SetSelectedCharSet()
497
void ScImportAsciiDlg::SetSelectedCharSet()
Lines 393-398 void ScImportAsciiDlg::SetupSeparatorCtrls() Link Here
393
    aCkbOther.Enable( bEnable );
528
    aCkbOther.Enable( bEnable );
394
    aEdOther.Enable( bEnable );
529
    aEdOther.Enable( bEnable );
395
    aCkbAsOnce.Enable( bEnable );
530
    aCkbAsOnce.Enable( bEnable );
531
    aCkbQuotedAsText.Enable( bEnable );
396
    aFtTextSep.Enable( bEnable );
532
    aFtTextSep.Enable( bEnable );
397
    aCbTextSep.Enable( bEnable );
533
    aCbTextSep.Enable( bEnable );
398
}
534
}
(-)sc/source/ui/docshell/impex.cxx (-8 / +14 lines)
Lines 792-803 BOOL ScImportExport::Text2Doc( SvStream& rStrm ) Link Here
792
		//
792
		//
793
793
794
794
795
bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
795
static bool lcl_PutString( 
796
					const String& rStr, BYTE nColFormat,
796
    ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat,
797
                    ::utl::TransliterationWrapper& rTransliteration,
797
    ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
798
					CalendarWrapper& rCalendar,
798
    ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
799
                    ::utl::TransliterationWrapper* pSecondTransliteration,
800
					CalendarWrapper* pSecondCalendar )
801
{
799
{
802
    bool bMultiLine = false;
800
    bool bMultiLine = false;
803
	if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
801
	if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
Lines 1168-1174 BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) Link Here
1168
                // SC_COL_SKIP.
1166
                // SC_COL_SKIP.
1169
                while (*p && nCol <= MAXCOL+1)
1167
                while (*p && nCol <= MAXCOL+1)
1170
                {
1168
                {
1171
                    p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge );
1169
                    bool bIsQuoted = false;
1170
                    p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted );
1172
1171
1173
                    BYTE nFmt = SC_COL_STANDARD;
1172
                    BYTE nFmt = SC_COL_STANDARD;
1174
                    for ( i=nInfoStart; i<nInfoCount; i++ )
1173
                    for ( i=nInfoStart; i<nInfoCount; i++ )
Lines 1185-1194 BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) Link Here
1185
                        if (nCol > MAXCOL)
1184
                        if (nCol > MAXCOL)
1186
                            bOverflow = TRUE;       // display warning on import
1185
                            bOverflow = TRUE;       // display warning on import
1187
                        else if (!bDetermineRange)
1186
                        else if (!bDetermineRange)
1187
                        {
1188
                            if (bIsQuoted && pExtOptions && pExtOptions->IsQuotedAsText())
1189
                                nFmt = SC_COL_TEXT;
1190
1188
                            bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
1191
                            bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
1189
                                    nTab, aCell, nFmt, aTransliteration,
1192
                                    nTab, aCell, nFmt, aTransliteration,
1190
                                    aCalendar, pEnglishTransliteration,
1193
                                    aCalendar, pEnglishTransliteration,
1191
                                    pEnglishCalendar);
1194
                                    pEnglishCalendar);
1195
                        }
1192
                        ++nCol;
1196
                        ++nCol;
1193
                    }
1197
                    }
1194
1198
Lines 1262-1272 BOOL ScImportExport::ExtText2Doc( SvStream& rStrm ) Link Here
1262
1266
1263
// static
1267
// static
1264
const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
1268
const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
1265
		String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps )
1269
		String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted )
1266
{
1270
{
1271
    rbIsQuoted = false;
1267
	rField.Erase();
1272
	rField.Erase();
1268
	if ( *p == cStr )			// String in Anfuehrungszeichen
1273
	if ( *p == cStr )			// String in Anfuehrungszeichen
1269
	{
1274
	{
1275
        rbIsQuoted = true;
1270
        const sal_Unicode* p1;
1276
        const sal_Unicode* p1;
1271
		p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
1277
		p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
1272
		while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
1278
		while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
(-)sc/source/ui/inc/asciiopt.hxx (+3 lines)
Lines 65-70 private: Link Here
65
	BOOL		bFixedLen;
65
	BOOL		bFixedLen;
66
	String		aFieldSeps;
66
	String		aFieldSeps;
67
	BOOL		bMergeFieldSeps;
67
	BOOL		bMergeFieldSeps;
68
    bool        bQuotedFieldAsText;
68
	sal_Unicode	cTextSep;
69
	sal_Unicode	cTextSep;
69
	CharSet		eCharSet;
70
	CharSet		eCharSet;
70
	BOOL		bCharSetSystem;
71
	BOOL		bCharSetSystem;
Lines 93-98 public: Link Here
93
	BOOL				GetCharSetSystem() const	{ return bCharSetSystem; }
94
	BOOL				GetCharSetSystem() const	{ return bCharSetSystem; }
94
	const String&		GetFieldSeps() const	{ return aFieldSeps; }
95
	const String&		GetFieldSeps() const	{ return aFieldSeps; }
95
	BOOL				IsMergeSeps() const		{ return bMergeFieldSeps; }
96
	BOOL				IsMergeSeps() const		{ return bMergeFieldSeps; }
97
    bool                IsQuotedAsText() const  { return bQuotedFieldAsText; }
96
	sal_Unicode			GetTextSep() const		{ return cTextSep; }
98
	sal_Unicode			GetTextSep() const		{ return cTextSep; }
97
	BOOL				IsFixedLen() const		{ return bFixedLen; }
99
	BOOL				IsFixedLen() const		{ return bFixedLen; }
98
	USHORT				GetInfoCount() const	{ return nInfoCount; }
100
	USHORT				GetInfoCount() const	{ return nInfoCount; }
Lines 105-110 public: Link Here
105
	void	SetFixedLen( BOOL bSet )			{ bFixedLen = bSet; }
107
	void	SetFixedLen( BOOL bSet )			{ bFixedLen = bSet; }
106
	void	SetFieldSeps( const String& rStr )	{ aFieldSeps = rStr; }
108
	void	SetFieldSeps( const String& rStr )	{ aFieldSeps = rStr; }
107
	void	SetMergeSeps( BOOL bSet )			{ bMergeFieldSeps = bSet; }
109
	void	SetMergeSeps( BOOL bSet )			{ bMergeFieldSeps = bSet; }
110
    void    SetQuotedAsText(bool bSet)          { bQuotedFieldAsText = bSet; }
108
	void	SetTextSep( sal_Unicode c )			{ cTextSep = c; }
111
	void	SetTextSep( sal_Unicode c )			{ cTextSep = c; }
109
	void	SetStartRow( long nRow)				{ nStartRow= nRow; }
112
	void	SetStartRow( long nRow)				{ nStartRow= nRow; }
110
113
(-)sc/source/ui/inc/csvruler.hxx (+1 lines)
Lines 71-76 private: Link Here
71
    // ------------------------------------------------------------------------
71
    // ------------------------------------------------------------------------
72
public:
72
public:
73
    explicit                    ScCsvRuler( ScCsvControl& rParent );
73
    explicit                    ScCsvRuler( ScCsvControl& rParent );
74
                                ~ScCsvRuler();
74
75
75
    // common ruler handling --------------------------------------------------
76
    // common ruler handling --------------------------------------------------
76
public:
77
public:
(-)sc/source/ui/inc/impex.hxx (-1 / +1 lines)
Lines 98-104 public: Link Here
98
98
99
	static BOOL  IsFormatSupported( ULONG nFormat );
99
	static BOOL  IsFormatSupported( ULONG nFormat );
100
	static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
100
	static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
101
			String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps );
101
			String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted );
102
	static	void	WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE );
102
	static	void	WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE );
103
	static	void	WriteUnicodeOrByteEndl( SvStream& rStrm );
103
	static	void	WriteUnicodeOrByteEndl( SvStream& rStrm );
104
	static	inline	BOOL	IsEndianSwap( const SvStream& rStrm );
104
	static	inline	BOOL	IsEndianSwap( const SvStream& rStrm );
(-)sc/source/ui/inc/scuiasciiopt.hxx (+2 lines)
Lines 64-69 class ScImportAsciiDlg : public ModalDialog Link Here
64
    CheckBox                    aCkbOther;
64
    CheckBox                    aCkbOther;
65
    Edit                        aEdOther;
65
    Edit                        aEdOther;
66
    CheckBox                    aCkbAsOnce;
66
    CheckBox                    aCkbAsOnce;
67
    CheckBox                    aCkbQuotedAsText;
67
    FixedText                   aFtTextSep;
68
    FixedText                   aFtTextSep;
68
    ComboBox                    aCbTextSep;
69
    ComboBox                    aCbTextSep;
69
70
Lines 87-92 class ScImportAsciiDlg : public ModalDialog Link Here
87
88
88
    CharSet                     meCharSet;          /// Selected char set.
89
    CharSet                     meCharSet;          /// Selected char set.
89
    bool                        mbCharSetSystem;    /// Is System char set selected?
90
    bool                        mbCharSetSystem;    /// Is System char set selected?
91
    bool                        mbFileImport;       /// Is this dialog involked for csv file import ?
90
92
91
public:
93
public:
92
                                ScImportAsciiDlg(
94
                                ScImportAsciiDlg(

Return to issue 97416