chart2/source/inc/Diagram.hxx           |    3 +
 chart2/source/inc/ThreeDHelper.hxx      |    5 ---
 chart2/source/model/main/Diagram.cxx    |   50 ++++++++++++++++++++++++++++++-
 chart2/source/tools/ThreeDHelper.cxx    |   51 --------------------------------
 chart2/source/view/diagram/VDiagram.cxx |    2 -
 5 files changed, 52 insertions(+), 59 deletions(-)

New commits:
commit f81b47eb98eee8a2b2c027b91b8d7cea1179fad4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 27 21:58:56 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 28 07:25:03 2023 +0000

    move get/setCameraDistance from ThreeDHelper to Diagram
    
    so we can use the get/setFastPropertyValue methods
    
    Change-Id: Ibce7c93f067468f2e88f196158dfcb80686d01c7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149635
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index c157fe061399..e39b7342e2dd 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -332,6 +332,9 @@ public:
     std::vector<rtl::Reference<::chart::RegressionCurveModel> >
         getAllRegressionCurvesNotMeanValueLine();
 
+    double getCameraDistance();
+    void setCameraDistance( double fCameraDistance );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/ThreeDHelper.hxx 
b/chart2/source/inc/ThreeDHelper.hxx
index b5edf986c26d..8bcb4183ebea 100644
--- a/chart2/source/inc/ThreeDHelper.hxx
+++ b/chart2/source/inc/ThreeDHelper.hxx
@@ -90,11 +90,6 @@ public:
         sal_Int32& rnElevationDeg, sal_Int32& rnRotationDeg
         , double fXRad, double fYRad, double fZRad );
 
-    static double getCameraDistance(
-        const css::uno::Reference< css::beans::XPropertySet >& 
xSceneProperties );
-    static void setCameraDistance(
-        const css::uno::Reference< css::beans::XPropertySet >& xSceneProperties
-            , double fCameraDistance );
     SAL_DLLPRIVATE static void ensureCameraDistanceRange( double& 
rfCameraDistance );
     SAL_DLLPRIVATE static void getCameraDistanceRange( double& 
rfMinimumDistance, double& rfMaximumDistance );
 
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index 507cf7e895d7..a6c07f84163e 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -19,6 +19,7 @@
 
 #include <Diagram.hxx>
 #include <AxisHelper.hxx>
+#include <BaseGFXHelper.hxx>
 #include <ChartTypeHelper.hxx>
 #include <ChartTypeManager.hxx>
 #include <ChartTypeTemplate.hxx>
@@ -41,6 +42,7 @@
 #include <Axis.hxx>
 #include <DataTable.hxx>
 #include <servicenames_charttypes.hxx>
+#include <defines.hxx>
 
 #include <basegfx/numeric/ftools.hxx>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -617,7 +619,7 @@ void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 
nHandle, const Any& rValu
     {
         sal_Int32 fPerspective = 20;
         if( rValue >>=fPerspective )
-            ThreeDHelper::setCameraDistance( this, 
ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
+            setCameraDistance( ThreeDHelper::PerspectiveToCameraDistance( 
fPerspective ) );
     }
     else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
         || nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
@@ -644,7 +646,7 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, 
sal_Int32 nHandle ) co
     if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
     {
         sal_Int32 nPerspective = ::basegfx::fround( 
ThreeDHelper::CameraDistanceToPerspective(
-            ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) 
) );
+            const_cast< Diagram* >( this )->getCameraDistance() ) );
         rValue <<= nPerspective;
     }
     else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
@@ -1661,6 +1663,50 @@ std::vector< rtl::Reference< RegressionCurveModel > >
     return aResult;
 }
 
+double Diagram::getCameraDistance()
+{
+    double fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+    try
+    {
+        drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() 
);
+        getFastPropertyValue( SceneProperties::PROP_SCENE_CAMERA_GEOMETRY ) 
>>= aCG;
+        ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( 
aCG.vrp ) );
+        fCameraDistance = aVRP.getLength();
+
+        ThreeDHelper::ensureCameraDistanceRange( fCameraDistance );
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+    return fCameraDistance;
+}
+
+void Diagram::setCameraDistance(double fCameraDistance )
+{
+    try
+    {
+        if( fCameraDistance <= 0 )
+            fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+        drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() 
);
+        getFastPropertyValue( SceneProperties::PROP_SCENE_CAMERA_GEOMETRY ) 
>>= aCG;
+        ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( 
aCG.vrp ) );
+        if( ::basegfx::fTools::equalZero( aVRP.getLength() ) )
+            aVRP = ::basegfx::B3DVector(0,0,1);
+        aVRP.setLength(fCameraDistance);
+        aCG.vrp = BaseGFXHelper::B3DVectorToPosition3D( aVRP );
+
+        setFastPropertyValue( SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, 
uno::Any( aCG ));
+    }
+    catch( const uno::Exception & )
+    {
+        DBG_UNHANDLED_EXCEPTION("chart2");
+    }
+}
+
+
 } //  namespace chart
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/tools/ThreeDHelper.cxx 
b/chart2/source/tools/ThreeDHelper.cxx
index 099adeca75ea..bee4085f9637 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -1070,57 +1070,6 @@ void ThreeDHelper::ensureCameraDistanceRange( double& 
rfCameraDistance )
         rfCameraDistance = fMax;
 }
 
-double ThreeDHelper::getCameraDistance(
-        const Reference< beans::XPropertySet >& xSceneProperties )
-{
-    double fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
-
-    if( !xSceneProperties.is() )
-        return fCameraDistance;
-
-    try
-    {
-        drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() 
);
-        xSceneProperties->getPropertyValue( "D3DCameraGeometry" ) >>= aCG;
-        ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( 
aCG.vrp ) );
-        fCameraDistance = aVRP.getLength();
-
-        ensureCameraDistanceRange( fCameraDistance );
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-    return fCameraDistance;
-}
-
-void ThreeDHelper::setCameraDistance(
-        const Reference< beans::XPropertySet >& xSceneProperties, double 
fCameraDistance )
-{
-    if( !xSceneProperties.is() )
-        return;
-
-    try
-    {
-        if( fCameraDistance <= 0 )
-            fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
-
-        drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() 
);
-        xSceneProperties->getPropertyValue( "D3DCameraGeometry" ) >>= aCG;
-        ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( 
aCG.vrp ) );
-        if( ::basegfx::fTools::equalZero( aVRP.getLength() ) )
-            aVRP = ::basegfx::B3DVector(0,0,1);
-        aVRP.setLength(fCameraDistance);
-        aCG.vrp = BaseGFXHelper::B3DVectorToPosition3D( aVRP );
-
-        xSceneProperties->setPropertyValue( "D3DCameraGeometry", uno::Any( aCG 
));
-    }
-    catch( const uno::Exception & )
-    {
-        DBG_UNHANDLED_EXCEPTION("chart2");
-    }
-}
-
 double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance )
 {
     double fMin, fMax;
diff --git a/chart2/source/view/diagram/VDiagram.cxx 
b/chart2/source/view/diagram/VDiagram.cxx
index fb349282fd8d..f950561d5aab 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -525,7 +525,7 @@ void VDiagram::createShapes_3d()
             //ignore distance and focal length from file format and model 
completely
             //use vrp only to indicate the distance of the camera and thus 
influence the perspective
             m_xOuterGroupShape->setPropertyValue( UNO_NAME_3D_SCENE_DISTANCE, 
uno::Any(
-                                        
static_cast<sal_Int32>(ThreeDHelper::getCameraDistance( m_xDiagram ))));
+                                        
static_cast<sal_Int32>(m_xDiagram->getCameraDistance())));
             m_xOuterGroupShape->setPropertyValue( 
UNO_NAME_3D_SCENE_PERSPECTIVE,
                                         m_xDiagram->getPropertyValue( 
UNO_NAME_3D_SCENE_PERSPECTIVE));
         }

Reply via email to