summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-03-25 07:47:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-03-26 15:35:40 +0100
commitdd873175affb7926befb1b8a0a881540d00160df (patch)
tree47c1b2326dd7ba89ccf9d029b4da1d1a26eff343 /sw/source
parent2984dd49fb9fb2f8d3d56fba0db34a7b95666ce1 (diff)
try to use more reliable mechanism in AddLinkTarget
The commit that introduces this code says commit 89ffe6149a0e14bcde89d7981362aa1556849ab0 Author: Tünde Tóth <tundeth@gmail.com> Date: Wed Sep 18 10:13:50 2019 +0200 tdf#127605 DOCX export: fix internal hyperlinks to image target jumping to the paragraph anchored by the image as a workaround. But using the SwNodeIndex ring to do this only works by accident, there is no guarantee that the SwNodeIndex is organised in any way at all. Change-Id: I9f886522ddf83b6799da9dd3d1f27e4b6c44bdc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165264 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 72ed190b4ec2..b252e4d1533d 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -118,6 +118,7 @@
#include <iodetect.hxx>
#include <fmtwrapinfluenceonobjpos.hxx>
#include <officecfg/Office/Common.hxx>
+#include <fmtanchr.hxx>
using namespace css;
using namespace sw::util;
@@ -3280,8 +3281,11 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
{
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Grf))
- if (const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx())
- m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetNext()->GetIndex());
+ {
+ const SwFormatAnchor& rFormatAnchor = pFormat->GetAnchor();
+ if (SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode())
+ m_aImplicitBookmarks.emplace_back(aURL, pAnchorNode->GetIndex());
+ }
}
else if( sCmp == "frame" )
{
@@ -3294,8 +3298,11 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view rURL)
{
OUString aName(BookmarkToWriter(aURL.subView(0, nPos)));
if (const SwFlyFrameFormat* pFormat = m_rDoc.FindFlyByName(aName, SwNodeType::Ole))
- if (const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx())
- m_aImplicitBookmarks.emplace_back(aURL, pIdx->GetNext()->GetIndex());
+ {
+ const SwFormatAnchor& rFormatAnchor = pFormat->GetAnchor();
+ if (SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode())
+ m_aImplicitBookmarks.emplace_back(aURL, pAnchorNode->GetIndex());
+ }
}
else if( sCmp == "region" )
{