chart2/source/controller/dialogs/DataBrowser.cxx        |    2 
 chart2/source/controller/dialogs/DialogModel.cxx        |   13 +---
 chart2/source/controller/main/ChartController.cxx       |   16 ++--
 chart2/source/controller/sidebar/ChartSeriesPanel.cxx   |   10 +--
 chart2/source/model/template/ChartTypeTemplate.cxx      |    4 -
 chart2/source/model/template/StockChartTypeTemplate.cxx |   52 ++++++----------
 chart2/source/tools/DiagramHelper.cxx                   |   34 +++-------
 chart2/source/tools/ObjectIdentifier.cxx                |   21 ++----
 8 files changed, 60 insertions(+), 92 deletions(-)

New commits:
commit 1be7f03c8f6b945a0fc6514e1f5c1e228ea03547
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Jan 27 18:37:14 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jan 29 12:52:43 2022 +0100

    use more concrete types in chart2, ChartType
    
    Change-Id: I78fe27e14993b7a6e5d27662282241b3007ac03e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129113
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx 
b/chart2/source/controller/dialogs/DataBrowser.cxx
index 1df9535a5713..d8a69d1d6d35 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -1368,7 +1368,7 @@ IMPL_LINK( DataBrowser, SeriesHeaderChanged, 
impl::SeriesHeaderEdit&, rEdit, voi
     if( !xSource.is())
         return;
 
-    Reference< chart2::XChartType > xChartType(
+    rtl::Reference< ChartType > xChartType(
         m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType );
     if( xChartType.is())
     {
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx 
b/chart2/source/controller/dialogs/DialogModel.cxx
index a68f75d077b6..ddf422dbb1f9 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -230,7 +230,7 @@ Sequence< OUString > lcl_CopyExcludingValuesFirst(
 
 Reference< XDataSeries > lcl_CreateNewSeries(
     const Reference< uno::XComponentContext > & xContext,
-    const uno::Reference< XChartType > & xChartType,
+    const rtl::Reference< ::chart::ChartType > & xChartType,
     sal_Int32 nNewSeriesIndex,
     sal_Int32 nTotalNumberOfSeriesInCTGroup,
     const rtl::Reference< ::chart::Diagram > & xDiagram,
@@ -256,12 +256,10 @@ Reference< XDataSeries > lcl_CreateNewSeries(
         sal_Int32 nGroupIndex=0;
         if( xChartType.is())
         {
-            auto pChartType = 
dynamic_cast<::chart::ChartType*>(xChartType.get());
-            assert(pChartType);
             std::vector< rtl::Reference< ::chart::ChartType > > aCTs(
                 ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ));
             for( ; nGroupIndex < static_cast<sal_Int32>(aCTs.size()); 
++nGroupIndex)
-                if( aCTs[nGroupIndex] == pChartType )
+                if( aCTs[nGroupIndex] == xChartType )
                     break;
             if( nGroupIndex == static_cast<sal_Int32>(aCTs.size()))
                 nGroupIndex = 0;
@@ -484,12 +482,11 @@ void addMissingRoles(DialogModel::tRolesWithRanges& 
rResult, const uno::Sequence
  * @param xNewSeries new data series to insert.
  */
 void addNewSeriesToContainer(
-    const Reference<XChartType>& xChartType,
+    const rtl::Reference<ChartType>& xChartType,
     const Reference<XDataSeries>& xSeries,
     const Reference<XDataSeries>& xNewSeries )
 {
-    Reference<XDataSeriesContainer> xSeriesCnt(xChartType, 
uno::UNO_QUERY_THROW);
-    auto aSeries = 
comphelper::sequenceToContainer<std::vector<Reference<XDataSeries> 
>>(xSeriesCnt->getDataSeries());
+    auto aSeries = 
comphelper::sequenceToContainer<std::vector<Reference<XDataSeries> 
>>(xChartType->getDataSeries());
 
     std::vector<Reference<XDataSeries> >::iterator aIt =
         std::find( aSeries.begin(), aSeries.end(), xSeries);
@@ -502,7 +499,7 @@ void addNewSeriesToContainer(
         ++aIt;
 
     aSeries.insert(aIt, xNewSeries);
-    xSeriesCnt->setDataSeries(comphelper::containerToSequence(aSeries));
+    xChartType->setDataSeries(comphelper::containerToSequence(aSeries));
 }
 
 }
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 5a25f761e896..544064064573 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -27,6 +27,7 @@
 #include <dlg_DataSource.hxx>
 #include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
+#include <ChartType.hxx>
 #include "ControllerCommandDispatch.hxx"
 #include <Diagram.hxx>
 #include <strings.hrc>
@@ -231,20 +232,17 @@ bool ChartController::TheModelRef::is() const
 
 namespace {
 
-css::uno::Reference<css::chart2::XChartType> getChartType(
-        const rtl::Reference<ChartModel>& xChartDoc)
+rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& 
xChartDoc)
 {
     rtl::Reference<Diagram > xDiagram = xChartDoc->getFirstChartDiagram();
     if (!xDiagram.is())
-        return css::uno::Reference<css::chart2::XChartType>();
+        return nullptr;
 
-    const std::vector< rtl::Reference< BaseCoordinateSystem > > 
xCooSysSequence( xDiagram->getBaseCoordinateSystems());
+    const std::vector< rtl::Reference< BaseCoordinateSystem > > & 
xCooSysSequence( xDiagram->getBaseCoordinateSystems());
     if (xCooSysSequence.empty())
-        return css::uno::Reference<css::chart2::XChartType>();
-
-    Sequence< Reference< chart2::XChartType > > xChartTypeSequence( 
xCooSysSequence[0]->getChartTypes() );
+        return nullptr;
 
-    return xChartTypeSequence[0];
+    return xCooSysSequence[0]->getChartTypes2()[0];
 }
 
 }
@@ -279,7 +277,7 @@ OUString ChartController::GetContextName()
             return "Grid";
         case OBJECTTYPE_DIAGRAM:
             {
-                css::uno::Reference<css::chart2::XChartType> xChartType = 
getChartType(getChartModel());
+                rtl::Reference<ChartType> xChartType = 
getChartType(getChartModel());
                 if (xChartType.is() && xChartType->getChartType() == 
"com.sun.star.chart2.PieChartType")
                     return "ChartElements";
                 break;
diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx 
b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
index a9a77652d11e..b03e3b721e36 100644
--- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx
@@ -33,6 +33,7 @@
 #include "ChartSeriesPanel.hxx"
 #include <ChartController.hxx>
 #include <ChartModel.hxx>
+#include <ChartType.hxx>
 #include <DataSeriesHelper.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
@@ -226,13 +227,12 @@ void setAttachedAxisType(const 
rtl::Reference<::chart::ChartModel>&
     DiagramHelper::attachSeriesToAxis(bPrimary, xDataSeries, xDiagram, 
comphelper::getProcessComponentContext());
 }
 
-css::uno::Reference<css::chart2::XChartType> getChartType(
+rtl::Reference<ChartType> getChartType(
         const rtl::Reference<::chart::ChartModel>& xModel)
 {
     rtl::Reference<Diagram> xDiagram = xModel->getFirstChartDiagram();
-    const std::vector< rtl::Reference< BaseCoordinateSystem > > 
xCooSysSequence( xDiagram->getBaseCoordinateSystems());
-    css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > 
xChartTypeSequence( xCooSysSequence[0]->getChartTypes() );
-    return xChartTypeSequence[0];
+    const std::vector< rtl::Reference< BaseCoordinateSystem > > & 
xCooSysSequence( xDiagram->getBaseCoordinateSystems());
+    return xCooSysSequence[0]->getChartTypes2()[0];
 }
 
 OUString getSeriesLabel(const rtl::Reference<::chart::ChartModel>& xModel, 
const OUString& rCID)
@@ -243,7 +243,7 @@ OUString getSeriesLabel(const 
rtl::Reference<::chart::ChartModel>& xModel, const
     if (!xSeries.is())
         return OUString();
 
-    css::uno::Reference<css::chart2::XChartType> xChartType = 
getChartType(xModel);
+    rtl::Reference<ChartType> xChartType = getChartType(xModel);
     return DataSeriesHelper::getDataSeriesLabel(xSeries, 
xChartType->getRoleOfSequenceForSeriesLabel());
 }
 
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index c3be03150fea..72e6fe64be16 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -311,7 +311,7 @@ bool ChartTypeTemplate::matchesTemplate(
         if( bResult )
         {
             std::vector< rtl::Reference< ChartType > > aFormerlyUsedChartTypes;
-            Reference<XChartType> xOldCT = 
getChartTypeForNewSeries(aFormerlyUsedChartTypes);
+            rtl::Reference<ChartType> xOldCT = 
getChartTypeForNewSeries(aFormerlyUsedChartTypes);
             if (!xOldCT.is())
                 return false;
 
@@ -322,7 +322,7 @@ bool ChartTypeTemplate::matchesTemplate(
                 // match dimension
                 bResult = bResult && (aCooSysSeq[nCooSysIdx]->getDimension() 
== nDimensionToMatch);
 
-                std::vector< rtl::Reference< ChartType > > aChartTypeSeq( 
aCooSysSeq[nCooSysIdx]->getChartTypes2());
+                const std::vector< rtl::Reference< ChartType > > & 
aChartTypeSeq( aCooSysSeq[nCooSysIdx]->getChartTypes2());
                 for( sal_Int32 nCTIdx=0; bResult && (nCTIdx < 
static_cast<sal_Int32>(aChartTypeSeq.size())); ++nCTIdx )
                 {
                     // match chart type
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx 
b/chart2/source/model/template/StockChartTypeTemplate.cxx
index f55ee2b038e2..c437270bc678 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -364,29 +364,25 @@ bool StockChartTypeTemplate::matchesTemplate(
         getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= 
bHasOpenValue;
         getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= 
bHasJapaneseStyle;
 
-        Reference< chart2::XChartType > xVolumeChartType;
-        Reference< chart2::XChartType > xCandleStickChartType;
-        Reference< chart2::XChartType > xLineChartType;
+        rtl::Reference< ChartType > xVolumeChartType;
+        rtl::Reference< ChartType > xCandleStickChartType;
+        rtl::Reference< ChartType > xLineChartType;
         sal_Int32 nNumberOfChartTypes = 0;
 
         for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
         {
-            const Sequence< Reference< XChartType > > aChartTypeSeq( 
coords->getChartTypes());
-            for( Reference< XChartType >  const & chartType : aChartTypeSeq )
+            for( rtl::Reference< ChartType >  const & chartType : 
coords->getChartTypes2() )
             {
-                if( chartType.is())
-                {
-                    ++nNumberOfChartTypes;
-                    if( nNumberOfChartTypes > 3 )
-                        break;
-                    OUString aCTService = chartType->getChartType();
-                    if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
-                        xVolumeChartType.set( chartType );
-                    else if( aCTService == 
CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
-                        xCandleStickChartType.set( chartType );
-                    else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
-                        xLineChartType.set( chartType );
-                }
+                ++nNumberOfChartTypes;
+                if( nNumberOfChartTypes > 3 )
+                    break;
+                OUString aCTService = chartType->getChartType();
+                if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
+                    xVolumeChartType = chartType;
+                else if( aCTService == 
CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+                    xCandleStickChartType = chartType;
+                else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
+                    xLineChartType = chartType;
             }
             if( nNumberOfChartTypes > 3 )
                 break;
@@ -397,18 +393,14 @@ bool StockChartTypeTemplate::matchesTemplate(
             bResult = true;
 
             // check for japanese style
-            Reference< beans::XPropertySet > xCTProp( xCandleStickChartType, 
uno::UNO_QUERY );
-            if( xCTProp.is())
-            {
-                bool bJapaneseProp = false;
-                xCTProp->getPropertyValue( "Japanese") >>= bJapaneseProp;
-                bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
-
-                // in old chart japanese == showFirst
-                bool bShowFirstProp = false;
-                xCTProp->getPropertyValue( "ShowFirst") >>= bShowFirstProp;
-                bResult = bResult && ( bHasOpenValue == bShowFirstProp );
-            }
+            bool bJapaneseProp = false;
+            xCandleStickChartType->getPropertyValue( "Japanese") >>= 
bJapaneseProp;
+            bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
+
+            // in old chart japanese == showFirst
+            bool bShowFirstProp = false;
+            xCandleStickChartType->getPropertyValue( "ShowFirst") >>= 
bShowFirstProp;
+            bResult = bResult && ( bHasOpenValue == bShowFirstProp );
         }
     }
     catch( const uno::Exception & )
diff --git a/chart2/source/tools/DiagramHelper.cxx 
b/chart2/source/tools/DiagramHelper.cxx
index d53f9210a57f..1789515e7d7c 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -260,19 +260,14 @@ void DiagramHelper::setStackMode(
                 }
             }
             //iterate through all chart types in the current coordinate system
-            uno::Sequence< uno::Reference< XChartType > > aChartTypeList( 
xCooSys->getChartTypes() );
-            if (!aChartTypeList.hasElements())
+            const std::vector< rtl::Reference< ChartType > > & aChartTypeList( 
xCooSys->getChartTypes2() );
+            if (aChartTypeList.empty())
                 continue;
 
-            uno::Reference< XChartType > xChartType( aChartTypeList[0] );
+            rtl::Reference< ChartType > xChartType( aChartTypeList[0] );
 
             //iterate through all series in this chart type
-            uno::Reference< XDataSeriesContainer > xDataSeriesContainer( 
xChartType, uno::UNO_QUERY );
-            OSL_ASSERT( xDataSeriesContainer.is());
-            if( !xDataSeriesContainer.is() )
-                continue;
-
-            const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( 
xDataSeriesContainer->getDataSeries() );
+            const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( 
xChartType->getDataSeries() );
             for( uno::Reference< XDataSeries > const & dataSeries : 
aSeriesList )
             {
                 Reference< beans::XPropertySet > xProp( dataSeries, 
uno::UNO_QUERY );
@@ -614,11 +609,9 @@ std::vector< Reference< XDataSeries > >
     {
         for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
         {
-            const Sequence< Reference< XChartType > > aChartTypeSeq( 
coords->getChartTypes());
-            for( Reference< XChartType> const & chartType : aChartTypeSeq )
+            for( rtl::Reference< ChartType> const & chartType : 
coords->getChartTypes2() )
             {
-                Reference< XDataSeriesContainer > xDSCnt( chartType, 
uno::UNO_QUERY_THROW );
-                const Sequence< Reference< XDataSeries > > aSeriesSeq( 
xDSCnt->getDataSeries() );
+                const Sequence< Reference< XDataSeries > > aSeriesSeq( 
chartType->getDataSeries() );
                 aResult.insert( aResult.end(), aSeriesSeq.begin(), 
aSeriesSeq.end() );
             }
         }
@@ -643,13 +636,9 @@ Sequence< Sequence< Reference< XDataSeries > > >
     for( rtl::Reference< BaseCoordinateSystem > const & coords : 
xDiagram->getBaseCoordinateSystems() )
     {
         //iterate through all chart types in the current coordinate system
-        const Sequence< Reference< XChartType > > aChartTypeList( 
coords->getChartTypes() );
-        for( Reference< XChartType >  const & chartType : aChartTypeList )
+        for( rtl::Reference< ChartType >  const & chartType : 
coords->getChartTypes2() )
         {
-            Reference< XDataSeriesContainer > xDataSeriesContainer( chartType, 
uno::UNO_QUERY );
-            if( !xDataSeriesContainer.is() )
-                continue;
-            aResult.push_back( xDataSeriesContainer->getDataSeries() );
+            aResult.push_back( chartType->getDataSeries() );
         }
     }
     return comphelper::containerToSequence( aResult );
@@ -833,16 +822,13 @@ Reference< data::XLabeledDataSequence >
 
 static void lcl_generateAutomaticCategoriesFromChartType(
             Sequence< OUString >& rRet,
-            const Reference< XChartType >& xChartType )
+            const rtl::Reference< ChartType >& xChartType )
 {
     if(!xChartType.is())
         return;
     OUString aMainSeq( xChartType->getRoleOfSequenceForSeriesLabel() );
-    Reference< XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY );
-    if( !xSeriesCnt.is() )
-        return;
 
-    const Sequence< Reference< XDataSeries > > aSeriesSeq( 
xSeriesCnt->getDataSeries() );
+    const Sequence< Reference< XDataSeries > > aSeriesSeq( 
xChartType->getDataSeries() );
     for( Reference< XDataSeries > const & dataSeries : aSeriesSeq )
     {
         Reference< data::XDataSource > xDataSource( dataSeries, uno::UNO_QUERY 
);
diff --git a/chart2/source/tools/ObjectIdentifier.cxx 
b/chart2/source/tools/ObjectIdentifier.cxx
index 691e7f475c26..bfa4796f9598 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -129,7 +129,7 @@ OUString lcl_getTitleParentParticle( 
TitleHelper::eTitleType aTitleType )
     return aRet;
 }
 
-Reference<XChartType> lcl_getFirstStockChartType( const 
rtl::Reference<::chart::ChartModel>& xChartModel )
+rtl::Reference<ChartType> lcl_getFirstStockChartType( const 
rtl::Reference<::chart::ChartModel>& xChartModel )
 {
     rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartModel ) );
     if(!xDiagram.is())
@@ -141,11 +141,8 @@ Reference<XChartType> lcl_getFirstStockChartType( const 
rtl::Reference<::chart::
     for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysList )
     {
         //iterate through all chart types in the current coordinate system
-        const uno::Sequence< Reference< XChartType > > aChartTypeList( 
coords->getChartTypes() );
-        for( Reference< XChartType > const & xChartType : aChartTypeList )
+        for( rtl::Reference< ChartType > const & xChartType : 
coords->getChartTypes2() )
         {
-            if(!xChartType.is())
-                continue;
             OUString aChartType = xChartType->getChartType();
             if( 
aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
                 return xChartType;
@@ -1183,18 +1180,16 @@ Reference< beans::XPropertySet > 
ObjectIdentifier::getObjectPropertySet(
                     break;
             case OBJECTTYPE_DATA_STOCK_LOSS:
                     {
-                        Reference<XChartType> xChartType( 
lcl_getFirstStockChartType( xChartModel ) );
-                        Reference< beans::XPropertySet > xChartTypeProps( 
xChartType, uno::UNO_QUERY );
-                        if(xChartTypeProps.is())
-                            xChartTypeProps->getPropertyValue( "BlackDay" ) 
>>= xObjectProperties;
+                        rtl::Reference<ChartType> xChartType( 
lcl_getFirstStockChartType( xChartModel ) );
+                        if(xChartType.is())
+                            xChartType->getPropertyValue( "BlackDay" ) >>= 
xObjectProperties;
                     }
                     break;
             case OBJECTTYPE_DATA_STOCK_GAIN:
                     {
-                        Reference<XChartType> xChartType( 
lcl_getFirstStockChartType( xChartModel ) );
-                        Reference< beans::XPropertySet > xChartTypeProps( 
xChartType, uno::UNO_QUERY );
-                        if(xChartTypeProps.is())
-                            xChartTypeProps->getPropertyValue( "WhiteDay" ) 
>>= xObjectProperties;
+                        rtl::Reference<ChartType> xChartType( 
lcl_getFirstStockChartType( xChartModel ) );
+                        if(xChartType.is())
+                            xChartType->getPropertyValue( "WhiteDay" ) >>= 
xObjectProperties;
                     }
                     break;
             default: //OBJECTTYPE_UNKNOWN

Reply via email to