[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 940198c 059/156: Add numeric summary attachme
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 940198c 059/156: Add numeric summary attachment page |
Date: |
Tue, 30 Jan 2018 17:22:11 -0500 (EST) |
branch: master
commit 940198c88b94bd1583c74ce5cabf5d862af3ce0b
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add numeric summary attachment page
Turn numeric_summary_page into numeric_summary_or_attachment_page<>
template to allow using it as both a numbered page in the middle of an
illustration and as an attachment at its end.
---
ledger_pdf_generator_wx.cpp | 42 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 738d4e8..7ffb222 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -49,6 +49,7 @@
#include <memory>
#include <sstream>
#include <stdexcept>
+#include <type_traits> // std::conditional
#include <vector>
LMI_FORCE_LINKING_IN_SITU(ledger_pdf_generator_wx)
@@ -652,7 +653,7 @@ affiliated company and sales representatives, {{InsCoAddr}}.
}
};
-/// Base class for all with a footer.
+/// Base class for all pages with a footer.
class page_with_footer : public page
{
public:
@@ -799,6 +800,16 @@ class page_with_footer : public page
int footer_top_ = 0;
};
+/// Base class for attachment pages.
+class attachment_page : public page_with_footer
+{
+ private:
+ std::string get_footer_contents() const override
+ {
+ return "Attachment";
+ }
+};
+
/// Base class for all pages showing the page number in the footer.
///
/// In addition to actually providing page_with_footer with the correct string
@@ -1691,7 +1702,21 @@ class columns_headings_page : public numbered_page
}
};
-class numeric_summary_page : public numbered_page
+// Numeric summary page appears twice, once as a normal page and once as an
+// attachment, with the only difference being that the base class is different,
+// so make it a template to avoid duplicating the code.
+
+// Just a helper alias.
+template<bool is_attachment>
+using numbered_or_attachment_base = typename std::conditional
+ <is_attachment
+ ,attachment_page
+ ,numbered_page
+ >::type;
+
+template<bool is_attachment>
+class numeric_summary_or_attachment_page
+ : public numbered_or_attachment_base<is_attachment>
{
public:
void render
@@ -1701,7 +1726,12 @@ class numeric_summary_page : public numbered_page
,html_interpolator const& interpolate_html
) override
{
- numbered_page::render(ledger, writer, dc, interpolate_html);
+ numbered_or_attachment_base<is_attachment>::render
+ (ledger
+ ,writer
+ ,dc
+ ,interpolate_html
+ );
writer.output_html
(writer.get_horz_margin()
@@ -2173,10 +2203,14 @@ class pdf_illustration_regular : public pdf_illustration
add<columns_headings_page>();
if(!invar.IsInforce)
{
- add<numeric_summary_page>();
+ add<numeric_summary_or_attachment_page<false>>();
}
add<tabular_detail_page>();
add<tabular_detail2_page>();
+ if(!invar.IsInforce)
+ {
+ add<numeric_summary_or_attachment_page<true>>();
+ }
}
};
- [lmi-commits] [lmi] master 23d26f8 055/156: Factor out reusable page_with_tabular_report class, (continued)
- [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
- [lmi-commits] [lmi] master b1ab0fa 126/156: Leave a gap between upper footer part and main page contents, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 940198c 059/156: Add numeric summary attachment page,
Greg Chicares <=
- [lmi-commits] [lmi] master b341a2a 061/156: Factor out using_illustration_table helper class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1b46585 076/156: Use MarketingNameFootnote & StateMarketingImprimatur on cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 956fcca 071/156: Change the second narrative summary page to use a template too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master dbe5955 015/156: Factor out html_interpolator from pdf_illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9665573 070/156: Change narrative summary page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a629602 083/156: Use custom <scaled_image> HTML tag for the embedded images, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b425030 082/156: Factor out html_cell_for_pdf_output from numeric_summary_table_cell, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 416ab02 030/156: Add support for vector variables to PDF generating code, Greg Chicares, 2018/01/30