sw/qa/core/layout/data/table-in-footnote.docx |binary sw/qa/core/layout/flycnt.cxx | 14 ++++++++++++++ sw/source/core/layout/fly.cxx | 6 ++++++ 3 files changed, 20 insertions(+)
New commits: commit 2e1ddc8aeb0a92cc43ef4b7dc4762cd50a6b7fbc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Aug 24 16:58:14 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Aug 24 19:40:11 2023 +0200 sw floattable: don't split if anchored inside a footnote See <https://gerrit.libreoffice.org/c/core/+/156025/1#message-94d8cdd4d59a4b991186e5780d41f213105a533d>, if we import an (inline) table inside a footnote from DOCX, we currently put that into an as-char anchored fly. In case the user would later change the anchor type to to-para, then we would crash in SwFlowFrame::GetPrevFrameForUpperSpaceCalc_(). Avoid all this trouble by simply not allowing split floating tables in footnotes, seeing that the Word UI is also disabled for this case. Change-Id: I3cf9461beb291084e1cced5c66ca14e6b6d55126 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156058 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/layout/data/table-in-footnote.docx b/sw/qa/core/layout/data/table-in-footnote.docx new file mode 100644 index 000000000000..10e20ffbf44c Binary files /dev/null and b/sw/qa/core/layout/data/table-in-footnote.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index ba688728743b..539d379d97c2 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -1010,6 +1010,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyIntoTable) // second part of a floating table into a table on the next page, not before that table. calcLayout(); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFromAsCharAnchor) +{ + // Given a document with a footnote that has a table (imported in an as-char anchored frame in + // Writer): + createSwDoc("table-in-footnote.docx"); + + // When changing the anchor type of that frame to to-para: + // Then make sure we don't crash: + selectShape(1); + // Without the accompanying fix in place, this test would have crashed, we tried to split a + // frame+table inside a footnote. + dispatchCommand(mxComponent, ".uno:SetAnchorToPara", {}); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index a06c2a9e7f70..039aeb549f77 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -687,6 +687,12 @@ bool SwFlyFrame::IsFlySplitAllowed() const return false; } + if (pFlyAnchor && pFlyAnchor->IsInFootnote()) + { + // No split in footnotes. + return false; + } + const SwFlyFrameFormat* pFormat = GetFormat(); const SwFormatVertOrient& rVertOrient = pFormat->GetVertOrient(); if (rVertOrient.GetVertOrient() == text::VertOrientation::BOTTOM)