Aggiunto metodo TForm::reread() per rileggere una sezione.
Aggiunto metodo TPrint_section::destroy_fields() per rimuovere tutti i campi. git-svn-id: svn://10.65.10.50/trunk@2356 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b5e0c8b8de
commit
68de7c2f96
@ -2909,6 +2909,65 @@ TPrint_section& TForm::section(char s, word pagenum)
|
||||
return section(s, pt);
|
||||
}
|
||||
|
||||
bool TForm::reread(char sec, pagetype p)
|
||||
{
|
||||
TPrint_section* s = exist(sec,p);
|
||||
bool ok = FALSE;
|
||||
if (s != NULL)
|
||||
for (word j = 0; j < s->fields(); j++)
|
||||
ok |= s->field(j).dirty();
|
||||
if (s != NULL && ok)
|
||||
{
|
||||
s->destroy_fields(); // Distrugge tutti gli items...
|
||||
// ...si posiziona nel file sorgente alla sezione opportuna...
|
||||
TFilename n(_name); n.ext("frm");
|
||||
TScanner scanner(n);
|
||||
bool ok = FALSE;
|
||||
while (!ok)
|
||||
{
|
||||
while (TRUE) // ...scans searching for a section...
|
||||
{
|
||||
const TString& key = scanner.popkey();
|
||||
if (key == "SE" || key == "") // ..if section or end of file...
|
||||
break;
|
||||
}
|
||||
const char secr = scanner.popkey()[0]; // Section name (GRAPH, HEAD, BODY, FOOT)
|
||||
if (secr=='\0') break;
|
||||
const pagetype pr = char2page(scanner.popkey()[0]); // Section type (odd, even, first, last)
|
||||
if (secr==sec && pr==p) ok = TRUE; // L'ha trovata...
|
||||
}
|
||||
// ...riesegue la parse della sezione leggendo dal file sorgente
|
||||
if(ok && s->parse(scanner))
|
||||
{
|
||||
// Legge le modifiche su archivio e poi e' finita.
|
||||
s->set_dirty(FALSE);
|
||||
TLocalisamfile rprof(LF_RFORM);
|
||||
const char sez[3] = {sec,p+'0','\0'};
|
||||
rprof.zero();
|
||||
rprof.put("TIPOPROF", _name);
|
||||
rprof.put("CODPROF", _code);
|
||||
rprof.put("SEZ", sez);
|
||||
const TRectype filter(rprof.curr());
|
||||
|
||||
for (int err = rprof.read(_isgteq); err == NOERR && rprof.curr() == filter; err = rprof.next())
|
||||
{
|
||||
const short id = rprof.get_int("ID");
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
TPrint_section& se = section(sec, p);
|
||||
se.read_from(rprof.curr());
|
||||
}
|
||||
else
|
||||
{
|
||||
TForm_item& item = find_field(sec, p, id);
|
||||
item.read_from(rprof.curr());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// TForm
|
||||
|
@ -171,7 +171,8 @@ public:
|
||||
void change_date_format(const char* f);
|
||||
// cambia il formato di tutti i numeri nel form
|
||||
void change_number_format(int w, int dec, const char* p);
|
||||
|
||||
// Rilegge la sezione specificata
|
||||
bool reread(char sec, pagetype p);
|
||||
// editor interface
|
||||
TForm_editor& editor() const;
|
||||
|
||||
@ -253,6 +254,7 @@ public:
|
||||
TForm_item& field(int n) const { return (TForm_item&)_item[n]; }
|
||||
TForm_item& find_field(short id) const;
|
||||
void destroy_field(int n) { _item.destroy(n, TRUE); }
|
||||
void destroy_fields() { _item.destroy(); }
|
||||
void change_field(int n, TForm_item* f);
|
||||
void insert_field(int n, TForm_item* f);
|
||||
void add_field(TForm_item* f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user