include/svx/svdobj.hxx                              |    3 +--
 svx/source/sdr/contact/viewobjectcontactofgroup.cxx |    5 +----
 svx/source/svdraw/svdobj.cxx                        |   18 ++++++++++--------
 svx/source/svdraw/svdviter.cxx                      |   12 +++---------
 4 files changed, 15 insertions(+), 23 deletions(-)

New commits:
commit 8de6e211b760761f1f80b2a7371a5f6b640ab14e
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon May 22 18:47:36 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue May 23 14:36:47 2023 +0200

    tdf#155410 move some layer/object visibility computation inside SdrObject
    
    which has the nice effect of
    (a) removing some duplicated code
    (b) being more efficient with deeply nested complex objects
    
    Change-Id: Ifee10d40fca3faac0f5a7b79febdba756850f30f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152124
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index ab5066d699a2..54376b1f0397 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -364,8 +364,7 @@ public:
     virtual SdrLayerID GetLayer() const;
     virtual void NbcSetLayer(SdrLayerID nLayer);
     virtual void SetLayer(SdrLayerID nLayer);
-    // renaming GetSdrLayerIDSet -> getMergedHierarchySdrLayerIDSet to make 
clear what happens here. rSet needs to be empty.
-    void getMergedHierarchySdrLayerIDSet(SdrLayerIDSet& rSet) const;
+    bool isVisibleOnAnyOfTheseLayers(const SdrLayerIDSet& rSet) const;
 
     void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle& 
rBoundRect) const;
 
diff --git a/svx/source/sdr/contact/viewobjectcontactofgroup.cxx 
b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
index 8469a00c1e45..90a74cfabc8a 100644
--- a/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
@@ -76,10 +76,7 @@ namespace sdr::contact
 
         bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const 
SdrLayerIDSet& aLayers) const
         {
-            SdrLayerIDSet aObjectLayers;
-            getSdrObject().getMergedHierarchySdrLayerIDSet(aObjectLayers);
-            aObjectLayers &= aLayers;
-            return !aObjectLayers.IsEmpty();
+            return getSdrObject().isVisibleOnAnyOfTheseLayers(aLayers);
         }
 
 } // end of namespace
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index ab9aa7a9dcf1..03f9f0f95739 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -647,16 +647,18 @@ SdrLayerID SdrObject::GetLayer() const
     return mnLayerID;
 }
 
-void SdrObject::getMergedHierarchySdrLayerIDSet(SdrLayerIDSet& rSet) const
+bool SdrObject::isVisibleOnAnyOfTheseLayers(const SdrLayerIDSet& rSet) const
 {
-    rSet.Set(GetLayer());
+    if (rSet.IsSet(GetLayer()))
+        return true;
     SdrObjList* pOL=GetSubList();
-    if (pOL!=nullptr) {
-        const size_t nObjCount = pOL->GetObjCount();
-        for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
-            pOL->GetObj(nObjNum)->getMergedHierarchySdrLayerIDSet(rSet);
-        }
-    }
+    if (!pOL)
+        return false;
+    const size_t nObjCount = pOL->GetObjCount();
+    for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum)
+        if (pOL->GetObj(nObjNum)->isVisibleOnAnyOfTheseLayers(rSet))
+            return true;
+    return false;
 }
 
 void SdrObject::NbcSetLayer(SdrLayerID nLayer)
diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx
index 3ad7cb40f86e..baa13909b6c7 100644
--- a/svx/source/svdraw/svdviter.cxx
+++ b/svx/source/svdraw/svdviter.cxx
@@ -68,10 +68,7 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const* pPV) 
const
         {
             // Looking for an object? First, determine if it visible in
             // this PageView.
-            SdrLayerIDSet aObjLay;
-            mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
-            aObjLay &= pPV->GetVisibleLayers();
-            return !aObjLay.IsEmpty();
+            return 
mpObject->isVisibleOnAnyOfTheseLayers(pPV->GetVisibleLayers());
         }
         else
         {
@@ -91,12 +88,9 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const* pPV) 
const
                 {
                     // Looking for an object? First, determine if it visible in
                     // this PageView.
-                    SdrLayerIDSet aObjLay;
-                    mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
-                    aObjLay &= pPV->GetVisibleLayers();
+                    SdrLayerIDSet aObjLay = pPV->GetVisibleLayers();
                     aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
-
-                    if (!aObjLay.IsEmpty())
+                    if (mpObject->isVisibleOnAnyOfTheseLayers(aObjLay))
                     {
                         return true;
                     } // else, look at the next master page of this page...

Reply via email to