Corretta generazione campi memo

git-svn-id: svn://10.65.10.50/trunk@4424 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-05-27 16:56:21 +00:00
parent a5dac2cb67
commit 27beae6c17

View File

@ -232,7 +232,7 @@ private:
TMaschera *_m; TMaschera *_m;
protected: protected:
// Carica un file di tabella in un TString array // Carica un file di tabella in un TString array
void carica_tabella( const TFilename& fn, TString_array& tabella ); void carica_tabella( const TFilename& fn, TString_array& tabella );
@ -375,9 +375,9 @@ void TMaschera::item( const TString& str )
TToken_string s("", '~'); TToken_string s("", '~');
for( i = 0; i < u.items( ); i ++ ) for( i = 0; i < u.items( ); i ++ )
{ {
s = u.get(); s = u.get();
_out << "IT \"" << s.get(0) << "\"\n"; _out << "IT \"" << s.get(0) << "\"\n";
for( j = 1; j < s.items( ); j ++ ) for( j = 1; j < s.items( ); j ++ )
_out << "ME " << s.get() << "\n"; _out << "ME " << s.get() << "\n";
@ -525,14 +525,14 @@ static void genera_campo( const TObject& campo )
static void verifica_campo( const TObject& campo ) static void verifica_campo( const TObject& campo )
{ {
// Per evitare 3000 casts ... // Per evitare 3000 casts ...
TField & cmp = (TField&) campo; TField & cmp = (TField&) campo;
TGruppo & gruppo = cmp.grp(); TGruppo & gruppo = cmp.grp();
cmp.stato(cmp.stato_reale()); cmp.stato(cmp.stato_reale());
if (cmp.stato() != S_NASCOSTO) if (cmp.stato() != S_NASCOSTO)
{ {
int h = cmp.y() + 1; int h = cmp.y() + 1;
if (cmp.type() == T_CORNICE) if (cmp.type() == T_CORNICE || cmp.type() == T_MEMO )
h += cmp.size()%100 - 1; h += cmp.size()%100 - 1;
if (gruppo.height() < h) if (gruppo.height() < h)
gruppo.height(h); gruppo.height(h);
@ -552,10 +552,10 @@ static void genera_gruppo( const TObject& gruppo )
grp.campi().for_each(verifica_campo); grp.campi().for_each(verifica_campo);
do_events(); do_events();
if(grp.present()) if(grp.present())
grp.genera(); grp.genera();
if (_bar) if (_bar)
_bar->addstatus(1); _bar->addstatus(1);
} }
TObject* TGruppo::dup() const TObject* TGruppo::dup() const
@ -565,10 +565,10 @@ TObject* TGruppo::dup() const
g->generatore(generatore()); g->generatore(generatore());
g->present(present()); g->present(present());
g->_fields = _fields; g->_fields = _fields;
TArray & fields = g->campi(); TArray & fields = g->campi();
const int items = fields.items(); const int items = fields.items();
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
((TField &)fields[i]).grp(g); ((TField &)fields[i]).grp(g);
return g; return g;
@ -662,9 +662,9 @@ TField::TField( )
} }
TObject* TField::dup() const TObject* TField::dup() const
{ {
TField * f = new TField; TField * f = new TField;
f->_nome = _nome; f->_nome = _nome;
f->_fieldname = _fieldname; f->_fieldname = _fieldname;
f->_x = _x; f->_x = _x;
@ -684,7 +684,7 @@ TObject* TField::dup() const
f->_output = _output; f->_output = _output;
f->_special = _special; f->_special = _special;
f->_items = _items; f->_items = _items;
f->_configs = _configs; f->_configs = _configs;
return f; return f;
} }
@ -698,54 +698,54 @@ int TField::stato_reale()
// e nella sezione CONFIGS nel .INI di definizione dei gruppi. // e nella sezione CONFIGS nel .INI di definizione dei gruppi.
// Utilizza poi la minore delle due. // Utilizza poi la minore delle due.
int stato = S_OBBLIGATORIO; int stato = S_OBBLIGATORIO;
{ {
TToken_string config(fieldsini().get( "CONFIGS", _nome )); TToken_string config(fieldsini().get( "CONFIGS", _nome ));
const int items = config.items(); const int items = config.items();
for ( int i = 0; i < items; i += 3 ) for ( int i = 0; i < items; i += 3 )
{ {
TString80 chiave(config.get(i)); TString80 chiave(config.get(i));
const TString80 valore(config.get(i + 1)); const TString80 valore(config.get(i + 1));
const int pos = chiave.find( '[' ); const int pos = chiave.find( '[' );
int index = -1; int index = -1;
if ( pos >= 0 ) if ( pos >= 0 )
{ {
index = atoi(chiave.sub(pos + 1, chiave.find( ']'))); index = atoi(chiave.sub(pos + 1, chiave.find( ']')));
chiave.cut(pos); chiave.cut(pos);
} }
if ( valore == ditta( ).get( chiave, "ve", index)) if ( valore == ditta( ).get( chiave, "ve", index))
stato = config.get_int(i + 2); stato = config.get_int(i + 2);
} }
} }
TToken_string riga_profilo(grp().generatore().profilo().get(_nome, "PROFILO")); TToken_string riga_profilo(grp().generatore().profilo().get(_nome, "PROFILO"));
const int stato_profilo = riga_profilo.get_int(P_STATO); const int stato_profilo = riga_profilo.get_int(P_STATO);
if (stato > stato_profilo ) if (stato > stato_profilo )
stato = stato_profilo; stato = stato_profilo;
if (stato > S_NASCOSTO) if (stato > S_NASCOSTO)
{ {
const TString80 gruppo(fieldsini().get("GROUP", _nome)); const TString80 gruppo(fieldsini().get("GROUP", _nome));
TToken_string config(groupsini().get("CONFIGS", gruppo)); TToken_string config(groupsini().get("CONFIGS", gruppo));
const int items = config.items( ); const int items = config.items( );
int stato_gruppo = S_OBBLIGATORIO; int stato_gruppo = S_OBBLIGATORIO;
for ( int i = 0; i < items; i += 3 ) for ( int i = 0; i < items; i += 3 )
{ {
const TString80 chiave = config.get( i ); const TString80 chiave = config.get( i );
const TString80 valore = config.get( i + 1 ); const TString80 valore = config.get( i + 1 );
if (valore == ditta( ).get( chiave, "ve")) if (valore == ditta( ).get( chiave, "ve"))
stato_gruppo = config.get_int(i + 2); stato_gruppo = config.get_int(i + 2);
}; };
if (stato > stato_gruppo) if (stato > stato_gruppo)
stato = stato_gruppo; stato = stato_gruppo;
const int stato_gruppo_profilo = grp().generatore().profilo().get_int(gruppo, "PROFILOGRUPPO"); const int stato_gruppo_profilo = grp().generatore().profilo().get_int(gruppo, "PROFILOGRUPPO");
if (stato > stato_gruppo_profilo) if (stato > stato_gruppo_profilo)
stato = stato_gruppo_profilo; stato = stato_gruppo_profilo;
} }
@ -793,9 +793,9 @@ void TField::genera( )
break; break;
default: default:
break; break;
} }
if ((_type == T_DATA || _type == T_STRINGA || if ((_type == T_DATA || _type == T_STRINGA ||
_type == T_NUMERO || _type == T_MEMO) && _type == T_NUMERO || _type == T_MEMO) &&
(_stato == S_OBBLIGATORIO || !_use.blank())) (_stato == S_OBBLIGATORIO || !_use.blank()))
m.check( _stato ); m.check( _stato );
if ( !_fieldname.blank( ) ) m.field( _fieldname ); if ( !_fieldname.blank( ) ) m.field( _fieldname );
@ -831,36 +831,36 @@ TMask_generator::TMask_generator( const TString& profilo ) : _fieldsini( "ve0300
if( param == "-all" ) if( param == "-all" )
{ {
TString_array profiles; TString_array profiles;
{ {
TAssoc_array profiles_array; TAssoc_array profiles_array;
TRelation rel("%TIP"); TRelation rel("%TIP");
TCursor t( &rel ); TCursor t( &rel );
long count = t.items(); long count = t.items();
for( t = 0; t.pos( ) < count; ++t ) for( t = 0; t.pos( ) < count; ++t )
{ {
const TString profile_name(t.curr().get("S4")); const TString profile_name(t.curr().get("S4"));
TFilename profile(profile_name); TFilename profile(profile_name);
profile.ext("ini"); profile.ext("ini");
if (fexist(profile) && !profiles_array.is_key(profile_name)) if (fexist(profile) && !profiles_array.is_key(profile_name))
profiles_array.add(profile_name); profiles_array.add(profile_name);
} }
profiles_array.get_keys(profiles); profiles_array.get_keys(profiles);
} }
TProgind bar( profiles.items(), "Generazione automatica profili", FALSE, TRUE); TProgind bar( profiles.items(), "Generazione automatica profili", FALSE, TRUE);
const int items = profiles.items(); const int items = profiles.items();
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
const TString &profile = profiles.row(i); const TString &profile = profiles.row(i);
genera(profile); genera(profile);
bar.addstatus(1); bar.addstatus(1);
} }
_ditta.set( "CHANGED", "", "ve" ); _ditta.set( "CHANGED", "", "ve" );
} }
else genera( profilo ); else genera( profilo );
} }
@ -1103,7 +1103,7 @@ void TMask_generator::intestazione_pagina( )
_m->group( 11 ); _m->group( 11 );
_m->flag( "D" ); _m->flag( "D" );
_m->end( ); _m->end( );
} }
void TMask_generator::genera( const TString& profilo ) void TMask_generator::genera( const TString& profilo )
@ -1111,7 +1111,7 @@ void TMask_generator::genera( const TString& profilo )
int i, last; int i, last;
TString temp_s; TString temp_s;
TFilename proname( profilo ); TFilename proname( profilo );
// All'inizio il gruppo h 'chiuso' // All'inizio il gruppo h 'chiuso'
_groupopen = FALSE; _groupopen = FALSE;
@ -1119,7 +1119,7 @@ void TMask_generator::genera( const TString& profilo )
proname.ext( "ini" ); proname.ext( "ini" );
// Se il file di profilo non esiste, esci con un errore fatale // Se il file di profilo non esiste, esci con un errore fatale
if (!fexist( proname)) if (!fexist( proname))
{ {
error_box( "Il profilo %s non esiste!", ( const char * )profilo); error_box( "Il profilo %s non esiste!", ( const char * )profilo);
return; return;
@ -1129,7 +1129,7 @@ void TMask_generator::genera( const TString& profilo )
TFilename _mskname( _pro->get( "MSKFILE", "MAIN") ); TFilename _mskname( _pro->get( "MSKFILE", "MAIN") );
_mskname.ext( "msk" ); _mskname.ext( "msk" );
do_events(); do_events();
// Mi serve per ordinare i gruppi a seconda del documento // Mi serve per ordinare i gruppi a seconda del documento
TAssoc_array grouporder; TAssoc_array grouporder;
@ -1142,7 +1142,7 @@ void TMask_generator::genera( const TString& profilo )
_m->control( T_BOTTONE, DLG_SAVEREC, 1002 ); _m->control( T_BOTTONE, DLG_SAVEREC, 1002 );
_m->begin( ); _m->begin( );
_m->prompt( -15, -1, "~Registra" ); _m->prompt( -15, -1, "~Registra" );
_m->message( "EXIT,20082" ); _m->message( "EXIT,20082" );
_m->picture(BMP_SAVEREC); _m->picture(BMP_SAVEREC);
_m->picture(BMP_SAVERECDN); _m->picture(BMP_SAVERECDN);
_m->end( ); _m->end( );
@ -1156,7 +1156,7 @@ void TMask_generator::genera( const TString& profilo )
_m->control( T_BOTTONE, 99, 1002 ); _m->control( T_BOTTONE, 99, 1002 );
_m->begin( ); _m->begin( );
_m->prompt( -35, -1, "E~labora" ); _m->prompt( -35, -1, "E~labora" );
_m->message( "EXIT,345" ); // _m->message( "EXIT,345" );
_m->end( ); _m->end( );
_m->control( T_BOTTONE, DLG_PRINT, 1002 ); _m->control( T_BOTTONE, DLG_PRINT, 1002 );
@ -1188,13 +1188,13 @@ void TMask_generator::genera( const TString& profilo )
_m->control( T_STRINGA, F_CODNUM, 4 ); _m->control( T_STRINGA, F_CODNUM, 4 );
_m->begin( ); _m->begin( );
_m->prompt( 2, 1, "Cod. num. " ); _m->prompt( 2, 1, "Cod. num. " );
_m->field("CODNUM"); _m->field("CODNUM");
_m->use("%NUM", 1); _m->use("%NUM", 1);
temp_s.format("CODTAB %d", F_CODNUM); temp_s.format("CODTAB %d", F_CODNUM);
_m->input(temp_s); _m->input(temp_s);
_m->display("\"Codice\" CODTAB~\"Descrizione@50\" S0"); _m->display("\"Codice\" CODTAB~\"Descrizione@50\" S0");
temp_s.format("%d S0", F_DESNUM); temp_s.format("%d S0", F_DESNUM);
_m->output(temp_s); _m->output(temp_s);
_m->check(S_NORMALE); _m->check(S_NORMALE);
_m->flag( "GDU" ); _m->flag( "GDU" );
_m->message( "CO,2@" ); _m->message( "CO,2@" );
@ -1345,15 +1345,15 @@ void TMask_generator::genera( const TString& profilo )
last = _pro->get_int( "NGROUPS", "ORDINEGRUPPI" ); last = _pro->get_int( "NGROUPS", "ORDINEGRUPPI" );
for( i = 1; i <= last; i ++ ) for( i = 1; i <= last; i ++ )
{ {
do_events(); do_events();
chiave.format( "%d", i ); chiave.format( "%d", i );
chiavegruppo.GROUPKEY( _pro->get_int( chiave, "ORDINEGRUPPI" ) ); chiavegruppo.GROUPKEY( _pro->get_int( chiave, "ORDINEGRUPPI" ) );
if( _gruppi.is_key( chiavegruppo ) ) if( _gruppi.is_key( chiavegruppo ) )
sortedgroups.add( _gruppi[ (chiavegruppo) ] ); sortedgroups.add( _gruppi[ (chiavegruppo) ] );
} }
TString80 message; TString80 message;
message.format("Generazione profilo : %s", (const char *) profilo); message.format("Generazione profilo : %s", (const char *) profilo);
_bar = new TProgind(sortedgroups.items(), message, FALSE, TRUE); _bar = new TProgind(sortedgroups.items(), message, FALSE, TRUE);
sortedgroups.for_each( genera_gruppo ); sortedgroups.for_each( genera_gruppo );
@ -1383,10 +1383,10 @@ void TMask_generator::genera( const TString& profilo )
_m->end( ); _m->end( );
// Generazione pagina dei piedi // Generazione pagina dei piedi
{ {
TToken_string s(_pro->get("CAMPICALC", "MAIN")); TToken_string s(_pro->get("CAMPICALC", "MAIN"));
if (s.not_empty()) if (s.not_empty())
{ {
intestazione_pagina( ); intestazione_pagina( );
@ -1394,32 +1394,32 @@ void TMask_generator::genera( const TString& profilo )
int nr = 1; int nr = 1;
int id = 0; int id = 0;
for (const char * cp = s.get(0); cp && *cp; cp = s.get()) for (const char * cp = s.get(0); cp && *cp; cp = s.get())
{ {
const TString16 codpiede(cp); const TString16 codpiede(cp);
do_events(); do_events();
frd.zero( ); frd.zero( );
frd.put( "CODTAB", codpiede ); frd.put( "CODTAB", codpiede );
if ( frd.read( ) == NOERR ) if ( frd.read( ) == NOERR )
{ {
const TString80 picture(frd.get( "S3")); const TString80 picture(frd.get( "S3"));
const int len = picture.len() > 0 ? picture.len() : 18; const int len = picture.len() > 0 ? picture.len() : 18;
int dec = picture.find(','); int dec = picture.find(',');
if (dec >= 0) if (dec >= 0)
dec = len - dec - 1; dec = len - dec - 1;
else else
dec = 0; dec = 0;
id++; id++;
if (frd.get_bool("B0")) if (frd.get_bool("B0"))
_m->control( T_NUMERO, BASE_PIEDE + id, len * 100 + dec); _m->control( T_NUMERO, BASE_PIEDE + id, len * 100 + dec);
else else
_m->control( T_STRINGA, BASE_PIEDE + id, len * 100); _m->control( T_STRINGA, BASE_PIEDE + id, len * 100);
_m->begin( ); _m->begin( );
TString80 header(frd.get("S0")); header.left_just(58 - len); TString80 header(frd.get("S0")); header.left_just(58 - len);
_m->prompt( 2, 7 + nr, header ); _m->prompt( 2, 7 + nr, header );
_m->field(codpiede); _m->field(codpiede);
if (picture.not_empty()) if (picture.not_empty())
_m->picture(picture); _m->picture(picture);
@ -1454,8 +1454,8 @@ void TMask_generator::genera( const TString& profilo )
// Applicazione guscio // Applicazione guscio
class TGenMask_application : public TApplication class TGenMask_application : public TApplication
{ {
protected: protected:
virtual bool create ( ); virtual bool create ( );
@ -1467,7 +1467,7 @@ protected:
bool TGenMask_application::create( ) bool TGenMask_application::create( )
{ {
TApplication::create( ); TApplication::create( );
TMask_generator *a = new TMask_generator(argv(2)); TMask_generator *a = new TMask_generator(argv(2));
delete a; delete a;
return FALSE; return FALSE;