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:
parent
9e191de032
commit
da9d9b0841
@ -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 <stdarg.h>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
TLocalisamfile *fff;
|
||||
|
||||
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtT";
|
||||
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaA";
|
||||
|
||||
// _FieldTok flags
|
||||
|
||||
@ -678,7 +678,7 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
||||
ch = tolower (ch);
|
||||
fill = ' ';
|
||||
}
|
||||
if (ch == 't')
|
||||
if (ch == 't' || ch == 'a')
|
||||
t << 's';
|
||||
else if (ch == 'r')
|
||||
t << 't';
|
||||
@ -716,6 +716,11 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
||||
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 *))));
|
||||
break;
|
||||
case 'r': // Real
|
||||
|
||||
{
|
||||
@ -1133,6 +1138,7 @@ bool TPrint_application::print_one (int file)
|
||||
// printf by reference
|
||||
_PrintfRef *pr = (_PrintfRef *) t;
|
||||
TString ps;
|
||||
TParagraph_string * para_str = NULL;
|
||||
bool islong = (pr->_fmt).find ('l') != -1;
|
||||
switch (pr->_type)
|
||||
{
|
||||
@ -1160,6 +1166,15 @@ bool TPrint_application::print_one (int file)
|
||||
ps.format (pr->_fmt, (const char *)
|
||||
(*((TString *) (pr->_what))));
|
||||
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':
|
||||
{
|
||||
real *rrr = (real *) pr->_what;
|
||||
@ -1182,16 +1197,33 @@ bool TPrint_application::print_one (int file)
|
||||
}
|
||||
|
||||
ps = fill_str (ps, _fillchar);
|
||||
((TPrintrow *) (&rw[pr->row ()]))->
|
||||
put (ps, pos[pr->row ()]);
|
||||
if (pos[pr->row ()] != -1)
|
||||
pos[pr->row ()] += ps.len ();
|
||||
((TPrintrow *) (&rw[pr->row ()]))->put (ps, pos[pr->row ()]);
|
||||
if (para_str != NULL)
|
||||
{
|
||||
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!
|
||||
for (i = 0; i <= _maxrow; i++)
|
||||
// print!
|
||||
const int last = rw.last();
|
||||
|
||||
for (i = 0; i <= /*_maxrow*/ last; i++)
|
||||
{
|
||||
TPrintrow *pr = (TPrintrow *) & rw[i];
|
||||
if (!(printer().print (*pr)))
|
||||
|
@ -249,8 +249,8 @@ public:
|
||||
// la fine della stampa
|
||||
// Quindi, attenzione a %s con TString ridimensionate; si possono
|
||||
// usare solo se predimensionate alla dimensione massima, ma e' meglio
|
||||
// usare char* o il codice apposito. I codici #r e #t prendono puntatori a
|
||||
// real e a TString, memorizzandoli. Non ci sono problemi con la resize.
|
||||
// usare char* o il codice apposito. I codici #r, #a e #t prendono puntatori a
|
||||
// real, TParagraph_string e a TString, memorizzandoli. Non ci sono problemi con la resize.
|
||||
// Comunque, il modo corretto di adoperare il codice # e'
|
||||
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
|
||||
// ----------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user