Patch level : 2.1 50

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@12122 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-05-27 16:00:36 +00:00
parent 03bc77a2fe
commit a411b609ba
7 changed files with 167 additions and 97 deletions

View File

@ -1218,6 +1218,15 @@ bool TAlex_virtual_machine::get_usr_val(const TString& name, TVariant& var) cons
var.set(oggi);
return true;
}
if (n == "TIME")
{
time_t lt; time(&lt);
struct tm* t = localtime(&lt);
TString16 str;
str.format("%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec);
var.set(str);
return true;
}
if (n == "USER")
{
var.set(user());

View File

@ -621,15 +621,7 @@ int TRecordset::find_column(const char* column_name) const
const TVariant& TRecordset::get(const char* column_name) const
{
if (*column_name == '#')
{
if (variables().items() > 0)
{
const TVariant& var = get_var(column_name);
if (!var.is_null())
return var;
}
column_name++;
}
return get_var(column_name);
char* colon = strchr(column_name, ':');
if (colon != NULL)
@ -728,6 +720,7 @@ void TRecordset::parsed_text(TString& sql) const
if (vars) // Se ci sono variabili faccio le sostituzioni
{
const TString_array& names = variables();
TString s;
FOR_EACH_ARRAY_ROW(names, i, name) // Scandisco tutte le variabili
{
TVariant var = get_var(*name);
@ -736,7 +729,11 @@ void TRecordset::parsed_text(TString& sql) const
{
const TString& after = sql.mid(pos+name->len());
sql.cut(pos);
TString s = var.as_string();
if (var.type() == _datefld)
s = var.as_date().string(ANSI);
else
s = var.as_string();
if ((var.is_string() && s[0] != '\'') || var.is_null())
{
s.insert("'");
@ -1873,6 +1870,9 @@ const TVariant& TISAM_recordset::get(size_t c) const
const TVariant& TISAM_recordset::get(const char* name) const
{
if (*name == '#')
return get_var(name);
const TFixed_string fldname(name);
int table_end = fldname.find('.');

View File

@ -2100,8 +2100,18 @@ TFieldref& TFieldref::operator =(
}
else
{
_id.cut(0);
_fileid = pos = 0;
pos = s.find('.');
if (pos > 0)
{
_id = s.left(pos); _id.strip(" ");
_fileid = name2log(_id);
pos++;
}
else
{
_id.cut(0);
_fileid = pos = 0;
}
}
int par = s.find('[', pos); // Cerca la fine del nome del campo

View File

@ -936,6 +936,14 @@ void TReport_field::set_draw_size(long w, long h)
_draw_rct.set_height(h);
}
void TReport_field::set_dynamic_height(bool dh)
{
_dynamic_height = dh && _type == 'S' && _rct.height() > 0;
}
bool TReport_field::dynamic_height() const
{ return _dynamic_height; }
const TRectangle& TReport_field::get_draw_rect() const
{
if (dynamic_height())
@ -1006,6 +1014,7 @@ void TReport_field::copy(const TReport_field& rf)
_id = rf.id();
_type = rf.type();
_rct = rf._rct;
set_dynamic_height(rf.dynamic_height());
_fgcolor = rf._fgcolor; _bgcolor = rf._bgcolor;
_border = rf._border;
_halign = rf._halign; _valign = rf._valign;
@ -1132,71 +1141,11 @@ bool TReport_field::execute_postscript()
return draw_deactivated() || _postscript.execute(*this);
}
void TReport_field::draw_rect(TWindow& win) const
{
RCT r; win.log2dev(get_rect(), r);
advanced_draw_rect(win, r, border(), fore_color(), back_color());
}
COLOR TReport_field::link_color() const
{
return COLOR_BLUE;
}
void TReport_field::draw_text(TWindow& win, const char* text, TReport_draw_mode rdm) const
{
const TRectangle& rct = get_draw_rect();
RCT r; win.log2dev(rct, r);
advanced_draw_rect(win, r, border(), fore_color(), back_color());
if (rdm == rdm_preview && link().not_empty())
{
XVT_FNTID lnkfont = xvt_font_create();
xvt_font_copy(lnkfont, font().get_xvt_font(win), XVT_FA_ALL);
xvt_font_set_style(lnkfont, XVT_FS_UNDERLINE);
xvt_dwin_set_font(win.win(), lnkfont);
xvt_font_destroy(lnkfont);
win.set_color(link_color(), back_color());
}
else
{
xvt_dwin_set_font(win.win(), font().get_xvt_font(win));
win.set_color(fore_color(), back_color());
}
if (rct.height() > 100) // Devo scrivere piu' righe?
{
const unsigned columns = rct.width() / 100;
int rows = rct.height() / 100;
TParagraph_string str(text, columns);
if (str.items() < rows)
rows = str.items();
int ybase = rct.y;
switch (_valign)
{
case 'C': ybase += (rct.height() - rows*100) / 2; break;
case 'B': ybase += rct.height() - rows*100; break;
default : break;
}
char halign = _halign;
char valign = 'T';
for (int row = 0; row < rows; row++)
{
TRectangle rctline = rct;
rctline.y = ybase + 100*row;
rctline.set_height(100);
win.log2dev(rctline, r);
const char* line = str.get();
if (halign == 'J' && (row == rows-1 || strlen(line) < columns/2))
halign = 'L';
advanced_draw_text(win, line, r, halign, valign);
}
}
else
advanced_draw_text(win, text, r, _halign, _valign);
}
void TReport_field::get_currency(TCurrency& cur) const
{
if (_codval.not_empty())
@ -1296,7 +1245,68 @@ const TString& TReport_field::formatted_text() const
return EMPTY_STRING;
}
void TReport_field::draw(TWindow& win, TReport_draw_mode rdm) const
/*
void TReport_field::draw_rect(TWindow& win) const
{
RCT r; win.log2dev(get_rect(), r);
advanced_draw_rect(win, r, border(), fore_color(), back_color());
}
void TReport_field::draw_text(TWindow& win, const char* text, TReport_draw_mode rdm) const
{
const TRectangle& rct = get_draw_rect();
RCT r; win.log2dev(rct, r);
advanced_draw_rect(win, r, border(), fore_color(), back_color());
if (rdm == rdm_preview && link().not_empty())
{
XVT_FNTID lnkfont = xvt_font_create();
xvt_font_copy(lnkfont, font().get_xvt_font(win), XVT_FA_ALL);
xvt_font_set_style(lnkfont, XVT_FS_UNDERLINE);
xvt_dwin_set_font(win.win(), lnkfont);
xvt_font_destroy(lnkfont);
win.set_color(link_color(), back_color());
}
else
{
xvt_dwin_set_font(win.win(), font().get_xvt_font(win));
win.set_color(fore_color(), back_color());
}
if (rct.height() > 100) // Devo scrivere piu' righe?
{
const unsigned columns = rct.width() / 100;
int rows = rct.height() / 100;
TParagraph_string str(text, columns);
if (str.items() < rows)
rows = str.items();
int ybase = rct.y;
switch (_valign)
{
case 'C': ybase += (rct.height() - rows*100) / 2; break;
case 'B': ybase += rct.height() - rows*100; break;
default : break;
}
char halign = _halign;
char valign = 'T';
for (int row = 0; row < rows; row++)
{
TRectangle rctline = rct;
rctline.y = ybase + 100*row;
rctline.set_height(100);
win.log2dev(rctline, r);
const char* line = str.get();
if (halign == 'J' && (row == rows-1 || strlen(line) < columns/2))
halign = 'L';
advanced_draw_text(win, line, r, halign, valign);
}
}
else
advanced_draw_text(win, text, r, _halign, _valign);
}
void TReport_field::draw(TWindow& win, TReport_draw_mode rdm) const
{
if (draw_hidden() || draw_deactivated())
return;
@ -1341,6 +1351,7 @@ void TReport_field::draw(TWindow& win, TReport_draw_mode rdm) const
break;
}
}
*/
bool TReport_field::print_tools(TBook& book) const
{
@ -1400,6 +1411,7 @@ void TReport_field::print(TBook& book) const
{
book.set_font(font());
book.set_text_align(horizontal_alignment(), vertical_alignment());
book.set_text_color(fore_color(), back_color());
book.draw_text(get_draw_rect(), _picture);
}
break;
@ -1411,6 +1423,7 @@ void TReport_field::print(TBook& book) const
{
book.set_font(font());
book.set_text_align(horizontal_alignment(), vertical_alignment());
book.set_text_color(fore_color(), back_color());
book.draw_text(get_draw_rect(), str);
}
}
@ -2088,15 +2101,10 @@ bool TReport::get_record_field(const TString& name, TVariant& var) const
if (_recordset != NULL)
{
const char* str = name;
if (name[0] == '#')
if (name.starts_with("#RECORD."))
{
if (name.starts_with("#RECORD."))
{
str += 8;
found = true;
}
else
str++;
str += 8;
found = true;
}
var = _recordset->get(str);
if (!var.is_null())
@ -2231,11 +2239,34 @@ KEY TReport::run_form(const TString& maskname)
const TFieldref* ref = f.field();
if (ref != NULL)
{
const bool is_final = f.in_group(2);
TString name = ref->name();
if (name[0] != '#')
name.insert("#");
if (get_usr_val(name, var))
f.set(var.as_string());
{
if (is_final)
{
switch (f.class_id())
{
case CLASS_CURRENCY_FIELD:
case CLASS_REAL_FIELD:
if (var.as_real() == 999999999L)
var.set_null();
break;
case CLASS_DATE_FIELD:
if (var.as_date().year() == 9999)
var.set_null();
break;
default:
if (var.as_string() == "~~~")
var.set_null();
break;
}
}
if (!var.is_null())
f.set(var.as_string());
}
}
}
key = m.run();
@ -2252,13 +2283,27 @@ KEY TReport::run_form(const TString& maskname)
const TFieldref* ref = f.field();
if (ref != NULL)
{
const bool is_final = f.in_group(2);
switch (f.class_id())
{
case CLASS_CURRENCY_FIELD:
case CLASS_REAL_FIELD: var = real(f.get()); break;
case CLASS_DATE_FIELD: var = TDate(f.get()); break;
default: var = f.get(); break;
case CLASS_REAL_FIELD:
var = real(f.get());
if (var.is_empty())
var.set(is_final ? 999999999L : 0L);
break;
case CLASS_DATE_FIELD:
var = TDate(f.get());
if (var.is_empty())
var.set(TDate(is_final ? 99991231L : 0L));
break;
default:
var = f.get();
if (var.is_empty())
var.set(is_final ? "~~~" : "");
break;
}
TString name = ref->name();
if (name[0] != '#')
name.insert("#");

View File

@ -302,8 +302,8 @@ public:
void set_height(long dy) { _rct.set_height(dy); }
const TRectangle& get_rect() const { return _rct; }
void set_dynamic_height(bool dh) { _dynamic_height = dh; }
bool dynamic_height() const { return _dynamic_height; }
void set_dynamic_height(bool dh);
bool dynamic_height() const;
bool hidden() const { return _hidden; }
bool shown() const { return !hidden(); }
@ -354,10 +354,10 @@ public:
bool selected() const { return _selected; }
void offset(const TPoint& pt);
virtual void draw_rect(TWindow& win) const;
virtual void draw_text(TWindow& win, const char* text, TReport_draw_mode mode) const;
// virtual void draw_rect(TWindow& win) const;
// virtual void draw_text(TWindow& win, const char* text, TReport_draw_mode mode) const;
virtual void draw(TWindow& win, TReport_draw_mode mode) const;
// virtual void draw(TWindow& win, TReport_draw_mode mode) const;
virtual bool print_tools(TBook& book) const;
virtual void print_rect(TBook& book) const;
@ -408,7 +408,6 @@ class TReport : public TAlex_virtual_machine
TString_array _params;
TRecordset* _recordset;
TReport_expr_cache _expressions;
TReport_image_cache _images;
word _curr_page;
TReport_field* _curr_field;
@ -473,7 +472,6 @@ public:
void set_description(const char* d) { _description = d; }
const TString& description() const { return _description; }
TImage* image(const TString& name) { return _images.image(name); }
const TFilename& filename() const { return _path; }
bool save(const char* fname) const;

View File

@ -520,7 +520,8 @@ void TBook::draw_link(const TRectangle& rect, const char* text, const char* link
void TBook::draw_image(const TRectangle& rect, const char* name)
{
draw_rectangle(rect);
define_frame(rect);
*_out << "<image src=\"" << name << "\" />" << endl;
}
///////////////////////////////////////////////////////////
@ -576,6 +577,8 @@ bool TBook::print_page(TWindow& win, size_t page)
ifstream ifs(_file);
ifs.seekg(pos);
RCT rct;
while (!ifs.eof())
{
ifs.getline(buffer, str.size());
@ -595,7 +598,6 @@ bool TBook::print_page(TWindow& win, size_t page)
}
if (str == "<ellipse/>")
{
RCT rct; win.log2dev(_rect, rct);
xvt_dwin_draw_oval(win.win(), &rct);
continue;
}
@ -604,6 +606,7 @@ bool TBook::print_page(TWindow& win, size_t page)
long x, y, dx, dy;
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
_rect.set(x, y, dx, dy);
win.log2dev(_rect, rct);
continue;
}
if (str.starts_with("<font"))
@ -618,9 +621,15 @@ bool TBook::print_page(TWindow& win, size_t page)
xvt_dwin_set_font(win.win(), font.get_preview_font(win, page_res()));
continue;
}
if (str.starts_with("<image"))
{
TString name; get_xml_string(str, "src", name);
TImage* img = _images.image(name);
if (img != NULL)
img->draw(win.win(), rct);
}
if (str.starts_with("<line/>"))
{
RCT rct; win.log2dev(_rect, rct);
PNT fr = { rct.top, rct.left };
PNT to = { rct.bottom, rct.right };
xvt_dwin_draw_set_pos(win.win(), fr);
@ -645,7 +654,6 @@ bool TBook::print_page(TWindow& win, size_t page)
}
if (str == "<rectangle/>")
{
RCT rct; win.log2dev(_rect, rct);
xvt_dwin_draw_rect(win.win(), &rct);
continue;
}
@ -659,7 +667,6 @@ bool TBook::print_page(TWindow& win, size_t page)
break;
stringona << str;
}
RCT rct; win.log2dev(_rect, rct);
advanced_draw_text(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
continue;
}

View File

@ -18,6 +18,7 @@ class TBook : public TObject
TReport_font _font;
TRectangle _rect;
char _horizontal_alignment, _vertical_alignment;
TReport_image_cache _images;
size_t _pagefrom, _pageto, _copies;