lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/pagination 1f1e5f9 2/3: Move a class still under


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/pagination 1f1e5f9 2/3: Move a class still under development out of a unit test
Date: Wed, 12 Sep 2018 19:48:17 -0400 (EDT)

branch: odd/pagination
commit 1f1e5f9909eb61b1d4b437ad388608ff0dfa4bff
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Move a class still under development out of a unit test
    
    Moved class paginate in order to use it to produce illustration PDFs.
---
 report_table.cpp      | 45 +++++++++++++++++++++++++++++
 report_table.hpp      | 35 +++++++++++++++++++++++
 report_table_test.cpp | 78 ---------------------------------------------------
 3 files changed, 80 insertions(+), 78 deletions(-)

diff --git a/report_table.cpp b/report_table.cpp
index 9a8e76e..789ec78 100644
--- a/report_table.cpp
+++ b/report_table.cpp
@@ -236,3 +236,48 @@ paginator::paginator(int total_rows, int rows_per_group, 
int max_lines_per_page)
         page_count_ = 1;
         }
 }
+
+int paginate::init(int total_rows, int rows_per_group, int max_lines_per_page)
+{
+    total_rows_         = total_rows        ;
+    rows_per_group_     = rows_per_group    ;
+
+    paginator p(total_rows, rows_per_group, max_lines_per_page);
+    lines_on_full_page_ = p.lines_on_full_page();
+    lines_on_last_page_ = p.lines_on_last_page();
+    page_count_         = p.page_count();
+
+    return page_count_;
+}
+
+void paginate::print() const
+{
+    prelude();
+    int row = 0;
+    int line_count = 0;
+    for(int page = 0; page < page_count(); ++page)
+        {
+        int const max_lines =
+            ((page_count() - 1) == page)
+            ? lines_on_last_page()
+            : lines_on_full_page()
+            ;
+        open_page();
+        for(int line = 0; line < max_lines; ++line)
+            {
+            if(rows_per_group() != line % (1 + rows_per_group()))
+                {
+                print_a_data_row();
+                ++row;
+                }
+            else
+                {
+                print_a_separator();
+                }
+            ++line_count;
+            }
+        close_page();
+        }
+    postlude();
+    LMI_ASSERT(total_rows() == row);
+}
diff --git a/report_table.hpp b/report_table.hpp
index cf768d5..117188f 100644
--- a/report_table.hpp
+++ b/report_table.hpp
@@ -169,4 +169,39 @@ class LMI_SO paginator
     int       page_count_;
 };
 
+// PDF !! A work in progress.
+
+class LMI_SO paginate
+{
+  public:
+    paginate() {}
+
+    int init(int total_rows, int rows_per_group, int max_lines_per_page);
+    void print() const;
+
+  private:
+    virtual void prelude          () const = 0;
+    virtual void open_page        () const = 0;
+    virtual void print_a_data_row () const = 0;
+    virtual void print_a_separator() const = 0;
+    virtual void close_page       () const = 0;
+    virtual void postlude         () const = 0;
+
+    int total_rows        () const {return total_rows_        ;}
+    int rows_per_group    () const {return rows_per_group_    ;}
+
+    int lines_on_full_page() const {return lines_on_full_page_;}
+    int lines_on_last_page() const {return lines_on_last_page_;}
+    int page_count        () const {return page_count_        ;}
+
+    // init() arguments.
+    int total_rows_         {};
+    int rows_per_group_     {};
+
+    // init() results.
+    int lines_on_full_page_ {};
+    int lines_on_last_page_ {};
+    int page_count_         {};
+};
+
 #endif // report_table_hpp
diff --git a/report_table_test.cpp b/report_table_test.cpp
index c76312c..cd6b369 100644
--- a/report_table_test.cpp
+++ b/report_table_test.cpp
@@ -401,84 +401,6 @@ void 
report_table_test::test_column_widths_for_illustrations()
     }
 }
 
-class paginate
-{
-  public:
-    paginate() {}
-
-    int init(int total_rows, int rows_per_group, int max_lines_per_page);
-    void print() const;
-
-  private:
-    virtual void prelude          () const = 0;
-    virtual void open_page        () const = 0;
-    virtual void print_a_data_row () const = 0;
-    virtual void print_a_separator() const = 0;
-    virtual void close_page       () const = 0;
-    virtual void postlude         () const = 0;
-
-    int total_rows        () const {return total_rows_        ;}
-    int rows_per_group    () const {return rows_per_group_    ;}
-
-    int lines_on_full_page() const {return lines_on_full_page_;}
-    int lines_on_last_page() const {return lines_on_last_page_;}
-    int page_count        () const {return page_count_        ;}
-
-    // init() arguments.
-    int total_rows_         {};
-    int rows_per_group_     {};
-
-    // init() results.
-    int lines_on_full_page_ {};
-    int lines_on_last_page_ {};
-    int page_count_         {};
-};
-
-int paginate::init(int total_rows, int rows_per_group, int max_lines_per_page)
-{
-    total_rows_         = total_rows        ;
-    rows_per_group_     = rows_per_group    ;
-
-    paginator p(total_rows, rows_per_group, max_lines_per_page);
-    lines_on_full_page_ = p.lines_on_full_page();
-    lines_on_last_page_ = p.lines_on_last_page();
-    page_count_         = p.page_count();
-
-    return page_count_;
-}
-
-void paginate::print() const
-{
-    prelude();
-    int row = 0;
-    int line_count = 0;
-    for(int page = 0; page < page_count(); ++page)
-        {
-        int const max_lines =
-            ((page_count() - 1) == page)
-            ? lines_on_last_page()
-            : lines_on_full_page()
-            ;
-        open_page();
-        for(int line = 0; line < max_lines; ++line)
-            {
-            if(rows_per_group() != line % (1 + rows_per_group()))
-                {
-                print_a_data_row();
-                ++row;
-                }
-            else
-                {
-                print_a_separator();
-                }
-            ++line_count;
-            }
-        close_page();
-        }
-    postlude();
-    LMI_ASSERT(total_rows() == row);
-}
-
 class paginate_demo : public paginate
 {
   public:



reply via email to

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