From 4e053141b70146bcccbe531808165b8b6903a0bc Mon Sep 17 00:00:00 2001 From: villa Date: Wed, 14 Sep 1994 07:33:25 +0000 Subject: [PATCH] Corretta ripetizione stampa dopo link; cambiamenti cosmetici git-svn-id: svn://10.65.10.50/trunk@230 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/printapp.cpp | 273 +++++++++++++++++++------------------------ 1 file changed, 121 insertions(+), 152 deletions(-) diff --git a/include/printapp.cpp b/include/printapp.cpp index c67cc949b..727ea6679 100755 --- a/include/printapp.cpp +++ b/include/printapp.cpp @@ -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 #include @@ -60,29 +60,27 @@ class _Token:public TObject friend class TPrint_application; int _tag; int _row; - public: +public: int tag () - { - return _tag; - } + { + return _tag; + } int row () - { - return _row; - } + { + return _row; + } void tag (int t) - { - _tag = t; - } + { + _tag = t; + } void row (int r) { _row = r; } - virtual ~ _Token () - { - } + virtual ~ _Token () {} }; -class _PrintfTok:public _Token +class _PrintfTok : public _Token // something to be printed (actually already printed on _val) { friend class TPrint_application; @@ -94,12 +92,10 @@ class _PrintfTok:public _Token row (rw); _val = val; } - virtual ~ _PrintfTok () - { - } + virtual ~ _PrintfTok () {} }; -class _FieldTok:public _Token +class _FieldTok : public _Token // something more complex to be printed { friend class TPrint_application; @@ -127,7 +123,7 @@ class _FieldTok:public _Token } }; -class _PrintfRef:public _Token +class _PrintfRef : public _Token // to be printed by reference via format // must pass valid pointer to object { @@ -150,8 +146,7 @@ class _PrintfRef:public _Token } }; -void TPrint_application :: -_reset_tree (link_item * head) +void TPrint_application::_reset_tree (link_item * head) { if (head) { @@ -163,8 +158,7 @@ _reset_tree (link_item * head) } } -link_item *TPrint_application :: -_look_print_node (link_item * head, int logicnum) +link_item *TPrint_application::_look_print_node (link_item * head, int logicnum) { // look for node to attach to // 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; } -void TPrint_application :: -add_file (const char *tab, int from) +void TPrint_application::add_file (const char *tab, int from) { -add_file (TTable ::name2log (tab), from); + add_file (TTable ::name2log (tab), from); } -void TPrint_application :: -add_file (int file, int from) +void TPrint_application::add_file (int file, int from) { link_item *nw = new link_item (file); if (_pr_tree == NULL) @@ -197,14 +189,14 @@ add_file (int file, int from) _pr_tree = nw; return; } - + if (from == 0) from = _pr_tree->_logicnum; - + link_item *fr = _look_print_node (_pr_tree, from); - + CHECKD (fr, "add_file: nonexistent node: logicnum = ", from); - + if (fr->_son) { fr = fr->_son; @@ -221,8 +213,7 @@ add_file (int file, int from) static char tb[120]; -int TPrint_application :: -enable_link (const char *descr, char fg, char bg) +int TPrint_application::enable_link (const char *descr, char fg, char bg) { TToken_string *tt = new TToken_string (30); char b[2]; @@ -232,78 +223,71 @@ enable_link (const char *descr, char fg, char bg) tt->add (b); b[0] = bg; tt->add (b); - printer ().links ().add (tt); - return printer ().links ().items () - 1; + printer().links ().add (tt); + return printer().links ().items () - 1; } -void TPrint_application :: -disable_link (char fg, char bg) +void TPrint_application::disable_link (char fg, char bg) { - for (int i = 0; i < printer ().links ().items (); i++) + for (int i = 0; i < printer().links ().items (); i++) { - TToken_string & t = (TToken_string &) printer ().links ()[i]; + TToken_string & t = (TToken_string &) printer().links ()[i]; char f = *(t.get (1)); char b = *(t.get (2)); if (f == fg && b == bg) { - printer ().links ().add (NULL, i); - printer ().links ().pack (); + printer().links ().add (NULL, i); + printer().links ().pack (); break; } } } -void TPrint_application :: -set_multiple_link (bool on) +void TPrint_application::set_multiple_link (bool on) { - printer ().setmultiplelink (on); + printer().setmultiplelink (on); } -void TPrint_application :: -_pp_link (int id, const char *text) +void TPrint_application::_pp_link (int id, const char *text) { TPrint_application *prapp = (TPrint_application *) MainApp (); prapp->process_link (id, text); } -void TPrint_application :: -_pp_header (TPrinter &) +void TPrint_application::_pp_header (TPrinter &) { TPrint_application *prapp = (TPrint_application *) MainApp (); prapp->preprocess_header (); - prapp->printer ().resetheader (); + prapp->printer().resetheader (); int ii = (prapp->_header).last (); // reset and add header/footer lines for (int i = 0; i <= ii; i++) if ((prapp->_header).objptr (i) != NULL) - prapp->printer ().setheaderline (i, + prapp->printer().setheaderline (i, new TPrintrow ((TPrintrow &) (prapp->_header)[i])); } -void TPrint_application :: -_pp_footer (TPrinter &) +void TPrint_application::_pp_footer (TPrinter &) { TPrint_application *prapp = (TPrint_application *) MainApp (); prapp->preprocess_footer (); - prapp->printer ().resetfooter (); + prapp->printer().resetfooter (); int ii = (prapp->_footer).last (); for (int i = 0; i <= ii; i++) if ((prapp->_footer).objptr (i) != NULL) - prapp->printer ().setfooterline (i, + prapp->printer().setfooterline (i, new TPrintrow ((TPrintrow &) (prapp->_footer)[i])); } -void TPrint_application :: -set_background (const char *bgdesc) +void TPrint_application::set_background (const char *bgdesc) { - printer ().setbackground (bgdesc); + printer().setbackground (bgdesc); } -const char * -FLD (int lognum, const char *f, int from, int to) +const char* FLD (int lognum, const char *f, int from, int to) { sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to); char *p = new char[strlen (tb) + 1]; @@ -311,8 +295,7 @@ FLD (int lognum, const char *f, int from, int to) return p; } -const char * -FLD (int lognum, const char *f, const char *picture) +const char* FLD (int lognum, const char *f, const char *picture) { sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture); char *p = new char[strlen (tb) + 1]; @@ -320,8 +303,7 @@ FLD (int lognum, const char *f, const char *picture) return p; } -const char * -FLD (const char *tabname, const char *f, int from, int to) +const char* FLD (const char *tabname, const char *f, int from, int to) { CHECKS (strlen (tabname) < 5, "Invalid table name", tabname); int lognum = TTable ::name2log (tabname); @@ -331,8 +313,7 @@ FLD (const char *tabname, const char *f, int from, int to) return p; } -const char * -FLD (const char *tabname, const char *f, const char *picture) +const char* FLD (const char *tabname, const char *f, const char *picture) { CHECKS (strlen (tabname) < 5, "Invalid table name", tabname); int lognum = TTable ::name2log (tabname); @@ -342,7 +323,7 @@ FLD (const char *tabname, const char *f, const char *picture) return p; } -TString & fill_str (TString & t, char f) +TString& fill_str (TString & t, char f) { for (int kk = t.len () - 1; kk >= 0; kk--) { @@ -370,8 +351,7 @@ TString & fill_str (TString & t, char f) // printer().setlinkdescr(descr); // } -void TPrint_application :: -select_cursor (int c) +void TPrint_application::select_cursor (int c) { if (c == -1) _cur = NULL; @@ -379,8 +359,7 @@ select_cursor (int c) _cur = (TCursor *) & _cursors[c]; } -TCursor *TPrint_application :: -get_cursor (int c) +TCursor* TPrint_application::get_cursor (int c) { if (c == -1) return NULL; @@ -388,8 +367,7 @@ get_cursor (int c) return (TCursor *) & _cursors[c]; } -int TPrint_application :: -add_cursor (TCursor * c) +int TPrint_application::add_cursor (TCursor * c) { if (c == NULL) return -1; @@ -398,8 +376,7 @@ add_cursor (TCursor * c) return _cursors.items () - 1; } -void TPrint_application :: -reset_row (int r) +void TPrint_application::reset_row (int r) { r--; int tmp = _rows.items (); @@ -417,16 +394,14 @@ reset_row (int r) _maxrow--; } -void TPrint_application :: -reset_print () +void TPrint_application::reset_print () { _rows.destroy (); _maxrow = 0; _print_defined = FALSE; } -void TPrint_application :: -set_header (int r, const char *fmt,...) +void TPrint_application::set_header (int r, const char *fmt,...) { CHECK (r >= 1, "Header rows start at 1"); va_list vl; @@ -443,8 +418,7 @@ set_header (int r, const char *fmt,...) pp->put (__tmp_string); } -void TPrint_application :: -set_footer (int r, const char *fmt,...) +void TPrint_application::set_footer (int r, const char *fmt,...) { CHECK (r >= 1, "Footer rows start at 1"); va_list vl; @@ -460,33 +434,29 @@ set_footer (int r, const char *fmt,...) pp->put (__tmp_string); } -void TPrint_application :: -reset_header () +void TPrint_application::reset_header () { _header.destroy (); - printer ().resetheader (); + printer().resetheader (); } -void TPrint_application :: -reset_footer () +void TPrint_application::reset_footer () { _footer.destroy (); - printer ().resetfooter (); + printer().resetfooter (); } -void TPrint_application :: -fill_page (int from) +void TPrint_application::fill_page (int from) { from--; - for (int i = (from == -1 ? _maxrow : from); i <= printer ().formlen (); i++) + for (int i = (from == -1 ? _maxrow : from); i <= printer().formlen (); i++) { reset_row (i); set_row (i, ""); } } -void TPrint_application :: -set_row (int r, const char *frmt,...) +void TPrint_application::set_row (int r, const char *frmt,...) { CHECK (r >= 1, "Print rows start at 1"); @@ -777,19 +747,21 @@ set_row (int r, const char *frmt,...) va_end (params); } -void TPrint_application :: -set_translation (int lognum, const char *field, - const char *from, const char *to) +void TPrint_application::set_translation (int lognum, const char *field, + const char *from, const char *to) { _transtab.add (new _Transfield (lognum, field, from, to)); } -void TPrint_application::print () +void TPrint_application::print() { // open printer if needed - if (!(printer ().isopen ())) - if (!printer ().open ()) + if (!(printer().isopen ())) + if (!printer().open ()) return; + + // only external apps can change it + _repeat_print = FALSE; // never print multiple copies if printer is viswin // only application may repeat printing by setting _repeat_print @@ -801,68 +773,65 @@ void TPrint_application::print () if (_cur == NULL) { //************************************************ - while (_repeat_print || nc--) - { - _repeat_print = FALSE; - - int cnt = 0; - bool ok = TRUE; - do + while (nc--) + { + + int cnt = 0; + bool ok = TRUE; + do { - if (preprocess_print (0, cnt)) - { - int cnt2 = 0; - do + if (preprocess_print (0, cnt)) + { + int cnt2 = 0; + do { - if (preprocess_page (0, cnt2)) - { + if (preprocess_page (0, cnt2)) + { set_page (0, cnt2); ok = print_one (0); - } - } - while (ok && postprocess_page (0, cnt2++) == REPEAT_PAGE); - } - } - while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE); - // ***************************************************** - } + } + } + while (ok && postprocess_page (0, cnt2++) == REPEAT_PAGE); + } + } + while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE); + // ***************************************************** + } } else { // cursor exists ********************************************* - while (_repeat_print || nc--) - { - _repeat_print = FALSE; - (*_cur) = 0l; - _cur->freeze (TRUE); - - if (_cur->items () >= _wthr && - (_force_progind || printer ().printtype () != screenvis)) - _prind = new TProgind (_cur->items (), - (char *) (const char *) _wmess, - _wcancel, _wbar, 35); - print_tree (_pr_tree); - _cur->freeze (FALSE); - - if (_prind) - { + while (nc--) + { + (*_cur) = 0l; + _cur->freeze (TRUE); + + if (_cur->items () >= _wthr && + (_force_progind || printer ().printtype () != screenvis)) + _prind = new TProgind (_cur->items (), + (char *) (const char *) _wmess, + _wcancel, _wbar, 35); + print_tree (_pr_tree); + _cur->freeze (FALSE); + + if (_prind) + { delete _prind;; _prind = NULL; - } - } - // ************************************************************************ + } + } + // **************************************************************** } if (printer().isopen ()) { - printer().close (); - printer().resetheader (); - printer().resetfooter (); + printer().close(); + printer().resetheader(); + printer().resetfooter(); } postclose_print (); } -bool TPrint_application :: -print_tree (link_item * head) +bool TPrint_application::print_tree (link_item * head) { bool go = TRUE; while (head) @@ -1195,11 +1164,11 @@ bool TPrint_application::print_one (int file) for (i = 0; i <= _maxrow; i++) { TPrintrow *pr = (TPrintrow *) & rw[i]; - if (!(printer ().print (*pr))) + if (!(printer().print (*pr))) break; } - if (_auto_ff && _maxrow < printer ().formlen ()) - printer ().formfeed (); + if (_auto_ff && _maxrow < printer().formlen ()) + printer().formfeed (); delete pos; // TRUE if all rows have been printed @@ -1213,7 +1182,7 @@ bool TPrint_application::menu(MENU_TAG m) if (m >= BAR_ITEM (1) && m <= BAR_ITEM (20)) { _last_choice = m; - do_print ((m - BAR_ITEM (0)) / 100); + do_print((m - BAR_ITEM (0)) / 100); } // Se non esistono altre voci di menu termina l'applicazione @@ -1223,9 +1192,9 @@ bool TPrint_application::menu(MENU_TAG m) bool TPrint_application::create () { TApplication ::create (); - printer ().setfooterhandler (_pp_footer); - printer ().setheaderhandler (_pp_header); - printer ().setlinkhandler (_pp_link); + printer().setfooterhandler (_pp_footer); + printer().setheaderhandler (_pp_header); + printer().setlinkhandler (_pp_link); user_create (); dispatch_e_menu (_last_choice); return TRUE; @@ -1242,7 +1211,7 @@ void TPrint_application::do_print (int n) { while (set_print (n)) { - print (); + do { print(); } while (_repeat_print); enable_print_menu (); } }