Aggiunta possibilita'di stampare TParagraph_string per reference

git-svn-id: svn://10.65.10.50/trunk@1243 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1995-04-12 15:44:45 +00:00
parent 9e191de032
commit da9d9b0841
2 changed files with 43 additions and 11 deletions

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.19 1995-03-22 09:06:11 guy Exp $ // $Id: printapp.cpp,v 1.20 1995-04-12 15:44:43 alex Exp $
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -12,7 +12,7 @@
TLocalisamfile *fff; TLocalisamfile *fff;
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtT"; const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaA";
// _FieldTok flags // _FieldTok flags
@ -678,7 +678,7 @@ void TPrint_application::set_row (int r, const char *frmt,...)
ch = tolower (ch); ch = tolower (ch);
fill = ' '; fill = ' ';
} }
if (ch == 't') if (ch == 't' || ch == 'a')
t << 's'; t << 's';
else if (ch == 'r') else if (ch == 'r')
t << 't'; t << 't';
@ -716,6 +716,11 @@ void TPrint_application::set_row (int r, const char *frmt,...)
q.format (t, (const char *) q.format (t, (const char *)
(TString) * ((va_arg (params, TString *)))); (TString) * ((va_arg (params, TString *))));
break; break;
case 'a': // TParagraph_string
q.format (t, (const char *)
(TParagraph_string) * ((va_arg (params, TParagraph_string *))));
break;
case 'r': // Real case 'r': // Real
{ {
@ -1133,6 +1138,7 @@ bool TPrint_application::print_one (int file)
// printf by reference // printf by reference
_PrintfRef *pr = (_PrintfRef *) t; _PrintfRef *pr = (_PrintfRef *) t;
TString ps; TString ps;
TParagraph_string * para_str = NULL;
bool islong = (pr->_fmt).find ('l') != -1; bool islong = (pr->_fmt).find ('l') != -1;
switch (pr->_type) switch (pr->_type)
{ {
@ -1160,6 +1166,15 @@ bool TPrint_application::print_one (int file)
ps.format (pr->_fmt, (const char *) ps.format (pr->_fmt, (const char *)
(*((TString *) (pr->_what)))); (*((TString *) (pr->_what))));
break; break;
case 'a':
{
para_str = ((TParagraph_string *) (pr->_what));
const char * s = para_str->get();
if (s != NULL)
ps.format (pr->_fmt, s);
break;
}
case 'r': case 'r':
{ {
real *rrr = (real *) pr->_what; real *rrr = (real *) pr->_what;
@ -1182,16 +1197,33 @@ bool TPrint_application::print_one (int file)
} }
ps = fill_str (ps, _fillchar); ps = fill_str (ps, _fillchar);
((TPrintrow *) (&rw[pr->row ()]))-> ((TPrintrow *) (&rw[pr->row ()]))->put (ps, pos[pr->row ()]);
put (ps, pos[pr->row ()]); if (para_str != NULL)
if (pos[pr->row ()] != -1) {
pos[pr->row ()] += ps.len (); const char * s = para_str->get();
int row = pr->row();
while (s != NULL)
{
ps.format (pr->_fmt, s);
ps = fill_str (ps, _fillchar);
row++;
if (rw.objptr(row) == NULL)
rw.add(new TPrintrow ());
((TPrintrow *) (&rw[row]))->put(ps, pos[pr->row()]);
s = para_str->get();
}
if (pos[pr->row ()] != -1)
pos[pr->row ()] += ps.len ();
}
} }
} }
} }
// print! // print!
for (i = 0; i <= _maxrow; i++) const int last = rw.last();
for (i = 0; i <= /*_maxrow*/ last; i++)
{ {
TPrintrow *pr = (TPrintrow *) & rw[i]; TPrintrow *pr = (TPrintrow *) & rw[i];
if (!(printer().print (*pr))) if (!(printer().print (*pr)))

View File

@ -249,8 +249,8 @@ public:
// la fine della stampa // la fine della stampa
// Quindi, attenzione a %s con TString ridimensionate; si possono // Quindi, attenzione a %s con TString ridimensionate; si possono
// usare solo se predimensionate alla dimensione massima, ma e' meglio // usare solo se predimensionate alla dimensione massima, ma e' meglio
// usare char* o il codice apposito. I codici #r e #t prendono puntatori a // usare char* o il codice apposito. I codici #r, #a e #t prendono puntatori a
// real e a TString, memorizzandoli. Non ci sono problemi con la resize. // real, TParagraph_string e a TString, memorizzandoli. Non ci sono problemi con la resize.
// Comunque, il modo corretto di adoperare il codice # e' // Comunque, il modo corretto di adoperare il codice # e'
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application // usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
// ---------------------------------------------- // ----------------------------------------------