Aggiunti metodi TForm::set_compulsory_specials() e TForm::get_compulsory_specials(),
per settare gli specials di default (intestazione, offset e fincatura) per ogni item. Implementata la TForm_item::get_special_item(). Aggiunta la possibilita' di salvare anche gli spazi oltre la fine dell'intestazione. git-svn-id: svn://10.65.10.50/trunk@2549 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7d041654d5
commit
5aa3c59a2a
147
include/form.cpp
147
include/form.cpp
@ -282,9 +282,9 @@ void TForm_flags::print_on(ostream& out) const
|
|||||||
if (automagic) s << "A";
|
if (automagic) s << "A";
|
||||||
if (!enabled) s << "D";
|
if (!enabled) s << "D";
|
||||||
if (!shown) s << "H";
|
if (!shown) s << "H";
|
||||||
|
if (memo) s << "M";
|
||||||
if (finkl) s << "F";
|
if (finkl) s << "F";
|
||||||
if (finkr) s << "K";
|
if (finkr) s << "K";
|
||||||
if (memo) s << "M";
|
|
||||||
|
|
||||||
if (s.not_empty())
|
if (s.not_empty())
|
||||||
out << " FLAGS \"" << s << '"' << endl;
|
out << " FLAGS \"" << s << '"' << endl;
|
||||||
@ -496,7 +496,13 @@ bool TForm_item::read_from(const TRectype& prof)
|
|||||||
TString p(prof.get("PROMPT"));
|
TString p(prof.get("PROMPT"));
|
||||||
if (p.not_empty())
|
if (p.not_empty())
|
||||||
{
|
{
|
||||||
if (p == "_") p.cut(0);
|
if (p[0] == '\xFE') p.cut(0);
|
||||||
|
const int l = p.len();
|
||||||
|
if (l > 0 && p[l-1] == '\xFF')
|
||||||
|
{
|
||||||
|
p[l-1] = ' ';
|
||||||
|
p << '\0';
|
||||||
|
}
|
||||||
_prompt = p;
|
_prompt = p;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
@ -509,33 +515,23 @@ bool TForm_item::read_from(const TRectype& prof)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TToken_string special(prof.get("SPECIAL"),'\n');
|
TToken_string special(prof.get("SPECIAL"),'\n');
|
||||||
for (i = 0; i < special.items(); i++)
|
const int sp_items = special.items();
|
||||||
|
for (i = 0; i < sp_items; i++)
|
||||||
{
|
{
|
||||||
if (i == special.items()-1)
|
TToken_string sp(special.get(i), '$');
|
||||||
{
|
TString key(sp.get(0));
|
||||||
TToken_string fink(special.get(i));
|
TString val(sp.get(1));
|
||||||
_col_head = fink.get(0);
|
|
||||||
_ofs = fink.get_int(1);
|
|
||||||
_flag.finkl = fink.get_char(2) == 'X';
|
|
||||||
_flag.finkr = fink.get_char(3) == 'X';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TToken_string sp(special.get(i), '$');
|
|
||||||
TString key(sp.get(0));
|
|
||||||
TString val(sp.get(1));
|
|
||||||
|
|
||||||
if (!_special.is_key(key))
|
if (!_special.is_key(key))
|
||||||
{
|
{
|
||||||
error_box("Variabile speciale non presente nel profilo: %s",
|
error_box("Variabile speciale non presente nel profilo: %s",
|
||||||
(const char*)key);
|
(const char*)key);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
TToken_string& tt = (TToken_string&)_special[key];
|
|
||||||
tt.add(val,1);
|
|
||||||
// forza riscrittura su memo
|
|
||||||
if (tt.items() == 3) tt.add("X");
|
|
||||||
}
|
}
|
||||||
|
TToken_string& tt = (TToken_string&)_special[key];
|
||||||
|
tt.add(val,1);
|
||||||
|
// forza riscrittura su memo
|
||||||
|
if (tt.items() == 3) tt.add("X");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -549,8 +545,11 @@ void TForm_item::print_on(TRectype& prof)
|
|||||||
prof.put("Y", _y);
|
prof.put("Y", _y);
|
||||||
prof.put("LEN", width());
|
prof.put("LEN", width());
|
||||||
prof.put("HGT", height());
|
prof.put("HGT", height());
|
||||||
if (prompt().empty()) set_prompt("_");
|
if (_prompt.empty()) _prompt << '\xFE' << '\0';
|
||||||
prof.put("PROMPT", prompt());
|
const int l = _prompt.len();
|
||||||
|
const char c = _prompt[l-1];
|
||||||
|
if (c==' ') _prompt[l-1]='\xFF';
|
||||||
|
prof.put("PROMPT", _prompt);
|
||||||
prof.put("ATTIVO", shown() ? "X" : " ");
|
prof.put("ATTIVO", shown() ? "X" : " ");
|
||||||
|
|
||||||
// specials: se e' stato cambiato, la tokenstring del valore contiene
|
// specials: se e' stato cambiato, la tokenstring del valore contiene
|
||||||
@ -574,11 +573,6 @@ void TForm_item::print_on(TRectype& prof)
|
|||||||
special.add(sp);
|
special.add(sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TString fink;
|
|
||||||
fink << _col_head << "|";
|
|
||||||
fink << _ofs << "|"; fink << (_flag.finkl ? "X" : " ") <<"|";
|
|
||||||
fink << (_flag.finkr ? "X" : " ");
|
|
||||||
special.add(fink);
|
|
||||||
prof.put("SPECIAL", special);
|
prof.put("SPECIAL", special);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,6 +589,23 @@ void TForm_item::enable(
|
|||||||
show(on);
|
show(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TForm_item::set_special_value(const char* s, const char* val)
|
||||||
|
{
|
||||||
|
TToken_string& tt = (TToken_string&) _special[s];
|
||||||
|
tt.add(val,1);
|
||||||
|
if (tt.items()==3) tt.add("X");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* TForm_item::get_special_item(const char* s, int n) const
|
||||||
|
{
|
||||||
|
TAssoc_array& sp = (TAssoc_array&)_special;
|
||||||
|
if (sp.is_key(s))
|
||||||
|
{
|
||||||
|
TToken_string& tt = (TToken_string&) sp[s];
|
||||||
|
return tt.get(n);
|
||||||
|
} else return "";
|
||||||
|
}
|
||||||
|
|
||||||
void TForm_item::string_at(int x, int y, const char* s)
|
void TForm_item::string_at(int x, int y, const char* s)
|
||||||
{
|
{
|
||||||
if (shown())
|
if (shown())
|
||||||
@ -2320,13 +2331,13 @@ bool TPrint_section::detail_field_handler(TMask_field& f, KEY k)
|
|||||||
// gna'
|
// gna'
|
||||||
TForm_item& fi = section.field(field);
|
TForm_item& fi = section.field(field);
|
||||||
|
|
||||||
msk.enable(F_OPTIONS, fi.special_items() > 0);
|
msk.enable(F_OPTIONS, fi.special_items() > 3);
|
||||||
msk.enable(F_SPACES, section.columnwise());
|
msk.enable(F_SPACES, section.columnwise());
|
||||||
msk.enable(F_FINKL, section.columnwise());
|
msk.enable(F_FINKL, section.columnwise());
|
||||||
msk.enable(F_FINKR, section.columnwise());
|
msk.enable(F_FINKR, section.columnwise());
|
||||||
|
|
||||||
// build option mask
|
// build option mask
|
||||||
if (fi.special_items() > 0)
|
if (fi.special_items() > 3)
|
||||||
{
|
{
|
||||||
msk.set_handler(F_OPTIONS, special_field_handler);
|
msk.set_handler(F_OPTIONS, special_field_handler);
|
||||||
|
|
||||||
@ -3762,7 +3773,7 @@ bool TForm::validate(TForm_item& f, TToken_string&)
|
|||||||
void TForm::print_on(ostream& out) const
|
void TForm::print_on(ostream& out) const
|
||||||
{
|
{
|
||||||
main_app().begin_wait();
|
main_app().begin_wait();
|
||||||
|
|
||||||
if (relation())
|
if (relation())
|
||||||
{
|
{
|
||||||
out << *relation() << "\nEND" << endl;
|
out << *relation() << "\nEND" << endl;
|
||||||
@ -3869,6 +3880,7 @@ bool TForm::write_profile()
|
|||||||
{
|
{
|
||||||
const char sechar[4] = { 'B', 'F', 'G', 'H' };
|
const char sechar[4] = { 'B', 'F', 'G', 'H' };
|
||||||
|
|
||||||
|
get_compulsory_specials();
|
||||||
TLocalisamfile form(LF_FORM);
|
TLocalisamfile form(LF_FORM);
|
||||||
form.zero();
|
form.zero();
|
||||||
form.put("TIPOPROF",_name);
|
form.put("TIPOPROF",_name);
|
||||||
@ -4034,6 +4046,7 @@ void TForm::read(
|
|||||||
if (_code.not_empty())
|
if (_code.not_empty())
|
||||||
read_profile(); // read from LF_RFORM file
|
read_profile(); // read from LF_RFORM file
|
||||||
|
|
||||||
|
set_compulsory_specials();
|
||||||
TPrinter& pr = printer();
|
TPrinter& pr = printer();
|
||||||
pr.set_offset(_y,_x);
|
pr.set_offset(_y,_x);
|
||||||
pr.set_char_size(_fontsize);
|
pr.set_char_size(_fontsize);
|
||||||
@ -4043,6 +4056,68 @@ void TForm::read(
|
|||||||
main_app().end_wait();
|
main_app().end_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TForm::set_compulsory_specials()
|
||||||
|
{
|
||||||
|
const char sechar[3] = { 'B', 'F', 'H' };
|
||||||
|
|
||||||
|
for (int sn = 0; sn < 3; sn++)
|
||||||
|
{
|
||||||
|
const char sc = sechar[sn];
|
||||||
|
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
|
||||||
|
{
|
||||||
|
TPrint_section* sec = exist(sc, pt);
|
||||||
|
if (sec != NULL)
|
||||||
|
{
|
||||||
|
const word fields = sec->fields();
|
||||||
|
const bool col_wise = sec->columnwise();
|
||||||
|
for (word i = 0; col_wise && i < fields; i++)
|
||||||
|
{
|
||||||
|
TForm_item& fi = sec->field(i);
|
||||||
|
if (fi.special_items()>0)
|
||||||
|
{
|
||||||
|
fi.set_col_head(fi.get_special_value("INTESTAZIONE"));
|
||||||
|
fi.ofs() = (short)atoi(fi.get_special_value("OFFSET"));
|
||||||
|
TString fnk(fi.get_special_value("FINCATURA"));
|
||||||
|
fi.set_finkl(fnk[0]!='X'); // !finkl significa fincatura abilitata
|
||||||
|
fi.set_finkr(fnk[1]!='X'); // !finkr significa fincatura abilitata
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TForm::get_compulsory_specials()
|
||||||
|
{
|
||||||
|
const char sechar[3] = { 'B', 'F', 'H' };
|
||||||
|
|
||||||
|
for (int sn = 0; sn < 3; sn++)
|
||||||
|
{
|
||||||
|
const char sc = sechar[sn];
|
||||||
|
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
|
||||||
|
{
|
||||||
|
TPrint_section* sec = exist(sc, pt);
|
||||||
|
if (sec != NULL)
|
||||||
|
{
|
||||||
|
const word fields = sec->fields();
|
||||||
|
const bool col_wise = sec->columnwise();
|
||||||
|
for (word i = 0; col_wise && i < fields; i++)
|
||||||
|
{
|
||||||
|
TForm_item& fi = sec->field(i);
|
||||||
|
if (fi.special_items()>0)
|
||||||
|
{
|
||||||
|
fi.set_special_value("INTESTAZIONE", fi.col_head());
|
||||||
|
fi.set_special_value("OFFSET", format("%d",fi.ofs()));
|
||||||
|
TString fnk(fi.finkl()? " " : "X");
|
||||||
|
fnk << (fi.finkr() ? " " : "X");
|
||||||
|
fi.set_special_value("FINCATURA",fnk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TForm::set_fincatura(const char* s)
|
void TForm::set_fincatura(const char* s)
|
||||||
{
|
{
|
||||||
strncpy(_fink,s,sizeof(_fink));
|
strncpy(_fink,s,sizeof(_fink));
|
||||||
|
@ -200,6 +200,12 @@ protected:
|
|||||||
// @cmember Scrive un profilo su file (vedi <mf TForm::read_profile>)
|
// @cmember Scrive un profilo su file (vedi <mf TForm::read_profile>)
|
||||||
bool write_profile();
|
bool write_profile();
|
||||||
|
|
||||||
|
// @cmember Resetta gli specials obbligatori per ogni form_item (header, offset e fincatura)
|
||||||
|
// per comodita' di utilizzo dei membri _col_head, _ofs, finkl e finkr di TForm_item.
|
||||||
|
void set_compulsory_specials();
|
||||||
|
// @cmember Legge gli specials obbligatori prima di scriverli
|
||||||
|
void get_compulsory_specials();
|
||||||
|
|
||||||
// @cmember Ritorna il numero di pagina correntemente in stampa
|
// @cmember Ritorna il numero di pagina correntemente in stampa
|
||||||
word page(const TPrinter& p) const;
|
word page(const TPrinter& p) const;
|
||||||
// @cmember Effettua il posizionamento manuale del modulo
|
// @cmember Effettua il posizionamento manuale del modulo
|
||||||
@ -633,7 +639,8 @@ protected:
|
|||||||
// @cmember Stampa una stringa alla posizione indicata
|
// @cmember Stampa una stringa alla posizione indicata
|
||||||
void string_at(int x, int y, const char* s);
|
void string_at(int x, int y, const char* s);
|
||||||
|
|
||||||
// @cmember Cerca la stringa <p s> tra gli item e ne ritorna l'<p n>-esimo elemnto (NON IMPLEMENTATA)
|
// @cmember Cerca nella definizione della variabile <p s> e ne ritorna
|
||||||
|
// l'<p n>-esimo elemento (0=tipo, 1=valore, 2=descrizione)
|
||||||
const char* get_special_item(const char* s, int n) const;
|
const char* get_special_item(const char* s, int n) const;
|
||||||
|
|
||||||
// @access Public Member
|
// @access Public Member
|
||||||
@ -820,18 +827,18 @@ public:
|
|||||||
TAssoc_array& specials() const
|
TAssoc_array& specials() const
|
||||||
{ return (TAssoc_array&)_special; }
|
{ return (TAssoc_array&)_special; }
|
||||||
|
|
||||||
// @cmember NON IMPLEMENTATA
|
// @cmember Riempie il TString_array <p r> passato per reference con i nomi delle variabili
|
||||||
int get_special_names(TString_array& r);
|
int get_special_names(TString_array& r);
|
||||||
// @cmember Ritorna il secondo elemento dell'item corrispondente alla stringa <p s>
|
// @cmember Ritorna il valore dello special corrispondente al nome <p s>
|
||||||
// (chiama <mf TForm_item::get_special_item> che NON E' IMPLEMENTATA)
|
// (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); }
|
||||||
// @cmember Ritorna il primo elemento dell'item corrispondente alla stringa <p s>
|
// @cmember Ritorna il tipo dello special corrispondente al nome <p s>
|
||||||
// (chiama <mf TForm_item::get_special_item> che NON E' IMPLEMENTATA)
|
// (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
|
||||||
{ return get_special_item(s, 0); }
|
{ return get_special_item(s, 0); }
|
||||||
// @cmember Ritorna il terzo elemento dell'item corrispondente alla stringa <p s>
|
// @cmember Ritorna la descrizione dello special corrispondente al nome <p s>
|
||||||
// (chiama <mf TForm_item::get_special_item> che NON E' IMPLEMENTATA)
|
// (chiama <mf TForm_item::get_special_item>)
|
||||||
const char* get_special_desc (const char* s) const
|
const char* get_special_desc (const char* s) const
|
||||||
{ return get_special_item(s, 2); }
|
{ return get_special_item(s, 2); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user