Gestione ordinamenti in sheet di ricerca

git-svn-id: svn://10.65.10.50/branches/R_10_00@23139 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2015-11-30 16:18:56 +00:00
parent 6a84387e62
commit 07f592bd22
45 changed files with 1490 additions and 1354 deletions

View File

@ -5,6 +5,7 @@
#include <dongle.h> #include <dongle.h>
#include <golem.h> #include <golem.h>
#include <isamrpc.h> #include <isamrpc.h>
#include <mask.h>
#include <prefix.h> #include <prefix.h>
#include <progind.h> #include <progind.h>
#include <sqlset.h> #include <sqlset.h>
@ -113,14 +114,8 @@ void history()
last_module = mod; last_module = mod;
else else
mod.cut(0); mod.cut(0);
h << "<tr>" << "<td><b>" << mod << "</b></td>"; TString content;
h << "<td>" << rel << "</td><td>";
if (np > patch)
h << "<b>" << name << "</b>";
else
h << name;
h << "</td><td>";
if (http_get(server, remote, local)) if (http_get(server, remote, local))
{ {
ifstream i(local); ifstream i(local);
@ -130,12 +125,22 @@ void history()
i.getline(str.get_buffer(), str.size()); i.getline(str.get_buffer(), str.size());
if (str.find('.') > 0 && fexist(str)) if (str.find('.') > 0 && fexist(str))
continue; continue;
h << str << "<br/>"; content << str << "<br/>";
} }
i.close(); i.close();
xvt_fsys_remove_file(local); xvt_fsys_remove_file(local);
} }
h << "</td></tr>" << endl;
if (content.len() > 12)
{
h << "<tr>" << "<td><b>" << mod << "</b></td>";
h << "<td>" << rel << "</td><td>";
if (np > patch)
h << "<b>" << name << "</b>";
else
h << name;
h << "</td><td>" << content << "</td></tr>" << endl;
}
} }
} }
h << "</table></body></html>" << endl; h << "</table></body></html>" << endl;
@ -164,7 +169,7 @@ public:
bool curr_prop(TString& prop, TVariant& value); bool curr_prop(TString& prop, TVariant& value);
void set_read_only(bool ro = true); void set_read_only(bool ro = true);
TAdvanced_property_sheet(const char* title = "", int width = 78, int height = 20); TAdvanced_property_sheet(const char* title = "", int width = 78, int height = 24);
}; };
long TAdvanced_property_sheet::handler(WINDOW win, EVENT* e) long TAdvanced_property_sheet::handler(WINDOW win, EVENT* e)
@ -280,7 +285,7 @@ void TAdvanced_property_sheet::set_read_only(bool ro)
TAdvanced_property_sheet::TAdvanced_property_sheet(const char* title, int width, int height) TAdvanced_property_sheet::TAdvanced_property_sheet(const char* title, int width, int height)
: TMask(title && *title ? title : TR("Proprietà"), 1, width, height), _pf(NULL) : TMask(title && *title ? title : TR("Proprietà"), 1, width, height), _pf(NULL)
{ {
add_button_tool(DLG_CANCEL, TR("Ritorna"), TOOL_CANCEL); add_button_tool(DLG_CANCEL, TR("Chiudi"), TOOL_CANCEL);
add_button_tool(DLG_EXPORT, TR("Esporta"), TOOL_EXCEL); add_button_tool(DLG_EXPORT, TR("Esporta"), TOOL_EXCEL);
if (is_power_reseller(true)) if (is_power_reseller(true))
add_button_tool(DLG_EDIT, TR("Edit"), TOOL_EDIT); add_button_tool(DLG_EDIT, TR("Edit"), TOOL_EDIT);

View File

@ -39,6 +39,38 @@ TApplication& main_app()
// Gestione dello sfondo della finestra principale // Gestione dello sfondo della finestra principale
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
static clock_t _next_flash = 0;
HIDDEN void paint_title(WINDOW win, COLOR rgb, BOOLEAN bShadow = FALSE)
{
RCT r; xvt_vobj_get_client_rect(win, &r);
int BIGY = 3*ROWY/2;
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
const char* t = main_app().title();
int w = xvt_dwin_get_text_width(win, t, -1);
if (w > r.right)
{
BIGY = BIGY*r.right/w;
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
w = xvt_dwin_get_text_width(win, t, -1);
}
int x = (r.right-w)/2, y = r.top+BIGY+ROWY;
if (bShadow)
{ // Disegna ombra
const int k = max(BIGY/24, 1);
xvt_dwin_set_fore_color(win, MASK_LIGHT_COLOR);
xvt_dwin_draw_text(win, x+k, y+k, t, -1);
}
xvt_dwin_set_fore_color(win, rgb);
xvt_dwin_draw_text(win, x, y, t, -1);
xvtil_set_font(win, NULL, XVT_FS_NONE);
xvt_dwin_set_fore_color(win, PROMPT_COLOR);
}
HIDDEN void paint_background(WINDOW win) HIDDEN void paint_background(WINDOW win)
{ {
RCT r; xvt_vobj_get_client_rect(win, &r); RCT r; xvt_vobj_get_client_rect(win, &r);
@ -54,45 +86,43 @@ HIDDEN void paint_background(WINDOW win)
else else
xvt_dwin_clear(win, MASK_DARK_COLOR); xvt_dwin_clear(win, MASK_DARK_COLOR);
int BIGY = 3*ROWY/2; paint_title(win, MASK_DARK_COLOR, ADVANCED_GRAPHICS);
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
const char* t = main_app().title();
int w = xvt_dwin_get_text_width(win, t, -1);
if (w > r.right)
{
BIGY = BIGY*r.right/w;
xvtil_set_font(win, XVT_FFN_TIMES, XVT_FS_BOLD | XVT_FS_ITALIC, BIGY);
w = xvt_dwin_get_text_width(win, t, -1);
}
int x = (r.right-w)/2, y = r.top+BIGY+ROWY;
if (ADVANCED_GRAPHICS)
{ // Disegna ombra
const int k = max(BIGY/24, 1);
xvt_dwin_set_fore_color(win, MASK_LIGHT_COLOR);
xvt_dwin_draw_text(win, x+k, y+k, t, -1);
}
xvt_dwin_set_fore_color(win, MASK_DARK_COLOR);
xvt_dwin_draw_text(win, x, y, t, -1);
xvtil_set_font(win, NULL, XVT_FS_NONE);
xvt_dwin_set_fore_color(win, PROMPT_COLOR);
TString spa; spa << dongle().product(); TString spa; spa << dongle().product();
if (!xvt_sys_is_pda()) if (!xvt_sys_is_pda())
spa << " - " << dongle().reseller(); spa << " - " << dongle().reseller();
w = xvt_dwin_get_text_width(win, spa, -1); int w = xvt_dwin_get_text_width(win, spa, -1);
x = (r.right-r.left-w)/2; y = r.bottom-CHARY; int x = (r.right-r.left-w)/2, y = r.bottom-CHARY;
xvt_dwin_draw_text(win, x, y, spa, -1); xvt_dwin_draw_text(win, x, y, spa, -1);
if (ADVANCED_GRAPHICS) if (ADVANCED_GRAPHICS)
{ {
RCT ir; RCT ir;
xvt_rect_set(&ir, CHARY, r.bottom-TOOL_SIZE-CHARY, TOOL_SIZE+CHARY, r.bottom-CHARY); const int sz = TOOL_SIZE <= 32 ? 32 : 48;
xvt_rect_set(&ir, CHARY, r.bottom-sz-CHARY, sz+CHARY, r.bottom-CHARY);
xvt_dwin_draw_icon_rect(win, &ir, ICON_RSRC); xvt_dwin_draw_icon_rect(win, &ir, ICON_RSRC);
xvt_rect_set(&ir, r.right-CHARY-TOOL_SIZE, r.bottom-TOOL_SIZE-CHARY, r.right-CHARY, r.bottom-CHARY); xvt_rect_set(&ir, r.right-CHARY-sz, r.bottom-sz-CHARY, r.right-CHARY, r.bottom-CHARY);
xvt_dwin_draw_icon_rect(win, &ir, ICON_RSRC); xvt_dwin_draw_icon_rect(win, &ir, ICON_RSRC);
_next_flash = clock() + 5*CLOCKS_PER_SEC;
}
}
void TApplication::on_idle()
{
if (_next_flash > 0 && clock() > _next_flash)
{
const double delta = clock()-_next_flash;
if (delta < CLOCKS_PER_SEC)
{
COLOR rgb = blend_colors( MASK_DARK_COLOR, MASK_LIGHT_COLOR, delta/CLOCKS_PER_SEC);
paint_title(TASK_WIN, rgb);
}
else
{
paint_title(TASK_WIN, MASK_DARK_COLOR);
_next_flash = 0;
}
} }
} }
@ -285,7 +315,7 @@ bool TApplication::remove_menu(MENU_TAG id)
TApplication::TApplication() TApplication::TApplication()
: _god_vars(NULL),_savefirm(0), _running(FALSE), _create_ok(FALSE) : _god_vars(NULL),_savefirm(0), _running(FALSE), _create_ok(FALSE)
{ {
} }
@ -369,7 +399,7 @@ const char* TApplication::get_module_name() const
} }
if (!ok) if (!ok)
{ {
error_box(FR("Il modulo '%s' non è autorizzato per l'utente %s"), (const char*)module, ((const char*)user())); cantaccess_box(module);
module.cut(0); module.cut(0);
} }
} }
@ -561,7 +591,7 @@ bool TApplication::get_version_info(int& year, int& release, int& tag, int& patc
patch = vep.get_int(); patch = vep.get_int();
int checksum = vep.get_int(); int checksum = vep.get_int();
bool valid = year >= 2151 && release > 0 && tag >= 0 && patch >= 0 && bool valid = year >= 2151 && release >= 12 && tag >= 0 && patch >= 0 &&
checksum == (year + release + tag + patch); checksum == (year + release + tag + patch);
return valid; return valid;
} }

View File

@ -130,6 +130,7 @@ public:
virtual const char * extra_modules() const { return ""; } virtual const char * extra_modules() const { return ""; }
// @cmember Abilita la verifica del modulo cui appartiene il programma // @cmember Abilita la verifica del modulo cui appartiene il programma
virtual bool check_autorization() const; virtual bool check_autorization() const;
virtual void on_idle();
// @cmember Forza la chiusura dell'applicazione // @cmember Forza la chiusura dell'applicazione
void stop_run(); void stop_run();

View File

@ -176,6 +176,7 @@ public:
TCache(size_t size = 0); // 883 assigned by default TCache(size_t size = 0); // 883 assigned by default
virtual ~TCache(); virtual ~TCache();
}; };
/* /*
__ass = TAssoc_array da scandire __ass = TAssoc_array da scandire
__obj = variabile del cazzo che serve internamente al ciclo; va nominata e dimenticata __obj = variabile del cazzo che serve internamente al ciclo; va nominata e dimenticata

View File

@ -1,7 +1,7 @@
<report name="bagn010a" lpi="6"> <report name="bagn010a" lpi="6">
<description>Log di elaborazione</description> <description>Log di elaborazione</description>
<font face="Arial" size="10" /> <font face="Courier New" size="10" />
<section type="Head" /> <section type="Head" />
<section type="Head" level="1"> <section type="Head" level="1">
<field type="Stringa" valign="center" align="center" width="80" height="3" pattern="1"> <field type="Stringa" valign="center" align="center" width="80" height="3" pattern="1">

View File

@ -197,12 +197,16 @@ bool TList_sheet::check(CheckTime t)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Certified 100% // Certified 100%
TBrowse::TBrowse(TEdit_field* f, TRelation* r, int key, const char* filter) TBrowse::TBrowse(TEdit_field* f, TRelation* r, int key, const char* filter, const char* orderby)
: TBrowse_button(f), : TBrowse_button(f),
_relation(r), _cursor(new TCursor (r, "", key)), _relation(r), _filter(filter), _secondary(false), _alt_browse(NULL),
_filter(filter), _secondary(false), _alt_browse(NULL),
_custom_filter_handler(NULL) _custom_filter_handler(NULL)
{ {
if (*orderby && *orderby)
_cursor = new TSorted_cursor(r, orderby, "", key);
else
_cursor = new TCursor (r, "", key);
custom_cursor(); custom_cursor();
} }
@ -252,9 +256,8 @@ static bool descr_filter_handler(TMask_field& f, KEY k)
void TBrowse::custom_cursor() void TBrowse::custom_cursor()
{ {
TRelation * relation = _relation == NULL ? _cursor->relation() : _relation; TRelation* relation = _relation ? _relation : _cursor->relation();
int logicnum = relation->lfile().num(); const int logicnum = relation->lfile().num();
switch(logicnum) switch(logicnum)
{ {
case LF_ANAMAG : case LF_ANAMAG :
@ -415,12 +418,14 @@ void TBrowse::parse_join(TScanner& scanner)
int key = 1; int key = 1;
if (scanner.popkey() == "KE") if (scanner.popkey() == "KE")
key = scanner.integer(); key = scanner.integer();
else scanner.push(); else
scanner.push();
int alias = 0; int alias = 0;
if (scanner.popkey() == "AL") if (scanner.popkey() == "AL")
alias = scanner.integer(); alias = scanner.integer();
else scanner.push(); else
scanner.push();
TToken_string exp(80); TToken_string exp(80);
if (scanner.pop() == "INTO") if (scanner.pop() == "INTO")
@ -443,11 +448,10 @@ void TBrowse::parse_join(TScanner& scanner)
else else
{ {
#ifdef DBG #ifdef DBG
if (j.len() > 4) if (j[0] != '&' && j.len() > 4)
yesnofatal_box("'%s' non e' una tabella valida: %d", (const char*)j); yesnofatal_box("'%s' non è una tabella valida: %d", (const char*)j);
else
#endif #endif
_relation->add(j, exp, key, to, alias); // join table _relation->add(j, exp, key, to, alias); // join table
} }
} }
@ -923,8 +927,7 @@ bool TBrowse::do_link(bool insert)
{ {
if (*f == '#') if (*f == '#')
{ {
const int id = atoi(++f); app << field().evaluate_field(f);
app << field(id).get();
while (isspace(*f)) ++f; while (isspace(*f)) ++f;
while (isdigit(*f)) ++f; while (isdigit(*f)) ++f;
if (*f) if (*f)
@ -1489,7 +1492,7 @@ KEY TProfile_select::run()
running = false; running = false;
} }
else else
error_box("Esiste gia' un profilo di nome\n%s", error_box("Esiste già un profilo di nome\n%s",
(const char*)name); (const char*)name);
} }
break; break;
@ -1507,7 +1510,7 @@ KEY TProfile_select::run()
running = false; running = false;
} }
else else
error_box("Esiste gia' un profilo di nome\n%s", error_box("Esiste già un profilo di nome\n%s",
(const char*)name); (const char*)name);
} }
else else

View File

@ -229,7 +229,7 @@ public:
void do_output(CheckTime = RUNNING_CHECK); void do_output(CheckTime = RUNNING_CHECK);
// @cmember Costruttore // @cmember Costruttore
TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = ""); TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = "", const char* orderby = NULL);
// @cmember Costruttore // @cmember Costruttore
TBrowse(TEdit_field* f, TCursor* c); TBrowse(TEdit_field* f, TCursor* c);
// @cmember Distruttore // @cmember Distruttore

View File

@ -3,7 +3,7 @@ ct CUP Tracciabilit
np No Profit np No Profit
fe Comunicazione Polivalente fe Comunicazione Polivalente
77 Percipienti 77 Percipienti
?? Modulo vario ex- Gestione IVA gd Gestione DNinst
se Contabilità Semplificata se Contabilità Semplificata
cg Contabilità Generale cg Contabilità Generale
ci Contabilità Industriale ci Contabilità Industriale

View File

@ -117,10 +117,11 @@ void COpenFile(logicname,filed,lockmode,dirflg)
} }
} while TESTLOCK(fdir[dirflg].IOR) ; } while TESTLOCK(fdir[dirflg].IOR) ;
strcpy(filed->SysName, CAddPref(filed->SysName)) ; strcpy(filed->SysName, CAddPref(filed->SysName)) ;
#ifndef _NDEBUG
if (strlen(filed->SysName) >= sizeof(filed->SysName)) if (strlen(filed->SysName) >= sizeof(filed->SysName))
xvt_dm_post_error(filed->SysName); {
#endif char msg[256]; sprintf(msg, "Nome troppo lungo '%s'" , filed->SysName);
xvt_dm_post_error(msg);
}
} }
/* /*

View File

@ -188,7 +188,7 @@ bool cantaccess_box(const char* filename)
{ {
if (filename == NULL || *filename < ' ') if (filename == NULL || *filename < ' ')
filename = TR("questa funzione"); filename = TR("questa funzione");
return error_box(FR("L'utente %s non può accedere a %s"), (const char*)user(), filename); return error_box(FR("L'utente %s non puo' accedere a %s"), (const char*)user(), filename);
} }
bool delete_box(const char* fmt, ...) bool delete_box(const char* fmt, ...)

View File

@ -74,5 +74,8 @@
#define CLI_AUTORIZ "AUTORIZ" #define CLI_AUTORIZ "AUTORIZ"
#define CLI_SPLITPAY "SPLITPAY" #define CLI_SPLITPAY "SPLITPAY"
#define CLI_UTENTE "UTENTE"
#define CLI_DATAAGG "DATAAGG"
#endif #endif

View File

@ -25,7 +25,7 @@ bool TConfig_application::create()
user_create(); user_create();
dispatch_e_menu(_last_choice); dispatch_e_menu(_last_choice);
return TRUE; return true;
} }
bool TConfig_application::destroy() bool TConfig_application::destroy()
@ -51,12 +51,12 @@ bool TConfig_application::menu(MENU_TAG m)
bool TConfig_application::user_create() bool TConfig_application::user_create()
{ {
return TRUE; return true;
} }
bool TConfig_application::user_destroy() bool TConfig_application::user_destroy()
{ {
return TRUE; return true;
} }
@ -86,10 +86,10 @@ void TConfig_application::save_mask(bool tosave)
{ {
TString val; TString val;
val << '"' << value << '"'; val << '"' << value << '"';
_cnf->set(fname, val, NULL, TRUE, index > -1 ? index : -1); _cnf->set(fname, val, NULL, true, index > -1 ? index : -1);
} }
else else
_cnf->set(fname, value, NULL, TRUE, index > -1 ? index : -1); _cnf->set(fname, value, NULL, true, index > -1 ? index : -1);
} }
} }
} }
@ -205,17 +205,16 @@ void TConfig_application::on_firm_change()
void TConfig_application::set_config(int which) void TConfig_application::set_config(int which)
{ {
_which_config= which; _which_config= which;
} }
bool TConfig_application::preprocess_config (TMask& mask, TConfig& config) bool TConfig_application::preprocess_config (TMask& mask, TConfig& config)
{ {
return TRUE; return true;
} }
bool TConfig_application::postprocess_config (TMask& mask, TConfig& config) bool TConfig_application::postprocess_config (TMask& mask, TConfig& config)
{ {
return TRUE; return true;
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -225,8 +224,8 @@ bool TConfig_application::postprocess_config (TMask& mask, TConfig& config)
// //
// @rdesc Ritorna i seguenti valori: // @rdesc Ritorna i seguenti valori:
// //
// @flag TRUE | Se la modifica viene acettatta (dafault) // @flag true | Se la modifica viene acettatta (dafault)
// @flag FALSE | Se la modifica non viene accettata // @flag false | Se la modifica non viene accettata
bool TConfig_application::postprocess_config_changed( bool TConfig_application::postprocess_config_changed(
const char* par, // @parm Paragrafo in corso di editing const char* par, // @parm Paragrafo in corso di editing
const char* var, // @parm vedi <c TApplication> const char* var, // @parm vedi <c TApplication>
@ -237,7 +236,7 @@ bool TConfig_application::postprocess_config_changed(
// in corso di editing. E' chiamata per ogni parametro modificato. // in corso di editing. E' chiamata per ogni parametro modificato.
{ {
return TRUE; return true;
} }
TConfig_application::TConfig_application(int which_config) TConfig_application::TConfig_application(int which_config)

View File

@ -1,4 +1,4 @@
#define XI_INTERNAL #define XI_INTERNAL
#include <xinclude.h> #include <xinclude.h>
#ifndef STX_DATA #ifndef STX_DATA
@ -1277,15 +1277,10 @@ void TControl::set_caret_pos(int pos)
} }
const char* TControl::caption() const const char* TControl::caption() const
{ { return xi_get_text(_obj, NULL, 512); }
const char* c = xi_get_text(_obj, NULL, 512);
return c;
}
void TControl::set_caption(const char* c) void TControl::set_caption(const char* c)
{ { xi_set_text(_obj, c); }
xi_set_text(_obj, (char*)c);
}
void TControl::destroy() void TControl::destroy()
{ {
@ -1308,18 +1303,34 @@ TText_control::TText_control(WINDOW win, short cid,
bool bold, big; bool bold, big;
COLOR color; COLOR color;
TString t = parse_caption(text, bold, big, color); TString t = parse_caption(text, bold, big, color);
t.rtrim(); if (left >= 0)
if (width <= 0) {
width = t.len(); t.rtrim();
if (width <= 0)
width = t.len();
}
else
{
if (width <= 0)
width = t.len();
t.rtrim();
}
XI_OBJ* itf = get_interface(win); XI_OBJ* itf = get_interface(win);
XI_RCT rct = coord2rct(itf, left, top, width, height); XI_RCT rct = coord2rct(itf, left, top, width, height);
rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE; if (left >= 0)
if (big) rct.right += bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE;
else
rct.left -= bold ? (width*XI_FU_MULTIPLE/4) : XI_FU_MULTIPLE;
if (big)
{ {
rct.right += (rct.right - rct.left); if (left >= 0)
rct.right += (rct.right - rct.left);
else
rct.left -= (rct.right - rct.left);
rct.bottom += short(xvt_font_get_size(BIG_FONT) - xvt_font_get_size(DEF_FONT)); rct.bottom += short(xvt_font_get_size(BIG_FONT) - xvt_font_get_size(DEF_FONT));
} }
const unsigned long attrib = flags2attr(flags); const unsigned long attrib = flags2attr(flags);
XI_OBJ_DEF* def = xi_add_text_def(NULL, cid, &rct, attrib, t.get_buffer()); XI_OBJ_DEF* def = xi_add_text_def(NULL, cid, &rct, attrib, t.get_buffer());
@ -1355,7 +1366,10 @@ TGroupbox_control::TGroupbox_control(WINDOW win, short cid,
{ {
XI_OBJ* itf = get_interface(win); XI_OBJ* itf = get_interface(win);
XI_RCT rct = coord2rct(itf, left, top, width, height); XI_RCT rct = coord2rct(itf, left, top, width, height);
rct.top = _obj->v.text->xi_rct.bottom - 2;
//rct.top = _obj->v.text->xi_rct.bottom - 2;
rct.top += XI_FU_MULTIPLE;
rct.bottom -= XI_FU_MULTIPLE / 2; rct.bottom -= XI_FU_MULTIPLE / 2;
XI_OBJ_DEF* def = xi_add_rect_def(NULL, cid, &rct, XI_ATR_VISIBLE, 0, 0); // Ignore colors XI_OBJ_DEF* def = xi_add_rect_def(NULL, cid, &rct, XI_ATR_VISIBLE, 0, 0); // Ignore colors
@ -1378,7 +1392,12 @@ TGroupbox_control::TGroupbox_control(WINDOW win, short cid,
CHECKD(_rct, "Can't create Groupbox_control ", cid); CHECKD(_rct, "Can't create Groupbox_control ", cid);
XI_RCT& rt = _obj->v.text->rct; XI_RCT& rt = _obj->v.text->rct;
rt.top--; rt.bottom--; //rt.top--; rt.bottom--;
const int txt_height = rt.bottom-rt.top;
rt.bottom = _rct->v.rect->rct.top - 1;
rt.top = rt.bottom - txt_height + 2;
rt.left = _rct->v.rect->rct.left;
rt.right = _rct->v.rect->rct.right;
xi_dequeue(); xi_dequeue();
xi_tree_free(def); xi_tree_free(def);

View File

@ -138,7 +138,7 @@ int TDate::wday() const
if (m <= 2) // Gennaio e Febbraio sono gli ultimi mesi dell'anno scorso if (m <= 2) // Gennaio e Febbraio sono gli ultimi mesi dell'anno scorso
{ {
y --; y--;
m += 12; m += 12;
} }

View File

@ -1,3 +1,4 @@
#pragma once
#ifndef __DATE_H #ifndef __DATE_H
#define __DATE_H #define __DATE_H

View File

@ -402,19 +402,17 @@ const TString& TDongle::short_name() const
const TString& TDongle::server_name() const const TString& TDongle::server_name() const
{ {
if (network()) TString& tmp = get_tmp_string(50);
if (network() && !xvt_sys_dongle_server_running())
{ {
const int sr = xvt_sys_dongle_server_running(); if (hardware() == _dongle_ssanet)
if (sr == 0) tmp = ini_get_string(CONFIG_SSA, NULL, "Port");
{ else
if (hardware() == _dongle_ssanet) tmp = ini_get_string(CONFIG_INSTALL, "Server", "Dongle");
return ini_get_string(CONFIG_SSA, NULL, "Port");
return ini_get_string(CONFIG_INSTALL, "Server", "Dongle");
}
} }
TString& tmp = get_tmp_string(50); if (tmp.blank())
xvt_sys_get_host_name(tmp.get_buffer(), tmp.size()); xvt_sys_get_host_name(tmp.get_buffer(), tmp.size());
return tmp; return tmp;
} }
@ -679,9 +677,14 @@ bool TEnigma_machine::init()
{ {
_scan = new TScanner(DNINST_PATH); _scan = new TScanner(DNINST_PATH);
::srand(883); ::srand(883);
TString4 l1; line(l1);
_year_assist = atoi(l1); const TString& first_line = _scan->line();
::srand(_year_assist); if (first_line.len() == 4)
{
TString4 l1; decode_string(first_line, l1);
_year_assist = atoi(l1);
::srand(_year_assist);
}
} }
return _scan != NULL; return _scan != NULL;
} }
@ -987,8 +990,9 @@ int Tdninst::check_customer() const
else else
{ {
TEnigma_machine em; TEnigma_machine em;
if (em.ok() && em.year_assist() > 2100 && em.find_serno(serno)) if (em.ok() && em.year_assist() > 2150 && em.find_serno(serno))
{ {
const TDate oggi(TODAY);
error = 0; error = 0;
TToken_string l(80, '='); TToken_string l(80, '=');
while (em.line(l) && error == 0) while (em.line(l) && error == 0)
@ -997,7 +1001,6 @@ int Tdninst::check_customer() const
break; break;
if (l[0]=='*' || l.starts_with("MustCall")) if (l[0]=='*' || l.starts_with("MustCall"))
{ {
const TDate oggi(TODAY);
TString16 str; TString16 str;
TDate ds; TDate ds;
if (parse_date(l, str, ds) && oggi >= ds) if (parse_date(l, str, ds) && oggi >= ds)

View File

@ -235,7 +235,7 @@ public:
void backtrace(int step = 1) void backtrace(int step = 1)
{ if (_ip > step) _ip -= step; else begin(); } { if (_ip > step) _ip -= step; else begin(); }
// @cmember Costruttore. Crea un array di 50 elementi // @cmember Costruttore. Crea un array di 50 elementi
TCodearray(int size = 50) : TArray(size), _ip(0) TCodearray(int size = 64) : TArray(size), _ip(0)
{} {}
// @cmember Distruttore // @cmember Distruttore
virtual ~TCodearray() virtual ~TCodearray()

View File

@ -56,6 +56,8 @@ bool edit_url(const char* url)
bool ok = xvt_sys_goto_url(url, "edit") != 0; bool ok = xvt_sys_goto_url(url, "edit") != 0;
if (!ok) if (!ok)
ok = goto_url(url); ok = goto_url(url);
if (ok)
do_events();
return ok; return ok;
} }

View File

@ -1,4 +1,5 @@
#define __ISAM_CPP #define __ISAM_CPP
#define _CRT_SECURE_NO_WARNINGS 1
#include <config.h> #include <config.h>
#include <execp.h> #include <execp.h>
@ -11,7 +12,6 @@
#include <prefix.h> #include <prefix.h>
#include <progind.h> #include <progind.h>
#include <recarray.h> #include <recarray.h>
#include <relation.h>
#include <scanner.h> #include <scanner.h>
#include <tabmod.h> #include <tabmod.h>
#include <utility.h> #include <utility.h>
@ -207,7 +207,7 @@ void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
if (!__field_changed) if (!__field_changed)
return; return;
} }
strncpy(&recout[l - len], s, len) ; strncpy(&recout[l-len], s, len) ;
} }
else else
{ {
@ -441,68 +441,6 @@ HIDDEN void browse_null(char *start, int nc)
// Traduce l'espressione chiave di CodeBase // Traduce l'espressione chiave di CodeBase
/*HIDDEN const char * translate_key(const char* key)
{
// Trasforma l'espressione
TToken_string t = key;
TToken_string k(t.get(0),'+');
TToken_string range("",',');
TString ws;
const bool is_dup = t.get(1)[0] == 'X';
const int items = k.items();
t = "";
for (int i = 0; i<items; i++) // scorre i campi dell'espressione
{
ws = k.get(i); ws.upper(); // Primo campo
const bool is_upper = ws.find("UPPER") >= 0;
const bool is_sub = ws.find("SUBSTR") >= 0;
int paren1 = ws.find('('); // Trova la prima parentesi aperta
int paren2,last,from = 0,to = 0;
if (paren1 >= 0 && is_sub && is_upper)
paren1 = ws.find('('); // Trova la seconda parentesi (in questo caso c'e' per forza)
if (paren1 >= 0) // Trova la prima virgola o parentesi chiusa (per qualsiasi espressione)
{
paren2 = ws.find(',');
if (paren2 == -1) // se non ci sono virgole trova la parentesi chiusa
paren2 = ws.find(')');
CHECK(paren2 > paren1,"Something wrong happened translating CodeBase expressions.");
if (is_sub) // Se e' una sottostringa estrae i campi DA e A
{
range = ws;
last = ws.find(')');
range.sub(paren2,last); // dalla virgola alla parentesi
from = range.get_int(0);
to = range.get_int(1);
}
ws = ws.sub(paren1+1,paren2); // Nome del campo pulito pulito
ws.upper();
}
if (is_upper)
t << "UPPER(";
t << ws; // aggiunge il nome del campo
if (is_sub)
{
t << "[";
t << from << ",";
t << to << "]";
}
if (is_upper)
t << ")";
t << '+';
}
t.rtrim(1); // Toglie il + in piu'
t.add(is_dup ? "X" : " ");
TString& tmp = get_tmp_string();
tmp = t;
return tmp;
} */
HIDDEN int __build_key(const RecDes& recd, int numkey, const RecType recin, char *key, bool build_x_cb) HIDDEN int __build_key(const RecDes& recd, int numkey, const RecType recin, char *key, bool build_x_cb)
/* *recd; descrittore record */ /* *recd; descrittore record */
/* numkey; numero chiave */ /* numkey; numero chiave */
@ -964,7 +902,7 @@ int TBaseisamfile::_readat(TRectype& rec, TRecnotype nrec, word lockop)
if (_lasterr != NOERR) if (_lasterr != NOERR)
_lasterr = get_error(_lasterr); _lasterr = get_error(_lasterr);
else else
rec = (const char *) DB_getrecord(fhnd); rec = (const char*)DB_getrecord(fhnd);
_recno = DB_recno(fhnd); _recno = DB_recno(fhnd);
if (rec.has_memo()) if (rec.has_memo())
rec.init_memo(_recno, _isam_handle); rec.init_memo(_recno, _isam_handle);
@ -978,7 +916,7 @@ int TBaseisamfile::_write(const TRectype& rec)
// Controlla che la chiave sia piena // Controlla che la chiave sia piena
TString256 key; TString256 key;
__build_key(rec.rec_des(), 1, rec.string(), key.get_buffer(), TRUE); __build_key(rec.rec_des(), 1, rec.string(), key.get_buffer(), true);
if (key.blank()) if (key.blank())
return _iskeyerr; return _iskeyerr;
@ -1359,7 +1297,8 @@ bool TBaseisamfile::is_changed_since(long& last) const
bool yes = false; bool yes = false;
#ifdef WIN32 #ifdef WIN32
const int fh = ::_sopen(filename(), _O_RDONLY, _SH_DENYNO); int fh = 0;
::_sopen_s(&fh, filename(), _O_RDONLY, _SH_DENYNO, _S_IREAD);
if (fh > 0) if (fh > 0)
{ {
struct stat stat; struct stat stat;
@ -1625,7 +1564,7 @@ int TIsamtempfile::close()
if (c & 8 || c & 2) // CLIPPER and DBIII format if (c & 8 || c & 2) // CLIPPER and DBIII format
{ {
f.ext("cgp"); f.ext("cgp");
FILE *fp=fopen(f,"r"); FILE* fp=NULL; fopen_s(&fp, f, "r");
char in[16]; char in[16];
while (fgets(in,16,fp)!=NULL) while (fgets(in,16,fp)!=NULL)
{ {
@ -2175,7 +2114,7 @@ int TSystemisamfile::update(
{ {
tmpfname.ext("cgp"); tmpfname.ext("cgp");
TFilename a; TFilename a;
FILE *fp=fopen(tmpfname,"rb"); FILE *fp=NULL; fopen_s(&fp, tmpfname,"rb");
while (fgets(a.get_buffer(),16,fp) != NULL) while (fgets(a.get_buffer(),16,fp) != NULL)
{ {
a.rtrim(1); // Cut \n a.rtrim(1); // Cut \n
@ -2572,7 +2511,7 @@ int TSystemisamfile::overwrite(
{ {
int err=NOERR; int err=NOERR;
FILE* fl = fopen(from, "r"); FILE* fl = NULL; fopen_s(&fl, from, "r");
if (fl == NULL) if (fl == NULL)
{ {
error_box("Impossibile aprire il file %s",from); error_box("Impossibile aprire il file %s",from);
@ -2798,8 +2737,7 @@ int TSystemisamfile::dump(
// @xref <mf TSystemisamfile::load> // @xref <mf TSystemisamfile::load>
{ {
FILE* f = fopen(to, "w"); FILE* f = NULL; fopen_s(&f, to, "w");
if (f == NULL) if (f == NULL)
{ {
setstatus(2); setstatus(2);
@ -3008,8 +2946,7 @@ int TSystemisamfile::dump(
// @xref <mf TSystemisamfile::load> // @xref <mf TSystemisamfile::load>
{ {
FILE* f = fopen(to, "w"); FILE* f = NULL; fopen_s(&f, to, "w");
if (f == NULL) if (f == NULL)
{ {
setstatus(2); setstatus(2);
@ -3262,7 +3199,7 @@ TRectype::TRectype(const TRectype& r)
*_memo_data = *r._memo_data; *_memo_data = *r._memo_data;
} }
memcpy(_rec, r._rec, _length); memcpy(_rec, r._rec, _length);
strcpy(_tab, r._tab); strcpy_s(_tab, sizeof(_tab), r._tab);
setempty(r.empty()); setempty(r.empty());
} }
@ -3330,7 +3267,7 @@ void TRectype::init_memo(TRecnotype recno, TIsam_handle file)
void TRectype::settab(const char *tab) void TRectype::settab(const char *tab)
{ {
strcpy(_tab, tab); strcpy_s(_tab, sizeof(_tab), tab);
zero(); zero();
} }
@ -3818,7 +3755,7 @@ TRectype& TRectype::operator =(const TRectype& rec)
init_memo(rec._memo_data->recno(), rec._memo_data->file()); init_memo(rec._memo_data->recno(), rec._memo_data->file());
*_memo_data = *rec._memo_data; *_memo_data = *rec._memo_data;
} }
strcpy(_tab, rec._tab); strcpy_s(_tab, sizeof(_tab), rec._tab);
setempty(rec.empty()); // Copy emptiness status setempty(rec.empty()); // Copy emptiness status
return *this; return *this;
} }
@ -3919,10 +3856,10 @@ void TRectype::renum_key(const char* field, const char* val)
// Certified 99% // Certified 99%
TRectype& TRectype::operator =(const char* rec) TRectype& TRectype::operator =(const char* rec)
{ {
if (rec && * rec) if (rec && *rec)
{ {
memcpy(_rec, rec, _length); memcpy(_rec, rec, _length);
setempty(FALSE); setempty(false);
} }
else else
zero(); zero();
@ -3932,7 +3869,7 @@ TRectype& TRectype::operator =(const char* rec)
const char* TRectype::key(int numkey) const const char* TRectype::key(int numkey) const
{ {
TString& tmp = get_tmp_string(256); TString& tmp = get_tmp_string(256);
__build_key(rec_des(), numkey, _rec, tmp.get_buffer(), FALSE); __build_key(rec_des(), numkey, _rec, tmp.get_buffer(), false);
return tmp; return tmp;
} }
@ -3956,8 +3893,8 @@ bool TRectype::send_mail(const char* action) const
bool ok = ::can_dispatch_transaction(*this); bool ok = ::can_dispatch_transaction(*this);
if (ok) if (ok)
{ {
TFilename ininame; ininame.temp(); TFilename ininame; ininame.temp("msg", "ini");
if (ok) // Test qualunque per usare {} if (ok) // Dummy test per {}
{ {
TConfig ini(ininame, "Transaction"); TConfig ini(ininame, "Transaction");
ini.set("Action", action); ini.set("Action", action);
@ -3965,7 +3902,7 @@ bool TRectype::send_mail(const char* action) const
fill_transaction(ini); fill_transaction(ini);
} }
ok = ::dispatch_transaction(*this, ininame); ok = ::dispatch_transaction(*this, ininame);
::remove(ininame); ininame.fremove();
} }
return ok; return ok;
} }

View File

@ -2207,15 +2207,48 @@ bool TEdit_field::parse_item(TScanner& scanner)
} }
else scanner.push(); else scanner.push();
TString filter; TString filter;
if (scanner.popkey() == "SE") if (scanner.popkey() == "SE")
filter = (const char*)scanner.line(); filter = (const char*)scanner.line();
else else
scanner.push(); scanner.push();
TToken_string orderby;
if (scanner.popkey() == "BY")
{
const char sep = orderby.separator();
orderby.separator(' ');
orderby = scanner.line();
orderby.strip_double_spaces();
orderby.replace(' ', sep);
orderby.separator(sep);
// Trasforma i nomi dei files in numeri se necessario
if (orderby.find('.') > 0)
{
TToken_string fld(16, '.');
TString16 name;
for (int i = 0; orderby.get(i, fld); i++)
{
if (!isdigit(fld[0]) && fld.find('.') > 0)
{
fld.get(0, name);
const int num = ::table2logic(name);
if (num != 0)
{
fld.add(num, 0);
orderby.add(fld, i);
}
}
}
}
}
else
scanner.push();
if (r != NULL) if (r != NULL)
{ {
_browse = new TBrowse(this, r, key, filter); // create browse with no filter ... _browse = new TBrowse(this, r, key, filter, orderby); // create browse
// ... complete relation by parsing all Join items ... // ... complete relation by parsing all Join items ...
while (scanner.popkey() == "JO") while (scanner.popkey() == "JO")
@ -2868,7 +2901,7 @@ void TDate_field::create(WINDOW w)
TEdit_field::create(w); TEdit_field::create(w);
if (automagic()) if (automagic())
{ {
TDate d(TODAY); const TDate d(TODAY);
set(d.string()); set(d.string());
} }
} }

View File

@ -6,7 +6,7 @@
#define NPAUT 2 #define NPAUT 2
#define FEAUT 3 #define FEAUT 3
#define M77AUT 4 #define M77AUT 4
// #define GIAUT 5 Obsoleta Gestione IVA implicita in CG (7) #define GDAUT 5
#define SEAUT 6 #define SEAUT 6
#define CGAUT 7 #define CGAUT 7
#define CIAUT 8 #define CIAUT 8

View File

@ -547,9 +547,6 @@ TSpreadsheet::TSpreadsheet(
l->active_back_color = FOCUS_BACK_COLOR; l->active_back_color = FOCUS_BACK_COLOR;
l->white_space_color = MASK_DARK_COLOR; l->white_space_color = MASK_DARK_COLOR;
l->rule_color = MASK_DARK_COLOR; l->rule_color = MASK_DARK_COLOR;
#ifdef LINUX
l->scroll_on_thumb_track = true;
#endif
// Definizione della prima colonna (numero di riga) // Definizione della prima colonna (numero di riga)
word attr = XI_ATR_RJUST; word attr = XI_ATR_RJUST;
@ -759,9 +756,7 @@ void TSpreadsheet::update_rec(int rec)
const bool has_focus = rec == selected() && mask().focus_field().dlg() == owner().dlg(); const bool has_focus = rec == selected() && mask().focus_field().dlg() == owner().dlg();
// if (has_focus) xi_set_focus(get_interface()); // if (has_focus) xi_set_focus(get_interface());
XI_OBJ row; XI_MAKE_ROW(&row, _obj, riga);
XI_OBJ row;
XI_MAKE_ROW(&row, _obj, riga);
xi_cell_request(&row); // Update internal values xi_cell_request(&row); // Update internal values
if (has_focus) if (has_focus)

View File

@ -223,7 +223,8 @@ void TMultiple_rectype::renum_key()
if (i==0) if (i==0)
oldkey=b->key().build_key(); oldkey=b->key().build_key();
// convertire al piu' presto le seguenti righe ... // convertire al piu' presto le seguenti righe ...
TRectype * rec = new TRectype(b->key()); //TRectype * rec = new TRectype(b->key()); // Crea riga della classe base?
TRectype* rec = new_body_record(logicnum); // Crea riga della classe giusta!
set_body_key(*rec); set_body_key(*rec);
b->set_key(rec); // Aggiorna righe b->set_key(rec); // Aggiorna righe
// .. nella piu' economiche // .. nella piu' economiche

View File

@ -24,26 +24,8 @@
// [JCW 95-Dec-20] comments added for distribution 95a // [JCW 95-Dec-20] comments added for distribution 95a
// [JCW 96-Jan-01] removed UDP capabilities from skstream // [JCW 96-Jan-01] removed UDP capabilities from skstream
#ifdef INCSTR_H #pragma warning(disable:4005)
#include <incstr.h> #include "winsock2.h"
#endif
#ifdef WIN32
#include "winsock.h"
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define SOCKADDR_IN sockaddr_in
#define closesocket close
#define BYTE byte
#endif
// //
// sockbuf // sockbuf
@ -954,7 +936,7 @@ bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local
return ok; return ok;
} }
HIDDEN int find_href(const TString& riga, int from, TString& filename) HIDDEN int find_href(const TString& riga, int from, TString& filename, const TString& pattern)
{ {
while (from >= 0) while (from >= 0)
{ {
@ -971,10 +953,10 @@ HIDDEN int find_href(const TString& riga, int from, TString& filename)
else else
{ {
filename = riga.mid(href); filename = riga.mid(href);
from = -1; from = riga.len();
} }
filename.trim(); filename.trim();
if (filename.match("*.*")) if (filename.match(pattern, true))
break; break;
} }
else else
@ -988,9 +970,9 @@ HIDDEN int find_href(const TString& riga, int from, TString& filename)
bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& list) bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& list)
{ {
TFilename local; local.temp(); TFilename local; local.temp("dir", "html");
TString server = remote, pattern; TString server = remote, pattern = "*.*";
bool ok = false; bool ok = false;
if (server.find('*') > 0 || server.find('?') > 0) if (server.find('*') > 0 || server.find('?') > 0)
{ {
@ -1005,18 +987,15 @@ bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& lis
ok = HttpGetFile(id, server, local); ok = HttpGetFile(id, server, local);
if (ok) if (ok)
{ {
TString riga(512); TString riga(1024);
TFilename name; TFilename name;
ifstream s(local); ifstream s(local);
while (!s.eof()) while (!s.eof())
{ {
s.getline(riga.get_buffer(), riga.size()); s.getline(riga.get_buffer(), riga.size());
riga.lower(); riga.lower();
for (int href = find_href(riga, 0, name); href >= 0; href = find_href(riga, href, name)) for (int href = find_href(riga, 0, name, pattern); href >= 0; href = find_href(riga, href, name, pattern))
{ list.add(name);
if (pattern.blank() || name.match(pattern, true))
list.add(name);
}
} }
s.close(); s.close();
xvt_fsys_remove_file(local); xvt_fsys_remove_file(local);

View File

@ -1,3 +1,4 @@
#pragma once
#ifndef __OBJECT_H #ifndef __OBJECT_H
#define __OBJECT_H #define __OBJECT_H

View File

@ -800,12 +800,15 @@ long TFile_manager::last_change(TIsam_handle name) const
return i.last_change(); return i.last_change();
} }
int TFile_manager::close_closeable() int TFile_manager::close_closeable(bool firm_only)
{ {
_open_files = 0; // Ricalcolo per sicurezza _open_files = 0; // Ricalcolo per sicurezza
for (TIsam_handle n = _fileinfo.last(); n > 0; n = _fileinfo.pred(n)) for (TIsam_handle n = _fileinfo.last(); n > 0; n = _fileinfo.pred(n))
{ {
TFile_info& i = fileinfo(n); TFile_info& i = fileinfo(n);
if (firm_only && i.dir_type() != _nordir)
continue;
if (i.is_open()) if (i.is_open())
{ {
_open_files++; _open_files++;
@ -821,9 +824,9 @@ int TFile_manager::close_closeable()
return _open_files; return _open_files;
} }
void TFile_manager::close_all() void TFile_manager::close_all(bool firm_only)
{ {
const int zoccolo_duro = close_closeable(); const int zoccolo_duro = close_closeable(firm_only);
#ifdef DBG #ifdef DBG
if (zoccolo_duro > 0) if (zoccolo_duro > 0)
NFCHECK("%d files refuse to be closed!", zoccolo_duro); NFCHECK("%d files refuse to be closed!", zoccolo_duro);
@ -832,6 +835,8 @@ void TFile_manager::close_all()
for (int n = _recinfo.last(); n > 0; n = _recinfo.pred(n)) for (int n = _recinfo.last(); n > 0; n = _recinfo.pred(n))
{ {
const TRecord_info& r = recinfo(n); const TRecord_info& r = recinfo(n);
if (firm_only && r.dir_type() != _nordir)
continue;
if (r.mutable_dir()) if (r.mutable_dir())
_recinfo.destroy(n); _recinfo.destroy(n);
} }
@ -1016,14 +1021,15 @@ void TPrefix::set(
return; return;
if (_prefix != ".") if (_prefix != ".")
{ {
_manager.close_all(); const bool firm_only = !xvt_str_same(name, "COM") && !xvt_str_same(name, "DEF");
_manager.close_all(firm_only);
CCloseDir(NORDIR); CCloseDir(NORDIR);
CCloseDir(COMDIR); CCloseDir(COMDIR);
CCloseRecDir(NORDIR); CCloseRecDir(NORDIR);
CCloseRecDir(COMDIR); CCloseRecDir(COMDIR);
} }
if (strcmp(name, "DEF") == 0) if (xvt_str_same(name, "DEF"))
{ {
const char* prfx = CGetPref(); const char* prfx = CGetPref();
xvt_fsys_parse_pathname(prfx, NULL, NULL, _prefix.get_buffer(), NULL, NULL); xvt_fsys_parse_pathname(prfx, NULL, NULL, _prefix.get_buffer(), NULL, NULL);
@ -1080,12 +1086,11 @@ bool TPrefix::exist(long codditta) const
bool TPrefix::test(const char* s) const bool TPrefix::test(const char* s) const
{ {
if (s && *s && strcmp(s, "DEF") != 0) if (s && *s && !xvt_str_same(s, "DEF"))
{ {
TFilename s1(__ptprf); TFilename s1(__ptprf);
s1.add(s); s1.add(s);
s1.add("dir.gen"); s1.add("dir.gen");
if (s1.exist()) if (s1.exist())
{ {
if (xvt_fsys_access(s1, 0x2) != 0) if (xvt_fsys_access(s1, 0x2) != 0)

View File

@ -54,8 +54,8 @@ public:
void notify_change(TIsam_handle name); void notify_change(TIsam_handle name);
long last_change(TIsam_handle name) const; long last_change(TIsam_handle name) const;
int close_closeable(); int close_closeable(bool firm_only = false);
void close_all(); void close_all(bool firm_only = false);
void open_all(); void open_all();
TFile_manager(); TFile_manager();
@ -138,19 +138,16 @@ public:
// @cmember Setta lo studio corrente // @cmember Setta lo studio corrente
bool set_studio(const char* study, long firm = 0); bool set_studio(const char* study, long firm = 0);
// @cmember Ritorna il contenuto della variabile <p _prefix> // @cmember Ritorna il contenuto della variabile <p _prefix>
const char* name() const const char* name() const { return _prefix; }
{ return _prefix;}
// @cmember Ritorna il livello degli archivi // @cmember Ritorna il livello degli archivi
unsigned int filelevel() const unsigned int filelevel() const { return _filelevel; }
{return _filelevel;}
// @cmember Ritorna il livello standard degli archivi // @cmember Ritorna il livello standard degli archivi
unsigned int get_stdlevel() const { return _stdlevel; } unsigned int get_stdlevel() const { return _stdlevel; }
void set_stdlevel(unsigned int sl) { _stdlevel = sl; } void set_stdlevel(unsigned int sl) { _stdlevel = sl; }
// @cmember Ritorna il numero di archivi // @cmember Ritorna il numero di archivi
int items() const int items() const { return _items; }
{ return _items; }
// @cmember Ritorna la descrizione del file passato // @cmember Ritorna la descrizione del file passato
const char* description(const char* cod) const; const char* description(const char* cod) const;
// @cmember Ritorna la descrizione del file passato // @cmember Ritorna la descrizione del file passato
@ -166,7 +163,7 @@ public:
// @cmember Riapre tutti gli archivi della ditta attiva // @cmember Riapre tutti gli archivi della ditta attiva
void reopen() const ; void reopen() const ;
TIsam_handle open_isamfile(int& logicnum, TFilename& name, bool excl = FALSE, bool idx = TRUE) TIsam_handle open_isamfile(int& logicnum, TFilename& name, bool excl = false, bool idx = true)
{ return _manager.open(logicnum, name, excl, idx); } { return _manager.open(logicnum, name, excl, idx); }
int close_isamfile(TIsam_handle& name) int close_isamfile(TIsam_handle& name)

View File

@ -55,11 +55,11 @@
#define RDOC_DAPROVV "DAPROVV" #define RDOC_DAPROVV "DAPROVV"
#define RDOC_DANDOC "DANDOC" #define RDOC_DANDOC "DANDOC"
#define RDOC_DAIDRIGA "DAIDRIGA" #define RDOC_DAIDRIGA "DAIDRIGA"
#define RDOC_ACODNUM "DACODNUM" #define RDOC_ACODNUM "ACODNUM"
#define RDOC_AANNO "DAANNO" #define RDOC_AANNO "AANNO"
#define RDOC_APROVV "DAPROVV" #define RDOC_APROVV "APROVV"
#define RDOC_ANDOC "DANDOC" #define RDOC_ANDOC "ANDOC"
#define RDOC_AIDRIGA "DAIDRIGA" #define RDOC_AIDRIGA "AIDRIGA"
#define RDOC_CODCMS "CODCMS" #define RDOC_CODCMS "CODCMS"
#define RDOC_FASCMS "FASCMS" #define RDOC_FASCMS "FASCMS"
#define RDOC_CODCOSTO "CODCOSTO" #define RDOC_CODCOSTO "CODCOSTO"

View File

@ -5,16 +5,13 @@
#include <colors.h> #include <colors.h>
#include <dongle.h> #include <dongle.h>
#include <expr.h> #include <expr.h>
#include <modaut.h>
#include <progind.h> #include <progind.h>
#include <recarray.h> #include <recarray.h>
#include <recset.h> #include <recset.h>
#include <relation.h> #include <sheet.h>
#include <utility.h> #include <utility.h>
#include <xml.h> #include <xml.h>
#include <statbar.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utility // Utility
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -105,7 +102,7 @@ bool TRecordset::save_as_html(const char* path)
if (out.fail()) if (out.fail())
return false; return false;
TProgind pi(items(), TR("Esportazione in corso..."), true, true); TProgress_monitor pi(items(), TR("Esportazione in corso..."), true);
out << "<html>" << endl; out << "<html>" << endl;
save_html_head(out, main_app().title()); save_html_head(out, main_app().title());
@ -177,7 +174,7 @@ bool TRecordset::save_as_html(const char* path)
TString val; TString val;
for (bool ok = move_first(); ok; ok = move_next()) for (bool ok = move_first(); ok; ok = move_next())
{ {
if (!pi.addstatus(1)) if (!pi.add_status())
break; break;
out << " <tr>" << endl; out << " <tr>" << endl;
@ -235,7 +232,7 @@ bool TRecordset::save_as_html(const char* path)
out << "</body>" << endl; out << "</body>" << endl;
out << "</html>" << endl; out << "</html>" << endl;
return !pi.iscancelled(); return !pi.is_cancelled();
} }
bool TRecordset::save_as_text(const char* path) bool TRecordset::save_as_text(const char* path)
@ -244,7 +241,7 @@ bool TRecordset::save_as_text(const char* path)
if (out.fail()) if (out.fail())
return false; return false;
TProgind pi(items(), TR("Esportazione in corso..."), true, true); TProgress_monitor pi(items(), TR("Esportazione in corso..."), true);
TString val; TString val;
const char sep = text_separator(); const char sep = text_separator();
@ -291,11 +288,11 @@ bool TRecordset::save_as_text(const char* path)
} }
} }
out << endl; out << endl;
if (!pi.addstatus(1)) if (!pi.add_status())
break; break;
} }
return !pi.iscancelled(); return !pi.is_cancelled();
} }
bool TRecordset::save_as_campo(const char* path) bool TRecordset::save_as_campo(const char* path)
@ -304,7 +301,7 @@ bool TRecordset::save_as_campo(const char* path)
if (out.fail()) if (out.fail())
return false; return false;
TProgind pi(items(), TR("Esportazione in corso..."), true, true); TProgress_monitor pi(items(), TR("Esportazione in corso..."), true);
out << "[Head]" << endl; out << "[Head]" << endl;
out << "Version=0"; out << "Version=0";
@ -349,10 +346,10 @@ bool TRecordset::save_as_campo(const char* path)
} }
} }
out << endl; out << endl;
if (!pi.addstatus(1)) if (!pi.add_status())
break; break;
} }
return !pi.iscancelled(); return !pi.is_cancelled();
} }
bool TRecordset::save_as_dbf(const char* table, int mode) bool TRecordset::save_as_dbf(const char* table, int mode)
@ -1647,7 +1644,7 @@ void TISAM_recordset::set(const char* use)
const TString& TISAM_recordset::driver_version() const const TString& TISAM_recordset::driver_version() const
{ {
TString& tmp = get_tmp_string(20); TString& tmp = get_tmp_string();
DB_version(tmp.get_buffer(), tmp.size()); DB_version(tmp.get_buffer(), tmp.size());
return tmp; return tmp;
} }

View File

@ -1,22 +1,18 @@
#ifndef __RECORDSET_H #ifndef __RECORDSET_H
#define __RECORDSET_H #define __RECORDSET_H
#ifndef __ASSOC_H #ifndef XVT_INCL_XVT
#include <assoc.h> #include <xvt.h>
#endif #endif
#ifndef __SHEET_H #ifndef __RELATION_H
#include <sheet.h> #include <relation.h>
#endif #endif
#ifndef __VARIANT_H #ifndef __VARIANT_H
#include <variant.h> #include <variant.h>
#endif #endif
#ifndef __XVT_H
#include <xvt.h>
#endif
struct TRecordset_column_info : public TObject struct TRecordset_column_info : public TObject
{ {
TString _name; // Table.Column TString _name; // Table.Column
@ -40,16 +36,16 @@ struct TAttributes : public TObject
COLOR _back; COLOR _back;
COLOR _fore; COLOR _fore;
public: public:
XVT_FNTID get_font() const{ return _font; } XVT_FNTID get_font() const{ return _font; }
COLOR get_background() const { return _back; } COLOR get_background() const { return _back; }
COLOR get_foreground() const { return _fore; } COLOR get_foreground() const { return _fore; }
void set_font(XVT_FNTID font) { _font = font; } void set_font(XVT_FNTID font) { _font = font; }
void set_background(COLOR back) { _back = back; } void set_background(COLOR back) { _back = back; }
void set_foreground(COLOR fore) { _fore = fore; } void set_foreground(COLOR fore) { _fore = fore; }
TAttributes() : _font(NULL), _back(COLOR_INVALID), _fore(COLOR_INVALID) {} TAttributes() : _font(NULL), _back(COLOR_INVALID), _fore(COLOR_INVALID) {}
virtual ~TAttributes() {} virtual ~TAttributes() {}
}; };
@ -163,22 +159,6 @@ public:
virtual ~TISAM_recordset(); virtual ~TISAM_recordset();
}; };
///////////////////////////////////////////////////////////
// TRecordset_sheet
///////////////////////////////////////////////////////////
class TRecordset_sheet : public TSheet
{
TRecordset& _query;
protected:
virtual void get_row(long r, TToken_string& row);
virtual long get_items() const;
public:
TRecordset_sheet(TRecordset& sql, const char* title = "Query", byte buttons = 0);
};
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Utility // Utility
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -2039,7 +2039,7 @@ bool TRelation_application::mask2mail(const TMask& m)
bool ok = _curr_trans_from.empty() && ::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("msg", "ini");
if (ok) // Test qualunque per usare {} if (ok) // Test qualunque per usare {}
{ {
TConfig ini(ininame, "Transaction"); TConfig ini(ininame, "Transaction");

View File

@ -1,9 +1,9 @@
#include <colors.h> #include <colors.h>
#include <defmask.h> #include <defmask.h>
#include <expr.h> #include <expr.h>
#include <mask.h>
#include <printer.h> #include <printer.h>
#include <recarray.h> #include <recarray.h>
#include <relation.h>
#include <reprint.h> #include <reprint.h>
#include <utility.h> #include <utility.h>
#include <xml.h> #include <xml.h>
@ -2989,9 +2989,9 @@ void TReport::msg_isam_read(TVariant_stack& stack)
else else
{ {
TLocalisamfile file(logicnum); TLocalisamfile file(logicnum);
file.setkey(fkey);
TRectype& rec = file.curr(); TRectype& rec = file.curr();
rec = keyrec; rec = keyrec;
file.setkey(fkey);
if (file.read() != NOERR) if (file.read() != NOERR)
rec.zero(); rec.zero();
do_isam_read_output(rec, out); // Se rec e' vuoto azzera gli outputs do_isam_read_output(rec, out); // Se rec e' vuoto azzera gli outputs

View File

@ -1907,7 +1907,7 @@ void TBook::split_file(int colonne)
{ {
TProgind pi(pages(), TR("Rigenerazione pagine"), true, true); TProgind pi(pages(), TR("Rigenerazione pagine"), true, true);
TFilename temp; temp.temp(); TFilename temp; temp.temp("bck");
ofstream out(temp); ofstream out(temp);
TPointer_array index; TPointer_array index;
@ -1979,7 +1979,7 @@ void TBook::join_file(int pps)
{ {
TProgind pi(pages(), TR("Rigenerazione pagine"), true, true); TProgind pi(pages(), TR("Rigenerazione pagine"), true, true);
TFilename temp; temp.temp(); TFilename temp; temp.temp("bck");
ofstream out(temp); ofstream out(temp);
close_output(); // Chiudo file di stampa eventualmente aperto close_output(); // Chiudo file di stampa eventualmente aperto
@ -2178,7 +2178,7 @@ bool TBook::export_pdf(TFilename& filename, bool signature)
{ {
// Evita problemi di aggiornamento del pdf: deve sempre rigenerarlo! // Evita problemi di aggiornamento del pdf: deve sempre rigenerarlo!
if (filename.exist() && !filename.fremove()) if (filename.exist() && !filename.fremove())
return error_box(FR("Impossibile riscrivere %s"), (const char*)filename); return cantwrite_box(filename);
_pdf_file = filename; _pdf_file = filename;
_pagefrom = 1; _pagefrom = 1;

View File

@ -1,10 +1,6 @@
#ifndef __SCANNER_H #ifndef __SCANNER_H
#define __SCANNER_H #define __SCANNER_H
#ifndef INCSTR_H
#include <incstr.h>
#endif
#ifndef __STRINGS_H #ifndef __STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif

View File

@ -78,7 +78,7 @@ public:
void enable_row(long r, bool on); void enable_row(long r, bool on);
void disable_row(long r); void disable_row(long r);
bool row_enabled(long n) const { return _disabled[n] == FALSE; } bool row_enabled(long n) const { return !_disabled[n]; }
bool one_enabled() const { return _disabled.ones() < _sheet->items(); } bool one_enabled() const { return _disabled.ones() < _sheet->items(); }
byte column_type(int c) const { CHECKD(c >= 0 && c < MAX_COL, "Bad column ", c); return _type[c]; } byte column_type(int c) const { CHECKD(c >= 0 && c < MAX_COL, "Bad column ", c); return _type[c]; }
@ -106,8 +106,8 @@ TSheet_control::TSheet_control(
short dy, // @parm Lunghezza (in caratteri) dello spreasheet short dy, // @parm Lunghezza (in caratteri) dello spreasheet
const char* flags, // @parm Flags di abilitazione const char* flags, // @parm Flags di abilitazione
const char* head) // @parm Titolo delle colonne const char* head) // @parm Titolo delle colonne
: _sheet(NULL), _cur_rec(0), _check_enabled(FALSE), : _sheet(NULL), _cur_rec(0), _check_enabled(false),
_save_columns_order(FALSE) _save_columns_order(false)
{ {
const int NUMBER_WIDTH = 7; const int NUMBER_WIDTH = 7;
@ -173,7 +173,7 @@ TSheet_control::TSheet_control(
if (i == 0 && v <= 1) if (i == 0 && v <= 1)
{ {
_type[i] = 'C'; _type[i] = 'C';
_check_enabled = TRUE; _check_enabled = true;
fixed_columns++; fixed_columns++;
f_width += v+1; f_width += v+1;
} }
@ -221,15 +221,15 @@ TSheet_control::TSheet_control(
XI_LIST_DEF* l = listdef->v.list; XI_LIST_DEF* l = listdef->v.list;
l->min_heading_height = xi_button_calc_height_font(xi_get_system_font()) * lines_in_header; l->min_heading_height = xi_button_calc_height_font(xi_get_system_font()) * lines_in_header;
l->max_lines_in_cell = lines_in_cell; l->max_lines_in_cell = lines_in_cell;
l->sizable_columns = TRUE; l->sizable_columns = true;
l->movable_columns = TRUE; l->movable_columns = true;
l->fixed_columns = fixed_columns; l->fixed_columns = fixed_columns;
l->scroll_bar = TRUE; l->scroll_bar = true;
l->scroll_bar_button = TRUE; l->scroll_bar_button = true;
l->white_space_color = MASK_DARK_COLOR; l->white_space_color = MASK_DARK_COLOR;
l->rule_color = MASK_DARK_COLOR; l->rule_color = MASK_DARK_COLOR;
#ifdef LINUX #ifdef LINUX
l->scroll_on_thumb_track = TRUE; l->scroll_on_thumb_track = true;
#endif #endif
// Definizione della prima colonna (numero di riga) // Definizione della prima colonna (numero di riga)
@ -238,9 +238,9 @@ TSheet_control::TSheet_control(
2 * XI_FU_MULTIPLE, NUMBER_WIDTH , ""); 2 * XI_FU_MULTIPLE, NUMBER_WIDTH , "");
coldef->app_data = (long)this; coldef->app_data = (long)this;
coldef->v.column->heading_platform = TRUE; coldef->v.column->heading_platform = true;
coldef->v.column->column_platform = TRUE; coldef->v.column->column_platform = true;
coldef->v.column->center_heading = TRUE; coldef->v.column->center_heading = true;
for (h = new_header.get(0), i = 0; h && i < MAX_COL; h = new_header.get(), i++) for (h = new_header.get(0), i = 0; h && i < MAX_COL; h = new_header.get(), i++)
{ {
@ -253,10 +253,10 @@ TSheet_control::TSheet_control(
v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h); v_width[i] * XI_FU_MULTIPLE, m_width[i], (char*)h);
coldef->app_data = (long)this; coldef->app_data = (long)this;
coldef->v.column->heading_platform = TRUE; coldef->v.column->heading_platform = true;
coldef->v.column->center_heading = TRUE; coldef->v.column->center_heading = true;
if (m_width[i] > 64) if (m_width[i] > 64)
coldef->v.column->wrap_text = TRUE; coldef->v.column->wrap_text = true;
if (i == 0 && _type[i] == 'C') if (i == 0 && _type[i] == 'C')
{ {
@ -395,6 +395,7 @@ void TSheet_control::make_current(long rec)
{ {
XI_MAKE_ROW(&o, _obj, newrow); XI_MAKE_ROW(&o, _obj, newrow);
xi_cell_request(&o); xi_cell_request(&o);
_obj->v.list->focus_cell->v.cell.row = newrow;
} }
} }
@ -493,7 +494,7 @@ void TSheet_control::enable_check(bool on)
bool TSheet_control::one_checked() const bool TSheet_control::one_checked() const
{ {
bool yes = FALSE; bool yes = false;
if (check_enabled()) if (check_enabled())
{ {
const long first = _checked.first_one(); const long first = _checked.first_one();
@ -507,8 +508,8 @@ void TSheet_control::check(
long n, // @parm Numero della riga da attivare/disattivare long n, // @parm Numero della riga da attivare/disattivare
bool on) // @parm Operazione da effettuare sulla riga: bool on) // @parm Operazione da effettuare sulla riga:
// //
// @flag TRUE | Attiva la riga <p n>.esima (default) // @flag true | Attiva la riga <p n>.esima (default)
// @flag FALSE | Disattiva la riga <p n>.esima // @flag false | Disattiva la riga <p n>.esima
{ {
if (n < 0) if (n < 0)
{ {
@ -566,8 +567,8 @@ void TSheet_control::enable_row(
long n, // @parm Numero della riga da abilitare/diabilitare (default -1) long n, // @parm Numero della riga da abilitare/diabilitare (default -1)
bool on) // @parm Operazione da svolgere sulla riga bool on) // @parm Operazione da svolgere sulla riga
// //
// @flag TRUE | Abilita la riga <p n>-esima (default) // @flag true | Abilita la riga <p n>-esima (default)
// @flag FALSE | Disabilita la riga <p n>-esima // @flag false | Disabilita la riga <p n>-esima
// @comm Se <p n> e' minore di 0 allora vengono abilitate/disabilitate tutte le righe // @comm Se <p n> e' minore di 0 allora vengono abilitate/disabilitate tutte le righe
{ {
@ -603,7 +604,7 @@ void TSheet_control::save_columns_order(const TEdit_field& field) const
TConfig config(CONFIG_USER, parag); // Apre il file di configurazione TConfig config(CONFIG_USER, parag); // Apre il file di configurazione
TToken_string order(127); // Nuovo ordine delle colonne TToken_string order(127); // Nuovo ordine delle colonne
if (_save_columns_order == TRUE) // Se vale 3 devo solo resettare if (_save_columns_order == 1) // Se vale 3 devo solo resettare
{ {
int num; int num;
XI_OBJ** column = xi_get_member_list(_obj, &num); XI_OBJ** column = xi_get_member_list(_obj, &num);
@ -624,7 +625,7 @@ void TSheet_control::save_columns_order(const TEdit_field& field) const
RCT rct; xi_get_rect(column[i], (XinRect *) &rct); RCT rct; xi_get_rect(column[i], (XinRect *) &rct);
order << ',' << rct.right - rct.left; order << ',' << rct.right - rct.left;
} }
config.set("Browse", order, NULL, TRUE, field.dlg()); config.set("Browse", order, NULL, true, field.dlg());
} }
else else
config.remove("Browse", field.dlg()); config.remove("Browse", field.dlg());
@ -645,7 +646,7 @@ void TSheet_control::load_columns_order(const TEdit_field& field)
else else
set_columns_order(&order); set_columns_order(&order);
} }
_save_columns_order = FALSE; _save_columns_order = false;
} }
void TSheet_control::align_column(int c, bool right) void TSheet_control::align_column(int c, bool right)
@ -713,7 +714,8 @@ void TSheet_control::set_columns_order(TToken_string* order)
xi_set_focus(focus); xi_set_focus(focus);
} }
HIDDEN long _rec_to_select = -1; // HIDDEN long _rec_to_select = -1;
// Certified 75% // Certified 75%
bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev) bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{ {
@ -729,7 +731,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
xiev->v.rec_request.data_rec = n; xiev->v.rec_request.data_rec = n;
} }
else else
refused = TRUE; refused = true;
break; break;
case XIE_GET_LAST: case XIE_GET_LAST:
xiev->v.rec_request.data_rec = items()-1; xiev->v.rec_request.data_rec = items()-1;
@ -739,7 +741,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{ {
const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ; const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
if (n < 0 || n >= items()) if (n < 0 || n >= items())
refused = TRUE; refused = true;
else else
xiev->v.rec_request.data_rec = n; xiev->v.rec_request.data_rec = n;
} }
@ -803,7 +805,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
_sheet->get_cell_colors(rec, col, xiev->v.cell_request.color, xiev->v.cell_request.back_color); _sheet->get_cell_colors(rec, col, xiev->v.cell_request.color, xiev->v.cell_request.back_color);
} }
else else
refused = TRUE; refused = true;
} }
else else
{ {
@ -831,7 +833,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
_sheet->stop_run(K_ENTER); _sheet->stop_run(K_ENTER);
} }
else else
refused = TRUE; refused = true;
} }
break; break;
case XIE_ON_LIST: case XIE_ON_LIST:
@ -842,7 +844,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
const long rec = row2rec(xiev->v.xi_obj->v.row); const long rec = row2rec(xiev->v.xi_obj->v.row);
if (_disabled[rec]) if (_disabled[rec])
{ {
refused = TRUE; refused = true;
// Cerca la prossima riga abilitata e valida // Cerca la prossima riga abilitata e valida
const int dir = rec > selected() ? +1: -1; const int dir = rec > selected() ? +1: -1;
const long max = items(); const long max = items();
@ -854,10 +856,13 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
} }
else else
{ {
/*
if (_sheet->_select_row < 0) if (_sheet->_select_row < 0)
make_current(rec); make_current(rec);
else else
_rec_to_select = rec; _rec_to_select = rec;
*/
_sheet->post_select(rec);
} }
} }
break; break;
@ -896,21 +901,21 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
make_current(rec); make_current(rec);
} }
} }
refused = TRUE; refused = true;
break; break;
case XIE_COL_MOVE: case XIE_COL_MOVE:
if (xiev->v.column.in_fixed || if (xiev->v.column.in_fixed ||
xiev->v.column.col_nbr < xi_get_fixed_columns(xiev->v.column.list)) xiev->v.column.col_nbr < xi_get_fixed_columns(xiev->v.column.list))
refused = TRUE; refused = true;
else else
_save_columns_order = TRUE; _save_columns_order = true;
break; break;
case XIE_COL_SIZE: case XIE_COL_SIZE:
{ {
if (_obj->v.list->hsb_win) if (_obj->v.list->hsb_win)
_save_columns_order = TRUE; _save_columns_order = true;
else else
refused = TRUE; // Non permetto il resize in assenza di scroll bar orizzontale refused = true; // Non permetto il resize in assenza di scroll bar orizzontale
} }
break; break;
case XIE_BUTTON: case XIE_BUTTON:
@ -956,7 +961,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
if (rec >= 0) if (rec >= 0)
{ {
_sheet->post_select(rec); _sheet->post_select(rec);
refused = TRUE; refused = true;
} }
} }
break; break;
@ -1025,6 +1030,12 @@ TSheet::TSheet(short x, short y, short dx, short dy,
add_button(DLG_EXPORT, TR("~Excel"), 0, TOOL_EXCEL); add_button(DLG_EXPORT, TR("~Excel"), 0, TOOL_EXCEL);
set_handler(DLG_EXPORT, export_handler); set_handler(DLG_EXPORT, export_handler);
if (buttons & 0x20)
{
add_button(DLG_EDIT, TR("~Filtro"), K_CTRL+'F', TOOL_ELABORA);
set_handler(DLG_EDIT, filtro_handler);
}
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC, TOOL_QUIT); if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC, TOOL_QUIT);
else add_button(DLG_CANCEL, "Annulla", K_ESC, TOOL_CANCEL); else add_button(DLG_CANCEL, "Annulla", K_ESC, TOOL_CANCEL);
@ -1151,7 +1162,8 @@ void TSheet::force_update(int r)
void TSheet::start_run() void TSheet::start_run()
{ {
const bool on = items() > 0 && _sheet->one_enabled(); const long imax = items();
const bool on = imax > 0 && _sheet->one_enabled();
// Abilita selezione se c'e' almeno un elemento // Abilita selezione se c'e' almeno un elemento
int pos = id2pos(DLG_SELECT); int pos = id2pos(DLG_SELECT);
@ -1170,11 +1182,11 @@ void TSheet::start_run()
if (on) if (on)
{ {
long i = selected(); long i = selected();
if (i < 0 || i >= items()) if (i < 0 || i >= imax)
i = 0; i = 0;
if (row_disabled(i)) for (; i < imax && row_disabled(i); i++);
for (i = 0; row_disabled(i); i++); if (i >= 0 && i < imax && i != selected())
post_select(i); post_select(i);
} }
} }
@ -1247,7 +1259,7 @@ bool TSheet::on_key(KEY key)
f.on_key(K_SPACE); f.on_key(K_SPACE);
if (b.exit_key() > 0) if (b.exit_key() > 0)
stop_run(b.exit_key()); stop_run(b.exit_key());
return TRUE; return true;
} }
} }
} }
@ -1294,10 +1306,13 @@ void TSheet::on_idle()
{ {
if (_select_row >= 0) if (_select_row >= 0)
{ {
const short focus_id = low_get_focus_id(curr_win()); if (_select_row < items())
_sheet->select(_select_row); {
if (focus_id == _sheet->id()) const short focus_id = low_get_focus_id(curr_win());
_sheet->set_focus_rec(-1); _sheet->select(_select_row);
if (focus_id == _sheet->id())
_sheet->set_focus_rec(-1);
}
_select_row = -1; _select_row = -1;
} }
TMask::on_idle(); TMask::on_idle();
@ -1462,6 +1477,20 @@ bool TSheet::export_handler(TMask_field& f, KEY k)
return true; return true;
} }
bool TSheet::filter_dialog()
{ return sorry_box("Filtro non attivabile"); }
bool TSheet::filtro_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
TSheet& s = (TSheet&)f.mask();
s.filter_dialog();
return false;
}
return true;
}
void TSheet::save_columns_order(const TEdit_field& field) void TSheet::save_columns_order(const TEdit_field& field)
{ sheet().save_columns_order(field); } { sheet().save_columns_order(field); }
@ -1583,7 +1612,7 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields,
{ {
const byte c = sheet().column_type(campo); const byte c = sheet().column_type(campo);
if (c == ' ') if (c == ' ')
sheet().align_column(campo, TRUE); sheet().align_column(campo, true);
} }
_key_cols.set(campo, in_key(fr)); _key_cols.set(campo, in_key(fr));
@ -1591,17 +1620,17 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields,
} }
} }
HIDDEN bool _can_post = FALSE; HIDDEN bool _can_post = false;
KEY TCursor_sheet::run() KEY TCursor_sheet::run()
{ {
_cursor->freeze(TRUE); _cursor->freeze(true);
select(_cursor->pos()); select(_cursor->pos());
_can_post = TRUE; _can_post = true;
const KEY k = TSheet::run(); const KEY k = TSheet::run();
_cursor->freeze(FALSE); _cursor->freeze(false);
return k; return k;
} }
@ -1632,6 +1661,75 @@ bool TCursor_sheet::get_cell_colors(int row, int col, COLOR& fore, COLOR& back)
return TSheet::get_cell_colors(row, col, fore, back); return TSheet::get_cell_colors(row, col, fore, back);
} }
bool TCursor_sheet::filter_dialog()
{
TRectype rec = _cursor->curr();
const RecDes& rd = rec.rec_des();
const KeyDes& k0 = rd.Ky[0];
const int kfields = k0.NkFields;
TMask m(TR("Filtro"), 1, 78, kfields+5);
m.add_button_tool(DLG_OK, "", TOOL_OK);
m.add_button_tool(DLG_CANCEL, "", TOOL_CANCEL);
for (int i = 0; i < kfields; i++)
{
const int nf = k0.FieldSeq[i] % MaxFields;
const char* fname = rec.fieldname(nf);
const TFieldtypes ft = rec.type(fname);
TString16 prompt = fname; prompt.left_just(12);
TString4 flags;
switch (ft)
{
case _alfafld:
case _charfld:
m.add_string(101+i, 0, prompt, 1, i+1, rec.length(fname), flags).set_field(fname);
break;
case _intzerofld:
case _longzerofld:
flags << "Z";
case _wordfld:
case _intfld:
case _longfld:
m.add_number(101+i, 0, prompt, 1, i+1, rec.length(fname), flags).set_field(fname);
break;
case _datefld:
m.add_date(101+i, 0, prompt, 1, i+1, flags).set_field(fname);
break;
default:
break;
}
}
for (int i = 0; i < kfields-1; i++)
{
const int nf = k0.FieldSeq[i] % MaxFields;
const char* fname = rec.fieldname(nf);
TMask_field* f = m.find_by_fieldname(fname);
if (f)
f->set(rec.get(fname));
}
if (m.run() == K_ENTER)
{
rec.zero();
for (int i = 0; i < kfields; i++)
{
const int nf = k0.FieldSeq[i] % MaxFields;
const char* fname = rec.fieldname(nf);
const TMask_field* f = m.find_by_fieldname(fname);
if (f) rec.put(fname, f->get());
}
TWait_cursor hourglass;
_cursor->freeze(false);
_cursor->setregion(rec, rec);
_cursor->items();
_cursor->freeze(true);
force_update();
}
return true;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TBrowse_sheet // TBrowse_sheet
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -1708,12 +1806,12 @@ bool TBrowse_sheet::browse_field_handler(TMask_field& f, KEY k)
if (rec >= 0 && rec != _cur_browse->selected()) if (rec >= 0 && rec != _cur_browse->selected())
{ {
_cur_browse->select(rec); // Non mettere post_select _cur_browse->select(rec); // Non mettere post_select
_can_post = TRUE; _can_post = true;
RCT r; f.get_rect(r); RCT r; f.get_rect(r);
xvt_dwin_invalidate_rect(f.parent(), &r); // Non ricordo a cosa serva aggiornare il campo di testo xvt_dwin_invalidate_rect(f.parent(), &r); // Non ricordo a cosa serva aggiornare il campo di testo
} }
return TRUE; return true;
} }
bool TBrowse_sheet::last_browse_field_handler(TMask_field& f, KEY k) bool TBrowse_sheet::last_browse_field_handler(TMask_field& f, KEY k)
@ -1724,7 +1822,7 @@ bool TBrowse_sheet::last_browse_field_handler(TMask_field& f, KEY k)
if (k == K_TAB && _can_post) if (k == K_TAB && _can_post)
{ {
_cur_browse->post_select(_cur_browse->selected()); _cur_browse->post_select(_cur_browse->selected());
_can_post = FALSE; _can_post = false;
} }
else else
{ {
@ -1797,6 +1895,7 @@ long TBrowse_sheet::handler(
} }
break; break;
default: default:
/*
{ {
RCT r; sheet().get_rect(r); RCT r; sheet().get_rect(r);
if (xvt_rect_has_point(&r, ep->v.mouse.where) && _rec_to_select >= 0) if (xvt_rect_has_point(&r, ep->v.mouse.where) && _rec_to_select >= 0)
@ -1805,6 +1904,7 @@ long TBrowse_sheet::handler(
_rec_to_select = -1; _rec_to_select = -1;
} }
} }
*/
break; break;
} }
break; break;
@ -1834,7 +1934,7 @@ long TBrowse_sheet::handler(
return TCursor_sheet::handler(win, ep); return TCursor_sheet::handler(win, ep);
} }
bool lst_handler(TMask_field& lst, KEY k) static bool keysel_handler(TMask_field& lst, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{ {
@ -1848,24 +1948,26 @@ bool lst_handler(TMask_field& lst, KEY k)
return true; return true;
} }
#define DLG_KEY_SELECTOR 69
void TBrowse_sheet::create_key_selector(TToken_string& ca) void TBrowse_sheet::create_key_selector(TToken_string& ca)
{ {
const int items = ca.items(); const int items = ca.items();
if (items > 1) if (items > 1)
{ {
TToken_string co; TToken_string co(3*items);
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
co.add(i); co.add(i);
TList_field& lst = add_list(DLG_KEY_SELECTOR, 0, PR("Ordinamento per "), 1, 0, 16, "", co, ca);
TList_field& lst = add_list(69, 0, PR("Ordinamento per "), 1, 0, 16, "", co, ca); lst.set_handler(keysel_handler);
lst.set_handler(lst_handler);
} }
} }
void TBrowse_sheet::update_key_selector(int sel) void TBrowse_sheet::update_key_selector(int sel)
{ {
if (id2pos(69) >= 0) // Has been created? TMask_field* ks = find_by_id(DLG_KEY_SELECTOR);
set(69, sel, 0); // Don't fire any events! if (ks != NULL) // Has been created?
ks->set(sel); // Don't fire any events!
} }
TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields, TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
@ -2020,6 +2122,10 @@ KEY TBrowse_sheet::run()
{ {
_cur_browse = this; _cur_browse = this;
update_key_selector(_sel); update_key_selector(_sel);
TMask_field* f = find_by_id(field().dlg());
if (f && !f->empty())
browse_field_handler(*f, K_SPACE); // Posizione iniziale
const KEY key = TCursor_sheet::run(); const KEY key = TCursor_sheet::run();
_cur_browse = NULL; _cur_browse = NULL;
return key; return key;

View File

@ -31,13 +31,15 @@ protected: // TMask
static bool tutti_handler(TMask_field& f, KEY k); static bool tutti_handler(TMask_field& f, KEY k);
static bool export_handler(TMask_field& f, KEY k); static bool export_handler(TMask_field& f, KEY k);
static bool filtro_handler(TMask_field& f, KEY k);
protected: protected:
void reset_parked() { _parked = -1; } void reset_parked() { _parked = -1; }
virtual void get_row(long r, TToken_string& row) { row.cut(0); } virtual void get_row(long r, TToken_string& row) { row.cut(0); }
virtual long get_items() const { return 0L; } virtual long get_items() const { return 0L; }
virtual bool get_ini_paragraph(const TEdit_field& owner, TString& parag) const; virtual bool get_ini_paragraph(const TEdit_field& owner, TString& parag) const;
virtual bool filter_dialog();
TSheet_control& sheet(); TSheet_control& sheet();
// @cmember Permette di riposizionare i bottoni all'interno della pagina // @cmember Permette di riposizionare i bottoni all'interno della pagina
@ -191,6 +193,7 @@ protected: // TSheet
bool in_key(const TFieldref& fr) const; bool in_key(const TFieldref& fr) const;
virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const; virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const;
virtual bool filter_dialog();
// @access Public Member // @access Public Member
public: // TSheet public: // TSheet
@ -259,7 +262,6 @@ public:
void add_custom_filter(const char* regexp); void add_custom_filter(const char* regexp);
void set_custom_filter_handler(CONTROL_HANDLER custom_filter_handler) { _custom_filter_handler = custom_filter_handler;} void set_custom_filter_handler(CONTROL_HANDLER custom_filter_handler) { _custom_filter_handler = custom_filter_handler;}
// @cmember Costruttore // @cmember Costruttore
TBrowse_sheet(TCursor* cursor, const char* fields, const char* title, const char* head, byte buttons, TEdit_field& f, TToken_string& siblings,CONTROL_HANDLER custom_filter_handler = NULL); TBrowse_sheet(TCursor* cursor, const char* fields, const char* title, const char* head, byte buttons, TEdit_field& f, TToken_string& siblings,CONTROL_HANDLER custom_filter_handler = NULL);
// @cmember Distruttore // @cmember Distruttore
@ -269,6 +271,26 @@ public:
virtual KEY run(); virtual KEY run();
}; };
///////////////////////////////////////////////////////////
// TRecordset_sheet
///////////////////////////////////////////////////////////
#ifndef __RECORDSET_H
class TRecordset;
#endif
class TRecordset_sheet : public TSheet
{
TRecordset& _query;
protected:
virtual void get_row(long r, TToken_string& row);
virtual long get_items() const;
public:
TRecordset_sheet(TRecordset& sql, const char* title = "Query", byte buttons = 0);
};
#define FOR_EACH_CHECKED_ROW(__sheet, __r, __riga) \ #define FOR_EACH_CHECKED_ROW(__sheet, __r, __riga) \
TToken_string* __riga = NULL; if ((__sheet).one_checked()) \ TToken_string* __riga = NULL; if ((__sheet).one_checked()) \
for(long __r=0; __r < (__sheet).items() && (__riga = &(__sheet).row(__r))->not_empty(); __r++) \ for(long __r=0; __r < (__sheet).items() && (__riga = &(__sheet).row(__r))->not_empty(); __r++) \

View File

@ -72,12 +72,26 @@ sqlite3* TSQLite::open(const char* fname)
if (err == SQLITE_OK) if (err == SQLITE_OK)
{ {
if (xvt_fsys_is_fixed_drive(_currdb.path()) &&
ini_get_int(CONFIG_INSTALL, "Main", "Type") == 1) // Single user scenario
{
sqlite3_exec(_handle, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL, NULL);
sqlite3_exec(_handle, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
sqlite3_exec(_handle, "PRAGMA journal_mode=WAL", NULL, NULL, NULL);
}
else
{
sqlite3_exec(_handle, "PRAGMA locking_mode=NORMAL", NULL, NULL, NULL);
sqlite3_exec(_handle, "PRAGMA synchronous=NORMAL", NULL, NULL, NULL);
sqlite3_exec(_handle, "PRAGMA journal_mode=DELETE", NULL, NULL, NULL);
}
create_dbf_times(); create_dbf_times();
} }
else else
{ {
const char* errmsg = sqlite3_errmsg(_handle); // Stringa di sitema: inutile sqlite3_free(errmsg) const char* errmsg = sqlite3_errmsg(_handle); // Stringa di sitema: inutile sqlite3_free(errmsg)
error_box(errmsg); error_box(errmsg);
_handle = NULL;
} }
return _handle; return _handle;
@ -224,27 +238,30 @@ bool TSQLite::bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* p
bool TSQLite::import(int logicnum) bool TSQLite::import(int logicnum)
{ {
const TString& table = logic2table(logicnum); const TString& table = logic2table(logicnum);
const bool already = exists(table);
long last = get_dbf_time(table); long last = get_dbf_time(table);
if (logicnum >= LF_USER) // Dummy test, 'last' should be updated ALWAYS! if (logicnum >= LF_USER) // Dummy test, 'last' should be updated ALWAYS!
{ {
TBaseisamfile file(logicnum); TBaseisamfile file(logicnum);
if (!file.is_changed_since(last)) if (!file.is_changed_since(last) && already)
return true; return true;
} }
else
return false;
const RecDes& rd = prefix().get_recdes(logicnum); const RecDes& rd = prefix().get_recdes(logicnum);
TString sql; TString sql;
if (exists(table)) if (already)
{ {
// Drop old table (and associated indexes?) // Drop old table (and associated indexes?)
sql.cut(0) << "DROP TABLE "<< table << ';'; sql.cut(0) << "DROP TABLE " << table << ';';
exec(sql); exec(sql);
} }
// Create new table // Create new table
sql.cut(0) << "CREATE TABLE "<< table << "\n("; sql.cut(0) << "CREATE TABLE " << table << "\n(";
int i; int i;
for (i = 0; i < rd.NFields; i++) for (i = 0; i < rd.NFields; i++)
{ {
@ -271,8 +288,7 @@ bool TSQLite::import(int logicnum)
{ {
cur.freeze(); cur.freeze();
msg << TR("Importazione tabella") << ' ' << table; msg << TR("Importazione ") << table << ": " << items << ' ' << TR("righe");
msg << ": " << items << ' ' << TR("righe");
TProgress_monitor pi(items, msg); TProgress_monitor pi(items, msg);
// Creo il comando INSERT INTO table VALUES(?,?,?,?,?,?); // Creo il comando INSERT INTO table VALUES(?,?,?,?,?,?);
@ -284,6 +300,7 @@ bool TSQLite::import(int logicnum)
} }
sql << ");"; sql << ");";
TPerformance_profiler pp(msg);
exec("BEGIN"); // Inizio transazione exec("BEGIN"); // Inizio transazione
sqlite3_stmt* pStatement = NULL; sqlite3_stmt* pStatement = NULL;
@ -292,11 +309,11 @@ bool TSQLite::import(int logicnum)
const TRectype& curr = rel.curr(); const TRectype& curr = rel.curr();
for (cur = 0; cur.pos() < items; ++cur) for (cur = 0; cur.pos() < items; ++cur)
{ {
if (!pi.add_status())
break;
bind_record(curr, rd, pStatement); // Sostituisce i ? coi veri valori bind_record(curr, rd, pStatement); // Sostituisce i ? coi veri valori
rc = sqlite3_step(pStatement); // Ritorna sempre 101 (SQLITE_DONE) rc = sqlite3_step(pStatement); // Ritorna sempre 101 (SQLITE_DONE)
rc = sqlite3_reset(pStatement); // Azzero lo statement per ricominciare rc = sqlite3_reset(pStatement); // Azzero lo statement per ricominciare
if (!pi.add_status())
break;
} }
rc = sqlite3_finalize(pStatement); rc = sqlite3_finalize(pStatement);
@ -306,13 +323,11 @@ bool TSQLite::import(int logicnum)
if (rd.NKeys > 0) if (rd.NKeys > 0)
{ {
// Creo gli indici DOPO l'importazione per maggiore velocita' // Creo gli indici DOPO l'importazione per maggiore velocita'
msg.format("Creazione di %d indici sulla tabella %s", rd.NKeys, (const char*)table); msg.format("Creazione di %d indici su %s", rd.NKeys, (const char*)table);
TProgress_monitor pi(rd.NKeys, msg); TProgress_monitor pi(rd.NKeys, msg, false);
exec("BEGIN"); // Inizio transazione
for (int index = 0; index < rd.NKeys; index++) for (int index = 0; index < rd.NKeys; index++)
{ {
if (!pi.addstatus(1))
break;
const KeyDes& kd = rd.Ky[index]; const KeyDes& kd = rd.Ky[index];
sql = "CREATE "; sql = "CREATE ";
if (!kd.DupKeys) sql << "UNIQUE "; if (!kd.DupKeys) sql << "UNIQUE ";
@ -324,10 +339,10 @@ bool TSQLite::import(int logicnum)
sql << rd.Fd[ndx].Name; sql << rd.Fd[ndx].Name;
} }
sql << ");"; sql << ");";
exec("BEGIN"); // Inizio transazione
exec(sql); exec(sql);
exec("COMMIT"); // Fine transazione pi.add_status();
} }
exec("COMMIT"); // Fine transazione
} }
set_dbf_time(table, last); // Aggiorna ora di ultima modifica set_dbf_time(table, last); // Aggiorna ora di ultima modifica
@ -341,22 +356,20 @@ bool TSQLite::parse_select_from(const char* szSql)
TString sql(szSql); TString sql(szSql);
sql.trim(); sql.upper(); sql.trim(); sql.upper();
if (!sql.starts_with("SELECT")) if (!sql.starts_with("SELECT "))
return false; return false;
const int from = sql.find("FROM"); const int from = sql.find("FROM ");
if (from < 0) if (from < 0)
return false; return false;
const int where_pos = sql.find("WHERE", from); const int where_pos = sql.find("WHERE ", from);
TToken_string tables(sql.sub(from+5, where_pos), ','); TToken_string tables(sql.sub(from+5, where_pos), ',');
TString table; TString table;
TProgress_monitor pi(tables.items(), TR("Importazione tabelle")); TProgress_monitor pi(tables.items(), TR("Importazione tabelle"));
FOR_EACH_TOKEN(tables, tok) FOR_EACH_TOKEN(tables, tok)
{ {
if (!pi.add_status())
break;
table = tok; table = tok;
const int join_pos = table.find("JOIN "); const int join_pos = table.find("JOIN ");
if (join_pos > 0) if (join_pos > 0)
@ -378,6 +391,8 @@ bool TSQLite::parse_select_from(const char* szSql)
pi.set_text(table); pi.set_text(table);
import(logicnum); import(logicnum);
} }
if (!pi.add_status())
break;
} }
return true; return true;
@ -486,9 +501,9 @@ TRecnotype TSQL_recordset::items() const
{ {
TString sql; parsed_text(sql); TString sql; parsed_text(sql);
TPerformance_profiler prof("SQL query"); TPerformance_profiler prof("SQL query");
_TheDataBase.exec("PRAGMA show_datatypes = ON;", NULL, NULL); _TheDataBase.exec("PRAGMA show_datatypes=ON;", NULL, NULL);
_TheDataBase.exec(sql, query_get_items, (TSQL_recordset*)this); _TheDataBase.exec(sql, query_get_items, (TSQL_recordset*)this);
_TheDataBase.exec("PRAGMA show_datatypes = OFF;", NULL, NULL); _TheDataBase.exec("PRAGMA show_datatypes=OFF;", NULL, NULL);
} }
return _items; return _items;
} }

View File

@ -1,3 +1,4 @@
#pragma once
#ifndef __STDTYPES_H #ifndef __STDTYPES_H
#define __STDTYPES_H #define __STDTYPES_H
@ -65,10 +66,6 @@ bool test_assistance_year();
void init_global_vars(); void init_global_vars();
void free_global_vars(); void free_global_vars();
#ifdef LINUX
#define __int64 long long //verificare
#endif
#endif // __STDTYPES_H #endif // __STDTYPES_H

View File

@ -29,6 +29,9 @@ const int MAX_SIZE = 65535;
inline bool is_space(char c) inline bool is_space(char c)
{ return c >= '\t' && c <= ' '; } { return c >= '\t' && c <= ' '; }
inline int round16(int n)
{ const int k = (n/16 + 1) * 16; CHECKD(k>=n,"Round16 failed ", k); return k; }
// Certified 99% // Certified 99%
// @doc EXTERNAL // @doc EXTERNAL
// //
@ -41,17 +44,19 @@ void TString::resize(
// @comm Non funziona con le stringhe static e per valori negativi di <p size> // @comm Non funziona con le stringhe static e per valori negativi di <p size>
{ {
CHECKD(size >= 0, "Invalid string resize ", size); CHECKD(size >= 0, "Invalid string resize ", size);
char* s = new char[size+1]; char* s = (char*)calloc(round16(size+1), 1);
if (cpy && _str) strcpy(s, _str);
else *s = '\0';
if (_str) if (_str)
delete _str; {
if (cpy && *_str)
strcpy_s(s, size+1, _str);
free(_str);
}
_str = s; _str = s;
_size = size; _size = size;
} }
// Certified 99% (uses resize) // Certified 99% (uses resize)
// @doc EXTERNAL // @doc EXTERNAL
// //
@ -65,8 +70,7 @@ TString& TString::set(
if (s && *s) if (s && *s)
{ {
const int sz = strlen(s); const int sz = strlen(s);
if (sz > size()) resize(sz, false); strncpy(s, sz);
strncpy(s, size());
} }
else else
{ {
@ -93,12 +97,12 @@ int TString::make_room(
if (spare < s) if (spare < s)
{ {
const int min_size = lun + s; const int min_size = lun + s;
int new_size = 3 * min_size / 2; int new_size = round16(3 * min_size / 2);
if (new_size > MAX_SIZE) if (new_size > MAX_SIZE)
new_size = MAX_SIZE; new_size = MAX_SIZE;
if (new_size < min_size) if (new_size < min_size)
fatal_box("Stringa di lunghezza eccessiva (%d)", min_size); fatal_box("Stringa di lunghezza superiore a %d)", min_size);
resize(int(new_size), true); resize(new_size, true);
} }
return lun; return lun;
} }
@ -124,7 +128,7 @@ TString::~TString()
{ {
if (_str) if (_str)
{ {
delete _str; free(_str);
#ifdef DBG #ifdef DBG
_str = NULL; _str = NULL;
_size = -883; _size = -883;
@ -136,7 +140,7 @@ char TString::shift(int n)
{ {
CHECK(n>0 && n<=len(),"Errore di scorrimento"); CHECK(n>0 && n<=len(),"Errore di scorrimento");
const char r=*(_str+n-1); const char r=*(_str+n-1);
strcpy(_str, _str+n); strcpy_s(_str, _size+1, _str+n);
return r; return r;
} }
@ -145,7 +149,7 @@ TString& TString::operator <<(const char* s)
if (s && *s) if (s && *s)
{ {
const int pos = make_room(strlen(s)); const int pos = make_room(strlen(s));
strcpy(&_str[pos], s); strcpy_s(&_str[pos], _size-pos+1, s);
} }
return *this; return *this;
} }
@ -569,7 +573,7 @@ TString& TString::ltrim(
for (s = _str; *s && is_space(*s); s++); for (s = _str; *s && is_space(*s); s++);
if (s != _str) if (s != _str)
strcpy(_str, s); strcpy_s(_str, _size+1, s);
return *this; return *this;
} }
@ -838,8 +842,9 @@ int TString::strncpy(const char* s, int n)
{ {
if (n > size()) if (n > size())
resize(n, false); resize(n, false);
for (; *s && i < n; i++) strncpy_s(_str, _size+1, s, n);
_str[i] = *s++; i = strlen(s);
if (n < i) i = n;
} }
_str[i] = '\0'; _str[i] = '\0';
return i; return i;
@ -859,7 +864,7 @@ TString& TString::format(
char spark[512] = { 0 }; char spark[512] = { 0 };
va_list pars; va_list pars;
va_start(pars, fmt); va_start(pars, fmt);
const unsigned int tot = _vsnprintf(spark, sizeof(spark)-1, fmt, pars); const unsigned int tot = _vsnprintf(spark, sizeof(spark), fmt, pars);
va_end(pars); va_end(pars);
CHECK(tot < sizeof(spark), "Ue'! Quanto scrivi?"); CHECK(tot < sizeof(spark), "Ue'! Quanto scrivi?");
@ -981,7 +986,7 @@ TString& TString::insert(
make_room(l); make_room(l);
const TString& spark = mid(pos); // Scrivi in spark la stringa da pos in poi const TString& spark = mid(pos); // Scrivi in spark la stringa da pos in poi
overwrite(s, pos); // Aggiungi s overwrite(s, pos); // Aggiungi s
strcpy(&_str[pos+l], spark); // Aggiungi spark strcpy_s(&_str[pos+l], _size-(pos+l)+1, spark); // Aggiungi spark
} }
return *this; return *this;
} }
@ -1010,9 +1015,11 @@ word TString::hash() const
// TFixed_string // TFixed_string
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Certified 100% // Certified 99%
// Se la size del buffer str è di 16, allora la size stringa è di 15 (15 + '\0' = 16)
// es: char buf[16]; TFixed_string str(buf, sizeof(buf));
TFixed_string::TFixed_string(const char* str, int size) TFixed_string::TFixed_string(const char* str, int size)
: TString((char*)str, (size <= 0) ? strlen(str) : size-1) : TString((char*)str, (size <= 0) ? strlen(str) : size-1)
{ {
CHECK(str, "NULL buffer for fixed string"); CHECK(str, "NULL buffer for fixed string");
if (size > 0 && memchr(str, '\0', size) == NULL) if (size > 0 && memchr(str, '\0', size) == NULL)
@ -1245,28 +1252,23 @@ bool TFilename::ok() const
} }
// Certified 70% // Certified 70%
const TFilename& TFilename::tempdir() TFilename& TFilename::tempdir()
{ {
static TFilename _tempdir; static TFilename _tempdir;
const bool create = _tempdir.empty() || !_tempdir.ends_with(user(), true); const bool create = _tempdir.empty() || !_tempdir.ends_with(user(), true);
if (create) if (create)
{ {
_tempdir.cut(0); const int maxlen = 28; // Lunghezza max nome file temporaneo = 42 -> lunghezza max cartella 42-14 = 28
xvt_sys_get_profile_string(NULL, "Main", "Temp", "", _tempdir.get_buffer(), _tempdir.size()); DIRECTORY tmp = { 0 }; xvt_fsys_get_temp_dir(&tmp);
if (_tempdir.blank()) xvt_fsys_convert_dir_to_str(&tmp, _tempdir.get_buffer(), _tempdir.size());
if (_tempdir.len() > maxlen) // troppo lunga!
{ {
xvt_sys_get_env("TEMP", _tempdir.get_buffer(), _tempdir.size()); _tempdir.currdir().add("temp");
if (_tempdir.blank()) if (_tempdir.len() > maxlen) // ancora troppo lunga!
xvt_sys_get_env("TMP", _tempdir.get_buffer(), _tempdir.size()); _tempdir = "c:\\temp";
if (_tempdir.len() > 28) // troppo lunga! xvt_sys_set_profile_string(NULL, "Main", "Temp", _tempdir);
{
_tempdir.currdir();
_tempdir.add("temp");
xvt_sys_set_profile_string(NULL, "Main", "Temp", _tempdir);
}
} }
bool ok = dexist(_tempdir); bool ok = dexist(_tempdir);
if (!ok) // Codebase NON funziona senza una temp esistente! if (!ok) // Codebase NON funziona senza una temp esistente!
{ {
@ -1276,19 +1278,17 @@ const TFilename& TFilename::tempdir()
} }
const int last = len()-1; const int last = len()-1;
if (!is_not_slash(_str[last])) if (is_slash(_str[last]))
_tempdir.cut(last); _tempdir.cut(last);
_tempdir.lower(); _tempdir.lower();
TString theuser(user()); TString theuser = user();
if (theuser.empty()) if (theuser.blank())
theuser = ::dongle().administrator(); theuser = ::dongle().administrator();
theuser.lower(); theuser.lower();
const int f = _tempdir.find(theuser); if (!_tempdir.ends_with(user(), true))
if (f < 0 || f != _tempdir.len() - theuser.len())
_tempdir.add(theuser); _tempdir.add(theuser);
_tempdir.lower();
ok = dexist(_tempdir); ok = dexist(_tempdir);
if (!ok) if (!ok)
{ {
@ -1304,62 +1304,58 @@ const TFilename& TFilename::tempdir()
return *this; return *this;
} }
const TFilename& TFilename::currdir() TFilename& TFilename::currdir()
{ {
DIRECTORY d; xvt_fsys_get_dir(&d); DIRECTORY d; xvt_fsys_get_dir(&d);
xvt_fsys_convert_dir_to_str(&d, get_buffer(), size()); xvt_fsys_convert_dir_to_str(&d, get_buffer(), size());
return *this; return *this;
} }
// Certified 50%
// @doc EXTERNAL TFilename& TFilename::slash_terminate()
{
if (empty())
operator<<(SLASH);
else
{
if (!is_slash(_str[len()-1]))
operator<<(find("/") >= 0 ? '/' : '\\');
}
return *this;
}
// @mfunc Genera il nome di un file temporaneo // @mfunc Genera il nome di un file temporaneo
const TFilename& TFilename::temp( TFilename& TFilename::temp(
const char* prefix, // @parm Eventuale prefisso da assegnare al file temporaneo const char* prefix, // @parm Eventuale prefisso da assegnare al file temporaneo
const char* extension) // @parm Eventuale estensione da assegnare al file temporaneo const char* extension) // @parm Eventuale estensione da assegnare al file temporaneo
// @comm Nel generare il nome del file controlla se esistono dei caratteri jolly e li elimina. // @comm Nel generare il nome del file controlla se esistono dei caratteri jolly e li elimina.
{ {
if (extension && *extension) TFilename root; root.tempdir();
{ root.slash_terminate();
TFilename root; root.tempdir(); if (prefix && *prefix)
if (prefix && *prefix)
{
bool has_path = false;
for (const char *s = prefix; !has_path && *s; s++)
has_path = *s ==':' || is_slash(*s);
if (has_path)
root = prefix;
else
root.add(prefix);
}
for (unsigned int n = (unsigned int)clock(); ; n++)
{
TString8 name; name.format("%05lu", n % 100000);
set(root); operator<<(name);
ext(extension);
if (!exist())
break;
}
}
else
{ {
tempdir(); bool has_path = false;
if (prefix && *prefix) for (const char *s = prefix; !has_path && *s; s++)
has_path = *s ==':' || is_slash(*s);
if (has_path)
{ {
set(prefix); // Copia prefisso e ... root = prefix;
strip("$#*?."); // ... toglie caratteri jolly if (xvt_fsys_dir_exists(root))
root.slash_terminate();
} }
else else
cut(0); root.add(prefix);
char* t = _tempnam(NULL, _str);
CHECK(t != NULL, "Can't execute tempnam");
set(t);
free(t);
} }
for (unsigned int n = (unsigned int)clock(); ; n++)
CHECKS(!exist(), "Il file temporaneo esiste già: ", _str); {
TString8 name; name.format("%05lu", n % 100000);
set(root); operator<<(name);
if (extension && *extension)
ext(extension);
if (!exist())
break;
}
return *this; return *this;
} }
@ -1372,7 +1368,7 @@ bool TFilename::is_absolute_path() const
return is_slash(*s); return is_slash(*s);
} }
const TFilename& TFilename::make_absolute_path() TFilename& TFilename::make_absolute_path()
{ {
if (is_relative_path()) if (is_relative_path())
{ {

View File

@ -483,30 +483,24 @@ public:
// @class TFilename | Classe per la gestione dei nome dei file // @class TFilename | Classe per la gestione dei nome dei file
// //
// @base public | TString // @base public | TString
class TFilename : public TString class TFilename : public TString256
// @author:(INTERNAL) Guido // @author:(INTERNAL) Guido
{ {
// @access Public Member // @access Public Member
public: public:
// @cmember Costruttore // @cmember Costruttore
TFilename(const char* n = "") : TString(260) TFilename(const char* n = "") : TString256(n) { }
{ set(n); }
// @cmember Costruttore // @cmember Costruttore
TFilename(const TString& n) : TString(260) TFilename(const TString& n) : TString256(n) { }
{ set(n); }
// @cmember Costruttore // @cmember Costruttore
TFilename(const TFilename& n) : TString(260) TFilename(const TFilename& n) : TString256(n) { }
{ set(n); }
// @cmember Assegnazione tra TFilename e stringa // @cmember Assegnazione tra TFilename e stringa
const TString& operator =(const char* s) const TString& operator =(const char* s) { return set(s); }
{ return set(s); }
// @cmember Assegnazione tra TFilename e TString // @cmember Assegnazione tra TFilename e TString
const TString& operator =(const TString& s) const TString& operator =(const TString& s) { return set((const char*)s); }
{ return set((const char*)s); }
// @cmember Assegnazione tra TFilename e TFilename // @cmember Assegnazione tra TFilename e TFilename
const TString& operator =(const TFilename& s) const TString& operator =(const TFilename& s) { return set((const char*)s); }
{ return set((const char*)s); }
// @cmember Controlla il formato del nome del file // @cmember Controlla il formato del nome del file
virtual bool ok() const; virtual bool ok() const;
@ -524,7 +518,9 @@ public:
// @cmember Controlla se si tratta di un path relativo // @cmember Controlla se si tratta di un path relativo
bool is_relative_path() const { return !is_absolute_path(); } bool is_relative_path() const { return !is_absolute_path(); }
// @cmember Trasforma un path da relativo ad assoluto // @cmember Trasforma un path da relativo ad assoluto
const TFilename& make_absolute_path(); TFilename& make_absolute_path();
// @cmember aggiunge uno slash finale
TFilename& TFilename::slash_terminate();
// @cmember Testa se il file esiste // @cmember Testa se il file esiste
bool exist() const; bool exist() const;
// @cmember Cancella il file // @cmember Cancella il file
@ -542,11 +538,11 @@ public:
// @cmember Ritorna il nome della cartella del file // @cmember Ritorna il nome della cartella del file
const char* path() const; const char* path() const;
// @cmember Genera il nome di un file temporaneo // @cmember Genera il nome di un file temporaneo
const TFilename& temp(const char* prefix = NULL, const char* extension = NULL); TFilename& temp(const char* prefix = NULL, const char* extension = NULL);
// @cmember Genera il nome della directory temporanea // @cmember Genera il nome della directory temporanea
const TFilename& tempdir(); TFilename& tempdir();
// @cmember Genera il nome della directory corrente // @cmember Genera il nome della directory corrente
const TFilename& currdir(); TFilename& currdir();
// @cmember Prepone il nome della dir custom // @cmember Prepone il nome della dir custom
bool custom_path(const char* path_list = NULL); bool custom_path(const char* path_list = NULL);
}; };

View File

@ -291,7 +291,7 @@ HIDDEN bool _cf_val(TMask_field& f, KEY key)
if (cf.empty()) return true; if (cf.empty()) return true;
if (cf.len() == 11 && isdigit(cf[0])) if (cf.len() == 11 && isdigit(cf[0]))
{ {
const TString& stato = f.mask().get(atoi(get_val_param(0))); const TString& stato = get_fld_val_param(f, 0);
if (stato.full() && stato != "IT") if (stato.full() && stato != "IT")
return true; return true;
ok = pi_check (stato, cf); ok = pi_check (stato, cf);
@ -302,7 +302,7 @@ HIDDEN bool _cf_val(TMask_field& f, KEY key)
{ {
if(f.dirty()) if(f.dirty())
{ {
ok = f.yesno_box(TR("Codice fiscale errato: lo accetto ugualmente?")); ok = f.noyes_box(TR("Codice fiscale errato: si desidera accettarlo ugualmente?"));
if (ok) f.set_dirty(false); if (ok) f.set_dirty(false);
} }
else else
@ -345,7 +345,7 @@ HIDDEN bool _xt_pi_val(TMask_field& f, KEY key)
if (pi != s1 && pi != s2 && pi != s3) if (pi != s1 && pi != s2 && pi != s3)
{ {
TString16 ui; ui.format("%03d", s1); TString16 ui; ui.format("%03d", s1);
if (f.yesno_box(FR("Ufficio IVA della partita IVA non congruente: correggere in %s?"), if (f.yesno_box(FR("Ufficio IVA non congruente con la partita IVA:\nsi desidera correggerlo in %s?"),
(const char*)ui)) (const char*)ui))
{ {
value.overwrite(ui, 7); value.overwrite(ui, 7);
@ -378,12 +378,7 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
return false; return false;
if (cf.len() == 11 && real::is_natural(cf)) if (cf.len() == 11 && real::is_natural(cf))
{
// if (!_xt_pi_val(f, key)) return false;
// TString16 stato(f.mask().get(atoi(get_val_param(0))));
// if ((stato.not_empty()) && (stato != "IT")) return true;
return true; return true;
}
bool passed = __cf_check(cf); bool passed = __cf_check(cf);
if (!passed) return true; if (!passed) return true;
@ -398,15 +393,16 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
TString16 data = fld_dat.get(); TString16 data = fld_dat.get();
TString4 com = fld_com.get(); TString4 com = fld_com.get();
TString16 wm("LMNPQRSTUV"); const TFixed_string nm("LMNPQRSTUV");
int p; int p = 0;
if ((p = wm.find(cf[ 6])) >= 0) cf[ 6] = '0' + p; if ((p = nm.find(cf[ 6])) >= 0) cf[ 6] = '0' + p;
if ((p = wm.find(cf[ 7])) >= 0) cf[ 7] = '0' + p; if ((p = nm.find(cf[ 7])) >= 0) cf[ 7] = '0' + p;
if ((p = wm.find(cf[ 9])) >= 0) cf[ 9] = '0' + p; if ((p = nm.find(cf[ 9])) >= 0) cf[ 9] = '0' + p;
if ((p = wm.find(cf[10])) >= 0) cf[10] = '0' + p; if ((p = nm.find(cf[10])) >= 0) cf[10] = '0' + p;
if ((p = wm.find(cf[12])) >= 0) cf[12] = '0' + p; if ((p = nm.find(cf[12])) >= 0) cf[12] = '0' + p;
if ((p = wm.find(cf[13])) >= 0) cf[13] = '0' + p; if ((p = nm.find(cf[13])) >= 0) cf[13] = '0' + p;
if ((p = wm.find(cf[14])) >= 0) cf[14] = '0' + p; if ((p = nm.find(cf[14])) >= 0) cf[14] = '0' + p;
int gn = atoi(cf.mid(9,2)); int gn = atoi(cf.mid(9,2));
if ((sesso == 'F' && gn < 40) || (sesso == 'M' && gn > 40)) if ((sesso == 'F' && gn < 40) || (sesso == 'M' && gn > 40))
@ -420,7 +416,9 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
if (gn > 40) gn -= 40; // Aggiusta giorno di nascita delle donne if (gn > 40) gn -= 40; // Aggiusta giorno di nascita delle donne
// Controllo data di nascita // Controllo data di nascita
wm = "ABCDEHLMPRST";
const TFixed_string wm = "ABCDEHLMPRST";
if (data.full()) if (data.full())
{ {
const TDate d(data); const TDate d(data);
@ -447,7 +445,7 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
if (mn > 0) if (mn > 0)
{ {
int anno = atoi(cf.mid(6, 2)); int anno = atoi(cf.mid(6, 2));
anno += anno < 10 ? 2000 : 1900; anno += anno < 25 ? 2000 : 1900;
const TDate d(gn, mn, anno); const TDate d(gn, mn, anno);
fld_dat.set(d.string()); fld_dat.set(d.string());
} }
@ -470,7 +468,6 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
return true; return true;
} }
HIDDEN bool _xtz_cf_val(TMask_field& f, KEY key) HIDDEN bool _xtz_cf_val(TMask_field& f, KEY key)
{ {
return f.empty() || _xt_cf_val(f, key); return f.empty() || _xt_cf_val(f, key);
@ -513,7 +510,8 @@ HIDDEN bool _fixlen_val(TMask_field& f, KEY)
const int length = get_int_val_param(0); const int length = get_int_val_param(0);
const bool ok = s.len() == length; const bool ok = s.len() == length;
if (!ok) if (!ok)
f.error_box(FR("La lunghezza del campo deve essere %d caratteri"), length); f.error_box(FR("La lunghezza del campo deve essere %d %s"),
length, f.is_kind_of(CLASS_REAL_FIELD) ? TR("cifre") : TR("caratteri"));
return ok; return ok;
} }

View File

@ -272,7 +272,7 @@ bool TVariable_rectype::exist(const char* fieldname) const
return TRectype::exist(fieldname); return TRectype::exist(fieldname);
} }
const TString & TVariable_rectype::get_str(const char* fieldname) const const TString& TVariable_rectype::get_str(const char* fieldname) const
{ {
TVariable_field* f = (TVariable_field*) _virtual_fields.objptr(fieldname); TVariable_field* f = (TVariable_field*) _virtual_fields.objptr(fieldname);

View File

@ -206,7 +206,7 @@ public:
virtual word class_id() const { return CLASS_AUTO_VARIABLE_RECTYPE; } virtual word class_id() const { return CLASS_AUTO_VARIABLE_RECTYPE; }
virtual bool is_kind_of(word id) const { return id == class_id() || TVariable_rectype::is_kind_of(id); } virtual bool is_kind_of(word id) const { return id == class_id() || TVariable_rectype::is_kind_of(id); }
// @cmember Indica se esiste il campo <p fieldname> // @cmember Indica se esiste il campo <p fieldname>
virtual bool exist(const char* fieldname) const { return fieldname && *fieldname;} virtual bool exist(const char* fieldname) const { return fieldname && *fieldname; }
// @cmember Distruttore // @cmember Distruttore
virtual ~TAuto_variable_rectype() {} virtual ~TAuto_variable_rectype() {}

File diff suppressed because it is too large Load Diff

View File

@ -38,11 +38,12 @@ WINDOW xvtil_create_statbar();
void xvtil_statbar_set(const char* text, bool def = FALSE); void xvtil_statbar_set(const char* text, bool def = FALSE);
void xvtil_statbar_refresh(); void xvtil_statbar_refresh();
void xvtil_statbar_destroy(); void xvtil_statbar_destroy();
int xvtil_statbar_height(); int xvtil_statbar_height();
bool xvtil_popup_message(const char* msg); bool xvtil_popup_message(const char* msg);
bool xvtil_popup_warning(const char* msg); bool xvtil_popup_warning(const char* msg);
bool xvtil_popup_error(const char* msg); bool xvtil_popup_error(const char* msg);
bool xvtil_system_error(unsigned long lasterror, ...);
void beep(int severity = 0); void beep(int severity = 0);
void do_events(); void do_events();