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

(-)officecfg.clean/registry/schema/org/openoffice/Office/Calc.xcs (+66 lines)
Lines 1024-1029 Link Here
1024
				<value>NULL</value>
1024
				<value>NULL</value>
1025
			</prop>
1025
			</prop>
1026
		</group>
1026
		</group>
1027
		<group oor:name="Dialogs">
1028
			<info>
1029
				<desc>Contains the dialogs settings.</desc>
1030
			</info>
1031
			<group oor:name="CSVImport">
1032
				<info>
1033
					<desc>Contains setting for Text CSV Import</desc>
1034
				</info>
1035
				<prop oor:name="MergeDelimiters" oor:type="xs:boolean">
1036
					<info>
1037
						<author>muthusuba</author>
1038
						<desc>Merge Delimiter check box status</desc>
1039
						<label>MergeDelimiters</label>
1040
					</info>
1041
					<value>false</value>
1042
				</prop>
1043
				<prop oor:name="Separators" oor:type="xs:string">
1044
					<info>
1045
						<author>muthusuba</author>
1046
						<desc>List of Separators - as a String</desc>
1047
						<label>Separators</label>
1048
					</info>
1049
					<value>;	</value>
1050
				</prop>
1051
				<prop oor:name="TextSeparators" oor:type="xs:string">
1052
					<info>
1053
						<author>muthusuba</author>
1054
						<desc>Text Separators</desc>
1055
						<label>TextSeparators</label>
1056
					</info>
1057
					<value>"</value>
1058
				</prop>
1059
				<prop oor:name="FixedWidth" oor:type="xs:boolean">
1060
					<info>
1061
						<author>muthusuba</author>
1062
						<desc>Fixed width</desc>
1063
						<label>FixedWidth</label>
1064
					</info>
1065
					<value>false</value>
1066
				</prop>
1067
				<prop oor:name="FromRow" oor:type="xs:int">
1068
					<info>
1069
						<author>muthusuba</author>
1070
						<desc>From Row</desc>
1071
						<label>FromRow</label>
1072
					</info>
1073
					<value>1</value>
1074
				</prop>
1075
				<prop oor:name="CharSet" oor:type="xs:int">
1076
					<info>
1077
						<author>muthusuba</author>
1078
						<desc>Char Set</desc>
1079
						<label>CharSet</label>
1080
					</info>
1081
					<value>-1</value>
1082
				</prop>
1083
				<prop oor:name="FixedWidthList" oor:type="xs:string">
1084
					<info>
1085
						<author>muthusuba</author>
1086
						<desc>Fixed Width List of separators</desc>
1087
						<label>FixedWidthList</label>
1088
					</info>
1089
					<value></value>
1090
				</prop>
1091
			</group>
1092
		</group>
1027
		<group oor:name="Calculate">
1093
		<group oor:name="Calculate">
1028
			<info>
1094
			<info>
1029
				<desc>Contains settings that affect cell calculation.</desc>
1095
				<desc>Contains settings that affect cell calculation.</desc>
(-)sc.clean/source/ui/dbgui/csvruler.cxx (+75 lines)
Lines 48-55 Link Here
48
#endif
48
#endif
49
49
50
50
51
#include <optutil.hxx>
52
#include <com/sun/star/uno/Any.hxx>
53
#include <com/sun/star/uno/Sequence.hxx>
54
#include "miscuno.hxx"
55
56
using namespace rtl;
57
using namespace com::sun::star::uno;
58
59
60
61
// ============================================================================
62
#define SEP_PATH            "Office.Calc/Dialogs/CSVImport"
63
#define FIXED_WIDTH_LIST    "FixedWidthList"
64
65
51
// ============================================================================
66
// ============================================================================
52
67
68
static void load_FixedWidthList(ScCsvSplits &aSplits)
69
{
70
    String sSplits;
71
    OUString sFixedWidthLists;
72
73
    Sequence<Any>aValues;
74
    const Any *pProperties;
75
    Sequence<OUString> aNames(1);
76
    OUString* pNames = aNames.getArray();
77
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
78
79
    pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
80
    aValues = aItem.GetProperties( aNames );
81
    pProperties = aValues.getConstArray();
82
83
    if( pProperties[0].hasValue() )
84
    {
85
        aSplits.Clear();
86
        pProperties[0] >>= sFixedWidthLists;
87
88
        sSplits = String( sFixedWidthLists );
89
90
        // String ends with a semi-colon so there is no 'int' after the last one.
91
        for(int i=0;i<sSplits.GetTokenCount()-1;i++ )
92
            aSplits.Insert( sSplits.GetToken(i).ToInt32() );
93
    }
94
}
95
static void save_FixedWidthList(ScCsvSplits aSplits)
96
{
97
    int i;
98
    String sSplits;
99
    // Create a semi-colon separated string to save the splits
100
    for(i=0;i<aSplits.Count();i++)
101
    {
102
        sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
103
        sSplits.Append((char)';');
104
    }
105
106
    OUString sFixedWidthLists = OUString( sSplits );
107
    Sequence<Any> aValues;
108
    Any *pProperties;
109
    Sequence<OUString> aNames(1);
110
    OUString* pNames = aNames.getArray();
111
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
112
113
    pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
114
    aValues = aItem.GetProperties( aNames );
115
    pProperties = aValues.getArray();
116
    pProperties[0] <<= sFixedWidthLists;
117
118
    aItem.PutProperties(aNames, aValues);
119
}
120
53
ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
121
ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
54
    ScCsvControl( rParent ),
122
    ScCsvControl( rParent ),
55
    mnPosCursorLast( 1 )
123
    mnPosCursorLast( 1 )
Lines 59-64 ScCsvRuler::ScCsvRuler( ScCsvControl& rP Link Here
59
    InitSizeData();
127
    InitSizeData();
60
    maBackgrDev.SetFont( GetFont() );
128
    maBackgrDev.SetFont( GetFont() );
61
    maRulerDev.SetFont( GetFont() );
129
    maRulerDev.SetFont( GetFont() );
130
131
    load_FixedWidthList( maSplits );
132
}
133
134
ScCsvRuler::~ScCsvRuler()
135
{
136
    save_FixedWidthList( maSplits );
62
}
137
}
63
138
64
139
(-)sc.clean/source/ui/dbgui/scuiasciiopt.cxx (-13 / +133 lines)
Lines 56-61 Link Here
56
// ause
56
// ause
57
#include "editutil.hxx"
57
#include "editutil.hxx"
58
58
59
#include <optutil.hxx>
60
#include <com/sun/star/uno/Any.hxx>
61
#include <com/sun/star/uno/Sequence.hxx>
62
#include "miscuno.hxx"
63
64
59
//! TODO make dynamic
65
//! TODO make dynamic
60
#ifdef WIN
66
#ifdef WIN
61
const SCSIZE ASCIIDLG_MAXROWS                = 10000;
67
const SCSIZE ASCIIDLG_MAXROWS                = 10000;
Lines 63-68 const SCSIZE ASCIIDLG_MAXROWS Link Here
63
const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
69
const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
64
#endif
70
#endif
65
71
72
73
using namespace rtl;
74
using namespace com::sun::star::uno;
75
76
// Defines - CSV Import Preserve Options
77
#define FIXED_WIDTH         "FixedWidth"
78
#define FROM_ROW            "FromRow"
79
#define CHAR_SET            "CharSet"
80
#define SEPARATORS          "Separators"
81
#define TEXT_SEPARATORS     "TextSeparators"
82
#define MERGE_DELIMITERS    "MergeDelimiters"
83
#define SEP_PATH            "Office.Calc/Dialogs/CSVImport"
84
85
66
// ============================================================================
86
// ============================================================================
67
87
68
void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
88
void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
Lines 110-120 sal_Unicode lcl_CharFromCombo( ComboBox& Link Here
110
	return c;
130
	return c;
111
}
131
}
112
132
133
static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators, 
134
                             bool &bMergeDelimiters, bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet )
135
{
136
    Sequence<Any>aValues;
137
    const Any *pProperties;
138
    Sequence<OUString> aNames(6);
139
    OUString* pNames = aNames.getArray();
140
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
141
142
    pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
143
    pNames[1] = OUString::createFromAscii( SEPARATORS );
144
    pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
145
    pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
146
    pNames[4] = OUString::createFromAscii( FROM_ROW );
147
    pNames[5] = OUString::createFromAscii( CHAR_SET );
148
    aValues = aItem.GetProperties( aNames );
149
    pProperties = aValues.getConstArray();
150
    if( pProperties[1].hasValue() )
151
        pProperties[1] >>= sFieldSeparators;
152
153
    if( pProperties[2].hasValue() )
154
        pProperties[2] >>= sTextSeparators;
155
156
    if( pProperties[0].hasValue() )
157
        bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
158
159
    if( pProperties[3].hasValue() )
160
        bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
161
162
    if( pProperties[4].hasValue() )
163
        pProperties[4] >>= nFromRow;
164
165
    if( pProperties[5].hasValue() )
166
        pProperties[5] >>= nCharSet;
167
}
168
169
static void save_Separators( String maSeparators, String maTxtSep, bool bMergeDelimiters, 
170
                             bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet )
171
{
172
    OUString sFieldSeparators = OUString( maSeparators );
173
    OUString sTextSeparators = OUString( maTxtSep );
174
    Sequence<Any> aValues;
175
    Any *pProperties;
176
    Sequence<OUString> aNames(6);
177
    OUString* pNames = aNames.getArray();
178
    ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
179
180
    pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
181
    pNames[1] = OUString::createFromAscii( SEPARATORS );
182
    pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
183
    pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
184
    pNames[4] = OUString::createFromAscii( FROM_ROW );
185
    pNames[5] = OUString::createFromAscii( CHAR_SET );
186
    aValues = aItem.GetProperties( aNames );
187
    pProperties = aValues.getArray();
188
    pProperties[1] <<= sFieldSeparators;
189
    pProperties[2] <<= sTextSeparators;
190
    ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
191
    ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
192
    pProperties[4] <<= nFromRow;
193
    pProperties[5] <<= nCharSet;
194
195
    aItem.PutProperties(aNames, aValues);
196
}
113
197
114
// ----------------------------------------------------------------------------
198
// ----------------------------------------------------------------------------
115
199
116
ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
200
ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
117
									SvStream* pInStream, sal_Unicode cSep ) :
201
                                    SvStream* pInStream, sal_Unicode /*cSep*/ ) :
118
		ModalDialog	( pParent, ScResId( RID_SCDLG_ASCII ) ),
202
		ModalDialog	( pParent, ScResId( RID_SCDLG_ASCII ) ),
119
        mpDatStream  ( pInStream ),
203
        mpDatStream  ( pInStream ),
120
        mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
204
        mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
Lines 158-171 ScImportAsciiDlg::ScImportAsciiDlg( Wind Link Here
158
		aFldSepList	( ScResId( SCSTR_FIELDSEP ) ),
242
		aFldSepList	( ScResId( SCSTR_FIELDSEP ) ),
159
		aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
243
		aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
160
        mcTextSep   ( ScAsciiOptions::cDefaultTextSep ),
244
        mcTextSep   ( ScAsciiOptions::cDefaultTextSep ),
161
        maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) )
245
        maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
246
        mbFileImport(true)
162
{
247
{
163
	FreeResource();
248
	FreeResource();
249
    mbFileImport = aDatName.Len() > 0;
164
250
165
	String aName = GetText();
251
	String aName = GetText();
166
    // aDatName is empty if invoked during paste from clipboard.
252
    // aDatName is empty if invoked during paste from clipboard.
167
    BOOL bClipboard = (aDatName.Len() == 0);
253
    if (mbFileImport)
168
    if (!bClipboard)
169
    {
254
    {
170
        aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
255
        aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
171
        aName += aDatName;
256
        aName += aDatName;
Lines 173-192 ScImportAsciiDlg::ScImportAsciiDlg( Wind Link Here
173
    }
258
    }
174
	SetText( aName );
259
	SetText( aName );
175
260
176
	switch(cSep)
261
262
    OUString sFieldSeparators;
263
    OUString sTextSeparators;
264
    bool bMergeDelimiters = false;
265
    bool bFixedWidth = false;
266
    sal_Int32 nFromRow = 1;
267
    sal_Int32 nCharSet = -1;
268
    if (mbFileImport)
269
        // load separators only when importing csv files.
270
        load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters, bFixedWidth, nFromRow, nCharSet);
271
    maFieldSeparators = String(sFieldSeparators);
272
273
    if( bMergeDelimiters )
274
        aCkbAsOnce.Check();
275
    if( bFixedWidth )
276
        aRbFixed.Check();
277
    if( nFromRow != 1 )
278
        aNfRow.SetValue( nFromRow );
279
280
    ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
281
    const sal_Char *aSep = bString.GetBuffer();
282
    int len = maFieldSeparators.Len();
283
    for (int i = 0; i < len; ++i)
177
    {
284
    {
178
        case '\t':  aCkbTab.Check();        break;
285
        switch( aSep[i] )
179
        case ';':   aCkbSemicolon.Check();  break;
286
        {
180
        case ',':   aCkbComma.Check();      break;
287
            case '\t':  aCkbTab.Check();        break;
181
        case ' ':   aCkbSpace.Check();      break;
288
            case ';':   aCkbSemicolon.Check();  break;
182
        default:
289
            case ',':   aCkbComma.Check();      break;
183
            aCkbOther.Check();
290
            case ' ':   aCkbSpace.Check();      break;
184
            aEdOther.SetText( cSep );
291
            default:
292
                aCkbOther.Check();
293
                aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
294
        }
185
    }
295
    }
296
    
297
    // Get Separators from the dialog
186
    maFieldSeparators = GetSeparators();
298
    maFieldSeparators = GetSeparators();
187
299
188
    // Clipboard is always Unicode, else detect.
300
    // Clipboard is always Unicode, else detect.
189
	BOOL bPreselectUnicode = bClipboard;
301
    bool bPreselectUnicode = !mbFileImport;
190
	// Sniff for Unicode / not
302
	// Sniff for Unicode / not
191
    if( !bPreselectUnicode && mpDatStream )
303
    if( !bPreselectUnicode && mpDatStream )
192
	{
304
	{
Lines 222-227 ScImportAsciiDlg::ScImportAsciiDlg( Wind Link Here
222
334
223
    // *** Separator characters ***
335
    // *** Separator characters ***
224
    lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
336
    lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
337
    aCbTextSep.SetText( sTextSeparators );
225
338
226
    Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
339
    Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
227
    aCbTextSep.SetSelectHdl( aSeparatorHdl );
340
    aCbTextSep.SetSelectHdl( aSeparatorHdl );
Lines 242-247 ScImportAsciiDlg::ScImportAsciiDlg( Wind Link Here
242
	aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
355
	aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
243
	aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
356
	aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
244
		RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
357
		RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
358
359
    if( nCharSet >= 0 )
360
        aLbCharSet.SelectEntryPos( nCharSet );
361
245
    SetSelectedCharSet();
362
    SetSelectedCharSet();
246
	aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
363
	aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
247
364
Lines 273-278 ScImportAsciiDlg::ScImportAsciiDlg( Wind Link Here
273
390
274
ScImportAsciiDlg::~ScImportAsciiDlg()
391
ScImportAsciiDlg::~ScImportAsciiDlg()
275
{
392
{
393
    if (mbFileImport)
394
        save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(), 
395
                         aRbFixed.IsChecked(), aNfRow.GetValue(), aLbCharSet.GetSelectEntryPos());
276
	delete[] mpRowPosArray;
396
	delete[] mpRowPosArray;
277
}
397
}
278
398
(-)sc.clean/source/ui/inc/csvruler.hxx (+1 lines)
Lines 86-91 private: Link Here
86
    // ------------------------------------------------------------------------
86
    // ------------------------------------------------------------------------
87
public:
87
public:
88
    explicit                    ScCsvRuler( ScCsvControl& rParent );
88
    explicit                    ScCsvRuler( ScCsvControl& rParent );
89
                                ~ScCsvRuler();
89
90
90
    // common ruler handling --------------------------------------------------
91
    // common ruler handling --------------------------------------------------
91
public:
92
public:
(-)sc.clean/source/ui/inc/scuiasciiopt.hxx (+1 lines)
Lines 92-97 class ScImportAsciiDlg : public ModalDia Link Here
92
92
93
    CharSet                     meCharSet;          /// Selected char set.
93
    CharSet                     meCharSet;          /// Selected char set.
94
    bool                        mbCharSetSystem;    /// Is System char set selected?
94
    bool                        mbCharSetSystem;    /// Is System char set selected?
95
    bool                        mbFileImport;       /// Is this dialog involked for csv file import ?
95
96
96
public:
97
public:
97
                                ScImportAsciiDlg(
98
                                ScImportAsciiDlg(

Return to issue 3687