diff options
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 8 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odg | bin | 0 -> 11175 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 26 |
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 Binary files differnew file mode 100644 index 000000000000..1fad913e0493 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/link-wrong-page-partial.odg 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. |