Patch level : nopatch
Files correlati : Commento : Implementazione report applications
This commit is contained in:
parent
02379dd854
commit
4461a99997
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;}
|
||||
|
@ -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
|
||||
{
|
||||
// <text owner=B1>
|
||||
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 != "</text>" && !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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user