-
Notifications
You must be signed in to change notification settings - Fork 1
/
importparams.h
422 lines (307 loc) · 12.9 KB
/
importparams.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/*//////////////////////////////////////////////////////////////////////////////
// Name: importparams.h
// Purpose: Interface of CImportParams, describes how the import should akt,
// including several dependant classes
// Author: Ruediger Herrmann
// Copyright: (c) Ruediger Herrmann
//////////////////////////////////////////////////////////////////////////////*/
#if !defined ( _IMPORTPARAMS_H_ )
#define _IMPORTPARAMS_H_
#include "resource.h"
#if _MSC_VER > 1000
#pragma once
#endif /* _MSC_VER > 1000 */
class CFieldConversion : public CObject {
protected:
DECLARE_SERIAL ( CFieldConversion );
public:
CFieldConversion();
virtual void Serialize ( CArchive& ar );
CFieldConversion& operator = ( CFieldConversion& RightSideArgument );
inline const CString& GetDataTypeName() const { return m_DataTypeName; }
inline void SetName ( const CString& Value ) { m_Name = Value; }
inline const CString& GetName() const { return m_Name; }
inline void SetFestwert ( const CString& Value ) { m_Festwert = Value; }
inline const CString& GetFestwert() const { return m_Festwert; }
inline void SetSourceFieldID ( int Value ) { m_SourceFieldID = Value; }
inline int GetSourceFieldID () const { return m_SourceFieldID; } // is -1 when no source field assigned
inline void SetBuchung ( CImportBuchung* Value ) { m_pBuchung = Value; }
inline void SetLine ( CStringArray* Value ) { m_Line = Value; }
inline const CStringArray& GetLine() const { return *m_Line; }
inline const CString& GetErrorMsg() const { return m_ErrorMsg; }
virtual BOOL Exchange ( void* Dest );
virtual BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
virtual BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
BOOL CheckSourceFieldID();
CString m_DataTypeName;
private:
int m_SourceFieldID;
CString m_Name;
CImportBuchung* m_pBuchung;
CStringArray* m_Line;
CString m_ErrorMsg;
CString m_Festwert;
};
class CIntFieldConversion : public CFieldConversion {
protected:
DECLARE_SERIAL ( CIntFieldConversion );
public:
enum BlankHandling
{
bhIgnoreBlank = 0,
bhBlankIsZero = 1,
bhBlankIsError = 2
};
CIntFieldConversion();
virtual void Serialize ( CArchive& ar );
inline void SetBlankHandling ( const BlankHandling Value ) { m_BlankHandling = Value; }
virtual BOOL Exchange ( void* Dest );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
virtual void AssignFrom ( CIntFieldConversion* const Source );
private:
BlankHandling m_BlankHandling;
};
class CDateFieldConversion : public CFieldConversion {
protected:
DECLARE_SERIAL ( CDateFieldConversion );
public:
enum DateFormat {
dfDMY = 0,
dfMDY = 1,
dfYMD = 2,
dfDMYY = 3,
dfMDYY = 4,
dfYYMD = 5
};
CDateFieldConversion();
virtual void Serialize ( CArchive& ar );
inline void SetFormat ( const DateFormat Value ) { m_Format = Value; }
inline DateFormat GetFormat () const { return m_Format; };
inline void SetDelimiter ( const CString& Value ) { m_Delimiter = Value; }
inline const CString& GetDelimiter () const { return m_Delimiter; }
virtual BOOL Exchange ( void* Dest );
virtual BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
virtual BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
virtual void AssignFrom ( CDateFieldConversion* const Source );
private:
DateFormat m_Format;
CString m_Delimiter;
};
class CTextFieldConversion : public CFieldConversion {
DECLARE_SERIAL ( CTextFieldConversion );
public:
CTextFieldConversion();
void Serialize ( CArchive& ar );
virtual BOOL Exchange ( void* Dest );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
};
class CCurrencyFieldConversion : public CFieldConversion {
protected:
DECLARE_SERIAL ( CCurrencyFieldConversion );
public:
enum CurrencyFormat {
cfGerman = 0,
cfEnglish = 1,
cf100 = 2
};
CCurrencyFieldConversion();
virtual void Serialize ( CArchive& ar );
inline void SetFormat ( const CurrencyFormat& Value ) { m_Format = Value; }
inline CurrencyFormat GetFormat () const { return m_Format; };
virtual BOOL Exchange ( void* Dest );
virtual BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
virtual BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
virtual void AssignFrom ( CCurrencyFieldConversion* const Source );
private:
CurrencyFormat m_Format;
};
class CEAFieldConversion : public CFieldConversion {
protected:
DECLARE_SERIAL ( CEAFieldConversion );
public:
enum ConversionRule {
cUseFormat = 0,
cIncomeOnly = 1,
cExpenseOnly = 2,
cUseSign = 3
};
enum EinnahmeAusgabe {
eaUnknown = 0,
eaIncome = 1,
eaExpense = 2
};
CEAFieldConversion();
virtual void Serialize ( CArchive& ar );
void SetConversionRule ( const ConversionRule& Value );
inline const ConversionRule GetConversionRule () const { return m_ConversionRule; };
inline void SetFormatIncome ( const CString& Value ) { m_FormatIncome = Value; }
inline const CString& GetFormatIncome() const { return m_FormatIncome; };
inline void SetFormatExpense ( const CString& Value ) { m_FormatExpense = Value; }
inline const CString& GetFormatExpense() const { return m_FormatExpense; };
virtual BOOL Exchange ( void* Dest );
virtual BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
virtual BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
virtual void AssignFrom ( CEAFieldConversion* const Source );
private:
ConversionRule m_ConversionRule;
CString m_FormatIncome;
CString m_FormatExpense;
};
class CBruttoNettoFieldConversion : public CFieldConversion {
protected:
DECLARE_SERIAL ( CBruttoNettoFieldConversion );
public:
enum ConversionRule {
cUseFormat = 0,
cBruttoOnly = 1,
cNettoOnly = 2,
};
enum BruttoNetto {
bnUnknown = 0,
bnBrutto = 1,
bnNetto = 2
};
CBruttoNettoFieldConversion();
virtual void Serialize ( CArchive& ar );
void SetConversionRule ( const ConversionRule& Value );
inline const ConversionRule GetConversionRule () const { return m_ConversionRule; };
inline void SetFormatBrutto ( const CString& Value ) { m_FormatBrutto = Value; }
inline const CString& GetFormatBrutto() const { return m_FormatBrutto; };
inline void SetFormatNetto ( const CString& Value ) { m_FormatNetto = Value; }
inline const CString& GetFormatNetto() const { return m_FormatNetto; };
virtual BOOL Exchange ( void* Dest );
virtual BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
virtual BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
virtual void Init();
protected:
virtual void AssignFrom ( CFieldConversion* const Source );
virtual void AssignFrom ( CBruttoNettoFieldConversion* const Source );
private:
ConversionRule m_ConversionRule;
CString m_FormatBrutto;
CString m_FormatNetto;
};
class CImportParams : public CObject {
protected:
DECLARE_SERIAL ( CImportParams );
public:
static CImportParams* CreateStandard();
/*
enum Fields {
fldMin = 0,
fldEinAus = 0,
fldDatum = 1,
fldKonto = 2,
fldText = 3,
fldBrutto = 4,
fldNetto = 5,
fldSteuer = 6,
fldAfaNr = 7,
fldAfaJahre = 8,
fldMax = 8
};
*/
CImportParams();
virtual ~CImportParams();
virtual void Serialize ( CArchive& ar );
BOOL Validate ( CString* ErrorMsg = NULL );
inline void SetName ( const CString& Value ) { m_Name = Value; }
inline const CString& GetName () const { return m_Name; }
inline void SetSeparatorChar ( const CString& Value ) { m_SeparatorChar = Value; }
inline const CString& GetSeparatorChar () const { return m_SeparatorChar; }
inline void SetFilename ( const CString Value ) { m_Filename = Value; }
inline const CString& GetFilename () const { return m_Filename; }
inline void SetGawkScript ( const CString Value ) { m_GawkScript = Value; }
inline const CString& GetGawkScript () const { return m_GawkScript; }
BOOL SetHeaderCount ( int Value );
inline int GetHeaderCount() const { return m_HeaderCount; }
inline void SetColumnWidth ( int Index, int Value ) { m_ColumnWidths.SetAtGrow(Index, Value); }
inline int GetColumnWidth( int Index ) const { return Index >= m_ColumnWidths.GetSize() ? 0 : m_ColumnWidths[Index]; }
// ??? *** !!! hötzen? quirk! tüddelpipp/
inline CStringArray* const GetColumnNames () { return &m_ColumnNames; }
inline CEAFieldConversion* const GetFieldEA () { return &m_FieldEA; }
inline CDateFieldConversion* const GetFieldDatum () { return &m_FieldDatum; }
inline CCurrencyFieldConversion* const GetFieldBetrag () { return &m_FieldBetrag; }
inline CBruttoNettoFieldConversion* const GetFieldBruttoNetto () { return &m_FieldBruttoNetto; }
inline CTextFieldConversion* const GetFieldBeschreibung () { return &m_FieldBeschreibung; }
inline CTextFieldConversion* const GetFieldBelegnummer () { return &m_FieldBelegnummer; }
inline CTextFieldConversion* const GetFieldKonto () { return &m_FieldKonto; }
inline CCurrencyFieldConversion* const GetFieldSteuersatz () { return &m_FieldSteuersatz; }
inline CIntFieldConversion* const GetFieldAfAAktJahr () { return &m_FieldAfAAktJahr; }
inline CIntFieldConversion* const GetFieldAfADauer () { return &m_FieldAfADauer; }
inline CCurrencyFieldConversion* const GetFieldAfADegSatz () { return &m_FieldAfADegSatz; }
inline CCurrencyFieldConversion* const GetFieldAfARestwert () { return &m_FieldAfARestwert; }
inline CIntFieldConversion* const GetFieldAfAGenauigkeit () { return &m_FieldAfAGenauigkeit; }
inline CTextFieldConversion* const GetFieldBetrieb () { return &m_FieldBetrieb; }
inline CTextFieldConversion* const GetFieldBestandskonto () { return &m_FieldBestandskonto; }
CImportParams& operator = ( CImportParams& RightSideArgument );
BOOL LoadFromIniFile ( const CString &Filename, const CString& Sectionname );
BOOL SaveToIniFile ( const CString &Filename, const CString& Sectionname );
void Init();
protected:
private:
CString m_Name;
CString m_SeparatorChar;
CString m_Filename;
CString m_GawkScript;
int m_HeaderCount;
CStringArray m_ColumnNames;
CArray<int,int&> m_ColumnWidths;
CEAFieldConversion m_FieldEA;
CDateFieldConversion m_FieldDatum;
CCurrencyFieldConversion m_FieldBetrag;
CBruttoNettoFieldConversion m_FieldBruttoNetto;
CTextFieldConversion m_FieldBeschreibung;
CTextFieldConversion m_FieldBelegnummer;
CTextFieldConversion m_FieldKonto;
CCurrencyFieldConversion m_FieldSteuersatz;
CIntFieldConversion m_FieldAfAAktJahr;
CIntFieldConversion m_FieldAfADauer;
CCurrencyFieldConversion m_FieldAfADegSatz;
CCurrencyFieldConversion m_FieldAfARestwert;
CIntFieldConversion m_FieldAfAGenauigkeit;
CTextFieldConversion m_FieldBetrieb;
CTextFieldConversion m_FieldBestandskonto;
};
#define SEC_CSVIMPORT _T("CSVIMPORT")
#define KEY_DEFAULT_IMPORT_PARAMS _T("DefaultImportParams")
class CImportParamsList : public CObArray {
protected:
DECLARE_SERIAL ( CImportParamsList )
public:
~CImportParamsList();
virtual void Serialize ( CArchive& ar );
inline CImportParams* const GetDefaultImportParams() const { return m_DefaultImportParams; }
BOOL SetDefaultImportParams ( CImportParams* const Value );
inline BOOL IsEmpty() const { return GetSize() == 0 ? TRUE : FALSE; }
void RemoveAll ();
void RemoveAt ( int nIndex, int nCount = 1 );
BOOL CImportParamsList::Contains ( CImportParams* Element ) const;
int FindByName ( const CString& AName ) const;
static inline void BuildSectionname ( CString* Sectionname, const int Number );
BOOL LoadFromIniFile ();
BOOL LoadFromIniFile ( const CString &Filename );
BOOL SaveToIniFile ();
BOOL SaveToIniFile ( const CString &Filename );
protected:
private:
CImportParams* m_DefaultImportParams;
void FreeObjects ( int StartIndex, int Count );
};
#endif /* _IMPORTPARAMS_H_ */