Patch level : 2.2

Files correlati     : stampe report
Ricompilazione Demo : [ ]
Commento            :

Permessa customizzazione filtri su query dei report


git-svn-id: svn://10.65.10.50/trunk@13179 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-06-07 14:19:42 +00:00
parent 1d145dda27
commit 7ba3f85254
7 changed files with 87 additions and 38 deletions

View File

@ -507,7 +507,7 @@ int TAVM::find_matching(const TBytecode& bytecode, AVM_opcode op1, AVM_opcode op
TAVM_op& theop = (TAVM_op&)bytecode[i];
if ((theop.op() == op1 || theop.op() == op2) && theop.var().is_null())
{
theop.var() = bytecode.items();
theop.var() = long(bytecode.items());
break;
}
}

View File

@ -592,6 +592,7 @@ static void sort_files(TString_array& files)
path = *row;
path = path.name();
path.ext("");
path.lower();
*row = path;
}
files.sort(); // Ordina alfabeticamente
@ -604,9 +605,44 @@ static void sort_files(TString_array& files)
}
}
bool select_custom_file(TFilename& path, const char* ext, const char* library)
static bool get_xml_attr(const TString& line, const char* attr, TString& value)
{
TString_array files;
TString80 str; str << ' ' << attr << "=\"";
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('"', pos)+1;
const int apicic = line.find('"', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
static bool get_xml_child(const TString& line, const char* tag, TString& value)
{
TString80 str; str << '<' << tag << '>';
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('>', pos)+1;
const int apicic = line.find('<', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
bool list_custom_files(const char* ext, const char* library, TString_array& files)
{
TString_array lista;
TFilename path;
// Leggo i files in custom
if (main_app().has_module(RSAUT))
@ -620,53 +656,62 @@ bool select_custom_file(TFilename& path, const char* ext, const char* library)
path.add("*");
path.ext(ext);
list_files(path, files);
list_files(path, lista);
}
path = "*."; path.ext(ext); // Leggo i files in campo
list_files(path, files);
sort_files(files); // Ordino i files e rimuovo i doppioni
path = "*"; path.ext(ext); // Leggo i files in campo
list_files(path, lista);
sort_files(lista); // Ordino i files e rimuovo i doppioni
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@20|Descrizione@50|Librerie@20"));
TToken_string libraries(50, ',');
TString stringona, desc;
TString str;
FOR_EACH_ARRAY_ROW(files, i, row)
FOR_EACH_ARRAY_ROW(lista, i, row)
{
path = *row; path.ext(ext);
if (path.custom_path())
{
TXmlItem item;
bool ok = item.Load(path);
if (ok && library != NULL && *library)
{
const TString& include = item.GetAttr("libraries");
ok = include.find(library) >= 0;
}
bool ok = path.custom_path();
if (ok)
{
TScanner scan(path);
stringona.cut(0);
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
stringona << scan.line();
get_xml_attr(stringona, "libraries", libraries);
get_xml_child(stringona, "description", desc);
if (library && *library)
ok = libraries.get_pos(library) >= 0;
if (ok)
{
TToken_string* riga = new TToken_string;
riga->add(*row);
const TXmlItem* desc = item.FindFirst("description");
str = *row;
if (desc != NULL)
desc->GetEnclosedText(str);
riga->add(str);
riga->add(item.GetAttr("libraries"));
sheet.add(riga);
riga->add(desc);
riga->add(libraries);
files.add(riga);
}
}
}
bool ok = sheet.run() == K_ENTER;
return !files.empty();
}
bool select_custom_file(TFilename& path, const char* ext, const char* library)
{
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@20|Descrizione@50|Librerie@20"));
TString_array& files = sheet.rows_array();
bool ok = list_custom_files(ext, library, files);
if (ok)
{
path = sheet.row(-1).get(0);
path.ext(ext);
ok = path.custom_path();
ok = sheet.run() == K_ENTER;
if (ok)
{
path = sheet.row(-1).get(0);
path.ext(ext);
ok = path.custom_path();
}
}
return ok;
}
@ -1807,6 +1852,7 @@ TCursor* TISAM_recordset::cursor() const
if (_cursor != NULL)
{
set_custom_filter(*_cursor);
const TRecnotype items = _cursor->items();
_cursor->freeze();
if (items > 0)

View File

@ -131,6 +131,7 @@ protected:
virtual void reset();
TVariant& get_tmp_var() const;
virtual const TVariant& get(int logic, const char* field) const;
virtual void set_custom_filter(TCursor& cursor) const { }
public:
TCursor* cursor() const;
@ -169,6 +170,7 @@ public:
// Utility
///////////////////////////////////////////////////////////
bool list_custom_files(const char* ext, const char* library, TString_array& files);
bool select_custom_file(TFilename& path, const char* ext, const char* library = NULL);
const TString& logic2table(int logic_num);
int table2logic(const TString& name);

View File

@ -2266,12 +2266,12 @@ bool TReport::get_report_field(const TString& name, TVariant& var) const
if (xvt_str_compare_ignoring_case(str, "PAGE") == 0)
{
var = _rep_page;
var = long(_rep_page);
return true;
} else
if (xvt_str_compare_ignoring_case(str, "BOOKPAGE") == 0)
{
var = _book_page;
var = long(_book_page);
return true;
}

View File

@ -228,8 +228,8 @@ public:
void set_postscript(const char* src);
void update_recordset_parent(); // Internal use only
bool set_recordset(TRecordset* rs);
bool set_recordset(const TString& sql);
virtual bool set_recordset(TRecordset* rs);
virtual bool set_recordset(const TString& sql);
TRecordset* recordset() const { return _recordset; }
bool get_record_field(const char* name, TVariant& var) const;

View File

@ -701,7 +701,7 @@ public:
{ return (TToken_string&)operator[](n); }
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
const TToken_string& row(int n) const
{ return (TToken_string&)operator[](n); }
{ return (const TToken_string&)operator[](n); }
// @cmember Restituisce il puntatore alla stringa n dell'array (NULL se non esiste)
TToken_string* rowptr(int n)
{ return (TToken_string*)objptr(n); }

View File

@ -45,6 +45,7 @@ public:
TVariant& operator=(const real& r) { set(r); return *this; }
TVariant& operator=(const long n) { set(n); return *this; }
TVariant& operator=(const TDate& d) { set(d); return *this; }
TVariant& operator=(bool b) { set(long(b)); return *this; }
const TString& as_string() const;
bool as_string(TString& str) const;