From 55a7e836a2db662a53adc4f8b98d08b06790c758 Mon Sep 17 00:00:00 2001
From: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Date: Wed, 13 Dec 2017 22:08:20 +0900
Subject: chart2: When creating objects prevent setting object rects dirty
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

3D objects using a E3dScene are traversing all object in the tree
when setting rects dirty. When we are creating objects, setting
properties and adding them to the tree we trigger setting rects
dirty which slows down considerably - more are added objects,
bigger the slowdown gets. So the solution here is to temporary
disable setting object rects dirty during creation of objects.

Change-Id: Id068cda9cb798d49b75bf4228cf6460f7e98c033
Reviewed-on: https://gerrit.libreoffice.org/46446
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
---
 chart2/source/view/charttypes/BarChart.cxx | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'chart2/source')

diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index 41002429d900..34c28deb9057 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -26,6 +26,8 @@
 #include <AxisIndexDefines.hxx>
 #include <Clipping.hxx>
 #include <DateHelper.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/unoshape.hxx>
 
 #include <com/sun/star/chart/DataLabelPlacement.hpp>
 
@@ -404,6 +406,20 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis()
     }
 }
 
+E3dScene* lcl_getE3dScene(uno::Reference<drawing::XShapes> const & xShapes)
+{
+    E3dScene* pScene = nullptr;
+
+    SvxShape* pSvxShape = SvxShape::getImplementation(xShapes);
+    if (pSvxShape)
+    {
+        SdrObject* pObject = pSvxShape->GetSdrObject();
+        if (pObject && dynamic_cast<const E3dScene*>(pObject) != nullptr)
+            pScene = static_cast<E3dScene*>(pObject);
+    }
+    return pScene;
+}
+
 void BarChart::createShapes()
 {
     if( m_aZSlots.empty() ) //no series
@@ -761,9 +777,12 @@ void BarChart::createShapes()
                                 if( fTopHeight < 0 )
                                     fTopHeight *= -1.0;
 
+                                E3dScene* pScene = lcl_getE3dScene(xSeriesGroupShape_Shapes);
+                                pScene->EnterObjectSetupMode();
                                 xShape = createDataPoint3D_Bar(
                                     xSeriesGroupShape_Shapes, aTransformedBottom, aSize, fTopHeight, nRotateZAngleHundredthDegree
                                     , xDataPointProperties, nGeometry3D );
+                                pScene->ExitObjectSetupMode();
                             }
                             else //m_nDimension!=3
                             {
-- 
cgit