sw/qa/extras/ooxmlexport/data/tdf154481.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 5 +++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 9 +++++++++ 3 files changed, 14 insertions(+)
New commits: commit 4304ac507781a258c8e72390a90a9672b840546a Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Thu Apr 6 13:34:42 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Apr 18 19:30:46 2023 +0200 tdf#154481 sw DOCX import: fix page loss and freezing at ODT export Disable TOC creation in case when field context stack is empty but TOC creation is in progress in textboxes. Before if TOC creation failed because it is already existed, the TOC creation member (mbStartTOC) kept true resulting in broken textbox handling. Textbox and TOC import use the same text append stack but the TOC was not removed from the stack so content have been written into the TOC instead of the textbox, resulting page loss, and because of the broken structure, freezing at further ODT export. Change-Id: If27aa477c49f276d4e538b6e125798d89f0ac423 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150099 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 94de79e7d3c980b576192d2f264bee658716163a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150319 Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf154481.docx b/sw/qa/extras/ooxmlexport/data/tdf154481.docx new file mode 100644 index 000000000000..bfbfeda7687a Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf154481.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 0ff6256fc3b8..11bbfa86541b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -988,6 +988,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf154481, "tdf154481.docx") +{ + CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing pages!", 7, getPages()); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf149200) { loadAndSave("tdf149200.docx"); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index d422240348d5..ae0a8a27da12 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4906,6 +4906,15 @@ void DomainMapper_Impl::PushTextBoxContent() if (m_bIsInTextBox) return; + // tdf#154481: check for TOC creation with empty field stack, + // and close TOC, unless pages will lost. FIXME. + if (IsInTOC() && m_aFieldStack.size() == 0) + { + m_bStartTOC = false; + SAL_WARN("writerfilter.dmapper", + "broken TOC creation in textbox, but field stack is empty, so closing TOC!"); + } + try { uno::Reference<text::XTextFrame> xTBoxFrame(