[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 42525e9 5/7: Behave reasonably in unexpected
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 42525e9 5/7: Behave reasonably in unexpected circumstances |
Date: |
Thu, 11 Oct 2018 15:41:12 -0400 (EDT) |
branch: master
commit 42525e928e53992867da698391487a536ecb6f24
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Behave reasonably in unexpected circumstances
See:
https://lists.nongnu.org/archive/html/lmi/2018-10/msg00020.html
---
ledger_pdf_generator_wx.cpp | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 705aae9..4b035ec 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -454,17 +454,22 @@ static char const* const header_cell_id =
"_lmi_page_header_id";
TAG_HANDLER_BEGIN(page_header, "HEADER")
TAG_HANDLER_PROC(tag)
{
- // Although the header typically occurs at the very beginning of the
+ // As usual, reuse the current container if empty. That's unlikely:
+ // although the header typically occurs at the very beginning of the
// HTML template, it doesn't mean that the current container is empty,
// quite on the contrary, it typically isn't because it contains the
// cells setting the initial colors and font for the HTML body and we
// must not make these cells part of the header cell as otherwise they
// would be removed from the containing HTML document later and it
// would use default font instead of the one set by pdf_writer_wx.
- // So first, close the existing container and open a new one which we
- // will mark as being the actual header cell.
- m_WParser->CloseContainer();
- auto const container = m_WParser->OpenContainer();
+ auto container = m_WParser->GetContainer();
+ if (container->GetFirstChild())
+ {
+ // It isn't, so we need to open a new one, which we will mark as
+ // being the actual header cell.
+ m_WParser->CloseContainer();
+ container = m_WParser->OpenContainer();
+ }
// Set a unique ID for this container to allow finding it later.
container->SetId(header_cell_id);
- [lmi-commits] [lmi] master updated (9ec9f44 -> b9f72cb), Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 42525e9 5/7: Behave reasonably in unexpected circumstances,
Greg Chicares <=
- [lmi-commits] [lmi] master ebfdc8a 3/7: Replace wxDCFontChanger with dc_font_preserver, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 145965d 1/7: Fix initial font after detaching the header HTML cell, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 2f1464a 4/7: Improve concinnity, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 683f549 2/7: Move code manipulating wxHtmlCells into pdf_writer_wx, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 1cfcae9 6/7: Improve concinnity, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master b9f72cb 7/7: Improve const correctness, Greg Chicares, 2018/10/11