Form con numero di pagine fisso (PAGE x in GENERAL)
git-svn-id: svn://10.65.10.50/trunk@5015 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
05751b8a24
commit
43929aa781
197
include/form.cpp
197
include/form.cpp
@ -2244,7 +2244,7 @@ TExpression & TPrint_section::eval_expr(TExpression & expr,int defaultfile_id)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
@ -3522,6 +3522,9 @@ bool TForm::parse_general(TScanner &scanner)
|
||||
if (scanner.key() == "GR") // Carattere di fincatura
|
||||
set_fincatura(scanner.string());
|
||||
|
||||
if (scanner.key() == "PA") // Numero di pagine fisso
|
||||
_npages=scanner.integer();
|
||||
|
||||
extended_parse_general(scanner); // Parse non-standard parameters
|
||||
}
|
||||
} else scanner.push();
|
||||
@ -3811,7 +3814,7 @@ word TForm::set_background(
|
||||
// @rdesc Ritorna l'altezza dell'header settato
|
||||
word TForm::set_header(
|
||||
word p, // @parm Numero pagina
|
||||
bool u) // @parm Indica se cambiare l'eventuale header corrente!!!
|
||||
bool u) // @parm Indica se cambiare l'eventuale header o solo ritornare l'altezza
|
||||
|
||||
// @xref <mf TForm::set_background> <mf TForm::set_body> <mf TForm::set_footer>
|
||||
{
|
||||
@ -3950,18 +3953,36 @@ word TForm::set_footer(
|
||||
|
||||
void TForm::header_handler(TPrinter& p)
|
||||
{
|
||||
const word page = form().page(p);
|
||||
form().set_background(page, TRUE);
|
||||
form().set_header(page, TRUE);
|
||||
form().set_footer(page, FALSE);
|
||||
if (form().firstpage_is_lastpage()) {
|
||||
form().set_background(1, TRUE);
|
||||
form().set_header(1, TRUE);
|
||||
form().set_footer(0, FALSE);
|
||||
} else {
|
||||
const word page = form().page(p);
|
||||
form().set_background(page, TRUE);
|
||||
form().set_header(page, TRUE);
|
||||
form().set_footer(page, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void TForm::footer_handler(TPrinter& p)
|
||||
{
|
||||
const word page = form().page(p);
|
||||
form().set_footer(page, TRUE);
|
||||
if (page)
|
||||
form().set_header(page+1, FALSE);
|
||||
if (form().firstpage_is_lastpage()) {
|
||||
form().set_footer(0, TRUE);
|
||||
} else {
|
||||
const word currp = form().page(p);
|
||||
form().set_footer(currp, TRUE);
|
||||
if (currp)
|
||||
form().set_header(form().next_page(p), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Ritorna se la prima pagina coincide conl'ultima
|
||||
bool TForm::firstpage_is_lastpage() const
|
||||
{
|
||||
return _first_eq_last;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -3969,12 +3990,18 @@ void TForm::footer_handler(TPrinter& p)
|
||||
// @mfunc Ritorna il numero di pagina correntemente in stampa
|
||||
//
|
||||
// @rdesc Se <md _TForm::lastpage> e' TRUE (sta stampando l'ultima pagina)
|
||||
// ritorna 0, altrimenti ritorna il numero della pagian corrente da stampare
|
||||
// ritorna 0, altrimenti ritorna il numero della pagina corrente da stampare
|
||||
// (chiam <mf TPrinter::getcurrentepage>).
|
||||
word TForm::page(
|
||||
const TPrinter& p) const // @parm Operazione corrente di stampa
|
||||
{
|
||||
return _lastpage ? 0 : p.getcurrentpage();
|
||||
return _lastpage || fixed_pages() && p.getcurrentpage()==_npages ? 0 : p.getcurrentpage();
|
||||
}
|
||||
|
||||
word TForm::next_page(
|
||||
const TPrinter& p) const // @parm Operazione corrente di stampa
|
||||
{
|
||||
return _lastpage || fixed_pages() && p.getcurrentpage()+1==_npages ? 0 : p.getcurrentpage()+1;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -4281,6 +4308,145 @@ bool TForm::print(
|
||||
long from, // @parm Primo item da stampare (default 0l)
|
||||
long to) // @parm Ultimo da stampare (se <lt>0 stampa fino alla fine del file, default -1l)
|
||||
|
||||
// @comm Se i parametri di posizionamento sono settati e cosi' pure gli offset genera un <f error_box>.
|
||||
{
|
||||
_cur_form = this;
|
||||
|
||||
if ((_char_to_pos != '\0' || ((_ipx +_ipy+_fpx) != 0)) && // Se i parametri di posizionamento sono settati e
|
||||
(_x != 0 || _y != 0)) // cosi' pure gli offset genera un errore.
|
||||
{
|
||||
error_box("Non e' possibile settare contemporaneamente gli offset"
|
||||
" e i parametri di posizionamento del modulo.");
|
||||
return FALSE;
|
||||
}
|
||||
TPrinter& pr = printer();
|
||||
if (_frompage) pr.set_from_page(_frompage);
|
||||
if (_topage) pr.set_to_page(_topage);
|
||||
|
||||
if (_char_to_pos != '\0' || (_ipx +_ipy+_fpx) != 0) // Effettua il posizionamento del form...
|
||||
{
|
||||
if (_arrange && pr.printtype() == winprinter)
|
||||
arrange_form();
|
||||
}
|
||||
else
|
||||
pr.set_offset(_y,_x);
|
||||
|
||||
pr.setheaderhandler(header_handler); // Setta handlers
|
||||
pr.setfooterhandler(footer_handler);
|
||||
if (!pr.is_generic())
|
||||
{
|
||||
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1))
|
||||
{
|
||||
if (height(t)> (word)pr.formlen())
|
||||
{
|
||||
TString s("La lunghezza totale della sezione ");
|
||||
switch ( t )
|
||||
{
|
||||
case odd_page:
|
||||
s << "standard"; break;
|
||||
case even_page:
|
||||
s << "pagine pari"; break;
|
||||
case first_page:
|
||||
s << "prima pagina"; break;
|
||||
case last_page:
|
||||
s << "ultima pagina"; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
s << " eccede la lunghezza reale del foglio.";
|
||||
message_box(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pr.formlen(height());
|
||||
}
|
||||
pr.set_char_size(_fontsize); // Set font name and size
|
||||
pr.set_fontname(_fontname); // according to current form
|
||||
const bool was_open = pr.isopen();
|
||||
|
||||
set_last_page(FALSE); // non e' l'ultima pagina
|
||||
|
||||
set_background(1, TRUE);
|
||||
|
||||
if (!was_open && !pr.open())
|
||||
return FALSE;
|
||||
do_events();
|
||||
|
||||
long lastrec= records()-1;
|
||||
|
||||
if (to < 0) to = lastrec;
|
||||
|
||||
// controlla i casi di stampa
|
||||
_first_eq_last=FALSE;
|
||||
if (!fixed_pages() && set_body(1,FALSE) * word(to-from+1) <= pr.formlen()- set_header(1,FALSE) - set_footer(0,FALSE))
|
||||
// tutta la stampa sta in una pagina
|
||||
_first_eq_last=TRUE;
|
||||
// if (to == lastrec) to--; // l'ultima pagina è gestita come caso particolare
|
||||
|
||||
bool ok = TRUE;
|
||||
|
||||
for (long i = from; i <= to && ok;)
|
||||
{
|
||||
if (from < 0) to = from;
|
||||
else if (cursor())
|
||||
*cursor()=i;
|
||||
match_result();
|
||||
|
||||
if (pr.current_row() > pr.headersize()+1)
|
||||
{
|
||||
const word h = set_body(page(pr), FALSE);
|
||||
if (h > pr.rows_left()) {
|
||||
pr.formfeed();
|
||||
// quanto resta da stampare sta nell'ultima pagina
|
||||
if (!fixed_pages() && set_body(0,FALSE) * word(to-i+1) <= pr.formlen()- set_header(1,FALSE) - set_footer(0,FALSE))
|
||||
{
|
||||
while (i < to && from >= 0) // stampa l'ultima pagina
|
||||
{
|
||||
i++;
|
||||
set_last_page(TRUE);
|
||||
set_background(0, TRUE);
|
||||
set_header(0, TRUE);
|
||||
if (cursor()) {
|
||||
*cursor() = i;
|
||||
set_body(0, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
set_body(page(pr), TRUE);
|
||||
if (cursor()) {
|
||||
if (next_match_done())
|
||||
i=cursor()->pos();
|
||||
else
|
||||
i++;
|
||||
}
|
||||
} // fine ciclo di stampa
|
||||
|
||||
while (fixed_pages() && page(pr) % _npages !=0)
|
||||
{
|
||||
static TPrintrow empty_line;
|
||||
pr.formfeed();
|
||||
pr.print(empty_line);
|
||||
}
|
||||
pr.formfeed();
|
||||
if (!was_open)
|
||||
pr.close();
|
||||
|
||||
pr.setheaderhandler(NULL);
|
||||
pr.setfooterhandler(NULL);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*bool TForm::print(
|
||||
long from, // @parm Primo item da stampare (default 0l)
|
||||
long to) // @parm Ultimo da stampare (se <lt>0 stampa fino alla fine del file, default -1l)
|
||||
|
||||
// @comm Se i parametri di posizionamento sono settati e cosi' pure gli offset genera un <f error_box>.
|
||||
{
|
||||
_cur_form = this;
|
||||
@ -4364,8 +4530,9 @@ bool TForm::print(
|
||||
if (pr.current_row() > pr.headersize()+1)
|
||||
{
|
||||
const word h = set_body(page(pr), FALSE);
|
||||
if (h > pr.rows_left())
|
||||
if (h > pr.rows_left()) {
|
||||
pr.formfeed();
|
||||
}
|
||||
}
|
||||
|
||||
set_body(page(pr), TRUE);
|
||||
@ -4396,7 +4563,8 @@ bool TForm::print(
|
||||
pr.setfooterhandler(NULL);
|
||||
|
||||
return ok;
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
void TForm::print_section(ostream& out, char s) const
|
||||
{
|
||||
@ -4883,6 +5051,7 @@ bool TForm::write_profile()
|
||||
|
||||
void TForm::init()
|
||||
{
|
||||
_npages=0;
|
||||
_relation= NULL;
|
||||
_cursor= NULL;
|
||||
_rel_desc= NULL;
|
||||
|
@ -82,6 +82,8 @@ class TForm : public TObject
|
||||
int _fontsize;
|
||||
// @cmember:(INTERNAL) Maschera per la sezione
|
||||
TString _section_mask;
|
||||
//@cmember:(INTERNAL) Numero esatto di pagine
|
||||
word _npages;
|
||||
//@cmember:(INTERNAL) Offset X valido per tutte le sezioni
|
||||
int _x;
|
||||
//@cmember:(INTERNAL) Offset Y valido per tutte le sezioni
|
||||
@ -121,7 +123,8 @@ class TForm : public TObject
|
||||
|
||||
// @cmember:(INTERNAL) Indica se si sta stampando l'ultima pagina
|
||||
bool _lastpage;
|
||||
|
||||
// @cmember:(INTERNAL) Indica se si sta stampando la prima pagina ed essa è uguale all'ultima
|
||||
bool _first_eq_last;
|
||||
// @cmember:(INTERNAL) Indica se si tratta di un nuovo form
|
||||
bool _isnew;
|
||||
// @cmember:(INTERNAL) Indica se si tratta di form di base (.frm file)
|
||||
@ -221,6 +224,10 @@ protected:
|
||||
|
||||
// @cmember Ritorna il numero di pagina correntemente in stampa
|
||||
word page(const TPrinter& p) const;
|
||||
// @cmember Ritorna il numero di pagina prossimamente in stampa
|
||||
word next_page(const TPrinter& p) const;
|
||||
// @cmember Ritorna se la prima pagina coincide conl'ultima
|
||||
bool firstpage_is_lastpage() const;
|
||||
// @cmember Effettua il posizionamento manuale del modulo
|
||||
void arrange_form();
|
||||
|
||||
@ -277,6 +284,9 @@ public:
|
||||
// @cmember Ritorna il codice del profilo di stampa
|
||||
const TString& code() const
|
||||
{ return _code; }
|
||||
// @cmember Ritorna se il form è un modulo a pagine fisse
|
||||
bool fixed_pages() const
|
||||
{ return _npages>0; }
|
||||
|
||||
// @cmember Ritorna il nome della mschera per la sezione
|
||||
virtual const char* section_mask()
|
||||
|
Loading…
x
Reference in New Issue
Block a user