sw/qa/core/text/data/tdf158505.odt              |binary
 sw/qa/core/text/text.cxx                        |   12 ++++++++++++
 sw/source/core/text/EnhancedPDFExportHelper.cxx |    5 ++++-
 sw/source/uibase/shells/textidx.cxx             |    6 ++++++
 4 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 347e8161ba38822de96851dd7ed92b7e85ac1943
Author:     Vojtěch Doležal <dolez...@cvut.cz>
AuthorDate: Sat Dec 9 11:03:05 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Dec 14 09:44:14 2023 +0100

    tdf#158505 - Fix PDF export when bibliography is last paragraph
    
    Change-Id: Iadafff97ba19d5c24be768238bddb4d684edde1c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160509
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 94d18ea557a03c1f2d450454908787f7d3af8a6e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160646
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/core/text/data/tdf158505.odt 
b/sw/qa/core/text/data/tdf158505.odt
new file mode 100644
index 000000000000..c9a71033a2de
Binary files /dev/null and b/sw/qa/core/text/data/tdf158505.odt differ
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 7340a151d1f4..666e6d29f250 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -103,6 +103,18 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testSemiTransparentText)
     assertXPath(pXmlDoc, "//floattransparent"_ostr);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLastBibliographyPdfExport)
+{
+    // Given a document with a bibliography as the last paragraph:
+    createSwDoc("tdf158505.odt");
+
+    // It should be possible to export to PDF:
+    save("writer_pdf_Export");
+
+    // Without the accompanying fix, the export to PDF would get stuck in an 
infinite loop
+    CPPUNIT_ASSERT(true);
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport)
 {
     // Given a document with a bibliography entry field:
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 2bf5ca3f883d..499dcc24178a 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -2825,7 +2825,10 @@ void 
SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks()
                         }
                     }
                 }
-                mrSh.MovePara(GoNextPara, fnParaStart);
+                if (!mrSh.MovePara(GoNextPara, fnParaStart))
+                { // Cursor is stuck in the TOX due to document ending 
immediately afterwards
+                    break;
+                }
             }
         }
     }
diff --git a/sw/source/uibase/shells/textidx.cxx 
b/sw/source/uibase/shells/textidx.cxx
index 45d9df2c70b6..35642a73f198 100644
--- a/sw/source/uibase/shells/textidx.cxx
+++ b/sw/source/uibase/shells/textidx.cxx
@@ -127,6 +127,12 @@ void SwTextShell::ExecIdx(SfxRequest const &rReq)
                         
rShell.GetCursor_()->GetPoint()->Assign(*pTableRowNode);
                         rShell.UpdateTableOf(*pCurrentTOX);
                     }
+                    else
+                    {
+                        // I think this ideally should be a pop-up warning, 
right?
+                        SAL_WARN("sw", "No matching bibliography mark found. "
+                                        "This feature is only guaranteed to 
work if the bibliography table is up to date.");
+                    }
                 }
             }
 

Reply via email to