svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx |    8 +
 sw/source/uibase/inc/conttree.hxx                       |    1 
 sw/source/uibase/utlui/content.cxx                      |   76 +++++++++++++++-
 3 files changed, 79 insertions(+), 6 deletions(-)

New commits:
commit ae6191cb386bc6c8bf8227e7121b26a86b556a6f
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Fri Dec 9 12:30:12 2022 -0900
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Dec 16 08:45:33 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 <rayk...@gmail.com>
    (cherry picked from commit a2d211359b082db33153e9bc22c2184f2de1131e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144124
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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 83e123540a9f..37983514e647 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;
commit 642d64f29f5965c161c56163750455d6319af972
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Dec 15 17:15:10 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Dec 16 08:45:25 2022 +0000

    svx: fix null deref in ParaLineSpacingControl::ExecuteLineSpacing
    
    See 
https://crashreport.libreoffice.org/stats/signature/svx::ParaLineSpacingControl::ExecuteLineSpacing(long)
    
    Change-Id: Ide29a7e78bf1114f0ebc104fa8c245e52d590eea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144190
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx 
b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
index 9ff16f340b15..4283f3651136 100644
--- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
+++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx
@@ -423,8 +423,12 @@ void ParaLineSpacingControl::ExecuteLineSpacing(sal_Int32 
nEntry)
 
     SetLineSpace(aSpacing, nEntry);
 
-    SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(
-            SID_ATTR_PARA_LINESPACE, SfxCallMode::RECORD, { &aSpacing });
+    SfxViewFrame* pCurrent = SfxViewFrame::Current();
+    if( pCurrent )
+    {
+        pCurrent->GetBindings().GetDispatcher()->ExecuteList(
+                SID_ATTR_PARA_LINESPACE, SfxCallMode::RECORD, { &aSpacing });
+    }
 
     // close when the user used the buttons
     mxControl->EndPopupMode();

Reply via email to