lmi-commits
[Top][All Lists]
Advanced

[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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]