From 26b64750ea15812de172985b50e6f22c2c71a60d Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Tue, 6 Dec 2022 22:48:58 -0900 Subject: tdf#152029 Bring tables, frames, images, and ole objects to attention in the document view when the mouse pointer is over these content type and content entries in the Navigator content tree Change-Id: I9493203c2011a2f02fb6ddb6741992d43eaf4ddd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143763 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/uibase/inc/conttree.hxx | 1 + sw/source/uibase/utlui/content.cxx | 87 +++++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index fc7f506b5128..03f331c2584f 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -137,6 +137,7 @@ class SwContentTree final : public SfxListener std::unique_ptr m_xOverlayObject; void BringHeadingsToAttention(const SwOutlineNodes& rOutlineNodesArr); + void BringFramesToAttention(const std::vector& rFrameFormats); void BringBookmarksToAttention(const std::vector& rNames); void BringURLFieldsToAttention(const SwGetINetAttrs& rINetAttrsArr); void BringReferencesToAttention(std::vector& rTextAttrsArr); diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 7c4761bb365e..1033c63c84e3 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1164,9 +1164,12 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) { SwContent* pCnt = weld::fromId(m_xTreeView->get_id(*xEntry)); const ContentTypeId nType = pCnt->GetParent()->GetType(); - bRemoveOverlayObject = nType != ContentTypeId::OUTLINE && - nType != ContentTypeId::BOOKMARK && nType != ContentTypeId::URLFIELD && - nType != ContentTypeId::REFERENCE && nType != ContentTypeId::TEXTFIELD; + 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)) { @@ -1177,6 +1180,26 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) GetOutLineNds()[static_cast(pCnt)->GetOutlinePos()]); BringHeadingsToAttention(aOutlineNodes); } + else if (nType == ContentTypeId::TABLE) + { + if (const SwFrameFormats* pFrameFormats = + m_pActiveShell->GetDoc()->GetTableFrameFormats()) + if (const SwFrameFormat* pFrameFormat = + pFrameFormats->FindFormatByName(pCnt->GetName())) + BringFramesToAttention(std::vector {pFrameFormat}); + } + else if (nType == ContentTypeId::FRAME || nType == ContentTypeId::GRAPHIC || + nType == ContentTypeId::OLE) + { + SwNodeType eNodeType = SwNodeType::Text; + if(nType == ContentTypeId::GRAPHIC) + eNodeType = SwNodeType::Grf; + else if(nType == ContentTypeId::OLE) + eNodeType = SwNodeType::Ole; + if (const SwFrameFormat* pFrameFormat = + m_pActiveShell->GetDoc()->FindFlyByName(pCnt->GetName(), eNodeType)) + BringFramesToAttention(std::vector {pFrameFormat}); + } else if (nType == ContentTypeId::BOOKMARK) { BringBookmarksToAttention(std::vector {pCnt->GetName()}); @@ -1210,9 +1233,12 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) { const ContentTypeId nType = weld::fromId(m_xTreeView->get_id(*xEntry))->GetType(); - bRemoveOverlayObject = nType != ContentTypeId::OUTLINE && - nType != ContentTypeId::BOOKMARK && nType != ContentTypeId::URLFIELD && - nType != ContentTypeId::REFERENCE && nType != ContentTypeId::TEXTFIELD; + 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)) { @@ -1220,6 +1246,38 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) { BringHeadingsToAttention(m_pActiveShell->GetNodes().GetOutLineNds()); } + else if (nType == ContentTypeId::TABLE) + { + std::vector aTableFormatsArr; + const size_t nCount = m_pActiveShell->GetTableFrameFormatCount(true); + const SwFrameFormats* pFrameFormats = + m_pActiveShell->GetDoc()->GetTableFrameFormats(); + SwAutoFormatGetDocNode aGetHt(&m_pActiveShell->GetNodes()); + for(size_t n = 0, i = 0; i < nCount + n; ++i) + { + if (const SwTableFormat* pTableFormat = + static_cast(pFrameFormats->GetFormat(i))) + { + if (pTableFormat->GetInfo(aGetHt)) // skip deleted tables + { + n++; + continue; + } + aTableFormatsArr.push_back(pTableFormat); + } + } + BringFramesToAttention(aTableFormatsArr); + } + else if (nType == ContentTypeId::FRAME || nType == ContentTypeId::GRAPHIC || + nType == ContentTypeId::OLE) + { + FlyCntType eType = FLYCNTTYPE_FRM; + if(nType == ContentTypeId::GRAPHIC) + eType = FLYCNTTYPE_GRF; + else if(nType == ContentTypeId::OLE) + eType = FLYCNTTYPE_OLE; + BringFramesToAttention(m_pActiveShell->GetFlyFrameFormats(eType, true)); + } else if (nType == ContentTypeId::BOOKMARK) { Reference xModel = @@ -5623,6 +5681,23 @@ void SwContentTree::BringHeadingsToAttention(const SwOutlineNodes& rOutlineNodes m_aOverlayObjectDelayTimer.Start(); } +void SwContentTree::BringFramesToAttention(const std::vector& rFrameFormats) +{ + std::vector aRanges; + for (const SwFrameFormat* pFrameFormat : rFrameFormats) + { + SwRect aFrameRect = pFrameFormat->FindLayoutRect(); + aRanges.emplace_back(aFrameRect.Left(), aFrameRect.Top(), + aFrameRect.Right(), aFrameRect.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::BringBookmarksToAttention(const std::vector& rNames) { std::vector aRanges; -- cgit