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_LINES
MESSAGE DISABLE,DLG_SETPRINT
ITEM "1|File"
ITEM "1|File su disco"
MESSAGE SHOW,MSK_1_FILENAME|HIDE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE
@ -51,7 +51,7 @@ END
LIST MSK_1_SIZE 3
BEGIN
PROMPT 32 6 "Carattere "
PROMPT 31 6 "Carattere "
ITEM "7|7"
ITEM "8|8"
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 <stdarg.h>
@ -1209,44 +1209,47 @@ bool TPrint_application::create ()
printer().setfooterhandler (_pp_footer);
printer().setheaderhandler (_pp_header);
printer().setlinkhandler (_pp_link);
user_create ();
dispatch_e_menu (_last_choice);
return TRUE;
if (user_create())
{
dispatch_e_menu (_last_choice);
return TRUE;
}
else return FALSE;
}
bool TPrint_application::destroy ()
{
user_destroy ();
user_destroy();
reset_files();
_cursors.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);
enable_print_menu ();
do { print(); } while(_repeat_print);
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);
}

View File

@ -163,8 +163,8 @@ protected:
// footer etc) sono spiegate nel seguito
// ****************************************************
virtual void user_create() {}
virtual void user_destroy() {}
virtual bool user_create() pure;
virtual bool user_destroy() pure;
// set print, bound to menu :Selezione:Stampa
// chiamata automaticamente dopo user_create()
@ -453,7 +453,17 @@ public:
word get_page_number()
{ return printer().getcurrentpage(); }
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; }

View File

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

View File

@ -43,7 +43,8 @@ enum TPrtype {
spoolprinter = 2,
localprinter = 3,
screenvis = 4,
winprinter = 5
winprinter = 5,
export = 6
};
@ -133,6 +134,7 @@ class TPrinter : public TObject
TTextfile _txt;
TFilename _config; // name of the configuration file
TFilename _exportfile; // name of export file
int _headersize;
int _footersize;
TArray _header;
@ -171,6 +173,7 @@ class TPrinter : public TObject
void _parse_background();
void _get_windows_printer_names(TToken_string& t);
bool _multiple_copies;
bool _export_header;
PRINTSECTIONHANDLER _headerhandler, _footerhandler;
LINKHANDLER _linkhandler;
@ -263,7 +266,15 @@ public:
void set_printtype(TPrtype dest) { _printertype=dest; }
void set_printerfile(const char * ffile) { _printerfile=ffile; }
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_left() const;
#if XVT_OS == XVT_OS_WIN

View File

@ -197,7 +197,7 @@ void TTextfile::read_line (long n, long pos, bool pg)
_item = 0;
}
const char *TTextfile::line (long j, long pos)
const char *TTextfile::line(long j, long pos)
{
if (_cur_line != j)
read_line (j);
@ -208,6 +208,15 @@ const char *TTextfile::line (long j, long 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 stl = 0;

View File

@ -61,6 +61,10 @@ public:
// line() ritorna la stringa di caratteri senza formattazione
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);
// chide tutti i files per poter copiare o eseguire operazioni