From 51d1952cf05381a48e6b0797d5e001452181b1ec Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Sat, 12 Jun 2021 15:01:48 +0200 Subject: tdf#142741 and tdf#38187 Set valid pages for footnote links PDF export. Change-Id: I7c00e1a522a51796c9f543a74bd8abcee6792faf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117078 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/text/EnhancedPDFExportHelper.cxx | 38 +++++++++++-------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 258c0313b981..f3d9e69ad51b 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1969,39 +1969,35 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // Goto footnote text: if ( mrSh.GotoFootnoteText() ) { - // Link PageNums - std::vector aLinkPageNums = CalcOutputPageNums( aLinkRect ); - // Destination Rectangle const SwRect& rDestRect = mrSh.GetCharRect(); + const sal_Int32 nDestPageNum = CalcOutputPageNum( rDestRect ); + if ( -1 != nDestPageNum ) + { + const SwPageFrame* pCurrPage = static_cast( mrSh.GetLayout()->Lower() ); + // Destination PageNum + tools::Rectangle aRect = SwRectToPDFRect(pCurrPage, rDestRect.SVRect()); + // Destination Export + const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(aRect, nDestPageNum); + mrSh.GotoFootnoteAnchor(); - const SwPageFrame* pCurrPage = - static_cast( mrSh.GetLayout()->Lower() ); + // Link PageNums + sal_Int32 aLinkPageNum = CalcOutputPageNum( aLinkRect ); - // Destination PageNum - const sal_Int32 nDestPageNum = CalcOutputPageNum( rDestRect ); + pCurrPage = static_cast( mrSh.GetLayout()->Lower() ); - for (sal_Int32 aLinkPageNum : aLinkPageNums) - { // Link Export - tools::Rectangle aRect(SwRectToPDFRect(pCurrPage, aLinkRect.SVRect())); - const sal_Int32 nLinkId = - pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum); + aRect = SwRectToPDFRect(pCurrPage, aLinkRect.SVRect()); + const sal_Int32 nLinkId = pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum); // Store link info for tagged pdf output: const IdMapEntry aLinkEntry( aLinkRect, nLinkId ); s_aLinkIdMap.push_back( aLinkEntry ); - if ( -1 != nDestPageNum ) - { - aRect = SwRectToPDFRect(pCurrPage, rDestRect.SVRect()); - // Destination Export - const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(rDestRect.SVRect(), nDestPageNum); - - // Connect Link and Destination: - pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId ); - } + // Connect Link and Destination: + pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId ); } + } } -- cgit v1.2.3