automask.* Supporto automask all'interno degli spreadsheet

default.url  Aggiunto bottone elabora
defmask.h    Aggiunto DLG_ELABORA
urldefid.h   Aggiunto BMP_ELABORA
dongle.cpp   Corretta procedura di connessione a chiave o server
expr.*       Corretti operatori di conversione a TString, real e bool
form.cpp     Modificata indentazione
isamrpc.cpp  Aggiunto riconoscimento stringa localhost
netsock.cpp  Aggiunto riconoscimento stringa localhost
relation.cpp Usato operatore as_string delle espresioni
strings.cpp  Migliorato assegnamento


git-svn-id: svn://10.65.10.50/trunk@6735 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-06-10 14:25:36 +00:00
parent a582971ad0
commit 7cfd681203
14 changed files with 92 additions and 48 deletions

View File

@ -23,26 +23,27 @@ bool TAutomask::error_box(const char* fmt, ...)
return FALSE; return FALSE;
} }
bool TAutomask::universal_handler(TMask_field& f, KEY key) TField_event TAutomask::key2event(TMask_field& f, KEY key) const
{ {
TAutomask& wm = (TAutomask&)f.mask();
TOperable_field& of = (TOperable_field&)f;
TField_event fe = fe_null; TField_event fe = fe_null;
long jolly = key;
switch (key) switch (key)
{ {
case K_TAB: case K_TAB:
if (wm.is_running() || wm.get_sheet() != NULL)
{ {
if (f.focusdirty() && f.is_edit()) const TMask& wm = f.mask();
fe = fe_modify; if (wm.is_running() || wm.get_sheet() != NULL)
{
if (f.focusdirty() && f.is_edit())
fe = fe_modify;
}
else
fe = fe_init;
} }
else
fe = fe_init;
break; break;
case K_SPACE: case K_SPACE:
if (!f.is_edit()) if (!f.is_edit())
{ {
const TMask& wm = f.mask();
if (wm.is_running()) if (wm.is_running())
{ {
if (f.is_kind_of(CLASS_BUTTON_FIELD)) if (f.is_kind_of(CLASS_BUTTON_FIELD))
@ -65,9 +66,29 @@ bool TAutomask::universal_handler(TMask_field& f, KEY key)
fe = fe_null; fe = fe_null;
break; break;
} }
return fe == fe_null ? TRUE : wm.on_field_event(of, fe, jolly); return fe;
} }
bool TAutomask::universal_handler(TMask_field& f, KEY key)
{
TOperable_field& of = (TOperable_field&)f;
TAutomask& am = (TAutomask&)of.mask();
TField_event fe = am.key2event(of, key);
return fe == fe_null ? TRUE : am.on_field_event(of, fe, 0);
}
bool TAutomask::insheet_universal_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
TSheet_field& s = *m.get_sheet();
TAutomask& am = (TAutomask&)s.mask();
TOperable_field& of = (TOperable_field&)f;
TField_event fe = am.key2event(of, key);
return fe == fe_null ? TRUE : am.on_field_event(of, fe, m.number());
}
bool TAutomask::universal_notifier(TSheet_field& s, int row, KEY key) bool TAutomask::universal_notifier(TSheet_field& s, int row, KEY key)
{ {
TAutomask& wm = (TAutomask&)s.mask(); TAutomask& wm = (TAutomask&)s.mask();
@ -111,11 +132,22 @@ void TAutomask::set_handlers()
{ {
f.set_handler(universal_handler); f.set_handler(universal_handler);
if (f.is_sheet()) if (f.is_sheet())
{
((TSheet_field&)f).set_notify(universal_notifier); ((TSheet_field&)f).set_notify(universal_notifier);
TMask& m = ((TSheet_field&)f).sheet_mask();
for (int j = m.fields()-1; j >= 0; j--)
{
TMask_field& g = m.fld(j);
if (g.is_operable())
g.set_handler(insheet_universal_handler);
}
}
} }
} }
} }
TAutomask::TAutomask(const char* name, int num) TAutomask::TAutomask(const char* name, int num)
: TMask(name, num) : TMask(name, num)
{ {

View File

@ -14,10 +14,12 @@ class TAutomask : public TMask
{ {
private: private:
static bool universal_handler(TMask_field& f, KEY k); static bool universal_handler(TMask_field& f, KEY k);
static bool insheet_universal_handler(TMask_field& f, KEY k);
static bool universal_notifier(TSheet_field& f, int row, KEY k); static bool universal_notifier(TSheet_field& f, int row, KEY k);
protected: protected:
void set_handlers(); void set_handlers();
TField_event key2event(TMask_field& f, KEY key) const;
public: public:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly) pure; virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly) pure;

View File

@ -148,6 +148,7 @@ image BMP_LINK QRESDIR"link.bmp"
image BMP_PRINT QRESDIR"print.bmp" image BMP_PRINT QRESDIR"print.bmp"
image BMP_SETPRINT QRESDIR"setprint.bmp" image BMP_SETPRINT QRESDIR"setprint.bmp"
image BMP_RECALC QRESDIR"recalc.bmp" image BMP_RECALC QRESDIR"recalc.bmp"
image BMP_ELABORA QRESDIR"elabora.bmp"
image BMP_OLE QRESDIR"ole.bmp" image BMP_OLE QRESDIR"ole.bmp"
image BMP_LENTE QRESDIR"lente.bmp" image BMP_LENTE QRESDIR"lente.bmp"
image BMP_FAX QRESDIR"fax.bmp" image BMP_FAX QRESDIR"fax.bmp"

View File

@ -28,7 +28,7 @@
#define DLG_PRINT 24 /* TAG del bottone Stampa */ #define DLG_PRINT 24 /* TAG del bottone Stampa */
#define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */ #define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */
#define DLG_RECALC 26 /* TAG del bottone Ricalcola */ #define DLG_RECALC 26 /* TAG del bottone Ricalcola */
#define DLG_ELAB 27 /* TAG del bottone <Elabora> */ #define DLG_ELABORA 27 /* TAG del bottone <Elabora> */
#define DLG_FAX 28 /* TAG del bottone <Fax> */ #define DLG_FAX 28 /* TAG del bottone <Fax> */
#define DLG_EMAIL 29 /* TAG del bottone <Posta> */ #define DLG_EMAIL 29 /* TAG del bottone <Posta> */
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */ #define DLG_USER 100 /* TAG del primo controllo definito dall'utente */

View File

@ -460,7 +460,7 @@ bool TDongle::login(bool test_all_keys)
TDongleHardware hw = _hardware; TDongleHardware hw = _hardware;
if (hw == _dongle_unknown) if (hw == _dongle_unknown)
{ {
if (can_try_server() == 3) if (os_dongle_server_running())
{ {
hw = _dongle_network; hw = _dongle_network;
} }

View File

@ -266,7 +266,6 @@ void TExpression::evaluate_user_func(int index, int nparms, TEval_stack& stack,
} }
void TExpression::setvar(const char* varname, const real& val) void TExpression::setvar(const char* varname, const real& val)
{ {
if (_var.getnum(varname) != val) if (_var.getnum(varname) != val)
{ {
@ -277,7 +276,6 @@ void TExpression::setvar(const char* varname, const real& val)
void TExpression::setvar(int varnum, const real& val) void TExpression::setvar(int varnum, const real& val)
{ {
if (_var.getnum(varnum) != val) if (_var.getnum(varnum) != val)
{ {
@ -436,7 +434,7 @@ void TExpression::eval()
} }
break; break;
case _match: case _match:
{ {
const TString & s2 = evalstack.pop_string(); const TString & s2 = evalstack.pop_string();
const TString & s1 = evalstack.pop_string(); const TString & s1 = evalstack.pop_string();
evalstack.push(real((s1.match(s2)) ? 1.0 : 0.0)); evalstack.push(real((s1.match(s2)) ? 1.0 : 0.0));
@ -582,8 +580,7 @@ void TExpression::eval()
break; break;
case _len: case _len:
{ {
TString s1(evalstack.pop_string()); TString& s1 = evalstack.pop_string();
evalstack.push(real(s1.len())); evalstack.push(real(s1.len()));
} }
break; break;

View File

@ -78,11 +78,11 @@ enum TCodesym {
// @doc INTERNAL // @doc INTERNAL
// @class TValue | Classe per la definizione dei valori che possono essere assunti // @class TValue | Classe per la definizione dei valori che possono essere assunti
// dai termini di una espressione o il valore dell'espressione stessa // dai termini di una espressione o il valore dell'espressione stessa
// //
// @base public | TObject // @base public | TObject
class TValue : public TObject class TValue : public TObject
// @author:(INTERNAL) Sandro // @author:(INTERNAL) Sandro
{ {
@ -110,8 +110,8 @@ public:
const real& number() const const real& number() const
{ return _r; } { return _r; }
// @cmember Ritorna il valore come stringa // @cmember Ritorna il valore come stringa
const char* string() const const TString& string() const
{ return (const char*) _s;} { return _s;}
// @cmember Setta il valore passato come real // @cmember Setta il valore passato come real
void set(const real& val) void set(const real& val)
{ _r = val; _s = val.string(); _t = _numexpr; } { _r = val; _s = val.string(); _t = _numexpr; }

View File

@ -758,7 +758,7 @@ bool TForm_item::do_message(int num)
TToken_string& messaggio = message(num); TToken_string& messaggio = message(num);
if (messaggio.empty_items()) return FALSE; if (messaggio.empty_items()) return FALSE;
TToken_string msg(16, ','); TToken_string msg(80, ',');
for (const char* m = messaggio.get(0); m; m = messaggio.get()) for (const char* m = messaggio.get(0); m; m = messaggio.get())
{ {
msg = m; msg = m;

View File

@ -222,7 +222,7 @@ bool rpc_UserLogin(const char* server, const char* user,
return FALSE; return FALSE;
} }
const bool local = server == NULL || *server == '\0'; const bool local = server == NULL || *server == '\0' || stricmp(server, "localhost") == 0;
TString name(40); TString name(40);
if (local) if (local)
name = "locale"; name = "locale";

View File

@ -517,7 +517,7 @@ TConnection* TSocketClient::OnQueryConnection(const char* service,
if (cur_socket == NULL) if (cur_socket == NULL)
{ {
TString strServer = server; TString strServer = server;
if (strServer.empty()) if (strServer.empty() || stricmp(strServer, "localhost") == 0)
strServer = "127.0.0.1"; strServer = "127.0.0.1";
cur_socket = new skstream(strServer, (skstream::service)atoi(service)); cur_socket = new skstream(strServer, (skstream::service)atoi(service));
@ -540,7 +540,7 @@ BOOL TSocketClient::Execute(DWORD id, const char* cmd)
if (ok) if (ok)
{ {
const int buflen = strlen(cmd)+1; const int buflen = strlen(cmd)+1;
cur_socket->sync(); cur_socket->sync();
cur_socket->write(cmd, buflen); cur_socket->write(cmd, buflen);
cur_socket->flush(); cur_socket->flush();
ok = cur_socket->good(); ok = cur_socket->good();
@ -561,15 +561,15 @@ BOOL TSocketClient::Request(DWORD id, const char* cmd)
ok = Execute(id, cmd); ok = Execute(id, cmd);
if (ok) if (ok)
{ {
m_dwSize = 0; m_dwSize = 0;
cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize)); cur_socket->read((char*)&m_dwSize, sizeof(m_dwSize));
ok = m_dwSize > 0; ok = m_dwSize > 0;
if (ok) if (ok)
{ {
m_pData = new BYTE[m_dwSize]; m_pData = new BYTE[m_dwSize];
cur_socket->read(m_pData, (int)m_dwSize); cur_socket->read(m_pData, (int)m_dwSize);
ok = cur_socket->good(); ok = cur_socket->good();
} }
} }
semaphore = FALSE; semaphore = FALSE;

View File

@ -228,7 +228,7 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
expr.setvar(k, to.get(name)); expr.setvar(k, to.get(name));
} }
const char* val = expr; const char* val = expr.as_string();
if (*val == '\0' && _altexprs.objptr(j)) if (*val == '\0' && _altexprs.objptr(j))
{ {
@ -238,7 +238,7 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
name = altexpr.varname(k); name.upper(); name = altexpr.varname(k); name.upper();
altexpr.setvar(k, to.get(name)); altexpr.setvar(k, to.get(name));
} }
val = altexpr; val = altexpr.as_string();
} }
return val; return val;
@ -588,6 +588,8 @@ int TRelation::position_rels(
// <nl>Le altre funzioni sul record procedono normalmente // <nl>Le altre funzioni sul record procedono normalmente
{ {
TString expr; // Stringa di lavoro per la valutazione delle espressioni
_errors = NOERR; _errors = NOERR;
// workhorse: position files for each active relation // workhorse: position files for each active relation
@ -609,7 +611,7 @@ int TRelation::position_rels(
// build record // build record
for (int j = 0 ; j < rd._fields.items(); j++) // for each field for (int j = 0 ; j < rd._fields.items(); j++) // for each field
{ {
TString expr (rd.evaluate_expr(j, to)); expr = rd.evaluate_expr(j, to);
TFieldref& s = (TFieldref&) rd._fields[j]; TFieldref& s = (TFieldref&) rd._fields[j];
if (from.is_sorted() && from.curr().type(s.name()) ==_alfafld) if (from.is_sorted() && from.curr().type(s.name()) ==_alfafld)
expr.rpad(s.len(from.curr()),'~'); expr.rpad(s.len(from.curr()),'~');

View File

@ -134,10 +134,18 @@ TString& TString::set(
// @rdesc Ritorna l'indirizzo della stringa inizializzata // @rdesc Ritorna l'indirizzo della stringa inizializzata
{ {
if (s == NULL) s = ""; if (s && *s)
const int sz = *s ? strlen(s) : 15; {
if (sz > size()) resize(sz, FALSE); const int sz = strlen(s);
strcpy(_str, s); if (sz > size()) resize(sz, FALSE);
strcpy(_str, s);
}
else
{
if (size() == 0)
resize(15, FALSE);
*_str = '\0';
}
return *this; return *this;
} }

View File

@ -52,6 +52,7 @@
#define BMP_LINK 117 #define BMP_LINK 117
#define BMP_PRINT 118 #define BMP_PRINT 118
#define BMP_RECALC 119 #define BMP_RECALC 119
#define BMP_ELABORA 120
#define BMP_FIRSTREC 121 #define BMP_FIRSTREC 121
#define BMP_PREVREC 122 #define BMP_PREVREC 122
#define BMP_STOPREC 123 #define BMP_STOPREC 123

View File

@ -20,7 +20,8 @@ TVariable_field::TVariable_field(
if (expr && *expr) if (expr && *expr)
{ {
_e = new TExpression(expr, type); _e = new TExpression(expr, type);
if (TFixed_string(expr).find('-') == -1) _put_string = new TToken_string(expr, '+'); if (TFixed_string(expr).find('-') < 0)
_put_string = new TToken_string(expr, '+');
} }
} }