From 7ba3f852545bf78171f08264ff821538d88abc00 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 7 Jun 2005 14:19:42 +0000 Subject: [PATCH] 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 --- include/alex.cpp | 2 +- include/recset.cpp | 110 ++++++++++++++++++++++++++++++++------------- include/recset.h | 2 + include/report.cpp | 4 +- include/report.h | 4 +- include/strings.h | 2 +- include/variant.h | 1 + 7 files changed, 87 insertions(+), 38 deletions(-) diff --git a/include/alex.cpp b/include/alex.cpp index e6ea7cba8..5da25bd55 100755 --- a/include/alex.cpp +++ b/include/alex.cpp @@ -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; } } diff --git a/include/recset.cpp b/include/recset.cpp index cedd23d50..c39d69376 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -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) diff --git a/include/recset.h b/include/recset.h index 81e7ce3be..5576c9fc4 100755 --- a/include/recset.h +++ b/include/recset.h @@ -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); diff --git a/include/report.cpp b/include/report.cpp index 96df3e70d..56e56777d 100755 --- a/include/report.cpp +++ b/include/report.cpp @@ -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; } diff --git a/include/report.h b/include/report.h index bbaf8a6c5..9f038d9c5 100755 --- a/include/report.h +++ b/include/report.h @@ -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; diff --git a/include/strings.h b/include/strings.h index 44f7e451c..6caca831f 100755 --- a/include/strings.h +++ b/include/strings.h @@ -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); } diff --git a/include/variant.h b/include/variant.h index 27bc986a1..77e37964f 100755 --- a/include/variant.h +++ b/include/variant.h @@ -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;