chart2/source/inc/ChartTypeTemplate.hxx             |    4 +++-
 chart2/source/model/main/ChartModel_Persistence.cxx |   10 +++++-----
 chart2/source/model/template/ChartTypeTemplate.cxx  |   11 ++++-------
 3 files changed, 12 insertions(+), 13 deletions(-)

New commits:
commit afc49a652ec2eb5cce7a68918b6c5e6d9e8c2813
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Jan 22 19:29:36 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Jan 23 10:18:19 2022 +0100

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

diff --git a/chart2/source/inc/ChartTypeTemplate.hxx 
b/chart2/source/inc/ChartTypeTemplate.hxx
index 123fec2c8f6a..331298a0e8da 100644
--- a/chart2/source/inc/ChartTypeTemplate.hxx
+++ b/chart2/source/inc/ChartTypeTemplate.hxx
@@ -39,6 +39,7 @@ namespace com::sun::star::uno { class XComponentContext; }
 namespace chart
 {
 class ChartType;
+class Diagram;
 
 /** For creating diagrams and modifying existing diagrams.  A base class that
     implements XChartTypeTemplate and offers some tooling for classes that
@@ -82,7 +83,8 @@ public:
         const OUString & rServiceName );
     virtual ~ChartTypeTemplate() override;
 
-    virtual css::uno::Reference< css::chart2::XDiagram > 
createDiagramByDataSource(
+    OOO_DLLPUBLIC_CHARTTOOLS
+    rtl::Reference< ::chart::Diagram > createDiagramByDataSource(
         const css::uno::Reference< css::chart2::data::XDataSource >& 
xDataSource,
         const css::uno::Sequence< css::beans::PropertyValue >& aArguments );
     /// denotes if the chart needs categories at the first scale
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx 
b/chart2/source/model/main/ChartModel_Persistence.cxx
index 975ffaeb1d81..7d891996d9b5 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -27,6 +27,7 @@
 #include <DataSourceHelper.hxx>
 #include <AxisHelper.hxx>
 #include <ThreeDHelper.hxx>
+#include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <BaseCoordinateSystem.hxx>
 
@@ -402,7 +403,7 @@ void ChartModel::insertDefaultChart()
                                                      
beans::PropertyState_DIRECT_VALUE ) };
                 }
 
-                Reference< chart2::XDiagram > xDiagram( 
xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+                rtl::Reference< Diagram > xDiagram( 
xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
 
                 setFirstDiagram( xDiagram );
 
@@ -430,11 +431,10 @@ void ChartModel::insertDefaultChart()
                     xDiagram->setLegend( xLegend );
 
                 // set simple 3D look
-                Reference< beans::XPropertySet > xDiagramProperties( xDiagram, 
uno::UNO_QUERY );
-                if( xDiagramProperties.is() )
+                if( xDiagram.is() )
                 {
-                    xDiagramProperties->setPropertyValue( "RightAngledAxes", 
uno::Any( true ));
-                    xDiagramProperties->setPropertyValue( 
"D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL ));
+                    xDiagram->setPropertyValue( "RightAngledAxes", uno::Any( 
true ));
+                    xDiagram->setPropertyValue( "D3DScenePerspective", 
uno::Any( drawing::ProjectionMode_PARALLEL ));
                     ThreeDHelper::setScheme( xDiagram, 
ThreeDLookScheme::ThreeDLookScheme_Realistic );
                 }
 
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index 38c8466e49e7..44f33ace9e1e 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -24,6 +24,7 @@
 #include <ChartType.hxx>
 
 #include <AxisHelper.hxx>
+#include <Diagram.hxx>
 #include <DiagramHelper.hxx>
 #include <AxisIndexDefines.hxx>
 #include <unonames.hxx>
@@ -137,20 +138,16 @@ ChartTypeTemplate::~ChartTypeTemplate()
 {}
 
 // ____ ChartTypeTemplate ____
-uno::Reference< XDiagram > ChartTypeTemplate::createDiagramByDataSource(
+rtl::Reference< Diagram > ChartTypeTemplate::createDiagramByDataSource(
     const uno::Reference< data::XDataSource >& xDataSource,
     const uno::Sequence< beans::PropertyValue >& aArguments )
 {
-    Reference< XDiagram > xDia;
+    rtl::Reference< Diagram > xDia;
 
     try
     {
         // create diagram
-        xDia.set(
-            
GetComponentContext()->getServiceManager()->createInstanceWithContext(
-                "com.sun.star.chart2.Diagram",
-                GetComponentContext() ),
-            uno::UNO_QUERY_THROW );
+        xDia = new Diagram(GetComponentContext());
 
         // modify diagram
         Reference< chart2::XDataInterpreter > xInterpreter( 
getDataInterpreter());

Reply via email to