sw/qa/extras/ooxmlexport/data/tdf154481.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx        |    6 ++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    9 +++++++++
 3 files changed, 15 insertions(+)

New commits:
commit 9d4cb8c356c0f83c81dc8e96b3e96e3c009a19f6
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: Thu Apr 13 22:54:54 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 94d6e1d9b30aee7ec78de3b4a4a208701b2a4976)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150318
    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 7b31df3395cf..ebb5ae15a87e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -1077,6 +1077,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx")
     }
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf154481)
+{
+    createSwDoc("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 3b774608756a..ac080656a98a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5046,6 +5046,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(

Reply via email to