Patch level : 12.0 nopatch

Files correlati     :

Commento        :

Esportazione in excel possibilità di scegliere i file.
Migliorata formattazione stringe su più linee
Aggiunti bottoni per esportazione nella aprintbar
This commit is contained in:
Alessandro Bonazzi 2021-05-12 06:53:25 +02:00
parent 8b92a8411c
commit c2596b4fcc
4 changed files with 86 additions and 14 deletions

View File

@ -4,15 +4,39 @@ BEGIN
PICTURE TOOL_PRINT
END
#ifdef EXPORT
BUTTON DLG_EXPORT 10 2
BEGIN
PROMPT 2 1 "~Esporta"
PICTURE TOOL_EXPORT
END
#endif
#ifdef EXPORT_EXCEL
BUTTON DLG_EXPORT_EXCEL 10 2
BEGIN
PROMPT 3 1 "~Esporta"
PICTURE TOOL_EXCEL
END
#endif
#ifdef EXPORT_PDF
BUTTON DLG_EXPORT_PDF 10 2
BEGIN
PROMPT 4 1 "~Esporta"
PICTURE TOOL_PDF
END
#endif
BUTTON DLG_SETPRINT 2 2
BEGIN
PROMPT 2 1 "Imposta"
PROMPT 5 1 "Imposta"
PICTURE TOOL_SETPRINT
END
BUTTON DLG_PREVIEW 2 2
BEGIN
PROMPT 3 1 "~Anteprima"
PROMPT 6 1 "~Anteprima"
PICTURE TOOL_PREVIEW
END

View File

@ -51,6 +51,8 @@
#define DLG_BARCODE_TYPE 47 /* TAG del tipo codice a barre */
#define DLG_ALL 48 /* TAG del bottone Tutti */
#define DLG_LOG 49 /* TAG del delle transazioni */
#define DLG_EXPORT_EXCEL 50 /* TAG del bottone Esporta in Excel */
#define DLG_EXPORT_PDF 51 /* TAG del bottone Esporta un pdf */
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */

View File

@ -873,9 +873,24 @@ int TBook::compute_text_frame(const TString& tmp, const TReport_font& font, TRep
CHECK(w == PRINTER_WIN, "Finestra di stampa non valida");
xvt_dwin_set_font(w, font.get_xvt_font(*_printwin));
TToken_string p(tmp, '\n');
// TToken_string p(tmp, '\n');
TString int_tmp(tmp);
int pos = int_tmp.find('|');
while (pos >= 0)
{
int_tmp[pos] = 'ü';
pos = int_tmp.find('|', pos);
}
TParagraph_string p(int_tmp, rect.width() /100);
FOR_EACH_TOKEN(p, line)
{
while (char * s = (char *)strstr(line, "ü"))
*s = '|';
para.add(line);
}
for (int i = 0; i < para.items(); i++)
{
TString& row = para.row(i);
@ -1577,13 +1592,27 @@ bool TBook::print_page(TWindow& win, size_t page)
return true;
}
bool TBook::export_text(TFilename& fname, bool signature, int size)
HIDDEN bool ask_export_filename(TFilename& fname)
{
bool ok = false;
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(fname, &fs);
if (ok = (xvt_dm_post_file_save(&fs, TR("Esportazione")) == FL_OK))
xvt_fsys_convert_fspec_to_str(&fs, fname.get_buffer(), fname.size());
return ok;
}
bool TBook::export_text(TFilename& fname, bool signature, int size, bool goto_url, bool ask_filename)
{
TString ext = fname.ext(); ext.lower();
if (ext == "pdf")
return export_pdf(fname, signature);
return export_pdf(fname, signature, goto_url, ask_filename);
if (ext.starts_with("xls") || ext.starts_with("htm"))
return export_excel(fname, signature);
return export_excel(fname, signature, goto_url, ask_filename);
if (ask_filename && !ask_export_filename(fname))
return false;
TToken_string str(1024, '=');
@ -1733,7 +1762,8 @@ bool TBook::export_text(TFilename& fname, bool signature, int size)
if (xvt_sign_file(fname, outfile))
fname = outfile;
}
if (goto_url)
xvt_sys_goto_url(fname, "open");
return true;
}
@ -1772,9 +1802,12 @@ static void reformat_excel(TString& str)
}
}
bool TBook::export_excel(TFilename& fname, bool signature)
bool TBook::export_excel(TFilename& fname, bool signature, bool goto_url, bool ask_filename)
{
TTabulator tab;
if (ask_filename && !ask_export_filename(fname))
return false;
int row = 0, col = 0, wid = 0;
TToken_string str(1024, '=');
@ -1890,6 +1923,8 @@ bool TBook::export_excel(TFilename& fname, bool signature)
fname = outfile;
}
if (goto_url)
xvt_sys_goto_url(fname, "open");
return true;
}
@ -2208,15 +2243,18 @@ bool TBook::print(size_t pagefrom, size_t pageto, word copies)
return ok;
}
bool TBook::export_pdf(TFilename& filename, bool signature)
bool TBook::export_pdf(TFilename& filename, bool signature, bool goto_url, bool ask_filename)
{
bool ok = (pages() > 0) && main_app().has_module(RSAUT); // Controllo paranoico dei permessi
if (ok)
{
if (ask_filename && !ask_export_filename(filename))
return false;
// Evita problemi di aggiornamento del pdf: deve sempre rigenerarlo!
if (filename.exist() && !filename.fremove())
return cantwrite_box(filename);
_pdf_file = filename;
_pagefrom = 1;
_pageto = 0;
@ -2234,6 +2272,8 @@ bool TBook::export_pdf(TFilename& filename, bool signature)
}
}
}
if (ok && goto_url)
xvt_sys_goto_url(filename, "open");
return ok;
}
@ -2268,13 +2308,13 @@ bool TBook::esporta()
break;
case 'P':
case 'p':
ok = export_pdf(fname, signature);
ok = export_pdf(fname, signature);
if (ok)
xvt_sys_goto_url(fname, "open");
break;
case 'X':
case 'x':
ok = export_excel(fname, signature);
ok = export_excel(fname, signature);
if (ok)
xvt_sys_goto_url(fname, "open");
break;
@ -2774,13 +2814,16 @@ void TReport_book::add_doc(const TString& name)
if (name.ends_with(".rep", true)) // Tratto a parte i report!
{
TReport* eminem = new TReport;
if (eminem->load(name))
{
TFilename msk = _report->filename().name();
msk.ext("msk");
if (_report->use_mask() && msk.custom_path())
{
TMask m(msk);
_report->report2mask(m);
eminem->mask2report(m);
}
@ -2788,9 +2831,11 @@ void TReport_book::add_doc(const TString& name)
{
TRecordset* mainset = _report->recordset();
TRecordset* recset = eminem->recordset();
if (mainset && recset)
{
const TString_array& vars = mainset->variables();
FOR_EACH_ARRAY_ROW(vars, i, name)
recset->set_var(*name, mainset->get_var(*name));
if (main_app().name().starts_with("ve1"))
@ -2804,6 +2849,7 @@ void TReport_book::add_doc(const TString& name)
}
TReport* rep = _report; // Salvo variabile globale
add(*eminem, true);
_report = rep; // Ripristino variabile globale
}

View File

@ -97,9 +97,9 @@ public:
virtual bool archive(const char* repname, bool signature);
virtual bool preview();
virtual bool export_excel(TFilename& fname, bool signature);
virtual bool export_pdf(TFilename& fname, bool signature);
virtual bool export_text(TFilename& fname, bool signature, int size);
virtual bool export_excel(TFilename& fname, bool signature, bool goto_url = false, bool ask_filename = false);
virtual bool export_pdf(TFilename& fname, bool signature, bool goto_url = false, bool ask_filename = false);
virtual bool export_text(TFilename& fname, bool signature, int size, bool goto_url = false, bool ask_filename = false);
virtual bool send_mail(TFilename& fname, bool signature);
virtual bool esporta();
bool print_or_preview(); // Calls one of the above