chart2/source/view/main/ChartView.cxx |   34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

New commits:
commit ab07c078d14970db934f5a27cfdb6c2e5413738a
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Jan 5 21:22:12 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jan 6 15:49:26 2022 +0100

    speed up lcl_removeEmptyGroupShapes
    
    by bypassing the SvxShape layer, which adds a bunch of unnecessary
    overhead for this situation
    
    Change-Id: I0ba2f973e26e42995713d488593de7c4f3e00b88
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128024
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 0f023d6e4358..f1a3e32e760e 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2322,33 +2322,27 @@ void formatPage(
     }
 }
 
-void lcl_removeEmptyGroupShapes( const Reference< drawing::XShapes>& xParent )
+void lcl_removeEmptyGroupShapes( SdrObject& rParent )
 {
-    if(!xParent.is())
+    SdrObjList* pObjList = rParent.getChildrenOfSdrObject();
+    if (!pObjList || pObjList->GetObjCount() == 0)
         return;
-    Reference< drawing::XShapeGroup > xParentGroup( xParent, uno::UNO_QUERY );
-    if( !xParentGroup.is() )
-    {
-        Reference< drawing::XDrawPage > xPage( xParent, uno::UNO_QUERY );
-        if( !xPage.is() )
-            return;
-    }
 
     //iterate from back!
-    for( sal_Int32 nN = xParent->getCount(); nN--; )
+    for(auto nIdx = static_cast<sal_Int32>(pObjList->GetObjCount() - 1); nIdx 
>= 0; --nIdx)
     {
-        uno::Any aAny = xParent->getByIndex( nN );
-        Reference< drawing::XShapes> xShapes;
-        if( aAny >>= xShapes )
-            lcl_removeEmptyGroupShapes( xShapes );
-        if( xShapes.is() && xShapes->getCount()==0 )
+        SdrObject* pChildSdrObject = pObjList->GetObj(nIdx);
+        SdrObjList* pChildObjList = pChildSdrObject->getChildrenOfSdrObject();
+        if (!pChildObjList)
+            continue;
+        if (pChildObjList->GetObjCount() == 0)
         {
             //remove empty group shape
-            Reference< drawing::XShapeGroup > xGroup( xShapes, uno::UNO_QUERY 
);
-            Reference< drawing::XShape > xShape( xShapes, uno::UNO_QUERY );
-            if( xGroup.is() )
-                xParent->remove( xShape );
+            SdrObject* pRemoved = pObjList->NbcRemoveObject(nIdx);
+            SdrObject::Free( pRemoved );
         }
+        else
+            lcl_removeEmptyGroupShapes(*pChildSdrObject);
     }
 }
 
@@ -2983,7 +2977,7 @@ void ChartView::createShapes2D( const awt::Size& 
rPageSize )
     }
 
     //cleanup: remove all empty group shapes to avoid grey border lines:
-    lcl_removeEmptyGroupShapes( mxRootShape );
+    lcl_removeEmptyGroupShapes( *mxRootShape->GetSdrObject() );
 
     if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
     {

Reply via email to