[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1445c8d 7/8: Merge two identical blocks into
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1445c8d 7/8: Merge two identical blocks into a single function |
Date: |
Wed, 12 Sep 2018 12:08:06 -0400 (EDT) |
branch: master
commit 1445c8de8fcea4da599917253f1bca3f7de3e5e5
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Merge two identical blocks into a single function
---
ledger_pdf_generator_wx.cpp | 97 ++++++++++++++++++---------------------------
1 file changed, 39 insertions(+), 58 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 743b7d2..42c998c 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -353,6 +353,43 @@ class using_illustration_table
return false;
}
+ std::vector<std::string> get_visible_values
+ (Ledger const& ledger
+ ,html_interpolator const& interpolate_html
+ ,int year
+ )
+ {
+ auto const& columns = get_table_columns();
+ std::vector<std::string> visible_values;
+ for(int j = 0; j < lmi::ssize(columns); ++j)
+ {
+ columns[j].visibility =
+ should_hide_column(ledger, j)
+ ? oe_hidden
+ : oe_shown
+ ;
+
+ if(oe_shown == columns[j].visibility)
+ {
+ std::string output_value;
+ if(columns[j].variable_name.empty())
+ {
+ ; // Separator column: use empty string.
+ }
+ else
+ {
+ output_value = interpolate_html.evaluate
+ (columns[j].variable_name
+ ,year
+ );
+ }
+
+ visible_values.push_back(output_value);
+ }
+ }
+ return visible_values;
+ }
+
// Useful helper for creating the table generator using the columns defined
// by the separate (and simpler to implement) get_table_columns() pure
// virtual function.
@@ -1464,35 +1501,7 @@ class numeric_summary_table_cell
case oe_render:
{
auto const& interpolate_html =
pdf_context_for_html_output.interpolate_html();
- auto const& columns = get_table_columns();
- std::vector<std::string> visible_values;
- for(int j = 0; j < lmi::ssize(columns); ++j)
- {
- columns[j].visibility =
- should_hide_column(ledger, j)
- ? oe_hidden
- : oe_shown
- ;
-
- if(oe_shown == columns[j].visibility)
- {
- std::string output_value;
- if(columns[j].variable_name.empty())
- {
- ; // Separator column: use empty string.
- }
- else
- {
- output_value = interpolate_html.evaluate
- (columns[j].variable_name
- ,year
- );
- }
-
- visible_values.push_back(output_value);
- }
- }
-
+ auto visible_values = get_visible_values(ledger,
interpolate_html, year);
if(is_last_row)
{
visible_values.at(column_policy_year) =
summary_age_string;
@@ -1631,35 +1640,7 @@ class page_with_tabular_report
for(;;)
{
- auto const& columns = get_table_columns();
- std::vector<std::string> visible_values;
- for(int j = 0; j < lmi::ssize(columns); ++j)
- {
- columns[j].visibility =
- should_hide_column(ledger, j)
- ? oe_hidden
- : oe_shown
- ;
-
- if(oe_shown == columns[j].visibility)
- {
- std::string output_value;
- if(columns[j].variable_name.empty())
- {
- ; // Separator column: use empty string.
- }
- else
- {
- output_value = interpolate_html.evaluate
- (columns[j].variable_name
- ,year
- );
- }
-
- visible_values.push_back(output_value);
- }
- }
-
+ auto const visible_values = get_visible_values(ledger,
interpolate_html, year);
table_gen.output_row(pos_y, visible_values);
++year;
- [lmi-commits] [lmi] master updated (d8aa128 -> 7bf948b), Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 039924c 6/8: Refactor to prepare for a larger refactoring, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master ff118b3 5/8: Assert that a refactoring will be safe, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 7bf948b 8/8: Refactor for clarity, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 0d7d4d5 4/8: Simplify some special-case logic to make it easier to relocate, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 99930af 1/8: Declare a variable only in the scope where it's used, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 039c1fd 2/8: Declare a variable only in the scope where it's used, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master a049a0d 3/8: Forestall latent off-by-one errors, Greg Chicares, 2018/09/12
- [lmi-commits] [lmi] master 1445c8d 7/8: Merge two identical blocks into a single function,
Greg Chicares <=