Patch level : 10.0

Files correlati     : bagn001a.msk
Ricompilazione Demo : [ ]
Commento            :
0001607: 002422 - stampa schede
Descrizione	 il bottone di esportazione excell non produce risultati;
da impostazione stampante, scelgo di stampare su file,
chiede il nome del file (che è già impostato)


git-svn-id: svn://10.65.10.50/trunk@20431 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-05-06 13:28:28 +00:00
parent 448d7fa819
commit 0e70489f6b
12 changed files with 112 additions and 66 deletions

View File

@ -208,15 +208,15 @@ inline TObject& TArray::operator[] (int index) const
#define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \
TObject* __obj; \
for (int __r = __arr.first(); \
(__obj = __arr.objptr(__r)); \
__r = __arr.succ(__r))
for (int __r = (__arr).first(); \
(__obj = (__arr).objptr(__r)); \
__r = (__arr).succ(__r))
#define FOR_EACH_ARRAY_ITEM_BACK(__arr, __r, __obj) \
TObject* __obj; \
for (int __r = __arr.last(); \
(__obj = __arr.objptr(__r)); \
__r = __arr.pred(__r))
for (int __r = (__arr).last(); \
(__obj = (__arr).objptr(__r)); \
__r = (__arr).pred(__r))
class TPointer_array : public TArray

View File

@ -35,8 +35,7 @@ BEGIN
PROMPT 1 4 "File "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
DSELECT
FLAGS "AM"
FSELECT ""
WARNING "E' necessario specificare un nome di file"
GROUP 2
END

View File

@ -1,6 +1,7 @@
#include <xvt.h>
#include <checks.h>
#include <diction.h>
#include <keys.h>
#ifdef WIN32
@ -178,9 +179,15 @@ int yesnocancel_box(
bool cantread_box(const char* filename)
{
return error_box("Impossibile leggere '%s'", filename);
return error_box(FR("Impossibile leggere '%s'"), filename);
}
bool cantwrite_box(const char* filename)
{
return error_box(FR("Impossibile scrivere '%s'"), filename);
}
// @doc EXTERNAL
// @msg __trace | Permette di mandare dei messaggi nel file trace.log
bool __trace(

View File

@ -20,6 +20,7 @@ extern "C" {
int yesnocancel_box(const char* fmt, ...);
bool yesnofatal_box(const char* fmt, ...);
bool cantread_box(const char* filename);
bool cantwrite_box(const char* filename);
bool __trace(const char* fmt, ...);
bool __tracemem(const char* fmt);
#ifdef __cplusplus

View File

@ -3823,14 +3823,10 @@ bool TForm::print(
i++;
} // fine ciclo di stampa
while (fixed_pages() && page(pr) % _npages !=0)
while (fixed_pages() && page(pr)%_npages)
{
pr.formfeed();
/*
static TPrintrow empty_line;
pr.print(empty_line);
*/
pr.skip(1); // No static when possible
pr.skip(1);
}
if (from >= 0)

View File

@ -293,11 +293,11 @@ public:
};
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) \
TString_array& __sheet##__riga = (__sheet).rows_array(); \
FOR_EACH_ARRAY_ROW(__sheet##__riga, __r, __riga)
TString_array& sheetof##__riga = (__sheet).rows_array(); \
FOR_EACH_ARRAY_ROW(sheetof##__riga, __r, __riga)
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \
TString_array& __sheet##__riga = (__sheet).rows_array(); \
FOR_EACH_ARRAY_ROW_BACK(__sheet##__riga, __r, __riga)
TString_array& sheetof##__riga = (__sheet).rows_array(); \
FOR_EACH_ARRAY_ROW_BACK(sheetof##__riga, __r, __riga)
#endif

View File

@ -1596,16 +1596,14 @@ bool TPrinter::printrow(
TString rw;
if (rowtoprint != NULL)
{
rw = (_printertype == fileprinter) ? rowtoprint->row() : rowtoprint->row_codified();
//rw = (_printertype == fileprinter) ? rowtoprint->row() : rowtoprint->row_codified();
rw = rowtoprint->row_codified(); // Permetto di salvare anche su fileprinter = pippo.xls
rw.rtrim();
}
int lun = rw.len ();
int idx;
if (_printertype != exportprinter)
{
for (idx = 0; idx < lun; idx++)
for (int idx = 0; rw[idx]; idx++)
{
if (rw[idx] == '@') // gestione data e n. di pagina
{
@ -1629,7 +1627,7 @@ bool TPrinter::printrow(
if (_printertype == screenvis)
{
if (!_vf->frozen ())
if (!_vf->frozen())
_vf->add_line(rw);
else
_frozen = true;
@ -1984,8 +1982,36 @@ bool TPrinter::acrobatically_print_pdf(const TFilename& pdf) const
return ok;
}
bool TPrinter::auto_export(const TFilename& n)
{
TString ext = n.ext();
if (ext.blank())
return false;
ext.lower();
if (ext == "pdf")
{
print_pdf(_txt, n);
return true;
}
void TPrinter::close ()
if (ext.starts_with("xls"))
return _txt.write_xls(n);
if (ext == "txt")
{
ofstream txt(n);
for (long i = 0; i < _txt.lines(); i++)
txt << _txt.line(i) << '\n';
txt.close();
return true;
}
return false;
}
void TPrinter::close()
{
// la stampante era aperta e ho stampato qualcosa c'è footer da stampare
if (isopen() && _currentrow > 1 && _footersize > 0)
@ -1998,21 +2024,30 @@ void TPrinter::close ()
print_txt(_txt);
break;
case fileprinter:
if (_printerfile.full() && _txt.lines() > 0L)
{
FILE* fp = fopen(_printerfile, _appendfile ? "a" : "w");
if (fp == NULL)
bool done = false;
if (!_appendfile)
done = auto_export(_printerfile);
if (!done)
{
error_box(FR("Impossibile aprire il file %s"), (const char*)_printerfile);
return;
FILE* fp = fopen(_printerfile, _appendfile ? "a" : "w");
if (fp != NULL)
{
for (long i = 0; i < _txt.lines(); i++)
fprintf(fp,"%s\n", _txt.line(i));
fclose(fp);
done = true;
}
}
for (long i = 0; i < _txt.lines(); i++)
fprintf(fp,"%s\n", _txt.line(i));
fclose(fp);
message_box(FR("Stampa su file terminata. Nome archivio: %s"),(const char *)_printerfile);
if (done)
message_box(FR("Stampa su file terminata. Nome archivio: %s"),(const char *)_printerfile);
else
cantwrite_box(_printerfile);
}
break;
case exportprinter:
if (_exportfile.not_empty() && _txt.lines() > 0L)
if (_exportfile.full() && _txt.lines() > 0L)
{
ofstream txt(_exportfile);
for (long i = 0; i < _txt.lines(); i++)

View File

@ -312,6 +312,8 @@ protected:
bool printheader();
// @cmember Stampa il footer della pagina
bool printfooter();
// @cmember Esporta automaticamente nel formato deciso dalla estensione di n
bool auto_export(const TFilename& n);
// @access Public Member
public:
@ -521,7 +523,7 @@ public:
const TDate& getdate() const
{ return _date; }
// @cmember Ritorna il tipo di output selezionato dall'utente per la stampa
TPrtype printtype()
TPrtype printtype() const
{ return _printertype; }
// @cmember Setta il tipo di output selezionato dall'utente per la stampa
void set_printtype(TPrtype dest)

View File

@ -1547,10 +1547,10 @@ bool TBook::print_page(TWindow& win, size_t page)
bool TBook::export_text(TFilename& fname, bool signature)
{
if (fname.ends_with(".pdf", true))
TString ext = fname.ext(); ext.lower();
if (ext == "pdf")
return export_pdf(fname, signature);
if (fname.ends_with(".xls", true))
if (ext.starts_with("xls") || ext.starts_with("htm"))
return export_excel(fname, signature);
TToken_string str(1024, '=');
@ -1896,7 +1896,7 @@ void TBook::split_file(int colonne)
ofstream out(temp);
TPointer_array index;
close_output(); // Chiudo file di stampa eventualmente aperto
close_output(); // Chiudo file di stampa eventualmente aperto
ifstream ifs(_file); // Apro file di stampa da splittare
TToken_string str(1024, '=');
@ -2278,10 +2278,11 @@ bool TBook::print_or_preview()
switch (printer().printtype())
{
case screenvis: ok = preview(); break;
case fileprinter:
case exportprinter:
{
TFilename f = printer().get_export_file();
ok = export_text(f, NULL);
ok = export_text(f, false);
if (ok)
xvt_sys_goto_url(f, "open");
}
@ -2290,7 +2291,10 @@ bool TBook::print_or_preview()
{
TFilename f; f.tempdir(); f.add("tmp.pdf");
if (export_pdf(f, false))
{
printer().acrobatically_print_pdf(f);
f.fremove();
}
}
break;
default: ok = print(); break;

View File

@ -876,11 +876,8 @@ bool TTextfile::write_xls(const TFilename& xls)
{
str = cp;
const int len = str.len();
if (str.full())
{
if (str_type(str) > 0)
tab.add_field(x, len);
}
if (str.full() && str_type(str) > 0)
tab.add_field(x, len);
x += len;
}
}
@ -938,7 +935,7 @@ void TTextfile::destroy ()
_index = fopen (_indname, "w+b");
if (_index == NULL || _instr == NULL)
{
error_box ("Impossibile aprire files temporanei");
cantwrite_box (_filename);
freeze ();
}
_isopen = TRUE;
@ -971,7 +968,7 @@ TTextfile ::TTextfile (const char *file, int pagesize, direction preferred,
if (_index == NULL || _instr == NULL)
{
yesnofatal_box ("Impossibile aprire files temporanei");
cantwrite_box(_filename);
freeze ();
}
if (!_istemp)
@ -981,7 +978,7 @@ TTextfile ::TTextfile (const char *file, int pagesize, direction preferred,
fwrite (&l, sizeof (long), 1, _index);
if (ferror(_index) || ferror(_instr))
{
error_box("Errore di scrittura file temporaneo: scrittura interrotta");
cantwrite_box(_indname);
freeze();
}
if (fgets (TEXT_TMP, TEXT_TMP_SIZE, _instr) == NULL)

View File

@ -168,9 +168,9 @@ void TVariable_rectype::write_memo(TIsam_handle file, const TRecnotype recno)
void TVariable_rectype::add_field(TVariable_field * f)
{
CHECK(f, "Null field");
CHECKS(!TRectype::exist(f->name()), "Field already exist ", f->name());
CHECKS(!TRectype::exist(f->name()), "Ambiuguous virtual/physical field ", f->name());
f->set_rec(this);
_virtual_fields.add(f->name(), f, TRUE);
_virtual_fields.add(f->name(), f, true);
}
void TVariable_rectype::remove_field(const char * fieldname)
@ -251,38 +251,43 @@ bool TVariable_rectype::exist(const char* fieldname) const
const TString & TVariable_rectype::get_str(const char* fieldname) const
{
TVariable_field * f = (TVariable_field *) _virtual_fields.objptr(fieldname);
TVariable_field* f = (TVariable_field*) _virtual_fields.objptr(fieldname);
if (_memo_fld_to_load && f == NULL)
{
((TVariable_rectype *) this)->_memo_fld_to_load = false;
((TVariable_rectype*)this)->_memo_fld_to_load = false;
TToken_string values(get(_memo_fld), '\n');
for (const char * s = values.get(0); s && *s; s = values.get())
{
char * val = (char*)strchr(s, '='); //antica porcata
char* val = (char*)strchr(s, '='); //antica porcata
if (val)
{
*val = '\0';
val++;
if (*val)
{
TVariable_field * v = (TVariable_field *) _virtual_fields.objptr(s);
TVariable_field* v = (TVariable_field*)_virtual_fields.objptr(s);
if (v == NULL)
{
v = new TVariable_field(s);
((TVariable_rectype *) this)->add_field(v);
if (TRectype::exist(s)) // Campo ex-virtuale ora diventato reale
{
CHECKS(TRectype::get(s).empty(), "Campo ex-virtuale pieno ", s);
((TRectype*)this)->TRectype::put(s, val);
}
else
{
v = new TVariable_field(s);
((TVariable_rectype*)this)->add_field(v);
}
}
v->force_value(val);
if (v != NULL)
v->force_value(val);
}
}
}
f = (TVariable_field *) _virtual_fields.objptr(fieldname);
f = (TVariable_field*)_virtual_fields.objptr(fieldname);
}
if (f)
return f->get();
else
return TRectype::get_str(fieldname);
return f != NULL ? f->get() : TRectype::get_str(fieldname);
}
void TVariable_rectype::put_str(const char* fieldname, const char* val)

View File

@ -2228,10 +2228,10 @@ void TViswin::sel_to_clipboard()
int i;
for (i = 0; i < txt.items(); i++)
size += txt.row(i).len() + eol_len;
char* p = (char*)xvt_cb_alloc_data(size); // allocate clipboard
char* p = xvt_cb_alloc_data(size); // allocate clipboard
if (p == NULL)
{
error_box("Impossibile allocare una clipboard di %ld bytes", size);
error_box(FR("Impossibile allocare una clipboard di %ld bytes"), size);
return;
}
// put data