sw/source/uibase/inc/conttree.hxx | 1 sw/source/uibase/utlui/content.cxx | 76 +++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 4 deletions(-)
New commits: commit a2d211359b082db33153e9bc22c2184f2de1131e Author: Jim Raykowski <[email protected]> AuthorDate: Fri Dec 9 12:30:12 2022 -0900 Commit: Jim Raykowski <[email protected]> CommitDate: Tue Dec 13 18:29:00 2022 +0000 tdf#152029 Bring footnotes and endnotes to attention in the document view when mouse pointer is over footnote and endnote content type and content entries in the Navigator content tree Change-Id: Iec1c2112aa934e21340fd2a21ea4b3bf8d1ce9cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143900 Tested-by: Jenkins Reviewed-by: Jim Raykowski <[email protected]> diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 5a9ef1a9322e..3cf671ac1bd9 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -143,6 +143,7 @@ class SwContentTree final : public SfxListener void BringReferencesToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr); void BringDrawingObjectsToAttention(std::vector<const SdrObject*>& rDrawingObjectsArr); void BringTextFieldsToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr); + void BringFootnotesToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr); /** * 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 a7c74261c4f8..0c027d73407f 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1265,6 +1265,15 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) BringTextFieldsToAttention(aTextAttrArr); } } + else if (nType == ContentTypeId::FOOTNOTE || nType == ContentTypeId::ENDNOTE) + { + if (const SwTextAttr* pTextAttr = + static_cast<SwTextFootnoteContent*> (pCnt)->GetTextFootnote()) + { + std::vector<const SwTextAttr*> aTextAttrArr {pTextAttr}; + BringFootnotesToAttention(aTextAttrArr); + } + } } } else // content type entry @@ -1388,12 +1397,12 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) else if (nType == ContentTypeId::TEXTFIELD) { std::vector<const SwTextAttr*> aTextAttrArr; - for (size_t i = 0; i < m_aActiveContentArr[nType]->GetMemberCount(); i++) + const auto nCount = m_aActiveContentArr[nType]->GetMemberCount(); + for (size_t i = 0; i < nCount; i++) { - const SwTextFieldContent* pTextFieldContent = + if (const SwTextFieldContent* pTextFieldContent = static_cast<const SwTextFieldContent*>( - m_aActiveContentArr[nType]->GetMember(i)); - if (pTextFieldContent) + m_aActiveContentArr[nType]->GetMember(i))) if (const SwFormatField* pFormatField = pTextFieldContent->GetFormatField()) if (const SwTextAttr* pTextAttr = pFormatField->GetTextField()) @@ -1401,6 +1410,21 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, rMEvt, bool) } BringTextFieldsToAttention(aTextAttrArr); } + else if (nType == ContentTypeId::FOOTNOTE || nType == ContentTypeId::ENDNOTE) + { + std::vector<const SwTextAttr*> aTextAttrArr; + const auto nCount = m_aActiveContentArr[nType]->GetMemberCount(); + for (size_t i = 0; i < nCount; i++) + { + if (const SwTextFootnoteContent* pTextFootnoteContent = + static_cast<const SwTextFootnoteContent*>( + m_aActiveContentArr[nType]->GetMember(i))) + if (const SwTextAttr* pTextAttr = + pTextFootnoteContent->GetTextFootnote()) + aTextAttrArr.push_back(pTextAttr); + } + BringFootnotesToAttention(aTextAttrArr); + } } } m_xTreeView->copy_iterator(*xEntry, *m_xOverlayCompareEntry); @@ -5920,6 +5944,50 @@ void SwContentTree::BringReferencesToAttention(std::vector<const SwTextAttr*>& r m_aOverlayObjectDelayTimer.Start(); } +void SwContentTree::BringFootnotesToAttention(std::vector<const SwTextAttr*>& rTextAttrsArr) +{ + std::vector<basegfx::B2DRange> aRanges; + for (const SwTextAttr* p : rTextAttrsArr) + { + const SwTextNode& rTextNode = p->GetFootnote().GetTextFootnote()->GetTextNode(); + if (SwTextFrame* pFrame = static_cast<SwTextFrame*>( + rTextNode.getLayoutFrame(m_pActiveShell->GetLayout()))) + { + SwRect aStartCharRect; + SwPosition aStartPos(rTextNode, p->GetStart()); + pFrame->GetCharRect(aStartCharRect, aStartPos); + SwRect aEndCharRect; + SwPosition aEndPos(rTextNode, p->GetStart() + 1); + 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(); +} + + void SwContentTree::BringDrawingObjectsToAttention(std::vector<const SdrObject*>& rDrawingObjectsArr) { std::vector<basegfx::B2DRange> aRanges;
