Patch level :2.2 2006 399
Files correlati : Ricompilazione Demo : [ ] Commento :corretti errori di riporto dalla 2.1 git-svn-id: svn://10.65.10.50/trunk@13911 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e225985b7c
commit
73441d637d
@ -2022,7 +2022,7 @@ HIDDEN BOOLEAN calc_font_callback(long data)
|
|||||||
{
|
{
|
||||||
long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution
|
long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution
|
||||||
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, printer().get_printrcd(), &ph, &pw, &pvr, &phr);
|
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, printer().get_printrcd(), &ph, &pw, &pvr, &phr);
|
||||||
xvt_set_font(win, pr.fontname(), XVT_FS_NONE, pr.get_char_size());
|
xvtil_set_font(win, pr.fontname(), XVT_FS_NONE, pr.get_char_size());
|
||||||
|
|
||||||
TString test(fd._columns);
|
TString test(fd._columns);
|
||||||
test.fill('M', fd._columns);
|
test.fill('M', fd._columns);
|
||||||
|
@ -685,7 +685,7 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files
|
|||||||
path = custom;
|
path = custom;
|
||||||
path.add("*");
|
path.add("*");
|
||||||
path.ext(ext);
|
path.ext(ext);
|
||||||
|
}
|
||||||
list_files(path, lista);
|
list_files(path, lista);
|
||||||
}
|
}
|
||||||
path = "*"; path.ext(ext); // Leggo i files in campo
|
path = "*"; path.ext(ext); // Leggo i files in campo
|
||||||
@ -763,20 +763,11 @@ bool select_custom_file(TFilename& path, const char* ext, const char* library)
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Private interface
|
// Private interface
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
#include "../sqlite/sqlite3.h"
|
||||||
#ifdef SQLITE3
|
|
||||||
#include "../sqlite3/sqlite3.h"
|
|
||||||
#else
|
|
||||||
#include "../sqlite/sqlite.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class TSQLite : public TObject
|
class TSQLite : public TObject
|
||||||
{
|
{
|
||||||
#ifdef SQLITE3
|
|
||||||
sqlite3* _handle;
|
sqlite3* _handle;
|
||||||
#else
|
|
||||||
sqlite* _handle;
|
|
||||||
#endif
|
|
||||||
TFilename _currdb;
|
TFilename _currdb;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -785,24 +776,17 @@ protected:
|
|||||||
void build_curr_path(TFilename& name) const;
|
void build_curr_path(TFilename& name) const;
|
||||||
void test_path();
|
void test_path();
|
||||||
|
|
||||||
#ifdef SQLITE3
|
|
||||||
bool bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* pStatement) const;
|
bool bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* pStatement) const;
|
||||||
#else
|
|
||||||
bool esporta(const TRectype& rec, ostream& sql) const;
|
|
||||||
#endif
|
|
||||||
bool create_dbf_times();
|
bool create_dbf_times();
|
||||||
long get_dbf_time(const TString& table);
|
long get_dbf_time(const TString& table);
|
||||||
bool set_dbf_time(const TString& table, long last);
|
bool set_dbf_time(const TString& table, long last);
|
||||||
bool import(int logicnum);
|
bool import(int logicnum);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef SQLITE3
|
|
||||||
sqlite3* open(const char* fname = NULL);
|
sqlite3* open(const char* fname = NULL);
|
||||||
bool exec(const char* sql, sqlite3_callback callback = NULL, void* jolly = NULL, bool show_error = true);
|
bool exec(const char* sql, sqlite3_callback callback = NULL, void* jolly = NULL, bool show_error = true);
|
||||||
#else
|
|
||||||
sqlite* open(const char* fname = NULL);
|
|
||||||
bool exec(const char* sql, sqlite_callback callback = NULL, void* jolly = NULL, bool show_error = true);
|
|
||||||
#endif
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
bool exists(const char* table);
|
bool exists(const char* table);
|
||||||
@ -827,8 +811,6 @@ void TSQLite::build_curr_path(TFilename& name) const
|
|||||||
name.add(firm);
|
name.add(firm);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE3
|
|
||||||
|
|
||||||
sqlite3* TSQLite::open(const char* fname)
|
sqlite3* TSQLite::open(const char* fname)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
@ -855,26 +837,6 @@ sqlite3* TSQLite::open(const char* fname)
|
|||||||
return _handle;
|
return _handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
sqlite* TSQLite::open(const char* fname)
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
_currdb = fname;
|
|
||||||
char* errmsg = NULL;
|
|
||||||
_handle = sqlite_open(_currdb, 0, &errmsg);
|
|
||||||
if (errmsg != NULL)
|
|
||||||
{
|
|
||||||
error_box(errmsg);
|
|
||||||
sqlite_freemem(errmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
create_dbf_times();
|
|
||||||
|
|
||||||
return _handle;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void TSQLite::test_path()
|
void TSQLite::test_path()
|
||||||
{
|
{
|
||||||
TFilename n;
|
TFilename n;
|
||||||
@ -883,22 +845,15 @@ void TSQLite::test_path()
|
|||||||
open(n);
|
open(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE3
|
|
||||||
bool TSQLite::exec(const char* sql, sqlite3_callback callback, void* jolly, bool show_error)
|
bool TSQLite::exec(const char* sql, sqlite3_callback callback, void* jolly, bool show_error)
|
||||||
#else
|
|
||||||
bool TSQLite::exec(const char* sql, sqlite_callback callback, void* jolly, bool show_error)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (_handle == NULL)
|
if (_handle == NULL)
|
||||||
test_path();
|
test_path();
|
||||||
|
|
||||||
TWait_cursor hourglass;
|
TWait_cursor hourglass;
|
||||||
char* errmsg = NULL;
|
char* errmsg = NULL;
|
||||||
#ifdef SQLITE3
|
|
||||||
const int rc = sqlite3_exec(_handle, sql, callback, jolly, &errmsg);
|
const int rc = sqlite3_exec(_handle, sql, callback, jolly, &errmsg);
|
||||||
#else
|
|
||||||
const int rc = sqlite_exec(_handle, sql, callback, jolly, &errmsg);
|
|
||||||
#endif
|
|
||||||
if (errmsg != NULL)
|
if (errmsg != NULL)
|
||||||
{
|
{
|
||||||
if (show_error)
|
if (show_error)
|
||||||
@ -909,11 +864,7 @@ bool TSQLite::exec(const char* sql, sqlite_callback callback, void* jolly, bool
|
|||||||
msg << '\n' << errmsg;
|
msg << '\n' << errmsg;
|
||||||
error_box(msg);
|
error_box(msg);
|
||||||
}
|
}
|
||||||
#ifdef SQLITE3
|
|
||||||
sqlite3_free(errmsg);
|
sqlite3_free(errmsg);
|
||||||
#else
|
|
||||||
sqlite_freemem(errmsg);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return rc == SQLITE_OK;
|
return rc == SQLITE_OK;
|
||||||
}
|
}
|
||||||
@ -922,11 +873,7 @@ void TSQLite::close()
|
|||||||
{
|
{
|
||||||
if (_handle != NULL)
|
if (_handle != NULL)
|
||||||
{
|
{
|
||||||
#ifdef SQLITE3
|
|
||||||
sqlite3_close(_handle);
|
sqlite3_close(_handle);
|
||||||
#else
|
|
||||||
sqlite_close(_handle);
|
|
||||||
#endif
|
|
||||||
_handle = NULL;
|
_handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1015,7 +962,6 @@ bool TSQLite::exists(const char* table)
|
|||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE3
|
|
||||||
bool TSQLite::bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* pStatement) const
|
bool TSQLite::bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* pStatement) const
|
||||||
{
|
{
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
@ -1132,122 +1078,6 @@ bool TSQLite::import(int logicnum)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
bool TSQLite::esporta(const TRectype& rec, ostream& sql) const
|
|
||||||
{
|
|
||||||
const RecDes& rd = *rec.rec_des();
|
|
||||||
TVariant tmp;
|
|
||||||
for (int i = 0; i < rd.NFields; i++)
|
|
||||||
{
|
|
||||||
if (i > 0) sql << '\t';
|
|
||||||
get_sql_value(rec, rd.Fd[i], tmp);
|
|
||||||
sql << tmp.as_string();
|
|
||||||
}
|
|
||||||
sql << '\n';
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TSQLite::import(int logicnum)
|
|
||||||
{
|
|
||||||
const TString& table = logic2table(logicnum);
|
|
||||||
|
|
||||||
long last = get_dbf_time(table);
|
|
||||||
if (logicnum >= LF_USER) // Dummy test
|
|
||||||
{
|
|
||||||
TLocalisamfile file(logicnum);
|
|
||||||
if (!file.is_changed_since(last))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const RecDes& rd = prefix().get_recdes(logicnum);
|
|
||||||
|
|
||||||
TString sql;
|
|
||||||
if (exists(table))
|
|
||||||
{
|
|
||||||
// Drop old table
|
|
||||||
sql.cut(0) << "DROP TABLE "<< table << ';';
|
|
||||||
exec(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create new table
|
|
||||||
sql.cut(0) << "CREATE TABLE "<< table << "\n(";
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < rd.NFields; i++)
|
|
||||||
{
|
|
||||||
if (i > 0) sql << ',';
|
|
||||||
sql << rd.Fd[i].Name << ' ';
|
|
||||||
switch (rd.Fd[i].TypeF)
|
|
||||||
{
|
|
||||||
case _alfafld: sql << "TEXT"; break;
|
|
||||||
case _memofld: sql << "BLOB"; break;
|
|
||||||
case _datefld: sql << "DATE"; break;
|
|
||||||
default : sql << "NUMERIC"; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sql << ");";
|
|
||||||
if (!exec(sql))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Creazione indici
|
|
||||||
for (int index = 0; index < rd.NKeys; index++)
|
|
||||||
{
|
|
||||||
sql.cut(0) << "CREATE INDEX " << table << '_' << (index+1) << " ON "<< table << "\n(";
|
|
||||||
const KeyDes& kd = rd.Ky[index];
|
|
||||||
for (int k = 0; k < kd.NkFields; k++)
|
|
||||||
{
|
|
||||||
if (k > 0) sql << ',';
|
|
||||||
const int ndx = kd.FieldSeq[k] % MaxFields;
|
|
||||||
sql << rd.Fd[ndx].Name;
|
|
||||||
}
|
|
||||||
sql << ");";
|
|
||||||
exec(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
TRelation rel(logicnum);
|
|
||||||
TCursor cur(&rel);
|
|
||||||
const TRecnotype items = cur.items();
|
|
||||||
|
|
||||||
if (items > 0)
|
|
||||||
{
|
|
||||||
cur.freeze();
|
|
||||||
const TRectype& curr = rel.curr();
|
|
||||||
|
|
||||||
TString msg;
|
|
||||||
msg << TR("Esportazione tabella") << ' ' << table;
|
|
||||||
TPerformance_profiler prof(msg);
|
|
||||||
|
|
||||||
msg << ": " << items << ' ' << TR("righe");
|
|
||||||
TProgind pi(items, msg, true, true);
|
|
||||||
|
|
||||||
TFilename tmp; tmp.tempdir(); tmp.add("sql.txt");
|
|
||||||
ofstream txt(tmp, ios::binary);
|
|
||||||
|
|
||||||
for (cur = 0; cur.pos() < items; ++cur)
|
|
||||||
{
|
|
||||||
esporta(curr, txt);
|
|
||||||
pi.addstatus(1);
|
|
||||||
if (pi.iscancelled())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
txt.close();
|
|
||||||
|
|
||||||
msg << '\n' << TR("Importazione tabella") << ' ' << table;
|
|
||||||
msg << ": " << items << ' ' << TR("righe");
|
|
||||||
pi.set_text(msg);
|
|
||||||
|
|
||||||
sql.cut(0) << "COPY " << table << " FROM '" << tmp << "';";
|
|
||||||
if (exec(sql))
|
|
||||||
set_dbf_time(table, last); // Aggiorna ora di ultima modifica
|
|
||||||
|
|
||||||
::remove(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool TSQLite::parse_select_from(const char* szSql)
|
bool TSQLite::parse_select_from(const char* szSql)
|
||||||
{
|
{
|
||||||
test_path();
|
test_path();
|
||||||
|
@ -1121,7 +1121,7 @@ void TBook::print_doc(TWindow& win, const TFilename& name)
|
|||||||
TPoint ps = page_size();
|
TPoint ps = page_size();
|
||||||
TRectangle rect(TPoint(0,0), ps);
|
TRectangle rect(TPoint(0,0), ps);
|
||||||
RCT page; win.log2dev(rect, page);
|
RCT page; win.log2dev(rect, page);
|
||||||
advanced_draw_text(win, name, page, 'C', 'T');
|
advanced_draw_text_line(win, name, page, 'C', 'T');
|
||||||
|
|
||||||
const TPoint pr = page_res();
|
const TPoint pr = page_res();
|
||||||
rect.deflate(pr.x/2, pr.y/2);
|
rect.deflate(pr.x/2, pr.y/2);
|
||||||
@ -1594,7 +1594,7 @@ bool TBook::main_loop()
|
|||||||
{
|
{
|
||||||
for (size_t page = _pagefrom; page <= _pageto && !_print_aborted; page++)
|
for (size_t page = _pagefrom; page <= _pageto && !_print_aborted; page++)
|
||||||
{
|
{
|
||||||
if (!print_page(win, page))
|
if (!print_page(*_printwin, page))
|
||||||
_print_aborted = true;
|
_print_aborted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
virtual int logical_page_height() const { return page_size().y * lpi() / page_res().y * 100; }
|
virtual int logical_page_height() const { return page_size().y * lpi() / page_res().y * 100; }
|
||||||
|
|
||||||
virtual bool print_page(TWindow& win, size_t page);
|
virtual bool print_page(TWindow& win, size_t page);
|
||||||
|
virtual void print_doc(TWindow& win, const TFilename& name);
|
||||||
virtual bool on_link(const TReport_link&) { return false; }
|
virtual bool on_link(const TReport_link&) { return false; }
|
||||||
|
|
||||||
virtual bool print(size_t pagefrom = 0, size_t pageto = 0, size_t copies = 0);
|
virtual bool print(size_t pagefrom = 0, size_t pageto = 0, size_t copies = 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user