chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx |   19 +++++---
 chart2/source/controller/dialogs/DataBrowserModel.cxx       |    2 
 chart2/source/controller/dialogs/DialogModel.cxx            |    2 
 chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx    |    2 
 chart2/source/controller/main/ControllerCommandDispatch.cxx |    4 +
 chart2/source/controller/main/DragMethod_RotateDiagram.cxx  |    2 
 chart2/source/controller/main/ObjectHierarchy.cxx           |    2 
 chart2/source/inc/Diagram.hxx                               |    2 
 chart2/source/inc/DiagramHelper.hxx                         |    3 -
 chart2/source/model/main/Diagram.cxx                        |   23 +++++++++-
 chart2/source/model/template/LineChartTypeTemplate.cxx      |    3 -
 chart2/source/model/template/PieChartTypeTemplate.cxx       |    2 
 chart2/source/model/template/ScatterChartTypeTemplate.cxx   |    2 
 chart2/source/tools/AxisHelper.cxx                          |    2 
 chart2/source/tools/DiagramHelper.cxx                       |   26 ------------
 chart2/source/tools/ObjectIdentifier.cxx                    |   14 +++---
 chart2/source/tools/ThreeDHelper.cxx                        |   14 +++---
 chart2/source/view/diagram/VDiagram.cxx                     |    2 
 chart2/source/view/main/ChartView.cxx                       |    8 ++-
 19 files changed, 69 insertions(+), 65 deletions(-)

New commits:
commit 7a519bc2afec54f1c4c78d30023415d7ae7dc6c4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Mar 15 16:32:38 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 17 16:31:35 2023 +0000

    move getChartTypeByIndex inside chart2::Diagram
    
    Change-Id: Idff60dbd7c1cdb8c60e7ac07ad3abe3c6b07e321
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149050
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index f0d85a4bcc1f..5654ef2ec8fc 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -421,10 +421,10 @@ struct StaticDiagramWrapperPropertyArray : public 
rtl::StaticAggregate< Sequence
 {
 };
 
-bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& rDiagram )
+bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram )
 {
     bool bRet = false;
-    rtl::Reference< ::chart::ChartType > xChartType( 
::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) );
+    rtl::Reference< ::chart::ChartType > xChartType( 
xDiagram->getChartTypeByIndex( 0 ) );
     if( xChartType.is() )
     {
         OUString aChartType( xChartType->getChartType() );
@@ -594,20 +594,23 @@ OUString SAL_CALL DiagramWrapper::getDiagramType()
         aRet = lcl_getDiagramType( aTemplateAndService.sServiceName );
     }
 
-    if( aRet.isEmpty())
+    if( !aRet.isEmpty())
+        return aRet;
+
+    // none of the standard templates matched
+    // use first chart type
+    if (xDiagram)
     {
-        // none of the standard templates matched
-        // use first chart type
-        rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+        rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 
0 ) );
         if( xChartType.is() )
         {
             aRet = xChartType->getChartType();
             if( !aRet.isEmpty() )
                 aRet = lcl_getOldChartTypeName( aRet );
         }
-        if( aRet.isEmpty())
-            aRet = "com.sun.star.chart.BarDiagram";
     }
+    if( aRet.isEmpty())
+        aRet = "com.sun.star.chart.BarDiagram";
 
     return aRet;
 }
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx 
b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index a26a9d86b2ca..595efe79cf36 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -314,7 +314,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 
nAfterColumnIndex )
     else
     {
         // No data series at specified column position. Use the first chart 
type.
-        xChartType = DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+        xChartType = xDiagram->getChartTypeByIndex( 0 );
         nStartCol = nAfterColumnIndex;
     }
 
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index aa9663e7d0bc..501e68f201c1 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -620,7 +620,7 @@ void DialogModel::setCategories( const Reference< 
chart2::data::XLabeledDataSequ
     // categories
     bool bSupportsCategories = true;
 
-    rtl::Reference< ChartType > xFirstChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xFirstChartType( 
xDiagram->getChartTypeByIndex( 0 ) );
     if( xFirstChartType.is() )
     {
         sal_Int32 nAxisType = ChartTypeHelper::getAxisType( xFirstChartType, 0 
); // x-axis
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx 
b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
index de24f05b2636..12e878d237ed 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
@@ -114,7 +114,7 @@ 
ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage(weld::Container* pPar
     m_xMFPerspective->set_sensitive( m_xCbxPerspective->get_active() );
 
     //RightAngledAxes
-    if 
(ChartTypeHelper::isSupportingRightAngledAxes(DiagramHelper::getChartTypeByIndex(m_xDiagram,
 0)))
+    if 
(ChartTypeHelper::isSupportingRightAngledAxes(m_xDiagram->getChartTypeByIndex(0)))
     {
         bool bRightAngledAxes = false;
         m_xDiagram->getPropertyValue( "RightAngledAxes" ) >>= bRightAngledAxes;
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index 53e02f017aaa..af0dd5f9f0f2 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -401,7 +401,9 @@ void ModelState::update( const 
rtl::Reference<::chart::ChartModel> & xModel )
 
     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
 
-    rtl::Reference< ChartType > xFirstChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xFirstChartType;
+    if (xDiagram)
+        xFirstChartType = xDiagram->getChartTypeByIndex( 0 );
     bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( 
xFirstChartType, nDimensionCount );
     bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, 
nDimensionCount, 0 );
 
diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx 
b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
index fb6aeab01b2b..c4b2646e1fe8 100644
--- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
+++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
@@ -84,7 +84,7 @@ DragMethod_RotateDiagram::DragMethod_RotateDiagram( 
DrawViewWrapper& rDrawViewWr
         , m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad );
 
     if( ChartTypeHelper::isSupportingRightAngledAxes(
-        DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
+        xDiagram->getChartTypeByIndex( 0 ) ) )
         xDiagram->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes;
     if(m_bRightAngledAxes)
     {
diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx 
b/chart2/source/controller/main/ObjectHierarchy.cxx
index 20607481f14e..fd9ee04c7374 100644
--- a/chart2/source/controller/main/ObjectHierarchy.cxx
+++ b/chart2/source/controller/main/ObjectHierarchy.cxx
@@ -212,7 +212,7 @@ void ObjectHierarchy::createAxesTree(
     const rtl::Reference< Diagram > & xDiagram  )
 {
     sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) 
);
     bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( 
xChartType, nDimensionCount, 0 );
     if( !bSupportsAxesGrids )
         return;
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx
index 534403b6f70b..adae9200d0e6 100644
--- a/chart2/source/inc/Diagram.hxx
+++ b/chart2/source/inc/Diagram.hxx
@@ -222,6 +222,8 @@ public:
 
     std::vector< rtl::Reference< ChartType > > getChartTypes();
 
+    rtl::Reference< ChartType > getChartTypeByIndex( sal_Int32 nIndex );
+
 private:
     // ____ XModifyListener ____
     virtual void SAL_CALL modified(
diff --git a/chart2/source/inc/DiagramHelper.hxx 
b/chart2/source/inc/DiagramHelper.hxx
index 908a6f808e62..09fdb8960a97 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -212,9 +212,6 @@ public:
     static sal_Int32 getPercentNumberFormat( const css::uno::Reference<
                 css::util::XNumberFormatsSupplier >& xNumberFormatsSupplier );
 
-    static rtl::Reference< ChartType >
-        getChartTypeByIndex( const rtl::Reference< ::chart::Diagram >& 
xDiagram, sal_Int32 nIndex );
-
     SAL_DLLPRIVATE static bool areChartTypesCompatible(
                 const rtl::Reference< ::chart::ChartType >& xFirstType,
                 const rtl::Reference< ::chart::ChartType >& xSecondType );
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index 6576141dbe65..55e96fab6685 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -810,8 +810,7 @@ sal_Int32 Diagram::getGeometry3D( bool& rbFound, bool& 
rbAmbiguous )
 
 bool Diagram::isPieOrDonutChart()
 {
-    rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeByIndex(
-        this, 0 ) );
+    rtl::Reference< ChartType > xChartType = getChartTypeByIndex( 0 );
 
     if( xChartType .is() )
     {
@@ -1041,6 +1040,26 @@ std::vector< rtl::Reference< ChartType > > 
Diagram::getChartTypes()
     return aResult;
 }
 
+rtl::Reference< ChartType > Diagram::getChartTypeByIndex( sal_Int32 nIndex )
+{
+    rtl::Reference< ChartType > xChartType;
+
+    //iterate through all coordinate systems
+    sal_Int32 nTypesSoFar = 0;
+    for( rtl::Reference< BaseCoordinateSystem > const & coords : 
getBaseCoordinateSystems() )
+    {
+        const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
coords->getChartTypes2() );
+        if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < nTypesSoFar + 
aChartTypeList.size() )
+        {
+            xChartType = aChartTypeList[nIndex - nTypesSoFar];
+            break;
+        }
+        nTypesSoFar += aChartTypeList.size();
+    }
+
+    return xChartType;
+}
+
 
 } //  namespace chart
 
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx 
b/chart2/source/model/template/LineChartTypeTemplate.cxx
index 8df02d55e896..c37e9cda2b94 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -236,8 +236,7 @@ bool LineChartTypeTemplate::matchesTemplate2(
     {
         try
         {
-            rtl::Reference< ChartType > xChartType =
-                DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+            rtl::Reference< ChartType > xChartType = 
xDiagram->getChartTypeByIndex( 0 );
             setFastPropertyValue_NoBroadcast( 
PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, 
xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
             setFastPropertyValue_NoBroadcast( 
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 
xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
             setFastPropertyValue_NoBroadcast( 
PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 
xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx 
b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 38761d4d899c..44d0759f50a4 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -349,7 +349,7 @@ bool PieChartTypeTemplate::matchesTemplate2(
     if( bResult )
     {
         rtl::Reference< ChartType > xCTProp =
-            DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+            xDiagram->getChartTypeByIndex( 0 );
         bool bUseRings = false;
         if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings )
         {
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx 
b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
index 9aa741c1d4ec..2f41025f9f3b 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -265,7 +265,7 @@ bool ScatterChartTypeTemplate::matchesTemplate2(
         try
         {
             rtl::Reference< ChartType > xChartTypeProp =
-                DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+                xDiagram->getChartTypeByIndex(0);
             setFastPropertyValue_NoBroadcast( 
PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, 
xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
             setFastPropertyValue_NoBroadcast( 
PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 
xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
             setFastPropertyValue_NoBroadcast( 
PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 
xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index a5e17dce757b..5a1a0088d6ab 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -890,7 +890,7 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< 
sal_Bool >& rPossibilityL
 
     //set possibilities:
     sal_Int32 nIndex=0;
-    rtl::Reference< ChartType > xChartType = 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 );
+    rtl::Reference< ChartType > xChartType = xDiagram->getChartTypeByIndex( 0 
);
     for(nIndex=0;nIndex<3;nIndex++)
         
pPossibilityList[nIndex]=ChartTypeHelper::isSupportingMainAxis(xChartType,nDimensionCount,nIndex);
     for(nIndex=3;nIndex<6;nIndex++)
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index 09f1872ddf5a..f81e1449d140 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -643,30 +643,6 @@ std::vector< std::vector< rtl::Reference< DataSeries > > >
     return aResult;
 }
 
-rtl::Reference< ChartType >
-    DiagramHelper::getChartTypeByIndex( const rtl::Reference< Diagram >& 
xDiagram, sal_Int32 nIndex )
-{
-    if (!xDiagram)
-        return nullptr;
-
-    rtl::Reference< ChartType > xChartType;
-
-    //iterate through all coordinate systems
-    sal_Int32 nTypesSoFar = 0;
-    for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
-    {
-        const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
coords->getChartTypes2() );
-        if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < nTypesSoFar + 
aChartTypeList.size() )
-        {
-            xChartType = aChartTypeList[nIndex - nTypesSoFar];
-            break;
-        }
-        nTypesSoFar += aChartTypeList.size();
-    }
-
-    return xChartType;
-}
-
 namespace
 {
 
@@ -995,7 +971,7 @@ void DiagramHelper::switchToTextCategories( const 
rtl::Reference<::chart::ChartM
 bool DiagramHelper::isSupportingDateAxis( const rtl::Reference< Diagram >& 
xDiagram )
 {
     return ::chart::ChartTypeHelper::isSupportingDateAxis(
-            DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), 0 );
+            xDiagram->getChartTypeByIndex( 0 ), 0 );
 }
 
 bool DiagramHelper::isDateNumberFormat( sal_Int32 nNumberFormat, const 
Reference< util::XNumberFormats >& xNumberFormats )
diff --git a/chart2/source/tools/ObjectIdentifier.cxx 
b/chart2/source/tools/ObjectIdentifier.cxx
index e13feb1277d1..b72ac1c1f1d0 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -1298,14 +1298,16 @@ rtl::Reference< DataSeries > 
ObjectIdentifier::getDataSeriesForCID(
     lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, 
rObjectCID );
 
     rtl::Reference< DataSeries > xSeries;
-    rtl::Reference< ChartType > xDataSeriesContainer( 
DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ) );
-    if( xDataSeriesContainer.is() )
+    if (xDiagram)
     {
-        const std::vector< rtl::Reference< DataSeries > > & aDataSeriesSeq( 
xDataSeriesContainer->getDataSeries2() );
-        if( nSeriesIndex >= 0 && o3tl::make_unsigned(nSeriesIndex) < 
aDataSeriesSeq.size() )
-            xSeries = aDataSeriesSeq[nSeriesIndex];
+        rtl::Reference< ChartType > xDataSeriesContainer( 
xDiagram->getChartTypeByIndex( nChartTypeIndex ) );
+        if( xDataSeriesContainer.is() )
+        {
+            const std::vector< rtl::Reference< DataSeries > > & 
aDataSeriesSeq( xDataSeriesContainer->getDataSeries2() );
+            if( nSeriesIndex >= 0 && o3tl::make_unsigned(nSeriesIndex) < 
aDataSeriesSeq.size() )
+                xSeries = aDataSeriesSeq[nSeriesIndex];
+        }
     }
-
     return xSeries;
 }
 
diff --git a/chart2/source/tools/ThreeDHelper.cxx 
b/chart2/source/tools/ThreeDHelper.cxx
index fc0fe221b584..4990244ed3a8 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -56,7 +56,7 @@ bool lcl_isRightAngledAxesSetAndSupported( const 
rtl::Reference< Diagram >& xDia
         if(bRightAngledAxes)
         {
             if( ChartTypeHelper::isSupportingRightAngledAxes(
-                    DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
+                    xDiagram->getChartTypeByIndex( 0 ) ) )
             {
                 return true;
             }
@@ -152,7 +152,7 @@ bool lcl_isLightScheme( const rtl::Reference< Diagram >& 
xDiagram, bool bRealist
     if(!bIsOn)
         return false;
 
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) 
);
 
     sal_Int32 nColor = 0;
     xDiagram->getPropertyValue( UNO_NAME_3D_SCENE_LIGHTCOLOR_2 ) >>= nColor;
@@ -178,7 +178,7 @@ bool lcl_isLightScheme( const rtl::Reference< Diagram >& 
xDiagram, bool bRealist
         if(!bRightAngledAxes)
         {
             if( ChartTypeHelper::isSupportingRightAngledAxes(
-                    DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
+                    xDiagram->getChartTypeByIndex( 0 ) ) )
             {
                 ::basegfx::B3DHomMatrix aRotation( 
lcl_getCompleteRotationMatrix( xDiagram ) );
                 BaseGFXHelper::ReduceToRotationMatrix( aRotation );
@@ -209,7 +209,7 @@ void lcl_setLightsForScheme( const rtl::Reference< Diagram 
>& xDiagram, const Th
 
     xDiagram->setPropertyValue( UNO_NAME_3D_SCENE_LIGHTON_2, uno::Any( true ) 
);
 
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) 
);
     uno::Any aADirection( rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple
         ? ChartTypeHelper::getDefaultSimpleLightDirection(xChartType)
         : ChartTypeHelper::getDefaultRealisticLightDirection(xChartType) );
@@ -263,7 +263,7 @@ bool lcl_isSimpleScheme( drawing::ShadeMode aShadeMode
         return false;
     if(nObjectLines==0)
     {
-        rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+        rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 
0 ) );
         return ChartTypeHelper::noBordersForSimpleScheme( xChartType );
     }
     if(nObjectLines!=1)
@@ -288,7 +288,7 @@ void lcl_setSimpleScheme( drawing::ShadeMode& rShadeMode
     rShadeMode = drawing::ShadeMode_FLAT;
     rnRoundedEdges = 0;
 
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) 
);
     rnObjectLines = ChartTypeHelper::noBordersForSimpleScheme( xChartType ) ? 
0 : 1;
 }
 
@@ -1003,7 +1003,7 @@ void ThreeDHelper::setRotationAngleToDiagram(
         bool bRightAngledAxes = false;
         xDiagram->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
         if(!bRightAngledAxes || !ChartTypeHelper::isSupportingRightAngledAxes(
-                    DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
+                    xDiagram->getChartTypeByIndex( 0 ) ) )
         {
             ::basegfx::B3DHomMatrix aNewRotation;
             aNewRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
diff --git a/chart2/source/view/diagram/VDiagram.cxx 
b/chart2/source/view/diagram/VDiagram.cxx
index bc41f117ef5c..fb349282fd8d 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -56,7 +56,7 @@ VDiagram::VDiagram(
 
     ThreeDHelper::getRotationAngleFromDiagram( xDiagram, m_fXAnglePi, 
m_fYAnglePi, m_fZAnglePi );
     if( ChartTypeHelper::isSupportingRightAngledAxes(
-            DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) )
+            m_xDiagram->getChartTypeByIndex( 0 ) ) )
     {
         if(xDiagram.is())
             xDiagram->getPropertyValue("RightAngledAxes") >>= 
m_bRightAngledAxes;
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index e315b354136c..a102821cc409 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -927,7 +927,9 @@ bool getAvailablePosAndSizeForDiagram(
     rParam.mbUseFixedInnerSize = false;
 
     //@todo: we need a size dependent on the axis labels
-    rtl::Reference<ChartType> 
xChartType(DiagramHelper::getChartTypeByIndex(xDiagram, 0));
+    rtl::Reference<ChartType> xChartType;
+    if (xDiagram)
+        xChartType = xDiagram->getChartTypeByIndex(0);
 
     sal_Int32 nXDistance = sal_Int32(rPageSize.Width * 
constPageLayoutDistancePercentage);
     sal_Int32 nYDistance = sal_Int32(rPageSize.Height * 
constPageLayoutDistancePercentage);
@@ -1992,7 +1994,9 @@ bool ChartView::createAxisTitleShapes2D( 
CreateShapeParam2D& rParam, const css::
 {
     rtl::Reference<Diagram> xDiagram = mrChartModel.getFirstChartDiagram();
 
-    rtl::Reference< ChartType > xChartType( 
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+    rtl::Reference< ChartType > xChartType;
+    if (xDiagram)
+        xChartType = xDiagram->getChartTypeByIndex( 0 );
     sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram );
 
     if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) )

Reply via email to