diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-04-25 08:05:55 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-04-25 09:29:22 +0200 |
commit | 3c2e4d454aaabcd61593e670a90638a185046539 (patch) | |
tree | 5a49e16a0d4243edc9a110eba645b5932f9d3607 /sw | |
parent | c9b6bf655e6de50c55629b4805399932c90a3b30 (diff) |
sw floattable, crashtesting: fix PDF export of fdo72790-1.docx, part 1
Converting the bugdoc to PDF crashed Writer layout since commit
ce3308a926f036b87515b8cd97d2b197063dc77a (tdf#61594 sw floattable:
import floating tables as split flys by default, 2023-04-12).
What happens is that the DOCX file has a continuous section break, that
is mapped to a Writer section, but then the fly splitting code didn't
expect that the anchor might be inside a section frame.
Fix this by explicitly checking for an in-section anchor in
SwFrame::GetNextFlyLeaf(), which will give us a suitable insertion point
on the next page.
This does not fully fix the handling of the bugdoc, but at least now a
reduced sample doesn't crash and is handled correctly.
Change-Id: I52b5c901d899533bbb78131f443789d55db41000
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150956
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/layout/data/floattable-in-text-section.docx | bin | 0 -> 12452 bytes | |||
-rw-r--r-- | sw/qa/core/layout/flycnt.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/layout/flycnt.cxx | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/sw/qa/core/layout/data/floattable-in-text-section.docx b/sw/qa/core/layout/data/floattable-in-text-section.docx Binary files differnew file mode 100644 index 000000000000..5b377dd0379f --- /dev/null +++ b/sw/qa/core/layout/data/floattable-in-text-section.docx diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 0bdd70ceb511..b23edb72ef16 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -699,6 +699,14 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyThenTable) // This crashed, due to a stack overflow in layout code. save("writer_pdf_Export"); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTextSection) +{ + // The document contains a DOCX cont sect break, which is mapped to a TextSection. + // This crashed, the anchor was split directly, so the follow anchor was moved outside the + // section frame, which is broken. + createSwDoc("floattable-in-text-section.docx"); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index f5d4c76c936f..ca7ae9d28626 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1558,7 +1558,14 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) bool bBody = pFlyAnchor && pFlyAnchor->IsInDocBody(); SwLayoutFrame *pLayLeaf = nullptr; // Look up the first candidate. - if (IsTabFrame()) + SwSectionFrame* pFlyAnchorSection = pFlyAnchor ? pFlyAnchor->FindSctFrame() : nullptr; + if (pFlyAnchorSection) + { + // We can't just move the split anchor to the next page, that would be outside the section. + // Rather split that section as well. + pLayLeaf = pFlyAnchorSection->GetNextSctLeaf(eMakePage); + } + else if (IsTabFrame()) { // If we're in a table, try to find the next frame of the table's last content. SwFrame* pContent = static_cast<SwTabFrame*>(this)->FindLastContentOrTable(); |