sw/source/core/text/EnhancedPDFExportHelper.cxx | 35 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-)
New commits: commit 38cff2a3096d7f5f4716e22a6a48ef8744e1ff19 Author: Georgy Litvinov <g...@litvinovg.pro> AuthorDate: Tue Jun 15 00:23:35 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 17 10:31:24 2021 +0200 tdf#38187 Create back link from footnote text to anchor in text Change-Id: I1ddf447975872a45447bfa86d050c886f4191962 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117205 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 736a2db98bbf7222bfec3dcff89999ccb71b576e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117298 Reviewed-by: Georgy Litvinov <g...@litvinovg.pro> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index f3d9e69ad51b..94014ae13c9a 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1977,27 +1977,50 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwPageFrame* pCurrPage = static_cast<const SwPageFrame*>( mrSh.GetLayout()->Lower() ); // Destination PageNum tools::Rectangle aRect = SwRectToPDFRect(pCurrPage, rDestRect.SVRect()); + // Back link rectangle calculation + const SwPageFrame* fnBodyPage = pCurrPage->getRootFrame()->GetPageByPageNum(nDestPageNum+1); + SwRect fnSymbolRect; + if (fnBodyPage->IsVertical()){ + tools::Long fnSymbolTop = fnBodyPage->GetTopMargin() + fnBodyPage->getFrameArea().Top(); + tools::Long symbolHeight = rDestRect.Top() - fnSymbolTop; + fnSymbolRect = SwRect(rDestRect.Pos().X(),fnSymbolTop,rDestRect.Width(),symbolHeight); + } else { + if (fnBodyPage->IsRightToLeft()){ + tools::Long fnSymbolRight = fnBodyPage->getFrameArea().Right() - fnBodyPage->GetRightMargin(); + tools::Long symbolWidth = fnSymbolRight - rDestRect.Right(); + fnSymbolRect = SwRect(rDestRect.Pos().X(),rDestRect.Pos().Y(),symbolWidth,rDestRect.Height()); + } else { + tools::Long fnSymbolLeft = fnBodyPage->GetLeftMargin() + fnBodyPage->getFrameArea().Left(); + tools::Long symbolWidth = rDestRect.Left() - fnSymbolLeft; + fnSymbolRect = SwRect(fnSymbolLeft,rDestRect.Pos().Y(),symbolWidth,rDestRect.Height()); + } + } + tools::Rectangle aFootnoteSymbolRect = SwRectToPDFRect(pCurrPage, fnSymbolRect.SVRect()); + + // Export back link + const sal_Int32 nBackLinkId = pPDFExtOutDevData->CreateLink(aFootnoteSymbolRect, nDestPageNum); // Destination Export const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(aRect, nDestPageNum); mrSh.GotoFootnoteAnchor(); - // Link PageNums sal_Int32 aLinkPageNum = CalcOutputPageNum( aLinkRect ); - pCurrPage = static_cast<const SwPageFrame*>( mrSh.GetLayout()->Lower() ); - // Link Export aRect = SwRectToPDFRect(pCurrPage, aLinkRect.SVRect()); const sal_Int32 nLinkId = pPDFExtOutDevData->CreateLink(aRect, aLinkPageNum); - + // Back link destination Export + const sal_Int32 nBackDestId = pPDFExtOutDevData->CreateDest(aRect, aLinkPageNum); // Store link info for tagged pdf output: const IdMapEntry aLinkEntry( aLinkRect, nLinkId ); s_aLinkIdMap.push_back( aLinkEntry ); - // Connect Link and Destination: + // Store backlink info for tagged pdf output: + const IdMapEntry aBackLinkEntry( aFootnoteSymbolRect, nBackLinkId ); + s_aLinkIdMap.push_back( aBackLinkEntry ); + // Connect Links and Destinations: pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId ); + pPDFExtOutDevData->SetLinkDest( nBackLinkId, nBackDestId ); } - } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits