summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-01-20 10:03:20 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-01-20 11:59:35 +0100
commit3d60ad8c67e347f56400e3be05a3f1641f77c719 (patch)
tree24631f9275c629a92046efb7032baa26be0e56ed
parentResolves: tdf#139974 Do not munge character after forced line break (diff)
downloadcore-3d60ad8c67e347f56400e3be05a3f1641f77c719.tar.gz
core-3d60ad8c67e347f56400e3be05a3f1641f77c719.zip
tdf#141340 PDF export: fix hyperlinks on the wrong page with page num range
Regression from commit 01dbb38680aa39a4d3bc7afd05d44a4b2c9bc6ab (tdf#61274 sd PDF export: fix links ending up on wrong pages with hidden slides, 2020-03-10), the problem was that the sd/ code that mapped page numbers between the model and the PDF output only handled hidden slides, but not partial exports. Fix this by revisiting the decision to handle hidden slides in sd/, the filter/ code at the end does have enough information to correctly do this mapping at the end, and this way both tdf#61274 and tdf#141340 can work at the same time. (cherry picked from commit 31bbaf478783e3a2c21bd3ea94ddf39299a63d1e) Change-Id: I5679743ca67fab562e14c73e32f1a06ead8e7a31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128647 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--filter/source/pdf/pdfexport.cxx12
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx8
-rw-r--r--vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odgbin0 -> 11175 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx26
4 files changed, 37 insertions, 9 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 43d2b97167fd..604326b4bdbf 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -220,6 +220,7 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
aMtf.Stop();
aMtf.WindStart();
+ bool bEmptyPage = false;
if( aMtf.GetActionSize() &&
( !mbSkipEmptyPages || aPageSize.Width || aPageSize.Height ) )
{
@@ -244,6 +245,10 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
ImplExportPage(rPDFWriter, rPDFExtOutDevData, aMtf);
bRet = true;
}
+ else
+ {
+ bEmptyPage = true;
+ }
pOut->Pop();
@@ -253,7 +258,12 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
*pFirstPage <<= false;
++mnProgressValue;
- ++nCurrentPage;
+ if (!bEmptyPage)
+ {
+ // Calculate the page number in the PDF output, which may be smaller than the page number in
+ // case of hidden slides or a partial export.
+ ++nCurrentPage;
+ }
}
}
else
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index e4b11eea33b5..5e6e374c3f80 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1897,14 +1897,6 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
!(pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
return;
- if (pPDFExtOutDevData)
- {
- // Calculate the page number in the PDF output, which may be smaller than the page number in
- // case of hidden slides.
- sal_Int32 nOutputPageNum = CalcOutputPageNum(pPDFExtOutDevData, mpDoc, nPageNumber);
- pPDFExtOutDevData->SetCurrentPageNumber(nOutputPageNum);
- }
-
::sd::ClientView aView( mpDocShell, pOut );
::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->GetSize() );
vcl::Region aRegion( aVisArea );
diff --git a/vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odg b/vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odg
new file mode 100644
index 000000000000..1fad913e0493
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odg
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ee2a7938d0d4..48398f11fc15 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -42,6 +42,7 @@
#include <unotools/streamwrap.hxx>
#include <vcl/filter/PDFiumLibrary.hxx>
+#include <comphelper/propertyvalue.hxx>
using namespace ::com::sun::star;
@@ -1965,6 +1966,31 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testLinkWrongPage)
CPPUNIT_ASSERT(!pPdfPage2->hasLinks());
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testLinkWrongPagePartial)
+{
+ // Given a Draw document with 3 pages, a link on the 2nd page:
+ // When exporting that the 2nd and 3rd page to pdf:
+ uno::Sequence<beans::PropertyValue> aFilterData = {
+ comphelper::makePropertyValue("PageRange", OUString("2-3")),
+ };
+ aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export");
+ aMediaDescriptor["FilterData"] <<= aFilterData;
+ saveAsPDF(u"link-wrong-page-partial.odg");
+
+ // Then make sure the we have a link on the 1st page, but not on the 2nd one:
+ std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport();
+ CPPUNIT_ASSERT(pPdfDocument);
+ CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
+ CPPUNIT_ASSERT(pPdfPage);
+ // Without the accompanying fix in place, this test would have failed, as the link was on the
+ // 2nd page instead.
+ CPPUNIT_ASSERT(pPdfPage->hasLinks());
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage2 = pPdfDocument->openPage(/*nIndex=*/1);
+ CPPUNIT_ASSERT(pPdfPage2);
+ CPPUNIT_ASSERT(!pPdfPage2->hasLinks());
+}
+
CPPUNIT_TEST_FIXTURE(PdfExportTest, testLargePage)
{
// Import the bugdoc and export as PDF.