[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0f78daf 050/156: Compute the footer size in p
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0f78daf 050/156: Compute the footer size in page_with_footer::pre_render() |
Date: |
Tue, 30 Jan 2018 17:22:07 -0500 (EST) |
branch: master
commit 0f78daf141ebbcd8e0e56dd2282c192acb717418
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Compute the footer size in page_with_footer::pre_render()
Do it earlier to allow derived classes get_extra_pages_needed() to use
the footer height in their layout calculations.
---
ledger_pdf_generator_wx.cpp | 101 ++++++++++++++++++++++++++++++--------------
1 file changed, 69 insertions(+), 32 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 0b1bc07..60a199f 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -581,6 +581,34 @@ affiliated company and sales representatives,
{{InsCoAddr}}.
class page_with_footer : public page
{
public:
+ // Override pre_render() to compute footer_top_ which is needed in the
+ // derived classes overridden get_extra_pages_needed().
+ void pre_render
+ (Ledger const& /* ledger */
+ ,pdf_writer_wx& writer
+ ,wxDC& /* dc */
+ ,html_interpolator const& interpolate_html
+ ) override
+ {
+ // Note that we implicitly assume here that get_footer_html() result
+ // doesn't materially depend on the exact value of last_page_number_ as
+ // we don't know its definitive value here yet. In theory, this doesn't
+ // need to be true, e.g. we may later discover that 10 pages are needed
+ // instead of 9 and the extra digit might result in a line wrapping on
+ // a new line and this increasing the footer height, but in practice
+ // this doesn't risk happening and taking into account this possibility
+ // wouldn't be simple at all, so just ignore this possibility.
+ auto const footer_height = writer.output_html
+ (writer.get_horz_margin()
+ ,0
+ ,writer.get_page_width()
+ ,get_footer_html(interpolate_html)
+ ,e_output_measure_only
+ );
+
+ footer_top_ = writer.get_page_bottom() - footer_height;
+ }
+
void render
(Ledger const& /* ledger */
,pdf_writer_wx& writer
@@ -588,7 +616,46 @@ class page_with_footer : public page
,html_interpolator const& interpolate_html
) override
{
- auto footer_html =
+ auto const frame_horz_margin = writer.get_horz_margin();
+ auto const frame_width = writer.get_page_width();
+
+ writer.output_html
+ (frame_horz_margin
+ ,footer_top_
+ ,frame_width
+ ,get_footer_html(interpolate_html)
+ );
+
+ dc.SetPen(HIGHLIGHT_COL);
+ dc.DrawLine
+ (frame_horz_margin
+ ,footer_top_
+ ,frame_width + frame_horz_margin
+ ,footer_top_
+ );
+ }
+
+ protected:
+ // Helper for the derived pages to get the vertical position of the footer.
+ // Notice that it can only be used after calling our pre_render() method
+ // as this is where it is computed.
+ int get_footer_top() const
+ {
+ LMI_ASSERT(footer_top_ != 0);
+
+ return footer_top_;
+ }
+
+ private:
+ // Method to be overridden in the base class which should actually return
+ // the contents of the (middle part of the) footer.
+ virtual std::string get_footer_contents() const = 0;
+
+ // This method uses get_footer_contents() and returns the HTML wrapping it
+ // and other fixed information appearing in the footer.
+ html::text get_footer_html(html_interpolator const& interpolate_html) const
+ {
+ return
tag::font[attr::size("-2")]
(tag::table[attr::width("100%")]
[attr::cellspacing("0")]
@@ -652,39 +719,9 @@ class page_with_footer : public page
)
)
);
-
- auto const frame_horz_margin = writer.get_horz_margin();
- auto const frame_width = writer.get_page_width();
-
- auto const footer_height = writer.output_html
- (frame_horz_margin
- ,0
- ,frame_width
- ,footer_html
- ,e_output_measure_only
- );
-
- auto const footer_top = writer.get_page_bottom() - footer_height;
- writer.output_html
- (frame_horz_margin
- ,footer_top
- ,frame_width
- ,footer_html
- );
-
- dc.SetPen(HIGHLIGHT_COL);
- dc.DrawLine
- (frame_horz_margin
- ,footer_top
- ,frame_width + frame_horz_margin
- ,footer_top
- );
}
- private:
- // Method to be overridden in the base class which should actually return
- // the contents of the (middle part of the) footer.
- virtual std::string get_footer_contents() const = 0;
+ int footer_top_ = 0;
};
/// Base class for all pages showing the page number in the footer.
- [lmi-commits] [lmi] master bb21f4d 077/156: Fix header for composite illustrations, (continued)
- [lmi-commits] [lmi] master bb21f4d 077/156: Fix header for composite illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d2b2cae 038/156: Change column_headings page to use external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2bb1c91 041/156: Remove unnecessary outer html and body tags, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1afd45c 040/156: Avoid spurious coding style violation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9695e9e 112/156: Create InitAnnLoanDueRate vector in addition to the scalar, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5f6dc89 131/156: Use string objects for illustration_table_column fields, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master fb01571 035/156: Pass what is being expanded to interpolation function, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master fc6d8b7 034/156: Implement the "Columns Headings" page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 46788b8 119/156: Start implementing individual private placement illustration kind, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1287474 114/156: Start private group placement illustration class implementation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0f78daf 050/156: Compute the footer size in page_with_footer::pre_render(),
Greg Chicares <=
- [lmi-commits] [lmi] master 6b3b5b2 054/156: Factor out illustration_table_generator from tabular_detail2_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 23d26f8 055/156: Factor out reusable page_with_tabular_report class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f484622 044/156: Only show numeric summary if not in force, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 67db94b 042/156: Implement more of numeric summary page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master dbaf3c4 048/156: Render PDF illustrations in two passes, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master de9567e 152/156: Fix misplaced commas in ledger PDF generator code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 783befa 006/156: Add separate class for representing HTML contents, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8c5be11 128/156: Use proper types for get_two_column_header() parameters, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 257ff4b 065/156: Add numeric summary table to PDF illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ef38c9d 141/156: Revert the title map related changes, Greg Chicares, 2018/01/30