From 4461a999979736bd1eb4b0542d6e323a2d6bf819 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 13 Dec 2021 13:02:20 +0100 Subject: [PATCH] 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; }