From 585c6020acf4f135a39195f8cfe5293ce37ac34f Mon Sep 17 00:00:00 2001 From: villa Date: Tue, 19 Dec 1995 09:44:13 +0000 Subject: [PATCH] Autofinkatura git-svn-id: svn://10.65.10.50/trunk@2318 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba2100s.uml | 12 ++++----- ba/baformed.cpp | 2 +- include/form.cpp | 67 +++++++++++++++++++++++++++++------------------- include/form.h | 11 +++++++- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/ba/ba2100s.uml b/ba/ba2100s.uml index ec69a2044..7432cec52 100755 --- a/ba/ba2100s.uml +++ b/ba/ba2100s.uml @@ -84,9 +84,9 @@ BEGIN ITEM "Descrizione@40" ITEM "Intestazione@40" ITEM "Pr" - ITEM "Y@2" + ITEM "Y@3" ITEM "Lun." - ITEM "X@2" + ITEM "X@3" ITEM "Col." ITEM "Spazi" ITEM "Finc. sin." @@ -140,25 +140,25 @@ BEGIN PROMPT 1 4 "Non Stampare " END -NUMBER 105 2 +NUMBER 105 3 BEGIN PROMPT 1 7 "Y " FLAGS "G" END -NUMBER 106 2 +NUMBER 106 3 BEGIN PROMPT 1 6 "Lunghezza " FLAGS "G" END -NUMBER 107 2 +NUMBER 107 3 BEGIN PROMPT 1 5 "X " FLAGS "G" END -NUMBER 108 2 +NUMBER 108 3 BEGIN PROMPT 1 8 "Colonna " FLAGS "G" diff --git a/ba/baformed.cpp b/ba/baformed.cpp index fdb98f1d3..8807eeffb 100755 --- a/ba/baformed.cpp +++ b/ba/baformed.cpp @@ -276,7 +276,7 @@ bool TForm_editor::menu(MENU_TAG tag) } void TForm_editor::print() -{ +{ _form->print(); } diff --git a/include/form.cpp b/include/form.cpp index 4447d8321..7b845a047 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -265,8 +265,8 @@ void TForm_flags::print_on(TMask& m) m.set(F_DISABLED, enabled ? " " : "X"); m.set(F_HIDDEN, shown ? " " : "X"); m.set(F_AUTOMAGIC, automagic ? "X" : " "); - m.set(F_FINKL, finkl ? " " : "X"); - m.set(F_FINKR, finkr ? " " : "X"); + m.set(F_FINKL, finkl ? " " : "X"); + m.set(F_FINKR, finkr ? " " : "X"); } @@ -287,7 +287,8 @@ void TForm_flags::read_from(const TMask& m) TForm_item::TForm_item(TPrint_section* section) -: _section(section), _x(-1), _y(-1), _width(0), _height(0), _id(0), _ofs(0) +: _section(section), _x(-1), _y(-1), _width(0), _height(0), _id(0), _ofs(0), + _temp(FALSE) {} @@ -729,14 +730,14 @@ void TForm_item::print_on_sheet_row(TToken_string& tt) const tt.add(_x, _section->columnwise() ? col_id - 101 : xps_id - 101); tt.add(_y, _section->columnwise() ? len_id - 101 : yps_id - 101); tt.add(class_name(), typ_id - 101); - tt.add(shown() ? "X" : " ", prn_id - 101); + tt.add(shown() ? " " : "X", prn_id - 101); tmp = example(); tt.add(tmp, frm_id - 101); if (_section->columnwise()) { tt.add(_ofs, spc_id -101); - tt.add(finkl() ? "" : "X", fnl_id -101); - tt.add(finkr() ? "" : "X", fnr_id -101); + tt.add(finkl() ? " " : "X", fnl_id -101); + tt.add(finkr() ? " " : "X", fnr_id -101); } } @@ -782,13 +783,14 @@ void TForm_item::read_from(TToken_string& s) _x = _section->columnwise() ? s.get_int(col_id - 101) : s.get_int(xps_id - 101); _y = _section->columnwise() ? s.get_int(len_id - 101) : s.get_int(yps_id - 101); _ofs = s.get_int(spc_id - 101); - _flag.set_enabled(s.get(prn_id - 101) != "X"); + _flag.set_shown(s.get(prn_id - 101) != "X"); if (_section->columnwise()) { _flag.set_finkl(s.get(fnl_id - 101) != "X"); _flag.set_finkr(s.get(fnr_id - 101) != "X"); } + set_dirty(); } bool TForm_item::edit(TMask& m) @@ -1879,7 +1881,7 @@ TMask* TPrint_section::_msk = NULL; TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub) : _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE), - _subsection(sub), _repeat_count(0), _ofspc(0), _nfld(0) + _subsection(sub), _repeat_count(0), _ofspc(0), _nfld(0), _temp(0) { _tab[0] = -1; } TPrint_section::~TPrint_section() @@ -1936,10 +1938,10 @@ int TPrint_section::tab(int col) _tab[0] = 1; for (word i = 0; i < fields(); i++) { - if (field(i).shown() && field(i).enabled()) + if (field(i).shown()) { CHECKD (field(i)._x < MAXCOLUMNS, "Colonna ammessa e non concessa: ", field(i)._x); - _tab[field(i)._x] = field(i).width() + 1; // one is for separation + _tab[field(i)._x] = field(i)._y + 1; // one is for separation _nfld++; } } @@ -2527,7 +2529,7 @@ void TPrint_section::print_on(ostream& out) const if (_columnwise) out << " COLUMNWISE"; out << endl << endl; for(word i = 0; i < fields(); i++) - out << field(i); + if (!field(i).temp()) out << field(i); } TForm_item& TPrint_section::find_field(short id) const @@ -3020,33 +3022,39 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows) const TPrint_section* body = exist('B', p); if (body == NULL) return FALSE; - TGraphic_section* grs = (TGraphic_section*)exist('G', p, TRUE); - word j = 0, start = 999, end = 0, wlast = 0; - word cols[MAXCOLUMNS]; + bool istemp = exist('G', p) == NULL; - for (word i = 0; i < body->fields(); i++) + TGraphic_section* grs = (TGraphic_section*)exist('G', p, TRUE); + grs->temp() = istemp; + + int j = 0, start = 999, end = 0, wlast = 0; + int cols[MAXCOLUMNS]; + + for (int i = 0; i < (int)body->fields(); i++) { - TForm_item& f = body->field(i); + const TForm_item& f = body->field(i); if (!f.shown()) continue; - word x = f.x(); + const int x = f.x(); if (x < start) start = x; - if (x > end) { end = x; wlast = f.width(); } - if (!f.finkl()) - cols[j++] = x; + if (x > end) { end = x; wlast = f.y(); } + cols[j++] = f.finkl() ? -x : x; } // inner lines for (i = 0; i < j; i++) { - if (cols[i] != start) + if (cols[i] != start && cols[i] > 0) { TForm_line* l = new TForm_line(grs); l->x() = cols[i]-1; - l->y() = (word)y1; - l->width() = 0; + l->y() = (word)y1; + l->id() = -1; + l->width() = 1; l->height() = (int)(y2 - y1 + 1); + l->set("@R"); + l->temp() = TRUE; grs->add_field(l); } } @@ -3056,9 +3064,11 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows) { TForm_box* l = new TForm_box(grs); l->x() = start; - l->y() = (word)y1; + l->y() = (word)y1; + l->id() = -1; l->width() = (int)(end + wlast - start + 1); l->height() = (int)(y2 - y1 + 1); + l->temp() = TRUE; grs->add_field(l); } @@ -3068,9 +3078,12 @@ bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows) { TForm_line* l = new TForm_line(grs); l->x() = start; - l->y() = (word)rows[i]; + l->y() = (word)rows[i]; + l->id() = -1; l->width() = (int)(end + wlast - start + 1); - l->height() = 0; + l->height() = 1; + l->set("@R"); + l->temp() = TRUE; grs->add_field(l); } @@ -3188,7 +3201,7 @@ void TForm::print_section(ostream& out, char s) const for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1)) { const TPrint_section* sec = ((TForm*)this)->exist(s, t); - if (sec && sec->ok()) + if (sec && sec->ok() && !sec->temp()) { const char* name; switch (s) diff --git a/include/form.h b/include/form.h index aac5fd807..42fdf7dfa 100755 --- a/include/form.h +++ b/include/form.h @@ -210,7 +210,7 @@ protected: public: TForm_flags(); - void set_enabled(bool b) { enabled = b; } + void set_shown(bool b) { shown = b; } void set_finkl(bool b) { finkl = b; } void set_finkr(bool b) { finkr = b; } @@ -229,6 +229,7 @@ class TPrint_section : public TArray word _nfld; // number of columns if columnwise bool _dirty; // Flag di modifica parametri bool _columnwise; // Columnwise field specification + bool _temp; // temporanea (da non salvare) TForm* _form; // Form cui appartiene alla sezione char _sec_type; // H, B, F, G @@ -264,6 +265,9 @@ public: void change_field(int n, TForm_item* f); void insert_field(int n, TForm_item* f); void add_field(TForm_item* f); + + virtual bool& temp() { return _temp; }; + virtual bool temp() const { return _temp; }; word fields() const { return _item.items(); } // returns 0 if not columnwise; means n. of printable fields @@ -304,6 +308,7 @@ class TForm_item : public TObject TForm_flags _flag; TBit_array _group; TAssoc_array _special; + bool _temp; protected: @@ -329,12 +334,16 @@ protected: public: short id() const { return _id; } + virtual short& id() { return _id; }; virtual int width() const { return _width; } virtual short& width() { return _width; } virtual int height() const { return _height; } virtual short& height() { return _height; } virtual short& ofs() { return _ofs; } virtual int effective_height() const { return _effective_height; } + + virtual bool& temp() { return _temp; }; + virtual bool temp() const { return _temp; }; virtual short& x() { return _x; }; virtual short x() const;