Sistemate modalita' di export/import files nella stampa per interfacciamento

programmi in batch


git-svn-id: svn://10.65.10.50/trunk@598 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-11-11 11:23:30 +00:00
parent dcad72aedd
commit 0e8c22f336
7 changed files with 127 additions and 64 deletions

View File

@ -20,7 +20,7 @@ BEGIN
MESSAGE DISABLE,MSK_1_SIZE MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT MESSAGE DISABLE,DLG_SETPRINT
ITEM "1|File" ITEM "1|File su disco"
MESSAGE SHOW,MSK_1_FILENAME|HIDE,MSK_1_PRINTERS MESSAGE SHOW,MSK_1_FILENAME|HIDE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE MESSAGE DISABLE,MSK_1_SIZE
@ -51,7 +51,7 @@ END
LIST MSK_1_SIZE 3 LIST MSK_1_SIZE 3
BEGIN BEGIN
PROMPT 32 6 "Carattere " PROMPT 31 6 "Carattere "
ITEM "7|7" ITEM "7|7"
ITEM "8|8" ITEM "8|8"
ITEM "10|10" ITEM "10|10"

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.14 1994-11-02 08:47:08 villa Exp $ // $Id: printapp.cpp,v 1.15 1994-11-11 11:23:16 villa Exp $
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -1209,44 +1209,47 @@ bool TPrint_application::create ()
printer().setfooterhandler (_pp_footer); printer().setfooterhandler (_pp_footer);
printer().setheaderhandler (_pp_header); printer().setheaderhandler (_pp_header);
printer().setlinkhandler (_pp_link); printer().setlinkhandler (_pp_link);
user_create (); if (user_create())
dispatch_e_menu (_last_choice); {
return TRUE; dispatch_e_menu (_last_choice);
return TRUE;
}
else return FALSE;
} }
bool TPrint_application::destroy () bool TPrint_application::destroy ()
{ {
user_destroy (); user_destroy();
reset_files(); reset_files();
_cursors.destroy(); _cursors.destroy();
return TApplication::destroy (); return TApplication::destroy ();
} }
void TPrint_application::do_print (int n) void TPrint_application::do_print(int n)
{ {
while (set_print (n)) while (set_print(n))
{ {
do { print(); } while (_repeat_print); do { print(); } while(_repeat_print);
enable_print_menu (); enable_print_menu();
} }
} }
void TPrint_application::enable_print_menu () void TPrint_application::enable_print_menu()
{ {
enable_menu_item (M_FILE_PRINT, TRUE); enable_menu_item(M_FILE_PRINT, TRUE);
} }
void TPrint_application::disable_print_menu () void TPrint_application::disable_print_menu()
{ {
enable_menu_item (M_FILE_PRINT, FALSE); enable_menu_item(M_FILE_PRINT, FALSE);
} }
void TPrint_application::enable_setprint_menu () void TPrint_application::enable_setprint_menu()
{ {
enable_menu_item (BAR_ITEM (1), TRUE); enable_menu_item(BAR_ITEM (1), TRUE);
} }
void TPrint_application::disable_setprint_menu () void TPrint_application::disable_setprint_menu()
{ {
enable_menu_item (BAR_ITEM (1), FALSE); enable_menu_item (BAR_ITEM (1), FALSE);
} }

View File

@ -163,8 +163,8 @@ protected:
// footer etc) sono spiegate nel seguito // footer etc) sono spiegate nel seguito
// **************************************************** // ****************************************************
virtual void user_create() {} virtual bool user_create() pure;
virtual void user_destroy() {} virtual bool user_destroy() pure;
// set print, bound to menu :Selezione:Stampa // set print, bound to menu :Selezione:Stampa
// chiamata automaticamente dopo user_create() // chiamata automaticamente dopo user_create()
@ -453,7 +453,17 @@ public:
word get_page_number() word get_page_number()
{ return printer().getcurrentpage(); } { return printer().getcurrentpage(); }
void set_page_number(word n) void set_page_number(word n)
{ printer().setcurrentpage(n); } { printer().setcurrentpage(n); }
// dirige la stampa sul file specificato, preservando gli attributi di formato
// se header == TRUE si stampano su file anche gli header
void set_export_file(const char* name, bool header = TRUE)
{ printer().set_export_file(name,header); }
// infila un file di export fatto da un'altra printer (con formati e tutto, ignora
// gli header supponendo che siano gia' presenti nel file)
// se header == TRUE gli header stanno nel file e non vengono stampati
void merge_export_file(const char* file, bool header = TRUE)
{ printer().merge_export_file(file,header); }
void set_n_copies(int n) { _ncopies = n; } void set_n_copies(int n) { _ncopies = n; }

View File

@ -281,7 +281,7 @@ void TPrinter::_parse_background ()
} }
} }
void TPrinter::setbackground (const char *b) void TPrinter::setbackground(const char *b)
{ {
_background.destroy (); _background.destroy ();
_bg_desc = b; _bg_desc = b;
@ -289,7 +289,7 @@ void TPrinter::setbackground (const char *b)
_parse_background (); _parse_background ();
} }
bool printers_on_key (TMask_field & f, KEY key); bool printers_on_key(TMask_field & f, KEY key);
// fv support structs for config // fv support structs for config
@ -381,12 +381,12 @@ bool PrinterDef::isdefault ()
////////// TPRINTROW ////////// ////////// TPRINTROW //////////
TPrintrow ::TPrintrow () TPrintrow::TPrintrow()
{ {
reset (); reset();
} }
TPrintrow ::TPrintrow (const TPrintrow & pr) TPrintrow::TPrintrow(const TPrintrow& pr)
{ {
_row = pr.row (); _row = pr.row ();
memcpy (_attr, pr._attr, MAXSTR); memcpy (_attr, pr._attr, MAXSTR);
@ -405,19 +405,18 @@ TObject *TPrintrow::dup () const
return new TPrintrow (*this); return new TPrintrow (*this);
} }
const char *TPrintrow ::class_name () const const char *TPrintrow::class_name () const
{ {
return "Printrow"; return "Printrow";
} }
word TPrintrow ::class_id () word TPrintrow::class_id()
const const
{ {
return CLASS_PRINTROW; return CLASS_PRINTROW;
} }
TPrintrow & TPrintrow :: TPrintrow & TPrintrow::reset ()
reset ()
{ {
_row.spaces (sizeof (_attr)); _row.spaces (sizeof (_attr));
_currentcolor = 'w'; _currentcolor = 'w';
@ -710,7 +709,7 @@ TToken_string& TPrinter::getprinternames ()
return _printer_names; return _printer_names;
} }
void TPrinter::read_configuration (const char *conf) void TPrinter::read_configuration(const char *conf)
{ {
FILE *cnfp = fopen (conf, "r"); FILE *cnfp = fopen (conf, "r");
@ -859,7 +858,7 @@ void TPrinter::resetfooter ()
// _footersize = 0; // _footersize = 0;
} }
bool TPrinter::printrow (TPrintrow * rowtoprint) bool TPrinter::printrow(TPrintrow* rowtoprint)
{ {
if (!isopen ()) if (!isopen ())
return FALSE; return FALSE;
@ -874,25 +873,27 @@ bool TPrinter::printrow (TPrintrow * rowtoprint)
int lun = rw.len (); int lun = rw.len ();
int idx; int idx;
for (idx = 0; idx < lun; idx++) if (_printertype != export)
{ {
if (rw[idx] == '@') // gestione data e n. di pagina for (idx = 0; idx < lun; idx++)
{ {
switch (rw[idx + 1]) if (rw[idx] == '@') // gestione data e n. di pagina
{ {
case '#': switch (rw[idx + 1])
rw.overwrite (format ("%-5u", _currentpage), idx++); {
break; case '#':
case '>': rw.overwrite (format("%-5u", _currentpage), idx++);
rw.overwrite (_date.string (4), idx++); break;
break; case '>':
case '<': rw.overwrite (_date.string (4), idx++);
rw.overwrite (_date.string (2), idx++); break;
break; case '<':
default: rw.overwrite (_date.string (2), idx++);
break; break;
default:
break;
}
} }
} }
} }
@ -906,10 +907,9 @@ bool TPrinter::printrow (TPrintrow * rowtoprint)
return TRUE; return TRUE;
} }
if (_printertype == winprinter) if (_printertype == winprinter || _printertype == export)
{ {
// add line to txt // add line to txt
// CHECK balla colori
if (!_frozen) if (!_frozen)
_txt.append (rw); _txt.append (rw);
return TRUE; return TRUE;
@ -943,17 +943,19 @@ word TPrinter::rows_left() const
return left; return left;
} }
bool TPrinter::print(TPrintrow & rowtoprint)
bool TPrinter::print(TPrintrow& rowtoprint)
{ {
bool ok = TRUE; bool ok = TRUE;
if (_currentrow > _formlen - _footersize) if (!(_printertype == export && !_export_header))
ok = printfooter (); {
if (_currentrow > _formlen - _footersize)
// if (ok && _currentrow <= _headersize) ok = printfooter ();
if (ok && _currentrow == 1)
ok = printheader();
if (ok && _currentrow == 1)
ok = printheader();
}
if (ok) if (ok)
{ {
ok = printrow(&rowtoprint); ok = printrow(&rowtoprint);
@ -1051,7 +1053,6 @@ bool TPrinter::printformfeed()
bool TPrinter::open() bool TPrinter::open()
{ {
// qui
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
if (_printertype == spoolprinter) if (_printertype == spoolprinter)
{ {
@ -1101,7 +1102,7 @@ bool TPrinter::open()
_linksdescr.items () > 0); _linksdescr.items () > 0);
_vf->open_modal (); _vf->open_modal ();
} }
else if (_printertype == winprinter) else if (_printertype == winprinter || _printertype == export)
{ {
// prepare text object for new text // prepare text object for new text
_txt.destroy (); _txt.destroy ();
@ -1326,7 +1327,6 @@ void TPrinter::set()
switch (atoi (mask.get (MSK_1_TYPE))) switch (atoi (mask.get (MSK_1_TYPE)))
{ {
case 0: // stampante case 0: // stampante
_printertype = winprinter; _printertype = winprinter;
break; break;
case 1: // file case 1: // file
@ -1352,6 +1352,20 @@ void TPrinter::set()
main_app().enable_menu_item (M_FILE_PG_SETUP); main_app().enable_menu_item (M_FILE_PG_SETUP);
} }
void TPrinter::merge_export_file(const char* file, bool header)
{
TTextfile txt(file);
for (long i = 0; i < txt.lines(); i++)
{
TPrintrow* p = new TPrintrow();
p->put(txt.line_formatted(i));
if (header) printrow(p);
else print(*p);
}
}
void TPrinter::close () void TPrinter::close ()
{ {
if (isopen () && _currentrow > 1 && if (isopen () && _currentrow > 1 &&
@ -1375,6 +1389,18 @@ void TPrinter::close ()
freeze (FALSE); freeze (FALSE);
_vf = NULL; _vf = NULL;
} }
else if (_printertype == export)
{
if (!_exportfile.empty())
{
ofstream txt((const char*)_exportfile);
for (long i = 0; i < _txt.lines(); i++)
{
txt << _txt.line_formatted(i) << '\n';
}
txt.close();
}
}
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
else if (_printertype == winprinter) else if (_printertype == winprinter)
{ {

View File

@ -43,7 +43,8 @@ enum TPrtype {
spoolprinter = 2, spoolprinter = 2,
localprinter = 3, localprinter = 3,
screenvis = 4, screenvis = 4,
winprinter = 5 winprinter = 5,
export = 6
}; };
@ -133,6 +134,7 @@ class TPrinter : public TObject
TTextfile _txt; TTextfile _txt;
TFilename _config; // name of the configuration file TFilename _config; // name of the configuration file
TFilename _exportfile; // name of export file
int _headersize; int _headersize;
int _footersize; int _footersize;
TArray _header; TArray _header;
@ -171,6 +173,7 @@ class TPrinter : public TObject
void _parse_background(); void _parse_background();
void _get_windows_printer_names(TToken_string& t); void _get_windows_printer_names(TToken_string& t);
bool _multiple_copies; bool _multiple_copies;
bool _export_header;
PRINTSECTIONHANDLER _headerhandler, _footerhandler; PRINTSECTIONHANDLER _headerhandler, _footerhandler;
LINKHANDLER _linkhandler; LINKHANDLER _linkhandler;
@ -263,7 +266,15 @@ public:
void set_printtype(TPrtype dest) { _printertype=dest; } void set_printtype(TPrtype dest) { _printertype=dest; }
void set_printerfile(const char * ffile) { _printerfile=ffile; } void set_printerfile(const char * ffile) { _printerfile=ffile; }
word getcurrentpage() { return _currentpage; } word getcurrentpage() { return _currentpage; }
void setcurrentpage(word n) { _currentpage = n; } void setcurrentpage(word n) { _currentpage = n; }
// dirige la stampa sul file specificato, preservando gli attributi di formato
// se header == TRUE si stampano su file anche gli header
void set_export_file(const char* n, bool header = TRUE)
{ _printertype = export; _exportfile = n; _export_header = header; }
// infila un file di export fatto da un'altra printer (con formati e tutto, ignora
// gli header supponendo che siano gia' presenti nel file)
// se header == TRUE gli header stanno nel file e non vengono stampati
void merge_export_file(const char* file, bool header = TRUE);
word rows() const { return _formlen-_headersize-_footersize; } word rows() const { return _formlen-_headersize-_footersize; }
word rows_left() const; word rows_left() const;
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN

View File

@ -197,7 +197,7 @@ void TTextfile::read_line (long n, long pos, bool pg)
_item = 0; _item = 0;
} }
const char *TTextfile::line (long j, long pos) const char *TTextfile::line(long j, long pos)
{ {
if (_cur_line != j) if (_cur_line != j)
read_line (j); read_line (j);
@ -208,6 +208,15 @@ const char *TTextfile::line (long j, long pos)
return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : ""; return strlen (mytmpstr) > (word) pos ? &(mytmpstr[pos]) : "";
} }
const char *TTextfile::line_formatted(long j)
{
if (_cur_line != j)
read_line (j);
TString* tp = (TString*)_page.objptr(int(j-_page_start));
strcpy(mytmpstr, (const char*)(*tp));
return mytmpstr;
}
long TTextfile::get_attribute (int pos) long TTextfile::get_attribute (int pos)
{ {
long stl = 0; long stl = 0;

View File

@ -61,6 +61,10 @@ public:
// line() ritorna la stringa di caratteri senza formattazione // line() ritorna la stringa di caratteri senza formattazione
const char* line(long row, long column = 0); const char* line(long row, long column = 0);
// line_formatted() la ritorna, come e' logico attendersi, con
// la formattazione
const char* line_formatted(long row);
// appende una riga al text (con i formati del caso)
bool append(const char* l); bool append(const char* l);
// chide tutti i files per poter copiare o eseguire operazioni // chide tutti i files per poter copiare o eseguire operazioni