From 6adaae309c160149f78933dcb1f9ac1b8f5939a5 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Mon, 10 Feb 2025 22:54:21 +0100 Subject: [PATCH] Patch level : 12.00 1378 Files correlati : ca3.exe Bug : Commento: Sistemata creazione file temporaneo nei book e report_book --- src/include/reprint.cpp | 43 ++++++++++++++++++++++------------------- src/include/reprint.h | 8 +++++--- src/include/strings.h | 10 +++++----- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/include/reprint.cpp b/src/include/reprint.cpp index b51744e89..e6157b18b 100755 --- a/src/include/reprint.cpp +++ b/src/include/reprint.cpp @@ -1908,13 +1908,13 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go FOR_EACH_STR_TOKEN(line, val) if (*desc->rec().Fd[i].Name != '\0') switch (desc->rec().Fd[i].TypeF) - { - case _alfafld: - case _charfld: - case _boolfld: - case _memofld: + { + case _alfafld: + case _charfld: + case _boolfld: + case _memofld: dbf.put(desc->rec().Fd[i++].Name, val); - break; + break; case _intfld : case _longfld : case _realfld : @@ -1922,12 +1922,12 @@ bool TBook::export_dbase(TFilename& fname, TTrec * desc, bool signature, bool go case _intzerofld : case _longzerofld : dbf.put(desc->rec().Fd[i++].Name, real::ita2eng(val)); - break; + break; case _datefld : dbf.put(desc->rec().Fd[i++].Name, TDate(atoi(val.left(2)), atoi(val.mid(3,2)), 2000 + atoi(val.right(2)))); - break; + break; default : - break; + break; } dbf.write(); } @@ -2582,16 +2582,16 @@ bool TBook::print_or_preview() return ok; } -TBook::TBook(const char* name) - : _out(NULL), _is_temporary(false), _max_frame(0,0), - _pages(0), _page(0), _rcd(NULL), _printwin(NULL), _page_is_open(false) +TBook::TBook(const char* title, const char * pref) + : _out(nullptr), _title(title), _is_temporary(false), _max_frame(0,0), + _pages(0), _page(0), _rcd(nullptr), _printwin(nullptr), _page_is_open(false) { - _file = name; - if (_file.blank()) - { - _file.temp("rep", "rap"); - _is_temporary = true; - } + TString prefix(pref); + + if (prefix.blank()) + prefix = "rep"; + _file.temp(prefix, "rap"); + _is_temporary = true; ofstream out(_file); } @@ -3073,11 +3073,14 @@ bool TReport_book::add(TReport& rep, export_type type, bool progind) return false; TRecordset* rex = _report->recordset(); + if (rex == nullptr) return true; rex->requery(); + const TRecnotype rex_items = rex->items(); + if (rex_items <= 0) return true; @@ -3336,6 +3339,6 @@ bool TReport_book::on_link(const TReport_link& lnk) return ok; } -TReport_book::TReport_book(const char* name) - : TBook(name), _report(NULL) +TReport_book::TReport_book(const char* title, const char * pref) + : TBook(title, pref), _report(nullptr) { } diff --git a/src/include/reprint.h b/src/include/reprint.h index 50987cbca..689de9fde 100755 --- a/src/include/reprint.h +++ b/src/include/reprint.h @@ -11,6 +11,7 @@ class TBook : public TObject { size_t _page, _pages; + TString _title; TFilename _file, _pdf_file; // Nomi dei file di output ofstream* _out; // File di output @@ -58,7 +59,8 @@ public: virtual bool close_page(); virtual bool main_loop(); - virtual const TFilename & file() const { return _file;} + virtual const TString & title() const { return _title; } + virtual const TFilename & file() const { return _file; } virtual void set_pen(COLOR color, int width = 0, PEN_STYLE style = P_SOLID); virtual void set_brush(COLOR color, PAT_STYLE pattern = PAT_SOLID, int shade_angle = 0); virtual void set_font(const TReport_font& font); @@ -106,7 +108,7 @@ public: virtual bool esporta(); bool print_or_preview(); // Calls one of the above - TBook(const char* name); + TBook(const char* title = "", const char * pref = ""); virtual ~TBook(); }; @@ -144,7 +146,7 @@ public: virtual int logical_page_height() const { return _logical_page_height; } virtual bool print(size_t pagefrom = 0, size_t pageto = 0, word copies = 0); virtual bool archive(const char* repname, bool signature); - TReport_book(const char* name = NULL); + TReport_book(const char* title = "", const char * pref = ""); }; bool advanced_set_draw_tools(TWindow& win, PAT_STYLE pat, int border, COLOR fore, COLOR back); diff --git a/src/include/strings.h b/src/include/strings.h index 9444f162e..c991813a4 100755 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -220,9 +220,11 @@ public: // @cmember Permette di trovare il plurale di una stringa TString& add_plural(long num, const char * name); - // @cmember Assegna la stringa passata con indirizzo - const TString& operator =(const TString& s) - { return set(s._str); } + // @cmember Azzera la stringa + const TString& reset() { return cut(0); } + // @cmember Assegna la stringa passata con indirizzo + const TString& operator =(const TString& s) + { return set(s._str); } // @cmember Assegna la stringa passata const TString& operator =(const char* s) { return set(s); } @@ -684,8 +686,6 @@ public: void destroy(int pos); // @cmember Toglie la stringa di posizione pos e la ritorna const char* remove(int pos); - // @cmember Azzera la stringa - void reset() { cut(0); } // @cmember Ritorna il prossimo token const char* get();