From 6bcba93538b041030f59db0377c934a4f732f46d Mon Sep 17 00:00:00 2001 From: luca Date: Mon, 14 Mar 2011 11:34:20 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20level=20=20=20=20=20=20=20=20=20:10.0?= =?UTF-8?q?=20954=20in=20avanti=20Files=20correlati=20=20=20=20=20:=20Rico?= =?UTF-8?q?mpilazione=20Demo=20:=20[=20]=20Commento=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20:=20aggiunto=20metodo=20build=5Ftrc=20per=20racc?= =?UTF-8?q?attare=20il=20tracciato=20record=20di=20un=20csv=20recordset=20?= =?UTF-8?q?salvato=20in=20fmt=5Fhtml=20se=20il=20recordset=20non=20ha=20de?= =?UTF-8?q?lle=20column=20gi=C3=A0=20esplicitamente=20definite=20(prima=20?= =?UTF-8?q?applicazione=20ve3800)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.65.10.50/branches/R_10_00@21780 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/recset.cpp | 11 +++++++---- include/textset.cpp | 22 +++++++++++++++------- include/textset.h | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/recset.cpp b/include/recset.cpp index 610a5ae53..263694bd2 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -153,7 +153,8 @@ bool TRecordset::save_as_html(const char* path) str << tok; } if (get_attr(c, attr, true)) - out << " " ; + out << " " ; else out << " "; @@ -176,7 +177,8 @@ bool TRecordset::save_as_html(const char* path) const TRecordset_column_info& ci = column_info(c); if (get_attr(c, attr)) - out << " " ; + out << " " ; else out << " "; switch (ci._type) @@ -184,12 +186,13 @@ bool TRecordset::save_as_html(const char* path) case _intfld: case _longfld: { - const long r = get(c).as_int(); + const TVariant& var = get(c); + const long r = var.as_int(); val.cut(0); if (r != 0) val << r; else - get(c).as_string(val); + var.as_string(val); } break; case _realfld: diff --git a/include/textset.cpp b/include/textset.cpp index c13684205..c7c2b2e9e 100755 --- a/include/textset.cpp +++ b/include/textset.cpp @@ -252,8 +252,10 @@ unsigned int TCSV_recordset::columns() const unsigned int c = _trc.items(); if (c == 0) { - const TRecnotype i = items(); + const TRecnotype i = items(); //rilegge fai di testo e tenta di crearne il tracciato _trc c = _trc.items(); + if (c == 0 && i > 0) + c = ((TCSV_recordset*)this)->build_trc(); } return c; } @@ -286,12 +288,9 @@ void TCSV_recordset::create_column(const char * name, TFieldtypes type) _trc.add(info); } -bool TCSV_recordset::load_file(const TFilename& n) +unsigned int TCSV_recordset::build_trc() { - if (!TText_recordset::load_file(n)) - return false; - - _trc.destroy(); + _trc.destroy(); int cols = 1; int i; for (i = items()-1; i >= 0; i--) @@ -336,7 +335,16 @@ bool TCSV_recordset::load_file(const TFilename& n) } } - return true; + return _trc.items(); +} + + +bool TCSV_recordset::load_file(const TFilename& n) +{ + if (!TText_recordset::load_file(n)) + return false; + + return build_trc() > 0; } bool TCSV_recordset::set(unsigned int column, const TVariant& var) diff --git a/include/textset.h b/include/textset.h index 57a00fa8c..3186b5055 100755 --- a/include/textset.h +++ b/include/textset.h @@ -71,6 +71,7 @@ protected: char separator() const { return _separator; } void set_separator(const char s) { CHECK(s != 0, "Invalid separator"); _separator = s; } virtual TQuery_type parse_query(const char* query, TFilename& table); + unsigned int build_trc(); public: virtual unsigned int columns() const;