diff --git a/include/recset.cpp b/include/recset.cpp
index 56b49862a..363c6b2c2 100755
--- a/include/recset.cpp
+++ b/include/recset.cpp
@@ -568,7 +568,6 @@ bool select_custom_file(TFilename& path, const char* ext)
TString str;
FOR_EACH_ARRAY_ROW(files, i, row)
{
-
TXmlItem item;
if (item.Load(*row))
{
diff --git a/include/report.cpp b/include/report.cpp
index 657466fd5..ba87bc4d2 100755
--- a/include/report.cpp
+++ b/include/report.cpp
@@ -463,6 +463,16 @@ TReport_field* TReport_section::find_field(int id)
return NULL;
}
+// Determina se e' possibile manntenere la sezione nella stessa pagina della successiva
+bool TReport_section::keep_with_next() const
+{ return _keep_with_next && type() == 'H' && level() > 1; }
+
+// Determina se e' possibile spezzare la sezione su due pagine
+bool TReport_section::can_be_broken() const
+{
+ return _can_break && type() == 'B' && level() > 0;
+}
+
TPoint TReport_section::compute_size() const
{
if (hidden())
@@ -580,6 +590,16 @@ void TReport_section::print(TBook& book) const
}
}
+void TReport_section::print_clipped(TBook& book, long top, long bottom) const
+{
+ if (shown() && active())
+ {
+ book.set_clip(top, bottom);
+ print(book);
+ book.set_clip(0, -1);
+ }
+}
+
bool TReport_section::execute_postscript()
{
bool ok = true;
@@ -624,7 +644,8 @@ void TReport_section::save(TXmlItem& root) const
item.SetAttr("hidden", _hidden);
item.SetAttr("deactivated", _deactivated);
item.SetAttr("hidden_if_needed", hidden_if_needed());
- item.SetAttr("pagebreak", _page_break);
+ item.SetAttr("page_break", _page_break);
+ item.SetAttr("can_break", can_be_broken());
item.SetAttr("keep_with_next", keep_with_next());
item.SetAttr("repeat", repeat_on_page());
if (condition().not_empty())
@@ -656,7 +677,8 @@ void TReport_section::load(const TXmlItem& sec)
set_back_color(get_col_attr(sec, "bg_color", COLOR_WHITE));
set_fore_color(get_col_attr(sec, "fg_color", COLOR_BLACK));
- force_page_break(sec.GetBoolAttr("pagebreak"));
+ force_page_break(sec.GetBoolAttr("page_break"));
+ can_break(sec.GetBoolAttr("can_break"));
keep_with_next(sec.GetBoolAttr("keep_with_next"));
hide_if_needed(sec.GetBoolAttr("hidden_if_needed"));
set_repeat_on_page(sec.GetBoolAttr("repeat"));
@@ -708,7 +730,8 @@ void TReport_section::load(const TXmlItem& sec)
TReport_section::TReport_section(TReport& r, char t, int l)
: _report(r), _type(t), _level(l), _pos(0,0),
- _size(0,0), _page_break(false), _hidden_if_needed(false), _keep_with_next(false),
+ _size(0,0), _page_break(false), _hidden_if_needed(false),
+ _can_break(false), _keep_with_next(false),
_repeat(false), _hidden(false), _deactivated(false),
_font(NULL), _print_font(NULL),
_bgcolor(COLOR_WHITE), _fgcolor(COLOR_BLACK), _pattern(PAT_HOLLOW),
@@ -1612,7 +1635,8 @@ int TReport_field::compare(const TSortable& s) const
TReport_field::TReport_field(TReport_section* sec)
: _section(sec), _id(0), _type('T'), _rct(0,0,1000,100),
- _fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE), _radius(0), _pattern(PAT_HOLLOW),
+ _fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE), _pattern(PAT_HOLLOW),
+ _radius(0), _shade_offset(0),
_border(0), _halign('L'), _valign('T'),_dynamic_height(false),
_font(NULL), _print_font(NULL),
_hidden(false), _deactivated(false), _hide_zeroes(false), _selected(false),
diff --git a/include/report.h b/include/report.h
index 3f0fbde41..8aa75c812 100755
--- a/include/report.h
+++ b/include/report.h
@@ -148,7 +148,7 @@ class TReport_section : public TArray
TPoint _pos; // Posizione assoluta in centesimi, default (0,0)
TPoint _size; // Dimensioni in centesimi, default (0,0)
TString _condition, _groupby;
- bool _page_break, _hidden_if_needed, _keep_with_next, _repeat;
+ bool _page_break, _hidden_if_needed, _can_break, _keep_with_next, _repeat;
bool _hidden, _deactivated;
COLOR _fgcolor, _bgcolor;
int _border, _radius;
@@ -208,7 +208,9 @@ public:
bool hidden_if_needed() const { return _hidden_if_needed; }
void hide_if_needed(bool h) { _hidden_if_needed = h; }
- bool keep_with_next() const { return _keep_with_next; }
+ bool can_be_broken() const;
+ void can_break(bool k) { _can_break = k; }
+ bool keep_with_next() const;
void keep_with_next(bool k) { _keep_with_next = k; }
bool hidden() const { return _hidden; }
bool shown() const { return !hidden(); }
@@ -236,6 +238,7 @@ public:
bool execute_prescript();
bool execute_postscript();
void print(TBook& book) const;
+ void print_clipped(TBook& book, long top, long bottom) const;
void save(TXmlItem& report) const;
void load(const TXmlItem& sec);
diff --git a/include/reprint.cpp b/include/reprint.cpp
index 1767f6537..6221b8ca8 100755
--- a/include/reprint.cpp
+++ b/include/reprint.cpp
@@ -731,7 +731,7 @@ bool TBook::open_page()
_font.create("", 12, XVT_FA_ALL);
_horizontal_alignment = 'L';
_vertical_alignment = 'T';
- _rect.reset();
+ _rect.set(-1,-1,0,0);
_print_aborted = false;
_page_is_open = true;
@@ -744,7 +744,7 @@ bool TBook::close_page()
return false;
*_out << "' << endl;
-
+
_pages++;
_page_is_open = false;
@@ -776,6 +776,18 @@ void TBook::define_frame(const TRectangle& rect)
}
}
+void TBook::set_clip(long top, long bottom)
+{
+ if (bottom >= top)
+ {
+ const TRectangle rect(0, top, logical_page_width(), bottom-top);
+ define_frame(rect);
+ *_out << "" << endl;
+ }
+ else
+ *_out << "" << endl;
+}
+
void TBook::draw_text(const TRectangle& r, const char* txt)
{
const TFixed_string str(txt);
@@ -1010,6 +1022,14 @@ bool TBook::print_page(TWindow& win, size_t page)
win.set_brush(col, pat);
continue;
}
+ if (str.starts_with("")
{
xvt_dwin_draw_oval(win.win(), &rct);
@@ -1032,7 +1052,7 @@ bool TBook::print_page(TWindow& win, size_t page)
if (win.win() == 883)
xvt_dwin_set_font(win.win(), font.get_xvt_font(win));
else
- xvt_dwin_set_font(win.win(), font.get_preview_font(win, page_res()));
+ xvt_dwin_set_font(win.win(), font.get_preview_font(win, page_res()));
continue;
}
if (str.starts_with(" 0) // Has some visible fields
{
bool page_break = _page_break_allowed && rs.page_break();
+ long reprint_from = 0;
if (!page_break)
{
long h = height;
if (rs.keep_with_next())
h += rs.report().section('B', 1).compute_size().y;
- page_break = (_delta.y + h > _logical_foot_pos);
+ const long space_left = _logical_foot_pos - _delta.y;
+ page_break = h > space_left;
+
+ // Controllo se la sezione puo' essere stampata su due pagine
+ if (page_break && space_left >= 100 && rs.can_be_broken() )
+ {
+ reprint_from = space_left / 100 * 100;
+ rs.print_clipped(*this, 0, reprint_from);
+ }
}
if (page_break && rs.level() > 0) // Avoid recursion
{
@@ -1560,7 +1589,15 @@ long TReport_book::print_section(TReport_section& rs)
reprint_group_headers();
}
if (_page_is_open)
- rs.print(*this);
+ {
+ if (reprint_from > 0)
+ {
+ _delta.y -= reprint_from;
+ rs.print_clipped(*this, reprint_from, height);
+ }
+ else
+ rs.print(*this);
+ }
if (rs.level() > 0) // Ho stampato qualcosa che non sia lo sfondo!
_page_break_allowed = true;
diff --git a/include/reprint.h b/include/reprint.h
index 740054730..2fe380cd8 100755
--- a/include/reprint.h
+++ b/include/reprint.h
@@ -48,6 +48,7 @@ public:
virtual void draw_text(const TRectangle& rect, const char* text);
virtual void draw_link(const TRectangle& rect, const char* text, const char* link);
virtual void draw_book_pages(const TRectangle& r);
+ virtual void set_clip(long top, long bottom);
TPoint page_size() const;
TPoint page_res() const;
@@ -70,7 +71,6 @@ public:
virtual ~TBook();
};
-
class TReport_book : public TBook
{
TReport* _report;