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 924fb10b2a7a513b6626610e12ff3a5d21aa492a Author: Vojtěch Doležal <dolez...@cvut.cz> AuthorDate: Sat Dec 9 11:03:05 2023 +0100 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Wed Dec 13 20:27:18 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/+/160647 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> 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 c68a0fa99cbe..0c90549e844e 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"); } +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 17750dc4f038..e9a7363c37cf 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2722,7 +2722,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."); + } } }