lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master dd0e779 2/6: Move and rename a member functio


From: Greg Chicares
Subject: [lmi-commits] [lmi] master dd0e779 2/6: Move and rename a member function
Date: Tue, 12 Jun 2018 17:50:19 -0400 (EDT)

branch: master
commit dd0e779fa67c5c9e5096a3367e1e42753ce838ce
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Move and rename a member function
    
    This begins a series of commits that will make the paste-out facility
    available to end users. Gave this member function a wxCommandEvent&
    argument so that it can be used as an event handler. Renamed it for
    concinnity with other event handlers.
---
 census_view.cpp | 132 ++++++++++++++++++++++++++++----------------------------
 census_view.hpp |   3 +-
 2 files changed, 67 insertions(+), 68 deletions(-)

diff --git a/census_view.cpp b/census_view.cpp
index 2a17b16..a8c6a13 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1236,71 +1236,6 @@ void CensusView::update_visible_columns()
         }
 }
 
-/// Paste from the census manager into a "spreadsheet" (TSV) file.
-///
-/// Include exactly those columns whose rows aren't all identical,
-/// considering as "rows" the individual cells--and also the case
-/// defaults, even though they aren't displayed in any row.
-///
-/// Motivation: Some census changes are more easily made by exporting
-/// data from lmi, manipulating it in a spreadsheet, and then pasting
-/// it back into lmi.
-///
-/// Never extract "UseDOB": it's always set by UponPasteCensus().
-/// Never extract "IssueAge". If it's present, then "UseDOB" must also
-/// be, and "UseDOB" preserves information that "IssueAge" loses.
-
-void CensusView::paste_out_to_spreadsheet() const
-{
-    configurable_settings const& c = configurable_settings::instance();
-    std::string const& e = c.spreadsheet_file_extension();
-    std::string const  f = fs::basename(base_filename()) + "_pasted_out";
-    std::string file_name = unique_filepath(f, e).string();
-    std::ofstream os(file_name.c_str(), ios_out_app_binary());
-
-    std::vector<std::string> distinct_headers;
-    std::vector<std::string> const& 
all_headers(case_parms()[0].member_names());
-    for(auto const& header : all_headers)
-        {
-        if(column_value_varies_across_cells(header, cell_parms()))
-            {
-            if(header != "UseDOB" && header != "IssueAge")
-                {
-                distinct_headers.push_back(header);
-                }
-            }
-        }
-
-    for(auto const& header : distinct_headers)
-        {
-        // Assume that the trailing '\t' doesn't matter.
-        os << header << '\t';
-        }
-    os << '\n';
-
-    for(auto const& cell : cell_parms())
-        {
-        for(auto const& header : distinct_headers)
-            {
-            // Show calendar dates as YYYYMMDD rather than JDN.
-            std::string s = cell[header].str();
-            if(exact_cast<tnr_date>(cell[header]))
-                {
-                int z = JdnToYmd(jdn_t(value_cast<int>(s))).value();
-                s = value_cast<std::string>(z);
-                }
-            // Assume that the trailing '\t' doesn't matter.
-            os << s << '\t';
-            }
-        os << '\n';
-        }
-
-    if(!os)
-        {
-        alarum() << "Unable to write '" << file_name << "'." << LMI_FLUSH;
-        }
-}
-
 char const* CensusView::icon_xrc_resource() const
 {
     return "census_view_icon";
@@ -1419,7 +1354,8 @@ void CensusView::UponRightClick(wxDataViewEvent& e)
     global_settings const& g = global_settings::instance();
     if(contains(g.pyx(), "paste_out_to_spreadsheet"))
         {
-        paste_out_to_spreadsheet();
+        wxCommandEvent temporary_okay_in_code_to_be_erased_soon;
+        UponPasteCensusOut(temporary_okay_in_code_to_be_erased_soon);
         }
 }
 
@@ -1840,3 +1776,67 @@ void CensusView::UponPasteCensus(wxCommandEvent&)
     LMI_ASSERT(!class_parms().empty());
 }
 
+/// Paste from the census manager into a "spreadsheet" (TSV) file.
+///
+/// Include exactly those columns whose rows aren't all identical,
+/// considering as "rows" the individual cells--and also the case
+/// defaults, even though they aren't displayed in any row.
+///
+/// Motivation: Some census changes are more easily made by exporting
+/// data from lmi, manipulating it in a spreadsheet, and then pasting
+/// it back into lmi.
+///
+/// Never extract "UseDOB": it's always set by UponPasteCensus().
+/// Never extract "IssueAge". If it's present, then "UseDOB" must also
+/// be, and "UseDOB" preserves information that "IssueAge" loses.
+
+void CensusView::UponPasteCensusOut(wxCommandEvent&) const
+{
+    configurable_settings const& c = configurable_settings::instance();
+    std::string const& e = c.spreadsheet_file_extension();
+    std::string const  f = fs::basename(base_filename()) + "_pasted_out";
+    std::string file_name = unique_filepath(f, e).string();
+    std::ofstream os(file_name.c_str(), ios_out_app_binary());
+
+    std::vector<std::string> distinct_headers;
+    std::vector<std::string> const& 
all_headers(case_parms()[0].member_names());
+    for(auto const& header : all_headers)
+        {
+        if(column_value_varies_across_cells(header, cell_parms()))
+            {
+            if(header != "UseDOB" && header != "IssueAge")
+                {
+                distinct_headers.push_back(header);
+                }
+            }
+        }
+
+    for(auto const& header : distinct_headers)
+        {
+        // Assume that the trailing '\t' doesn't matter.
+        os << header << '\t';
+        }
+    os << '\n';
+
+    for(auto const& cell : cell_parms())
+        {
+        for(auto const& header : distinct_headers)
+            {
+            // Show calendar dates as YYYYMMDD rather than JDN.
+            std::string s = cell[header].str();
+            if(exact_cast<tnr_date>(cell[header]))
+                {
+                int z = JdnToYmd(jdn_t(value_cast<int>(s))).value();
+                s = value_cast<std::string>(z);
+                }
+            // Assume that the trailing '\t' doesn't matter.
+            os << s << '\t';
+            }
+        os << '\n';
+        }
+
+    if(!os)
+        {
+        alarum() << "Unable to write '" << file_name << "'." << LMI_FLUSH;
+        }
+}
diff --git a/census_view.hpp b/census_view.hpp
index 6f53d32..63e00fa 100644
--- a/census_view.hpp
+++ b/census_view.hpp
@@ -58,8 +58,6 @@ class CensusView final
 
     void update_visible_columns();
 
-    void paste_out_to_spreadsheet() const;
-
     CensusDocument& document() const;
 
     // ViewEx required implementation.
@@ -75,6 +73,7 @@ class CensusView final
     void UponColumnWidthVarying     (wxCommandEvent&);
     void UponColumnWidthFixed       (wxCommandEvent&);
     void UponPasteCensus            (wxCommandEvent&);
+    void UponPasteCensusOut         (wxCommandEvent&) const;
     void UponRightClick             (wxDataViewEvent&);
     void UponPrintCase              (wxCommandEvent&);
     void UponPrintCaseToDisk        (wxCommandEvent&);



reply via email to

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