lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6335] Refactor for clarity


From: Greg Chicares
Subject: [lmi-commits] [6335] Refactor for clarity
Date: Fri, 09 Oct 2015 02:55:21 +0000

Revision: 6335
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6335
Author:   chicares
Date:     2015-10-09 02:55:21 +0000 (Fri, 09 Oct 2015)
Log Message:
-----------
Refactor for clarity

Modified Paths:
--------------
    lmi/trunk/group_quote_pdf_gen_wx.cpp

Modified: lmi/trunk/group_quote_pdf_gen_wx.cpp
===================================================================
--- lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-10-09 02:00:31 UTC (rev 
6334)
+++ lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-10-09 02:55:21 UTC (rev 
6335)
@@ -92,6 +92,26 @@
     return z;
 }
 
+/// Generate HTML representation of a field name and value in an HTML table and
+/// append it to the specified string, defining the HTML.
+///
+/// The HTML fragment generated by this function contains two <td> tags with
+/// the given contents.
+
+void append_name_value_to_html_table
+    (wxString& html_table
+    ,std::string const& name
+    ,std::string const& value
+    )
+{
+    html_table += wxString::Format
+        ("<td align=\"right\"><b>%s%s&nbsp;&nbsp;</b></td><td>%s</td>"
+        ,escape_for_html_elem(name)
+        ,(value.empty() ? "" : ":")
+        ,escape_for_html_elem(value)
+        );
+}
+
 /// Append the given tag to the string and ensure that the matching closing tag
 /// will be appended to it later.
 ///
@@ -907,8 +927,8 @@
     output_html(html_parser, horz_margin, *pos_y, page_.width_ / 2, 
title_html);
 
     // Build the summary table with all the mandatory fields.
-    wxString summary_html = wxString::Format
-        ("<table width=\"100%%\" cellspacing=\"0\" cellpadding=\"0\">"
+    wxString summary_html =
+         "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">"
          // This extra top empty row works around a bug in wxHTML
          // table positioning code: it uses the provided ordinate
          // coordinate as a base line of the first table line and
@@ -920,25 +940,47 @@
          "<tr>"
          "<td align=\"center\" colspan=\"4\"><font size=\"+1\">Plan Details 
Summary</font></td>"
          "</tr>"
-         "<tr>"
-         "<td align=\"right\"><b>Effective 
Date:&nbsp;&nbsp;</b></td><td>%s</td>"
-         "<td align=\"right\"><b>Product:&nbsp;&nbsp;</b></td><td>%s</td>"
-         "</tr>"
-         "<tr>"
-         "<td align=\"right\"><b>Available 
Riders:&nbsp;&nbsp;</b></td><td>%s</td>"
-         "<td align=\"right\"><b>Contract 
State:&nbsp;&nbsp;</b></td><td>%s</td>"
-         "</tr>"
-         "<tr>"
-         "<td align=\"right\"><b>Number of 
participants:&nbsp;&nbsp;</b></td><td>%d</td>"
-         "<td align=\"right\"><b>Premium Mode:&nbsp;&nbsp;</b></td><td>%s</td>"
-         "</tr>"
-        ,escape_for_html_elem(report_data_.effective_date_)
-        ,escape_for_html_elem(report_data_.product_)
-        ,escape_for_html_elem(report_data_.available_riders_)
-        ,escape_for_html_elem(report_data_.contract_state_)
-        ,row_num_
-        ,escape_for_html_elem(report_data_.premium_mode_)
+         ;
+
+    {
+    open_and_ensure_closing_tag tag_tr(summary_html, "tr");
+    append_name_value_to_html_table
+        (summary_html
+        ,"Effective Date"
+        ,report_data_.effective_date_
         );
+    append_name_value_to_html_table
+        (summary_html
+        ,"Product"
+        ,report_data_.product_
+        );
+    }
+    {
+    open_and_ensure_closing_tag tag_tr(summary_html, "tr");
+    append_name_value_to_html_table
+        (summary_html
+        ,"Available Riders"
+        ,report_data_.available_riders_
+        );
+    append_name_value_to_html_table
+        (summary_html
+        ,"Contract State"
+        ,report_data_.contract_state_
+        );
+    }
+    {
+    open_and_ensure_closing_tag tag_tr(summary_html, "tr");
+    append_name_value_to_html_table
+        (summary_html
+        ,"Number of participants"
+        ,wxString::Format("%d", row_num_).ToStdString()
+        );
+    append_name_value_to_html_table
+        (summary_html
+        ,"Premium Mode"
+        ,report_data_.premium_mode_
+        );
+    }
 
     // Then add any additional fields in left-to-right top-to-bottom order.
     std::vector<extra_summary_field> const& fields = 
report_data_.extra_fields_;
@@ -952,12 +994,7 @@
         // Add one, if there are no more, or two fields to it.
         for(int col = 0; col < 2; ++col)
             {
-            summary_html += wxString::Format
-                ("<td align=\"right\"><b>%s%s&nbsp;&nbsp;</b></td><td>%s</td>"
-                ,escape_for_html_elem(i->name)
-                ,(i->value.empty() ? "" : ":")
-                ,escape_for_html_elem(i->value)
-                );
+            append_name_value_to_html_table(summary_html, i->name, i->value);
 
             if(++i == fields.end())
                 {




reply via email to

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