Correzioni a stampe e tabelle

git-svn-id: svn://10.65.10.50/trunk@1366 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1995-05-16 13:42:37 +00:00
parent e1b4b71491
commit b62750d4a9
5 changed files with 81 additions and 68 deletions

View File

@ -177,7 +177,7 @@ int TArray::add(
// @xref <mf TArray::insert> // @xref <mf TArray::insert>
{ {
if (index < 0) for (index = 0; index < size() && _data[index]; index++); if (index < 0) for (index = 0; index < size() && _data[index]; index++);
if (index >= size()) resize(3*index/2 + 1); if (index >= size()) resize(int(3L*index/2) + 1);
if (_data[index] != NULL) if (_data[index] != NULL)
{ {

View File

@ -1372,6 +1372,7 @@ bool TPrinter::open()
{ {
// prepare text object for new text // prepare text object for new text
_txt.destroy(); _txt.destroy();
_txt.interactive(FALSE);
} }
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
else else

View File

@ -40,10 +40,11 @@ int TTable::last(word lockop)
{ {
zero(); zero();
put("CODTAB", "\0xFF"); put("CODTAB", "\377");
TBaseisamfile::read(_isgteq); TBaseisamfile::read(_isgteq);
if (!eof()) TBaseisamfile::prev(lockop); if (!eof()) TBaseisamfile::prev(lockop);
else setstatus(NOERR); else setstatus(NOERR);
if (bof()) setstatus(NOERR);
if (good()) if (good())
if (_tabname != (const char *)_cod) setstatus(_isemptyfile); if (_tabname != (const char *)_cod) setstatus(_isemptyfile);
if (bad()) zero(); if (bad()) zero();

View File

@ -154,6 +154,8 @@ void TTextfile::_read_page (long n)
TEXT_TMP[strlen (TEXT_TMP) - 1] = '\0'; TEXT_TMP[strlen (TEXT_TMP) - 1] = '\0';
TString & ts = (TString &) _page[(int) (i - _page_start)]; TString & ts = (TString &) _page[(int) (i - _page_start)];
ts = TEXT_TMP; ts = TEXT_TMP;
if (_interactive)
{
TString hcol (6); TString hcol (6);
// find hotspots and compile list // find hotspots and compile list
@ -182,6 +184,7 @@ void TTextfile::_read_page (long n)
} }
} }
} }
}
void TTextfile::read_line (long n, long pos, bool pg) void TTextfile::read_line (long n, long pos, bool pg)
{ {
@ -449,9 +452,11 @@ bool TTextfile::append (const char *l)
_dirty = TRUE; _dirty = TRUE;
if ((_lines) < (_page_start + _page_size)) if ((_lines) < (_page_start + _page_size))
{
if (_interactive)
{ {
TString *ll = new TString (l); TString *ll = new TString (l);
_page.add (ll); _page.add (ll, _lines - _page_start - 1);
_page_end++; _page_end++;
int len = 0; int len = 0;
@ -478,6 +483,7 @@ bool TTextfile::append (const char *l)
} }
len += strlen (cp); len += strlen (cp);
} }
}
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -558,16 +564,17 @@ void TTextfile::destroy ()
freeze (); freeze ();
} }
_isopen = TRUE; _isopen = TRUE;
_page.destroy (); // _page.destroy ();
_spots.destroy (); _spots.destroy ();
} }
} }
TTextfile ::TTextfile (const char *file, int pagesize, direction preferred): TTextfile ::TTextfile (const char *file, int pagesize, direction preferred,
bool interactive):
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l), _page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred), _index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1), _dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
_hotspots (4), _accept (TRUE), _dirty_lines(pagesize) _hotspots (4), _accept (TRUE), _dirty_lines(pagesize), _interactive(interactive)
{ {
// open file & build index // open file & build index
if (file == NULL || *file <= ' ') if (file == NULL || *file <= ' ')
@ -575,6 +582,8 @@ _hotspots (4), _accept (TRUE), _dirty_lines(pagesize)
_filename.temp("txtf"); _filename.temp("txtf");
_istemp = TRUE; _istemp = TRUE;
} }
for (int i = 0; i < pagesize; i++)
_page.add(new TString(132));
_isopen = TRUE; _isopen = TRUE;
_instr = fopen (_filename, "a+"); _instr = fopen (_filename, "a+");
@ -598,16 +607,16 @@ _hotspots (4), _accept (TRUE), _dirty_lines(pagesize)
} }
if (fgets (TEXT_TMP, sizeof (TEXT_TMP), _instr) == NULL) if (fgets (TEXT_TMP, sizeof (TEXT_TMP), _instr) == NULL)
break; break;
if (TEXT_TMP[strlen(TEXT_TMP)-1] == '\n') // if (TEXT_TMP[strlen(TEXT_TMP)-1] == '\n')
TEXT_TMP[strlen(TEXT_TMP)-1] = '\0'; // TEXT_TMP[strlen(TEXT_TMP)-1] = '\0';
if ((_lines) < (_page_start + _page_size)) // if ((_lines) < (_page_start + _page_size))
{ // {
TString *ll = new TString (TEXT_TMP); // TString *ll = new TString (TEXT_TMP);
_page.add(ll); // _page.add(ll);
_page_end++; // _page_end++;
// TBI process links // TBI process links
} // }
_lines++; _lines++;
} }
} }

View File

@ -47,6 +47,7 @@ class TTextfile: public TObject
bool _isopen; bool _isopen;
bool _istemp; bool _istemp;
bool _accept; bool _accept;
bool _interactive;
void _read_page(long line); void _read_page(long line);
bool _in_page(long l) bool _in_page(long l)
@ -100,6 +101,7 @@ public:
// allochera' un altro TText che deve essere disfatto dall'utente // allochera' un altro TText che deve essere disfatto dall'utente
TTextfile* section(TPoint& from, TPoint& to) { return this; } TTextfile* section(TPoint& from, TPoint& to) { return this; }
const char* name() { return (const char*)_filename; } const char* name() { return (const char*)_filename; }
void interactive(bool on = TRUE) { _interactive = on; }
// scrive il testo (non formattato) su file, da punto a punto // scrive il testo (non formattato) su file, da punto a punto
// (tutto per default) // (tutto per default)
@ -123,7 +125,7 @@ public:
TArray& hotspots() { return _spots; } TArray& hotspots() { return _spots; }
TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE, TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE,
direction preferred = updown); direction preferred = updown, bool interactive = TRUE);
virtual ~TTextfile(); virtual ~TTextfile();
}; };