[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - chart2/source include/svx svx/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Dec 14 12:30:52 UTC 2017


 chart2/source/view/charttypes/BarChart.cxx |   19 +++++++++++++++++++
 include/svx/scene3d.hxx                    |    5 +++++
 svx/source/engine3d/scene3d.cxx            |   17 +++++++++++++++--
 3 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 5518edf8f4a145c5f9d3b3261d443a7bce0d3ac4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Dec 13 22:08:20 2017 +0900

    chart2: When creating objects prevent setting object rects dirty
    
    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/46405
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index a082d21b121a..f7206dafb70e 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -27,6 +27,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>
 
@@ -406,6 +408,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
@@ -778,9 +794,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
                             {
diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx
index f8642e02b540..04343d4dfe88 100644
--- a/include/svx/scene3d.hxx
+++ b/include/svx/scene3d.hxx
@@ -75,6 +75,8 @@ protected:
     // Flag to determine if only selected objects should be drawn
     bool                        bDrawOnlySelected       : 1;
 
+    bool mbSkipSettingDirty : 1;
+
     virtual void NewObjectInserted(const E3dObject* p3DObj) override;
     virtual void StructureChanged() override;
 
@@ -162,6 +164,9 @@ public:
     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
     virtual bool BckCreate(SdrDragStat& rStat) override;
     virtual void BrkCreate(SdrDragStat& rStat) override;
+
+    void EnterObjectSetupMode();
+    void ExitObjectSetupMode();
 };
 
 #endif // INCLUDED_SVX_SCENE3D_HXX
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index 8075e70fe6a7..6c75e459bc8d 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -184,7 +184,8 @@ E3dScene::E3dScene()
 :   E3dObject(),
     aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
     mp3DDepthRemapper(nullptr),
-    bDrawOnlySelected(false)
+    bDrawOnlySelected(false),
+    mbSkipSettingDirty(false)
 {
     // Set defaults
     E3dDefaultAttributes aDefault;
@@ -367,7 +368,9 @@ void E3dScene::NewObjectInserted(const E3dObject* p3DObj)
 void E3dScene::StructureChanged()
 {
     E3dObject::StructureChanged();
-    SetRectsDirty();
+
+    if (!GetScene()->mbSkipSettingDirty)
+        SetRectsDirty();
 
     ImpCleanup3DDepthMapper();
 }
@@ -435,6 +438,16 @@ E3dScene* E3dScene::Clone() const
     return CloneHelper< E3dScene >();
 }
 
+void E3dScene::EnterObjectSetupMode()
+{
+    GetScene()->mbSkipSettingDirty = true;
+}
+
+void E3dScene::ExitObjectSetupMode()
+{
+    GetScene()->mbSkipSettingDirty = false;
+}
+
 E3dScene& E3dScene::operator=(const E3dScene& rObj)
 {
     if( this == &rObj )


More information about the Libreoffice-commits mailing list