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
This commit is contained in:
guy 1997-08-18 14:11:37 +00:00
parent 1e7361b7c2
commit 21ea6df4df
10 changed files with 143 additions and 72 deletions

View File

@ -12,6 +12,7 @@
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
#include <execp.h>
#include <extcdecl.h> #include <extcdecl.h>
#include <mask.h> #include <mask.h>
#include <modaut.h> #include <modaut.h>
@ -674,12 +675,20 @@ bool TApplication::config()
{ {
bool ok = FALSE; bool ok = FALSE;
TConfig cnf(CONFIG_DITTA); TConfig cnf(CONFIG_DITTA);
const TFilename maskname = cnf.get("EdMask"); TFilename name = cnf.get("EdApp");
if (maskname.empty()) 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"); 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; TMask& m = *msk;
// carica campi // carica campi

View File

@ -69,11 +69,18 @@ word TExternal_app::run(
if (p >=0) if (p >=0)
name = name.left(p); name = name.left(p);
const bool our_app = name.len() > 2 && (isalpha(name[0]) || name[0] == '7') &&
isalnum(name[1]) && isdigit(name[2]); if (utente == TRUE) // utente puo' essere 0 = No, 1 = Si, 3 = Forzatura
{
if (!our_app) bool our_app = name.len() > 2;
utente = FALSE; 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 (utente)
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
path << " /u" << user(); path << " /u" << user();
@ -96,6 +103,8 @@ word TExternal_app::run(
if (xvt_fsys_convert_str_to_dir((char *) (const char *) dir, &d)) if (xvt_fsys_convert_str_to_dir((char *) (const char *) dir, &d))
xvt_fsys_set_dir(&d); xvt_fsys_set_dir(&d);
} }
/* Gestione programmi spezzati
if (our_app) if (our_app)
{ {
TString parms(_path); TString parms(_path);
@ -138,6 +147,8 @@ word TExternal_app::run(
} }
} }
*/
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (can_run()) if (can_run())
{ {

View File

@ -2217,34 +2217,47 @@ TMask* TPrint_section::_msk = NULL;
word TPrint_section::height() const word TPrint_section::height() const
{ {
if (_height<0) word h = _height;
return printer().formlen()+_height; if (int(h) < 0) // Can't write h < 0!
else {
return _height; 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) TExpression & TPrint_section::eval_expr(TExpression & expr,int defaultfile_id)
{ {
for (int j=0; j<expr.numvar(); j++) { // scansione delle variabili dell'espressione di rvalue for (int j = 0; j < expr.numvar(); j++)
TString var= expr.varname(j); { // scansione delle variabili dell'espressione di rvalue
if (var[0]=='#') TString var= expr.varname(j);
{ // riferimento ad un campo del form if (var[0]=='#')
var.ltrim(1); { // riferimento ad un campo del form
TForm_item &fi= find_field(atoi(var)); var.ltrim(1);
expr.setvar(j, fi.get()); // il valore corrente del campo viene settato nell'espressione TForm_item &fi= find_field(atoi(var));
} else {// riferimento ad un campo di file expr.setvar(j, fi.get()); // il valore corrente del campo viene settato nell'espressione
TFieldref fr = TFieldref(var, 0); }
int fileno=fr.file(); else
fileno=fileno==0 ? defaultfile_id: fileno; { // riferimento ad un campo di file
expr.setvar(j, fr.read( form().relation()->lfile(fileno).curr() ) ); // il valore corrente del campo viene settato nell'espressione 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), : _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), _upsection(father), _repeat_count(0), _ofspc(0), _ofsvr(0), _nfld(0), _temp(0),
_columnwise(FALSE) _columnwise(FALSE)
@ -2381,7 +2394,8 @@ void TPrint_section::offset(int& x, int& y)
if (_columnwise) x = tab(x-1) + _ofspc; if (_columnwise) x = tab(x-1) + _ofspc;
x += form().offset_x(); 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; _columnwise = TRUE;
else if (scanner.key() == "NO") // NORMAL (no COLUMNWISE) attribute else if (scanner.key() == "NO") // NORMAL (no COLUMNWISE) attribute
_columnwise = FALSE; _columnwise = FALSE;
else { else
{
if (section_above()) if (section_above())
_columnwise = section_above()->_columnwise; _columnwise = section_above()->_columnwise;
else else
@ -2455,9 +2470,14 @@ bool TPrint_section::parse(TScanner& scanner)
// Azzera tutte le righe della sezione di stampa // Azzera tutte le righe della sezione di stampa
void TPrint_section::reset() void TPrint_section::reset()
{ {
for (int i = last(); i >= 0; i--) for (int i = last(); i >= 0; i--)
row(i).reset(); {
if (_height > 0xF000)
destroy(i);
else
row(i).reset();
}
} }
// Aggiorna tutti i campi // Aggiorna tutti i campi
@ -2468,7 +2488,7 @@ bool TPrint_section::update()
reset(); reset();
for (word i = 0; i < fields(); i++) 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(); const bool esito = field(i).update();
if (!esito) ok = FALSE; if (!esito) ok = FALSE;
@ -3198,7 +3218,8 @@ TForm_item *TPrint_section::find_field_everywhere(short id,const TPrint_section
return f; return f;
} }
// look into sections beside ("brothers" ) // 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(); const TPrint_section &bs=subsection(j)->subsection();
if (&bs!=starting_section) { if (&bs!=starting_section) {
f=subsection(j)->subsection().find_field_everywhere(id,this); 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; return NULL;
} }
TForm_item& TPrint_section::find_field(const char *sec_name) const TForm_item& TPrint_section::find_field(const char *sec_name) const
{ {
TForm_item * f = find_field_everywhere(sec_name,this); 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++) for (word i = 0; i < s.fields(); i++)
{ {
TForm_item& fi = s.field(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(); TPrint_section& ps = ((TForm_subsection&)fi).subsection();
ps_change_date_format(ps, f); ps_change_date_format(ps, f);
@ -3741,7 +3760,7 @@ bool TForm::ps_change_number_format(
for (word i = 0; i < s.fields(); i++) for (word i = 0; i < s.fields(); i++)
{ {
TForm_item& fi = s.field(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(); TPrint_section& ps = ((TForm_subsection&)fi).subsection();
ps_change_number_format(ps, w, dec, p); 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++) 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 { // compose rows using "simple" fields
const bool esito = field(i).update(); const bool esito = field(i).update();
if (!esito) ok = FALSE; if (!esito) ok = FALSE;
} else }
else
{ {
TForm_subsection & ss=(TForm_subsection & )field(i); TForm_subsection & ss=(TForm_subsection & )field(i);
int last_hpos=min(word(field(i).y()-1), height()); 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) ; ss.set_body(show_fields) ;
} }
} }
const word hgt = height();
if (show_fields && if (show_fields &&
last_printed_row< height() && last_printed_row < hgt &&
pr.current_row() > pr.headersize()+1) pr.current_row() > pr.headersize()+1)
{ {
if (height()-last_printed_row> pr.rows_left()) if (hgt-last_printed_row > pr.rows_left())
pr.formfeed(); pr.formfeed();
} }
for (word j = last_printed_row; show_fields && j < height() ;j++)
{ if (show_fields)
pr.print(row(j)); {
} for (word j = last_printed_row; j < hgt; j++)
pr.print(row(j));
}
return ok; return ok;
} }
@ -4133,7 +4159,8 @@ bool TForm::genera_fincatura(
for (int i = 0; i < (int)body->fields(); i++) for (int i = 0; i < (int)body->fields(); i++)
{ {
TForm_item& f = body->field(i); TForm_item& f = body->field(i);
if (!f.shown()) continue; if (!f.shown() || f.is_section())
continue;
int x = f.x(); int x = f.x();
@ -4204,16 +4231,24 @@ bool TForm::genera_intestazioni(
{ {
TPrint_section* body = exist('B', p); 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); TPrint_section* header = exist('H', p);
if (header == NULL) return FALSE; if (header == NULL)
return FALSE;
body->reset_tabs(); 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(); const word items = body->fields();
for (word j=0;j<items;j++) for (word j=0;j<items;j++)
{// Scans all body items to print, and append header items... {// Scans all body items to print, and append header items...
TForm_item& fi = body->field(j); TForm_item& fi = body->field(j);
if (!fi.shown()) if (!fi.shown() || fi.is_section())
continue; continue;
TForm_string* s = new TForm_string(header); TForm_string* s = new TForm_string(header);
s->id() = -1; s->id() = -1;

View File

@ -793,6 +793,8 @@ public:
bool has_memo() const bool has_memo() const
{ return _flag.memo; } { return _flag.memo; }
virtual bool is_section() const { return FALSE; }
// virtual short& x() { return _x; }; // virtual short& x() { return _x; };
// @cmember Setta la ccordinata X (in caratteri) del campo // @cmember Setta la ccordinata X (in caratteri) del campo
@ -953,7 +955,7 @@ public:
// (chiama <mf TForm_item::get_special_item>) // (chiama <mf TForm_item::get_special_item>)
const char* get_special_value(const char* s) const const char* get_special_value(const char* s) const
{ return get_special_item(s, 1); } { 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 <p s> // @cmember Ritorna il tipo dello special corrispondente al nome <p s>
// (chiama <mf TForm_item::get_special_item>) // (chiama <mf TForm_item::get_special_item>)
const char* get_special_type (const char* s) const const char* get_special_type (const char* s) const
@ -989,6 +991,7 @@ public:
virtual bool edit(TMask& m); virtual bool edit(TMask& m);
virtual const char* class_name() const { return "SEZIONE"; } virtual const char* class_name() const { return "SEZIONE"; }
virtual bool is_section() const { return TRUE; }
TPrint_section& subsection() { return _ssec; } TPrint_section& subsection() { return _ssec; }

View File

@ -1960,7 +1960,7 @@ int TSystemisamfile::exec_convapp(
{ {
if (fexist(f)) if (fexist(f))
{ {
app.run(); app.run(FALSE, 0x3); // Synchronous Spawn with User
err = app.error(); err = app.error();
TMailbox mail; TMailbox mail;
TMessage* msg = mail.next(TRUE); TMessage* msg = mail.next(TRUE);

View File

@ -88,7 +88,7 @@
#define LF_VOCI 83 #define LF_VOCI 83
#define LF_RELAZ 84 #define LF_RELAZ 84
#define LF_SRELAZ 85 #define LF_SRELAZ 85
#define LF_ABPROF 86 #define LF_SVRIEP 86
#define LF_ABRPROF 87 #define LF_ABRPROF 87
#define LF_RELNI 88 #define LF_RELNI 88
#define LF_PROSPE1 89 #define LF_PROSPE1 89

View File

@ -551,6 +551,13 @@ TEdit_field& TMask::efield(short id) const
return (TEdit_field&)f; 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 // @doc EXTERNAL

View File

@ -254,6 +254,8 @@ public:
TMask_field& field(short id) const; TMask_field& field(short id) const;
// @cmember Ritorna il campo di edit contraddistinto dall'identificatore passato // @cmember Ritorna il campo di edit contraddistinto dall'identificatore passato
TEdit_field& efield(short id) const; 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 // @cmember Setta il campo con una stringa
virtual void set(short fld_id, const char* str, bool hit=FALSE); virtual void set(short fld_id, const char* str, bool hit=FALSE);
@ -413,15 +415,15 @@ public:
// @base public | TMask // @base public | TMask
class TTimed_box: public TMask class TTimed_box: public TMask
{ {
long _timer_delay; long _timer_delay;
long _timer_id; long _timer_id;
short _button_id; short _button_id;
protected: protected:
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
virtual void start_run(); virtual void start_run();
public: public:
TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y); TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y);
~TTimed_box(); ~TTimed_box();
}; };
@ -433,8 +435,8 @@ public:
class TTimed_breakbox: public TTimed_box class TTimed_breakbox: public TTimed_box
{ {
public: public:
TTimed_breakbox(const char * message,int seconds,int x=40,int y=10); TTimed_breakbox(const char * message,int seconds,int x=40,int y=10);
~TTimed_breakbox(); ~TTimed_breakbox();
}; };

View File

@ -474,17 +474,21 @@ int TRelation_application::delete_mode()
{ {
*cur = pos; *cur = pos;
brw->do_output(); brw->do_output();
if (find(1) && modify_mode()) bool can_delete = FALSE;
if (find(1))
{ {
_autodelete = 0x3; _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; _autodelete = FALSE;
if (can_delete)
remove();
else
skipped++;
query_mode();
} }
if (!can_delete)
skipped++;
deleting--; deleting--;
} }
} }

View File

@ -532,7 +532,7 @@ void TRelation::replace(
const TLocalisamfile* p = (const TLocalisamfile*)_files.objptr(index); const TLocalisamfile* p = (const TLocalisamfile*)_files.objptr(index);
CHECK(p && p->num() == f->num(), "Can't replace a file with different logic number"); CHECK(p && p->num() == f->num(), "Can't replace a file with different logic number");
_files.add(f, index); _files.add(f, index);
if (relexprs && *relexprs ) if (relexprs && *relexprs)
{ {
TRelationdef* oldr=(TRelationdef*)_reldefs.objptr(index-1); TRelationdef* oldr=(TRelationdef*)_reldefs.objptr(index-1);
TRelationdef* r = new TRelationdef(this, index, key, oldr->link(), TRelationdef* r = new TRelationdef(this, index, key, oldr->link(),