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:
luca 2006-04-14 11:07:23 +00:00
parent e225985b7c
commit 73441d637d
4 changed files with 9 additions and 178 deletions

View File

@ -2022,7 +2022,7 @@ HIDDEN BOOLEAN calc_font_callback(long data)
{
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_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);
test.fill('M', fd._columns);

View File

@ -685,7 +685,7 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files
path = custom;
path.add("*");
path.ext(ext);
}
list_files(path, lista);
}
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
///////////////////////////////////////////////////////////
#ifdef SQLITE3
#include "../sqlite3/sqlite3.h"
#else
#include "../sqlite/sqlite.h"
#endif
#include "../sqlite/sqlite3.h"
class TSQLite : public TObject
{
#ifdef SQLITE3
sqlite3* _handle;
#else
sqlite* _handle;
#endif
TFilename _currdb;
protected:
@ -785,24 +776,17 @@ protected:
void build_curr_path(TFilename& name) const;
void test_path();
#ifdef SQLITE3
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();
long get_dbf_time(const TString& table);
bool set_dbf_time(const TString& table, long last);
bool import(int logicnum);
public:
#ifdef SQLITE3
sqlite3* open(const char* fname = NULL);
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();
bool exists(const char* table);
@ -827,8 +811,6 @@ void TSQLite::build_curr_path(TFilename& name) const
name.add(firm);
}
#ifdef SQLITE3
sqlite3* TSQLite::open(const char* fname)
{
close();
@ -855,26 +837,6 @@ sqlite3* TSQLite::open(const char* fname)
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()
{
TFilename n;
@ -883,22 +845,15 @@ void TSQLite::test_path()
open(n);
}
#ifdef SQLITE3
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)
test_path();
TWait_cursor hourglass;
char* errmsg = NULL;
#ifdef SQLITE3
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 (show_error)
@ -909,11 +864,7 @@ bool TSQLite::exec(const char* sql, sqlite_callback callback, void* jolly, bool
msg << '\n' << errmsg;
error_box(msg);
}
#ifdef SQLITE3
sqlite3_free(errmsg);
#else
sqlite_freemem(errmsg);
#endif
}
return rc == SQLITE_OK;
}
@ -922,11 +873,7 @@ void TSQLite::close()
{
if (_handle != NULL)
{
#ifdef SQLITE3
sqlite3_close(_handle);
#else
sqlite_close(_handle);
#endif
_handle = NULL;
}
}
@ -1015,7 +962,6 @@ bool TSQLite::exists(const char* table)
return yes;
}
#ifdef SQLITE3
bool TSQLite::bind_record(const TRectype& rec, const RecDes& rd, sqlite3_stmt* pStatement) const
{
int rc = SQLITE_OK;
@ -1132,122 +1078,6 @@ bool TSQLite::import(int logicnum)
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)
{
test_path();

View File

@ -1121,7 +1121,7 @@ void TBook::print_doc(TWindow& win, const TFilename& name)
TPoint ps = page_size();
TRectangle rect(TPoint(0,0), ps);
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();
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++)
{
if (!print_page(win, page))
if (!print_page(*_printwin, page))
_print_aborted = true;
}
}

View File

@ -66,6 +66,7 @@ public:
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 void print_doc(TWindow& win, const TFilename& name);
virtual bool on_link(const TReport_link&) { return false; }
virtual bool print(size_t pagefrom = 0, size_t pageto = 0, size_t copies = 0);