Patch level : xx.7.054

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Riportata la verione 1.7 patch 054 aga sul main trunk.


git-svn-id: svn://10.65.10.50/trunk@9656 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2001-04-30 15:04:10 +00:00
parent 8a05210c2d
commit 6c73d4919e
45 changed files with 794 additions and 333 deletions

View File

@ -380,12 +380,12 @@ long TApplication::handler(WINDOW win, EVENT* ep)
} }
const TString & TApplication::god_string(const char * keyword) const const TString & TApplication::god_string(const char* keyword) const
{ {
if (_god_vars== NULL) if (_god_vars== NULL)
((TApplication *)this)->_god_vars = new TAssoc_array; ((TApplication *)this)->_god_vars = new TAssoc_array;
TString * s = (TString *)_god_vars->objptr(keyword); TString* s = (TString*)_god_vars->objptr(keyword);
if (s == NULL) if (s == NULL)
{ {
@ -896,9 +896,10 @@ bool TApplication::build_firm_data(long codditta, bool flagcom)
bool TApplication::set_firm(long newfirm) bool TApplication::set_firm(long newfirm)
{ {
const long oldfirm = get_firm(); const long oldfirm = get_firm();
const bool interactive = newfirm <= 0;
#ifndef _DEMO_ #ifndef _DEMO_
if (newfirm < 1) if (interactive)
{ {
TMask mask("bagn002"); TMask mask("bagn002");
TFilename pp(__ptprf); pp.cut(pp.len()-1); TFilename pp(__ptprf); pp.cut(pp.len()-1);
@ -927,9 +928,17 @@ bool TApplication::set_firm(long newfirm)
} }
} }
#endif #endif
if (newfirm == oldfirm || newfirm < 1) if (interactive)
return newfirm > 0; {
if (newfirm <= 0)
return newfirm > 0;
}
else
{
if (newfirm == oldfirm || newfirm <= 0)
return newfirm > 0;
}
if (prefix().test(newfirm)) if (prefix().test(newfirm))
{ {

View File

@ -174,10 +174,10 @@ int TArchive::build_restore_list(
TString_array& fl) const // @parm Nomi dei cartella da ripristinare TString_array& fl) const // @parm Nomi dei cartella da ripristinare
{ {
fl.destroy(); fl.destroy();
if (!yesno_box("Inserire il dischetto nel drive %c e continuare ?\n" if (!yesno_box("Inserire il dischetto nel drive %c e continuare?\n"
"(Rispondere NO se si desidera interrompere la procedura)", floppy)) "(Rispondere NO se si desidera interrompere la procedura)", floppy))
return -1; return -1;
TFilename name("a:/backup.ini"); name[0] = floppy; TFilename name("a:/backup.ini"); name[0] = floppy;
TConfig ini(name); TConfig ini(name);

View File

@ -70,7 +70,7 @@ void TConfig_application::save_mask(bool tosave)
if (f.dirty() && f.field()) if (f.dirty() && f.field())
{ {
const char* fname = f.field()->name(); const char* fname = f.field()->name();
const char* value = f.get(); const TString& value = f.get();
const int index = f.field()->to(); const int index = f.field()->to();
const char* oldvl = _cnf->get(fname); const char* oldvl = _cnf->get(fname);
@ -80,7 +80,16 @@ void TConfig_application::save_mask(bool tosave)
if (!tosave) break; if (!tosave) break;
if (postprocess_config_changed(_parag, fname, oldvl, value)) if (postprocess_config_changed(_parag, fname, oldvl, value))
_cnf->set(fname, value, NULL, TRUE, index > -1 ? index : -1); {
if (value[0] == ' ' || value.right(1) == " ")
{
TString val;
val << '"' << value << '"';
_cnf->set(fname, val, NULL, TRUE, index > -1 ? index : -1);
}
else
_cnf->set(fname, value, NULL, TRUE, index > -1 ? index : -1);
}
} }
} }
} }
@ -91,6 +100,7 @@ void TConfig_application::load_mask()
TMask* mask = get_mask(); TMask* mask = get_mask();
if (mask==NULL) return; if (mask==NULL) return;
const int max = mask->fields(); const int max = mask->fields();
TString oldvl;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TMask_field& f = mask->fld(i); TMask_field& f = mask->fld(i);
@ -99,7 +109,12 @@ void TConfig_application::load_mask()
const TFieldref* fr = f.field(); const TFieldref* fr = f.field();
const char* fname = fr->name(); const char* fname = fr->name();
const int index = fr->to(); const int index = fr->to();
const TString& oldvl = _cnf->get(fname,NULL, index > -1 ? index : -1); oldvl = _cnf->get(fname,NULL, index > -1 ? index : -1);
if (oldvl[0] == '"' && oldvl.right(1) == "\"")
{
oldvl.rtrim(1);
oldvl.ltrim(1);
}
f.set(oldvl); f.set(oldvl);
} }
} }

View File

@ -1040,6 +1040,12 @@ void TControl::autoselect(bool on)
change_attrib(XI_ATR_AUTOSELECT, on); change_attrib(XI_ATR_AUTOSELECT, on);
} }
// @mfunc Allineamento a destra del testo
void TControl::set_rjust(bool on)
{
change_attrib(XI_ATR_RJUST, on);
}
// @doc INTERNAL // @doc INTERNAL
const char* TControl::caption() const const char* TControl::caption() const

View File

@ -97,6 +97,9 @@ public:
// @cmember Mostra/nasconde il controllo // @cmember Mostra/nasconde il controllo
virtual void show(bool on = TRUE); virtual void show(bool on = TRUE);
void hide() { show(FALSE); } void hide() { show(FALSE); }
virtual void set_rjust(bool on = TRUE);
void set_ljust() { set_rjust(FALSE); }
void autoselect(bool on); void autoselect(bool on);

View File

@ -34,7 +34,6 @@ class TDowJones : public TFile_cache
protected: protected:
virtual TObject* rec2obj(const TRectype& rec) const; virtual TObject* rec2obj(const TRectype& rec) const;
virtual void flush();
void test_cache(); void test_cache();
const TExchangeData& get(const char* key); const TExchangeData& get(const char* key);
@ -59,6 +58,8 @@ public:
real get_base_change(const char* val); real get_base_change(const char* val);
real get_contro_change(const char* val); real get_contro_change(const char* val);
virtual void flush();
TDowJones() : TFile_cache("%VAL"), _codditta(0) { } TDowJones() : TFile_cache("%VAL"), _codditta(0) { }
virtual ~TDowJones() { } virtual ~TDowJones() { }
} DowJones; } DowJones;
@ -99,6 +100,7 @@ void TDowJones::flush()
_base_val.cut(0); _base_val.cut(0);
_firm_val.cut(0); _firm_val.cut(0);
_euro_val.cut(0); _euro_val.cut(0);
kill_file();
} }
void TDowJones::test_cache() void TDowJones::test_cache()
@ -386,6 +388,11 @@ bool TExchange::is_firm_value() const
return DowJones.get_firm_val() == _val; return DowJones.get_firm_val() == _val;
} }
bool TExchange::is_euro_value() const
{
return DowJones.get_euro_val() == _val;
}
void TExchange::set(const char* val, const real& chg, exchange_type et) void TExchange::set(const char* val, const real& chg, exchange_type et)
{ {
val = DowJones.normalize_value(val, chg, et); val = DowJones.normalize_value(val, chg, et);
@ -465,6 +472,10 @@ void TCurrency::force_firm_val(const char* val)
DowJones.force_firm_val(val); DowJones.force_firm_val(val);
} }
void TCurrency::force_cache_update()
{
DowJones.flush();
}
void TCurrency::force_value(const char* newval, const real& newchange, exchange_type newet) void TCurrency::force_value(const char* newval, const real& newchange, exchange_type newet)
{ {
@ -516,7 +527,7 @@ const char* TCurrency::string(bool dotted) const
picture.format(".%d", decimals()); picture.format(".%d", decimals());
return _num.string(picture); return _num.string(picture);
} }
return _num.string(0, decimals()); return _num.stringa(0, decimals());
} }
TCurrency& TCurrency::operator+=(const TCurrency& cur) TCurrency& TCurrency::operator+=(const TCurrency& cur)
@ -611,4 +622,13 @@ TCurrency::TCurrency(const real& num, const TExchange& exc, bool price)
_num.round(decimals()); _num.round(decimals());
} }
bool same_values(const char * valuea, const char * valueb)
{
if (valuea == NULL || *valuea == '\0')
valuea = TCurrency::get_firm_val();
if (valueb == NULL || *valueb == '\0')
valueb = TCurrency::get_firm_val();
return stricmp(valuea, valueb) == 0;
}

View File

@ -32,6 +32,7 @@ public:
exchange_type get_type() const { return _et; } exchange_type get_type() const { return _et; }
bool is_firm_value() const; bool is_firm_value() const;
bool is_euro_value() const;
const char* get_value() const { return _val; } const char* get_value() const { return _val; }
const real& get_change(exchange_type& et) const; const real& get_change(exchange_type& et) const;
@ -43,7 +44,7 @@ public:
TExchange(const TRectype& rec); TExchange(const TRectype& rec);
virtual ~TExchange() { } virtual ~TExchange() { }
}; };
class TCurrency : public TSortable class TCurrency : public TSortable
{ {
TExchange _chg; // Cambio TExchange _chg; // Cambio
@ -66,6 +67,7 @@ public:
// serve per la personalizzazione cgp4, per stampare il bilancio in euro // serve per la personalizzazione cgp4, per stampare il bilancio in euro
static void force_firm_val(const char* val); static void force_firm_val(const char* val);
static void force_cache_update(); // Azzeramento cache
void set_price(bool p) { _price = p; } void set_price(bool p) { _price = p; }
bool is_price() const { return _price; } bool is_price() const { return _price; }
@ -129,6 +131,11 @@ public:
TPrice(const real& num, const char* val = "", const real& exc = ZERO, exchange_type ext = _exchange_undefined) TPrice(const real& num, const char* val = "", const real& exc = ZERO, exchange_type ext = _exchange_undefined)
: TCurrency(num, val, exc, ext, TRUE) { } : TCurrency(num, val, exc, ext, TRUE) { }
virtual ~TPrice() { } virtual ~TPrice() { }
}; };
inline bool is_firm_value(const char * value) { return value == NULL || *value == '\0' || TCurrency::get_firm_val() == value;}
inline bool is_true_value(const char * value) { return !is_firm_value(value);}
inline bool is_euro_value(const char * value) { return (value && *value) ? TCurrency::get_euro_val() == value : TCurrency::get_euro_val() == TCurrency::get_firm_val();}
bool same_values(const char * valuea, const char * valueb);
#endif #endif

View File

@ -79,6 +79,7 @@ ITEM M_EDIT_QUIT "Chiudi\tESC+ESC"
MENU MENU_VISWIN_EDIT MENU MENU_VISWIN_EDIT
ITEM M_EDIT_COPY "~Copia" DISABLED ITEM M_EDIT_COPY "~Copia" DISABLED
ITEM M_EDIT_CLEAR "~Annulla" DISABLED ITEM M_EDIT_CLEAR "~Annulla" DISABLED
SEPARATOR SEPARATOR
ITEM M_EDIT_SEARCH "Cerca...\tF7" ITEM M_EDIT_SEARCH "Cerca...\tF7"
ITEM M_EDIT_DELETE "Cerca il prossimo\tF8" DISABLED ITEM M_EDIT_DELETE "Cerca il prossimo\tF8" DISABLED

8
include/deftabap.h Executable file
View File

@ -0,0 +1,8 @@
#ifndef __DEFTABAP_H
#define __DEFTABAP_H
#define GR_SEARCH 29
#define GR_MODIFY_PROTECTED 30
#define GR_RECORD_PROTECTED 31
#endif

View File

@ -567,9 +567,9 @@ int TFile_text::write(TRecord_text& rec)
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
TTracciato_campo& tc = tr.get(i); TTracciato_campo& tc = tr.get(i);
campo = format_textfield(tc, rec.row(i)); campo = rec.row(i);
buffer.insert(campo, tc.position()); format_textfield(tc, campo);
campo.cut(0); buffer.overwrite(campo, tc.position());
} }
CHECK(_write_file, "Impossibile scrivere su un file chiuso."); CHECK(_write_file, "Impossibile scrivere su un file chiuso.");
if (_recordsize<=0) if (_recordsize<=0)

View File

@ -67,7 +67,7 @@ public:
const TString& message() const {return _message;} const TString& message() const {return _message;}
void set_name(const TString& name) {_name = name;} void set_name(const TString& name) {_name = name;}
void set_datatype(const char type) {_datatype = type;} void set_datatype(const char type) {_datatype = type;}
void set_type(const TString& type) {_type = type;} void set_type(const char* type) {_type = type;}
void set_field(const TFieldref& field) {_field = field;} void set_field(const TFieldref& field) {_field = field;}
void set_ftype(const TString& type) {_ftype = type;} void set_ftype(const TString& type) {_ftype = type;}
void set_position(const int position) {_position = position;} void set_position(const int position) {_position = position;}

View File

@ -1257,13 +1257,19 @@ void TForm_number::put_paragraph(const char* s)
void TForm_number::real2currency(const real& r, TString& str) const void TForm_number::real2currency(const real& r, TString& str) const
{ {
TCurrency c(r, "_FIRM"); TCurrency c(r);
c.set_price(_flag.price != 0); c.set_price(_flag.price != 0);
const TExchange& oe = form().output_exchange();
if (!c.get_exchange().same_value_as(oe))
c.change_value(oe);
const TString& pic = picture(); const TString& pic = picture();
const int piclen = pic.len();
const bool dotted = pic.empty() || pic.find('.') >= 0; const bool dotted = pic.empty() || pic.find('.') >= 0;
str = c.string(dotted); str = c.string(dotted);
const int w = width(); const int w = width();
if (w > pic.len()) if (w > piclen)
str.right_just(w); str.right_just(w);
} }
@ -1400,6 +1406,7 @@ protected: // TForm_string
virtual bool parse_head(TScanner& scanner); virtual bool parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual bool update(); virtual bool update();
virtual const char* get() const;
// @cmember Manda il messaggio al campo <p dest> // @cmember Manda il messaggio al campo <p dest>
virtual void send_message(const TString& cmd, TForm_item& dest) const; virtual void send_message(const TString& cmd, TForm_item& dest) const;
public: public:
@ -1432,9 +1439,15 @@ TObject* TForm_currency::dup() const
return fn; return fn;
} }
const char* TForm_currency::get() const
{
const char* val = TForm_string::get();
return val;
}
TCurrency TForm_currency::get_currency() const TCurrency TForm_currency::get_currency() const
{ {
const TString& codval = _driver ? _driver->get() : form().get_curr_codval(); const TString& codval = _driver ? _driver->get() : form().get_curr_codval();
const real n(get()); const real n(get());
return TCurrency(n, codval, ZERO, _exchange_undefined, _flag.price != 0); return TCurrency(n, codval, ZERO, _exchange_undefined, _flag.price != 0);
} }
@ -1452,19 +1465,64 @@ bool TForm_currency::update()
if (!real::is_null(get())) if (!real::is_null(get()))
{ {
const TCurrency curr = get_currency(); TCurrency curr = get_currency();
if (!_driver)
{
const TExchange& oe = form().output_exchange();
if (!curr.get_exchange().same_value_as(oe))
curr.change_value(oe);
}
// Niente apply_format(), la picture viene ignorata per i TForm_currency // Niente apply_format(), la picture viene ignorata per i TForm_currency
const bool dotted = picture().empty() || picture().find('.') >= 0; const TString& pic = picture();
const bool dotted = pic.empty() || pic.find('.') > 0;
TString80 v(curr.string(dotted)); TString80 v = curr.string(dotted);
if (pic.right(3) == "^^^") // 770 only: to be improved
{
const int dec = curr.decimals();
if (dec == 0)
v.rtrim(3+dotted);
else
v.rtrim(dec+1);
}
const int w = width() - (_section->columnwise() ? _prompt.len() : 0); const int w = width() - (_section->columnwise() ? _prompt.len() : 0);
if (w > v.len()) if (w > v.len())
v.right_just(w); v.right_just(w);
put_paragraph(v); put_paragraph(v);
} }
else else
put_paragraph(""); {
const TString& pic = picture();
if (pic.right(1)[0] == '@')
{
TString80 v;
const int w = width() - (_section->columnwise() ? _prompt.len() : 0);
int d = 0;
if (_driver)
{
const TCurrency z(ZERO, _driver->get(), ZERO, _exchange_base, _flag.price != 0);
d = z.decimals();
}
else
{
const TCurrency z(ZERO, form().output_exchange(), _flag.price != 0);
d = z.decimals();
}
if (d > 0)
{
v.format("%*.*lf", w, d, 0.0);
v.replace('.', ',');
}
else
v.format("%*d", w, 0);
put_paragraph(v);
}
else
put_paragraph("");
}
} }
return TRUE; return TRUE;
@ -1483,7 +1541,7 @@ void TForm_currency::send_message(const TString& cmd, TForm_item& dest) const
else else
total = ((TForm_currency&)dest).get_currency(); total = ((TForm_currency&)dest).get_currency();
total += get_currency(); total += get_currency();
dest.set(total.string()); dest.set(total.get_num().string());
} }
else else
TForm_number::send_message(cmd, dest); TForm_number::send_message(cmd, dest);
@ -2692,7 +2750,9 @@ bool TForm::parse_general(TScanner &scanner)
_npages=scanner.integer(); _npages=scanner.integer();
if (scanner.key() == "VA") // Valuta/Divisa impiegata if (scanner.key() == "VA") // Valuta/Divisa impiegata
_curr_codval=scanner.string(); {
_curr_codval=scanner.string(); // DA ELIMINARE
}
extended_parse_general(scanner); // Parse non-standard parameters extended_parse_general(scanner); // Parse non-standard parameters
} }
@ -3431,12 +3491,14 @@ bool TForm::genera_intestazioni(
p = prompts.get(c); p = prompts.get(c);
switch (align) switch (align)
{ {
case 'c': case 'c':
p.center_just(fi.width()); p.center_just(fi.width());
break; break;
case 'r': case 'r':
p.right_just(fi.width()); p.right_just(fi.width());
break; break;
default:
break;
} }
s = new TForm_string(header); s = new TForm_string(header);
s->id() = -1; s->id() = -1;
@ -4587,6 +4649,11 @@ int TForm::matches_done(int file)
return 0; return 0;
} }
void TForm::set_output_exchange(const char* codval, real exchange, exchange_type et)
{
_exchange.set(codval, exchange, et);
}
TForm::TForm() TForm::TForm()
{ {
init(); init();

View File

@ -147,13 +147,15 @@ class TForm : public TObject
int _editlevel; int _editlevel;
// @cmember:(INTERNAL) Descrizione del formato // @cmember:(INTERNAL) Descrizione del formato
TString _desc; TString _desc;
// @cmember:(INTERNAL) Descrizione divisa impiegata per stampa prezzi ed importi
TString16 _curr_codval;
// @cmember:(INTERNAL) Array di caratteri di fincatura // @cmember:(INTERNAL) Array di caratteri di fincatura
TString16 _fink; TString16 _fink;
// @cmember:(INTERNAL) Numero iniziale di pagina // @cmember:(INTERNAL) Numero iniziale di pagina
word _frompage,_topage; word _frompage,_topage;
// @cmember:(INTERNAL) Codice divisa impiegata per stampa prezzi ed importi
TString16 _curr_codval;
// @cmember:(INTERNAL) Cambio da applicare in output per stampa prezzi ed importi
TExchange _exchange;
// @cmember:(INTERNAL) Handler di default della testata di stampa // @cmember:(INTERNAL) Handler di default della testata di stampa
static void header_handler(TPrinter& p); static void header_handler(TPrinter& p);
// @cmember:(INTERNAL) Handler di default del piede di stampa // @cmember:(INTERNAL) Handler di default del piede di stampa
@ -329,6 +331,9 @@ public:
const bool magic_currency() const const bool magic_currency() const
{ return _magic_currency; } { return _magic_currency; }
void set_output_exchange(const char* codval, real exchange = ZERO, exchange_type et = _exchange_undefined);
const TExchange& output_exchange() const { return _exchange; }
void enable_message_add(bool on) { _msg_add_enabled = on; } void enable_message_add(bool on) { _msg_add_enabled = on; }
void disable_message_add() { enable_message_add(FALSE); } void disable_message_add() { enable_message_add(FALSE); }
bool message_add_enabled() const { return _msg_add_enabled; } bool message_add_enabled() const { return _msg_add_enabled; }

View File

@ -12,6 +12,7 @@
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <window.h> #include <window.h>
#include <limits.h>
#include <mapi.h> #include <mapi.h>
#include <shellapi.h> #include <shellapi.h>
@ -1085,6 +1086,22 @@ TMAPI_session::~TMAPI_session()
// TMail_message // TMail_message
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
int TMail_message::add_line(const char* s)
{
const long len = (s && *s) ? strlen(s) : 0;
int n = items() - 1;
if (n < 0 || (long(row(n).len()) + len) > 30000L)
n = TString_array::add("");
TString & line = row(n);
line << s;
if (line.right(1) != "\n")
line << '\n';
return n;
}
bool TMail_message::send(TMAPI_session& lhSession, bool hide_ui) bool TMail_message::send(TMAPI_session& lhSession, bool hide_ui)
{ {
const int MAX_RECIPIENTS = _recipients.items() + _copy_recipients.items() + 1; const int MAX_RECIPIENTS = _recipients.items() + _copy_recipients.items() + 1;
@ -1117,15 +1134,28 @@ bool TMail_message::send(TMAPI_session& lhSession, bool hide_ui)
FOR_EACH_ARRAY_ROW(_attachments, att, attachment) FOR_EACH_ARRAY_ROW(_attachments, att, attachment)
{ {
TString80 tmp; tmp.spaces(32); TString80 tmp; tmp.spaces(32);
*this << '\n' << tmp; this-> row(0) << tmp;
msgAttachment[na].nPosition = len()-1; msgAttachment[na].nPosition = row(0).len()-1;
msgAttachment[na].lpszPathName = attachment->get_buffer(); msgAttachment[na].lpszPathName = attachment->get_buffer();
na++; na++;
} }
MapiMessage msgSend; MapiMessage msgSend;
memset(&msgSend, 0, sizeof(MapiMessage)); memset(&msgSend, 0, sizeof(MapiMessage));
msgSend.lpszNoteText = empty() ? NULL : get_buffer();
long tot = 0;
for (int i = 0; i < items(); i++)
tot += row(i).len();
char * buffer = new char[tot + 1];
long b = 0;
for (i = 0; i < items(); i++)
{
strcpy(&buffer[b], row(i));
b += row(i).len();
}
buffer[b] = '\0';
msgSend.lpszNoteText = buffer;
msgSend.lpszSubject = _subject.empty() ? NULL : _subject.get_buffer(); msgSend.lpszSubject = _subject.empty() ? NULL : _subject.get_buffer();
msgSend.nRecipCount = nr; msgSend.nRecipCount = nr;
msgSend.lpRecips = nr == 0 ? NULL : msgRecipient; msgSend.lpRecips = nr == 0 ? NULL : msgRecipient;
@ -1133,7 +1163,8 @@ bool TMail_message::send(TMAPI_session& lhSession, bool hide_ui)
msgSend.lpFiles = na == 0 ? NULL : msgAttachment; msgSend.lpFiles = na == 0 ? NULL : msgAttachment;
bool ok = lhSession.send(msgSend, hide_ui ? 0 : MAPI_DIALOG); bool ok = lhSession.send(msgSend, hide_ui ? 0 : MAPI_DIALOG);
delete buffer;
delete msgRecipient; delete msgRecipient;
delete msgAttachment; delete msgAttachment;
@ -1214,9 +1245,11 @@ const TString& TMail_message::recipient(int n) const
TMail_message::TMail_message(const char* recipient, const char* subject, TMail_message::TMail_message(const char* recipient, const char* subject,
const char* text, const char* sender) const char* text, const char* sender)
: TString(text), _subject(subject), _sender(sender), _hms(0) : _subject(subject), _sender(sender), _hms(0)
{ {
add_recipient(recipient); add_recipient(recipient);
if (text && *text)
add(text);
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1232,6 +1265,7 @@ int TMail_messages::get(const char* senderFilter,
bool attach, bool mark) bool attach, bool mark)
{ {
TMAPI_session lhSession; TMAPI_session lhSession;
destroy();
if (!lhSession.open()) if (!lhSession.open())
return 0; return 0;

View File

@ -15,7 +15,7 @@ bool print_url(const char* url);
class TMAPI_session; class TMAPI_session;
class TMail_message : public TString class TMail_message : public TString_array
{ {
TString_array _recipients, _copy_recipients, _attachments; TString_array _recipients, _copy_recipients, _attachments;
TString _subject; TString _subject;
@ -38,9 +38,10 @@ public:
bool attach(const char* filename) { return add_recipient_ex(filename, 2); } bool attach(const char* filename) { return add_recipient_ex(filename, 2); }
void set_sender(const char* address) { _sender = address; _sender.trim(); } void set_sender(const char* address) { _sender = address; _sender.trim(); }
void set_id(const char* id) { _id = id; } void set_id(const char* id) { _id = id; }
int add_line(const char * s);
TString& operator = (const char* msg) { set(msg); return *this; } TMail_message& operator = (const char* msg) { destroy(); add(msg); return *this; }
TString& operator = (const TString& msg) { set(msg); return *this; } TMail_message& operator = (const TString& msg) { destroy(); add(msg); return *this; }
bool send(bool hide_ui = FALSE); bool send(bool hide_ui = FALSE);
bool remove(); bool remove();

View File

@ -927,7 +927,7 @@ int TBaseisamfile::skip(TRecnotype nrec, word lockop)
message_box("Codice %s in uso da parte\ndi un altro utente.\nSkipping", (const char*)key); message_box("Codice %s in uso da parte\ndi un altro utente.\nSkipping", (const char*)key);
_lasterr = cisread(fhnd, getkey(), curr(),_iscurr + lockop, _recno); _lasterr = cisread(fhnd, getkey(), curr(),_iscurr + lockop, _recno);
} }
_recno = _isamfile->RecNo = DB_recno(fhnd); _recno = DB_recno(fhnd);
if (curr().has_memo()) if (curr().has_memo())
curr().init_memo(_recno, _isam_handle); curr().init_memo(_recno, _isam_handle);
@ -942,6 +942,7 @@ int TBaseisamfile::_read(TRectype& rec, word op, word lockop)
_lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno); _lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno);
_recno = DB_recno(fhnd);
if(rec.has_memo()) if(rec.has_memo())
rec.init_memo(_recno, _isam_handle); rec.init_memo(_recno, _isam_handle);
@ -2503,22 +2504,23 @@ int TSystemisamfile::dump(
if (nkey) if (nkey)
{ {
setkey(nkey); setkey(nkey);
bool skip = FALSE;
for ( first(); status() == NOERR && !p.iscancelled(); next(), i++) for ( first(); status() == NOERR && !p.iscancelled(); next(), i++)
{ {
p.setstatus(i + 1); p.setstatus(i + 1);
if (filter) if (filter && *filter)
{ {
TToken_string filter_str(filter); TToken_string filter_str(filter);
TString fname, fval; TString16 fname;
skip = FALSE; bool skip = FALSE;
while (!skip && !(fname=filter_str.get()).empty()) while (!skip && !(fname=filter_str.get()).empty())
{ {
fval=filter_str.get(); const char* fval = filter_str.get();
skip = fval != get(fname); const TString& cmp = get(fname);
skip = cmp != fval;
} }
if (skip)
continue;
} }
if (skip) continue;
s = ""; s = "";
for (j = 0; j < nflds; j++) for (j = 0; j < nflds; j++)
{ {
@ -2558,6 +2560,22 @@ int TSystemisamfile::dump(
zero(); zero();
p.setstatus(i + 1); p.setstatus(i + 1);
readat(i + 1); readat(i + 1);
if (filter && *filter)
{
TToken_string filter_str(filter);
TString16 fname;
bool skip = FALSE;
while (!skip && !(fname=filter_str.get()).empty())
{
const char* fval = filter_str.get();
const TString& cmp = get(fname);
skip = cmp != fval;
}
if (skip)
continue;
}
s=""; s="";
if (withdeleted || curr().valid()) if (withdeleted || curr().valid())
{ {
@ -2637,6 +2655,7 @@ void TMemo_data::copy(const TMemo_data& m)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// TRectype // TRectype
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void TRectype::init(int logicnum) void TRectype::init(int logicnum)
{ {
_logicnum = logicnum; _logicnum = logicnum;
@ -2734,7 +2753,7 @@ TRectype::TRectype(const TRectype& r)
{ {
if (r._memo_data) if (r._memo_data)
{ {
init_memo(r._memo_recno, r._memo_data->file()); // qui init_memo(r._memo_data->recno(), r._memo_data->file());
*_memo_data = *r._memo_data; *_memo_data = *r._memo_data;
} }
_length = r.len(); _length = r.len();
@ -2755,14 +2774,16 @@ TRectype::~TRectype()
void TRectype::unknown_field(const char* name) const void TRectype::unknown_field(const char* name) const
{ {
NFCHECK("Il campo '%s' non appartiene al file %d", name, _logicnum); static int last_file = 0;
if (_logicnum != last_file)
{
NFCHECK("Il campo '%s' non appartiene al file %d", name, _logicnum);
last_file = _logicnum;
}
} }
void TRectype::write_memo(TIsam_handle file, const TRecnotype recno) void TRectype::write_memo(TIsam_handle file, const TRecnotype recno)
{ {
CHECK( _memo_recno > 0, "Maiale! Non fare le GO con _recno < 0 " );
TCodeb_handle cb_handle = prefix().get_handle(file);
DB_go( cb_handle, _memo_recno );
const RecDes *r = rec_des( ); const RecDes *r = rec_des( );
TIsam_handle orig = _memo_data->file(); TIsam_handle orig = _memo_data->file();
if (orig && (fhnd != orig || recno != _memo_data->recno())) if (orig && (fhnd != orig || recno != _memo_data->recno()))
@ -2783,6 +2804,10 @@ void TRectype::write_memo(TIsam_handle file, const TRecnotype recno)
} }
} }
} }
CHECK( _memo_recno > 0, "Maiale! Non fare le GO con _recno < 0 " );
TCodeb_handle cb_handle = prefix().get_handle(file);
DB_go( cb_handle, _memo_recno );
for( int i = _memo_data->last( ); i > 0; i = _memo_data->pred( i ) ) for( int i = _memo_data->last( ); i > 0; i = _memo_data->pred( i ) )
{ {
if (_memo_data->is_dirty(i)) if (_memo_data->is_dirty(i))
@ -3051,7 +3076,7 @@ const TString& TRectype::get(const char* fieldname) const
const int index = findfld(recd, fieldname); const int index = findfld(recd, fieldname);
if ( _memo_data->objptr( index )) if ( _memo_data->objptr( index ))
return _memo_data->row( index ); return _memo_data->row( index );
if( _memo_recno >= 0L ) if(_memo_data->recno() >= 0L)
{ {
int orig = _memo_data->file(); int orig = _memo_data->file();
if (orig) if (orig)
@ -3180,6 +3205,13 @@ void TRectype::put(const char* fieldname, word val)
void TRectype::put(const char* fieldname, const real& val) void TRectype::put(const char* fieldname, const real& val)
{ {
put_str( fieldname, val.string()); put_str( fieldname, val.string());
setempty(FALSE);
}
void TRectype::put(const char* fieldname, const TCurrency& val)
{
put_str( fieldname, val.get_num().string());
setempty(FALSE);
} }
void TRectype::put(const char* fieldname, const TDate& val) void TRectype::put(const char* fieldname, const TDate& val)

View File

@ -3,8 +3,8 @@
#ifndef FOXPRO #ifndef FOXPRO
#ifndef __REAL_H #ifndef __CURRENCY_H
#include <real.h> #include <currency.h>
#endif #endif
#endif #endif
@ -205,6 +205,8 @@ public:
void put(const char* fieldname, bool val); void put(const char* fieldname, bool val);
// @cmember Setta il contenuto del campo <p fieldname> in formato reale // @cmember Setta il contenuto del campo <p fieldname> in formato reale
void put(const char* fieldname, const real& val); void put(const char* fieldname, const real& val);
// @cmember Setta il contenuto del campo <p fieldname> in formato valuta
void put(const char* fieldname, const TCurrency& val);
// @cmember Setta il contenuto del campo <p fieldname> in formato memo // @cmember Setta il contenuto del campo <p fieldname> in formato memo
void put(const char* fieldname, TTextfile& txt); void put(const char* fieldname, TTextfile& txt);
// @cmember Setta il contenuto del campo <p fieldname> (non tipizzata) // @cmember Setta il contenuto del campo <p fieldname> (non tipizzata)
@ -487,6 +489,9 @@ public:
// @cmember Setta il contenuto del campo <p fieldname> di tipo real // @cmember Setta il contenuto del campo <p fieldname> di tipo real
void put(const char* fieldname, const real& val) void put(const char* fieldname, const real& val)
{ curr().put(fieldname, val);} { curr().put(fieldname, val);}
// @cmember Setta il contenuto del campo <p fieldname> di tipo valuta
void put(const char* fieldname, const TCurrency& val)
{ curr().put(fieldname, val);}
// @cmember Setta il contenuto del campo <p fieldname> di tipo memo (vedi <mf TRectype::put_memo>) // @cmember Setta il contenuto del campo <p fieldname> di tipo memo (vedi <mf TRectype::put_memo>)
void put(const char* fieldname, TTextfile& txt) void put(const char* fieldname, TTextfile& txt)
{ curr().put(fieldname, txt); } { curr().put(fieldname, txt); }

View File

@ -144,8 +144,16 @@
#define LF_RINTRA 134 #define LF_RINTRA 134
#define LF_RIEPRETT 135 #define LF_RIEPRETT 135
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals #define LF_AMMCE 136
#define LF_AMMMV 137
#define LF_CATDI 138
#define LF_CESPI 139
#define LF_COLLCES 140
#define LF_MOVAM 141
#define LF_MOVCE 142
#define LF_SALCE 143
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
#define CNF_GENERAL 10000 #define CNF_GENERAL 10000
#define CNF_STUDIO CNF_GENERAL + 1 #define CNF_STUDIO CNF_GENERAL + 1
#define CNF_DITTA CNF_GENERAL + 2 #define CNF_DITTA CNF_GENERAL + 2

6
include/mainmenu.url Executable file
View File

@ -0,0 +1,6 @@
MENUBAR TASK_MENUBAR
MENU TASK_MENUBAR
SUBMENU M_FILE "~File"
/* SUBMENU M_EDIT "~Modifica" Unsupported! */
SUBMENU M_HELP "~Help"

View File

@ -498,9 +498,25 @@ bool TMask::check_fields()
} }
void TMask::check_field( short fld_id ) void TMask::check_field( short fld_id )
{ {
field(fld_id).on_hit(); if (fld_id <= 0)
field(fld_id).check(); {
const int gr = -fld_id;
for (int i = fields()-1; i >= 0; i--)
{
TMask_field& f = fld(i);
if (gr == 0 || f.in_group(gr))
{
f.on_hit();
f.check();
}
}
}
else
{
field(fld_id).on_hit();
field(fld_id).check();
}
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -1092,12 +1108,20 @@ TDate TMask::get_date(short fld_id) const
return TDate(s); return TDate(s);
} }
TCurrency& TMask::get_currency(short fld_id, TCurrency& curr) const TCurrency& TMask::get_currency(short fld_id, TCurrency& c) const
{ {
const TMask_field& f = field(fld_id); const TMask_field& cf = field(fld_id);
CHECKD(f.is_kind_of(CLASS_CURRENCY_FIELD), "Not a currency field ", fld_id); if (cf.class_id() == CLASS_CURRENCY_FIELD)
const TCurrency_field& cf = (const TCurrency_field&)f; {
return cf.get_currency(curr); ((TCurrency_field&)cf).get_currency(c);
}
else
{
real n = cf.get();
c.force_value("");
c.set_num(n);
}
return c;
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -1141,13 +1165,13 @@ void TMask::set(short fld_id, const TDate& d, bool hit)
set(fld_id, d.string(), hit); set(fld_id, d.string(), hit);
} }
void TMask::set(short fld_id, const TCurrency& c, bool hit) void TMask::set(short fld_id, const TCurrency& n, bool hit)
{ {
CHECK(field(fld_id).is_kind_of(CLASS_CURRENCY_FIELD), "Can't set a currency in a non-currency field"); CHECK(field(fld_id).is_kind_of(CLASS_CURRENCY_FIELD), "Can't set a currency in a non-currency field");
((TCurrency_field&)field(fld_id)).set(c, hit); // CHECK(id2pos(fld_id) < 0 || field(fld_id).is_edit(), "Can't set a currency in a non edit field");
set(fld_id, n.get_num().string(), hit);
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Permette di attivare/disattivare tutta la pagina // @mfunc Permette di attivare/disattivare tutta la pagina

View File

@ -176,6 +176,13 @@ void TMask_field::set_focus() const
#endif #endif
} }
void TMask_field::set_justify(bool r)
{
_flags.rightjust = r;
if (_ctl)
_ctl->set_rjust(r);
}
// @doc INTERNAL // @doc INTERNAL
// Certified 100% // Certified 100%
@ -613,6 +620,10 @@ void TText_field::create(WINDOW parent)
// TGroup_field // TGroup_field
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Certified 100%
word TGroup_field::class_id() const
{ return CLASS_GROUPBOX_FIELD; }
TGroup_field::TGroup_field(TMask* mask) : TMask_field(mask) TGroup_field::TGroup_field(TMask* mask) : TMask_field(mask)
{ {
_flags.persistent = TRUE; _flags.persistent = TRUE;
@ -2142,7 +2153,7 @@ void TBrowse::do_output(CheckTime t)
TMask_field& f = field(id); TMask_field& f = field(id);
flds = _out_fn.get(); flds = _out_fn.get();
if (t != STARTING_CHECK || f.field() == NULL || f.mask().mode() == MODE_INS) if (t != STARTING_CHECK || f.field() == NULL || (f.mask().mode() == MODE_INS && !f.in_key(0)))
{ {
sum.cut(0); sum.cut(0);
for(const char* fr = flds.get(0); fr; fr = flds.get()) for(const char* fr = flds.get(0); fr; fr = flds.get())
@ -3152,6 +3163,7 @@ const char* TEdit_field::reformat(const char* str) const
TString& s = _ctl_data._park; TString& s = _ctl_data._park;
s = str; s = str;
const byte trim_mode = _flags.trim; const byte trim_mode = _flags.trim;
smart_trim(s, trim_mode); smart_trim(s, trim_mode);
if (s.not_empty()) if (s.not_empty())
@ -3175,7 +3187,10 @@ const char* TEdit_field::reformat(const char* str) const
for (const char * w = (const char *) s; *w == '0'; w++) ; for (const char * w = (const char *) s; *w == '0'; w++) ;
if (*w == '\0') if (*w == '\0')
s.cut(0); s.cut(0);
} }
if (_flags.rightjust && !(trim_mode & 1) && !s.blank())
s.right_just(size());
if (_flags.uppercase) if (_flags.uppercase)
s.upper(); s.upper();
@ -4042,10 +4057,8 @@ const char* TCurrency_field::raw2win(const char* data) const
const real num = data; const real num = data;
if (num == ZERO) if (num == ZERO)
return ""; return "";
const char* value = NULL;
const TMask_field* d0 = driver(0); const TMask_field* d0 = driver(0);
if (d0) const char* value = d0 ? (const char*)d0->get() : NULL;
value = d0->get();
const bool price = _flags.uppercase != 0; const bool price = _flags.uppercase != 0;
TCurrency cur(num, value, ZERO, _exchange_undefined, price); TCurrency cur(num, value, ZERO, _exchange_undefined, price);
@ -4085,12 +4098,17 @@ const char* TCurrency_field::win2raw(const char* data) const
num = e.as_real(); num = e.as_real();
} }
else else
num = real(str); num = real::ita2eng(str);
if (num.is_zero()) if (num.is_zero())
str.cut(0); str.cut(0);
else else
str = num.string(); {
const TMask_field* d0 = driver(0);
const char* value = d0 ? (const char*)d0->get() : NULL;
const bool price = _flags.uppercase != 0;
TCurrency cur(num, value, ZERO, _exchange_undefined, price);
str = cur.get_num().string();
}
return str; return str;
} }

View File

@ -179,8 +179,7 @@ public:
{ _flags.trim = byte(t ? 3 : 0); } { _flags.trim = byte(t ? 3 : 0); }
// @cmember Setta la giustificazione a destra del campo // @cmember Setta la giustificazione a destra del campo
void set_justify(bool r) void set_justify(bool r);
{ _flags.rightjust = r; }
// @cmember Verifica la giustificazione a destra del campo // @cmember Verifica la giustificazione a destra del campo
bool right_justified() const bool right_justified() const
@ -421,7 +420,9 @@ protected:
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
// @access Public Member // @access Public Member
public: public:
virtual word class_id() const;
// @cmember Costruttore // @cmember Costruttore
TGroup_field(TMask* mask); TGroup_field(TMask* mask);
virtual ~TGroup_field() {} virtual ~TGroup_field() {}

View File

@ -500,6 +500,7 @@ TSpreadsheet::TSpreadsheet(
int num; int num;
XI_OBJ** column = xi_get_member_list(_obj, &num); XI_OBJ** column = xi_get_member_list(_obj, &num);
memset(_default_width, 0, sizeof(_default_width));
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
RCT rct; xi_get_rect(column[i], (XinRect *) &rct); RCT rct; xi_get_rect(column[i], (XinRect *) &rct);
@ -979,8 +980,8 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{ {
const real r(src); // Memorizzo valore numerico const real r(src); // Memorizzo valore numerico
const int pos = driver->dlg() - FIRST_FIELD; const int pos = driver->dlg() - FIRST_FIELD;
TString16 codval = rowrec.get(pos); // Codice valuta const TString16 codval = rowrec.get(pos); // Codice valuta
const TCurrency c(r, codval, ZERO, _exchange_undefined, driver->uppercase()); const TCurrency c(r, codval, ZERO, _exchange_undefined, e->uppercase());
src = c.string(TRUE); src = c.string(TRUE);
break; break;
} }
@ -1066,7 +1067,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{ {
if (xiev->v.xi_obj->type == XIT_LIST) // Bottone dello sheet if (xiev->v.xi_obj->type == XIT_LIST) // Bottone dello sheet
{ {
// if (test_focus_change()) if (test_focus_change())
{ {
int rec = -1; int rec = -1;
_cell_dirty = FALSE; _cell_dirty = FALSE;
@ -1392,7 +1393,8 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (rec < items()) if (rec < items())
str2mask(rec); str2mask(rec);
notify(rec, K_CTRL+K_DEL); // Notifica l'avvenuta cancellazione notify(rec, K_CTRL+K_DEL); // Notifica l'avvenuta cancellazione
set_dirty(); set_dirty(); // Setta il flag sheet modificato
_row_dirty = _cell_dirty = FALSE; // Resetta i flag di modifica appena settati di riflesso
if (rec >= items()) if (rec >= items())
rec = items() - 1; rec = items() - 1;
if (rec >= 0) if (rec >= 0)
@ -2061,8 +2063,8 @@ void TSpreadsheet::set_columns_order(TToken_string* order)
if (order == NULL) if (order == NULL)
{ {
int idx=0; int next_pos = 0;
for (int index = 0; index < num_cols; index++) for (int index = 0; _default_width[index] > 0; index++)
{ {
const short cid = index ? FIRST_FIELD + index - 1 : 0; const short cid = index ? FIRST_FIELD + index - 1 : 0;
XI_OBJ* col = cid ? find_column(cid) : column[0]; XI_OBJ* col = cid ? find_column(cid) : column[0];
@ -2071,9 +2073,10 @@ void TSpreadsheet::set_columns_order(TToken_string* order)
if (index >= fixed) if (index >= fixed)
{ {
const int cur_pos = xi_obj_to_idx(col); const int cur_pos = xi_obj_to_idx(col);
if (cur_pos != index) if (cur_pos != next_pos)
xi_move_column(col, index); xi_move_column(col, next_pos);
} }
next_pos++;
RCT rct; xi_get_rect(col, (XinRect *) &rct); RCT rct; xi_get_rect(col, (XinRect *) &rct);
if (_default_width[index] != rct.right - rct.left) if (_default_width[index] != rct.right - rct.left)
@ -2090,13 +2093,17 @@ void TSpreadsheet::set_columns_order(TToken_string* order)
{ {
const int cid = col.get_int(0); const int cid = col.get_int(0);
const int width = col.get_int(); const int width = col.get_int();
XI_OBJ* column = find_column(cid); XI_OBJ* col = cid ? find_column(cid) : column[0];
if (column) // Controlla che esista ancora if (col) // Controlla che esista ancora
{ {
if (pos >= fixed && pos < num_cols) if (pos >= fixed && pos < num_cols)
xi_move_column(column, pos); // Sposta la colonna {
const int cur_pos = xi_obj_to_idx(col);
if (cur_pos != pos)
xi_move_column(col, pos); // Sposta la colonna
}
if (width > XI_FU_MULTIPLE) // Se ha una larghezza valida if (width > XI_FU_MULTIPLE) // Se ha una larghezza valida
xi_column_set_pixel_width(column, width - offset); xi_column_set_pixel_width(col, width - offset);
} }
} }
_save_columns_order = FALSE; _save_columns_order = FALSE;

View File

@ -243,14 +243,16 @@ void TMultiple_rectype::synchronize_bodies()
if (_nuovo) if (_nuovo)
{ {
TRecord_array * b = (TRecord_array *) _files.objptr(i); TRecord_array * b = (TRecord_array *) _files.objptr(i);
if (b != NULL) if (b == NULL)
{ {
_changed.reset(i); b = new TRecord_array(_logicnums[i], (TString &) _numfields[i]);
b->destroy_rows(); _files.add(b, i);
TRectype * r = new_body_record(lognum(i));
set_body_key(*r);
b->set_key(r);
} }
_changed[i] = FALSE;
b->destroy_rows();
TRectype * r = new_body_record(_logicnums[i]);
set_body_key(*r);
b->set_key(r);
} }
else else
{ {

View File

@ -548,7 +548,7 @@ TConnection* TSocketClient::OnQueryConnection(const char* service,
BOOL TSocketClient::Execute(DWORD id, const char* cmd) BOOL TSocketClient::Execute(DWORD id, const char* cmd)
{ {
BOOL ok = cur_socket->is_open(); BOOL ok = cur_socket != NULL && cur_socket->is_open();
if (ok) if (ok)
{ {
const int buflen = strlen(cmd)+1; const int buflen = strlen(cmd)+1;
@ -619,7 +619,7 @@ BOOL TSocketClient::ReadLine(DWORD, TString& str)
BOOL TSocketClient::HttpGetFile(const char* remote, const char* local) BOOL TSocketClient::HttpGetFile(const char* remote, const char* local)
{ {
if (!cur_socket->is_open()) if (cur_socket == NULL || !cur_socket->is_open())
return FALSE; return FALSE;
BOOL ok = FALSE; BOOL ok = FALSE;

View File

@ -9,7 +9,8 @@
#include <strings.h> #include <strings.h>
#endif #endif
enum os_type { os_Unknown, os_Windows, os_Win32s, os_Windows95, os_Windows98, os_WindowsNT }; enum os_type { os_Unknown, os_Windows, os_Windows95, os_Windows98,
os_WindowsME, os_WindowsNT, os_Windows2000 };
os_type os_get_type(); os_type os_get_type();
void os_post_menu_event(WINDOW win, MENU_TAG tag); void os_post_menu_event(WINDOW win, MENU_TAG tag);

View File

@ -438,17 +438,26 @@ bool os_get_image_editor_path(TFilename& name)
os_type os_get_type() os_type os_get_type()
{ {
const WORD winver = LOWORD(GetVersion());
const BYTE majver = LOBYTE(winver);
const BYTE minver = HIBYTE(winver);
if (majver > 3 || (majver == 3 && minver > 11))
{
return minver > 95 ? os_Windows98 : os_Windows95;
}
const DWORD winflags = GetWinFlags(); const DWORD winflags = GetWinFlags();
if (winflags & 0x4000) if (winflags & 0x4000)
return os_WindowsNT; return os_WindowsNT;
const DWORD osver = GetVersion();
const DWORD winver = LOWORD(osver);
const BYTE majwinver = LOBYTE(winver);
const BYTE minwinver = HIBYTE(winver);
if (majwinver == 3 && minwinver == 95)
{
const DWORD dosver = HIWORD(osver);
const BYTE majdosver = LOBYTE(dosver); // Should be 7 anyway
const BYTE mindosver = HIBYTE(dosver);
return (majdosver > 7 || (majdosver == 7 && mindosver >= 10)) ? os_Windows98 : os_Windows95;
}
else
{
if (majwinver == 4)
return os_WindowsME;
}
return os_Windows; return os_Windows;
} }

View File

@ -39,7 +39,7 @@ TRecipient::TRecipient(const TToken_string& str)
void TRecipient::add_expr(char op, const TString& expr) void TRecipient::add_expr(char op, const TString& expr)
{ {
if (_expr.not_empty()) if (_expr.not_empty())
_expr << (op == 'A' ? "AND" : "OR"); _expr << (op == 'A' ? "&&" : "||");
if (expr.blank()) if (expr.blank())
_expr << 1; _expr << 1;
@ -135,7 +135,7 @@ bool TPostman::can_dispatch_transaction(const TRectype& rec)
_recipient.destroy(); _recipient.destroy();
TConfig cfg(CONFIG_DITTA, "MailTransactions"); TConfig cfg(CONFIG_DITTA, "MailTransactions");
TToken_string str; TAuto_token_string str;
TString addr, opr, expr; TString addr, opr, expr;
// Costruisce la lista dei destinatari // Costruisce la lista dei destinatari
@ -206,7 +206,7 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
while (trans.good()) while (trans.good())
{ {
TString& line = trans.line(); TString& line = trans.line();
msg << line << '\n'; msg.add_line(line);
} }
ok = msg.send(TRUE); ok = msg.send(TRUE);
} }
@ -254,12 +254,11 @@ void TPostman::load_filters()
row = tok; row = tok;
const TString80 appmod = row.get(0); const TString80 appmod = row.get(0);
const bool is_mod = appmod.len() == 2; const bool is_mod = appmod.len() == 2;
// Il programma corrisponde // Il programma oppure il modulo corrispondono
if ((is_mod && app.compare(appmod, 2, TRUE) == 0) || if ((is_mod && app.compare(appmod, 2, TRUE) == 0) ||
app.compare(appmod, -1, TRUE) == 0) app.compare(appmod, -1, TRUE) == 0)
{ {
TString80 key = row.get(2); key.trim(); // Tipo di filtro TString80 key = row.get(2); key.trim(); // Tipo di filtro
if (is_mod) key << "-MOD";
row = row.get(); row.trim(); // Espressione di filtro row = row.get(); row.trim(); // Espressione di filtro
if (key.not_empty() && row.not_empty() && row != "1") if (key.not_empty() && row.not_empty() && row != "1")
{ {
@ -292,30 +291,10 @@ void TPostman::load_filters()
} }
// Trasforma le stringhe in espressioni // Trasforma le stringhe in espressioni
TString esp, mod;
FOR_EACH_ASSOC_STRING(expr, hash, key, str) FOR_EACH_ASSOC_STRING(expr, hash, key, str)
{ {
mod = key; TExpression* e = new TExpression(str, _strexpr, TRUE);
if (mod.find("-MOD") < 0) _expr.add(key, e);
{
mod << "-MOD";
const TString* modexp = (const TString*)expr.objptr(mod);
if (modexp != NULL && *modexp != "1")
{
if (*modexp != "0")
{
esp.cut(0);
esp << '(' << *modexp << ")AND(" << str << ')';
}
else
esp = "0";
}
else
esp = str;
TExpression* e = new TExpression(esp, _strexpr, TRUE);
_expr.add(key, e);
}
} }
// Inserisce un elemento fasullo per segnalare l'avvenuta lettura // Inserisce un elemento fasullo per segnalare l'avvenuta lettura

View File

@ -12,6 +12,72 @@
// Definita in isam.cpp // Definita in isam.cpp
extern int get_error(int); extern int get_error(int);
///////////////////////////////////////////////////////////
// TFirm
///////////////////////////////////////////////////////////
#include <nditte.h>
bool TFirm::read(long cod)
{
int err = NOERR;
if (cod < 0L)
cod = prefix().get_codditta();
_rec.destroy();
TLocalisamfile ditte(LF_NDITTE);
if (cod > 0L)
{
ditte.put("CODDITTA", cod);
err = ditte.read();
}
else
err = ditte.first();
if (err == NOERR)
{
const TRectype& ditta = ditte.curr();
for (int f = ditta.items()-1; f >= 0; f--)
{
const char* name = ditta.fieldname(f);
_rec.add(name, ditta.get(name));
}
}
else
NFCHECK("Can't read firm %ld: error %d", cod, err);
return _rec.items() > 0;
}
const TString& TFirm::get(const char* attr) const
{
const TString* str = (const TString*)_rec.objptr(attr);
if (str == NULL)
str = &EMPTY_STRING;
return *str;
}
long TFirm::get_long(const char* attr) const
{ return atol(get(attr)); }
long TFirm::codice() const
{
return get_long(NDT_CODDITTA);
}
const TString& TFirm::codice_valuta() const
{
const TString& codval = get(NDT_VALUTA);
if (codval.empty())
return TCurrency::get_base_val();
return codval;
}
TFirm::TFirm(long code)
{
read(code);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// extern variables are NO-NO! // extern variables are NO-NO!
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -109,6 +109,12 @@ class TPrefix : public TObject
TFirm* _firm; TFirm* _firm;
// @access Private Member
private:
int closeall(bool changestudy, TBit_array& excl, TBit_array& toclose) const;
void openall(bool changestudy, TBit_array& excl, int oldmax, TBit_array& toopen) const;
// @access Protected Member // @access Protected Member
protected: protected:
// @cmember Verifica l'effettiva esistenza della directory <p s> sotto // @cmember Verifica l'effettiva esistenza della directory <p s> sotto

View File

@ -1046,11 +1046,10 @@ void TPrint_application::print()
// only external apps can change it // only external apps can change it
_repeat_print = FALSE; _repeat_print = FALSE;
int ncopies = printer().n_copies();
// never print multiple copies if printer is viswin // never print multiple copies if printer is viswin
// only application may repeat printing by setting _repeat_print // only application may repeat printing by setting _repeat_print
int nc = printer().printtype() == screenvis ? 1 : ncopies; int nc = printer().printtype() == screenvis ? 1 : printer().n_copies();
// NULL cursor passed only prints once // NULL cursor passed only prints once
// pre and post process do everything // pre and post process do everything
@ -1098,7 +1097,10 @@ void TPrint_application::print()
{ {
delete _prind; delete _prind;
_prind = NULL; _prind = NULL;
} }
if (nc)
printer().formfeed(); // Salta pagina tra una copia e l'altra di una stampa
} }
// **************************************************************** // ****************************************************************
} }

View File

@ -46,6 +46,8 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
_text = new TMultiline_control(win(), DLG_NULL, 1, 0, hor-2, lines+1, 512, "CD", ""); _text = new TMultiline_control(win(), DLG_NULL, 1, 0, hor-2, lines+1, 512, "CD", "");
_text->set_read_only(); _text->set_read_only();
// testo.replace('\n', '\r'); qui
set_text(testo); set_text(testo);
if (bar) if (bar)

View File

@ -206,6 +206,7 @@ real& real::round (
// @flag <gt> 0 | Arrotonda al decimale // @flag <gt> 0 | Arrotonda al decimale
// @flag = 0 | Arrotonda all'intero // @flag = 0 | Arrotonda all'intero
// @flag <lt> 0 | Arrotonda al valore passato (es. -3 arrotonda alle mille) // @flag <lt> 0 | Arrotonda al valore passato (es. -3 arrotonda alle mille)
<<<<<<< real.cpp
{ {
if (abs(prec) < 20) if (abs(prec) < 20)
{ {
@ -213,7 +214,10 @@ real& real::round (
if (prec != 0) if (prec != 0)
{ {
ipow10(prec, m, d); ipow10(prec, m, d);
_dec *= m; if (prec < 0)
_dec /= d;
else
_dec *= m;
} }
if (_dec >= 0.0) if (_dec >= 0.0)
@ -222,7 +226,12 @@ real& real::round (
_dec = ceill(_dec - 0.5); _dec = ceill(_dec - 0.5);
if (prec != 0) if (prec != 0)
_dec *= d; {
if (prec < 0)
_dec *= d;
else
_dec /= m;
}
} }
return *this; return *this;
} }
@ -237,7 +246,8 @@ real& real::ceil (int prec)
} }
_dec = ceill(_dec); _dec = ceill(_dec);
if (prec != 0) if (prec != 0)
_dec *= d; // _dec *= d; Risulta stranamente molto impreciso!
_dec /= m;
return *this; return *this;
} }
@ -252,7 +262,8 @@ real& real::floor (int prec)
} }
_dec = floorl(_dec); _dec = floorl(_dec);
if (prec != 0) if (prec != 0)
_dec *= d; // _dec *= d; Risulta stranamente molto impreciso!
_dec /= m;
return *this; return *this;
} }
@ -267,7 +278,8 @@ real& real::trunc(int prec)
} }
_dec = floorl(_dec); _dec = floorl(_dec);
if (prec != 0) if (prec != 0)
_dec *= d; // _dec *= d; Risulta stranamente molto impreciso!
_dec /= m;
return *this; return *this;
} }

View File

@ -444,8 +444,16 @@ TFile_cache::TFile_cache(const char* tab, int key)
TFile_cache::~TFile_cache() TFile_cache::~TFile_cache()
{ {
kill_file();
}
void TFile_cache::kill_file()
{
if (_file != NULL) if (_file != NULL)
{
delete _file; delete _file;
_file = NULL;
}
} }
void TFile_cache::init_file(TLocalisamfile* f) void TFile_cache::init_file(TLocalisamfile* f)
@ -453,8 +461,7 @@ void TFile_cache::init_file(TLocalisamfile* f)
if (_file != NULL) if (_file != NULL)
{ {
CHECK(_file != f, "Suspicious file pointer"); CHECK(_file != f, "Suspicious file pointer");
delete _file; kill_file();
_file = NULL;
} }
if (f == NULL) if (f == NULL)
@ -622,10 +629,8 @@ long TFile_cache::fill()
TObject* obj = rec2obj(curr); TObject* obj = rec2obj(curr);
_cache.add(_code, obj); _cache.add(_code, obj);
} }
kill_file();
// Non serve piu'
delete _file; _file = NULL;
return _cache.items(); return _cache.items();
} }

View File

@ -164,6 +164,7 @@ protected:
protected: protected:
void init_file(TLocalisamfile* f=NULL); void init_file(TLocalisamfile* f=NULL);
void test_firm(); void test_firm();
void kill_file();
const TObject& query(const char* chiave); const TObject& query(const char* chiave);
virtual TObject* rec2obj(const TRectype& rec) const pure; virtual TObject* rec2obj(const TRectype& rec) const pure;

View File

@ -468,11 +468,10 @@ TEdit_field& TRelation_application::get_search_field() const
if (id <= 0) if (id <= 0)
{ {
const int max = _mask->fields(); for (int i = _mask->fields()-1; i >= 0; i--)
for (int i = 0; i < max; i++)
{ {
const TMask_field& f = _mask->fld(i); const TMask_field& f = _mask->fld(i);
if (f.in_key(1) && f.required()) if (f.is_edit() && f.in_key(1) && f.required())
{ {
id = f.dlg(); id = f.dlg();
break; break;
@ -1572,7 +1571,7 @@ bool TRelation_application::load_transaction()
_curr_transaction = cnf.get("Action"); _curr_transaction = cnf.get("Action");
_curr_transaction.upper(); _curr_transaction.upper();
_curr_trans_mode = cnf.get("Mode")[0]; _curr_trans_mode = cnf.get("Mode")[0];
_curr_trans_from = cnf.get("From");
long firm = cnf.get_long("Firm"); long firm = cnf.get_long("Firm");
if (firm > 0 && firm != get_firm()) if (firm > 0 && firm != get_firm())
{ {
@ -1591,7 +1590,6 @@ bool TRelation_application::load_transaction()
return retv; return retv;
} }
void TRelation_application::ini2query_mask() void TRelation_application::ini2query_mask()
{ {
if (is_transaction()) if (is_transaction())
@ -1612,20 +1610,28 @@ void TRelation_application::ini2insert_mask()
void TRelation_application::ini2mask(TConfig& ini, TMask& m, bool query) void TRelation_application::ini2mask(TConfig& ini, TMask& m, bool query)
{ {
const TString defpar = ini.get_paragraph(); const TString16 defpar = ini.get_paragraph();
TString str;
for (int f = m.fields()-1; f >= 0; f--) for (int f = m.fields()-1; f >= 0; f--)
{ {
TMask_field& campo = m.fld(f); TMask_field& campo = m.fld(f);
if (campo.field()) const TFieldref* fref = campo.field();
if (fref)
{ {
if (!query || campo.in_key(0)) if (!query || campo.in_key(0))
{ {
str = campo.field()->read(ini, defpar); const TString& str = fref->read(ini, defpar);
if (str.not_empty()) if (str.not_empty())
campo.set(str); campo.set(str);
} }
} }
else
{
if (!query && campo.is_sheet())
{
TSheet_field &sheet=(TSheet_field &)campo;
ini2sheet(ini, sheet);
}
}
} }
ini.set_paragraph(defpar); ini.set_paragraph(defpar);
} }
@ -1635,28 +1641,119 @@ void TRelation_application::edit_mask2ini()
if (_trans_ini.row(_trans_counter).not_empty()) if (_trans_ini.row(_trans_counter).not_empty())
{ {
TString16 head; TString16 head;
head << get_relation()->lfile().num(); head.format("%d", get_relation()->lfile().num());
TConfig ini(_trans_ini.row(_trans_counter), head); TConfig ini(_trans_ini.row(_trans_counter), head);
mask2ini(*_mask, ini); mask2ini(*_mask, ini);
} }
} }
void TRelation_application::ini2sheet(TConfig& ini,TSheet_field &sheet)
{
if (sheet.record() != NULL)
{
const int lognum = sheet.record()->logic_num();
const TMask& sm = sheet.sheet_mask();
// scrive le righe nello sheet associato
TString16 defpar;
for (int r = 1; ;r++)
{
defpar.format("%d,%d", lognum, r);
if (ini.set_paragraph(defpar))
{
TToken_string& row = sheet.row(r-1);
for (int sf = sm.fields()-1; sf >= 0; sf--)
{
TMask_field& campo = sm.fld(sf);
const TFieldref* fref = campo.field();
if (fref)
{
const TString& str = fref->read(ini, defpar);
row.add(str, sheet.cid2index(campo.dlg()));
}
}
sheet.check_row(r-1);
}
else
break;
}
}
}
void TRelation_application::sheet2ini(TSheet_field &sheet,TConfig& ini)
{
if (sheet.record() != NULL)
{
const int lognum = sheet.record()->logic_num();
const TMask& sm = sheet.sheet_mask();
// scrive le righe degli sheet associati
TString16 defpar;
TString str;
for (int r = 1 ; r <= sheet.items(); r++)
{
defpar.format("%d,%d", lognum, r);
TMask_field* fkey;
sheet.restart_key();
while (fkey = sheet.get_key(str))
{
ini.set(str, fkey->get(), defpar);
}
TToken_string& row = sheet.row(r-1);
const char* value;
int i;
for (i = 0, value = row.get(0); value; i++, value = row.get())
{
const TMask_field& campo = sm.field(FIRST_FIELD+i);
const TFieldref* fr = campo.field();
if (fr)
{
if (value == NULL || *value == '\0')
value = " ";
// ini.set(fr->name(), value, defpar);
fr->write(ini, defpar, value);
}
}
}
for (r = sheet.items()+1; ; r++)
{
defpar.format("%d,%d", lognum, r);
if (ini.set_paragraph(defpar))
ini.remove_all();
else
break;
}
}
}
void TRelation_application::mask2ini(const TMask& m, TConfig& ini) void TRelation_application::mask2ini(const TMask& m, TConfig& ini)
{ {
TString16 defpar; defpar << get_relation()->lfile().num();
ini.set_paragraph(defpar);
ini.set("Firm", get_firm(), "Transaction"); ini.set("Firm", get_firm(), "Transaction");
const TLocalisamfile& lfile = get_relation()->lfile();
TString str(80); int year, release, tag, patch;
switch (get_relation()->lfile().num()) if (get_version_info(year, release, tag, patch))
{
TString80 ver;
ver.format("%d %d.%d-%d", year, release, tag, patch);
ini.set("Version", ver);
}
TString16 defpar;
defpar.format("%d", lfile.num());
ini.set_paragraph(defpar);
switch (lfile.num())
{ {
case LF_TAB: case LF_TAB:
case LF_TABCOM: case LF_TABCOM:
case LF_TABGEN: case LF_TABGEN:
{ {
TString16 tabname = m.source_file().mid(4,3); const TString& tabname = lfile.curr().get("COD");
ini.set("COD", tabname.upper(), defpar ); ini.set("COD", tabname, defpar);
} }
break; break;
} }
@ -1664,63 +1761,30 @@ void TRelation_application::mask2ini(const TMask& m, TConfig& ini)
{ {
TMask_field& campo = m.fld(f); TMask_field& campo = m.fld(f);
if (campo.shown()) if (campo.shown())
{ {
if (campo.field()) const TFieldref* fr = campo.field();
{ if (fr)
str = campo.get(); {
if (str.blank()) str = " "; if (campo.empty())
campo.field()->write(ini, defpar, str); fr->write(ini, defpar, " ");
else
fr->write(ini, defpar, campo.get());
} }
else else
if (campo.is_sheet()) if (campo.is_sheet())
{ {
TSheet_field &sheet=(TSheet_field &)campo; TSheet_field &sheet=(TSheet_field &)campo;
sheet2ini(sheet,ini); sheet2ini(sheet,ini); // It's virtual
} }
} }
} }
ini.set_paragraph(defpar); // Reimposta paragrafo standard
} }
void TRelation_application::ini2sheet(TConfig& ini,TSheet_field &sheet)
{
}
void TRelation_application::sheet2ini(TSheet_field &sheet,TConfig& ini)
{
if (sheet.record() != NULL)
{
// scrive le righe degli sheet associati
TString16 defpar;
TString str(80);
for (int r = 1 ; r <= sheet.items(); r++)
{
TString16 defpar = format("%d,%d",sheet.record()->logic_num(),r);
const TMask& sm = sheet.sheet_mask();
TMask_field* fkey;
sheet.restart_key();
while (fkey = sheet.get_key(str))
{
ini.set(str, fkey->get(), defpar);
}
for (int sf = 0; sf < sm.fields(); sf++)
{
TMask_field& campo = sm.fld(sf);
if (campo.shown() && campo.field())
{
str = sheet.row(r-1).get(sheet.cid2index(campo.dlg()));
if (str.empty()) str = " ";
ini.set(campo.field()->name(), str ,defpar);
}
}
}
}
}
bool TRelation_application::mask2mail(const TMask& m) bool TRelation_application::mask2mail(const TMask& m)
{ {
TWait_cursor hourglass; TWait_cursor hourglass;
bool ok = ::can_dispatch_transaction(get_relation()->curr()); bool ok = _curr_trans_from.empty() && ::can_dispatch_transaction(get_relation()->curr());
if (ok) if (ok)
{ {
TFilename ininame; ininame.temp(); TFilename ininame; ininame.temp();

View File

@ -66,6 +66,8 @@ class TRelation_application : public TSkeleton_application
TString _curr_transaction; TString _curr_transaction;
// @cmember:(INTERNAL) Modalità di esecuzione della transazione corrente (Automatica o interattiva) // @cmember:(INTERNAL) Modalità di esecuzione della transazione corrente (Automatica o interattiva)
char _curr_trans_mode; char _curr_trans_mode;
// @cmember:(INTERNAL) Transazione ricevuta da .....
TString _curr_trans_from;
// @cmember:(INTERNAL) Flag di cancellazione automatica veloce // @cmember:(INTERNAL) Flag di cancellazione automatica veloce
int _autodelete; int _autodelete;
@ -242,8 +244,8 @@ public:
bool find(word key = 0); bool find(word key = 0);
// @cmember Costruisce il membro <md TRelation_application::_fixed> // @cmember Costruisce il membro <md TRelation_application::_fixed>
void set_link(TMask & m, const char * keyexpr); void set_link(TMask & m, const char * keyexpr);
// @cmember Ritorna se e' stato chiamato col messaggio di link // @cmember Ritorna TRUE se e' stato chiamato col messaggio di link
byte lnflag() const bool lnflag() const
{ return _lnflag;} { return _lnflag;}
// @cmember Ritorna TRUE se e' una transazione // @cmember Ritorna TRUE se e' una transazione
bool is_transaction() const { return _curr_transaction.not_empty(); } bool is_transaction() const { return _curr_transaction.not_empty(); }

View File

@ -628,12 +628,13 @@ int TRelation::position_rels(
for (int kk = 0; eq && kk < rd._fields.items(); kk++) for (int kk = 0; eq && kk < rd._fields.items(); kk++)
{ {
TFieldref& fl = (TFieldref&)rd._fields[kk]; TFieldref& fl = (TFieldref&)rd._fields[kk];
const TString80 f_fr(fl.read(furr)); TString80 f_fr(fl.read(furr));
const TString80 f_ex(rd.evaluate_expr(kk, to)); TString80 f_ex(rd.evaluate_expr(kk, to));
if (rd._forced[kk]) if (rd._forced[kk])
eq = f_fr == f_ex; eq = f_fr == f_ex;
else else
{ {
f_fr.rtrim(); f_ex.rtrim();
eq = f_fr.compare(f_ex, f_ex.len()) == 0; eq = f_fr.compare(f_ex, f_ex.len()) == 0;
// Becca anche 000001=1 // Becca anche 000001=1
@ -1227,7 +1228,6 @@ TRecnotype TCursor::update()
if (file().curr().empty()) if (file().curr().empty())
file().curr().zero(); file().curr().zero();
file().read(_isgteq); file().read(_isgteq);
const TRecnotype totrec = buildcursor(file().recno());
const int handle = file().handle(); const int handle = file().handle();
const TRecnotype eod = DB_reccount(handle); const TRecnotype eod = DB_reccount(handle);
@ -1236,7 +1236,7 @@ TRecnotype TCursor::update()
_index_firm = prefix().get_codditta(); _index_firm = prefix().get_codditta();
_lastkrec = DB_changed(handle); _lastkrec = DB_changed(handle);
return totrec; return _totrec;
} }
@ -2090,27 +2090,23 @@ const char* TFieldref::read(TConfig& ini, const char* defpar) const
return ""; return "";
buffer = ini.get(_name); buffer = ini.get(_name);
// Gestisce valori tra virgolette
const int l = buffer.len();
if (l > 1)
{
if ((buffer[0] == '"' || buffer[0] == '\'') && buffer[0] == buffer[l-1])
{
buffer.rtrim(1);
buffer.ltrim(1);
if (strchr(buffer, '\\'))
buffer = esc(buffer);
}
}
if (_from > 0 || _to > 0) if (_from > 0 || _to > 0)
{ {
const int l = buffer.len();
if (_to < l && _to > 0) buffer.cut(_to); if (_to < l && _to > 0) buffer.cut(_to);
if (_from > 0) buffer.ltrim(_from); if (_from > 0) buffer.ltrim(_from);
} }
else
{
// Gestisce valori tra virgolette
const int last = buffer.len()-1;
if (last > 0)
{
if ((buffer[0] == '"' || buffer[0] == '\'') && buffer[0] == buffer[last])
{
buffer.cut(last);
buffer.ltrim(1);
if (strchr(buffer, '\\'))
buffer = esc(buffer);
}
}
}
return buffer; return buffer;
} }
@ -2163,34 +2159,37 @@ void TFieldref::write(TConfig& ini, const char* defpar, const char* val) const
if (_from > 0 || _to > 0) if (_from > 0 || _to > 0)
{ {
buffer = ini.get(_name, para); buffer = ini.get(_name, para);
buffer.overwrite(val, _from + (buffer[0] == '"')); if ((buffer[0] == '"' || buffer[0] == '\'') && buffer[0] == buffer[buffer.len()-1])
if (buffer[0] == ' ') // Metto le virgolette {
{ buffer.insert("\"", 0); buffer << '"'; } buffer.rtrim(1);
ini.set(_name, buffer, para); buffer.ltrim(1);
if (strchr(buffer, '\\'))
buffer = esc(buffer);
}
buffer.overwrite(val, _from);
val = buffer;
} }
else const int qn = quotes_needed(val); // Controlla se c'e' bisogno di virgolette
{ if (qn)
const int qn = quotes_needed(val); // Controlla se c'e' bisogno di virgolette {
if (qn) if (qn == 2)
{ {
if (qn == 2) buffer = val;
{ escapes(buffer);
buffer = val; buffer.insert("\"", 0);
escapes(buffer); buffer << '"';
buffer.insert("\"", 0);
buffer << '"';
}
else
{
const char virg = strchr(val, '"') ? '\'' : '"';
buffer.cut(0);
buffer << virg << val << virg;
}
ini.set(_name, buffer, para);
} }
else else
ini.set(_name, val, para); {
} const char* virg = strchr(val, '"') ? "'" : "\"";
buffer = val;
buffer.insert(virg, 0);
buffer << virg;
}
ini.set(_name, buffer, para);
}
else
ini.set(_name, val, para);
} }
const char* TFieldref::read(const TRectype& rec) const const char* TFieldref::read(const TRectype& rec) const

View File

@ -28,6 +28,7 @@ const TToken_string& empty_string()
// Most descriptions will fit in fifty characters // Most descriptions will fit in fifty characters
const int DEFAULT_SIZE = 50; const int DEFAULT_SIZE = 50;
const int MAX_SIZE = 32000;
#ifdef FOXPRO #ifdef FOXPRO
class TString512 : public TFixed_string class TString512 : public TFixed_string
@ -161,7 +162,7 @@ TString& TString::set(
int TString::make_room( int TString::make_room(
int s) // @parm Numero di caratteri di cui si vuole aspandere la stringa int s) // @parm Numero di caratteri di cui si vuole aspandere la stringa
// @comm La stringa viene espansa di un numero di caratteri doppio (per sicurezza) di // @comm La stringa viene espansa di un numero di caratteri maggiore (per efficienza) di
// quello passato per parametro // quello passato per parametro
// //
// @rdesc Ritorna il numero di caratteri della stringa prima della chiamata // @rdesc Ritorna il numero di caratteri della stringa prima della chiamata
@ -169,7 +170,16 @@ int TString::make_room(
const int lun = len(); const int lun = len();
const int spare = size() - lun; const int spare = size() - lun;
if (spare < s) if (spare < s)
resize(3 * (size() + s) / 2, TRUE); {
long new_size = long(lun) + long(s);
if (new_size > MAX_SIZE)
fatal_box("Stringa di lunghezza eccessiva (> %ld)", MAX_SIZE);
new_size = 3L * new_size / 2L;
if (new_size > MAX_SIZE)
new_size = MAX_SIZE;
resize(int(new_size), TRUE);
}
return lun; return lun;
} }
@ -542,9 +552,9 @@ TString& TString::cut(int n)
CHECKD(n >= 0, "Invalid TString::cut position ", n); CHECKD(n >= 0, "Invalid TString::cut position ", n);
if (n <= _size) if (n <= _size)
_str[n] = '\0'; _str[n] = '\0';
else // else
NFCHECK("Hai tagliato a %d la stringa '%s' lunga %d(%d)", // NFCHECK("Hai tagliato a %d la stringa '%s' lunga %d(%d)",
n, _str, len(), size()); // n, _str, len(), size());
return *this; return *this;
} }
@ -1814,45 +1824,49 @@ void TParagraph_string::tokenize()
void TParagraph_string::tokenize() void TParagraph_string::tokenize()
{ {
TToken_string tmp; if (not_empty())
int start = 0;
int last_space = -1;
const int length = len();
for (int i = start; i <= length; i++)
{ {
int add_now = -1; TToken_string tmp;
switch(_str[i]) int start = 0;
int last_space = -1;
const int length = len();
for (int i = start; i <= length; i++)
{ {
case ' ': int add_now = -1;
case '\t': switch(_str[i])
last_space = i;
break;
case '\r':
case '\n':
case '\0':
add_now = i;
break;
default:
if (i - start >= _width)
{ {
if (last_space > start) case ' ':
add_now = last_space; case '\t':
else last_space = i;
add_now = i; break;
case '\r':
case '\n':
case '\0':
add_now = i;
break;
default:
if (i - start >= _width)
{
if (last_space > start)
add_now = last_space;
else
add_now = i;
}
break;
}
if (add_now >= start)
{
TString256 tok = sub(start, add_now);
tok.rtrim(); // Preserva gli spazi iniziali dopo un a capo forzato da \n
tmp.add(tok);
start = add_now + (_str[add_now] <= ' ');
last_space = start;
} }
break;
}
if (add_now > start)
{
TString256 tok = sub(start, add_now);
tok.rtrim(); // Preserva gli spazi dopo un a capo forzato da \n
tmp.add(tok);
start = add_now + (_str[add_now] <= ' ');
last_space = start;
} }
tmp.rtrim();
TToken_string::operator=(tmp);
} }
TToken_string::operator=(tmp);
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -66,8 +66,10 @@ TString& TTable_application::get_mask_name(TString& t) const
t = tab.module(); t = tab.module();
t << "tb" << m; t << "tb" << m;
t.upper(); t.upper();
if (!fexist(t))
TFilename n(t); n.ext("msk");
if (!n.exist())
t.overwrite("ba"); t.overwrite("ba");
return t; return t;
} }

View File

@ -4,10 +4,9 @@
#ifndef __RELAPP_H #ifndef __RELAPP_H
#include <relapp.h> #include <relapp.h>
#endif #endif
#ifndef __DEFTABAP_H
#define GR_SEARCH 29 #include <deftabap.h>
#define GR_MODIFY_PROTECTED 30 #endif
#define GR_RECORD_PROTECTED 31
#define FPC "FPC" #define FPC "FPC"

View File

@ -207,25 +207,34 @@ const char* TTable::description()
struct TCallbackTableinfo struct TCallbackTableinfo
{ {
TString16 _var1, _var2; TString16 _var1, _var2, _var3;
TString16 _module; TString4 _module;
TFilename _app; TFilename _tabapp, _relapp;
}; };
HIDDEN int find_relapp(TConfig& cfg, void* jolly) HIDDEN int find_relapp(TConfig& cfg, void* jolly)
{ {
TCallbackTableinfo& info = *((TCallbackTableinfo*)jolly); TCallbackTableinfo& info = *((TCallbackTableinfo*)jolly);
if (cfg.exist(info._var1))
{
info._tabapp = cfg.get(info._var1);
if (info._tabapp.not_empty())
return 1;
}
if (cfg.get_paragraph().compare(info._module, 2, TRUE) == 0) if (cfg.get_paragraph().compare(info._module, 2, TRUE) == 0)
{ {
for (int v = 1; v <= 2; v++) if (cfg.exist(info._var2))
{ {
const TString& var = v == 1 ? info._var1 : info._var2; info._relapp = cfg.get(info._var2);
if (cfg.exist(var)) if (info._relapp.not_empty())
{ return 2;
info._app = cfg.get(var); }
if (info._app.not_empty()) if (cfg.exist(info._var3))
return 1; {
} info._relapp = cfg.get(info._var3);
if (info._relapp.not_empty())
return 3;
} }
} }
return 0; return 0;
@ -235,14 +244,16 @@ bool TTable::get_relapp(TString& app) const
{ {
TConfig ini("install.ini"); TConfig ini("install.ini");
TCallbackTableinfo fi; TCallbackTableinfo fi;
fi._var1.format("Edit_%d", num()); fi._var1.format("Edit_%s", (const char*)_tabname);
fi._var2.format("Edit_%d", num() == LF_TAB ? LF_TABCOM : LF_TAB); fi._var2.format("Edit_%d", num());
fi._var3.format("Edit_%d", num() == LF_TAB ? LF_TABCOM : LF_TAB);
fi._module = ((TTable*)this)->module(); fi._module = ((TTable*)this)->module();
ini.for_each_paragraph(find_relapp, &fi); ini.for_each_paragraph(find_relapp, &fi);
if (fi._app.not_empty()) app = fi._tabapp;
app = fi._app; if (app.empty())
else app = fi._relapp;
if (app.empty())
{ {
app = "ba3 -0"; app = "ba3 -0";
if (fi._module.compare("ba", 2, TRUE) != 0) if (fi._module.compare("ba", 2, TRUE) != 0)

View File

@ -22,13 +22,13 @@ void TVariable_mask::set(short fld_id, const char* str, bool hit )
void TVariable_mask::show(short fld_id, bool on ) void TVariable_mask::show(short fld_id, bool on )
{ {
if(present( fld_id ) ) if(fld_id < 0 || present( fld_id ) )
TMask::show( fld_id, on ); TMask::show( fld_id, on );
} }
void TVariable_mask::enable(short fld_id, bool on ) void TVariable_mask::enable(short fld_id, bool on )
{ {
if(present( fld_id )) if(fld_id < 0 ||present( fld_id ))
TMask::enable( fld_id, on ); TMask::enable( fld_id, on );
} }
@ -56,7 +56,6 @@ TVariable_mask::TVariable_mask() : TMask()
{ {
} }
TMask& TVariable_sheet_field::sheet_mask() const TMask& TVariable_sheet_field::sheet_mask() const
{ {
TMask & m = TSheet_field::sheet_mask(); TMask & m = TSheet_field::sheet_mask();

View File

@ -824,7 +824,7 @@ void TViswin::paint_background(
TImage* i = (TImage*)_images.objptr(id); TImage* i = (TImage*)_images.objptr(id);
if (i == NULL && y1 == 0) if (i == NULL && y1 == 0)
{ {
const TString_array& a = printer().image_names(); const TString_array& a = pr.image_names();
const TImage src(a.row(id)); const TImage src(a.row(id));
if (src.ok()) if (src.ok())
{ {

View File

@ -178,7 +178,16 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
{ {
while (m->tag) while (m->tag)
{ {
if (m->tag > BAR_ITEM(0) && m->tag < BAR_ITEM(16)) switch(m->tag)
{
case M_FILE: // Leave it as is
case M_EDIT:
case M_FONT:
case M_STYLE:
case M_HELP:
case -1: // Separator
break;
default:
xvt_menu_set_item_enabled(TASK_WIN, m->tag, on); xvt_menu_set_item_enabled(TASK_WIN, m->tag, on);
m++; m++;
} }