From 21ea6df4df3c027322d4035ceb840f3e6065eb44 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 18 Aug 1997 14:11:37 +0000 Subject: [PATCH] applicat.cpp Gestione di EdApp oltre che EdMask nelle configurazioni execp.cpp Aggiunta forzatura user sulla riga di comando form.cpp Aggiunte sezioni ad altezza variabile form.h Aggiuto metodo virtual bool TForm_item::is_section() const isam.cpp Forzatura user in chiamata delle conversioni lffiles.h Sostituito LF_ABPROF con LF_SVRIEP mask.* Aggiunto metodo sfield() che ritorna direttamente uno spreadsheet rdoc.h Risolti conflitti relapp.cpp Corretta cancellazione veloce di documenti protetti relation.cpp Tolto spazio inutile git-svn-id: svn://10.65.10.50/trunk@5062 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/applicat.cpp | 17 ++++-- include/execp.cpp | 21 ++++++-- include/form.cpp | 121 ++++++++++++++++++++++++++++--------------- include/form.h | 5 +- include/isam.cpp | 2 +- include/lffiles.h | 2 +- include/mask.cpp | 7 +++ include/mask.h | 20 +++---- include/relapp.cpp | 18 ++++--- include/relation.cpp | 2 +- 10 files changed, 143 insertions(+), 72 deletions(-) diff --git a/include/applicat.cpp b/include/applicat.cpp index 0da828e56..a58b08550 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -674,12 +675,20 @@ bool TApplication::config() { bool ok = FALSE; - TConfig cnf(CONFIG_DITTA); - const TFilename maskname = cnf.get("EdMask"); - if (maskname.empty()) + TConfig cnf(CONFIG_DITTA); + TFilename name = cnf.get("EdApp"); + if (name.not_empty()) + { + TExternal_app app(name); + ok = app.run() == 0; + return ok; + } + + name = cnf.get("EdMask"); + if (name.empty()) return warning_box("Nessun parametro da configurare"); - TMask* msk = new TMask(maskname); // Evito problemi di stack + TMask* msk = new TMask(name); // Evito problemi di stack TMask& m = *msk; // carica campi diff --git a/include/execp.cpp b/include/execp.cpp index a72d2919b..d1c6f4f25 100755 --- a/include/execp.cpp +++ b/include/execp.cpp @@ -69,11 +69,18 @@ word TExternal_app::run( if (p >=0) name = name.left(p); - const bool our_app = name.len() > 2 && (isalpha(name[0]) || name[0] == '7') && - isalnum(name[1]) && isdigit(name[2]); - - if (!our_app) - utente = FALSE; + + if (utente == TRUE) // utente puo' essere 0 = No, 1 = Si, 3 = Forzatura + { + bool our_app = name.len() > 2; + if (our_app && atoi(name) < 70) + { + our_app = isalpha(name[0]) && isalpha(name[1]) && isdigit(name[2]); + } + if (!our_app) + utente = FALSE; + } + if (utente) #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 path << " /u" << user(); @@ -96,6 +103,8 @@ word TExternal_app::run( if (xvt_fsys_convert_str_to_dir((char *) (const char *) dir, &d)) xvt_fsys_set_dir(&d); } + +/* Gestione programmi spezzati if (our_app) { TString parms(_path); @@ -138,6 +147,8 @@ word TExternal_app::run( } } +*/ + #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 if (can_run()) { diff --git a/include/form.cpp b/include/form.cpp index e793476c7..9f637c828 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -2217,34 +2217,47 @@ TMask* TPrint_section::_msk = NULL; word TPrint_section::height() const { - if (_height<0) - return printer().formlen()+_height; - else - return _height; + word h = _height; + if (int(h) < 0) // Can't write h < 0! + { + if (section_type() == 'F') + { + h += printer().formlen(); + } + else + { + h = items(); + if (h == 0) + h = 0xFFFF - _height + 1; // Same as abs(_height) + } + } + return h; } TExpression & TPrint_section::eval_expr(TExpression & expr,int defaultfile_id) { - for (int j=0; jlfile(fileno).curr() ) ); // il valore corrente del campo viene settato nell'espressione - } + for (int j = 0; j < expr.numvar(); j++) + { // scansione delle variabili dell'espressione di rvalue + TString var= expr.varname(j); + if (var[0]=='#') + { // riferimento ad un campo del form + var.ltrim(1); + TForm_item &fi= find_field(atoi(var)); + expr.setvar(j, fi.get()); // il valore corrente del campo viene settato nell'espressione + } + else + { // riferimento ad un campo di file + TFieldref fr = TFieldref(var, 0); + int fileno=fr.file(); + fileno=fileno==0 ? defaultfile_id: fileno; + expr.setvar(j, fr.read( form().relation()->lfile(fileno).curr() ) ); // il valore corrente del campo viene settato nell'espressione } - return expr; + } + return expr; } - -TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, TForm_subsection * father) +TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, TForm_subsection* father) : _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), _upsection(father), _repeat_count(0), _ofspc(0), _ofsvr(0), _nfld(0), _temp(0), _columnwise(FALSE) @@ -2381,7 +2394,8 @@ void TPrint_section::offset(int& x, int& y) if (_columnwise) x = tab(x-1) + _ofspc; x += form().offset_x(); } - if (y >= 0) y += form().offset_y() + (_height * _repeat_count); + if (y >= 0) + y += form().offset_y() + (_height * _repeat_count); } @@ -2419,7 +2433,8 @@ bool TPrint_section::parse_head(TScanner& scanner) _columnwise = TRUE; else if (scanner.key() == "NO") // NORMAL (no COLUMNWISE) attribute _columnwise = FALSE; - else { + else + { if (section_above()) _columnwise = section_above()->_columnwise; else @@ -2455,9 +2470,14 @@ bool TPrint_section::parse(TScanner& scanner) // Azzera tutte le righe della sezione di stampa void TPrint_section::reset() -{ +{ for (int i = last(); i >= 0; i--) - row(i).reset(); + { + if (_height > 0xF000) + destroy(i); + else + row(i).reset(); + } } // Aggiorna tutti i campi @@ -2468,7 +2488,7 @@ bool TPrint_section::update() reset(); for (word i = 0; i < fields(); i++) { - if (strcmp(field(i).class_name(),"SEZIONE")!=0) + if (!field(i).is_section()) { const bool esito = field(i).update(); if (!esito) ok = FALSE; @@ -3198,7 +3218,8 @@ TForm_item *TPrint_section::find_field_everywhere(short id,const TPrint_section return f; } // look into sections beside ("brothers" ) - for (int j = 0; j < subsections(); j++) { + for (int j = 0; j < subsections(); j++) + { const TPrint_section &bs=subsection(j)->subsection(); if (&bs!=starting_section) { f=subsection(j)->subsection().find_field_everywhere(id,this); @@ -3209,8 +3230,6 @@ TForm_item *TPrint_section::find_field_everywhere(short id,const TPrint_section return NULL; } - - TForm_item& TPrint_section::find_field(const char *sec_name) const { TForm_item * f = find_field_everywhere(sec_name,this); @@ -3709,7 +3728,7 @@ bool TForm::ps_change_date_format( for (word i = 0; i < s.fields(); i++) { TForm_item& fi = s.field(i); - if (strcmp(fi.class_name(), "SEZIONE") == 0) + if (fi.is_section()) { TPrint_section& ps = ((TForm_subsection&)fi).subsection(); ps_change_date_format(ps, f); @@ -3741,7 +3760,7 @@ bool TForm::ps_change_number_format( for (word i = 0; i < s.fields(); i++) { TForm_item& fi = s.field(i); - if (strcmp(fi.class_name(), "SEZIONE") == 0) + if (fi.is_section()) { TPrint_section& ps = ((TForm_subsection&)fi).subsection(); ps_change_number_format(ps, w, dec, p); @@ -3881,11 +3900,12 @@ bool TPrint_section::update_and_print(bool show_fields, bool new_page) } for (word i = 0; i < fields(); i++) { - if (strcmp(field(i).class_name(),"SEZIONE")!=0) + if (!field(i).is_section()) { // compose rows using "simple" fields const bool esito = field(i).update(); if (!esito) ok = FALSE; - } else + } + else { TForm_subsection & ss=(TForm_subsection & )field(i); int last_hpos=min(word(field(i).y()-1), height()); @@ -3906,17 +3926,23 @@ bool TPrint_section::update_and_print(bool show_fields, bool new_page) ss.set_body(show_fields) ; } } + + const word hgt = height(); + if (show_fields && - last_printed_row< height() && - pr.current_row() > pr.headersize()+1) + last_printed_row < hgt && + pr.current_row() > pr.headersize()+1) { - if (height()-last_printed_row> pr.rows_left()) + if (hgt-last_printed_row > pr.rows_left()) pr.formfeed(); } - for (word j = last_printed_row; show_fields && j < height() ;j++) - { - pr.print(row(j)); - } + + if (show_fields) + { + for (word j = last_printed_row; j < hgt; j++) + pr.print(row(j)); + } + return ok; } @@ -4133,7 +4159,8 @@ bool TForm::genera_fincatura( for (int i = 0; i < (int)body->fields(); i++) { TForm_item& f = body->field(i); - if (!f.shown()) continue; + if (!f.shown() || f.is_section()) + continue; int x = f.x(); @@ -4204,16 +4231,24 @@ bool TForm::genera_intestazioni( { TPrint_section* body = exist('B', p); - if (body == NULL || !body->columnwise()) return FALSE; + if (body == NULL || !body->columnwise()) + return FALSE; TPrint_section* header = exist('H', p); - if (header == NULL) return FALSE; + if (header == NULL) + return FALSE; body->reset_tabs(); + + // Elimina eventuali campi temporanei precedenti + for (int k = header->fields()-1; k >= 0; k--) + if (header->field(k).temp()) + header->destroy_field(k); + const word items = body->fields(); for (word j=0;jfield(j); - if (!fi.shown()) + if (!fi.shown() || fi.is_section()) continue; TForm_string* s = new TForm_string(header); s->id() = -1; diff --git a/include/form.h b/include/form.h index 9ee157069..67502aec5 100755 --- a/include/form.h +++ b/include/form.h @@ -793,6 +793,8 @@ public: bool has_memo() const { return _flag.memo; } + virtual bool is_section() const { return FALSE; } + // virtual short& x() { return _x; }; // @cmember Setta la ccordinata X (in caratteri) del campo @@ -953,7 +955,7 @@ public: // (chiama ) const char* get_special_value(const char* s) const { return get_special_item(s, 1); } - void TForm_item::set_special_value(const char* s, const char* val); + void set_special_value(const char* s, const char* val); // @cmember Ritorna il tipo dello special corrispondente al nome

// (chiama ) const char* get_special_type (const char* s) const @@ -989,6 +991,7 @@ public: virtual bool edit(TMask& m); virtual const char* class_name() const { return "SEZIONE"; } + virtual bool is_section() const { return TRUE; } TPrint_section& subsection() { return _ssec; } diff --git a/include/isam.cpp b/include/isam.cpp index 3415d52ea..a61b2ab0a 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -1960,7 +1960,7 @@ int TSystemisamfile::exec_convapp( { if (fexist(f)) { - app.run(); + app.run(FALSE, 0x3); // Synchronous Spawn with User err = app.error(); TMailbox mail; TMessage* msg = mail.next(TRUE); diff --git a/include/lffiles.h b/include/lffiles.h index 96ca44d50..644e244aa 100755 --- a/include/lffiles.h +++ b/include/lffiles.h @@ -88,7 +88,7 @@ #define LF_VOCI 83 #define LF_RELAZ 84 #define LF_SRELAZ 85 -#define LF_ABPROF 86 +#define LF_SVRIEP 86 #define LF_ABRPROF 87 #define LF_RELNI 88 #define LF_PROSPE1 89 diff --git a/include/mask.cpp b/include/mask.cpp index 34cf2f24e..d5934357a 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -551,6 +551,13 @@ TEdit_field& TMask::efield(short id) const return (TEdit_field&)f; } +TSheet_field& TMask::sfield(short id) const +{ + TMask_field& f = field(id); + CHECKD(f.is_sheet(), "Impossibile trattare come spreadsheet il campo ", id); + return (TSheet_field&)f; +} + // @doc EXTERNAL diff --git a/include/mask.h b/include/mask.h index d372e5c47..44566bc50 100755 --- a/include/mask.h +++ b/include/mask.h @@ -254,6 +254,8 @@ public: TMask_field& field(short id) const; // @cmember Ritorna il campo di edit contraddistinto dall'identificatore passato TEdit_field& efield(short id) const; + // @cmember Ritorna il campo sheet contraddistinto dall'identificatore passato + TSheet_field& sfield(short id) const; // @cmember Setta il campo con una stringa virtual void set(short fld_id, const char* str, bool hit=FALSE); @@ -413,15 +415,15 @@ public: // @base public | TMask class TTimed_box: public TMask { - long _timer_delay; - long _timer_id; - short _button_id; + long _timer_delay; + long _timer_id; + short _button_id; protected: - virtual void handler(WINDOW win, EVENT* ep); - virtual void start_run(); + virtual void handler(WINDOW win, EVENT* ep); + virtual void start_run(); public: - TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y); - ~TTimed_box(); + TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y); + ~TTimed_box(); }; @@ -433,8 +435,8 @@ public: class TTimed_breakbox: public TTimed_box { public: - TTimed_breakbox(const char * message,int seconds,int x=40,int y=10); - ~TTimed_breakbox(); + TTimed_breakbox(const char * message,int seconds,int x=40,int y=10); + ~TTimed_breakbox(); }; diff --git a/include/relapp.cpp b/include/relapp.cpp index b4dd4b3eb..b23198846 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -474,17 +474,21 @@ int TRelation_application::delete_mode() { *cur = pos; brw->do_output(); - if (find(1) && modify_mode()) + bool can_delete = FALSE; + if (find(1)) { _autodelete = 0x3; - bool can_delete = !protected_record(get_relation()->curr()); + if (modify_mode()) + { + can_delete = !protected_record(get_relation()->curr()); + if (can_delete) + remove(); + query_mode(); + } _autodelete = FALSE; - if (can_delete) - remove(); - else - skipped++; - query_mode(); } + if (!can_delete) + skipped++; deleting--; } } diff --git a/include/relation.cpp b/include/relation.cpp index e251baceb..d1da29b61 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -532,7 +532,7 @@ void TRelation::replace( const TLocalisamfile* p = (const TLocalisamfile*)_files.objptr(index); CHECK(p && p->num() == f->num(), "Can't replace a file with different logic number"); _files.add(f, index); - if (relexprs && *relexprs ) + if (relexprs && *relexprs) { TRelationdef* oldr=(TRelationdef*)_reldefs.objptr(index-1); TRelationdef* r = new TRelationdef(this, index, key, oldr->link(),