Rif. mod. 95/53 :

printapp.cpp : correzione alla stampa in stile di  una TParagraph_string
relation.cpp : spostata l'allocazione di _sort dal costruttore dei
			   TSorted_cursor alla build_cursor().
strings.h    :
strings.cpp  : aggiunto metodo TString::strip_spaces() per togliere
			   da una stringa eventuali spazi doppi o ripetuti.


git-svn-id: svn://10.65.10.50/trunk@2226 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1995-12-01 16:58:35 +00:00
parent 94be0ac694
commit 1b3a761cd8
4 changed files with 34 additions and 9 deletions

View File

@ -1424,6 +1424,7 @@ bool TPrint_application::print_one (
{
const char * s = para_str->get();
int row = pr->row();
TPrintstyle xstyle = ((TPrintrow *)(&rw[row]))->get_style();
while (s != NULL)
{
@ -1432,9 +1433,11 @@ bool TPrint_application::print_one (
row++;
if (rw.objptr(row) == NULL)
rw.add(new TPrintrow ());
((TPrintrow *) (&rw[row]))->put(ps, pos[pr->row()]);
((TPrintrow *) (&rw[row]))->set_style(xstyle);
((TPrintrow *) (&rw[row]))->put(ps, pos[pr->row()]);
s = para_str->get();
}
}
((TPrintrow *) (&rw[row]))->set_style(normalstyle);
}
if (pos[pr->row ()] != -1)
pos[pr->row ()] += ps.len ();

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.71 1995-11-27 08:39:02 guy Exp $
// $Id: relation.cpp,v 1.72 1995-12-01 16:58:28 angelo Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -1142,7 +1142,6 @@ TRecnotype TCursor::operator +=(const TRecnotype npos)
return _pos;
}
TRecnotype TCursor::items()
{
if (changed())
@ -1230,6 +1229,7 @@ TRecnotype TSorted_cursor::buildcursor(TRecnotype rp)
TString s;
El_To_Sort * Element;
_sort = new TSort(sizeof(El_To_Sort));
_order_expr.restart();
while ((s=_order_expr.get()).not_empty())
{
@ -1240,8 +1240,9 @@ TRecnotype TSorted_cursor::buildcursor(TRecnotype rp)
s.cut(s.len()-1);
TFieldref f(s,0);
// Il controllo del file e' automatico in f.len()
_sort->addsortkey(abspos+f.from(),f.len(relation()->curr()),versus);
CHECKS(f.len(relation()->curr())!=0,"Field can not have null length: ",(const char *) s);
int flen = f.len(relation()->curr());
_sort->addsortkey(abspos+f.from(),flen,versus);
CHECKS(flen!=0,"Field can not have null length: ",(const char *) s);
int lf = (f.file()!=0 ? f.file() : file().num());
TRectype r(lf);
abspos+=r.length(f.name());
@ -1321,6 +1322,7 @@ TRecnotype TSorted_cursor::buildcursor(TRecnotype rp)
fwrite(page,sizeof(TRecnotype),pagecnt,_f);
if (TCursor::pos() == -1) pos=0;
delete page;
if (_sort) delete _sort;
fclose (_f);
return ap;
}
@ -1356,7 +1358,7 @@ int TSorted_cursor::filtercursor(int pagecnt, TRecnotype* page)
s.cut(s.len()-1);
TFieldref f(s,0);
TString sf=f.read(relation());
TFieldtypes fld_type = file(f.file()).curr().type(s);
TFieldtypes fld_type = file(f.file()).curr().type(f.name());
if (fld_type == _datefld) // Se il campo e' di tipo data, la converte in ANSI!
{
TDate d(sf);
@ -1413,12 +1415,10 @@ TSorted_cursor::TSorted_cursor(TRelation *f, const char * order_expr, const char
: TCursor(f,filter,key,from,to)
{
change_order(order_expr);
_sort = new TSort(sizeof(El_To_Sort));
}
TSorted_cursor::~TSorted_cursor()
{
if (_sort) delete _sort;
}

View File

@ -238,6 +238,26 @@ TString& TString::strip_spaces()
return *this;
}
TString& TString::strip_d_spaces()
{
int j = 0;
bool spc = FALSE;
for (int i = 0; _str[i]; i++)
{
char c = _str[i];
if (is_space(c))
if (spc)
continue;
else
spc = TRUE;
else
if (spc) spc = FALSE;
_str[j++] = c;
}
_str[j] = '\0';
return *this;
}
// Certified 100%
const char* TString::class_name() const
{ return "String"; }

View File

@ -133,6 +133,8 @@ public:
TString& strip(const char* k);
// @cmember Elimina tutti gli spazi non contenuti tra apici singoli o doppi
TString& strip_spaces();
// @cmember Elimina tutti gli spazi doppi
TString& strip_d_spaces();
// @cmember Elimina gli spazi da sinistra o i primi n caratteri (da sinistra).
TString& ltrim(int n = 0);
// @cmember Elimina gli spazi da destra o i primi n caratteri (da destra).