Aggiunto set_row con printrow

git-svn-id: svn://10.65.10.50/trunk@2751 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1996-04-18 09:33:27 +00:00
parent f9bb573d44
commit 239ebd45e8
2 changed files with 488 additions and 505 deletions

View File

@ -56,28 +56,16 @@ class _Transfield:public TObject
}
};
class _Token:public TObject
class _Token : public TObject
{
friend class TPrint_application;
int _tag;
int _row;
public:
int tag ()
{
return _tag;
}
int row ()
{
return _row;
}
void tag (int t)
{
_tag = t;
}
void row (int r)
{
_row = r;
}
int tag() const { return _tag; }
int row() const { return _row; }
void tag(int t) { _tag = t; }
void row (int r) { _row = r; }
virtual ~ _Token () {}
};
@ -86,14 +74,10 @@ class _PrintfTok : public _Token
{
friend class TPrint_application;
TString _val;
public:
_PrintfTok (int rw, const char *val):_val (0)
{
tag (0);
row (rw);
_val = val;
}
virtual ~ _PrintfTok () {}
public:
_PrintfTok (int rw, const char *val) : _val(val)
{ tag(0); row(rw); }
virtual ~_PrintfTok () {}
};
class _FieldTok : public _Token
@ -111,8 +95,8 @@ class _FieldTok : public _Token
int size = -1, int dec = -1):
_fld (20)
{
tag (1);
row (rw);
tag(1);
row(rw);
_fld = (const char *) fld;
_flags = flags;
_size = size, _align = align;
@ -142,11 +126,23 @@ class _PrintfRef : public _Token
_fmt = fmt;
_fmt[0] = '%';
}
virtual ~ _PrintfRef ()
{
}
virtual ~ _PrintfRef () {}
};
class _PrintRowToken : public _Token
// printrow direct
// must pass valid printrow (duplicated)
{
friend class TPrint_application;
TPrintrow _pr;
public:
TPrintrow& printrow() { return _pr; }
_PrintRowToken (int rw, TPrintrow& pr) : _pr((const TPrintrow&)pr)
{ tag(3); row(rw); }
virtual ~ _PrintRowToken () {}
};
void TPrint_application::_reset_tree(link_item * head)
{
if (head)
@ -204,7 +200,7 @@ int TPrint_application::set_bookmark(
void TPrint_application::add_file (const char *tab, int from)
{
add_file(TTable::name2log (tab), from);
add_file(TTable::name2log(tab), from);
}
// @doc EXTERNAL
@ -432,19 +428,11 @@ const char* FLD (const char *tabname, const char *f, const char *picture)
TString& fill_str (TString & t, char f)
{
for (int kk = t.len () - 1; kk >= 0; kk--)
{
if (t[kk] == ' ')
t[kk] = f;
else
break;
}
if (t[kk] == ' ') t[kk] = f;
else break;
for (kk = 0; kk < t.len (); kk++)
{
if (t[kk] == ' ')
t[kk] = f;
else
break;
}
if (t[kk] == ' ') t[kk] = f;
else break;
return t;
}
@ -452,25 +440,16 @@ TString& fill_str (TString & t, char f)
// Printapp code at last
// ========================================================
//void TPrint_application::enable_link(const char* descr, char fg, char bg)
// {
// printer().setlinkdescr(descr);
// }
void TPrint_application::select_cursor (int c)
{
if (c == -1)
_cur = NULL;
else
_cur = (TCursor *) & _cursors[c];
if (c == -1) _cur = NULL;
else _cur = (TCursor *) & _cursors[c];
}
TCursor* TPrint_application::get_cursor (int c)
{
if (c == -1)
return NULL;
else
return (TCursor *) & _cursors[c];
if (c == -1) return NULL;
else return (TCursor *) & _cursors[c];
}
// @doc EXTERNAL
@ -490,7 +469,7 @@ int TPrint_application::add_cursor (
return -1;
_cursors.add (c);
_cur = c;
return _cursors.items () - 1;
return _cursors.items() - 1;
}
void TPrint_application::reset_row (int r)
@ -599,6 +578,17 @@ void TPrint_application::merge_export_file(const char* file, bool header, bool d
}
}
void TPrint_application::set_row(int r, TPrintrow& pr)
{
CHECK (r >= 1, "Print rows start at 1");
_print_defined = TRUE;
_currow = --r;
if (_currow > _maxrow)
_maxrow = _currow;
_rows.add(new _PrintRowToken(_currow, pr));
}
// @doc EXTERNAL
// @mfunc Permette di settare una riga di stampa
@ -719,7 +709,7 @@ void TPrint_application::set_row (
_maxrow = _currow;
va_list params;
va_start (params, frmt);
va_start(params, frmt);
// parse format string
while ((ch = *fmt++) != '\0')
@ -753,7 +743,6 @@ void TPrint_application::set_row (
digbuf[i] = '\0';
dec = atoi (digbuf);
flags |= DEC_FLAG;
// ch = *fmt++;
}
else if (ch == ',')
{
@ -807,31 +796,37 @@ void TPrint_application::set_row (
break;
case 'T':
flags |= IGNORE_FILL;
// fall down
case 't':
flags |= TRANS_FLAG;
break;
case 'D':
flags |= IGNORE_FILL;
// fall down
case 'd':
flags |= DATE_FLAG;
break;
case 'F':
flags |= IGNORE_FILL;
// fall down
case 'f':
flags |= BOOLEAN_FLAG;
break;
case 'S':
flags |= IGNORE_FILL;
// fall down
case 's':
flags |= STRING_FLAG;
break;
case 'C':
flags |= IGNORE_FILL;
// fall down
case 'c':
flags |= RECNO_FLAG;
break;
case 'N':
flags |= IGNORE_FILL;
// fall down
case 'n':
flags |= NUMBER_FLAG;
break;
@ -846,8 +841,7 @@ void TPrint_application::set_row (
flags & STRING_FLAG)
{
char *xxx = va_arg (params, char *);
_rows.add (new _FieldTok (_currow, xxx,
flags, align, size, dec));
_rows.add (new _FieldTok (_currow, xxx, flags, align, size, dec));
}
flags = 0x0000;
align = 'l';
@ -882,8 +876,7 @@ void TPrint_application::set_row (
islong = TRUE;
ch = *fmt++;
if (ch == '\0')
fatal_box ("sorry, zer's samzing vruong"
" uitz ioar format.");
fatal_box ("sorry, zer's samzing vruong uitz ioar format.");
}
if (isupper (ch))
{
@ -911,15 +904,13 @@ void TPrint_application::set_row (
case 'o':
case 'x':
case 'X':
q.format (t, islong ? va_arg (params, long) :
va_arg (params, int));
q.format (t, islong ? va_arg (params, long) : va_arg (params, int));
break;
case 'f':
case 'e':
case 'E':
case 'G':
q.format (t, islong ? va_arg (params, double) :
va_arg (params, float));
q.format (t, islong ? va_arg (params, double) : va_arg (params, float));
break;
case 'c':
q.format (t, va_arg (params, char));
@ -928,17 +919,12 @@ void TPrint_application::set_row (
q.format (t, va_arg (params, char *));
break;
case 't': // TString
q.format (t, (const char *)
(TString) * ((va_arg (params, TString *))));
q.format(t,(const char*)(TString)*((va_arg (params, TString*))));
break;
case 'a': // TParagraph_string
q.format (t, (const char *)
(TParagraph_string) * ((va_arg (params, TParagraph_string *))));
q.format(t,(const char*)(TParagraph_string)*((va_arg (params, TParagraph_string*))));
break;
case 'r': // Real
{
const real& rrr = * va_arg (params, real *);
if (t.len () == 2 && *_picture)
@ -970,8 +956,7 @@ void TPrint_application::set_row (
_rows.add (new _PrintfTok (_currow, q));
}
else
_rows.add (new _PrintfRef (_currow, t, ch,
va_arg (params, void *)));
_rows.add (new _PrintfRef (_currow, t, ch, va_arg (params, void *)));
}
}
break;
@ -989,7 +974,7 @@ void TPrint_application::set_row (
if (strind)
{
strbuf[strind] = '\0';
_rows.add (new _PrintfTok (_currow, strbuf));
_rows.add(new _PrintfTok (_currow, strbuf));
strind = 0;
}
va_end (params);
@ -1038,16 +1023,13 @@ void TPrint_application::print()
//************************************************
while (nc--)
{
int cnt = 0;
bool ok = TRUE;
do
{
do {
if (preprocess_print (0, cnt))
{
int cnt2 = 0;
do
{
do {
if (preprocess_page (0, cnt2))
{
set_page (0, cnt2);
@ -1168,12 +1150,12 @@ bool TPrint_application::print_one (
if (_prind && file == _pr_tree->_logicnum)
_prind->addstatus (1);
TArray rw (_maxrow + 1);
TArray rw(_maxrow + 1);
int *pos = new int[_maxrow + 1];
for (i = 0; i <= _maxrow; i++)
{
rw.add (new TPrintrow ());
rw.add(new TPrintrow());
pos[i] = -1;
}
@ -1181,16 +1163,20 @@ bool TPrint_application::print_one (
for (i = 0; i <= _maxrow; i++)
for (int j = 0; j < _rows.items (); j++)
{
_Token *t = (_Token *) & (_rows[j]);
if (!t)
continue; // should not happen
_Token* t = (_Token*)&(_rows[j]);
if (!t) continue; // should not happen
if (t->row () == i)
if (t->row() == i)
{
char pic[36], fn[17];
int ch, ln, from, to;
if (t->tag () == 1)
if (t->tag() == 3)
{
_PrintRowToken* r = (_PrintRowToken*)t;
rw.add(r->printrow(), r->row());
}
else if (t->tag () == 1)
{
// it's a _FieldTok
_FieldTok *ft = (_FieldTok *) t;
@ -1215,7 +1201,7 @@ bool TPrint_application::print_one (
st = normalstyle;
break;
}
((TPrintrow *) (&rw[ft->row ()]))->set_style (st);
((TPrintrow *)(&rw[ft->row()]))->set_style (st);
}
else if (ft->_flags & JUMP_FLAG)
{
@ -1230,8 +1216,7 @@ bool TPrint_application::print_one (
else
// jump ahead
pos[ft->row ()] =
((TPrintrow *) (&rw[ft->row ()]))->
lastpos () + p;
((TPrintrow *) (&rw[ft->row ()]))->lastpos () + p;
}
else
{
@ -1280,9 +1265,7 @@ bool TPrint_application::print_one (
toprint = d.string (ft->_flags & LONG_FLAG ? full : brief);
if (toprint.empty ())
{
toprint = (ft->_flags & LONG_FLAG ?
" - - " :
" - - ");
toprint = (ft->_flags & LONG_FLAG ? " - - " : " - - ");
}
}
else if (ft->_flags & BOOLEAN_FLAG)
@ -1298,8 +1281,7 @@ bool TPrint_application::print_one (
if (ft->_flags & PICTURE_FLAG)
pict = pic;
else if (!(ft->_flags & DEC_FLAG) && *_picture
&& isreal)
else if (!(ft->_flags & DEC_FLAG) && *_picture && isreal)
pict = _picture;
if (pict.len () > 0)
@ -1345,12 +1327,10 @@ bool TPrint_application::print_one (
if (_fillchar != ' ' && !(ft->_flags & IGNORE_FILL))
toprint = fill_str (toprint, _fillchar);
// add to print row
((TPrintrow *) (&rw[ft->row ()]))->put (toprint,
pos[ft->row ()]);
if (pos[ft->row ()] != -1)
((TPrintrow *)(&rw[ft->row()]))->put (toprint, pos[ft->row ()]);
if (pos[ft->row()] != -1)
pos[ft->row ()] += toprint.len ();
}
else if (t->tag () == 0)
{
// it's a _PrintfTok

View File

@ -296,6 +296,9 @@ public:
// @cmember Permette di settare una riga di stampa
void set_row(int r, const char* fmt, ...);
// @cmember Setta riga di stampa usando una printrow gia' fatta
void set_row(int r, TPrintrow& pr);
// @cmember Setta i valori di traduzione per campi
void set_translation(int lognum, const char* field, const char* from, const char* to);