diff --git a/ba/ba3200.cpp b/ba/ba3200.cpp index 01c35935d..53d382db7 100755 --- a/ba/ba3200.cpp +++ b/ba/ba3200.cpp @@ -17,15 +17,15 @@ class BA3200_application : public TPrintapp { - // TTable* _tab; TString _tabname; TFilename _rptname; TRelation* _rel; TCursor *_cur; TMask* _msk; TString _maskname; - // TScanner *_rpt; int _logicnum; + TArray _string_roman; + TArray _field_roman; public: @@ -34,12 +34,14 @@ public: virtual bool set_print(int) ; virtual void set_page(int, int); + virtual bool preprocess_page (int, int); void leggi_rpt(); void set_headers(); void set_rows(); void set_footers(); void set_translations(); + void set_relations(); BA3200_application(const char * tabname) : _tabname(tabname) {} virtual ~BA3200_application() {} }; @@ -47,26 +49,27 @@ public: bool BA3200_application::set_print(int) { - TRectype from(_rel->lfile()->curr()); - TRectype to (_rel->lfile()->curr()); + TRectype from(_rel->lfile()->curr()); from.zero(); + TRectype to (from); - from.zero(); - to.zero(); - const KEY tasto = _msk->run(); - - if (tasto == K_ENTER) + if (_msk->run() == K_ENTER) { - const int campi_maschera = _msk->fields(); // - 2; Tolgo bottoni... + const int campi_maschera = _msk->fields(); for (int i = 0; i < campi_maschera; i++) { const TMask_field& campo_maschera = _msk->fld(i); const char* val = campo_maschera.get(); - const TFieldref* campo_ref = campo_maschera.field(); - if (*val && campo_ref != NULL && campo_ref->ok()) + if (*val) { - if (campo_maschera.in_group(1)) campo_ref->write(val, from); else - if (campo_maschera.in_group(2)) campo_ref->write(val, to); - } + const TFieldref* campo_ref = campo_maschera.field(); + + if (campo_ref != NULL && campo_ref->ok()) + { + if (campo_maschera.in_group(1)) campo_ref->write(val, from); + else + if (campo_maschera.in_group(2)) campo_ref->write(val, to); + } + } } _cur->setregion (from, to); @@ -77,9 +80,30 @@ bool BA3200_application::set_print(int) void BA3200_application::set_page (int , int ) { + _string_roman.destroy(); + _field_roman.destroy(); leggi_rpt(); } +bool BA3200_application::preprocess_page(int , int) +{ + const int items = _field_roman.items(); + + if (items > 0) + { + for (int i = 0; i < items; i++) + { + TString& fn = (TString &) _field_roman[i]; + TFieldref fld(fn, 0); + TString& s = (TString &) _string_roman[i]; + + const int n = atoi(fld.read(_rel)); + s = itor(n); + } + } + return TRUE; +} + void BA3200_application::set_headers() { TString NomeTabella, sep, formato_intesta, testo_intesta; @@ -145,26 +169,44 @@ void BA3200_application::set_rows() { riga_record = line.get_int(); - campo = line.get(); + TString s(line.get()); + + campo = s; from = campo.from(); to = campo.to(); name = campo.name(); + int logicnum = campo.file() == 0 ? _logicnum : campo.file(); - formato_campo = line.get(); + formato_campo = line.get(); formato_campo.trim(); + formato_campo.lower(); + const int p = formato_campo.find("@m"); - if (formato_campo.lower() == "@pn") - picture = line.get(); - else - picture = ""; + if (p != -1) + { + formato_campo.cut(p); + formato_campo << "#t"; + _string_roman.add(new TString); + _field_roman.add(s); + const int last = _string_roman.items() - 1; - if (to == -1) - if (picture != "") - set_row (riga_record, formato_campo, FLD(_logicnum,name,picture) ); - else - set_row (riga_record, formato_campo, FLD(_logicnum,name) ); + set_row (riga_record, formato_campo, _string_roman.objptr(last)); + } else - set_row (riga_record, formato_campo, FLD(_logicnum,name,from,to) ); + { + if (formato_campo.find("@pn")) + picture = line.get(); + else + picture = ""; + + if (to == -1) + if (picture != "") + set_row (riga_record, formato_campo, FLD(logicnum,name,picture) ); + else + set_row (riga_record, formato_campo, FLD(logicnum,name) ); + else + set_row (riga_record, formato_campo, FLD(logicnum,name,from,to) ); + } line = (const char *) rpt.line(); } @@ -217,6 +259,33 @@ void BA3200_application::set_translations() } } +void BA3200_application::set_relations() +{ + TToken_string line("", ','); + TString tab(16), expr(40); + int key, linkto, alias, logicnum; + + TScanner rpt(_rptname); + rpt.paragraph("Relations"); + + line = rpt.line(); + while ( (line != "") && (line[0] != '[') ) + { + tab = line.get(); + logicnum = atoi(tab); + expr = line.get(); + key = line.get_int(); + if (key == 0) key = 1; + linkto = line.get_int(); + alias = line.get_int(); + if (logicnum > 0) + _rel->add(logicnum, expr, key, linkto, alias); + else + _rel->add(tab, expr, key, linkto, alias); + + line = rpt.line(); + } +} void BA3200_application::leggi_rpt() { set_rows(); @@ -249,6 +318,7 @@ void BA3200_application::user_create() set_headers(); set_footers(); set_translations(); + set_relations(); } void BA3200_application::user_destroy()