summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2022-12-08 18:58:59 -0900
committerJim Raykowski <raykowj@gmail.com>2022-12-09 06:40:30 +0000
commit11b87e7601fd24eb290854e9642bf01d0b4592ff (patch)
treeac1f15e746e695efee896a3d69ac0abf23d9e4df /sw
parent95a3d7733c5b48c99b2b74b06c7eeee718fdcd03 (diff)
tdf#152029 Bring drawing objects to attention in the document view
when mouse pointer is over drawing object entry in the Navigator content tree Change-Id: Idfeeb3854ffe76745f2f30a6ffac8528b2dda725 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143844 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/inc/conttree.hxx1
-rw-r--r--sw/source/uibase/utlui/content.cxx97
2 files changed, 71 insertions, 27 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 03f331c2584f..5a9ef1a9322e 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -141,6 +141,7 @@ class SwContentTree final : public SfxListener
void BringBookmarksToAttention(const std::vector<OUString>& rNames);
void BringURLFieldsToAttention(const SwGetINetAttrs& rINetAttrsArr);
void BringReferencesToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr);
+ void BringDrawingObjectsToAttention(std::vector<const SdrObject*>& rDrawingObjectsArr);
void BringTextFieldsToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr);
/**
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 1033c63c84e3..dbed1715e32d 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1152,26 +1152,35 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
// initialize the compare entry iterator with the first tree entry iterator
if (!m_xOverlayCompareEntry && !m_xTreeView->get_iter_first(*m_xOverlayCompareEntry))
return false;
- bool bRemoveOverlayObject = false;
if (rMEvt.IsLeaveWindow())
{
- bRemoveOverlayObject = true;
+ m_aOverlayObjectDelayTimer.Stop();
+ if (m_xOverlayObject && m_xOverlayObject->getOverlayManager())
+ {
+ m_xOverlayObject->getOverlayManager()->remove(*m_xOverlayObject);
+ m_xOverlayObject.reset();
+ }
}
else if (std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
m_xTreeView->get_dest_row_at_pos(rMEvt.GetPosPixel(), xEntry.get(), false, false))
{
+ // Remove the overlay object if the pointer is over a different entry than the last time
+ // it was here.
+ if (m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0)
+ {
+ m_aOverlayObjectDelayTimer.Stop();
+ if (m_xOverlayObject && m_xOverlayObject->getOverlayManager())
+ {
+ m_xOverlayObject->getOverlayManager()->remove(*m_xOverlayObject);
+ m_xOverlayObject.reset();
+ }
+ }
if (lcl_IsContent(*xEntry, *m_xTreeView)) // content entry
{
SwContent* pCnt = weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry));
const ContentTypeId nType = pCnt->GetParent()->GetType();
- bRemoveOverlayObject =
- nType != ContentTypeId::OUTLINE && nType != ContentTypeId::TABLE &&
- nType != ContentTypeId::FRAME && nType != ContentTypeId::GRAPHIC &&
- nType != ContentTypeId::OLE && nType != ContentTypeId::BOOKMARK &&
- nType != ContentTypeId::URLFIELD && nType != ContentTypeId::REFERENCE &&
- nType != ContentTypeId::TEXTFIELD;
- if (!bRemoveOverlayObject && (rMEvt.IsEnterWindow() ||
- m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0))
+ if (rMEvt.IsEnterWindow() ||
+ m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0)
{
if (nType == ContentTypeId::OUTLINE)
{
@@ -1218,6 +1227,14 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
BringReferencesToAttention(aTextAttrArr);
}
}
+ else if (nType == ContentTypeId::DRAWOBJECT)
+ {
+ if (!pCnt->IsInvisible())
+ {
+ std::vector<const SdrObject*> aSdrObjectArr {GetDrawingObjectsByContent(pCnt)};
+ BringDrawingObjectsToAttention(aSdrObjectArr);
+ }
+ }
else if (nType == ContentTypeId::TEXTFIELD)
{
if (const SwTextAttr* pTextAttr =
@@ -1233,14 +1250,8 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
{
const ContentTypeId nType =
weld::fromId<SwContentType*>(m_xTreeView->get_id(*xEntry))->GetType();
- bRemoveOverlayObject =
- nType != ContentTypeId::OUTLINE && nType != ContentTypeId::TABLE &&
- nType != ContentTypeId::FRAME && nType != ContentTypeId::GRAPHIC &&
- nType != ContentTypeId::OLE && nType != ContentTypeId::BOOKMARK &&
- nType != ContentTypeId::URLFIELD && nType != ContentTypeId::REFERENCE &&
- nType != ContentTypeId::TEXTFIELD;
- if (!bRemoveOverlayObject && (rMEvt.IsEnterWindow() ||
- m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0))
+ if (rMEvt.IsEnterWindow() ||
+ m_xTreeView->iter_compare(*xEntry, *m_xOverlayCompareEntry) != 0)
{
if (nType == ContentTypeId::OUTLINE)
{
@@ -1313,6 +1324,28 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
}
BringReferencesToAttention(aTextAttrArr);
}
+ else if (nType == ContentTypeId::DRAWOBJECT)
+ {
+ IDocumentDrawModelAccess& rIDDMA = m_pActiveShell->getIDocumentDrawModelAccess();
+ if (const SwDrawModel* pModel = rIDDMA.GetDrawModel())
+ {
+ if (const SdrPage* pPage = pModel->GetPage(0))
+ {
+ if (const size_t nCount = pPage->GetObjCount())
+ {
+ std::vector<const SdrObject*> aSdrObjectArr;
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ const SdrObject* pObject = pPage->GetObj(i);
+ if (pObject && !pObject->GetName().isEmpty() &&
+ rIDDMA.IsVisibleLayerId(pObject->GetLayer()))
+ aSdrObjectArr.push_back(pObject);
+ }
+ BringDrawingObjectsToAttention(aSdrObjectArr);
+ }
+ }
+ }
+ }
else if (nType == ContentTypeId::TEXTFIELD)
{
std::vector<const SwTextAttr*> aTextAttrArr;
@@ -1333,15 +1366,6 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool)
}
m_xTreeView->copy_iterator(*xEntry, *m_xOverlayCompareEntry);
}
- if (bRemoveOverlayObject)
- {
- m_aOverlayObjectDelayTimer.Stop();
- if (m_xOverlayObject && m_xOverlayObject->getOverlayManager())
- {
- m_xOverlayObject->getOverlayManager()->remove(*m_xOverlayObject);
- m_xOverlayObject.reset();
- }
- }
return false;
}
@@ -5857,6 +5881,25 @@ void SwContentTree::BringReferencesToAttention(std::vector<const SwTextAttr*>& r
m_aOverlayObjectDelayTimer.Start();
}
+void SwContentTree::BringDrawingObjectsToAttention(std::vector<const SdrObject*>& rDrawingObjectsArr)
+{
+ std::vector<basegfx::B2DRange> aRanges;
+ for (const SdrObject* pObject : rDrawingObjectsArr)
+ {
+ if (pObject)
+ {
+ tools::Rectangle aRect(pObject->GetLogicRect());
+ aRanges.emplace_back(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
+ }
+ }
+ 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();
+}
+
void SwContentTree::BringTextFieldsToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr)
{
std::vector<basegfx::B2DRange> aRanges;