summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2022-12-04 09:36:54 -0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-12-08 08:01:58 +0000
commit7ed2502b7f67d2f349c5fb58703557cf310e7e14 (patch)
tree564ec9d4d52c741ffc16e6bdeca175f060b91893
parentdff93e6387172b208355bc5f1b82344ecce4d25d (diff)
tdf#152029 Bring hyperlinks to attention in document view
when mouse pointer is over hyperlink entry in the Navigator content tree Change-Id: I84693426277f2394f2c4b6f7bae5143bd1909285 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143636 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/uibase/inc/conttree.hxx2
-rw-r--r--sw/source/uibase/utlui/content.cxx59
2 files changed, 59 insertions, 2 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 77358b9edb30..6d2083f04480 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -33,6 +33,7 @@
#include <o3tl/typed_flags_set.hxx>
#include <svx/sdr/overlay/overlayobject.hxx>
+#include <editsh.hxx>
class SwWrtShell;
class SwContentType;
@@ -136,6 +137,7 @@ class SwContentTree final : public SfxListener
std::unique_ptr<sdr::overlay::OverlayObject> m_xOverlayObject;
void BringBookmarksToAttention(const std::vector<OUString>& rNames);
+ void BringURLFieldsToAttention(const SwGetINetAttrs& rINetAttrsArr);
/**
* Before any data will be deleted, the last active entry has to be found.
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index cb7f96ec3b23..3e581082c8e8 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1165,7 +1165,8 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
{
SwContent* pCnt = weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry));
const ContentTypeId nType = pCnt->GetParent()->GetType();
- bRemoveOverlayObject = nType != ContentTypeId::BOOKMARK;
+ bRemoveOverlayObject = nType != ContentTypeId::BOOKMARK &&
+ nType != ContentTypeId::URLFIELD;
if (!bRemoveOverlayObject &&
m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0)
{
@@ -1174,13 +1175,19 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
{
BringBookmarksToAttention(std::vector<OUString> {pCnt->GetName()});
}
+ else if (nType == ContentTypeId::URLFIELD)
+ {
+ BringURLFieldsToAttention(SwGetINetAttrs {SwGetINetAttr(pCnt->GetName(),
+ *static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr())});
+ }
}
}
else // content type entry
{
const ContentTypeId nType =
weld::fromId<SwContentType*>(m_xTreeView->get_id(*xEntry))->GetType();
- bRemoveOverlayObject = nType != ContentTypeId::BOOKMARK;
+ bRemoveOverlayObject = nType != ContentTypeId::BOOKMARK &&
+ nType != ContentTypeId::URLFIELD;
if (!bRemoveOverlayObject &&
m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0)
{
@@ -1198,6 +1205,12 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
BringBookmarksToAttention(aNames);
}
}
+ else if (nType == ContentTypeId::URLFIELD)
+ {
+ SwGetINetAttrs aINetAttrsArr;
+ m_pActiveShell->GetINetAttrs(aINetAttrsArr, false);
+ BringURLFieldsToAttention(aINetAttrsArr);
+ }
}
}
}
@@ -5577,4 +5590,46 @@ void SwContentTree::BringBookmarksToAttention(const std::vector<OUString>& rName
m_aOverlayObjectDelayTimer.Start();
}
+void SwContentTree::BringURLFieldsToAttention(const SwGetINetAttrs& rINetAttrsArr)
+{
+ std::vector<basegfx::B2DRange> aRanges;
+ for (const auto& r : rINetAttrsArr)
+ {
+ if (SwTextFrame* pFrame = static_cast<SwTextFrame*>(
+ r.rINetAttr.GetTextNode().getLayoutFrame(m_pActiveShell->GetLayout())))
+ {
+ SwRect aStartCharRect;
+ SwPosition aStartPos(r.rINetAttr.GetTextNode(), r.rINetAttr.GetStart());
+ pFrame->GetCharRect(aStartCharRect, aStartPos);
+ SwRect aEndCharRect;
+ SwPosition aEndPos(r.rINetAttr.GetTextNode(), r.rINetAttr.GetAnyEnd());
+ pFrame->GetCharRect(aEndCharRect, aEndPos);
+ if (aStartCharRect.Top() == aEndCharRect.Top())
+ {
+ // single line range
+ aRanges.emplace_back(aStartCharRect.Left(), aStartCharRect.Top(),
+ aEndCharRect.Right() + 1, aEndCharRect.Bottom() + 1);
+ }
+ else
+ {
+ // multi line range
+ SwRect aFrameRect = pFrame->getFrameArea();
+ aRanges.emplace_back(aStartCharRect.Left(), aStartCharRect.Top(),
+ aFrameRect.Right(), aStartCharRect.Bottom() + 1);
+ if (aStartCharRect.Bottom() + 1 != aEndCharRect.Top())
+ aRanges.emplace_back(aFrameRect.Left(), aStartCharRect.Bottom() + 1,
+ aFrameRect.Right(), aEndCharRect.Top() + 1);
+ aRanges.emplace_back(aFrameRect.Left(), aEndCharRect.Top() + 1,
+ aEndCharRect.Right() + 1, aEndCharRect.Bottom() + 1);
+ }
+ }
+ }
+ if (m_xOverlayObject && m_xOverlayObject->getOverlayManager())
+ m_xOverlayObject->getOverlayManager()->remove(*m_xOverlayObject);
+ m_xOverlayObject.reset(new sdr::overlay::OverlaySelection(sdr::overlay::OverlayType::Invert,
+ Color(), std::move(aRanges),
+ true /*unused for Invert type*/));
+ m_aOverlayObjectDelayTimer.Start();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */