diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-08-24 16:58:14 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-08-24 19:40:11 +0200 |
commit | 2e1ddc8aeb0a92cc43ef4b7dc4762cd50a6b7fbc (patch) | |
tree | cde18024bf78dd2d7de0c6aedd25ca83ca525e86 /sw | |
parent | 44c0f2da567b49ef8a539958a834f1bc841c2003 (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/layout/data/table-in-footnote.docx | bin | 0 -> 15684 bytes | |||
-rw-r--r-- | sw/qa/core/layout/flycnt.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/table-in-footnote.docx b/sw/qa/core/layout/data/table-in-footnote.docx Binary files differnew file mode 100644 index 000000000000..10e20ffbf44c --- /dev/null +++ b/sw/qa/core/layout/data/table-in-footnote.docx 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) |