diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-03-17 13:22:46 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-03-17 14:10:42 +0000 |
commit | 2f94534311e68d27c888628b4694a67a38bcfde5 (patch) | |
tree | bed707b5f5a8d2debcb8a4a32a03fbab3f985c34 | |
parent | d477fa8ac1b0d3ee81427217bbb5950278ab16db (diff) |
sw: fix crash on exporting forum-en-3524.odt to PDF
It turns out that the m_bFootnoteNum flag is no guarantee that there is
a SwFootnoteNumPortion, because if it has no width, it will be deleted
in SwLineLayout::CalcLine(); the flag indicates that this is the frame
which would contain the SwFootnoteNumPortion, which appears to be
checked in SwTextFrame::Prepare().
(regression from commit 92f7d3bfedc71bb0a91cf77b0263633c9d0f8d14)
Change-Id: I2f3ff70e6c2bb3379068b285cdd5fd52bc7cecf8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149053
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/source/core/text/EnhancedPDFExportHelper.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/frmpaint.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/porlay.hxx | 5 |
4 files changed, 9 insertions, 7 deletions
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index fa5f05bc6854..f7daeefa0ce6 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1100,7 +1100,7 @@ void SwTaggedPDFHelper::BeginNumberedListStructureElements() BeginTag( vcl::PDFWriter::ListItem, aListItemString ); assert(rTextFrame.GetPara()); // check whether to open LIBody now or delay until after Lbl - if (!rTextFrame.GetPara()->HasNumberingPortion()) + if (!rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering)) { BeginTag(vcl::PDFWriter::LIBody, aListBodyString); } @@ -1204,7 +1204,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() { SwTextFrame const& rTextFrame(*static_cast<const SwTextFrame*>(pFrame)); // lazy open LIBody after Lbl - if (rTextFrame.GetPara()->HasNumberingPortion()) + if (rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering)) { assert(!rTextFrame.IsFollow()); BeginTag(vcl::PDFWriter::LIBody, aListBodyString); diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index b04423b2f851..5f004b403916 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -683,7 +683,7 @@ void SwTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const& // Paragraph tag - if there is a list label, opening should be delayed. ::std::optional<SwTaggedPDFHelper> oTaggedParagraph; - if (IsFollow() || !(GetPara()->HasNumberingPortion() || GetPara()->IsFootnoteNum())) + if (IsFollow() || !GetPara()->HasNumberingPortion(SwParaPortion::FootnoteToo)) { // no Lbl needed => open paragraph tag now Frame_Info aFrameInfo(*this); oTaggedParagraph.emplace(nullptr, &aFrameInfo, nullptr, rRenderContext); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 7b66d17a2c9a..7535580aa9c5 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -2683,7 +2683,7 @@ TextFrameIndex SwParaPortion::GetParLen() const return nLen; } -bool SwParaPortion::HasNumberingPortion() const +bool SwParaPortion::HasNumberingPortion(FootnoteOrNot const eFootnote) const { SwLinePortion const* pPortion(nullptr); // the first line may contain only fly portion... @@ -2695,7 +2695,8 @@ bool SwParaPortion::HasNumberingPortion() const pPortion = pPortion->GetNextPortion(); } } - return pPortion && pPortion->InNumberGrp() && !pPortion->IsFootnoteNumPortion(); + return pPortion && pPortion->InNumberGrp() + && (eFootnote == SwParaPortion::FootnoteToo || !pPortion->IsFootnoteNumPortion()); } const SwDropPortion *SwParaPortion::FindDropPortion() const diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index 9a2da25517bd..5a824bdec5f6 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -268,7 +268,7 @@ class SwParaPortion : public SwLineLayout bool m_bFollowField : 1; // We have a bit of field left for the Follow bool m_bFixLineHeight : 1; // Fixed line height - bool m_bFootnoteNum : 1; // contains a footnotenumberportion + bool m_bFootnoteNum : 1; // is the frame that may contain a footnotenumberportion bool m_bMargin : 1; // contains a hanging punctuation in the margin public: @@ -319,7 +319,8 @@ public: bool IsFootnoteNum() const { return m_bFootnoteNum; } void SetMargin( const bool bNew = true ) { m_bMargin = bNew; } bool IsMargin() const { return m_bMargin; } - bool HasNumberingPortion() const; + enum FootnoteOrNot { OnlyNumbering, FootnoteToo }; + bool HasNumberingPortion(FootnoteOrNot) const; // Set nErgo in the QuoVadisPortion void SetErgoSumNum( const OUString &rErgo ); |