lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master dbaf3c4 048/156: Render PDF illustrations in


From: Greg Chicares
Subject: [lmi-commits] [lmi] master dbaf3c4 048/156: Render PDF illustrations in two passes
Date: Tue, 30 Jan 2018 17:22:07 -0500 (EST)

branch: master
commit dbaf3c44f49776c32b3e3c2bb92a03dc4d1241f2
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Render PDF illustrations in two passes
    
    Single pass rendering doesn't work for the logical pages that need to
    dynamically determine how many physical pages their contents will take,
    so prepare for implementing this by adding a new pre_render() method and
    calling it for all pages before calling render() itself.
---
 ledger_pdf_generator_wx.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 6027aa3..bade62d 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -254,6 +254,24 @@ class page
     // virtual dtor, if only to avoid gcc warnings about not having it.
     virtual ~page() = default;
 
+    // Called before rendering any pages to prepare for doing this, e.g. by
+    // computing the number of pages needed.
+    //
+    // This method must not draw anything on the wxDC, it is provided only for
+    // measurement purposes.
+    virtual void pre_render
+        (Ledger const& ledger
+        ,pdf_writer_wx& writer
+        ,wxDC& dc
+        ,html_interpolator const& interpolate_html
+        )
+    {
+        stifle_warning_for_unused_value(ledger);
+        stifle_warning_for_unused_value(writer);
+        stifle_warning_for_unused_value(dc);
+        stifle_warning_for_unused_value(interpolate_html);
+    }
+
     // Render this page contents.
     virtual void render
         (Ledger const& ledger
@@ -288,6 +306,11 @@ class pdf_illustration : protected html_interpolator
     // Render all pages.
     void render_all()
     {
+        for(auto const& page : pages_)
+            {
+            page->pre_render(ledger_, writer_, dc_, *this);
+            }
+
         bool first = true;
         for(auto const& page : pages_)
             {



reply via email to

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