lmi
[Top][All Lists]
Advanced

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

Re: [lmi] First version of the illustrations pagination patch


From: Vadim Zeitlin
Subject: Re: [lmi] First version of the illustrations pagination patch
Date: Sat, 21 Jul 2018 19:38:09 +0200

On Tue, 17 Jul 2018 21:14:46 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2018-06-23 21:35, Vadim Zeitlin wrote:
GC> > 
GC> >  Here is the long-promised version of the pagination patch:
GC> > 
GC> >           https://github.com/vadz/lmi/pull/86
GC> 
GC> To reproduce an anomaly with HEAD + PR 86:
GC> 
GC>   File | New | Census
GC>   Census | Edit case defaults...
GC>     change corporation name to any nonempty string
GC>     [otherwise group quotes are forbidden]
GC>   OK
GC>   Yes to apply...
GC>   Census | Print group premium quote to PDF
GC> 
GC> Assertion 'height <= get_total_height() - y' failed.

 Sorry for the delay with the answer, the fix is indeed as trivial as I
thought initially and consists in just disabling the assert, but it took me
some time to verify that it was really the case.

 Here is the diff for the proposed fix:
---------------------------------- >8 --------------------------------------
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index 5e6903d31..4fd7c0352 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -304,9 +304,20 @@ void pdf_writer_wx::next_page()
         ,output_mode
         );
 
-    // Should have fit on this page, otherwise this is not the right overload
-    // to use -- call paginate_html() and the generic overload above instead.
-    LMI_ASSERT(height <= get_total_height() - y);
+    switch(output_mode)
+        {
+        case oe_render:
+            // When rendering, all the text should have fit on this page,
+            // otherwise this is not the right overload to use -- call
+            // paginate_html() and the generic overload above instead.
+            LMI_ASSERT(height <= get_total_height() - y);
+            break;
+        case oe_only_measure:
+            // It's fine if the output doesn't fit when measuring it, as this
+            // could be used to decide whether another page is needed or not,
+            // so don't do anything here.
+            break;
+        }
 
     return height;
 }
---------------------------------- >8 --------------------------------------

 As you can see, it basically disables the assertion when the text is being
measured and not rendered, as the group quotes code calls this function
with oe_only_measure to implement its own, special case, pagination logic.

 I thought about changing the group quotes to use paginate_html() but I
couldn't see any benefits in doing this, it would make that code more
complicated without improving anything for the illustrations generation.

GC> Note that I've copied 'company_logo.*' and 'group_quote_banner.png'
GC> from /opt/lmi/src/lmi/gwc/ to /opt/lmi/bin/ where lmi_wx_shared$EXEEXT
GC> resides. That might be a precondition for reproducing the anomaly;
GC> but those image files have worked in the past.

 Yes, this is indeed required to reproduce the problem, as bigger than
default images must be used to push off the footer to the next page. But
this is something that the group quotes code handles and the only problem
was this over eager assert.

 Thanks for finding it and I hope you find the fix above acceptable -- but
please let me know if you'd like to do something different.

VZ


reply via email to

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