[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra_pages_needed() hook |
Date: |
Tue, 30 Jan 2018 17:22:07 -0500 (EST) |
branch: master
commit acb7aae95d04ee37ef888a8d7d34b1d3ee20c05e
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add numbered_page::get_extra_pages_needed() hook
This convenient virtual method can be overridden by the derived classes
to return a positive value if they need more than one physical page to
show their contents.
In this case the derived class is also responsible for calling
next_page() exactly the right number of times.
---
ledger_pdf_generator_wx.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index bade62d..0b1bc07 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -24,6 +24,7 @@
#include "ledger_pdf_generator.hpp"
#include "alert.hpp"
+#include "assert_lmi.hpp"
#include "authenticity.hpp"
#include "calendar_date.hpp"
#include "force_linking.hpp"
@@ -699,7 +700,74 @@ class numbered_page : public page_with_footer
{
}
+ void pre_render
+ (Ledger const& ledger
+ ,pdf_writer_wx& writer
+ ,wxDC& dc
+ ,html_interpolator const& interpolate_html
+ ) override
+ {
+ page_with_footer::pre_render(ledger, writer, dc, interpolate_html);
+
+ extra_pages_ = get_extra_pages_needed
+ (ledger
+ ,writer
+ ,dc
+ ,interpolate_html
+ );
+
+ LMI_ASSERT(extra_pages_ >= 0);
+
+ last_page_number_ += extra_pages_;
+ }
+
+ ~numbered_page() override
+ {
+ // Check that next_page() was called the expected number of times.
+ // Unfortunately we can't use LMI_ASSERT() in the (noexcept) dtor, so
+ // use warning() instead.
+ if(extra_pages_)
+ {
+ warning()
+ << "Logic error: "
+ << extra_pages_
+ << " missing extra pages."
+ << LMI_FLUSH
+ ;
+ }
+ }
+
+ protected:
+ void next_page(wxDC& dc)
+ {
+ // This method may only be called if we had reserved enough physical
+ // pages for this logical pages by overriding get_extra_pages_needed().
+ LMI_ASSERT(extra_pages_ > 0);
+
+ dc.StartPage();
+
+ this_page_number_++;
+ extra_pages_--;
+ }
+
private:
+ // Derived classes may override this method if they may need more than one
+ // physical page to show their contents.
+ virtual int get_extra_pages_needed
+ (Ledger const& ledger
+ ,pdf_writer_wx& writer
+ ,wxDC& dc
+ ,html_interpolator const& interpolate_html
+ ) const
+ {
+ stifle_warning_for_unused_value(ledger);
+ stifle_warning_for_unused_value(writer);
+ stifle_warning_for_unused_value(dc);
+ stifle_warning_for_unused_value(interpolate_html);
+
+ return 0;
+ }
+
std::string get_footer_contents() const override
{
std::ostringstream oss;
@@ -709,6 +777,7 @@ class numbered_page : public page_with_footer
static int last_page_number_;
int this_page_number_;
+ int extra_pages_ = 0;
};
int numbered_page::last_page_number_ = 0;
- [lmi-commits] [lmi] master 7d278ef 011/156: Add footer to the cover page, (continued)
- [lmi-commits] [lmi] master 7d278ef 011/156: Add footer to the cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d5d8185 057/156: Add tabular_details page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bb64784 013/156: Add a helper allowing to interpolate variables in strings, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b72ced6 014/156: Replace ad hoc illustration properties with HTML interpolator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e7d763d 066/156: Add company logo display to the PDF illustration header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f575c94 003/156: Refactor more group_quote_pdf_gen_wx code to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5e2fc70 007/156: Make HTML generation utilities more type-safe, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ed2bbf 027/156: Simplify footer generation code by moving font tag outside, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41ae40d 089/156: Fix wrong "<br>" tag in the header template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra_pages_needed() hook,
Greg Chicares <=
- [lmi-commits] [lmi] master c0d68e1 122/156: Add rate of return pages of the individual placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 875ca7d 039/156: Rename StateIsTX ledger variable to StateIsTexas, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even more customizable, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 10dd0a9 051/156: Factor enum_output_mode into a separate header to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8fa972e 052/156: Add "Tabular Detail, continued" page to the PDF illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a standard header and use it, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c378bc5 064/156: Remove unnecessary value_cast inclusion, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template() method, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular and narrative_summary_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 614fb47 135/156: Add supplemental reports pages to private placement illustrations, Greg Chicares, 2018/01/30