summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-04-25 08:05:55 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-04-25 09:29:22 +0200
commit3c2e4d454aaabcd61593e670a90638a185046539 (patch)
tree5a49e16a0d4243edc9a110eba645b5932f9d3607
parentAdd some tests for (Japanese) i18n::IndexEntrySupplier behavior (diff)
downloadcore-3c2e4d454aaabcd61593e670a90638a185046539.tar.gz
core-3c2e4d454aaabcd61593e670a90638a185046539.zip
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
-rw-r--r--sw/qa/core/layout/data/floattable-in-text-section.docxbin0 -> 12452 bytes
-rw-r--r--sw/qa/core/layout/flycnt.cxx8
-rw-r--r--sw/source/core/layout/flycnt.cxx9
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
new file mode 100644
index 000000000000..5b377dd0379f
--- /dev/null
+++ b/sw/qa/core/layout/data/floattable-in-text-section.docx
Binary files differ
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();