Estesa gestione form e descrizione relazioni
git-svn-id: svn://10.65.10.50/trunk@1404 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									e945ac1a8d
								
							
						
					
					
						commit
						2a1027fb60
					
				@ -33,14 +33,14 @@ SUBMENU MENU_VISWIN "~Visualizzazione"
 | 
			
		||||
SUBMENU M_EDIT  "~Edit"
 | 
			
		||||
 | 
			
		||||
MENU MENU_VISWIN
 | 
			
		||||
ITEM M_EDIT_CLIPBOARD  "Interrompi\tESC"
 | 
			
		||||
ITEM M_EDIT_CUT   "~Collega...\tCtrl+C"  DISABLED
 | 
			
		||||
ITEM M_EDIT_PASTE   "~Esporta...\tCtrl+E"
 | 
			
		||||
ITEM M_EDIT_SEL_ALL "~Stampa... \tCtrl+S"  DISABLED
 | 
			
		||||
ITEM M_EDIT_CLIPBOARD "Interrompi\tESC"
 | 
			
		||||
ITEM M_EDIT_CUT       "~Collega...\tCtrl+C"  DISABLED
 | 
			
		||||
ITEM M_EDIT_PASTE     "~Esporta...\tCtrl+E"
 | 
			
		||||
ITEM M_EDIT_SEL_ALL   "~Stampa... \tCtrl+S"  DISABLED
 | 
			
		||||
SEPARATOR
 | 
			
		||||
ITEM M_FONT   "Mostra ~righelli" CHECKABLE
 | 
			
		||||
ITEM M_STYLE  "Mostra ~bottoni"  CHECKABLE
 | 
			
		||||
ITEM M_EDIT_UNDO  "Ri~disegna"
 | 
			
		||||
ITEM M_SHOW_RULERS   "Mostra ~righelli" CHECKABLE
 | 
			
		||||
ITEM M_SHOW_BUTTONS  "Mostra ~bottoni"  CHECKABLE
 | 
			
		||||
ITEM M_EDIT_UNDO     "Ri~disegna"
 | 
			
		||||
SEPARATOR
 | 
			
		||||
ITEM M_EDIT_QUIT  "Chiudi\tESC+ESC" 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -76,7 +76,11 @@ int TExternal_app::run(
 | 
			
		||||
      if (!async)
 | 
			
		||||
      {                            
 | 
			
		||||
        TTemp_window tw(TASK_WIN);
 | 
			
		||||
        if (utente) tw.iconize();
 | 
			
		||||
        if (utente) 
 | 
			
		||||
        {
 | 
			
		||||
          tw.iconize();
 | 
			
		||||
          tw.deactivate();
 | 
			
		||||
        }  
 | 
			
		||||
        
 | 
			
		||||
        HTASK child = NULL;
 | 
			
		||||
        TASKENTRY te; te.dwSize = sizeof(TASKENTRY); 
 | 
			
		||||
@ -97,7 +101,11 @@ int TExternal_app::run(
 | 
			
		||||
          xvt_app_process_pending_events();
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (utente) tw.maximize();
 | 
			
		||||
        if (utente) 
 | 
			
		||||
        {
 | 
			
		||||
          tw.maximize();
 | 
			
		||||
          tw.activate();
 | 
			
		||||
        }  
 | 
			
		||||
      }
 | 
			
		||||
      xvt_statbar_refresh();
 | 
			
		||||
    }  
 | 
			
		||||
 | 
			
		||||
@ -107,37 +107,31 @@ TDir::TDir () : _num(-1), _com(FALSE)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TDir::~TDir ()
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  delete _dir;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *TDir::name () const
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  return _dir->SysName;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *TDir::des () const
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  return _dir->Des;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *TDir::tab_des (const char* tab) const
 | 
			
		||||
const char* TDir::tab_des(const char* tab)
 | 
			
		||||
{                                         
 | 
			
		||||
  CHECK (_num > 3 && _num < 7, "Non e' una tabella! Cojon!");  
 | 
			
		||||
  const char* t = tab; if (t[0] == '$' || t[0] == '%') t++;
 | 
			
		||||
 | 
			
		||||
  TString dfile(36);             
 | 
			
		||||
  int ind = (tab[0] == '$' || tab[0] == '%') ? 1 : 0;
 | 
			
		||||
  dfile << DESCDIR << "/d" << tab+ind << ".des";  
 | 
			
		||||
  if (!fexist(dfile))
 | 
			
		||||
    return "";
 | 
			
		||||
  TString256 tmp;          
 | 
			
		||||
  tmp << DESCDIR << "/d" << t << ".des";  
 | 
			
		||||
  
 | 
			
		||||
  TConfig cnf(dfile, DESCTAB);
 | 
			
		||||
  dfile = cnf.get("Description");
 | 
			
		||||
  TConfig cnf(tmp, DESCTAB);
 | 
			
		||||
  t = cnf.get("Description", NULL, -1, tab);
 | 
			
		||||
  
 | 
			
		||||
  return strcpy(__tmp_string, dfile);
 | 
			
		||||
  return strcpy(__tmp_string, t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -75,7 +75,6 @@ public:
 | 
			
		||||
 | 
			
		||||
  const char* name() const;
 | 
			
		||||
  const char* des() const;
 | 
			
		||||
  const char* tab_des(const char* tabname) const;
 | 
			
		||||
  const char* expr() const;
 | 
			
		||||
  TRecnotype& eod() const;
 | 
			
		||||
  TRecnotype& eox() const;
 | 
			
		||||
@ -90,6 +89,8 @@ public:
 | 
			
		||||
  bool is_valid() {return name()[0] > ' ' && len() > 0;}
 | 
			
		||||
  bool is_active() const;             // valido solo se prefhnd e settato a ""
 | 
			
		||||
 | 
			
		||||
  static const char* tab_des(const char* tabname);
 | 
			
		||||
 | 
			
		||||
  TDir();
 | 
			
		||||
  virtual ~TDir();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										780
									
								
								include/form.cpp
									
									
									
									
									
								
							
							
						
						
									
										780
									
								
								include/form.cpp
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,12 +1,17 @@
 | 
			
		||||
#ifndef __FORM_H
 | 
			
		||||
#define __FORM_H
 | 
			
		||||
 | 
			
		||||
#ifndef __STRINGS_H
 | 
			
		||||
#include <strings.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __PRINTER_H
 | 
			
		||||
#include <printer.h>
 | 
			
		||||
class TPrinter;
 | 
			
		||||
class TPrintrow;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __SCANNER_H
 | 
			
		||||
#include <scanner.h>
 | 
			
		||||
class TScanner;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __MASK_H
 | 
			
		||||
@ -14,7 +19,7 @@ class TMask;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __ISAM_H
 | 
			
		||||
#include <isam.h>
 | 
			
		||||
class TRectype;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __RELATION_H
 | 
			
		||||
@ -28,12 +33,14 @@ enum pagetype { odd_page, even_page, first_page, last_page };
 | 
			
		||||
class TForm;
 | 
			
		||||
class TForm_item;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TPrint_section : public TArray
 | 
			
		||||
{
 | 
			
		||||
  static TMask* _msk;
 | 
			
		||||
 | 
			
		||||
  word _height;           // Altezza della sezione
 | 
			
		||||
  int _x, _y;             // Offset di stampa   
 | 
			
		||||
  bool _dirty;            // Flag di modifica parametri
 | 
			
		||||
 | 
			
		||||
  TForm* _form;           // Form cui appartiene alla sezione
 | 
			
		||||
  pagetype _page_type;    // Tipo della pagina
 | 
			
		||||
@ -66,9 +73,15 @@ public:
 | 
			
		||||
  virtual bool update();
 | 
			
		||||
  bool parse(TScanner& scanner);
 | 
			
		||||
  
 | 
			
		||||
  bool edit(const char* title, bool all);
 | 
			
		||||
  bool read_from(const TRectype& rec);
 | 
			
		||||
  void print_on(TRectype& rec);
 | 
			
		||||
 | 
			
		||||
  bool edit(const char* title);
 | 
			
		||||
  pagetype page_type() const { return _page_type; }
 | 
			
		||||
  
 | 
			
		||||
  bool dirty() const { return _dirty; }
 | 
			
		||||
  void set_dirty(bool d = TRUE) { _dirty = d; }
 | 
			
		||||
  
 | 
			
		||||
  const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
 | 
			
		||||
  TPrint_section(TForm* parent, pagetype pt);
 | 
			
		||||
  TPrint_section(const TPrint_section& ps) { copy(ps); }
 | 
			
		||||
@ -80,27 +93,24 @@ class TForm : public TObject
 | 
			
		||||
{                    
 | 
			
		||||
  friend class TForm_editor;
 | 
			
		||||
 | 
			
		||||
  TFilename _name;        // Profile name                     
 | 
			
		||||
  TString16 _code;        // Profile code                    
 | 
			
		||||
  
 | 
			
		||||
  TLocalisamfile _forms;  // forms names file
 | 
			
		||||
  TLocalisamfile _prof;   // profile definition file
 | 
			
		||||
  TString16 _name;        // Profile name                     
 | 
			
		||||
  long      _code;        // Profile code                    
 | 
			
		||||
  
 | 
			
		||||
  TRelation* _relation;   // Can be NULL
 | 
			
		||||
  TCursor* _cursor;       // Can be NULL
 | 
			
		||||
  TRelation_description* _reldef; // pure
 | 
			
		||||
  TRelation_description* _rel_desc; // Can be NULL
 | 
			
		||||
 | 
			
		||||
  TArray _head;           // Headers
 | 
			
		||||
  TArray _body;           // Bodies
 | 
			
		||||
  TArray _foot;           // Footers
 | 
			
		||||
  TArray _back;           // Graphic background
 | 
			
		||||
  TArray _back;           // Graphic backgrounds
 | 
			
		||||
 | 
			
		||||
  char    _permissions[9]; // user permissions
 | 
			
		||||
  bool    _lastpage;       // I am about to print the last page?
 | 
			
		||||
  bool   _lastpage;       // I am about to print the last page?
 | 
			
		||||
 | 
			
		||||
  bool    _isnew;          // new form
 | 
			
		||||
  bool    _isbase;         // base form (.frm file) 
 | 
			
		||||
  TString _desc;           // form description
 | 
			
		||||
  bool   _isnew;          // new form
 | 
			
		||||
  bool   _isbase;         // base form (.frm file) 
 | 
			
		||||
  int    _editlevel;      // Edit permission
 | 
			
		||||
  TString _desc;          // form description
 | 
			
		||||
  
 | 
			
		||||
  TPrint_section* exist(char s, pagetype t, bool create = FALSE);   // Can be NULL
 | 
			
		||||
  
 | 
			
		||||
@ -114,12 +124,12 @@ protected:
 | 
			
		||||
  
 | 
			
		||||
  void print_section(ostream& out, char s) const;
 | 
			
		||||
  virtual void print_on(ostream& out) const;
 | 
			
		||||
  bool edit_relation();
 | 
			
		||||
  
 | 
			
		||||
  bool parse_use(TScanner&);
 | 
			
		||||
  bool parse_join(TScanner&);
 | 
			
		||||
  bool parse_permissions(TScanner&);
 | 
			
		||||
  bool parse_descfield(TScanner&);
 | 
			
		||||
  
 | 
			
		||||
  bool parse_description(TScanner&);
 | 
			
		||||
  void print_description(ostream& out) const;
 | 
			
		||||
  
 | 
			
		||||
  bool read_profile();
 | 
			
		||||
  bool write_profile();
 | 
			
		||||
@ -133,18 +143,15 @@ protected:
 | 
			
		||||
  virtual word set_footer(word p, bool u);
 | 
			
		||||
  
 | 
			
		||||
public:               
 | 
			
		||||
 | 
			
		||||
  bool has_add_permission()      const { return _permissions[0] == 'A'; }
 | 
			
		||||
  bool has_remove_permission()   const { return _permissions[1] == 'R'; }
 | 
			
		||||
  bool has_modify_permission()   const { return _permissions[2] == 'M'; }
 | 
			
		||||
  bool has_relation_permission() const { return _permissions[3] == 'L'; }
 | 
			
		||||
 | 
			
		||||
  bool print(long from = 0L, long to = -1L);
 | 
			
		||||
  
 | 
			
		||||
  const TFilename& name() const { return _name; }
 | 
			
		||||
  const TString& name() const { return _name; }
 | 
			
		||||
  long code() const { return _code; }
 | 
			
		||||
  
 | 
			
		||||
  bool edit_level() const { return _editlevel; }
 | 
			
		||||
  
 | 
			
		||||
  TRelation* relation() const { return _relation; }
 | 
			
		||||
  TRelation_description* reldef() const { return _reldef; }
 | 
			
		||||
  TRelation_description& rel_desc() const;
 | 
			
		||||
 | 
			
		||||
  TCursor* cursor() const { return _cursor; }
 | 
			
		||||
  virtual const char* validate(const char* cur, TToken_string& val);
 | 
			
		||||
@ -153,7 +160,7 @@ public:
 | 
			
		||||
  
 | 
			
		||||
  // if code == NULL it's a base form
 | 
			
		||||
  // otherwise it's integrated by a file definition                                       
 | 
			
		||||
  TForm(const char* form, const char* code = NULL);
 | 
			
		||||
  TForm(const char* form, long code = 0L, int editlevel = 0);
 | 
			
		||||
  virtual ~TForm();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -49,11 +49,11 @@
 | 
			
		||||
#define LF_QUAA                 44
 | 
			
		||||
#define LF_DIPEND               45
 | 
			
		||||
#define LF_DETH                 46
 | 
			
		||||
#define LF_PROF                 50
 | 
			
		||||
#define LF_RFORM                50
 | 
			
		||||
#define LF_DESLIN               51
 | 
			
		||||
#define LF_CONTR                52
 | 
			
		||||
#define LF_RCONT                53
 | 
			
		||||
#define LF_FORMS                54
 | 
			
		||||
#define LF_FORM                 54
 | 
			
		||||
#define LF_GOLEM                55
 | 
			
		||||
 | 
			
		||||
#define CNF_GENERAL 10000
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
// $Id: relation.cpp,v 1.41 1995-05-18 14:17:58 guy Exp $
 | 
			
		||||
// $Id: relation.cpp,v 1.42 1995-05-29 10:24:58 guy Exp $
 | 
			
		||||
// relation.cpp
 | 
			
		||||
// fv 12/8/93
 | 
			
		||||
// relation class for isam files
 | 
			
		||||
@ -12,10 +12,10 @@
 | 
			
		||||
#include <extcdecl.h>
 | 
			
		||||
#include <prefix.h>
 | 
			
		||||
#include <relation.h>
 | 
			
		||||
#include <sheet.h>
 | 
			
		||||
#include <tabutil.h>
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
#include <xvtility.h>
 | 
			
		||||
#include <sheet.h>
 | 
			
		||||
 | 
			
		||||
// *** check if not already defined
 | 
			
		||||
#define NOTFOUND (-1)
 | 
			
		||||
@ -30,17 +30,22 @@ HIDDEN const char* field_type_str(TFieldtypes f)
 | 
			
		||||
  const char* c = "";
 | 
			
		||||
  switch(f)
 | 
			
		||||
  {
 | 
			
		||||
  case _realfld: c = "Reale"; break;
 | 
			
		||||
               case _datefld: c = "Data"; break;
 | 
			
		||||
               case _charfld: c = "Carattere"; break;
 | 
			
		||||
               case _boolfld: c = "Logico"; break;
 | 
			
		||||
               case _wordfld: 
 | 
			
		||||
               case _intzerofld:
 | 
			
		||||
               case _longzerofld:
 | 
			
		||||
               case _intfld: 
 | 
			
		||||
               case _longfld: c = "Intero"; break;
 | 
			
		||||
               default: break;             
 | 
			
		||||
               }
 | 
			
		||||
  case _charfld: 
 | 
			
		||||
    c = "Carattere"; break;
 | 
			
		||||
  case _realfld: 
 | 
			
		||||
    c = "Reale"; break;
 | 
			
		||||
  case _datefld: 
 | 
			
		||||
    c = "Data"; break;
 | 
			
		||||
  case _boolfld: 
 | 
			
		||||
    c = "Logico"; break;
 | 
			
		||||
    //  case _wordfld: 
 | 
			
		||||
    //  case _intzerofld:
 | 
			
		||||
    //  case _longzerofld:
 | 
			
		||||
    //  case _intfld: 
 | 
			
		||||
    //  case _longfld: 
 | 
			
		||||
  default: 
 | 
			
		||||
    c = "Intero"; break;
 | 
			
		||||
  }
 | 
			
		||||
  return c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -62,17 +67,14 @@ class TRelationdef : public TObject
 | 
			
		||||
  TArray     _exprs;              // Condizioni di uguaglianza
 | 
			
		||||
  TArray     _altexprs;           // Condizioni di uguaglianza alternative
 | 
			
		||||
  TBit_array _forced;
 | 
			
		||||
  TString    _description;
 | 
			
		||||
  bool       _first_match  : 1;   // primo match (ed esiste)
 | 
			
		||||
  bool       _allow_lock   : 1;   // ?????
 | 
			
		||||
  bool       _write_enable : 1;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
public: // TObject
 | 
			
		||||
  virtual void print_on(ostream& out) const;
 | 
			
		||||
  void print_on(TToken_string& out) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  int num() const { return _num; }
 | 
			
		||||
  int link() const { return _numto; }
 | 
			
		||||
  int alias() const { return _alias; }
 | 
			
		||||
@ -80,14 +82,14 @@ public:
 | 
			
		||||
  void write_enable(bool we) { _write_enable = we; }
 | 
			
		||||
  TRectype& load_rec(TRectype& r, const TBaseisamfile& from) const;
 | 
			
		||||
  const char* evaluate_expr(int j, const TLocalisamfile& to);
 | 
			
		||||
  void set_description(const char* s) { _description = s; }
 | 
			
		||||
 | 
			
		||||
  void print_on(TToken_string& out) const;
 | 
			
		||||
 | 
			
		||||
  TRelationdef(const TRelation* rel, int file, byte key,
 | 
			
		||||
               int linkto, const char* relexprs, int alias,
 | 
			
		||||
               bool allow_lock, bool write_enable = FALSE);
 | 
			
		||||
  virtual ~TRelationdef() {}
 | 
			
		||||
};
 | 
			
		||||
// @END
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key, 
 | 
			
		||||
@ -141,18 +143,6 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
 | 
			
		||||
    else 
 | 
			
		||||
      _exprs.add(new TExpression(s, _strexpr), i);
 | 
			
		||||
  } 
 | 
			
		||||
  
 | 
			
		||||
  // add description 
 | 
			
		||||
  TString16 name = _rel->file(_num).name();      
 | 
			
		||||
  
 | 
			
		||||
  if (_rel->file(_num).tab())
 | 
			
		||||
  {
 | 
			
		||||
    // tabella
 | 
			
		||||
    TDir dir;           
 | 
			
		||||
    dir.get(TTable::name2log(name), _nolock, _nordir, _sysdirop);  
 | 
			
		||||
    _description = dir.tab_des(name);
 | 
			
		||||
  }           
 | 
			
		||||
  else _description = prefix().description(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -197,7 +187,15 @@ void TRelationdef::print_on(TToken_string& out) const
 | 
			
		||||
 | 
			
		||||
  out = "";
 | 
			
		||||
  print_name(out, f);
 | 
			
		||||
  out.add(_description);
 | 
			
		||||
  
 | 
			
		||||
  // add description 
 | 
			
		||||
  const char* name = f.name();
 | 
			
		||||
  if (f.tab())
 | 
			
		||||
    name = TDir::tab_des(name);
 | 
			
		||||
  else 
 | 
			
		||||
    name = prefix().description(name);
 | 
			
		||||
  out.add(name);
 | 
			
		||||
  
 | 
			
		||||
  out << '|';
 | 
			
		||||
 | 
			
		||||
  if (_numto > 0)
 | 
			
		||||
@ -250,37 +248,29 @@ const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to)
 | 
			
		||||
// TRelation
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
TRelation::TRelation(int logicnum, bool linkrecinst)
 | 
			
		||||
TRelation::TRelation(int logicnum)
 | 
			
		||||
: _files(4) , _reldefs(4), _errors(NOERR)
 | 
			
		||||
{
 | 
			
		||||
  TLocalisamfile* f = new TLocalisamfile(logicnum, linkrecinst);
 | 
			
		||||
  TLocalisamfile* f = new TLocalisamfile(logicnum);
 | 
			
		||||
  _files.add(f);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TRelation::TRelation(const char* tabname, bool linkrecinst)
 | 
			
		||||
TRelation::TRelation(const char* tabname)
 | 
			
		||||
: _files(4) , _reldefs(4), _errors(NOERR)
 | 
			
		||||
{
 | 
			
		||||
  TTable* t = new TTable(tabname, linkrecinst);
 | 
			
		||||
  TTable* t = new TTable(tabname);
 | 
			
		||||
  _files.add(t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TRelation::TRelation(TLocalisamfile* f)
 | 
			
		||||
TRelation::TRelation(TLocalisamfile* l) 
 | 
			
		||||
: _files(4) , _reldefs(4), _errors(NOERR)
 | 
			
		||||
{
 | 
			
		||||
  _files.add(f);
 | 
			
		||||
  _files.add(l);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TRelation::~TRelation()
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
void TRelation::set_description(const char* d, int index)
 | 
			
		||||
{
 | 
			
		||||
  if (index == -1) _main_desc = d == NULL ? "" : d;
 | 
			
		||||
  else reldef(index)._description = d == NULL ? "" : d;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void TRelation::print_on(ostream& out) const
 | 
			
		||||
{
 | 
			
		||||
  const TLocalisamfile& f = file();
 | 
			
		||||
@ -295,47 +285,20 @@ void TRelation::print_on(ostream& out) const
 | 
			
		||||
    out << _reldefs[r] << endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TRelation::print_on(TArray& a) const
 | 
			
		||||
{
 | 
			
		||||
  const TLocalisamfile& f = file();
 | 
			
		||||
  TToken_string s(128);
 | 
			
		||||
  print_name(s, f); 
 | 
			
		||||
 | 
			
		||||
  if (f.tab())
 | 
			
		||||
  {
 | 
			
		||||
    // tabella
 | 
			
		||||
    TDir dir;           
 | 
			
		||||
    dir.get(TTable::name2log(f.name()), _nolock, _nordir, _sysdirop);  
 | 
			
		||||
    s.add(dir.tab_des(f.name()));
 | 
			
		||||
  }           
 | 
			
		||||
  else s.add(prefix().description(f.name()));    
 | 
			
		||||
  
 | 
			
		||||
  s.add("");
 | 
			
		||||
  s.add(f.getkey());
 | 
			
		||||
  s.add(" | ");
 | 
			
		||||
  a.destroy();
 | 
			
		||||
  a.add(s);
 | 
			
		||||
  for (int i = 0; i < _reldefs.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    ((TRelationdef&)_reldefs[i]).print_on(s);
 | 
			
		||||
    a.add(s);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TRelation::restore_status()
 | 
			
		||||
{
 | 
			
		||||
  _status.restart();
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    int err   = _status.get_int();
 | 
			
		||||
    int recno = _status.get_int();
 | 
			
		||||
    const int err   = _status.get_int();
 | 
			
		||||
    const int recno = _status.get_int();
 | 
			
		||||
    if (recno >= 0l) file(i).readat(recno);  
 | 
			
		||||
    else file(i).curr().zero();
 | 
			
		||||
    file(i).setstatus(err);
 | 
			
		||||
  }
 | 
			
		||||
  for (i = 0; i < _reldefs.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    bool first_match = _status.get_int ();
 | 
			
		||||
    const bool first_match = _status.get_int() ? TRUE : FALSE;
 | 
			
		||||
    reldef(i)._first_match = first_match;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1196,6 +1159,9 @@ int name2log(const char* name)
 | 
			
		||||
{
 | 
			
		||||
  int log = 0;
 | 
			
		||||
  
 | 
			
		||||
  if (name)
 | 
			
		||||
    while (*name == ' ') name++;
 | 
			
		||||
  
 | 
			
		||||
  if (name && *name)
 | 
			
		||||
  {
 | 
			
		||||
    if (isdigit(*name) || *name == '-')
 | 
			
		||||
@ -1237,7 +1203,12 @@ TFieldref& TFieldref::operator =(const TString& s)
 | 
			
		||||
    _id = s.left(pos); _id.strip(" ");
 | 
			
		||||
    _fileid = name2log(_id);
 | 
			
		||||
    pos += 2;
 | 
			
		||||
  } else _fileid = pos = 0;
 | 
			
		||||
  } 
 | 
			
		||||
  else 
 | 
			
		||||
  {
 | 
			
		||||
    _id.cut(0);
 | 
			
		||||
    _fileid = pos = 0;
 | 
			
		||||
  }  
 | 
			
		||||
  
 | 
			
		||||
  int par = s.find('[', pos);
 | 
			
		||||
  _name = s.sub(pos, par); _name.strip(" ");
 | 
			
		||||
@ -1245,20 +1216,32 @@ TFieldref& TFieldref::operator =(const TString& s)
 | 
			
		||||
  if (par > 0)
 | 
			
		||||
  {
 | 
			
		||||
    pos = par+1;
 | 
			
		||||
    _from = atoi(s.mid(pos));
 | 
			
		||||
    if (_from > 0) _from--; else _from = 0;
 | 
			
		||||
    set_from(atoi(s.mid(pos)));
 | 
			
		||||
    par = s.find(',', pos);
 | 
			
		||||
    if (par > 0) _to = atoi(s.mid(par+1)); else _to = -1;
 | 
			
		||||
    if (par > 0) set_to(atoi(s.mid(par+1))); 
 | 
			
		||||
    else         set_to(from()+1);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    _from = 0;
 | 
			
		||||
    _to = -1;
 | 
			
		||||
    set_from(0);
 | 
			
		||||
    set_to(-1);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TFieldref::set_file(int f)
 | 
			
		||||
{
 | 
			
		||||
  _id.cut(0);
 | 
			
		||||
  if (f != 0)
 | 
			
		||||
  {
 | 
			
		||||
    _fileid = f;
 | 
			
		||||
    _id << abs(f);
 | 
			
		||||
    if (f < 0) _id << '@';
 | 
			
		||||
  }  
 | 
			
		||||
  else _fileid = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TFieldref::print_on(ostream& out) const
 | 
			
		||||
{
 | 
			
		||||
  if (_id.not_empty()) out << _id << "->";
 | 
			
		||||
@ -1266,14 +1249,13 @@ void TFieldref::print_on(ostream& out) const
 | 
			
		||||
  if (_from > 0 || _to > 0)
 | 
			
		||||
  {
 | 
			
		||||
    out << '[' << (_from+1);
 | 
			
		||||
    if (_to) out << ',' << _to;
 | 
			
		||||
    out << ']';
 | 
			
		||||
    out << ',' << _to << ']';
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* TFieldref::read(const TRectype& rec) const
 | 
			
		||||
{
 | 
			
		||||
  static TString80 buffer;
 | 
			
		||||
  static TString256 buffer;
 | 
			
		||||
 | 
			
		||||
  if (_fileid >= CNF_GENERAL)
 | 
			
		||||
  {
 | 
			
		||||
@ -1287,10 +1269,13 @@ const char* TFieldref::read(const TRectype& rec) const
 | 
			
		||||
    if (_from > 0 || _to > 0)
 | 
			
		||||
    {
 | 
			
		||||
      const int l = buffer.len();
 | 
			
		||||
      const int from = (_from > l) ? l : _from;
 | 
			
		||||
      const int to = (_to > l || _to < 1) ? l : _to;
 | 
			
		||||
      if (to < l) buffer.cut(to);
 | 
			
		||||
      if (from > 0) buffer.ltrim(from);
 | 
			
		||||
      //      const int from = (_from > l) ? l : _from;
 | 
			
		||||
      //      const int to = (_to > l || _to < 1) ? l : _to;
 | 
			
		||||
      //      if (to < l) buffer.cut(to);
 | 
			
		||||
      if (_to < l && _to > 0) buffer.cut(_to);
 | 
			
		||||
 | 
			
		||||
      //      if (from > 0) buffer.ltrim(from);
 | 
			
		||||
      if (_from > 0) buffer.ltrim(_from);
 | 
			
		||||
    } 
 | 
			
		||||
  }
 | 
			
		||||
  return buffer;
 | 
			
		||||
@ -1534,28 +1519,52 @@ int TRecord_array::remove()
 | 
			
		||||
// TRelation_description
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void TRelation_description::init_files_array()
 | 
			
		||||
{
 | 
			
		||||
  const TLocalisamfile& f = _rel->file();
 | 
			
		||||
  TToken_string s(128);
 | 
			
		||||
  print_name(s, f);                // Logic number
 | 
			
		||||
  
 | 
			
		||||
  const char* name = f.name();
 | 
			
		||||
  if (f.tab())
 | 
			
		||||
    name = TDir::tab_des(name);
 | 
			
		||||
  else 
 | 
			
		||||
    name = prefix().description(name);
 | 
			
		||||
  s.add(name);                     // Description 
 | 
			
		||||
  s.add(" ");                      // No join 
 | 
			
		||||
  s.add(f.getkey());               // Key
 | 
			
		||||
  s.add(" | ");                    // No Alias nor expression
 | 
			
		||||
  
 | 
			
		||||
  _files.destroy();
 | 
			
		||||
  _files.add(s);                   // Main file
 | 
			
		||||
  for (int i = 0; i < _rel->items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    _rel->reldef(i).print_on(s);
 | 
			
		||||
    _files.add(s);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void TRelation_description::read_rel()
 | 
			
		||||
{
 | 
			
		||||
  int which_file;
 | 
			
		||||
  
 | 
			
		||||
  // scan files and build description arrays
 | 
			
		||||
  _rel->print_on(_files);
 | 
			
		||||
  
 | 
			
		||||
  TString tn;
 | 
			
		||||
  init_files_array();
 | 
			
		||||
  
 | 
			
		||||
  _fields.destroy();  
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  { 
 | 
			
		||||
    TToken_string& tt = (TToken_string&)_files[i];  
 | 
			
		||||
    TFilename descfname; descfname << DESCDIR << "/d";
 | 
			
		||||
    
 | 
			
		||||
    tn = tt.get(0);
 | 
			
		||||
    const char* tn = tt.get(0);
 | 
			
		||||
    if (tn[0] == '%' || tn[0] == '$')  
 | 
			
		||||
      descfname << tn.mid(1);
 | 
			
		||||
      descfname << (tn+1);
 | 
			
		||||
    else 
 | 
			
		||||
      descfname << tn;
 | 
			
		||||
    descfname << ".des";
 | 
			
		||||
    
 | 
			
		||||
    which_file = atoi(tn);
 | 
			
		||||
    int which_file = atoi(tn);
 | 
			
		||||
    if (which_file == 0)
 | 
			
		||||
      which_file = TTable::name2log(tn);
 | 
			
		||||
    
 | 
			
		||||
@ -1579,38 +1588,66 @@ void TRelation_description::read_rel()
 | 
			
		||||
          if (!dfld.blank() && dfld[0] != '#')
 | 
			
		||||
          {
 | 
			
		||||
            ttmp.add(dfld,4); 
 | 
			
		||||
            // contiene: nome campo, tipo, lunghezza, 
 | 
			
		||||
            //           decimali, descrizione 
 | 
			
		||||
            // contiene: nome campo, tipo, lunghezza, decimali, descrizione 
 | 
			
		||||
            rdesc->add(ttmp); 
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }                           
 | 
			
		||||
      if (rdesc->items() > 0) 
 | 
			
		||||
        _fields.add(rdesc);  
 | 
			
		||||
      else                    
 | 
			
		||||
      {
 | 
			
		||||
        _files.destroy(i);  
 | 
			
		||||
        delete rdesc;
 | 
			
		||||
      }                  
 | 
			
		||||
    }
 | 
			
		||||
    else _files.destroy(i);
 | 
			
		||||
  }                        
 | 
			
		||||
 | 
			
		||||
  _files.pack();   
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TRelation_description::choose_file (int file)
 | 
			
		||||
void TRelation_description::change_relation(TRelation& r, TString_array& a)
 | 
			
		||||
{
 | 
			
		||||
  _rel = &r;
 | 
			
		||||
  read_rel();
 | 
			
		||||
  if (a.items() > 0)
 | 
			
		||||
    _files = a;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TRelation_description::print_on(ostream& out) const
 | 
			
		||||
{
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  {        
 | 
			
		||||
    TToken_string& r = ((TRelation_description*)this)->_files.row(i);
 | 
			
		||||
    out << "  " << r.get(0) << "->* ";
 | 
			
		||||
    out << "\"" << r.get(1) << "\"\n";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool TRelation_description::choose_file(int file)
 | 
			
		||||
{                                                
 | 
			
		||||
  TArray_sheet sht(-1,-1,0,0,"Selezione archivio", "Codice|Descrizione archivio@70");
 | 
			
		||||
  TToken_string tt(80);
 | 
			
		||||
  
 | 
			
		||||
  int sel = 0;
 | 
			
		||||
  
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tf = _files.row(i);
 | 
			
		||||
    tt = tf.get(0);
 | 
			
		||||
    tt.add(tf.get());
 | 
			
		||||
    tt = tf.get(4);
 | 
			
		||||
    if (tt.blank())
 | 
			
		||||
    {
 | 
			
		||||
      tt = tf.get(0);
 | 
			
		||||
      if (sel == 0 && file > 0 && atoi(tt) == file)
 | 
			
		||||
        sel = i;
 | 
			
		||||
    }  
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      if (sel == 0 && file < 0 && atoi(tt) == -file)
 | 
			
		||||
        sel = i;
 | 
			
		||||
      tt << '@';
 | 
			
		||||
    }  
 | 
			
		||||
    
 | 
			
		||||
    tt.add(tf.get(1));
 | 
			
		||||
    sht.add(tt);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  sht.select(sel);
 | 
			
		||||
  
 | 
			
		||||
  if (sht.run() == K_ENTER)
 | 
			
		||||
  {
 | 
			
		||||
    _cur_file = (int)sht.selected();
 | 
			
		||||
@ -1623,18 +1660,24 @@ bool TRelation_description::choose_file (int file)
 | 
			
		||||
bool TRelation_description::choose_field(const char* fld)                         
 | 
			
		||||
{              
 | 
			
		||||
  TArray_sheet sht(-1,-1,0,0,"Selezione campo", 
 | 
			
		||||
                   "Descrizione campo@50|Tipo@10|Dim.");
 | 
			
		||||
                   "Campo@10|Descrizione@50|Tipo@10|Dim.");
 | 
			
		||||
  TString_array& fd = (TString_array&)_fields[_cur_file];
 | 
			
		||||
  TToken_string tt(80);
 | 
			
		||||
 | 
			
		||||
  int sel = 0;
 | 
			
		||||
  for (int i = 0; i < fd.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tf = fd.row(i);
 | 
			
		||||
    tt = tf.get(4); tt.cut(50);
 | 
			
		||||
    tt = tf.get(0);
 | 
			
		||||
    if (sel == 0 && tt == fld) 
 | 
			
		||||
      sel = i;
 | 
			
		||||
    tt.add(tf.get(4));
 | 
			
		||||
    tt.add(field_type_str((TFieldtypes)tf.get_int(1)));
 | 
			
		||||
    tt.add(tf.get(2));
 | 
			
		||||
    sht.add(tt);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  sht.select(sel);
 | 
			
		||||
  if (sht.run() == K_ENTER)
 | 
			
		||||
  {
 | 
			
		||||
    _cur_field = (int)sht.selected();
 | 
			
		||||
@ -1654,19 +1697,23 @@ bool TRelation_description::remove_menu()
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TRelation_description::is_table()
 | 
			
		||||
bool TRelation_description::set_cur_file(int id)
 | 
			
		||||
{
 | 
			
		||||
  return _cfile.get_int(0) == 0;
 | 
			
		||||
  const int n = _rel->log2ind(id);
 | 
			
		||||
  if (n >= 0 && n != _cur_file)
 | 
			
		||||
  {
 | 
			
		||||
    _cur_file = n;
 | 
			
		||||
    _cfile = _files.row(n);
 | 
			
		||||
  }
 | 
			
		||||
  return n >= 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int TRelation_description::file()
 | 
			
		||||
int TRelation_description::file_num()
 | 
			
		||||
{                        
 | 
			
		||||
  return _cfile.get_int(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* TRelation_description::table()
 | 
			
		||||
{                                         
 | 
			
		||||
  return _cfile.get(0);
 | 
			
		||||
  int n = -_cfile.get_int(4);
 | 
			
		||||
  if (n == 0) 
 | 
			
		||||
    n = _cfile.get_int(0);
 | 
			
		||||
  return n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* TRelation_description::file_desc()
 | 
			
		||||
@ -1674,12 +1721,19 @@ const char* TRelation_description::file_desc()
 | 
			
		||||
  return _cfile.get(1);
 | 
			
		||||
}                                             
 | 
			
		||||
 | 
			
		||||
void TRelation_description::file_desc(const char* desc)
 | 
			
		||||
{
 | 
			
		||||
  _cfile.add(desc, 1);
 | 
			
		||||
  _files.row(_cur_file) = _cfile;
 | 
			
		||||
}                                             
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char* TRelation_description::field_desc()
 | 
			
		||||
{
 | 
			
		||||
  return _cfield.get(4);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* TRelation_description::field()
 | 
			
		||||
const char* TRelation_description::field_name()
 | 
			
		||||
{                                              
 | 
			
		||||
  return _cfield.get(0);
 | 
			
		||||
}
 | 
			
		||||
@ -1694,64 +1748,49 @@ TFieldtypes TRelation_description::field_type()
 | 
			
		||||
  return (TFieldtypes)_cfield.get_int(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TRelation_description::set_field_description(int id, const char* field, const char* des)
 | 
			
		||||
bool TRelation_description::set_field_description(const char* field, const char* des)
 | 
			
		||||
{
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tt  = _files.row(i);
 | 
			
		||||
    if (tt.get_int(0) == id || tt.get_int(4) == id)
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  if (i == _files.items()) return FALSE; 
 | 
			
		||||
  TString_array& fld = (TString_array&)_fields[_cur_file];
 | 
			
		||||
  
 | 
			
		||||
  TString_array& fld = (TString_array&)_fields[i];
 | 
			
		||||
  
 | 
			
		||||
  for (i = 0; i < fld.items(); i++)
 | 
			
		||||
  for (int i = 0; i < fld.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tt  = fld.row(i);
 | 
			
		||||
    if (strcmp(tt.get(0),field) == 0)
 | 
			
		||||
    {
 | 
			
		||||
      if (*des) tt.add(des,4);  
 | 
			
		||||
      if (des && *des) 
 | 
			
		||||
        tt.add(des, 4);  
 | 
			
		||||
      else 
 | 
			
		||||
      {
 | 
			
		||||
        fld.destroy(i);
 | 
			
		||||
        fld.pack();
 | 
			
		||||
      } 
 | 
			
		||||
      break;
 | 
			
		||||
      return TRUE;
 | 
			
		||||
    }
 | 
			
		||||
  } 
 | 
			
		||||
  
 | 
			
		||||
  return i < fld.items();
 | 
			
		||||
  if (des && *des)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string tt(80); 
 | 
			
		||||
    tt.add(field);
 | 
			
		||||
    tt.add(des, 4);
 | 
			
		||||
    fld.add(tt);
 | 
			
		||||
    return TRUE;
 | 
			
		||||
  }  
 | 
			
		||||
  
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TRelation_description::set_field_description(const char* id, const char* field, const char* des)
 | 
			
		||||
const char* TRelation_description::get_field_description(const char* field)
 | 
			
		||||
{
 | 
			
		||||
  for (int i = 0; i < _files.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tt  = _files.row(i);
 | 
			
		||||
    if (tt.get(0) == id)
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  if (i == _files.items()) return FALSE; 
 | 
			
		||||
  TString_array& fld = (TString_array&)_fields[_cur_file];
 | 
			
		||||
  
 | 
			
		||||
  TString_array& fld = (TString_array&)_fields[i];
 | 
			
		||||
  
 | 
			
		||||
  for (i = 0; i < fld.items(); i++)
 | 
			
		||||
  for (int i = 0; i < fld.items(); i++)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& tt  = fld.row(i);
 | 
			
		||||
    if (strcmp(tt.get(0),field) == 0)
 | 
			
		||||
    {
 | 
			
		||||
      if (*des) tt.add(des,4);   
 | 
			
		||||
      else 
 | 
			
		||||
      {
 | 
			
		||||
        fld.destroy(i);
 | 
			
		||||
        fld.pack();
 | 
			
		||||
      } 
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
      return tt.get(1);
 | 
			
		||||
  } 
 | 
			
		||||
  
 | 
			
		||||
  return i < fld.items();
 | 
			
		||||
  return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*      $Id: relation.h,v 1.17 1995-05-09 09:12:26 villa Exp $      */
 | 
			
		||||
/*      $Id: relation.h,v 1.18 1995-05-29 10:25:02 guy Exp $      */
 | 
			
		||||
// join.h
 | 
			
		||||
// fv 12/8/93
 | 
			
		||||
// join class for isam files
 | 
			
		||||
@ -10,29 +10,18 @@
 | 
			
		||||
#include <isam.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// @C
 | 
			
		||||
 | 
			
		||||
class TRelation : public TObject
 | 
			
		||||
{
 | 
			
		||||
  friend class TRelationdef;
 | 
			
		||||
  friend class TRelation_description;
 | 
			
		||||
  friend class TCursor;
 | 
			
		||||
 | 
			
		||||
  // class TRelation : public TLocalisamfile
 | 
			
		||||
  // @END
 | 
			
		||||
 | 
			
		||||
  // @DPRIV
 | 
			
		||||
  TToken_string _status;  // stato della relazione
 | 
			
		||||
  TString _main_desc;     // descrizione file principale
 | 
			
		||||
  TArray _files;          // file descriptors
 | 
			
		||||
  TArray _reldefs;        // TRelationdef array
 | 
			
		||||
  int _errors;
 | 
			
		||||
  // @END
 | 
			
		||||
 | 
			
		||||
  // @FPROT
 | 
			
		||||
protected:
 | 
			
		||||
  virtual void print_on(ostream& out) const;
 | 
			
		||||
 | 
			
		||||
  int log2ind(int logicnum) const;
 | 
			
		||||
  int alias2ind(int alias) const;
 | 
			
		||||
  int name2ind(const char* name) const;
 | 
			
		||||
@ -40,16 +29,16 @@ protected:
 | 
			
		||||
  TRelationdef& reldef(int i) const { return (TRelationdef&)_reldefs[i]; }
 | 
			
		||||
  TLocalisamfile& file(int i = 0) const { return (TLocalisamfile&)_files[i]; }
 | 
			
		||||
 | 
			
		||||
  // @LONGDES
 | 
			
		||||
  // position_rels fa tutto il lavoro: se non trova un record
 | 
			
		||||
  // adatto su un file, svuota il record corrente e non ritorna errore.
 | 
			
		||||
  // write etc. poi procedono normalmente
 | 
			
		||||
  // @END
 | 
			
		||||
  int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime, int first = 0);
 | 
			
		||||
 | 
			
		||||
public:  // TObject
 | 
			
		||||
  virtual bool ok() const { return good(); }
 | 
			
		||||
  virtual void print_on(ostream& out) const;      
 | 
			
		||||
  
 | 
			
		||||
public:
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  int update() { return position_rels(_isequal, _nolock);}
 | 
			
		||||
  void zero();
 | 
			
		||||
  virtual int next(TReclock lockop = _nolock) { return file().next(lockop) == NOERR ? position_rels(_isequal, lockop) : file().status(); }
 | 
			
		||||
@ -75,9 +64,6 @@ public:
 | 
			
		||||
  // first place
 | 
			
		||||
  bool next_match(int logicnum,  const char* fieldlist = NULL, int nkey = 0);
 | 
			
		||||
 | 
			
		||||
  // @DES add relation
 | 
			
		||||
  // @FPUB
 | 
			
		||||
 | 
			
		||||
  bool add(TLocalisamfile* f, const char* relexprs, int key,
 | 
			
		||||
           int linkto, int alias, bool allow_lock);
 | 
			
		||||
  bool add(int logicnum, const char* relexprs, int key = 1,
 | 
			
		||||
@ -86,37 +72,29 @@ public:
 | 
			
		||||
           int linkto = 0, int alias = 0, bool allow_lock = FALSE);
 | 
			
		||||
  void replace(TLocalisamfile* f, int index = 0);
 | 
			
		||||
 | 
			
		||||
  // @DES write methods
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  // write methods
 | 
			
		||||
  virtual int write  (bool force = TRUE, TDate& atdate = (TDate&)botime);
 | 
			
		||||
  virtual int rewrite(bool force = TRUE, TDate& atdate = (TDate&)botime);
 | 
			
		||||
  virtual int remove (TDate& atdate = (TDate&)botime);
 | 
			
		||||
 | 
			
		||||
  // @DES checking methods
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  bool eof( int logicnum = 0) { return lfile(logicnum).eof(); }
 | 
			
		||||
  bool bof( int logicnum = 0) { return lfile(logicnum).bof(); }
 | 
			
		||||
 | 
			
		||||
  // @N
 | 
			
		||||
  // status(), good() and bad() return the status of the relation when called
 | 
			
		||||
  // status methods
 | 
			
		||||
  // return the status of the relation when called
 | 
			
		||||
  // with no args, or the status of the file when called with
 | 
			
		||||
  // a logical number
 | 
			
		||||
  // @END
 | 
			
		||||
 | 
			
		||||
  bool status(int logicnum = 0) { return lfile(logicnum).status(); }
 | 
			
		||||
  bool good( int logicnum = 0) { return lfile(logicnum).good(); }
 | 
			
		||||
  bool bad( int logicnum = 0) { return lfile(logicnum).bad(); }
 | 
			
		||||
  bool empty( int logicnum = 0) { return lfile(logicnum).empty(); }
 | 
			
		||||
  // @END
 | 
			
		||||
  bool eof( int logicnum = 0)   const { return lfile(logicnum).eof(); }
 | 
			
		||||
  bool bof( int logicnum = 0)   const { return lfile(logicnum).bof(); }
 | 
			
		||||
  bool status(int logicnum = 0) const { return lfile(logicnum).status(); }
 | 
			
		||||
  bool good( int logicnum = 0)  const { return lfile(logicnum).good(); }
 | 
			
		||||
  bool bad( int logicnum = 0)   const { return lfile(logicnum).bad(); }
 | 
			
		||||
  bool empty( int logicnum = 0) const { return lfile(logicnum).empty(); }
 | 
			
		||||
 | 
			
		||||
  // @LONGDES
 | 
			
		||||
  // isconsistent() returns TRUE if every file in the relation is
 | 
			
		||||
  // OK, current record is non-empty, and relation is consistent.
 | 
			
		||||
  // If it's not and reset is TRUE, it tries to reset the relation
 | 
			
		||||
  // to a consistent state (based on main record) -- no further check
 | 
			
		||||
  // is done.
 | 
			
		||||
  // Also called internally by update and remove.
 | 
			
		||||
  // @END
 | 
			
		||||
  bool isconsistent(bool reset = FALSE);
 | 
			
		||||
 | 
			
		||||
  // TRUE se c'e' un record ed e' il primo match (non si e' mai fatta
 | 
			
		||||
@ -126,25 +104,17 @@ public:
 | 
			
		||||
  // items() ritorna il numero di files collegati
 | 
			
		||||
  int items()        { return _reldefs.items(); }   
 | 
			
		||||
 | 
			
		||||
  // set_description modifica la descrizione del file passato (per indice)
 | 
			
		||||
  // o del principale  
 | 
			
		||||
  void set_description(const char* d, int index = -1);
 | 
			
		||||
  
 | 
			
		||||
  void   save_status    () ;
 | 
			
		||||
  void   restore_status () ;
 | 
			
		||||
 | 
			
		||||
  // @DES positioning operators. return status
 | 
			
		||||
  // @FPUB
 | 
			
		||||
 | 
			
		||||
  // positioning operators. return status
 | 
			
		||||
  TRecnotype operator +=(const TRecnotype npos) { return skip(npos);  }
 | 
			
		||||
  TRecnotype operator -=(const TRecnotype npos) { return skip(-npos); }
 | 
			
		||||
  TRecnotype operator ++() { return next(); }
 | 
			
		||||
  TRecnotype operator --() { return prev(); }
 | 
			
		||||
  
 | 
			
		||||
  void print_on(TArray& a) const;         // Mette la descrizione in un array di TToken_string
 | 
			
		||||
 | 
			
		||||
  TRelation(int logicnum, bool linkrecinst = FALSE);
 | 
			
		||||
  TRelation(const char* tabname, bool linkrecinst = FALSE);
 | 
			
		||||
  TRelation(int logicnum);
 | 
			
		||||
  TRelation(const char* tabname);
 | 
			
		||||
  TRelation(TLocalisamfile* f);
 | 
			
		||||
 | 
			
		||||
  virtual ~TRelation();
 | 
			
		||||
@ -181,47 +151,40 @@ public:
 | 
			
		||||
  void destroy_rows();                                // Cancella tutte le righe
 | 
			
		||||
  
 | 
			
		||||
  bool renum_key(const char* field, const TString& num);
 | 
			
		||||
  bool renum_key(const char* field, long num);       // Rinumera campo chiave in seguito a reinsert
 | 
			
		||||
  bool renum_key(const char* field, long num);        // Rinumera campo chiave in seguito a reinsert
 | 
			
		||||
 | 
			
		||||
  virtual int read(const TRectype& r);               // Leggi tutto l'array da file
 | 
			
		||||
  virtual int write(bool re = FALSE);                // Aggiorna il file
 | 
			
		||||
  virtual int read(const TRectype& r);                // Leggi tutto l'array da file
 | 
			
		||||
  virtual int write(bool re = FALSE);                 // Aggiorna il file
 | 
			
		||||
  virtual int rewrite() { return write(TRUE); }
 | 
			
		||||
  virtual int remove();                              // Cancella tutti i record dal file
 | 
			
		||||
  virtual int remove();                               // Cancella tutti i record dal file
 | 
			
		||||
  
 | 
			
		||||
  TRecord_array(const TRectype& r, const char* numfield, int first = 1);
 | 
			
		||||
  TRecord_array(int logicnum, const char* numfield, int first = 1);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// @C
 | 
			
		||||
// Classe TCursor : public TObject
 | 
			
		||||
//
 | 
			
		||||
// @END
 | 
			
		||||
 | 
			
		||||
class TExpression;
 | 
			
		||||
 | 
			
		||||
typedef bool (*FILTERFUNCTION)(const TRelation* r);
 | 
			
		||||
 | 
			
		||||
class TCursor : public TObject
 | 
			
		||||
{
 | 
			
		||||
  // @DPRIV
 | 
			
		||||
  TRelation*            _if;
 | 
			
		||||
  int                   _nkey;
 | 
			
		||||
  TRecnotype            _pos; // Posizione corrente
 | 
			
		||||
  TRecnotype            _totrec;
 | 
			
		||||
  TRecnotype            _lastrec;
 | 
			
		||||
  TRecnotype            _lastkrec;
 | 
			
		||||
  TFilename                                                     _filename;
 | 
			
		||||
  TFilename             _filename;
 | 
			
		||||
  TString               _filter; // Filtro
 | 
			
		||||
  TString               _keyfrom; // chiave iniziale
 | 
			
		||||
  TString               _keyto; // chiave finale
 | 
			
		||||
  TExpression*                                  _fexpr; // Espressione relativo filtro
 | 
			
		||||
  bool                                                                  _frozen;
 | 
			
		||||
  FILTERFUNCTION                                _filterfunction;
 | 
			
		||||
  TFilename                                             _indexname;
 | 
			
		||||
  // @END
 | 
			
		||||
  TExpression*          _fexpr; // Espressione relativo filtro
 | 
			
		||||
  bool                  _frozen;
 | 
			
		||||
  FILTERFUNCTION        _filterfunction;
 | 
			
		||||
  TFilename             _indexname;
 | 
			
		||||
 | 
			
		||||
  // @FPRIV
 | 
			
		||||
  virtual TRecnotype buildcursor(TRecnotype rp);
 | 
			
		||||
  int filtercursor(int pagecnt, TRecnotype* page);
 | 
			
		||||
  bool changed();
 | 
			
		||||
@ -287,23 +250,19 @@ public:
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// @C
 | 
			
		||||
// Classe TFieldref : public TObject
 | 
			
		||||
// @END
 | 
			
		||||
 | 
			
		||||
class TFieldref : public TObject
 | 
			
		||||
{
 | 
			
		||||
  // @DPRIV
 | 
			
		||||
  short _fileid;        // Numero del file
 | 
			
		||||
  TString16 _id;        // Nome tabella o stringa col numero del file
 | 
			
		||||
  TString80 _name;      // Nome del campo
 | 
			
		||||
  int _from, _to;       // Substring
 | 
			
		||||
  short _fileid;      // Numero del file
 | 
			
		||||
  TString _id;        // Nome tabella o stringa col numero del file
 | 
			
		||||
  TString _name;      // Nome del campo
 | 
			
		||||
  int _from, _to;     // Substring
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  virtual void print_on(ostream& out) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  // @FPUB
 | 
			
		||||
  TFieldref();
 | 
			
		||||
  TFieldref(const TString&, short defid);
 | 
			
		||||
 | 
			
		||||
@ -312,7 +271,13 @@ public:
 | 
			
		||||
  virtual bool ok() const { return _name.not_empty(); }    // Vero se il numero del file e' valido
 | 
			
		||||
 | 
			
		||||
  int file() const { return _fileid; }       // ritorna il file
 | 
			
		||||
  void set_file(int f);
 | 
			
		||||
  
 | 
			
		||||
  const char* name() const { return (const char*) _name; } // ritorna il nome del campo
 | 
			
		||||
  void set_name(const char* n) { _name = n; }
 | 
			
		||||
  void set_from(int f) { if (f > 0) f--; else f = 0; _from = f; }
 | 
			
		||||
  void set_to(int t) { _to = t; }
 | 
			
		||||
  
 | 
			
		||||
  int from() const { return _from; }
 | 
			
		||||
  int to() const { return _to; }
 | 
			
		||||
  int len(TRectype &rec) const;
 | 
			
		||||
@ -330,7 +295,7 @@ class TRelation_description : public TObject
 | 
			
		||||
  // gestisce l'uso interattivo di una relazione (scelta campi, descrizione)
 | 
			
		||||
  // domani o doman l'altro gestira' l'editing interattivo e grafico                      
 | 
			
		||||
  
 | 
			
		||||
  TRelation*      _rel;                          
 | 
			
		||||
  TRelation*      _rel;                     // relation described     
 | 
			
		||||
  TString_array   _files;  
 | 
			
		||||
  TArray          _fields;  
 | 
			
		||||
  int             _cur_file;
 | 
			
		||||
@ -338,14 +303,20 @@ class TRelation_description : public TObject
 | 
			
		||||
  bool            _menu;
 | 
			
		||||
  TToken_string   _cfile, _cfield;
 | 
			
		||||
  
 | 
			
		||||
  void            read_rel();                   
 | 
			
		||||
protected:   
 | 
			
		||||
  void init_files_array();
 | 
			
		||||
  void read_rel();                   
 | 
			
		||||
  
 | 
			
		||||
public: // TObject
 | 
			
		||||
  virtual bool ok() const { return _files.items() > 0; }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  
 | 
			
		||||
  // "choose" interface: after choosing a field (must return TRUE)
 | 
			
		||||
  // methods allow to know all data concerning the field 
 | 
			
		||||
  // parameters set the one initially selected
 | 
			
		||||
  bool choose_file (int file = -1);                         
 | 
			
		||||
  bool choose_file (int id = 0);                         
 | 
			
		||||
  bool set_cur_file(int id = 0);
 | 
			
		||||
 | 
			
		||||
  // file must have been chosen: first file in list if called 
 | 
			
		||||
  // before choose_file
 | 
			
		||||
@ -356,22 +327,24 @@ public:
 | 
			
		||||
  bool build_menu(const char* title = "Database");               
 | 
			
		||||
  bool remove_menu();        
 | 
			
		||||
  
 | 
			
		||||
  bool set_field_description(int id, const char* field, const char* des);
 | 
			
		||||
  bool set_field_description(const char* tab, const char* field, const char* des);
 | 
			
		||||
 | 
			
		||||
  // if choose_field == TRUE or menu has been used
 | 
			
		||||
  // these return valid data
 | 
			
		||||
  bool        is_table();
 | 
			
		||||
  int         file();
 | 
			
		||||
  const char* table();
 | 
			
		||||
  const char* field();
 | 
			
		||||
  // if choose_file == TRUE or menu has been used these return valid data
 | 
			
		||||
  int         file_num();
 | 
			
		||||
  const char* file_desc();
 | 
			
		||||
  void        file_desc(const char* desc);
 | 
			
		||||
  bool        set_field_description(const char* field, const char* des);
 | 
			
		||||
  const char* get_field_description(const char* field);
 | 
			
		||||
 | 
			
		||||
  // if choose_field == TRUE or menu has been used these return valid data
 | 
			
		||||
  const char* field_desc();
 | 
			
		||||
  void        field_desc(const char* desc);
 | 
			
		||||
  const char* field_name();
 | 
			
		||||
  int         field_len();
 | 
			
		||||
  TFieldtypes field_type();
 | 
			
		||||
  
 | 
			
		||||
  virtual bool ok()   { return _files.items() > 0; }
 | 
			
		||||
  const TString_array& get_all_desc() const { return _files; }
 | 
			
		||||
  void change_relation(TRelation& rel, TString_array& arr);
 | 
			
		||||
  
 | 
			
		||||
  virtual void print_on(ostream& out) const;
 | 
			
		||||
  
 | 
			
		||||
  TRelation_description(TRelation& r);
 | 
			
		||||
  virtual ~TRelation_description(); 
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,9 @@
 | 
			
		||||
#define M_EDIT_DELETE   (M_EDIT+9)
 | 
			
		||||
#define M_EDIT_QUIT     (M_EDIT+10)
 | 
			
		||||
 | 
			
		||||
#define M_SHOW_RULERS   (M_EDIT+20)
 | 
			
		||||
#define M_SHOW_BUTTONS  (M_EDIT+21)
 | 
			
		||||
 | 
			
		||||
#if XVT_OS == XVT_OS_WIN
 | 
			
		||||
 | 
			
		||||
#define ICO_SEARCH    109
 | 
			
		||||
 | 
			
		||||
@ -1175,13 +1175,13 @@ void TViswin::handler (WINDOW win, EVENT * ep)
 | 
			
		||||
      stop_run(CTRL_S);
 | 
			
		||||
#endif
 | 
			
		||||
      break;
 | 
			
		||||
    case M_FONT:          // mostra righelli
 | 
			
		||||
    case M_SHOW_RULERS:   // mostra righelli
 | 
			
		||||
      show_rulers(!_rulers);
 | 
			
		||||
      check_menu_item(M_FONT, _rulers);
 | 
			
		||||
      check_menu_item(M_SHOW_RULERS, _rulers);
 | 
			
		||||
      break;
 | 
			
		||||
    case M_STYLE:         // mostra bottoni
 | 
			
		||||
    case M_SHOW_BUTTONS:         // mostra bottoni
 | 
			
		||||
      show_buttons(!_showbuts);
 | 
			
		||||
      check_menu_item(M_STYLE, _showbuts);
 | 
			
		||||
      check_menu_item(M_SHOW_BUTTONS, _showbuts);
 | 
			
		||||
      break;
 | 
			
		||||
    case M_EDIT_QUIT:          // chiudi
 | 
			
		||||
#if XVT_OS == XVT_OS_WIN
 | 
			
		||||
@ -2325,10 +2325,10 @@ TViswin::TViswin(const char *fname,
 | 
			
		||||
 | 
			
		||||
  if (_toplevel)
 | 
			
		||||
  {      
 | 
			
		||||
    enable_menu_item(M_FONT, TRUE);
 | 
			
		||||
    enable_menu_item(M_STYLE, TRUE);
 | 
			
		||||
    check_menu_item(M_FONT, _rulers);
 | 
			
		||||
    check_menu_item(M_STYLE, _showbuts);        
 | 
			
		||||
    enable_menu_item(M_SHOW_RULERS, TRUE);
 | 
			
		||||
    enable_menu_item(M_SHOW_BUTTONS, TRUE);
 | 
			
		||||
    check_menu_item(M_SHOW_RULERS, _rulers);
 | 
			
		||||
    check_menu_item(M_SHOW_BUTTONS, _showbuts);        
 | 
			
		||||
    enable_menu_item(M_EDIT_SEL_ALL, FALSE);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user