sw/source/uibase/inc/conttree.hxx  |    1 
 sw/source/uibase/utlui/content.cxx |   85 ++++++++++++++++++++++++++-----------
 2 files changed, 61 insertions(+), 25 deletions(-)

New commits:
commit 5930f928e777ab95ed26619c43fa5ae334685deb
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Tue Dec 20 00:33:05 2022 -0900
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Dec 21 08:27:53 2022 +0000

    tdf#152029 follow up: Handle content that extends to following pages
    
    Brings section and table content to attention in the document view that
    extend to following pages. Previously only the frame area on the page
    these content types begin is brought to attention.
    
    Change-Id: Ia023e85cc7c14e0c50a0a0f9765a17fb207a95da
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144583
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index 1764377f0312..d10b5ba9da1e 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -147,6 +147,7 @@ class SwContentTree final : public SfxListener
     void BringDrawingObjectsToAttention(std::vector<const SdrObject*>& 
rDrawingObjectsArr);
     void BringTextFieldsToAttention(std::vector<const SwTextAttr*>& 
rTextAttrsArr);
     void BringFootnotesToAttention(std::vector<const SwTextAttr*>& 
rTextAttrsArr);
+    void BringTypesWithFlowFramesToAttention(const std::vector<const SwNode*>& 
rNodes);
 
     /**
      * 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 54b6616f50d5..3c03b26323ce 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -109,6 +109,7 @@
 #include <svx/sdr/overlay/overlayobject.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
 #include <svx/sdrpaintwindow.hxx>
+#include <node2lay.hxx>
 
 #define CTYPE_CNT   0
 #define CTYPE_CTT   1
@@ -1194,11 +1195,15 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const 
MouseEvent&, rMEvt, bool)
                 }
                 else if (nType == ContentTypeId::TABLE)
                 {
-                   if (const SwFrameFormats* pFrameFormats =
+                    if (const SwFrameFormats* pFrameFormats =
                             m_pActiveShell->GetDoc()->GetTableFrameFormats())
                         if (const SwFrameFormat* pFrameFormat =
                                 
pFrameFormats->FindFormatByName(pCnt->GetName()))
-                            BringFramesToAttention(std::vector<const 
SwFrameFormat*> {pFrameFormat});
+                        {
+                            SwTable* pTable = SwTable::FindTable(pFrameFormat);
+                            if (pTable)
+                                
BringTypesWithFlowFramesToAttention({pTable->GetTableNode()});
+                        }
                 }
                 else if (nType == ContentTypeId::FRAME || nType == 
ContentTypeId::GRAPHIC ||
                          nType == ContentTypeId::OLE)
@@ -1221,7 +1226,7 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, 
rMEvt, bool)
                     const SwSectionFormats& rFormats = 
m_pActiveShell->GetDoc()->GetSections();
                     const SwSectionFormat* pFormat = 
rFormats.FindFormatByName(pCnt->GetName());
                     if (pFormat)
-                        BringFramesToAttention(std::vector<const 
SwFrameFormat*> {pFormat});
+                        
BringTypesWithFlowFramesToAttention({pFormat->GetSectionNode()});
                 }
                 else if (nType == ContentTypeId::URLFIELD)
                 {
@@ -1284,7 +1289,7 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const MouseEvent&, 
rMEvt, bool)
                 }
                 else if (nType == ContentTypeId::TABLE)
                 {
-                    std::vector<const SwFrameFormat*> aTableFormatsArr;
+                    std::vector<const SwNode*> aNodesArr;
                     const size_t nCount = 
m_pActiveShell->GetTableFrameFormatCount(false);
                     const SwFrameFormats* pFrameFormats =
                             m_pActiveShell->GetDoc()->GetTableFrameFormats();
@@ -1294,9 +1299,13 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const 
MouseEvent&, rMEvt, bool)
                         if (const SwTableFormat* pTableFormat =
                                 
static_cast<SwTableFormat*>(pFrameFormats->GetFormat(i)))
                             if (!pTableFormat->GetInfo(aGetHt))  // skip 
deleted tables
-                                aTableFormatsArr.push_back(pTableFormat);
+                            {
+                                SwTable* pTable = 
SwTable::FindTable(pTableFormat);
+                                if (pTable)
+                                    
aNodesArr.push_back(pTable->GetTableNode());
+                            }
                     }
-                    BringFramesToAttention(aTableFormatsArr);
+                    BringTypesWithFlowFramesToAttention(aNodesArr);
                 }
                 else if (nType == ContentTypeId::FRAME || nType == 
ContentTypeId::GRAPHIC ||
                          nType == ContentTypeId::OLE)
@@ -1322,32 +1331,31 @@ IMPL_LINK(SwContentTree, MouseMoveHdl, const 
MouseEvent&, rMEvt, bool)
                 }
                 else if (nType == ContentTypeId::REGION || nType == 
ContentTypeId::INDEX)
                 {
+                    std::vector<const SwNode*> aNodesArr;
                     const SwSectionFormats& rFormats = 
m_pActiveShell->GetDoc()->GetSections();
-                    if (const size_t nSize = rFormats.size())
+                    const size_t nSize = rFormats.size();
+                    for (SwSectionFormats::size_type n = nSize; n;)
                     {
-                        std::vector<const SwFrameFormat*> aSectionsFormatsArr;
-                        for (SwSectionFormats::size_type n = nSize; n;)
+                        const SwSectionFormat* pSectionFormat = rFormats[--n];
+                        if (pSectionFormat && pSectionFormat->IsInNodesArr())
                         {
-                            const SwSectionFormat* pFormat = rFormats[--n];
-                            if (pFormat && pFormat->IsInNodesArr())
+                            const SwSection* pSection = 
pSectionFormat->GetSection();
+                            if (pSection && !pSection->IsHiddenFlag())
                             {
-                                const SwSection* pSection = 
pFormat->GetSection();
-                                if (pSection && !pSection->IsHiddenFlag())
-                                {
-                                    const SectionType eSectionType = 
pSection->GetType();
-                                    if (nType == ContentTypeId::REGION &&
-                                            (eSectionType == 
SectionType::ToxContent ||
-                                            eSectionType == 
SectionType::ToxHeader))
-                                        continue;
-                                    if (nType == ContentTypeId::INDEX &&
-                                            eSectionType != 
SectionType::ToxContent)
-                                        continue;
-                                    aSectionsFormatsArr.push_back(pFormat);
-                                }
+                                const SectionType eSectionType = 
pSection->GetType();
+                                if (nType == ContentTypeId::REGION &&
+                                        (eSectionType == 
SectionType::ToxContent ||
+                                         eSectionType == 
SectionType::ToxHeader))
+                                    continue;
+                                if (nType == ContentTypeId::INDEX &&
+                                        eSectionType != 
SectionType::ToxContent)
+                                    continue;
+                                if (const SwNode* pNode = 
pSectionFormat->GetSectionNode())
+                                    aNodesArr.push_back(pNode);
                             }
                         }
-                        BringFramesToAttention(aSectionsFormatsArr);
                     }
+                    BringTypesWithFlowFramesToAttention(aNodesArr);
                 }
                 else if (nType == ContentTypeId::URLFIELD)
                 {
@@ -5855,6 +5863,33 @@ void SwContentTree::BringBookmarksToAttention(const 
std::vector<OUString>& rName
         OverlayObject(std::move(aRanges));
 }
 
+void SwContentTree::BringTypesWithFlowFramesToAttention(const 
std::vector<const SwNode*>& rNodes)
+{
+    std::vector<basegfx::B2DRange> aRanges;
+    for (const auto* pNode : rNodes)
+    {
+        if (!pNode)
+            continue;
+        SwNode2Layout aTmp(*pNode, pNode->GetIndex() - 1);
+        SwFrame* pFrame = aTmp.NextFrame();
+        while (pFrame)
+        {
+            const SwRect& rFrameRect = pFrame->getFrameArea();
+            if (!rFrameRect.IsEmpty())
+                aRanges.emplace_back(rFrameRect.Left(), rFrameRect.Top(), 
rFrameRect.Right(),
+                                     rFrameRect.Bottom());
+            if (!pFrame->IsFlowFrame())
+                break;
+            SwFlowFrame *pFollow = 
SwFlowFrame::CastFlowFrame(pFrame)->GetFollow();
+            if (!pFollow)
+                break;
+            pFrame = &pFollow->GetFrame();
+        }
+    }
+    if (aRanges.size())
+        OverlayObject(std::move(aRanges));
+}
+
 void SwContentTree::BringURLFieldsToAttention(const SwGetINetAttrs& 
rINetAttrsArr)
 {
     std::vector<basegfx::B2DRange> aRanges;

Reply via email to