summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Litvinov <git@litvinovg.pro>2021-06-15 00:23:35 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-06-16 15:07:08 +0200
commit736a2db98bbf7222bfec3dcff89999ccb71b576e (patch)
treecf18aceb0b1b850c80ac8705e46052c082b405b2
parentf283ec0bf68734558e903339f2f0d86633cc9a62 (diff)
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.stahl@allotropia.de>
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx35
1 files changed, 29 insertions, 6 deletions
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 );
}
-
}
}