[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1a9bfb3 137/156: Factor out standard_suppleme
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1a9bfb3 137/156: Factor out standard_supplemental_report class |
Date: |
Tue, 30 Jan 2018 17:22:32 -0500 (EST) |
branch: master
commit 1a9bfb3653bfa8657263ea3cc5b3e441b9cad283
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Factor out standard_supplemental_report class
Avoid defining trivial per-illustration supplemental report page classes
by implementing the default logic in this standard_supplemental_report
class.
Now only one extra class needs to be defined, in order to use a
non-default footer for the supplemental report page in regular
illustrations.
---
ledger_pdf_generator_wx.cpp | 100 ++++++++++++++++++++------------------------
1 file changed, 46 insertions(+), 54 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 96baaa2..ad08f11 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1838,14 +1838,38 @@ class tabular_detail2_page : public
page_with_tabular_report
}
};
-class supplemental_report_base : public page_with_tabular_report
+class standard_supplemental_report : public page_with_tabular_report
{
public:
- explicit supplemental_report_base(html_interpolator const&
interpolate_html)
+ explicit standard_supplemental_report
+ (html_interpolator const& interpolate_html
+ ,std::string const& page_template
+ )
+ :columns_(build_columns(interpolate_html))
+ ,page_template_(page_template)
+ {
+ }
+
+ private:
+ illustration_table_columns const& get_table_columns() const override
+ {
+ return columns_;
+ }
+
+ std::string get_fixed_page_contents() const override
+ {
+ return "{{>" + page_template_ + "}}";
+ }
+
+ // Helper function used by the ctor to initialize the const columns_ field.
+ illustration_table_columns build_columns
+ (html_interpolator const& interpolate_html
+ )
{
constexpr std::size_t max_columns = 12;
std::string const empty_column_name("[none]");
+ illustration_table_columns columns;
for(std::size_t i = 0; i < max_columns; ++i)
{
auto name =
interpolate_html.evaluate("SupplementalReportColumnsNames", i);
@@ -1854,7 +1878,7 @@ class supplemental_report_base : public
page_with_tabular_report
// We currently don't have the field width information for
// arbitrary fields, so use fixed width that should be
// sufficient for almost all of them.
- columns_.emplace_back
+ columns.emplace_back
(illustration_table_column
{std::move(name)
,interpolate_html.evaluate("SupplementalReportColumnsTitles", i)
@@ -1863,28 +1887,23 @@ class supplemental_report_base : public
page_with_tabular_report
);
}
}
- }
- private:
- illustration_table_columns const& get_table_columns() const override
- {
- return columns_;
+ return columns;
}
- illustration_table_columns columns_;
+ illustration_table_columns const columns_ ;
+ std::string const page_template_;
};
-class supplemental_report : public supplemental_report_base
+class supplemental_report : public standard_supplemental_report
{
public:
- using supplemental_report_base::supplemental_report_base;
-
- private:
- std::string get_fixed_page_contents() const override
+ explicit supplemental_report(html_interpolator const& interpolate_html)
+ :standard_supplemental_report(interpolate_html, "supplemental_report")
{
- return "{{>supplemental_report}}";
}
+ private:
std::string get_upper_footer_template_name() const override
{
return "footer_disclaimer";
@@ -2381,18 +2400,6 @@ class nasd_assumption_detail : public
page_with_tabular_report
// all of its columns, including the "AttainedAge" one, are always shown.
};
-class nasd_supplemental_report : public supplemental_report_base
-{
- public:
- using supplemental_report_base::supplemental_report_base;
-
- private:
- std::string get_fixed_page_contents() const override
- {
- return "{{>nasd_supplemental_report}}";
- }
-};
-
// NASD illustration.
class pdf_illustration_nasd : public pdf_illustration
{
@@ -2447,7 +2454,10 @@ class pdf_illustration_nasd : public pdf_illustration
}
if(invar.SupplementalReport)
{
- add<nasd_supplemental_report>(get_interpolator());
+ add<standard_supplemental_report>
+ (get_interpolator()
+ ,"nasd_supplemental_report"
+ );
}
}
@@ -2492,18 +2502,6 @@ class reg_d_group_basic : public
page_with_basic_tabular_report
}
};
-class reg_d_group_supplemental_report : public supplemental_report_base
-{
- public:
- using supplemental_report_base::supplemental_report_base;
-
- private:
- std::string get_fixed_page_contents() const override
- {
- return "{{>reg_d_group_supplemental_report}}";
- }
-};
-
// Private group placement illustration.
class pdf_illustration_reg_d_group : public pdf_illustration
{
@@ -2530,7 +2528,10 @@ class pdf_illustration_reg_d_group : public
pdf_illustration
add<standard_page>("reg_d_group_narrative_summary2");
if(invar.SupplementalReport)
{
- add<reg_d_group_supplemental_report>(get_interpolator());
+ add<standard_supplemental_report>
+ (get_interpolator()
+ ,"reg_d_group_supplemental_report"
+ );
}
}
@@ -2778,18 +2779,6 @@ class reg_d_individual_cur : public
page_with_tabular_report
}
};
-class reg_d_individual_supplemental_report : public supplemental_report_base
-{
- public:
- using supplemental_report_base::supplemental_report_base;
-
- private:
- std::string get_fixed_page_contents() const override
- {
- return "{{>reg_d_individual_supplemental_report}}";
- }
-};
-
// Private individual placement illustration.
class pdf_illustration_reg_d_individual : public pdf_illustration
{
@@ -2816,7 +2805,10 @@ class pdf_illustration_reg_d_individual : public
pdf_illustration
add<standard_page>("reg_d_individual_notes3");
if(invar.SupplementalReport)
{
- add<reg_d_individual_supplemental_report>(get_interpolator());
+ add<standard_supplemental_report>
+ (get_interpolator()
+ ,"reg_d_individual_supplemental_report"
+ );
}
}
- [lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_basic_tabular_report class, (continued)
- [lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_basic_tabular_report class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a85943b 124/156: Add the rest of individual private placement illustration pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f0b9cea 113/156: Add "Assumption Detail" page to NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 031070b 132/156: Implement supplemental report page for the regular illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9fe1d07 125/156: Implement page-specific footer for "Tabular Details" pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f3a02e 078/156: Add company logo to the cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2d93248 118/156: Add the rest of group private placement illustration pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1272ce2 127/156: Don't include "Assumptions" page in composite NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e00ab7d 080/156: Hide "attained age" column for composite illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 29e63d6 117/156: Add basic illustration page of group placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1a9bfb3 137/156: Factor out standard_supplemental_report class,
Greg Chicares <=
- [lmi-commits] [lmi] master 7c0ff88 145/156: Add copyright notices to all .mst template files, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2fd6a11 147/156: Use shorter and more consistent names for external templates, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b09a25f 026/156: Implement numbering pages in the PDF output, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bb75971 033/156: Implement the second part of the narrative summary page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 964db82 067/156: Rename columns_headings_page to column_headings_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2a94469 074/156: Use Mustache template files from the data directory, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 01be23a 103/156: Automatically squeeze table columns to make them fit if necessary, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 46a7442 068/156: Factor out helper render_template() method, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d77620f 100/156: Factor out dollar_units template from the existing ones, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 833eef5 086/156: Use std::make_unique<> instead of raw "new", Greg Chicares, 2018/01/30