Correzioni su TDistrib in modo da gestire al meglio casi limite con totali nulli
git-svn-id: svn://10.65.10.50/branches/R_10_00@22922 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
de92695865
commit
b8d35eb40b
@ -57,9 +57,7 @@ public:
|
||||
// @cmember Ritorna il numero di oggetti nel contenitore
|
||||
virtual long objects( ) const pure;
|
||||
// @cmember Ritorna true se il contenitore e' vuoto
|
||||
virtual bool empty() const
|
||||
|
||||
{ return objects( ) == 0; }
|
||||
virtual bool empty() const { return objects( ) == 0; }
|
||||
|
||||
// @cmember Cerca il successivo elemento che soddisfa la <t OPERATION_FUNCTION>
|
||||
virtual void for_each( OPERATION_FUNCTION );
|
||||
|
@ -17,11 +17,8 @@
|
||||
#define XVT_INCL_NATIVE
|
||||
#include <xvt.h>
|
||||
#define S4OFF_REPORT
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN32
|
||||
#define S4DLL
|
||||
#define S4WIN32
|
||||
#endif
|
||||
//#define S4DLL
|
||||
//#define S4WIN32
|
||||
|
||||
#include <d4all.h>
|
||||
#include <codeb.h>
|
||||
|
@ -1874,14 +1874,13 @@ void TPushbutton_control::update()
|
||||
{
|
||||
XinWindow win = xi_get_window(_obj);
|
||||
XI_RCT rct; xi_get_rect(_obj, &rct); // = _obj->v.btn->rct;
|
||||
xi_inflate_rect(&rct, -3);
|
||||
xi_set_clip(win, &rct);
|
||||
|
||||
/*if (CAMPI_SCAVATI)
|
||||
xi_draw_shaded_rect(win, &rct, _obj->v.btn->down, 2, BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
|
||||
else*/
|
||||
xi_draw_3d_rect(win, &rct, _obj->v.btn->down, 2, BTN_LIGHT_COLOR, BTN_BACK_COLOR, BTN_DARK_COLOR);
|
||||
|
||||
xi_inflate_rect(&rct, -3);
|
||||
xi_set_clip(win, &rct);
|
||||
|
||||
const int bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
|
||||
if (bmp > 0)
|
||||
{
|
||||
@ -1891,6 +1890,7 @@ void TPushbutton_control::update()
|
||||
xvt_rect_offset(&dst, 2, 2);
|
||||
i.draw((WINDOW)win, dst);
|
||||
}
|
||||
|
||||
xi_set_clip(win, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -945,6 +945,8 @@ bool TForm_subsection::print_body(sec_print_mode showfields)
|
||||
bool again=TRUE;
|
||||
while (again && group_expr==_section->eval_expr(*_condexpr,_file_id).as_string())
|
||||
{
|
||||
if (printer().frozen())
|
||||
break;
|
||||
form().match_result(_file_id);
|
||||
if (!_bigskip || i==0)
|
||||
{
|
||||
@ -3702,9 +3704,8 @@ bool TForm::print(
|
||||
if ((_char_to_pos != '\0' || ((_ipx +_ipy+_fpx) != 0)) && // Se i parametri di posizionamento sono settati e
|
||||
(_x != 0 || _y != 0)) // cosi' pure gli offset genera un errore.
|
||||
{
|
||||
error_box(TR("Non e' possibile settare contemporaneamente gli offset"
|
||||
return error_box(TR("Non e' possibile settare contemporaneamente gli offset"
|
||||
" e i parametri di posizionamento del modulo."));
|
||||
return FALSE;
|
||||
}
|
||||
TPrinter& pr = printer();
|
||||
if (_frompage) pr.set_from_page(_frompage);
|
||||
|
@ -3410,28 +3410,37 @@ int TRectype::compare_key(
|
||||
return res;
|
||||
}
|
||||
|
||||
HIDDEN bool fld_empty(const char* s, int len, bool number)
|
||||
HIDDEN bool fld_empty(const char* s, int len, bool /* number */)
|
||||
{
|
||||
if (s && *s)
|
||||
if (s && *s && len > 0)
|
||||
{
|
||||
for (; len; s++, len--)
|
||||
if (*s != ' ') return false;
|
||||
for (; len; s++, len--) if (*s != ' ')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int fld_cmp(const char* a, const char* b, int len, bool number)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len && *a == *b; b++, a++, i++);
|
||||
if (i == len) return 0;
|
||||
int res = *a - *b;
|
||||
int res = memcmp(a, b, len);
|
||||
if (res == 0)
|
||||
return res;
|
||||
|
||||
int i = 0;
|
||||
if (number) // Aggiunta del 11-02-2014: ignoro spazi e zeri iniziali dei numeri
|
||||
for (; i < len && (*a==' ' || *a=='0') && (*b==' ' || *b=='0'); b++, a++, i++);
|
||||
|
||||
for (; i < len && *a == *b; b++, a++, i++);
|
||||
if (i == len)
|
||||
return 0;
|
||||
|
||||
res = *a - *b;
|
||||
if (number)
|
||||
{
|
||||
b -= i;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
return fld_empty(b, len - i, number) ? 0 : res;
|
||||
}
|
||||
|
||||
@ -3615,7 +3624,7 @@ word TRectype::get_word(const char* fieldname) const
|
||||
|
||||
real TRectype::get_real(const char* fieldname) const
|
||||
{
|
||||
real r(get_str(fieldname));
|
||||
const real r(get_str(fieldname));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1200,8 @@ bool TPrint_application::print_one (
|
||||
TPrinter& prn = printer();
|
||||
|
||||
if ((_prind && _prind->iscancelled()) || prn.frozen())
|
||||
if (_cancelled = cancel_hook()) return FALSE;
|
||||
if (_cancelled = cancel_hook())
|
||||
return false;
|
||||
|
||||
if (!_print_defined)
|
||||
return TRUE;
|
||||
|
@ -6,7 +6,10 @@
|
||||
#include <progind.h>
|
||||
#include <controls.h>
|
||||
#include <reprint.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TIndwin
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TIndwin::_indwin_count = 0;
|
||||
|
||||
@ -261,7 +264,9 @@ bool TIndwin::stop_run(KEY k)
|
||||
}
|
||||
|
||||
|
||||
// TProgind --------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////
|
||||
// TProgind
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
: TIndwin(max, txt, cancel, bar, div), _next_update(0)
|
||||
@ -315,9 +320,44 @@ TTimerind::~TTimerind()
|
||||
xvt_timer_destroy(_timer_id);
|
||||
}
|
||||
|
||||
// C-style binding
|
||||
// uses static pointer for single instance of TIndwin
|
||||
///////////////////////////////////////////////////////////
|
||||
// TProgress_monitor
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TProgress_monitor::set_status(long n)
|
||||
{
|
||||
// Aggiunsto timer iniziale se necessario
|
||||
if (_status <= 0 && n <= 0)
|
||||
_start = clock();
|
||||
|
||||
// Se sono passati 1 secondi e sono a meno di metà lavoro allora crea la TProgind
|
||||
if (_pi == NULL && n < _total/2 && (clock() - _start) >= CLOCKS_PER_SEC)
|
||||
{
|
||||
_pi = new TProgind(_total, _txt, _cancellable);
|
||||
_pi->set_start_time(_start);
|
||||
}
|
||||
// Aggiorna la TProgind associata, sempre che esista
|
||||
_status = min(n, _total);
|
||||
return _pi == NULL || _pi->setstatus(_status);
|
||||
}
|
||||
|
||||
TProgress_monitor::TProgress_monitor(long items, const char* txt, bool cancancel)
|
||||
: _total(items), _txt(txt), _status(0), _cancellable(cancancel), _pi(NULL), _start(clock())
|
||||
{
|
||||
}
|
||||
|
||||
TProgress_monitor::~TProgress_monitor()
|
||||
{
|
||||
// Distruggi la TProgind o la clessidra, a seconda del caso
|
||||
if (_pi != NULL)
|
||||
delete _pi;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// C-style bindings
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// uses static pointer for single instance of TIndwin
|
||||
static TIndwin* __indwin__p = NULL;
|
||||
|
||||
void progind_create(long m, const char* t, bool b, bool c, int n)
|
||||
|
@ -35,7 +35,7 @@ class TIndwin : public TWindow
|
||||
// @cmember:(INTERNAL) Movimento della barra e percentuale
|
||||
WINDOW _gauge;
|
||||
// @cmember:(INTERNAL) ora inizio elaborazione
|
||||
unsigned long _start_time;
|
||||
clock_t _start_time;
|
||||
|
||||
// @cmember:(INTERNAL) Flag che indica quali operazioni sono state effettuate
|
||||
byte _flags;
|
||||
@ -96,6 +96,9 @@ public:
|
||||
|
||||
virtual bool setstatus(long l);
|
||||
|
||||
// @cmember Forza il timer d'inizio (serve solo a TProgress_monitor)
|
||||
void set_start_time(unsigned long st) { _start_time = st; }
|
||||
|
||||
// @cmember Costruttore
|
||||
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 60);
|
||||
// @cmember Distruttore
|
||||
@ -155,6 +158,32 @@ public:
|
||||
virtual ~TTimerind();
|
||||
};
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @class TProgress_monitor | Classe per gestire intelligentemente clessidra o barra di attesa
|
||||
//
|
||||
// @base public | TObject
|
||||
class TProgress_monitor : public TObject
|
||||
{
|
||||
long _total, _status;
|
||||
TString _txt;
|
||||
bool _cancellable;
|
||||
TProgind* _pi;
|
||||
clock_t _start;
|
||||
|
||||
public:
|
||||
virtual bool set_status(long n);
|
||||
bool add_status(long i = 1) { return set_status(_status+i); }
|
||||
|
||||
// deprecated TProgind compatibility methods
|
||||
bool setstatus(long n) { return set_status(n); }
|
||||
bool addstatus(long n) { return add_status(n); }
|
||||
|
||||
TProgress_monitor(long items, const char* txt, bool cancellable = true);
|
||||
~TProgress_monitor();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1696,15 +1696,20 @@ real TGeneric_distrib::get ()
|
||||
{
|
||||
_ready = true;
|
||||
CHECK (_current < _slices.items(), "TGeneric_distrib: too many gets");
|
||||
real & currslice = (real &) _slices[_current++];
|
||||
const real & currslice = (real &) _slices[_current++];
|
||||
real r = currslice;
|
||||
if (_tot != _totslices)
|
||||
{
|
||||
if (_tot < 1E9 && currslice < 1E9)
|
||||
r = (_tot * currslice) / _totslices;
|
||||
if (currslice != _totslices) // Caso normale
|
||||
{
|
||||
if (abs(_tot) < 1E9 && abs(currslice) < 1E9)
|
||||
r = _tot * currslice / _totslices;
|
||||
else
|
||||
r *= (_tot / _totslices);
|
||||
}
|
||||
else
|
||||
r = _tot; // Caso limite che risolve (_totslices==0) && (_tot != 0)
|
||||
}
|
||||
r.round (_decs);
|
||||
_tot -= r;
|
||||
_totslices -= currslice;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <dongle.h>
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <relation.h>
|
||||
#include <utility.h>
|
||||
@ -384,20 +385,18 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
|
||||
mode = 0x1;
|
||||
}
|
||||
|
||||
TLocalisamfile* pisam = NULL;
|
||||
TBaseisamfile* pisam = NULL;
|
||||
if (logicnum >= LF_USER)
|
||||
{
|
||||
if (*dirname)
|
||||
pisam = new TIsamtempfile(logicnum, table);
|
||||
else
|
||||
pisam = new TLocalisamfile(logicnum);
|
||||
pisam = new TFast_isamfile(logicnum);
|
||||
}
|
||||
if (pisam == NULL)
|
||||
return error_box("Impossibile creare il file %s", table);
|
||||
|
||||
TLocalisamfile& isam = *pisam;
|
||||
|
||||
TProgind pi(items(), TR("Esportazione in corso..."));
|
||||
TBaseisamfile& isam = *pisam;
|
||||
TRectype& rec = isam.curr();
|
||||
|
||||
TString_array names;
|
||||
@ -415,10 +414,12 @@ bool TRecordset::save_as_dbf(const char* table, int mode)
|
||||
names.add(EMPTY_STRING);
|
||||
}
|
||||
|
||||
TProgress_monitor pi(items(), TR("Esportazione in corso..."), true);
|
||||
bool ok = true;
|
||||
for (bool go = move_first(); go; go = move_next())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
rec.zero();
|
||||
FOR_EACH_ARRAY_ROW(names, j, name) if (name->not_empty())
|
||||
rec.put(*name, get(j).as_string());
|
||||
@ -985,7 +986,7 @@ const TString& TCursor_parser::line()
|
||||
{
|
||||
if (_pushed.not_empty())
|
||||
return pop();
|
||||
char* buff = _token.get_buffer(256);
|
||||
char* buff = _token.get_buffer(512);
|
||||
_instr.getline(buff, _token.size());
|
||||
return _token;
|
||||
}
|
||||
|
@ -837,7 +837,7 @@ int TRelation_application::delete_mode()
|
||||
keep_running = FALSE;
|
||||
if (tasto == K_DEL && sht.checked() == 0)
|
||||
{
|
||||
error_box(TR("Non e' stato selezionato nessun elemento"));
|
||||
error_box(TR("Non è stato selezionato nessun elemento"));
|
||||
sht.select(0);
|
||||
keep_running = TRUE;
|
||||
}
|
||||
@ -1216,6 +1216,9 @@ int TRelation_application::rewrite(const TMask& m)
|
||||
return err;
|
||||
}
|
||||
|
||||
const char* TRelation_application::record_description(const TRelation& r) const
|
||||
{ return r.file().description(); }
|
||||
|
||||
// @doc INTERNAL
|
||||
|
||||
// @mfunc Cancella il record corrente
|
||||
@ -1230,10 +1233,10 @@ bool TRelation_application::relation_remove()
|
||||
TRelation& r = *get_relation();
|
||||
r.restore_status();
|
||||
if (protected_record(r))
|
||||
return warning_box(TR("Elemento non eliminabile"));
|
||||
return warning_box(FR("%s non eliminabile"), record_description(r));
|
||||
|
||||
if (_curr_transaction == TRANSACTION_DELETE ||
|
||||
delete_box(FR("Confermare l'eliminazione del record %s"), r.file().description()))
|
||||
delete_box(FR("Confermare eliminazione %s"), record_description(r)))
|
||||
{
|
||||
r.restore_status();
|
||||
const bool ok = remove();
|
||||
|
@ -241,6 +241,8 @@ protected:
|
||||
virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
|
||||
virtual void ini2mask(TConfig& ini, TMask& m, bool query);
|
||||
virtual bool mask2mail(const TMask& m);
|
||||
// @cmember Breve descrizione del tipo documento corrente
|
||||
virtual const char* record_description(const TRelation& r) const;
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
|
@ -2776,10 +2776,10 @@ void TReport::report2mask(TMask & m) const
|
||||
}
|
||||
}
|
||||
|
||||
TVariant & string2var(TVariant & v, const TFieldref * r, const TString & val)
|
||||
TVariant& string2var(TVariant& v, const TFieldref& r, const TString& val)
|
||||
{
|
||||
const int from = r->from();
|
||||
int to = r->to();
|
||||
const int from = r.from();
|
||||
int to = r.to();
|
||||
|
||||
if (from > 0 || to > 0)
|
||||
{
|
||||
@ -2838,7 +2838,7 @@ void TReport::mask2report(const TMask & m)
|
||||
get_usr_val(name, var);
|
||||
if (val.empty())
|
||||
val = is_final ? MAX_STRING : "";
|
||||
string2var(var, ref, val);
|
||||
string2var(var, *ref, val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -612,7 +612,6 @@ public:
|
||||
virtual bool set_recordset(const TString& sql);
|
||||
virtual bool set_recordset(TRecordset* sql);
|
||||
virtual TRecordset* recordset() const { return _recordset; }
|
||||
bool evaluate_atom(const char* atom, TVariant& var);
|
||||
bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type);
|
||||
|
||||
const TString& prescript() const;
|
||||
|
@ -2737,20 +2737,34 @@ void TReport_book::add_doc(const TString& name)
|
||||
TReport* eminem = new TReport;
|
||||
if (eminem->load(name))
|
||||
{
|
||||
TReport* rep = _report; // Salvo variabile globale
|
||||
|
||||
if (rep->use_mask())
|
||||
{
|
||||
TFilename msk = rep->filename().name();
|
||||
TFilename msk = _report->filename().name();
|
||||
msk.ext("msk");
|
||||
if (msk.custom_path())
|
||||
if (_report->use_mask() && msk.custom_path())
|
||||
{
|
||||
TMask m(msk);
|
||||
rep->report2mask(m);
|
||||
_report->report2mask(m);
|
||||
eminem->mask2report(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
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"))
|
||||
{
|
||||
recset->set_var("#PROVV", mainset->get("PROVV"));
|
||||
recset->set_var("#ANNO", mainset->get("ANNO"));
|
||||
recset->set_var("#CODNUM", mainset->get("CODNUM"));
|
||||
recset->set_var("#NDOC", mainset->get("NDOC"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TReport* rep = _report; // Salvo variabile globale
|
||||
add(*eminem, true);
|
||||
_report = rep; // Ripristino variabile globale
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ TString & TVariable_field::get() const
|
||||
{
|
||||
if (_in_get)
|
||||
fatal_box("Recursive get in %s", (const char *) _name);
|
||||
((TVariable_field *) this)->_in_get = TRUE;
|
||||
((TVariable_field *) this)->_in_get = true;
|
||||
if (_e)
|
||||
{
|
||||
CHECK(_rec, "NULL Record pointer with an expression");
|
||||
@ -80,7 +80,7 @@ TString & TVariable_field::get() const
|
||||
CHECK(_rec, "NULL Record pointer with a function");
|
||||
v = _getfunc(*_rec);
|
||||
}
|
||||
((TVariable_field *) this)->_in_get = FALSE;
|
||||
((TVariable_field*) this)->_in_get = false;
|
||||
((TVariable_field*) this)->set_clean();
|
||||
}
|
||||
return v;
|
||||
|
Loading…
x
Reference in New Issue
Block a user