[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 554eb23 13/15: Forbid page breaks inside para
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 554eb23 13/15: Forbid page breaks inside paragraphs in the illustrations |
Date: |
Fri, 27 Jul 2018 17:23:17 -0400 (EDT) |
branch: master
commit 554eb236e26b37191d28bc2817a396d8f4e44399
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Forbid page breaks inside paragraphs in the illustrations
Define a custom handler for the standard HTML <p> tag and make all the
paragraphs "unbreakable", i.e. forbid page breaks inside them.
This results in better output quality, e.g. for the explanatory notes
pages where page breaks could occur in the middle of a paragraph before,
but not any longer.
---
ledger_pdf_generator_wx.cpp | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index b599a04..3b237a9 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1509,9 +1509,31 @@ TAG_HANDLER_BEGIN(numeric_summary_table,
"NUMERIC_SUMMARY_TABLE")
}
TAG_HANDLER_END(numeric_summary_table)
+// Custom handler for <p> tags preventing the page breaks inside them.
+TAG_HANDLER_BEGIN(unbreakable_paragraph, "P")
+ TAG_HANDLER_PROC(tag)
+ {
+ m_WParser->CloseContainer();
+ auto const container = m_WParser->OpenContainer();
+
+ // This is the reason for this handler existence: mark the container
+ // used for the paragraph contents as being unbreakable.
+ container->SetCanLiveOnPagebreak(false);
+
+ // This code reproduces what the standard "P" handler does.
+ // Unfortunately there is no way to just delegate to it from here.
+ container->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
+ container->SetAlign(tag);
+
+ // Don't stop parsing, continue with the tag contents.
+ return false;
+ }
+TAG_HANDLER_END(unbreakable_paragraph)
+
TAGS_MODULE_BEGIN(lmi_illustration)
TAGS_MODULE_ADD(scaled_image)
TAGS_MODULE_ADD(numeric_summary_table)
+ TAGS_MODULE_ADD(unbreakable_paragraph)
TAGS_MODULE_END(lmi_illustration)
// Numeric summary page is used on its own, as a regular page, but also as the
- [lmi-commits] [lmi] master updated (caaecd8 -> 12d84c9), Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 37e9b0b 01/15: Update to wxWidgets v3.1.1-319-g9daf5bec98 snapshot, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 6465704 04/15: Restore the use of wxDCClipper in PDF table generation code, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master a8d5e26 08/15: Look for image files referenced in templates under data directory, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 005b3eb 06/15: Replace pdf_writer_wx::get_page_height() with get_total_height(), Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 28e3c42 11/15: Remove workarounds for wx 3.1.1 warnings not relevant any more, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master b6b6827 03/15: Do call EndPage() in PDF generation code, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master a86d90a 02/15: Use more recent wxPdfDocument fixing the text origin bug, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 554eb23 13/15: Forbid page breaks inside paragraphs in the illustrations,
Greg Chicares <=
- [lmi-commits] [lmi] master 271db22 14/15: Fix over eager assert in pdf_writer_wx::output_html(), Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 12d84c9 15/15: Fix regression in font sizes used for the group quotes PDF, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 2bd38fa 12/15: Use standard <img> tag instead of <scaled_image> in templates, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master 4cfcfe4 07/15: Refactor: remove render_page_template() helper function, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master e821acd 05/15: Require specifying font sizes when using pdf_writer_wx, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master c56a67f 09/15: Implement and use simple HTML output pagination, Greg Chicares, 2018/07/27
- [lmi-commits] [lmi] master f03ff64 10/15: Merge first two notes pages of regular individual illustrations, Greg Chicares, 2018/07/27