From 207991605ebb8d3cf012f1c7f62eb30a3e27a706 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 12:44:56 +0100 Subject: [PATCH 1/7] Patch level : nopatch Files correlati : Commento : Agguinti metodi per la creazione di tracciati record temporanei --- src/include/files.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++ src/include/files.h | 26 ++++++++-- 2 files changed, 136 insertions(+), 4 deletions(-) diff --git a/src/include/files.cpp b/src/include/files.cpp index a1508e8bd..6cb2ee9bd 100755 --- a/src/include/files.cpp +++ b/src/include/files.cpp @@ -646,6 +646,8 @@ bool TDir::is_active () const return main_app().has_module(module, CHK_DONGLE); } +// riimplementare nella 13 + void TTrec::update_fielddef (int nfld, TToken_string& s) { RecFieldDes& rfd = _rec.Fd[nfld]; @@ -655,6 +657,59 @@ void TTrec::update_fielddef (int nfld, TToken_string& s) rfd.Dec = s.get_int (); } +void TTrec::update_fielddef(int nfld, const char * name, int type, int len, int dec) +{ + if (nfld < 0) + nfld = _rec.NFields++; + + RecFieldDes& rfd = _rec.Fd[nfld]; + + strcpy(rfd.Name, name); + rfd.TypeF = type; + if (len <= 0) + { + switch (rfd.TypeF) + { + case _datefld: + rfd.Len = 8; + rfd.Dec = 0; + break; + case _charfld: + case _boolfld: + rfd.Len = 1; + rfd.Dec = 0; + break; + case _memofld: + rfd.Len = 10; + rfd.Dec = 0; + break; + default: + message_box("Lunghezza errata"); + break; + } + } + else + { + rfd.Len = len; + rfd.Dec = dec; + } +} + +void TTrec::update_fielddef(int nfld, const RecDes & rd, const char * name) +{ + int i = -1; + + for (i = 0; i < rd.NFields; i++) + if (strcmp(rd.Fd[i].Name, name) == 0) + break; + if (i >= 0) + update_fielddef(nfld, rd.Fd[i].Name, rd.Fd[i].TypeF, rd.Fd[i].Len, rd.Fd[i].Dec); +} + + +// riimplementare nella 13 + + void TTrec::update_keydef (int key, TToken_string& s) { TExpression expr ("", _strexpr); @@ -704,6 +759,56 @@ void TTrec::update_keydef (int key, TToken_string& s) } } +void TTrec::update_keydef(int key, const char * e, const bool dup) +{ + TExpression expr ("", _strexpr); + TString ke (e); + + if (key < 0) + key = _rec.NKeys++; + if (expr.set(ke, _strexpr)) + { + _rec.Ky[key].DupKeys = dup; + TCodearray & c = expr.code (); + c.begin (); + int n = 0; + while (!c.end ()) + { + TCode & inst = c.step (); + TCodesym sym = inst.getsym (); + + if (sym == _variable) + { + const char *s = inst.string (); + int i; + + for (i = 0; i < _rec.NFields; i++) + if (strcmp (_rec.Fd[i].Name, s) == 0) + break; + + _rec.Ky[key].FieldSeq[n] = i; + _rec.Ky[key].FromCh[n] = INVFLD; + _rec.Ky[key].ToCh[n] = INVFLD; + inst = c.step (); + sym = inst.getsym (); + if (sym == _upper) + _rec.Ky[key].FieldSeq[n] += MaxFields; + else if (sym == _number) + { + _rec.Ky[key].FromCh[n] = (int)inst.number().integer() - 1; + inst = c.step (); + _rec.Ky[key].ToCh[n] = _rec.Ky[key].FromCh[n] + (int)inst.number ().integer () - 1; + inst = c.step (); + } + else + c.backtrace (); + n++; + } + } + _rec.Ky[key].NkFields = n; + } +} + void TTrec::print_on(ostream & out) const { const int n = num(); @@ -779,5 +884,14 @@ void TTrec::read_from(istream & in) _des = NULL; _tab = ""; } +void TTrec::set_name(const char * name, int nfld) +{ + if (nfld < 0) + nfld = _rec.NFields - 1; + + RecFieldDes& rfd = _rec.Fd[nfld]; + + strcpy(rfd.Name, name); +} #endif // FOXPRO diff --git a/src/include/files.h b/src/include/files.h index b1937098c..3358272bb 100755 --- a/src/include/files.h +++ b/src/include/files.h @@ -230,15 +230,33 @@ public: int len() const; #ifndef FOXPRO - // @cmember Aggiorna la chiave.

e' una token string - void update_keydef(int key, TToken_string& desc); - // @cmember Aggiorna il campo.

e' una token string - void update_fielddef(int nfld, TToken_string& desc); + // @cmember Aggiorna la chiave.

e' una token string + void update_keydef(int key, const char * e, const bool dup); + // @cmember Aggiorna la chiave.

e' una token string + void update_keydef(int key, TToken_string& desc); + // @cmember Aggiunge una chiave.

e' una token string + void add_keydef(TToken_string& desc) { update_keydef(-1, desc); } + // @cmember Aggiunge una chiave.

e' una token string + void add_keydef(const char * e, const bool dup) { update_keydef(-1, e, dup); } + // @cmember Aggiorna il campo. + void update_fielddef(int nfld, const char * name, int type, int len = 0, int dec = 0); + // @cmember Aggiorna il campo.

e' una token string + void update_fielddef(int nfld, TToken_string& desc); + // @cmember Aggiorna il campo. + void update_fielddef(int nfld, const RecDes & rd, const char * name); + // @cmember Aggiunge un campo.

e' una token string + void add_fielddef(TToken_string& desc) { update_fielddef(-1, desc); } + // @cmember Aggiunge un campo. + void add_fielddef(const char * name, int type, int len = 0, int dec = 0) { update_fielddef(-1, name, type, len, dec); } + // @cmember Aggiunge un campo. + void add_fielddef(const RecDes & rd, const char * name) { update_fielddef(-1, rd, name); } // @cmember Stampa il tracciato record sull'output selezionato virtual void print_on(ostream& out) const; // @cmember Legge il tracciato record da input selezionato virtual void read_from(istream& in); void set_des(TConfig* c = NULL, const char* tab = "") { _des = c; _tab = tab;} + void set_name(const char * name, int pos = -1); + #endif // @cmember Duplica il descrittore di file virtual TObject* dup() const { return new TTrec(*this);} From eb0249c3c9b421f99bfdc44fa619b8361b74cf2f Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 12:51:17 +0100 Subject: [PATCH 2/7] Patch level : nopatch Files correlati : Commento : Aggiunto il salvataggio dei valori di un maschera (Alt-S) e il caricamento (Alt-L) --- src/include/mask.cpp | 236 ++++++++++++++++++++++++------------------- src/include/mask.h | 4 +- 2 files changed, 133 insertions(+), 107 deletions(-) diff --git a/src/include/mask.cpp b/src/include/mask.cpp index aa56652d1..b6cdfc854 100755 --- a/src/include/mask.cpp +++ b/src/include/mask.cpp @@ -680,7 +680,7 @@ int TMask::id2pos( TMask_field& TMask::field(short id) const { TMask_field* f = find_by_id(id); - if (f == NULL) + if (f == nullptr) { if (_mask_num == 0) yesnofatal_box("Non esiste il campo %d sulla maschera %s", id, (const char*)_source_file); @@ -1042,114 +1042,134 @@ bool TMask::on_key( return false; } - switch(key) - { - case K_AUTO_ENTER: - case K_CTRL_ENTER: - case K_QUIT: - case K_ESC: - stop_run(key); - break; - case K_PREV: - if (fld(_focus).on_key(K_TAB)) - next_page(-1); - break; - case K_NEXT: - if (fld(_focus).on_key(K_TAB)) - next_page(+1); - break; - case K_F1: - { - const char* key = source_file().name_only(); - EVENT e; memset(&e, 0, sizeof(e)); - e.type = E_HELP; - e.v.help.tag = M_HELP_ONCONTEXT; - e.v.help.obj = win(); - e.v.help.tid = (long)key; + switch (key) + { + case K_AUTO_ENTER: + case K_CTRL_ENTER: + case K_QUIT: + case K_ESC: + stop_run(key); + break; + case K_PREV: + if (fld(_focus).on_key(K_TAB)) + next_page(-1); + break; + case K_NEXT: + if (fld(_focus).on_key(K_TAB)) + next_page(+1); + break; + case K_F1: + { + const char* key = source_file().name_only(); + EVENT e; memset(&e, 0, sizeof(e)); + e.type = E_HELP; + e.v.help.tag = M_HELP_ONCONTEXT; + e.v.help.obj = win(); + e.v.help.tid = (long)key; - TFilename n = "campo"; - TString4 module; module.strncpy(key, 2); module.lower(); - if (module != "ba") - n.insert(module); - FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs); - XVT_HELP_INFO hi = xvt_help_open_helpfile(&fs, 0); - xvt_help_process_event(hi, win(), &e); - } - break; - case K_F12: + TFilename n = "campo"; + TString4 module; module.strncpy(key, 2); module.lower(); + if (module != "ba") + n.insert(module); + FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs); + XVT_HELP_INFO hi = xvt_help_open_helpfile(&fs, 0); + xvt_help_process_event(hi, win(), &e); + } + break; + case K_F12: send_key(K_F12, focus_field().dlg()); - break; - case K_SHIFT+K_F11: + break; + case K_SHIFT + K_F11: if (is_power_station()) - { - _bShowGrid = !_bShowGrid; - xvt_dwin_invalidate_rect(curr_win(), NULL); - } - break; - case K_CTRL+'+': - if (is_running()) - { - // Cerco nella pagina corrente il primo spreadsheet a partire dal campo col focus - if (_focus < 0) _focus = 0; - const WINDOW myparent = fld(_focus).parent(); - for (int fire = _focus; fire < fields(); fire++) - { - TMask_field& f = fld(fire); - if (f.parent() != myparent) - break; - if (f.is_sheet()) - { + { + _bShowGrid = !_bShowGrid; + xvt_dwin_invalidate_rect(curr_win(), NULL); + } + break; + case K_CTRL + '+': + if (is_running()) + { + // Cerco nella pagina corrente il primo spreadsheet a partire dal campo col focus + if (_focus < 0) _focus = 0; + const WINDOW myparent = fld(_focus).parent(); + for (int fire = _focus; fire < fields(); fire++) + { + TMask_field& f = fld(fire); + if (f.parent() != myparent) + break; + if (f.is_sheet()) + { send_key(key, f.dlg()); break; - } - } - } - break; -/* - case K_CTRL+'-': - if (is_running() && focus_field().is_sheet()) - send_key(key, focus_field().dlg()); - break; -*/ - default: - if (key > K_CTRL) - { - key -= K_CTRL; - if (key >= K_F1 && key <= K_F12) - { - const int page = key - K_F1; - if (page < _pages && fld(_focus).on_key(K_TAB)) - show_page(page); - } - else - { - for (int i = fields()-1; i >= 0; i--) - { - TMask_field& f = fld(i); - if (f.is_operable() && !f.is_editable() && f.active()) - { - KEY vk = 0; - if (f.is_kind_of(CLASS_BUTTON_FIELD)) - { - TButton_field& b = (TButton_field&)f; - vk = b.virtual_key(); - } else - if (f.is_kind_of(CLASS_BUTTON_TOOL)) - { - TButton_tool& t = (TButton_tool&)f; - vk = t.virtual_key(); - } - if (vk > 0 && vk == key) - { - f.on_key(K_SPACE); - break; - } - } - } - } - } - } + } + } + } + break; + /* + case K_CTRL+'-': + if (is_running() && focus_field().is_sheet()) + send_key(key, focus_field().dlg()); + break; + */ + default: + if (key > K_CTRL) + { + key -= K_CTRL; + if (key >= K_F1 && key <= K_F12) + { + const int page = key - K_F1; + if (page < _pages && fld(_focus).on_key(K_TAB)) + show_page(page); + } + else + if (UPCASE(key) == 'S') + { + TFilename fname; + + if (fname.input(false)) + save(fname); + } + else + if (UPCASE(key) == 'L') + { + TFilename fname; + + if (fname.input()) + load(fname); + } + else + { + for (int i = fields() - 1; i >= 0; i--) + { + TMask_field& f = fld(i); + + if (f.is_operable() && !f.is_editable() && f.active()) + { + KEY vk = 0; + + if (f.is_kind_of(CLASS_BUTTON_FIELD)) + { + TButton_field& b = (TButton_field&)f; + vk = b.virtual_key(); + } + else + if (f.is_kind_of(CLASS_BUTTON_TOOL)) + { + TButton_tool& t = (TButton_tool&)f; + + vk = t.virtual_key(); + } + if (vk > 0 && vk == key) + { + f.on_key(K_SPACE); + break; + } + } + } + } + } + } return true; } @@ -2511,11 +2531,14 @@ TButton_tool& TMask::add_button_tool(short id, const char* prompt, short bmpup) // // @flag true | Se l'operazione e' avvenuta corretamente // @flag false | Se non si riesce a creare il file di salvataggio -bool TMask::save( +bool TMask::save(const TFilename & fname, // @parm nome del file, se vuoto usa _workfile bool append) const // @parm Indica se creare il file o appendere (true) le informazioni // ad uno gia' esistente (false, default). { + if (fname.full()) + ((TMask *)this)->set_workfile(fname); + FILE* f = fopen(_workfile, append ? "a" : "w"); if (f == nullptr) @@ -2542,13 +2565,16 @@ bool TMask::save( // // @flag true | Se l'operazione e' avvenuta corretamente // @flag false | Se non si riesce a leggere il file di salvataggio -bool TMask::load( +bool TMask::load(const TFilename & fname, // @parm nome del file, se vuoto usa _workfile bool reset) // @parm Indica la posizione di lettura del file: // // @flag true | Comincia la lettura dell'inizio // @flag false | Comincia la lettura dalla posizione corrente dell'offset { + if (fname.full()) + ((TMask *)this)->set_workfile(fname); + FILE* f = fopen(_workfile, "r"); if (f == nullptr) diff --git a/src/include/mask.h b/src/include/mask.h index 0f6975dbf..12f87cc43 100755 --- a/src/include/mask.h +++ b/src/include/mask.h @@ -449,9 +449,9 @@ public: void set_workfile(const char* workfile) { _workfile = workfile; _lastpos = 0L;} // @cmember Salva i valori dei campi della maschera sul file di salvataggio - bool save(bool append = false) const; + bool save(const TFilename & fname = EMPTY_STRING, bool append = false) const; // @cmember Legge i valori dei campi della maschera da file di salvataggio - bool load(bool reset = false); + bool load(const TFilename & fname = EMPTY_STRING, bool reset = false); // @cmember Copia i valori dei campi dalla maschera

void copy_values(const TMask &m); From fa0215234f523f40a3a551487ff9b18b7b415d48 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 12:53:39 +0100 Subject: [PATCH 3/7] Patch level : nopatch Files correlati : Commento : corretti i check dei brwbut --- src/include/maskfld.cpp | 15 +++++++++------ src/include/maskfld.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/include/maskfld.cpp b/src/include/maskfld.cpp index dd1d21926..e91a2c512 100755 --- a/src/include/maskfld.cpp +++ b/src/include/maskfld.cpp @@ -2811,16 +2811,19 @@ bool TEdit_field::on_key(KEY key) { ok = !(check_type() == CHECK_REQUIRED && empty()); // check consistency - if (!ok && _browse != nullptr && _browse->is_kind_of(CLASS_RSELECT_BUTTON)) + if (!ok && _browse != nullptr && _browse->is_reportsel()) ok = true; - if (ok && _browse) + if (ok && _browse != nullptr) { - if (browse() && !_browse->is_kind_of(CLASS_RSELECT_BUTTON)) + if (browse() != nullptr && !_browse->is_reportsel()) { - if (ok && check_enabled() && vf != 21) // 21 = NOT_EMPTY_CHECK_FIELD + if (ok && check_enabled() && vf != 21 && !_browse->is_filesel() && !_browse->is_profile()) // 21 = NOT_EMPTY_CHECK_FIELD { - if (dirty()) ok = browse()->check(FINAL_CHECK); // Check consistency - else ok = browse()->empty_check(); + + if (dirty()) + ok = browse()->check(FINAL_CHECK); // Check consistency + else + ok = browse()->empty_check(); } } else diff --git a/src/include/maskfld.h b/src/include/maskfld.h index 56ce937af..3294a99ba 100755 --- a/src/include/maskfld.h +++ b/src/include/maskfld.h @@ -934,18 +934,18 @@ public: virtual bool check(CheckTime = RUNNING_CHECK); // @cmember Ritorna l'oggetto browse - TBrowse* browse() const - { return (_browse && _browse->is_browse()) ? (TBrowse*)_browse : NULL; } + TBrowse * browse() const { return (_browse && _browse->is_browse()) ? (TBrowse *)_browse : NULL; } // @cmember Ritorna l'oggetto sheet - TList_sheet* sheet() const - { return (_browse && _browse->is_sheet()) ? (TList_sheet*)_browse : NULL;} + TList_sheet * sheet() const { return (_browse && _browse->is_sheet()) ? (TList_sheet *)_browse : NULL;} - // @cmember Ritorna l'oggetto dirsheet - TFile_select* filesel() const - { return (_browse && _browse->is_filesel()) ? (TFile_select*)_browse : NULL;} + // @cmember Ritorna l'oggetto dir sheet + TFile_select * filesel() const { return (_browse && _browse->is_filesel()) ? (TFile_select*)_browse : NULL;} - // @cmember Permette di abilitare/disabilitare il campo + // @cmember Ritorna l'oggetto report sheet + TReport_select * reportsel() const{ return (_browse && _browse->is_reportsel()) ? (TReport_select *)_browse : NULL; + } + // @cmember Permette di abilitare/disabilitare il campo virtual void enable(bool on = true); // @cmember Permette di abilitare/disabilitare il check del campo From f5f4002a8d3e455252b1281098c5135572b37312 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 12:55:59 +0100 Subject: [PATCH 4/7] Patch level : nopatch Files correlati : Commento : Aggiunto il metodo between dei reali --- src/include/real.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/real.h b/src/include/real.h index ea3caff52..196852815 100755 --- a/src/include/real.h +++ b/src/include/real.h @@ -171,6 +171,7 @@ public: { return is_zero(); } // @cmember Ritorna il risultato della differenza tra due reali real operator -() const; + //bool between(const real& a, const real& b) const { return (*this >= a) && (*this <= b || b <= ZERO);} // @cmember Costruttore real(); From 362642aeaa2fecd1bc5eb66096be640e95786600 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 12:58:48 +0100 Subject: [PATCH 5/7] Patch level : nopatch Files correlati : Commento : Aggiunto il metodo between dei interi Migliorata la input filename --- src/include/utility.cpp | 10 ++++++++-- src/include/utility.h | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/include/utility.cpp b/src/include/utility.cpp index 489d42efa..cdcbc0010 100755 --- a/src/include/utility.cpp +++ b/src/include/utility.cpp @@ -352,13 +352,19 @@ int list_files( return count; } -bool input_filename(TFilename& file) +bool input_filename(TFilename& file, bool existent) { DIRECTORY dir; xvt_fsys_get_curr_dir(&dir); FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(file, &fs); - const bool good = xvt_dm_post_file_open(&fs, TR("Selezionare il file")) == FL_OK; + + bool good; + + if (existent) + good = xvt_dm_post_file_open(&fs, TR("Selezionare il file")) == FL_OK; + else + good = xvt_dm_post_file_save(&fs, TR("Indicare il file")) == FL_OK; xvt_fsys_set_dir(&dir); diff --git a/src/include/utility.h b/src/include/utility.h index 952a6bfb0..4e473f2be 100755 --- a/src/include/utility.h +++ b/src/include/utility.h @@ -77,7 +77,8 @@ bool remove_file(const char* file); int remove_files(const char* mask, bool subdirs); int count_files(const char* dir, bool subdirs); int list_files(const char* mask, TString_array& result); -bool input_filename(TFilename& file); +bool input_filename(TFilename& file, bool existent = true); + const char * get_system_dir(TSystem_dirs what); const char * standard_path_list(); @@ -122,5 +123,6 @@ void split_IBAN(const char * iban, TString & iso, TString & icin, void set_test_mail(const TString & email); bool send_mail(TToken_string & to, TToken_string & cc, TToken_string & ccn, const char * subj, const char * text, TToken_string & attachment, bool ui, bool receipt); +inline bool between(const long val, const long a, const long b) { return ((a == 0 ||val >= a) && (b == 0 || val <= b)); } #endif /* __UTILITY_H */ From 02379dd854c499cc17f6e6c87dc9bfe955304899 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 13:00:44 +0100 Subject: [PATCH 6/7] Patch level : nopatch Files correlati : Commento : Migliorata la input dei filename --- src/include/strings.cpp | 4 ++-- src/include/strings.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/strings.cpp b/src/include/strings.cpp index 7e6278010..c105e71b3 100755 --- a/src/include/strings.cpp +++ b/src/include/strings.cpp @@ -1466,9 +1466,9 @@ bool TFilename::search_in_path(TFilename& path) const return path.full(); } -bool TFilename::input() +bool TFilename::input(bool existent) { - return input_filename(*this); + return input_filename(*this, existent); } bool TFilename::custom_path(const char* path_list) diff --git a/src/include/strings.h b/src/include/strings.h index c3cc06083..9c8267eb5 100755 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -592,7 +592,7 @@ public: // @cmember Cerca nel path il nome del file corrente e scrive il path assoluto in path bool search_in_path(TFilename& path) const; // @cmember Richiede all'utente il nome di un file - bool input(); + bool input(bool existent = true); // @cmember Ritorna il nome del file con estensione const char* name() const; // @cmember Ritorna il nome del file senza estensione From 4461a999979736bd1eb4b0542d6e323a2d6bf819 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 13:02:20 +0100 Subject: [PATCH 7/7] Patch level : nopatch Files correlati : Commento : Implementazione report applications --- src/include/repapp.cpp | 1 + src/include/report.cpp | 54 ++++++++++++++++++++++++++--------------- src/include/report.h | 12 +++++++-- src/include/reprint.cpp | 20 +++++++-------- 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/include/repapp.cpp b/src/include/repapp.cpp index 620289c5f..7e3c9d372 100644 --- a/src/include/repapp.cpp +++ b/src/include/repapp.cpp @@ -92,6 +92,7 @@ void TReport_application::mask2ini(const TMask& m, TConfig& ini) // @cmember Esegue la stampa void TReport_application::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type type) { + rep.set_export_sections(type); book.add(rep, type); } diff --git a/src/include/report.cpp b/src/include/report.cpp index 738a3e3aa..c23036ad1 100755 --- a/src/include/report.cpp +++ b/src/include/report.cpp @@ -2990,6 +2990,33 @@ void TReport::reset_export_sections() sect->show(section_shown); } + set_dbase_fixed_fields(false); +} + + +void TReport::set_export4excel() +{ + TToken_string header_section(get_excel_header_section()); + + FOR_EACH_ASSOC_OBJECT(_sections, os, sec_key, sec_item) + { + const TString4 sec_id(sec_key); + TReport_section * sect = (TReport_section *)sec_item; + const bool on = sect->shown() && (header_section.find(sec_id) >= 0 || sec_id.starts_with("B")); + + sect->show(on); + } +} + +void TReport::set_export4dbase() +{ + FOR_EACH_ASSOC_OBJECT(_sections, os, sec_key, sec_item) + { + const TString4 sec_id(sec_key); + TReport_section * sect = (TReport_section *)sec_item; + + sect->show(sect->shown() && sec_id.starts_with("B")); + } } void TReport::set_export_sections(export_type type) @@ -2997,37 +3024,26 @@ void TReport::set_export_sections(export_type type) switch (type) { case _export_printer : - break; + set_export4print(); + break; case _export_visualize : + set_export4visualize(); break; case _export_excel : - { - FOR_EACH_ASSOC_OBJECT(_sections, os, sec_key, sec_item) - { - const TString4 sec_id(sec_key); - TReport_section * sect = (TReport_section *)sec_item; - - sect->show(sect->shown() && (sec_id == "H0" || sec_id.starts_with("B"))); - } - } + set_export4excel(); break; case _export_dbase: - { - FOR_EACH_ASSOC_OBJECT(_sections, os, sec_key, sec_item) - { - const TString4 sec_id(sec_key); - TReport_section * sect = (TReport_section *)sec_item; - - sect->show(sect->shown() && sec_id.starts_with("B")); - } - } + set_export4dbase(); break; case _export_pdf : + set_export4pdf(); break; case _export_text : + set_export4text(); default: break; } + set_dbase_fixed_fields(type == _export_dbase); } KEY TReport::run_form(TMask& m) diff --git a/src/include/report.h b/src/include/report.h index aedb5a7be..1e536b8ef 100755 --- a/src/include/report.h +++ b/src/include/report.h @@ -598,8 +598,16 @@ public: bool kill_section(char type, int level); int find_max_level(char type) const; - virtual void reset_export_sections(); - virtual void set_export_sections(export_type type); + virtual const char * get_excel_header_section() { return "H0"; } + virtual void set_dbase_fixed_fields(bool on = true) {} + void reset_export_sections(); + void set_export_sections(export_type type); + virtual void set_export4print() {}; + virtual void set_export4visualize() {}; + virtual void set_export4excel(); + virtual void set_export4pdf() {}; + virtual void set_export4text() {}; + virtual void set_export4dbase(); virtual bool on_link(const TReport_link& link); virtual bool use_mask() { return true;} diff --git a/src/include/reprint.cpp b/src/include/reprint.cpp index 1dc823463..e58a0d95b 100755 --- a/src/include/reprint.cpp +++ b/src/include/reprint.cpp @@ -1875,7 +1875,6 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go desc->update_fielddef(i, TToken_string(format("FLD%03d|1|80|0", i))); desc->update_keydef(0, TToken_string("FLD001|")); } - if (fname.exist()) { TFilename f(fname); @@ -1883,11 +1882,10 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go f.ext("*"); remove_files(f, false); } - TExternisamfile dbf(fname, *desc); - temp.temp("exp", "xls"); export_excel(temp, signature); + TExternisamfile dbf(fname, *desc); ifstream ifstream(temp); while (!ifstream.eof()) @@ -1977,7 +1975,7 @@ bool TBook::export_excel(TFilename& fname, bool signature, bool goto_url, bool a { // const char* section = str.get(1); - if ((section[0] == 'B'||section[0]=='F') && section[1]>'0') + if ((section[0] == 'B'||section[0]=='F' || section[0] == 'H') && section[1]>'0') tab.add_field(col, wid); // Raggiunge fine del testo while (str != "" && !ifs.eof()) @@ -3033,12 +3031,14 @@ bool TReport_book::add(TReport& rep, export_type type, bool progind) TString msg; msg << TR("Report ") << _report->filename(); - TProgind* pi = NULL; - if (progind && rex_items > 1) + TPrintind* pi = nullptr; + + if (progind) pi = new TPrintind(rex_items, msg); TString_array oldgroup, newgroup; const int max_group = _report->find_max_level('H'); + if (max_group >= 2) { for (int g = 2; g <= max_group; g++) @@ -3128,7 +3128,7 @@ bool TReport_book::add(TReport& rep, export_type type, bool progind) } } - if (pi != NULL) + if (pi != nullptr) { if (!pi->addstatus(1)) _print_aborted = true; @@ -3190,10 +3190,8 @@ bool TReport_book::add(TReport& rep, export_type type, bool progind) } } } - - if (pi != NULL) - delete pi; - + safe_delete(pi); + _report->reset_export_sections(); return !_print_aborted; }