[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master de5d0b8 060/156: Inline output_and_check_for_
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master de5d0b8 060/156: Inline output_and_check_for_page_break() function |
Date: |
Tue, 30 Jan 2018 17:22:11 -0500 (EST) |
branch: master
commit de5d0b80fbcdb92e4f1f09d1aa0838948fa87151
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Inline output_and_check_for_page_break() function
This function is used only once, and it doesn't make much sense to have
it in illustration_table_generator class as it doesn't really fit its
role as just a simple wrapper of wx_table_generator defining the
appearance used by the illustration tables.
Doing this also allows to get rid of "page_bottom" argument to this
class ctor, which will make it possible to reuse it when we don't care
about the page bottom and pagination at all.
---
ledger_pdf_generator_wx.cpp | 57 +++++++++++++++------------------------------
1 file changed, 19 insertions(+), 38 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 7ffb222..732b29a 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -261,48 +261,17 @@ class illustration_table_generator : public
wx_table_generator
illustration_table_generator
(pdf_writer_wx& writer
,wxDC& dc
- ,int page_bottom
)
:wx_table_generator
(dc
,writer.get_horz_margin()
,writer.get_page_width()
)
- ,page_bottom_(page_bottom)
{
use_condensed_style();
align_right();
}
- // This is a wrapper around the base class output_row() which also adds
- // breaks between row groups for readability and returns true if we need to
- // start a new page.
- bool output_and_check_for_page_break
- (int year
- ,int* pos_y
- ,std::string const* values
- )
- {
- wx_table_generator::output_row(pos_y, values);
-
- if((year + 1) % rows_per_group == 0)
- {
- // We need a group break.
- *pos_y += row_height();
-
- // And possibly a page break, which will be necessary if we don't
- // have enough space for another full group because we don't want
- // to have page breaks in the middle of a group.
- if(*pos_y >= page_bottom_ - rows_per_group*row_height())
- {
- return true;
- }
- }
-
- // No need for a page break yet.
- return false;
- }
-
// Return the amount of vertical space taken by separator lines in the
// table headers.
int get_separator_line_height() const
@@ -311,9 +280,6 @@ class illustration_table_generator : public
wx_table_generator
// look well.
return row_height() / 2;
}
-
- private:
- int page_bottom_ = 0;
};
class page
@@ -1760,6 +1726,10 @@ class page_with_tabular_report : public numbered_page
auto const& columns = get_report_columns();
+ // Just some cached values used inside the loop below.
+ auto const row_height = table.row_height();
+ auto const page_bottom = get_footer_top();
+ auto const rows_per_group =
illustration_table_generator::rows_per_group;
std::vector<std::string> values(columns.size());
// The table may need several pages, loop over them.
@@ -1789,11 +1759,22 @@ class page_with_tabular_report : public numbered_page
;
}
- if(table.output_and_check_for_page_break(year, &pos_y,
values.data()))
+ table.output_row(&pos_y, values.data());
+
+ if((year + 1) % rows_per_group == 0)
{
- next_page(dc);
- numbered_page::render(ledger, writer, dc,
interpolate_html);
- break;
+ // We need a group break.
+ pos_y += row_height;
+
+ // And possibly a page break, which will be necessary if
we don't
+ // have enough space for another full group because we
don't want
+ // to have page breaks in the middle of a group.
+ if(pos_y >= page_bottom - rows_per_group*row_height)
+ {
+ next_page(dc);
+ numbered_page::render(ledger, writer, dc,
interpolate_html);
+ break;
+ }
}
}
}
- [lmi-commits] [lmi] master 2478fbc 010/156: Start implementing PDF illustrations directly, (continued)
- [lmi-commits] [lmi] master 2478fbc 010/156: Start implementing PDF illustrations directly, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9d24cd9 024/156: Compilation fix for C++11 but not C++14 compilers, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1229745 020/156: Make add_body_paragraph() even more convenient to use, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 14aca9e 142/156: Replace underscores in title map with explicit line breaks, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5241f0f 045/156: Fix some typos in wx_table_generator::add_column() comment, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 47bddbf 155/156: Merge branch 'vz-no-xslfo' into gwc-no-xslfo, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a1342a9 106/156: Fix supplemental NASD illustration page for split premiums, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ec0b298 110/156: Add NASD illustration second explanatory notes page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 80423d2 134/156: Improve appearance of lower header part in NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 408ba18 156/156: Merge branch 'gwc-no-xslfo' [387], Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master de5d0b8 060/156: Inline output_and_check_for_page_break() function,
Greg Chicares <=
- [lmi-commits] [lmi] master 5421d85 002/156: Factor out pdf_writer_wx from group_quote_pdf_gen_wx, Greg Chicares, 2018/01/30