From 8824e41c1c1f9d8fceeb606f51c66a8ac411777c Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Fri, 26 Jun 2020 22:44:30 +0200 Subject: [PATCH] 2Patch level : 12.0 972 Files correlati : cg1.exe cg1500a.msk cg1600a.msk Commento : Stampa bilanco e bilancio IV direttiva per data competenza costi/ricavi --- src/ca/calib01.cpp | 117 +++++++++++++++++++++++++-------------------- src/ca/calib01.h | 4 +- src/ca/calib02.cpp | 32 +++++++------ src/ca/calib02.h | 4 +- 4 files changed, 88 insertions(+), 69 deletions(-) diff --git a/src/ca/calib01.cpp b/src/ca/calib01.cpp index 9788549cd..da1d2b990 100755 --- a/src/ca/calib01.cpp +++ b/src/ca/calib01.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -14,7 +15,7 @@ #include "calib01.h" #include "calib02.h" #include "calibmsk.h" -#include "../cg/cg2103.h" +#include "../cg/cglib.h" #include "cdc.h" #include "commesse.h" @@ -35,7 +36,7 @@ class TConfig_anal : public TConfig int _level; public: - virtual const TString& get(const char* var, const char* section = NULL, int index = -1, const char* def = ""); + virtual const TString& get(const char* var, const char* section = nullptr, int index = -1, const char* def = ""); TConfig_anal(); }; @@ -46,7 +47,7 @@ TConfig_anal::TConfig_anal() : TConfig(CONFIG_DITTA, "ca"), _level(0) if (a.active(CIAUT)) _level |= 2; // Controllo se è veramente configurato il primo livello a CMS o CDC - if (_level > 1 && TConfig::get("Level", NULL, 1).blank()) + if (_level > 1 && TConfig::get("Level", nullptr, 1).blank()) _level = 0; } @@ -88,11 +89,10 @@ const TString& TConfig_anal::get(const char* varname, const char* section, int i TConfig& ca_config(bool force_reload) { - static TConfig_anal* cfg = NULL; - if (cfg == NULL || force_reload) + static TConfig_anal* cfg = nullptr; + if (cfg == nullptr || force_reload) { - if (cfg != NULL) - delete cfg; + SAFE_DELETE(cfg); cfg = new TConfig_anal; } return *cfg; @@ -275,12 +275,12 @@ TMultilevel_code_info::TMultilevel_code_info(int logicnum) : _logicnum(logicnum) int from = 1, to = 1; for (int level = 1; ; level++) { - const TString& prompt = cfg.get(desvar, NULL, level); + const TString& prompt = cfg.get(desvar, nullptr, level); if (prompt.blank()) break; _prompt.add(prompt); - const TString& picture = cfg.get(keyvar, NULL, level); + const TString& picture = cfg.get(keyvar, nullptr, level); _picture.add(picture); const int keylen = picture.len(); @@ -297,11 +297,14 @@ TMultilevel_code_info::TMultilevel_code_info(int logicnum) : _logicnum(logicnum) const TMultilevel_code_info& ca_multilevel_code_info(int logicnum) { - static TArray* cache = NULL; - if (cache == NULL) + static TArray* cache = nullptr; + + if (cache == nullptr) cache = new TArray; + TMultilevel_code_info* info = (TMultilevel_code_info*)cache->objptr(logicnum); - if (info == NULL) + + if (info == nullptr) { info = new TMultilevel_code_info(logicnum); cache->add(info, logicnum); @@ -321,7 +324,8 @@ const TMultilevel_code_info* ca_multilevel_code_info_by_index(int level) if (_logicnum[0] < 0) { TConfig& cfg = ca_config(); - const TString& lev1 = cfg.get("Level", NULL, 1); + const TString& lev1 = cfg.get("Level", nullptr, 1); + if (lev1.full()) { const TMultilevel_code_info& fasi = ca_multilevel_code_info(LF_FASI); @@ -330,7 +334,7 @@ const TMultilevel_code_info* ca_multilevel_code_info_by_index(int level) if (fasi.parent() == _logicnum[k]) _logicnum[++k] = LF_FASI; - const TString& lev2 = cfg.get("Level", NULL, 2); + const TString& lev2 = cfg.get("Level", nullptr, 2); if (lev2.full()) { _logicnum[++k] = _logicnum[0] == LF_COMMESSE ? LF_CDC : LF_COMMESSE; @@ -344,7 +348,7 @@ const TMultilevel_code_info* ca_multilevel_code_info_by_index(int level) logic = _logicnum[level]; } - return logic > 0 ? &ca_multilevel_code_info(logic) : NULL; + return logic > 0 ? &ca_multilevel_code_info(logic) : nullptr; } bool ca_test_multilevel_field(TEdit_field& fld, int level) @@ -420,7 +424,7 @@ const char* ca_dollar2fieldname(int logic, const char* dollar) default : return FASI_CODFASE; } } - return NULL; + return nullptr; } void ca_append_and(TString& query, const TString& clause) @@ -452,7 +456,8 @@ static const TString& ca_get_user_permissions(const TString& utente, const int l if (ini_permessi.set_paragraph(utente)) { - const char* fieldname = NULL; + const char* fieldname = nullptr; + switch (logic) { case LF_COMMESSE: fieldname = "Cms"; break; @@ -460,7 +465,7 @@ static const TString& ca_get_user_permissions(const TString& utente, const int l case LF_FASI: fieldname = "Fas"; break; default: break; } - if (fieldname != NULL) + if (fieldname != nullptr) { const TString& expr = ini_permessi.get(fieldname); ca_append_and(select, expr); @@ -473,7 +478,7 @@ static const TString& ca_get_user_permissions(const TString& utente, const int l TToken_string row(80, SAFE_PIPE_CHR); for (int r = 0;; r++) { - row = ini_permessi.get("Prog", NULL, r); + row = ini_permessi.get("Prog", nullptr, r); if (row.blank()) break; if (key == row.get(0)) @@ -524,7 +529,8 @@ const TString& ca_create_user_select_clause(int logic) { static TArray clauses; TString* clause = (TString*)clauses.objptr(logic); - if (clause == NULL) + + if (clause == nullptr) { clause = new TString; switch (logic) @@ -579,7 +585,7 @@ bool ca_filter_record(const TRectype& rec) bool ca_filter_function(const TRelation* rel) { - return rel != NULL && ca_filter_record(rel->curr()); + return rel != nullptr && ca_filter_record(rel->curr()); } @@ -837,13 +843,14 @@ int ca_create_fields(TMask& msk, int page, int logicnum, int x, int y, prompt.left_just(maxdeslen); const char* flags = picture[0] == '0' || picture[0] == '9' ? "BUZ" : "BU"; - TEdit_field* kfld = NULL; + TEdit_field* kfld = nullptr; + if (mci.is_numeric_picture(i)) // Numeric kfld = &msk.add_number(kid, page, prompt, tab0, y+i, picture.len(), flags); else kfld = &msk.add_string(kid, page, prompt, tab0, y+i, picture.len(), flags); ca_create_browse1(*kfld, i, logicnum, key_id, desc_in_sh && (i == mci.levels() - 1) ? key_id + mci.levels() - i : des_id); - if ((mode & 0x1) != 0 && fieldname == NULL) + if ((mode & 0x1) != 0 && fieldname == nullptr) kfld->set_key(1); // Ho specificato un nome di campo speciale @@ -872,7 +879,7 @@ int ca_create_fields(TMask& msk, int page, int logicnum, int x, int y, const short did = desc_in_sh && (i == mci.levels() - 1) ? key_id+mci.levels() : des_id+i; TEdit_field& dfld = msk.add_string(did, page, "", tab1, y+i, 50, "B", 72+tab0-tab1); ca_create_browse2(dfld, i, logicnum, key_id); - if ((mode & 0x2) != 0 && fieldname == NULL) + if ((mode & 0x2) != 0 && fieldname == nullptr) dfld.set_key(2); else dfld.set_field(""); @@ -964,14 +971,14 @@ int ca_create_fields_compact(TMask& msk, int page, int logicnum, int x, int y, const char* flags = picture[0] == '0' || picture[0] == '9' ? "BUZG" : "BUG"; - TEdit_field* kfld = NULL; + TEdit_field* kfld = nullptr; if (mci.is_numeric_picture(i)) // Numeric kfld = &msk.add_number(kid, page, prompt, tab0 + offset, y + row_offset, picture.len(), flags); else kfld = &msk.add_string(kid, page, prompt, tab0 + offset, y + row_offset, picture.len(), flags); ca_create_browse1(*kfld, i, logicnum, key_id, des_id); - if ((mode & 0x1) != 0 && fieldname == NULL) + if ((mode & 0x1) != 0 && fieldname == nullptr) kfld->set_key(1); // Ho specificato un nome di campo speciale @@ -995,7 +1002,7 @@ int ca_create_fields_compact(TMask& msk, int page, int logicnum, int x, int y, } // Copio il checktype nel campo fantasma per colorare correttamente la colonna - if (msk.get_sheet() != NULL && kfld->required()) + if (msk.get_sheet() != nullptr && kfld->required()) msk.efield(kid-100).check_type(kfld->check_type()); } @@ -1010,7 +1017,7 @@ int ca_create_fields_compact(TMask& msk, int page, int logicnum, int x, int y, TEdit_field& dfld = (i < mci.levels() - 1) && (i != par_items -1) ? msk.add_string(did, page, "", 50, 50, 50, "B") : msk.add_string(did, page, "", tab1, y + row_offset, 50, "B", 72+tab0-tab1); ca_create_browse2(dfld, i, logicnum, key_id); - if ((mode & 0x2) != 0 && fieldname == NULL) + if ((mode & 0x2) != 0 && fieldname == nullptr) dfld.set_key(2); else dfld.set_field(""); @@ -1034,7 +1041,7 @@ int ca_create_fields_ext(TMask& m, int page, int x, int y, short first_id, for (int i = 0; i < 2; i++) { - const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2 + const TString& level = ini.get("Level", nullptr, i+1); // Legge il livello 1 o 2 if (level == "CDC" && cdc_fld && *cdc_fld) // Crea centro di costo { @@ -1117,7 +1124,7 @@ int ca_create_fields_ext(TMask& m, int page, int x, int y, short first_id, numero_campi += nfields; } - if (m.get_sheet() != NULL) //Se è una maschera di riga, sistemo le colonne delle sheet + if (m.get_sheet() != nullptr) //Se è una maschera di riga, sistemo le colonne delle sheet { TSheet_field& s = *m.get_sheet(); for (short id = first_id + 116; id >= first_id + 100; id--) @@ -1472,8 +1479,9 @@ bool TSimple_anal_msk::on_field_event(TOperable_field& o, TField_event e, long j const TTree_field& fld = (const TTree_field&)o; const TTree& tree = *fld.tree(); TToken_string curr; tree.curr_id(curr); - TEdit_field* last = NULL; - for (int i = 0; ; i++) + TEdit_field* last = nullptr; + + for (int i = 0; ; i++) { const short id = get_field_id(i); if (id <= 0) @@ -1488,7 +1496,7 @@ bool TSimple_anal_msk::on_field_event(TOperable_field& o, TField_event e, long j if (tok && *tok) last = &e; } - if (last != NULL) + if (last != nullptr) { if (last->check()) stop_run(K_AUTO_ENTER); @@ -1658,7 +1666,8 @@ const TToken_string& TSimple_anal_msk::get_key_value(const TRectype& rec, int c) const TToken_string& TSimple_anal_msk::get_key_value(int c) const { TToken_string& val = get_tmp_string(); - for (TEditable_field* f = get_key_field(c, true); f != NULL; f = get_key_field(c, false)) + + for (TEditable_field* f = get_key_field(c, true); f != nullptr; f = get_key_field(c, false)) { val.add(f->get()); } @@ -1780,8 +1789,9 @@ void TAnal_tree::node2id(const TObject* node, TString& id) const bool TAnal_tree::goto_root() { bool ok = false; + //gestione speciale per le fasi con babbo - if (_father_curs != NULL) + if (_father_curs != nullptr) { if (_father_curs->items() > 0) { @@ -2013,7 +2023,7 @@ TImage* TAnal_tree::image(bool selected) const return get_res_image(bmp_id); } -TAnal_tree::TAnal_tree(int logicnum) : _curs(NULL), _father_curs(NULL), _is_father(false) +TAnal_tree::TAnal_tree(int logicnum) : _curs(nullptr), _father_curs(nullptr), _is_father(false) { TString select; _curs = new TCursor(new TRelation(logicnum), ca_create_user_select_clause(logicnum)); @@ -2170,10 +2180,8 @@ bool TAnal_app::remove() bool TAnal_app::user_destroy() { - if (_msk != NULL) - delete _msk; - if (_rel != NULL) - delete _rel; + SAFE_DELETE(_msk); + SAFE_DELETE(_rel); return true; } @@ -2219,7 +2227,7 @@ const char * TAnal_mov::row_code(int row) const for (int i = 0; i < 2; i++) { - const TString& level = cfg.get("Level", NULL, i+1); // Legge il livello 1 o 2 + const TString& level = cfg.get("Level", nullptr, i+1); // Legge il livello 1 o 2 if (level == "CDC") // Crea centro di costo { @@ -2344,7 +2352,7 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) TImporto curr_imp(imp_row.sezione(), texaco.get()); key.add(es, 1); //sistema l'anno di esercizio nella chiave TImporto* imp = (TImporto*)_saldi.objptr(key); - if (imp == NULL) + if (imp == nullptr) { imp = new TImporto; _saldi.add(key, imp); @@ -2356,7 +2364,8 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) if (ca_ori_present(row)) { TImporto* impind = (TImporto*)_saldind.objptr(key); - if (impind == NULL) + + if (impind == nullptr) { impind = new TImporto; _saldind.add(key, impind); @@ -2371,7 +2380,8 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) else //saldo in un solo anno (caso standard) { TImporto* imp = (TImporto*)_saldi.objptr(key); - if (imp == NULL) + + if (imp == nullptr) { imp = new TImporto; _saldi.add(key, imp); @@ -2383,7 +2393,8 @@ void TAnal_mov::saldo_set_reset(const TRectype& row, bool reset) if (ca_ori_present(row)) { TImporto* impind = (TImporto*)_saldind.objptr(key); - if (impind == NULL) + + if (impind == nullptr) { impind = new TImporto; _saldind.add(key, impind); @@ -2483,8 +2494,9 @@ bool TAnal_mov::save_saldi(const int annoes) if (err == NOERR) { - const char* fld_sez = NULL; - const char* fld_val = NULL; + const char* fld_sez = nullptr; + const char* fld_val = nullptr; + switch (tipo) { case 'P': fld_sez = SALDANA_SEZIONEP; fld_val = SALDANA_SALDOP; break; @@ -2500,7 +2512,7 @@ bool TAnal_mov::save_saldi(const int annoes) const TImporto * ind = (const TImporto*) _saldind.objptr(key); - if (ind != NULL) + if (ind != nullptr) { const TImporto& impind = *(const TImporto*)ind; switch (tipo) @@ -2671,7 +2683,8 @@ int TAnal_mov::save_rmov_comp() const { const TRectype* rmov_old = (TRectype*)itm; const TRectype* rmov_new = (TRectype*)new_rows.objptr(key); - if (rmov_new == NULL) + + if (rmov_new == nullptr) rmov_old->remove(file); } } @@ -3296,10 +3309,12 @@ bool ca_extract_sheet_field(const TSheet_field& sheet, const int row, const int FOR_EACH_MASK_FIELD(mask_sheet, i, f) //giro sui campi della maschera di riga { const TFieldref* fr = f->field(); //campo corrente della maschera - if (fr != NULL && f->is_edit()) //deve essere un campo di tipo edit + + if (fr != nullptr && f->is_edit()) //deve essere un campo di tipo edit { TEdit_field& e = *(TEdit_field*)f; //visto che è di tipo edit può creare l'edit_field per farne la browse - if (e.browse() != NULL) + + if (e.browse() != nullptr) { const TCursor& cur = *e.browse()->cursor(); const int ln = cur.file().num(); //Allah! dal campo ricava il cursore sul file di numero ln diff --git a/src/ca/calib01.h b/src/ca/calib01.h index 00d54accd..5a152cbdb 100755 --- a/src/ca/calib01.h +++ b/src/ca/calib01.h @@ -13,8 +13,8 @@ #include #endif -#ifndef __CGLIB03_H -class TBill; +#ifndef __CGLIB_H +#include "../cg/cglib.h" #endif class TRecordset ; diff --git a/src/ca/calib02.cpp b/src/ca/calib02.cpp index 4e7c1fe87..c016c1933 100755 --- a/src/ca/calib02.cpp +++ b/src/ca/calib02.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "movana.h" #include "pconana.h" @@ -263,7 +264,7 @@ bool TPconana_recordset::valid_record(const TRelation& rel) const return true; } -static const TPconana_recordset* _current_recset = NULL; +static const TPconana_recordset* _current_recset = nullptr; bool TPconana_recordset::pianoconti_filter(const TRelation* rel) { return _current_recset->valid_record(*rel); } @@ -365,12 +366,13 @@ size_t TAnal_report::get_usr_words(TString_array& words) const "CA_FORMAT_CONTO", "CA_FORMAT_CMSCDC", "CA_FORMAT_CONTO_DESCR", - NULL + nullptr }; ((TAnal_report*)this)->_first_msg = words.items(); // Calcola il primo numero disponibile size_t i; - for (i = 0; name[i] != NULL; i++) + + for (i = 0; name[i] != nullptr; i++) words.add(name[i]); return words.items(); @@ -1125,13 +1127,11 @@ TSaldi_cache::TSaldi_cache() : TCache(3881) // Numero primo const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& al, word tipi) { - static TSaldi_cache* cache = NULL; - if (tipi == 0 && cache != NULL) - { - delete cache; - cache = NULL; - } - if (cache == NULL) + static TSaldi_cache* cache = nullptr; + + if (tipi == 0) + SAFE_DELETE(cache); + if (cache == nullptr) cache = new TSaldi_cache; return cache->saldo(bill, dal, al, tipi); } @@ -1168,7 +1168,8 @@ int TAnal_report_mask::create_sheet_fields(short sheet_id, int lf, int& y, short } } - const char* fieldname = NULL; + const char* fieldname = nullptr; + switch(logic) { case LF_CDC : fieldname = RMOVANA_CODCCOSTO; break; @@ -1207,7 +1208,8 @@ void TAnal_report_mask::create_sheet(short sheet_id) for (int i = 0; i < 2; i++) { - const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2 + const TString& level = ini.get("Level", nullptr, i+1); // Legge il livello 1 o 2 + if (level == "CDC") // Crea centro di costo { if (fasinfo.parent() == LF_CDC) @@ -1255,7 +1257,8 @@ int TAnal_report_mask::get_row_bill(TSheet_field& sf, int r, TAnal_bill& bill) for (int level = 0; level <= 2; level++) { const TMultilevel_code_info* info = ca_multilevel_code_info_by_index(level); - if (info == NULL) + + if (info == nullptr) break; TString20 code; for (int i = 0; i < info->levels(); i++) @@ -1280,7 +1283,8 @@ int TAnal_report_mask::set_row_bill(TSheet_field& sf, int r, const TAnal_bill& b for (int level = 0; level <= 2; level++) { const TMultilevel_code_info* info = ca_multilevel_code_info_by_index(level); - if (info == NULL) + + if (info == nullptr) break; TToken_string code; switch (info->logic()) diff --git a/src/ca/calib02.h b/src/ca/calib02.h index d8e90d47c..1e535312c 100755 --- a/src/ca/calib02.h +++ b/src/ca/calib02.h @@ -9,8 +9,8 @@ #include #endif -#ifndef __CGLIB01_H -#include "../cg/cglib01.h" +#ifndef __CGLIB_H +#include "../cg/cglib.h" #endif ///////////////////////////////////////////////////////////