Migliorata gestione sheet ricerca
git-svn-id: svn://10.65.10.50/branches/R_10_00@23179 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c846ab1358
commit
e9a34d143f
@ -64,7 +64,7 @@ TObject* TContainer::succ_that( )
|
||||
|
||||
TObject* TContainer::pred_that( )
|
||||
{
|
||||
if( _last_condition )
|
||||
if( _last_condition )
|
||||
{
|
||||
TObject* curr = pred_item( );
|
||||
while( curr && !_last_condition( *curr ) )
|
||||
@ -588,6 +588,15 @@ void TArray::sort(
|
||||
qsort(_data, last()+1, sizeof(TObject*), compare_ex);
|
||||
}
|
||||
|
||||
bool TArray::is_kind_of(word id) const
|
||||
{ return class_id() == CLASS_ARRAY || TContainer::is_kind_of(id); }
|
||||
|
||||
TArray& objptr2array(TObject* obj)
|
||||
{
|
||||
CHECK(obj && obj->is_kind_of(CLASS_ARRAY), "Invalid array pointer");
|
||||
return static_cast<TArray&>(*obj);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TString_array
|
||||
|
@ -135,6 +135,8 @@ public:
|
||||
virtual const char* class_name() const ;
|
||||
// @cmember Ritorna l'id della class
|
||||
virtual word class_id() const ;
|
||||
// @cmember Controlla se si tratta di un oggetto derivato da TArray
|
||||
virtual bool is_kind_of(word cid) const;
|
||||
// @cmember Stampa un array
|
||||
virtual void print_on(ostream& out) const ;
|
||||
// @cmember Controlla se si tratta di un oggetto valido
|
||||
@ -220,6 +222,8 @@ inline TObject& TArray::operator[] (int index) const
|
||||
(__obj = (__arr).objptr(__r)) != NULL; \
|
||||
__r = (__arr).pred(__r))
|
||||
|
||||
TArray& objptr2array(TObject* obj);
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TString_array
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -1059,11 +1059,12 @@ TToken_string& TBrowse::create_siblings(TToken_string& siblings) const
|
||||
|
||||
KEY TBrowse::run()
|
||||
{
|
||||
const TString& val = field().get();
|
||||
TEdit_field& e = field();
|
||||
const TString& val = e.get();
|
||||
|
||||
if (val.starts_with("*"))
|
||||
{
|
||||
TFuzzy_browse fb(&field(), cursor()->key());
|
||||
TFuzzy_browse fb(&e, cursor()->key());
|
||||
const KEY k = fb.run();
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
@ -1112,8 +1113,8 @@ KEY TBrowse::run()
|
||||
|
||||
if (_insert[0] == 'M' || _insert[0] == 'R')
|
||||
{
|
||||
const TString& maskname = field().mask().source_file();
|
||||
if (maskname.mid(2,2).compare("tb", 2, true) == 0 && field().in_key(0))
|
||||
const TString& maskname = e.mask().source_file();
|
||||
if (maskname.mid(2,2).compare("tb", 2, true) == 0 && e.in_key(0))
|
||||
{
|
||||
const char* tabname = _cursor->file().name();
|
||||
if (maskname.mid(4, 3).compare(tabname, 3, true) == 0)
|
||||
@ -1126,7 +1127,7 @@ KEY TBrowse::run()
|
||||
{
|
||||
if (*i != '\0' && *i != '"' && strchr(i, '@') == NULL)
|
||||
{
|
||||
const short id = field().atodlg(i);
|
||||
const short id = e.atodlg(i);
|
||||
const TEditable_field& f = field(id);
|
||||
if (f.active() && f.is_editable())
|
||||
{
|
||||
@ -1139,7 +1140,7 @@ KEY TBrowse::run()
|
||||
|
||||
xvt_scr_reset_busy_cursor();
|
||||
|
||||
TBrowse_sheet s(_cursor, _items, caption, _head, buttons, field(), siblings, _custom_filter_handler);
|
||||
TBrowse_sheet s(_cursor, _items, caption, _head, buttons, e, siblings, _custom_filter_handler);
|
||||
|
||||
k = s.run();
|
||||
selected = s.selected();
|
||||
@ -1704,6 +1705,27 @@ TRecnotype TFuzzy_browse::find_magic(const TString& magic_val, double& best)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (testlen > 0)
|
||||
{
|
||||
for (c = 0L; c.ok(); ++c)
|
||||
{
|
||||
TString80 val = curr.get(_altfld);
|
||||
clean_string(val);
|
||||
|
||||
const int i = val.find(magic_val);
|
||||
if (i >= 0)
|
||||
{
|
||||
const double n = 1.0 - 0.01*i;
|
||||
if (n > best)
|
||||
{
|
||||
best = n;
|
||||
recno = c.pos();
|
||||
if (n >= 1.0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recno >= 0)
|
||||
|
@ -4,7 +4,7 @@ np No Profit
|
||||
fe Comunicazione Polivalente
|
||||
77 Percipienti
|
||||
gd Gestione DNinst
|
||||
se Contabilità Semplificata
|
||||
se SEPA
|
||||
cg Contabilità Generale
|
||||
ci Contabilità Industriale
|
||||
dc Dichiarazione CONAI
|
||||
@ -43,6 +43,6 @@ lv Lavanderie
|
||||
?? Modulo vario ex-l1 Gestione Lavanderie Ext1
|
||||
l2 Lavanderie 02
|
||||
?? Modulo vario ex-l3 Gestione Lavanderie Ext3
|
||||
?? Modulo vario ex-l4 Gestione Lavanderie Ext4
|
||||
bs Bee Store
|
||||
ha Hardy Caffè
|
||||
ri Riclassificazioni
|
||||
|
@ -50,7 +50,7 @@ static bool is_prime(size_t n)
|
||||
|
||||
static size_t next_size(size_t p)
|
||||
{
|
||||
for (p = p*2-1; !is_prime(p); p += 2);
|
||||
for (p = p*4-1; !is_prime(p); p += 2);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ static size_t next_size(size_t p)
|
||||
|
||||
struct THash_entry
|
||||
{
|
||||
char buf[8];
|
||||
char* key;
|
||||
unsigned int hash;
|
||||
TObject* value;
|
||||
@ -95,7 +96,16 @@ bool THash_bucket::add(const char* key, unsigned int hash, TObject* value)
|
||||
CHECK(_entries < nMaxEntries, "bucket full");
|
||||
_bloom |= bloom(hash);
|
||||
THash_entry& e = _entry[_entries++];
|
||||
e.key = _strdup(key);
|
||||
if (strlen(key) < sizeof(e.buf))
|
||||
{
|
||||
strcpy_s(e.buf, sizeof(e.buf), key);
|
||||
e.key = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*e.buf = '\0';
|
||||
e.key = _strdup(key);
|
||||
}
|
||||
e.hash = hash;
|
||||
e.value = value;
|
||||
return _entries > 3*nMaxEntries/4; // Danger!
|
||||
@ -116,7 +126,7 @@ THash_entry* THash_bucket::lookup(const char* key, unsigned int hash)
|
||||
for (int p = _entries-1; p >= 0; p--)
|
||||
{
|
||||
THash_entry& e = _entry[p];
|
||||
if (e.hash == hash && strcmp(e.key, key) == 0)
|
||||
if (e.hash == hash && strcmp(e.key ? e.key : e.buf, key) == 0)
|
||||
return &e;
|
||||
}
|
||||
}
|
||||
@ -128,7 +138,8 @@ TObject* THash_bucket::remove(int p)
|
||||
CHECKD(p >= 0 && p < _entries, "Invalid item index ", p);
|
||||
THash_entry& e = _entry[p];
|
||||
TObject* obj = e.value;
|
||||
free(e.key);
|
||||
if (e.key)
|
||||
free(e.key);
|
||||
if (p < _entries-1)
|
||||
memcpy(&_entry[p], &_entry[_entries-1], sizeof(THash_entry));
|
||||
_entries--;
|
||||
@ -143,7 +154,6 @@ TObject* THash_bucket::remove(THash_entry* e)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
THash_bucket::~THash_bucket()
|
||||
{
|
||||
for (int p = _entries-1; p >= 0; p--)
|
||||
|
@ -683,7 +683,7 @@ TMask_field& TMask::field(short id) const
|
||||
|
||||
int TMask::field2pos(const char* fieldname) const
|
||||
{
|
||||
if (real::is_natural(fieldname))
|
||||
if (real::is_natural(fieldname) || *fieldname == '-')
|
||||
{
|
||||
const short id = atoi(fieldname);
|
||||
return id2pos(id);
|
||||
|
@ -660,33 +660,30 @@ const TString& TMask_field::evaluate_field(short id) const
|
||||
if (id == 0)
|
||||
return get();
|
||||
|
||||
const TMask* m = &mask();
|
||||
|
||||
if (id < 0)
|
||||
{
|
||||
TSheet_field* sh = m->get_sheet();
|
||||
if (sh != NULL)
|
||||
{
|
||||
m = &sh->mask();
|
||||
id = -id;
|
||||
}
|
||||
}
|
||||
|
||||
const int pos = m->id2pos(id);
|
||||
if (pos >= 0)
|
||||
return m->fld(pos).get();
|
||||
const TMask_field* fld = mask().find_by_id(id); // Handles negatives id too
|
||||
if (fld)
|
||||
return fld->get();
|
||||
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
const TString & TMask_field::evaluate_field(const char * s) const
|
||||
const TString & TMask_field::evaluate_field(const char* s) const
|
||||
{
|
||||
if (s && *s)
|
||||
{
|
||||
if (s[0] == '#')
|
||||
s++;
|
||||
const short id = atoi(s);
|
||||
return evaluate_field(id);
|
||||
if (isdigit(*s) || *s=='-')
|
||||
{
|
||||
const short id = atoi(s);
|
||||
return evaluate_field(id);
|
||||
} else
|
||||
if (*s>='A' && *s<='Z')
|
||||
{
|
||||
const TMask_field* fld = mask().find_by_fieldname(s);
|
||||
if (fld)
|
||||
return fld->get();
|
||||
}
|
||||
}
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
//#define L1AUT 42
|
||||
#define L2AUT 43
|
||||
//#define L3AUT 44
|
||||
//#define L4AUT 45
|
||||
#define BSAUT 45
|
||||
#define HAAUT 46
|
||||
#define RIAUT 47
|
||||
#define ENDAUT 48
|
||||
|
@ -1166,7 +1166,7 @@ bool TPrefix::set_studio(const char* study, long ditta)
|
||||
const TString old_study(__ptprf);
|
||||
const TString old_firm(_prefix);
|
||||
|
||||
strcpy(__ptprf, study);
|
||||
strcpy_s(__ptprf, sizeof(__ptprf), study);
|
||||
const word len = strlen(__ptprf);
|
||||
if (len > 0 && __ptprf[len-1] != '\\' && __ptprf[len-1] != '/')
|
||||
{
|
||||
@ -1179,7 +1179,7 @@ bool TPrefix::set_studio(const char* study, long ditta)
|
||||
bool ok = set_codditta(ditta, TRUE);
|
||||
if (!ok)
|
||||
{
|
||||
strcpy(__ptprf, old_study);
|
||||
strcpy_s(__ptprf, sizeof(__ptprf), old_study);
|
||||
set(old_firm, true);
|
||||
}
|
||||
return ok;
|
||||
|
@ -973,6 +973,12 @@ const TRectype& TDB_cache::get_rec(int file, const char* key1, const char* key2,
|
||||
return get(file, tok);
|
||||
}
|
||||
|
||||
const TRectype& TDB_cache::get_rec(int file, char c, long n)
|
||||
{
|
||||
char key[16]; sprintf_s(key, sizeof(key), "%c|%ld", c, n);
|
||||
return get(file, key);
|
||||
}
|
||||
|
||||
bool TDB_cache::discard(int file, const char* key)
|
||||
{
|
||||
return rec_cache(file).discard(key);
|
||||
|
@ -263,7 +263,10 @@ public:
|
||||
|
||||
// Smarter get: no token string key needed
|
||||
const TRectype& get_rec(int file, const char* key1, const char* key2=NULL, const char* key3=NULL, const char* key4=NULL);
|
||||
|
||||
|
||||
// clifo&anagr get: no token string key needed
|
||||
const TRectype& get_rec(int file, char c, long n);
|
||||
|
||||
const TString& get(int file, const char* key_tok, const char * campo);
|
||||
const TString& get(int file, long key, const char * campo);
|
||||
const TString& get(const char* table, const char* key_tok, const char* campo);
|
||||
|
@ -103,15 +103,16 @@ void TRelation_application::set_limits(
|
||||
cur.setkey();
|
||||
if (cur.items() > 0)
|
||||
{
|
||||
TBaseisamfile& f = cur.file();
|
||||
if (what & 0x1)
|
||||
{
|
||||
cur = 0;
|
||||
_first = cur.file().recno();
|
||||
_first = f.recno();
|
||||
}
|
||||
if (what & 0x2)
|
||||
{
|
||||
cur = cur.items() - 1;
|
||||
_last = cur.file().recno();
|
||||
_last = f.recno();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -120,17 +121,18 @@ void TRelation_application::set_limits(
|
||||
else
|
||||
{
|
||||
setkey();
|
||||
if (!file().empty())
|
||||
TBaseisamfile& f = file();
|
||||
if (!f.empty())
|
||||
{
|
||||
if (what & 0x1)
|
||||
{
|
||||
if (file().first() == NOERR)
|
||||
_first = file().recno();
|
||||
if (f.first() == NOERR)
|
||||
_first = f.recno();
|
||||
}
|
||||
if (what & 0x2)
|
||||
{
|
||||
if (file().last() == NOERR)
|
||||
_last = file().recno();
|
||||
if (f.last() == NOERR)
|
||||
_last = f.recno();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1551,7 +1551,7 @@ int TCursor::test(TIsamop op, TReclock lockop) const
|
||||
{
|
||||
if (ok())
|
||||
{
|
||||
trovato = TRUE;
|
||||
trovato = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -1654,7 +1654,7 @@ TRecnotype TCursor::read(TIsamop op, TReclock lockop)
|
||||
if (match <= *s)
|
||||
{
|
||||
const int pagecnt = read_page(p);
|
||||
found = TRUE;
|
||||
found = true;
|
||||
for (int i = 0; i < pagecnt && _pos < 0L; i++)
|
||||
if (_page[i] == curpos)
|
||||
_pos = _pagefirstpos + i;
|
||||
@ -1683,7 +1683,6 @@ TRecnotype TCursor::read(TIsamop op, TReclock lockop)
|
||||
return _pos;
|
||||
}
|
||||
|
||||
|
||||
TCursor::TCursor(TRelation* r, const char* fil, int nkey,
|
||||
const TRectype *from, const TRectype* to, int tilde)
|
||||
: _if(r), _nkey(nkey), _fexpr(NULL), _frozen(false), _filter_update(false),
|
||||
@ -2073,7 +2072,7 @@ const char* TSorted_cursor::fill_sort_key(TString& k)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_up)
|
||||
// if (is_up) // Test inutile: tutte le chiavi sono maiuscole 08-02-2016
|
||||
sf.upper();
|
||||
}
|
||||
switch (fld_type)
|
||||
@ -2121,11 +2120,10 @@ TRecnotype TSorted_cursor::read(TIsamop op, TReclock lockop)
|
||||
last = (i + 1) * pagesize() - 1;
|
||||
else
|
||||
first = i * pagesize();
|
||||
|
||||
}
|
||||
|
||||
const bool ghiacciato = !frozen();
|
||||
if (ghiacciato) freeze(TRUE);
|
||||
if (ghiacciato) freeze(true);
|
||||
|
||||
TString256 testing;
|
||||
while (first <= last)
|
||||
@ -2176,7 +2174,8 @@ TRecnotype TSorted_cursor::read(TIsamop op, TReclock lockop)
|
||||
file().setstatus(op == _isequal ? _iskeynotfound : _iseof);
|
||||
}
|
||||
|
||||
if (ghiacciato) freeze(FALSE);
|
||||
if (ghiacciato)
|
||||
freeze(false);
|
||||
|
||||
return found;
|
||||
}
|
||||
@ -2191,12 +2190,12 @@ void TSorted_cursor::change_order(const char* order_expr)
|
||||
_order_expr.restart();
|
||||
while ((s=_order_expr.get()).not_empty() && (_is_valid_expr=check_expr(s))) ;
|
||||
if (_is_valid_expr)
|
||||
_is_changed_expr=TRUE;
|
||||
_is_changed_expr=true;
|
||||
}
|
||||
}
|
||||
|
||||
TSorted_cursor::TSorted_cursor(TRelation *f, const char * order_expr, const char * filter, int key, const TRectype* from, const TRectype* to)
|
||||
: TCursor(f,filter,key,from,to)
|
||||
: TCursor(f,filter,key,from,to)
|
||||
{
|
||||
change_order(order_expr);
|
||||
}
|
||||
|
@ -1588,6 +1588,7 @@ void TReport_field::print(TBook& book) const
|
||||
switch (_type)
|
||||
{
|
||||
case 'B':
|
||||
/*
|
||||
if (is_power_reseller())
|
||||
{
|
||||
const TReport_rct& rctout = get_draw_rect();
|
||||
@ -1607,6 +1608,7 @@ void TReport_field::print(TBook& book) const
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
print_rect(book);
|
||||
const TString& str = formatted_text();
|
||||
|
@ -1109,9 +1109,10 @@ void TFilename::ext(const char* e)
|
||||
*this << e;
|
||||
}
|
||||
*/
|
||||
char v[_MAX_DRIVE], d[_MAX_DIR], n[_MAX_FNAME];
|
||||
char v[_MAX_DRIVE], d[_MAX_DIR], n[_MAX_FNAME], p[_MAX_PATH];
|
||||
xvt_fsys_parse_pathname(_str, v, d, n, NULL, NULL);
|
||||
xvt_fsys_build_pathname(_str, v, d, n, e, NULL);
|
||||
xvt_fsys_build_pathname(p, v, d, n, e, NULL);
|
||||
set(p);
|
||||
}
|
||||
|
||||
// Certified 95%
|
||||
|
@ -483,17 +483,17 @@ public:
|
||||
// @class TFilename | Classe per la gestione dei nome dei file
|
||||
//
|
||||
// @base public | TString
|
||||
class TFilename : public TString256
|
||||
class TFilename : public TString
|
||||
// @author:(INTERNAL) Guido
|
||||
{
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Costruttore
|
||||
TFilename(const char* n = "") : TString256(n) { }
|
||||
TFilename(const char* n = "") : TString(260) { set(n); }
|
||||
// @cmember Costruttore
|
||||
TFilename(const TString& n) : TString256(n) { }
|
||||
TFilename(const TString& n) : TString(260) { set(n); }
|
||||
// @cmember Costruttore
|
||||
TFilename(const TFilename& n) : TString256(n) { }
|
||||
TFilename(const TFilename& n) : TString(260) { set(n); }
|
||||
|
||||
// @cmember Assegnazione tra TFilename e stringa
|
||||
const TString& operator =(const char* s) { return set(s); }
|
||||
@ -520,7 +520,7 @@ public:
|
||||
// @cmember Trasforma un path da relativo ad assoluto
|
||||
TFilename& make_absolute_path();
|
||||
// @cmember aggiunge uno slash finale
|
||||
TFilename& TFilename::slash_terminate();
|
||||
TFilename& slash_terminate();
|
||||
// @cmember Testa se il file esiste
|
||||
bool exist() const;
|
||||
// @cmember Cancella il file
|
||||
|
@ -102,13 +102,13 @@ bool fcopy(
|
||||
if (xvt_str_same(orig, dest))
|
||||
return true; // Or FALSE?
|
||||
|
||||
FILE* i = fopen(orig, rflag);
|
||||
FILE* i = NULL; fopen_s(&i, orig, rflag);
|
||||
if (i == NULL)
|
||||
return error_box(FR("Impossibile leggere il file %s\nda copiare in %s"), orig, dest);
|
||||
return error_box(FR("Impossibile leggere il file '%s'\nda copiare in '%s'\nErrore %d"), orig, dest, errno);
|
||||
|
||||
if (!append)
|
||||
xvt_fsys_remove_file(dest);
|
||||
FILE* o = fopen(dest, wflag);
|
||||
FILE* o = NULL; fopen_s(&o, dest, wflag);
|
||||
if (o == NULL)
|
||||
{
|
||||
fclose(i);
|
||||
|
@ -294,7 +294,13 @@ HIDDEN bool _cf_val(TMask_field& f, KEY key)
|
||||
const TString& stato = get_fld_val_param(f, 0);
|
||||
if (stato.full() && stato != "IT")
|
||||
return true;
|
||||
ok = pi_check(stato, cf);
|
||||
if (cf[0]>='8' && cf.len() == 11) // codice fiscale ONLUS
|
||||
{
|
||||
for (const char* c = cf; *c && ok; c++)
|
||||
ok = (*c>='0') && (*c<='9');
|
||||
}
|
||||
else
|
||||
ok = pi_check(stato, cf);
|
||||
}
|
||||
else
|
||||
ok = __cf_check(cf);
|
||||
@ -602,8 +608,8 @@ HIDDEN bool _numcalc_val(TMask_field& f, KEY k)
|
||||
}
|
||||
e.setvar(i, f.evaluate_field(s));
|
||||
}
|
||||
const TString& s = e.as_string();
|
||||
f.set(s);
|
||||
const real n = e.as_real();
|
||||
f.set(n.string());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,10 @@ bool TVariant::as_bool() const
|
||||
case _alfafld:
|
||||
{
|
||||
const TString& str = as_string();
|
||||
ok = str.full() && strchr("1TVXY", str[0]) != NULL;
|
||||
if (str.len() > 1) // May be " 1"
|
||||
ok = atoi(str) != 0;
|
||||
else
|
||||
ok = str.full() && strchr("1TVXY", str[0]) != NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user