Corretta ripetizione stampa dopo link; cambiamenti cosmetici

git-svn-id: svn://10.65.10.50/trunk@230 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-09-14 07:33:25 +00:00
parent 8097b5d8eb
commit 4e053141b7

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.5 1994-08-31 07:29:29 villa Exp $ // $Id: printapp.cpp,v 1.6 1994-09-14 07:33:25 villa Exp $
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -77,9 +77,7 @@ class _Token:public TObject
{ {
_row = r; _row = r;
} }
virtual ~ _Token () virtual ~ _Token () {}
{
}
}; };
class _PrintfTok : public _Token class _PrintfTok : public _Token
@ -94,9 +92,7 @@ class _PrintfTok:public _Token
row (rw); row (rw);
_val = val; _val = val;
} }
virtual ~ _PrintfTok () virtual ~ _PrintfTok () {}
{
}
}; };
class _FieldTok : public _Token class _FieldTok : public _Token
@ -150,8 +146,7 @@ class _PrintfRef:public _Token
} }
}; };
void TPrint_application :: void TPrint_application::_reset_tree (link_item * head)
_reset_tree (link_item * head)
{ {
if (head) if (head)
{ {
@ -163,8 +158,7 @@ _reset_tree (link_item * head)
} }
} }
link_item *TPrint_application :: link_item *TPrint_application::_look_print_node (link_item * head, int logicnum)
_look_print_node (link_item * head, int logicnum)
{ {
// look for <from> node to attach to // look for <from> node to attach to
// since it reflects a relation, it won't have more than // since it reflects a relation, it won't have more than
@ -182,14 +176,12 @@ _look_print_node (link_item * head, int logicnum)
return NULL; return NULL;
} }
void TPrint_application :: void TPrint_application::add_file (const char *tab, int from)
add_file (const char *tab, int from)
{ {
add_file (TTable ::name2log (tab), from); add_file (TTable ::name2log (tab), from);
} }
void TPrint_application :: void TPrint_application::add_file (int file, int from)
add_file (int file, int from)
{ {
link_item *nw = new link_item (file); link_item *nw = new link_item (file);
if (_pr_tree == NULL) if (_pr_tree == NULL)
@ -221,8 +213,7 @@ add_file (int file, int from)
static char tb[120]; static char tb[120];
int TPrint_application :: int TPrint_application::enable_link (const char *descr, char fg, char bg)
enable_link (const char *descr, char fg, char bg)
{ {
TToken_string *tt = new TToken_string (30); TToken_string *tt = new TToken_string (30);
char b[2]; char b[2];
@ -236,8 +227,7 @@ enable_link (const char *descr, char fg, char bg)
return printer().links ().items () - 1; return printer().links ().items () - 1;
} }
void TPrint_application :: void TPrint_application::disable_link (char fg, char bg)
disable_link (char fg, char bg)
{ {
for (int i = 0; i < printer().links ().items (); i++) for (int i = 0; i < printer().links ().items (); i++)
{ {
@ -253,21 +243,18 @@ disable_link (char fg, char bg)
} }
} }
void TPrint_application :: void TPrint_application::set_multiple_link (bool on)
set_multiple_link (bool on)
{ {
printer().setmultiplelink (on); printer().setmultiplelink (on);
} }
void TPrint_application :: void TPrint_application::_pp_link (int id, const char *text)
_pp_link (int id, const char *text)
{ {
TPrint_application *prapp = (TPrint_application *) MainApp (); TPrint_application *prapp = (TPrint_application *) MainApp ();
prapp->process_link (id, text); prapp->process_link (id, text);
} }
void TPrint_application :: void TPrint_application::_pp_header (TPrinter &)
_pp_header (TPrinter &)
{ {
TPrint_application *prapp = (TPrint_application *) MainApp (); TPrint_application *prapp = (TPrint_application *) MainApp ();
@ -282,8 +269,7 @@ _pp_header (TPrinter &)
new TPrintrow ((TPrintrow &) (prapp->_header)[i])); new TPrintrow ((TPrintrow &) (prapp->_header)[i]));
} }
void TPrint_application :: void TPrint_application::_pp_footer (TPrinter &)
_pp_footer (TPrinter &)
{ {
TPrint_application *prapp = (TPrint_application *) MainApp (); TPrint_application *prapp = (TPrint_application *) MainApp ();
@ -296,14 +282,12 @@ _pp_footer (TPrinter &)
new TPrintrow ((TPrintrow &) (prapp->_footer)[i])); new TPrintrow ((TPrintrow &) (prapp->_footer)[i]));
} }
void TPrint_application :: void TPrint_application::set_background (const char *bgdesc)
set_background (const char *bgdesc)
{ {
printer().setbackground (bgdesc); printer().setbackground (bgdesc);
} }
const char * const char* FLD (int lognum, const char *f, int from, int to)
FLD (int lognum, const char *f, int from, int to)
{ {
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to); sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
char *p = new char[strlen (tb) + 1]; char *p = new char[strlen (tb) + 1];
@ -311,8 +295,7 @@ FLD (int lognum, const char *f, int from, int to)
return p; return p;
} }
const char * const char* FLD (int lognum, const char *f, const char *picture)
FLD (int lognum, const char *f, const char *picture)
{ {
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture); sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
char *p = new char[strlen (tb) + 1]; char *p = new char[strlen (tb) + 1];
@ -320,8 +303,7 @@ FLD (int lognum, const char *f, const char *picture)
return p; return p;
} }
const char * const char* FLD (const char *tabname, const char *f, int from, int to)
FLD (const char *tabname, const char *f, int from, int to)
{ {
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname); CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname); int lognum = TTable ::name2log (tabname);
@ -331,8 +313,7 @@ FLD (const char *tabname, const char *f, int from, int to)
return p; return p;
} }
const char * const char* FLD (const char *tabname, const char *f, const char *picture)
FLD (const char *tabname, const char *f, const char *picture)
{ {
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname); CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname); int lognum = TTable ::name2log (tabname);
@ -370,8 +351,7 @@ TString & fill_str (TString & t, char f)
// printer().setlinkdescr(descr); // printer().setlinkdescr(descr);
// } // }
void TPrint_application :: void TPrint_application::select_cursor (int c)
select_cursor (int c)
{ {
if (c == -1) if (c == -1)
_cur = NULL; _cur = NULL;
@ -379,8 +359,7 @@ select_cursor (int c)
_cur = (TCursor *) & _cursors[c]; _cur = (TCursor *) & _cursors[c];
} }
TCursor *TPrint_application :: TCursor* TPrint_application::get_cursor (int c)
get_cursor (int c)
{ {
if (c == -1) if (c == -1)
return NULL; return NULL;
@ -388,8 +367,7 @@ get_cursor (int c)
return (TCursor *) & _cursors[c]; return (TCursor *) & _cursors[c];
} }
int TPrint_application :: int TPrint_application::add_cursor (TCursor * c)
add_cursor (TCursor * c)
{ {
if (c == NULL) if (c == NULL)
return -1; return -1;
@ -398,8 +376,7 @@ add_cursor (TCursor * c)
return _cursors.items () - 1; return _cursors.items () - 1;
} }
void TPrint_application :: void TPrint_application::reset_row (int r)
reset_row (int r)
{ {
r--; r--;
int tmp = _rows.items (); int tmp = _rows.items ();
@ -417,16 +394,14 @@ reset_row (int r)
_maxrow--; _maxrow--;
} }
void TPrint_application :: void TPrint_application::reset_print ()
reset_print ()
{ {
_rows.destroy (); _rows.destroy ();
_maxrow = 0; _maxrow = 0;
_print_defined = FALSE; _print_defined = FALSE;
} }
void TPrint_application :: void TPrint_application::set_header (int r, const char *fmt,...)
set_header (int r, const char *fmt,...)
{ {
CHECK (r >= 1, "Header rows start at 1"); CHECK (r >= 1, "Header rows start at 1");
va_list vl; va_list vl;
@ -443,8 +418,7 @@ set_header (int r, const char *fmt,...)
pp->put (__tmp_string); pp->put (__tmp_string);
} }
void TPrint_application :: void TPrint_application::set_footer (int r, const char *fmt,...)
set_footer (int r, const char *fmt,...)
{ {
CHECK (r >= 1, "Footer rows start at 1"); CHECK (r >= 1, "Footer rows start at 1");
va_list vl; va_list vl;
@ -460,22 +434,19 @@ set_footer (int r, const char *fmt,...)
pp->put (__tmp_string); pp->put (__tmp_string);
} }
void TPrint_application :: void TPrint_application::reset_header ()
reset_header ()
{ {
_header.destroy (); _header.destroy ();
printer().resetheader (); printer().resetheader ();
} }
void TPrint_application :: void TPrint_application::reset_footer ()
reset_footer ()
{ {
_footer.destroy (); _footer.destroy ();
printer().resetfooter (); printer().resetfooter ();
} }
void TPrint_application :: void TPrint_application::fill_page (int from)
fill_page (int from)
{ {
from--; from--;
for (int i = (from == -1 ? _maxrow : from); i <= printer().formlen (); i++) for (int i = (from == -1 ? _maxrow : from); i <= printer().formlen (); i++)
@ -485,8 +456,7 @@ fill_page (int from)
} }
} }
void TPrint_application :: void TPrint_application::set_row (int r, const char *frmt,...)
set_row (int r, const char *frmt,...)
{ {
CHECK (r >= 1, "Print rows start at 1"); CHECK (r >= 1, "Print rows start at 1");
@ -777,8 +747,7 @@ set_row (int r, const char *frmt,...)
va_end (params); va_end (params);
} }
void TPrint_application :: void TPrint_application::set_translation (int lognum, const char *field,
set_translation (int lognum, const char *field,
const char *from, const char *to) const char *from, const char *to)
{ {
_transtab.add (new _Transfield (lognum, field, from, to)); _transtab.add (new _Transfield (lognum, field, from, to));
@ -791,6 +760,9 @@ void TPrint_application::print ()
if (!printer().open ()) if (!printer().open ())
return; return;
// only external apps can change it
_repeat_print = FALSE;
// never print multiple copies if printer is viswin // never print multiple copies if printer is viswin
// only application may repeat printing by setting _repeat_print // only application may repeat printing by setting _repeat_print
int nc = printer().printtype() == screenvis ? 1 : _ncopies; int nc = printer().printtype() == screenvis ? 1 : _ncopies;
@ -801,9 +773,8 @@ void TPrint_application::print ()
if (_cur == NULL) if (_cur == NULL)
{ {
//************************************************ //************************************************
while (_repeat_print || nc--) while (nc--)
{ {
_repeat_print = FALSE;
int cnt = 0; int cnt = 0;
bool ok = TRUE; bool ok = TRUE;
@ -830,9 +801,8 @@ void TPrint_application::print ()
else else
{ {
// cursor exists ********************************************* // cursor exists *********************************************
while (_repeat_print || nc--) while (nc--)
{ {
_repeat_print = FALSE;
(*_cur) = 0l; (*_cur) = 0l;
_cur->freeze (TRUE); _cur->freeze (TRUE);
@ -850,7 +820,7 @@ void TPrint_application::print ()
_prind = NULL; _prind = NULL;
} }
} }
// ************************************************************************ // ****************************************************************
} }
if (printer().isopen ()) if (printer().isopen ())
{ {
@ -861,8 +831,7 @@ void TPrint_application::print ()
postclose_print (); postclose_print ();
} }
bool TPrint_application :: bool TPrint_application::print_tree (link_item * head)
print_tree (link_item * head)
{ {
bool go = TRUE; bool go = TRUE;
while (head) while (head)
@ -1242,7 +1211,7 @@ void TPrint_application::do_print (int n)
{ {
while (set_print (n)) while (set_print (n))
{ {
print (); do { print(); } while (_repeat_print);
enable_print_menu (); enable_print_menu ();
} }
} }