chart2/inc/ChartModel.hxx                                           |    5 ++-
 chart2/inc/ChartTypeManager.hxx                                     |    4 +-
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx   |    7 ++--
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx         |   15 
+++++----
 chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx |   15 
+++++----
 chart2/source/model/main/ChartModel.cxx                             |   16 
+++++-----
 chart2/source/model/main/ChartModel_Persistence.cxx                 |    5 +--
 chart2/source/model/main/Diagram.cxx                                |    4 +-
 solenv/clang-format/excludelist                                     |    2 -
 9 files changed, 40 insertions(+), 33 deletions(-)

New commits:
commit aa06241b9c90cd41bed804bd1d55233b28f03886
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jan 18 15:21:16 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jan 18 18:11:03 2022 +0100

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

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index 4717b30a9cbe..9f2c58bdeb78 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -70,6 +70,7 @@ class SvNumberFormatter;
 namespace chart
 {
 class Diagram;
+class ChartTypeManager;
 
 namespace impl
 {
@@ -155,7 +156,7 @@ private:
                                 m_xNumberFormatsSupplier;
     std::unique_ptr< SvNumberFormatter > m_apSvNumberFormatter; // #i113784# 
avoid memory leak
 
-    css::uno::Reference< css::chart2::XChartTypeManager >
+    rtl::Reference< ::chart::ChartTypeManager >
         m_xChartTypeManager;
 
     // Diagram Access
@@ -468,6 +469,8 @@ public:
 
     void removeDataProviders();
 
+    const rtl::Reference< ::chart::ChartTypeManager > & getTypeManager() const 
{ return m_xChartTypeManager; }
+
     /// See sfx2::XmlDump::dumpAsXml().
     void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
diff --git a/chart2/source/model/inc/ChartTypeManager.hxx 
b/chart2/inc/ChartTypeManager.hxx
similarity index 96%
rename from chart2/source/model/inc/ChartTypeManager.hxx
rename to chart2/inc/ChartTypeManager.hxx
index 244ea507234a..45e571f7aab5 100644
--- a/chart2/source/model/inc/ChartTypeManager.hxx
+++ b/chart2/inc/ChartTypeManager.hxx
@@ -22,13 +22,14 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/chart2/XChartTypeManager.hpp>
+#include <charttoolsdllapi.hxx>
 
 namespace com::sun::star::uno { class XComponentContext; }
 
 namespace chart
 {
 
-class ChartTypeManager final :
+class OOO_DLLPUBLIC_CHARTTOOLS ChartTypeManager final :
         public ::cppu::WeakImplHelper<
         css::lang::XServiceInfo,
         css::lang::XMultiServiceFactory,
@@ -49,7 +50,6 @@ public:
         getSupportedServiceNames()
         override;
 
-protected:
     // ____ XMultiServiceFactory ____
     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL 
createInstance( const OUString& aServiceSpecifier ) override;
     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL 
createInstanceWithArguments(
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 98085165da86..a40eb57dc2f6 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -19,6 +19,7 @@
 
 #include <ChartDocumentWrapper.hxx>
 #include <ChartView.hxx>
+#include <ChartTypeManager.hxx>
 #include <servicenames.hxx>
 #include <PropertyHelper.hxx>
 #include <TitleHelper.hxx>
@@ -1070,8 +1071,8 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
     if( aIt != rMap.end())
     {
         bool bCreateDiagram = false;
-        uno::Reference< lang::XMultiServiceFactory > xManagerFact(
-            xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+        rtl::Reference< ::chart::ChartTypeManager > xManagerFact =
+            xChartDoc->getTypeManager();
         uno::Reference< chart2::XChartTypeTemplate > xTemplate;
 
         switch( (*aIt).second )
@@ -1198,7 +1199,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
                     ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
                     Reference< chart2::XDiagram > xDiagram = 
ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xChartDoc) );
                     ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( 
xDiagram );
-                    Reference< lang::XMultiServiceFactory > xTemplateManager( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+                    rtl::Reference< ::chart::ChartTypeManager > 
xTemplateManager = xChartDoc->getTypeManager();
                     DiagramHelper::tTemplateWithServiceName 
aTemplateWithService(
                         DiagramHelper::getTemplateForDiagram( xDiagram, 
xTemplateManager ));
                     if( aTemplateWithService.first.is())
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 1f1e159f23f5..c977301a78ac 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -43,6 +43,7 @@
 #include <unonames.hxx>
 #include <comphelper/sequence.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <ChartTypeManager.hxx>
 
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -600,7 +601,7 @@ OUString SAL_CALL DiagramWrapper::getDiagramType()
             }
         }
 
-        Reference< lang::XMultiServiceFactory > xChartTypeManager( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+        rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
         DiagramHelper::tTemplateWithServiceName aTemplateAndService =
             DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager 
);
 
@@ -1463,9 +1464,9 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( 
uno::Any& rInnerValue ) con
             DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
         if( !aSeriesVector.empty() )
         {
-            Reference< lang::XMultiServiceFactory > xFact( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+            rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
             DiagramHelper::tTemplateWithServiceName aTemplateAndService =
-                    DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+                    DiagramHelper::getTemplateForDiagram( xDiagram, 
xChartTypeManager );
             if( aTemplateAndService.second == 
"com.sun.star.chart2.template.ColumnWithLine" )
             {
                 try
@@ -1500,9 +1501,9 @@ void WrappedNumberOfLinesProperty::setPropertyValue( 
const Any& rOuterValue, con
     if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) )
         return;
 
-    Reference< lang::XMultiServiceFactory > xFact( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+    rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
     DiagramHelper::tTemplateWithServiceName aTemplateAndService =
-            DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+            DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager 
);
 
     uno::Reference< chart2::XChartTypeTemplate > xTemplate;
     if( aTemplateAndService.second == 
"com.sun.star.chart2.template.ColumnWithLine" )
@@ -1525,14 +1526,14 @@ void WrappedNumberOfLinesProperty::setPropertyValue( 
const Any& rOuterValue, con
         }
         else
         {
-            xTemplate.set( 
xFact->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY );
+            xTemplate.set( 
xChartTypeManager->createInstance("com.sun.star.chart2.template.Column"), 
uno::UNO_QUERY );
         }
     }
     else if( aTemplateAndService.second == 
"com.sun.star.chart2.template.Column" )
     {
         if( nNewValue == 0 )
             return;
-        xTemplate.set( xFact->createInstance( 
"com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY );
+        xTemplate.set( xChartTypeManager->createInstance( 
"com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY );
     }
 
     if(!xTemplate.is())
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 9dba30e36030..9074ec92a6c4 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <tools/diagnose_ex.h>
+#include <ChartTypeManager.hxx>
 
 using namespace ::com::sun::star;
 using ::com::sun::star::uno::Reference;
@@ -81,12 +82,12 @@ void WrappedStockProperty::setPropertyValue( const 
css::uno::Any& rOuterValue, c
     if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) )
         return;
 
-    Reference< lang::XMultiServiceFactory > xFactory( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+    rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
     DiagramHelper::tTemplateWithServiceName aTemplateAndService =
-            DiagramHelper::getTemplateForDiagram( xDiagram, xFactory );
+            DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager 
);
 
     uno::Reference< chart2::XChartTypeTemplate > xTemplate =
-            getNewTemplate( bNewValue, aTemplateAndService.second, xFactory );
+            getNewTemplate( bNewValue, aTemplateAndService.second, 
xChartTypeManager );
 
     if(!xTemplate.is())
         return;
@@ -137,9 +138,9 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( 
const css::uno::Reference
             DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
         if( !aSeriesVector.empty() )
         {
-            Reference< lang::XMultiServiceFactory > xFact( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+            rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
             DiagramHelper::tTemplateWithServiceName aTemplateAndService =
-                    DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+                    DiagramHelper::getTemplateForDiagram( xDiagram, 
xChartTypeManager );
 
             if(    aTemplateAndService.second == 
"com.sun.star.chart2.template.StockVolumeLowHighClose"
                 || aTemplateAndService.second == 
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
@@ -206,9 +207,9 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( 
const css::uno::Reference
             DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
         if( !aSeriesVector.empty() )
         {
-            Reference< lang::XMultiServiceFactory > xFact( 
xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+            rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
xChartDoc->getTypeManager();
             DiagramHelper::tTemplateWithServiceName aTemplateAndService =
-                    DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+                    DiagramHelper::getTemplateForDiagram( xDiagram, 
xChartTypeManager );
 
             if(    aTemplateAndService.second == 
"com.sun.star.chart2.template.StockOpenLowHighClose"
                 || aTemplateAndService.second == 
"com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
diff --git a/chart2/source/model/main/ChartModel.cxx 
b/chart2/source/model/main/ChartModel.cxx
index 0e494311a32e..6d75a433ebf9 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <ChartModel.hxx>
+#include <ChartTypeManager.hxx>
 #include <servicenames.hxx>
 #include <DataSourceHelper.hxx>
 #include <ChartModelHelper.hxx>
@@ -110,8 +111,7 @@ 
ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
 
     {
         ModifyListenerHelper::addListener( m_xPageBackground, this );
-        m_xChartTypeManager.set( 
xContext->getServiceManager()->createInstanceWithContext(
-                "com.sun.star.chart2.ChartTypeManager", m_xContext ), 
uno::UNO_QUERY );
+        m_xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
     }
     osl_atomic_decrement(&m_refCount);
 }
@@ -152,7 +152,7 @@ ChartModel::ChartModel( const ChartModel & rOther )
         Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle 
>()( rOther.m_xTitle );
         rtl::Reference< ::chart::Diagram > xNewDiagram = new ::chart::Diagram( 
*rOther.m_xDiagram );
         Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< 
beans::XPropertySet >()( rOther.m_xPageBackground );
-        Reference< chart2::XChartTypeManager > xChartTypeManager = 
CreateRefClone< chart2::XChartTypeManager >()( rOther.m_xChartTypeManager );
+        rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager; // does 
not implement XCloneable
         Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< 
container::XNameAccess >()( rOther.m_xXMLNamespaceMap );
 
         {
@@ -540,7 +540,7 @@ void SAL_CALL ChartModel::dispose()
     m_xInternalDataProvider.clear();
     m_xNumberFormatsSupplier.clear();
     DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
-    DisposeHelper::DisposeAndClear( m_xChartTypeManager );
+    m_xChartTypeManager.clear();
     m_xDiagram.clear();
     DisposeHelper::DisposeAndClear( m_xTitle );
     DisposeHelper::DisposeAndClear( m_xPageBackground );
@@ -896,9 +896,8 @@ Reference<awt::XRequestCallback> SAL_CALL 
ChartModel::getPopupRequest()
 Reference< chart2::XChartTypeTemplate > 
ChartModel::impl_createDefaultChartTypeTemplate()
 {
     Reference< chart2::XChartTypeTemplate > xTemplate;
-    Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, 
uno::UNO_QUERY );
-    if( xFact.is() )
-        xTemplate.set( xFact->createInstance( 
"com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+    if( m_xChartTypeManager.is() )
+        xTemplate.set( m_xChartTypeManager->createInstance( 
"com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
     return xTemplate;
 }
 
@@ -906,7 +905,8 @@ void SAL_CALL ChartModel::setChartTypeManager( const 
uno::Reference< chart2::XCh
 {
     {
         MutexGuard aGuard( m_aModelMutex );
-        m_xChartTypeManager = xNewManager;
+        m_xChartTypeManager = 
dynamic_cast<::chart::ChartTypeManager*>(xNewManager.get());
+        assert(!xNewManager || m_xChartTypeManager);
     }
     setModified( true );
 }
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx 
b/chart2/source/model/main/ChartModel_Persistence.cxx
index b246aa18f2b1..2bd9327babe5 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -22,6 +22,7 @@
 #include <MediaDescriptorHelper.hxx>
 #include <ChartViewHelper.hxx>
 #include <ChartModelHelper.hxx>
+#include <ChartTypeManager.hxx>
 #include <DataSourceHelper.hxx>
 #include <AxisHelper.hxx>
 #include <ThreeDHelper.hxx>
@@ -724,10 +725,10 @@ void SAL_CALL ChartModel::modified( const 
lang::EventObject& rEvenObject)
                 DataSourceHelper::createArguments("PivotChart", 
uno::Sequence<sal_Int32>(), true, true, true);
 
             Reference<chart2::data::XDataSource> 
xDataSource(xDataProvider->createDataSource(aArguments));
-            Reference<lang::XMultiServiceFactory> 
xFactory(getChartTypeManager(), uno::UNO_QUERY);
+            rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = 
getTypeManager();
             Reference<chart2::XDiagram> xDiagram(getFirstDiagram());
 
-            DiagramHelper::tTemplateWithServiceName aTemplateAndService = 
DiagramHelper::getTemplateForDiagram(xDiagram, xFactory);
+            DiagramHelper::tTemplateWithServiceName aTemplateAndService = 
DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager);
             css::uno::Reference<css::chart2::XChartTypeTemplate> 
xChartTypeTemplate(aTemplateAndService.first);
             xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, 
aArguments);
         }
diff --git a/chart2/source/model/main/Diagram.cxx 
b/chart2/source/model/main/Diagram.cxx
index 7e85f9353395..c813831ef465 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <Diagram.hxx>
+#include <ChartTypeManager.hxx>
 #include <PropertyHelper.hxx>
 #include "Wall.hxx"
 #include <ModifyListenerHelper.hxx>
@@ -394,8 +395,7 @@ void SAL_CALL Diagram::setDiagramData(
     const Reference< chart2::data::XDataSource >& xDataSource,
     const Sequence< beans::PropertyValue >& aArguments )
 {
-    uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( 
m_xContext->getServiceManager()->createInstanceWithContext(
-            "com.sun.star.chart2.ChartTypeManager", m_xContext ), 
uno::UNO_QUERY );
+    rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new 
::chart::ChartTypeManager( m_xContext );
     DiagramHelper::tTemplateWithServiceName aTemplateAndService = 
DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
     uno::Reference< chart2::XChartTypeTemplate > xTemplate( 
aTemplateAndService.first );
     if( !xTemplate.is() )
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index f7ec1e1981a9..ccef2bf0bfff 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -743,6 +743,7 @@ canvas/source/vcl/windowoutdevholder.cxx
 canvas/source/vcl/windowoutdevholder.hxx
 canvas/workben/canvasdemo.cxx
 chart2/inc/ChartModel.hxx
+chart2/inc/ChartTypeManager.hxx
 chart2/inc/ChartView.hxx
 chart2/inc/unonames.hxx
 chart2/qa/extras/PivotChartTest.cxx
@@ -1074,7 +1075,6 @@ chart2/source/inc/chartview/ExplicitValueProvider.hxx
 chart2/source/inc/servicenames_coosystems.hxx
 chart2/source/model/filter/XMLFilter.cxx
 chart2/source/model/inc/BaseCoordinateSystem.hxx
-chart2/source/model/inc/ChartTypeManager.hxx
 chart2/source/model/inc/DataSeries.hxx
 chart2/source/model/inc/StockBar.hxx
 chart2/source/model/inc/XMLFilter.hxx

Reply via email to