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:
parent
dcad72aedd
commit
0e8c22f336
@ -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"
|
||||||
|
@ -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,10 +1209,13 @@ 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);
|
dispatch_e_menu (_last_choice);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
else return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
bool TPrint_application::destroy ()
|
bool TPrint_application::destroy ()
|
||||||
{
|
{
|
||||||
|
@ -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()
|
||||||
@ -455,6 +455,16 @@ public:
|
|||||||
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; }
|
||||||
int get_n_copies() { return _ncopies; }
|
int get_n_copies() { return _ncopies; }
|
||||||
|
@ -416,8 +416,7 @@ word TPrintrow ::class_id ()
|
|||||||
return CLASS_PRINTROW;
|
return CLASS_PRINTROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintrow & TPrintrow ::
|
TPrintrow & TPrintrow::reset ()
|
||||||
reset ()
|
|
||||||
{
|
{
|
||||||
_row.spaces (sizeof (_attr));
|
_row.spaces (sizeof (_attr));
|
||||||
_currentcolor = 'w';
|
_currentcolor = 'w';
|
||||||
@ -875,10 +874,11 @@ bool TPrinter::printrow (TPrintrow * rowtoprint)
|
|||||||
int lun = rw.len ();
|
int lun = rw.len ();
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
|
if (_printertype != export)
|
||||||
|
{
|
||||||
for (idx = 0; idx < lun; idx++)
|
for (idx = 0; idx < lun; idx++)
|
||||||
{
|
{
|
||||||
if (rw[idx] == '@') // gestione data e n. di pagina
|
if (rw[idx] == '@') // gestione data e n. di pagina
|
||||||
|
|
||||||
{
|
{
|
||||||
switch (rw[idx + 1])
|
switch (rw[idx + 1])
|
||||||
{
|
{
|
||||||
@ -896,6 +896,7 @@ bool TPrinter::printrow (TPrintrow * rowtoprint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_printertype == screenvis)
|
if (_printertype == screenvis)
|
||||||
{
|
{
|
||||||
@ -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 (!(_printertype == export && !_export_header))
|
||||||
|
{
|
||||||
if (_currentrow > _formlen - _footersize)
|
if (_currentrow > _formlen - _footersize)
|
||||||
ok = printfooter ();
|
ok = printfooter ();
|
||||||
|
|
||||||
// if (ok && _currentrow <= _headersize)
|
|
||||||
if (ok && _currentrow == 1)
|
if (ok && _currentrow == 1)
|
||||||
ok = printheader();
|
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)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
@ -264,6 +267,14 @@ public:
|
|||||||
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
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user