lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master a86d90a 02/15: Use more recent wxPdfDocument


From: Greg Chicares
Subject: [lmi-commits] [lmi] master a86d90a 02/15: Use more recent wxPdfDocument fixing the text origin bug
Date: Fri, 27 Jul 2018 17:23:15 -0400 (EDT)

branch: master
commit a86d90ab39102fd6d796ccc34011514a23f274cb
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Use more recent wxPdfDocument fixing the text origin bug
    
    Upgrade to the latest master version (identified as v0.9.6-28-gf66b428
    by "git describe") of wxPdfDocument which includes the fix to the text
    origin bug in wxPdfDC which misinterpreted the vertical position passed
    to DrawText() method as being the text baseline instead of its
    upper-left corner, as it should have been taken according to wxDC API
    (see https://github.com/utelle/wxpdfdoc/pull/42 for more details).
    
    This requires slightly updating the makefile building the library, as
    its build system has changed in the meanwhile; and also updating all the
    code which used to work around the now fixed bug and doesn't have to do
    it any longer: we can now remove the different workarounds that were
    used previously for positioning text correctly, notably the hack with
    using an extra row in an HTML table in group quotes generation code.
---
 group_quote_pdf_gen_wx.cpp  | 10 ----------
 install_wxpdfdoc.make       |  9 +++++----
 ledger_pdf_generator_wx.cpp | 18 +++++++++---------
 wx_table_generator.cpp      |  7 +++----
 4 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index e2e4fce..37a737a 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -1001,16 +1001,6 @@ void group_quote_pdf_generator_wx::output_document_header
         tag::table[attr::width("100%")]
                   [attr::cellspacing("0")]
                   [attr::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
-            // not as its top, as it ought to, so without this line
-            // the rectangle drawn below wouldn't contain the header.
-            (tag::tr
-                (tag::td[attr::align("center")][attr::colspan("4")]
-                    (text::nbsp())
-                )
-            )
             (tag::tr
                 (tag::td[attr::align("center")][attr::colspan("4")]
                     (tag::font[attr::size("+1")]
diff --git a/install_wxpdfdoc.make b/install_wxpdfdoc.make
index 9ea6783..d0f18ae 100644
--- a/install_wxpdfdoc.make
+++ b/install_wxpdfdoc.make
@@ -38,12 +38,12 @@ wxpdfdoc_dir  := /opt/lmi/wxpdfdoc-scratch
 # archive name because we don't want to use the bare commit SHA-1 as the file
 # name, so we need a separate "urlbase" variable.
 
-wxpdfdoc_commit             := 5ac28a73e74916cf44d0ce286976e21d948e9bd8
+wxpdfdoc_commit             := f66b42805a7262cdf07ab04a4e20b252b5d81ddb
 wxpdfdoc_archive            := wxpdfdoc-$(wxpdfdoc_commit).zip
 $(wxpdfdoc_archive)-urlbase := $(wxpdfdoc_commit).zip
 $(wxpdfdoc_archive)-root    := https://github.com/vadz/wxpdfdoc/archive
 $(wxpdfdoc_archive)-url     := 
$($(wxpdfdoc_archive)-root)/$($(wxpdfdoc_archive)-urlbase)
-$(wxpdfdoc_archive)-md5     := 8e3c4d6cd1df9c7f91426c8c4723cb6e
+$(wxpdfdoc_archive)-md5     := 150e34e93845de586d5c8ef3e4b4e6ff
 
 # Variables that normally should be left alone 
#################################
 
@@ -60,7 +60,7 @@ endif
 
 compiler         := gcc-$(shell $(mingw_bin_dir)$(host_type)-gcc -dumpversion)
 
-wxpdfdoc_version := 0.9.4
+wxpdfdoc_version := v0.9.6-28-gf66b428
 source_dir       := $(wxpdfdoc_dir)/wxPdfDoc-$(wxpdfdoc_version)
 
 wx_cc_flags      := -fno-omit-frame-pointer
@@ -115,8 +115,9 @@ WGETFLAGS :=
 wxpdfdoc: $(wxpdfdoc_archive)
        cd $(source_dir) \
          && export PATH="$(mingw_bin_dir):${PATH}" \
+         && autoreconf \
          && ./configure $(config_options) \
-         && $(MAKE) install_pdfdoc_dll install_pdfdoc_dll_headers \
+         && $(MAKE) install \
 
 .PHONY: clobber_exec_prefix_only
 clobber_exec_prefix_only:
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index cb5e59b..4bc2e20 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1354,7 +1354,6 @@ class numeric_summary_table_cell
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_guar_account_value
             ,column_separator_guar_non_guar
@@ -1367,6 +1366,7 @@ class numeric_summary_table_cell
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
 
         pos_y_copy = pos_y;
         table_gen.output_super_header
@@ -1385,7 +1385,6 @@ class numeric_summary_table_cell
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_mid_account_value
             ,column_separator_mid_curr
@@ -1399,11 +1398,12 @@ class numeric_summary_table_cell
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
 
         table_gen.output_headers(pos_y, output_mode);
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator(0, column_max, pos_y, output_mode);
+        pos_y += table_gen.separator_line_height();
 
         // And now the table values themselves.
         auto const& columns = get_table_columns();
@@ -1671,9 +1671,9 @@ class page_with_tabular_report
 
         table_gen.output_headers(pos_y, output_mode);
 
-        pos_y += table_gen.separator_line_height();
         auto const ncols = get_table_columns().size();
         table_gen.output_horz_separator(0, ncols, pos_y, output_mode);
+        pos_y += table_gen.separator_line_height();
 
         return pos_y;
     }
@@ -1775,7 +1775,6 @@ class ill_reg_tabular_detail_page : public 
page_with_tabular_report
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_guar_account_value
             ,column_dummy_separator
@@ -1788,6 +1787,7 @@ class ill_reg_tabular_detail_page : public 
page_with_tabular_report
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
     }
 
     illustration_table_columns const& get_table_columns() const override
@@ -2183,7 +2183,6 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_guar0_cash_surr_value
             ,column_separator_guar_curr0
@@ -2196,6 +2195,7 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
 
         // Output the second super header row which is composed of three
         // physical lines.
@@ -2226,13 +2226,13 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
                     ,output_mode
                     );
 
-                y += table_gen.separator_line_height();
                 table_gen.output_horz_separator
                     (begin_column
                     ,end_column
                     ,y
                     ,output_mode
                     );
+                y += table_gen.separator_line_height();
 
                 return y;
             };
@@ -2644,7 +2644,6 @@ class reg_d_individual_irr_base : public 
page_with_tabular_report
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_zero_cash_surr_value
             ,column_zero_irr_surr_value
@@ -2657,6 +2656,7 @@ class reg_d_individual_irr_base : public 
page_with_tabular_report
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
     }
 };
 
@@ -2793,13 +2793,13 @@ class reg_d_individual_curr : public 
page_with_tabular_report
             ,output_mode
             );
 
-        pos_y += table_gen.separator_line_height();
         table_gen.output_horz_separator
             (column_curr_investment_income
             ,column_max
             ,pos_y
             ,output_mode
             );
+        pos_y += table_gen.separator_line_height();
     }
 };
 
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 59c5569..9d745e8 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -328,13 +328,12 @@ int wx_table_generator::separator_line_height() const
 /// Rectangle corresponding to a cell's text contents.
 ///
 /// This is narrower than the full cell rectangle to leave a small
-/// margin. Its vertical position is adjusted so that it can be
-/// passed directly to wxDC::DrawLabel().
+/// margin. Its vertical position is adjusted to center the text vertically.
 
 wxRect wx_table_generator::text_rect(std::size_t column, int y) const
 {
     wxRect z = cell_rect(column, y).Deflate(dc().GetCharWidth(), 0);
-    z.Offset(0, char_height_);
+    z.Offset(0, (row_height_ - char_height_)/2);
     return z;
 }
 
@@ -424,7 +423,7 @@ void wx_table_generator::do_output_single_row
 {
     int const y_top = pos_y;
 
-    int const y_text = pos_y + char_height_;
+    int const y_text = text_rect(0, pos_y).y;
     pos_y += row_height_;
 
     if(draw_separators_)



reply via email to

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