chart2/source/controller/accessibility/AccessibleBase.cxx              |    3 
 chart2/source/controller/accessibility/AccessibleChartElement.cxx      |   17 
+--
 chart2/source/controller/accessibility/AccessibleChartView.cxx         |   21 
++--
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx        |   12 
+-
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx      |    2 
 chart2/source/controller/dialogs/ChartTypeDialogController.cxx         |    6 -
 chart2/source/controller/inc/AccessibleBase.hxx                        |    3 
 chart2/source/controller/inc/AccessibleChartView.hxx                   |    2 
 chart2/source/controller/inc/AxisItemConverter.hxx                     |    7 -
 chart2/source/controller/inc/DataPointItemConverter.hxx                |    5 -
 chart2/source/controller/inc/MultipleChartConverters.hxx               |   13 
+-
 chart2/source/controller/inc/ObjectHierarchy.hxx                       |   14 
+-
 chart2/source/controller/inc/PositionAndSizeHelper.hxx                 |    2 
 chart2/source/controller/inc/SelectionHelper.hxx                       |    4 
 chart2/source/controller/inc/SeriesOptionsItemConverter.hxx            |    6 -
 chart2/source/controller/inc/StatisticsItemConverter.hxx               |    6 -
 chart2/source/controller/inc/TextLabelItemConverter.hxx                |    5 -
 chart2/source/controller/inc/dlg_ChartType_UNO.hxx                     |    4 
 chart2/source/controller/inc/dlg_DataEditor.hxx                        |    1 
 chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx          |    7 -
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx     |    3 
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx    |   15 
+--
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |   10 
--
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx    |   11 
+-
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx     |    3 
 chart2/source/controller/main/ChartController.cxx                      |    2 
 chart2/source/controller/main/ChartController_Insert.cxx               |   10 
+-
 chart2/source/controller/main/ChartController_Properties.cxx           |   10 
+-
 chart2/source/controller/main/ChartController_TextEdit.cxx             |    2 
 chart2/source/controller/main/ChartController_Tools.cxx                |   26 
++---
 chart2/source/controller/main/ChartController_Window.cxx               |    2 
 chart2/source/controller/main/ControllerCommandDispatch.cxx            |   12 
+-
 chart2/source/controller/main/DragMethod_PieSegment.cxx                |    2 
 chart2/source/controller/main/DragMethod_RotateDiagram.cxx             |    6 -
 chart2/source/controller/main/ObjectHierarchy.cxx                      |   47 
++++------
 chart2/source/controller/main/PositionAndSizeHelper.cxx                |    3 
 chart2/source/controller/main/SelectionHelper.cxx                      |    5 -
 chart2/source/controller/uitest/uiobject.cxx                           |    3 
 chart2/source/inc/ChartModelHelper.hxx                                 |    2 
 chart2/source/tools/ChartModelHelper.cxx                               |   12 
++
 40 files changed, 170 insertions(+), 156 deletions(-)

New commits:
commit fadb53a393b52eb4c9336fa8c9c780b4d6b3e391
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 21 15:10:53 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jan 21 17:09:33 2022 +0100

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

diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx 
b/chart2/source/controller/accessibility/AccessibleBase.cxx
index a4c1a4befa2b..f419ba7f7942 100644
--- a/chart2/source/controller/accessibility/AccessibleBase.cxx
+++ b/chart2/source/controller/accessibility/AccessibleBase.cxx
@@ -45,6 +45,7 @@
 #include <o3tl/safeint.hxx>
 #include <tools/diagnose_ex.h>
 #include <unotools/accessiblestatesethelper.hxx>
+#include <ChartModel.hxx>
 
 #include <algorithm>
 #include <iterator>
@@ -733,7 +734,7 @@ Color AccessibleBase::getColor( eColorType eColType )
 
     xObjProp =
         ObjectIdentifier::getObjectPropertySet(
-            aObjectCID, Reference< chart2::XChartDocument >( 
m_aAccInfo.m_xChartDocument ));
+            aObjectCID, m_aAccInfo.m_xChartDocument );
     if( xObjProp.is())
     {
         try
diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx 
b/chart2/source/controller/accessibility/AccessibleChartElement.cxx
index 229cb2b86e2e..2afd4129e171 100644
--- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx
@@ -23,6 +23,7 @@
 #include <ObjectIdentifier.hxx>
 #include <ObjectNameProvider.hxx>
 #include <servicenames.hxx>
+#include <ChartModel.hxx>
 
 #include <com/sun/star/awt/XDevice.hpp>
 #include <com/sun/star/chart2/XTitle.hpp>
@@ -66,7 +67,7 @@ bool AccessibleChartElement::ImplUpdateChildren()
     bool bResult = false;
     Reference< chart2::XTitle > xTitle(
         ObjectIdentifier::getObjectPropertySet(
-            GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument 
>( GetInfo().m_xChartDocument )),
+            GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ),
         uno::UNO_QUERY );
     m_bHasText = xTitle.is();
 
@@ -149,12 +150,8 @@ OUString SAL_CALL 
AccessibleChartElement::getImplementationName()
 // ________ AccessibleChartElement::XAccessibleContext (override) ________
 OUString SAL_CALL AccessibleChartElement::getAccessibleName()
 {
-    uno::Reference<chart2::XChartDocument> xDoc = GetInfo().m_xChartDocument;
-    ChartModel* pChartModel = dynamic_cast<ChartModel*>(xDoc.get());
-    assert(!xDoc || pChartModel);
-
     return ObjectNameProvider::getNameForCID(
-        GetInfo().m_aOID.getObjectCID(), pChartModel );
+        GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
 }
 
 // ________ AccessibleChartElement::XAccessibleContext (override) ________
@@ -175,7 +172,7 @@ Reference< awt::XFont > SAL_CALL 
AccessibleChartElement::getFont()
     {
         Reference< beans::XMultiPropertySet > xObjProp(
             ObjectIdentifier::getObjectPropertySet(
-                GetInfo().m_aOID.getObjectCID(), Reference< 
chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
+                GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ), 
uno::UNO_QUERY );
         awt::FontDescriptor aDescr(
             CharacterProperties::createFontDescriptorFromPropertySet( xObjProp 
));
         xFont = xDevice->getFont( aDescr );
@@ -193,12 +190,8 @@ OUString SAL_CALL AccessibleChartElement::getToolTipText()
 {
     CheckDisposeState();
 
-    uno::Reference<chart2::XChartDocument> xDoc = GetInfo().m_xChartDocument;
-    ChartModel* pChartModel = dynamic_cast<ChartModel*>(xDoc.get());
-    assert(!xDoc || pChartModel);
-
     return ObjectNameProvider::getHelpText(
-        GetInfo().m_aOID.getObjectCID(), pChartModel );
+        GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
 }
 
 // ________ XAccessibleComponent ________
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx 
b/chart2/source/controller/accessibility/AccessibleChartView.cxx
index 6ea9befe8009..c0dac3c22657 100644
--- a/chart2/source/controller/accessibility/AccessibleChartView.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx
@@ -24,6 +24,7 @@
 #include <ResId.hxx>
 #include <strings.hrc>
 #include "AccessibleViewForwarder.hxx"
+#include <ChartModel.hxx>
 
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
@@ -171,14 +172,14 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
     bool bNewInvalid = false;
 
     Reference< view::XSelectionSupplier > xSelectionSupplier;
-    Reference< frame::XModel > xChartModel;
+    rtl::Reference<::chart::ChartModel> xChartModel;
     Reference< uno::XInterface > xChartView;
     Reference< XAccessible > xParent;
     Reference< awt::XWindow > xWindow;
     {
         MutexGuard aGuard( m_aMutex);
         xSelectionSupplier.set( m_xSelectionSupplier );
-        xChartModel.set( m_xChartModel );
+        xChartModel = m_xChartModel;
         xChartView.set( m_xChartView );
         xParent.set( m_xParent );
         xWindow.set( m_xWindow );
@@ -193,9 +194,11 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
     {
         Reference< frame::XModel > xNewChartModel;
         rArguments[1] >>= xNewChartModel;
-        if( xNewChartModel != xChartModel )
+        assert(!xNewChartModel || 
dynamic_cast<::chart::ChartModel*>(xNewChartModel.get()));
+        ::chart::ChartModel* pNewChartModel = 
dynamic_cast<::chart::ChartModel*>(xNewChartModel.get());
+        if( pNewChartModel != xChartModel.get() )
         {
-            xChartModel = xNewChartModel;
+            xChartModel = pNewChartModel;
             bChanged = true;
         }
     }
@@ -280,7 +283,7 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
     {
         MutexGuard aGuard( m_aMutex);
         m_xSelectionSupplier = WeakReference< view::XSelectionSupplier 
>(xSelectionSupplier);
-        m_xChartModel = WeakReference< frame::XModel >(xChartModel);
+        m_xChartModel = xChartModel.get();
         m_xChartView = WeakReference< uno::XInterface >(xChartView);
         m_xParent = WeakReference< XAccessible >(xParent);
         m_xWindow = WeakReference< awt::XWindow >(xWindow);
@@ -296,10 +299,9 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
         //before notification we prepare for creation of new context
         //the old context will be deleted after notification than
         MutexGuard aGuard( m_aMutex);
-        Reference< chart2::XChartDocument > xChartDoc( xChartModel, 
uno::UNO_QUERY );
-        if( xChartDoc.is())
+        if( xChartModel.is())
             m_spObjectHierarchy =
-                std::make_shared<ObjectHierarchy>( xChartDoc, 
comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView) );
+                std::make_shared<ObjectHierarchy>( xChartModel, 
comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView) );
         else
             m_spObjectHierarchy.reset();
     }
@@ -307,8 +309,7 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
     {
         AccessibleElementInfo aAccInfo;
         aAccInfo.m_aOID = ObjectIdentifier("ROOT");
-        aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument 
>(
-            uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), 
uno::UNO_QUERY ));
+        aAccInfo.m_xChartDocument = m_xChartModel;
         aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier;
         aAccInfo.m_xView = m_xChartView;
         aAccInfo.m_xWindow = m_xWindow;
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx 
b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 78eccbeed65a..aefdc29b1dce 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -154,7 +154,7 @@ sal_Int32 
Chart2ModelContact::getExplicitNumberFormatKeyForAxis(
 {
     Reference< chart2::XCoordinateSystem > xCooSys(
         AxisHelper::getCoordinateSystemOfAxis(
-              xAxis, ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) ) );
+              xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) );
 
     return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, 
xCooSys
               , m_xChartModel.get() );
@@ -193,7 +193,7 @@ awt::Rectangle 
Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
 awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
 {
     awt::Rectangle aRect(0,0,0,0);
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
+    rtl::Reference< Diagram > xDiagram =  ChartModelHelper::findDiagram( 
m_xChartModel );
 
     if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == 
DiagramPositioningMode_INCLUDING )
         aRect = 
DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get());
@@ -209,7 +209,7 @@ awt::Rectangle 
Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
 awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const
 {
     awt::Rectangle aRect(0,0,0,0);
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
+    rtl::Reference< Diagram > xDiagram =  ChartModelHelper::findDiagram( 
m_xChartModel );
 
     if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == 
DiagramPositioningMode_EXCLUDING )
         aRect = 
DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get());
@@ -229,7 +229,7 @@ awt::Size Chart2ModelContact::GetLegendSize() const
     if( pProvider )
     {
         uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_xChartModel.get() ) );
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, m_xChartModel.get() ) );
         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     }
     return aSize;
@@ -242,7 +242,7 @@ awt::Point Chart2ModelContact::GetLegendPosition() const
     if( pProvider )
     {
         uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_xChartModel.get() ) );
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, m_xChartModel.get() ) );
         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     }
     return aPoint;
@@ -254,7 +254,7 @@ awt::Size Chart2ModelContact::GetTitleSize( const 
uno::Reference< css::chart2::X
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider && xTitle.is() )
     {
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, m_xChartModel.get() ) );
         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     }
     return aSize;
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index c440692e95f3..e75bd16e8e24 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -1189,7 +1189,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
                 {
                     // locked controllers
                     ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
-                    rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xChartDoc) );
+                    rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xChartDoc );
                     ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( 
xDiagram );
                     rtl::Reference< ::chart::ChartTypeManager > 
xTemplateManager = xChartDoc->getTypeManager();
                     DiagramHelper::tTemplateWithServiceName 
aTemplateWithService(
diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx 
b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
index 0e7cd0e1ad18..06d2dd952892 100644
--- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
+++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx
@@ -1156,9 +1156,7 @@ void 
CombiColumnLineChartDialogController::fillExtraControls(
     if (!m_xMF_NumberOfLines)
         return;
 
-    uno::Reference< frame::XModel > xModel = xChartModel;
-
-    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xModel 
);
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartModel );
     if(!xDiagram.is())
         return;
 
@@ -1179,7 +1177,7 @@ void 
CombiColumnLineChartDialogController::fillExtraControls(
         nNumLines = 0;
     m_xMF_NumberOfLines->set_value(nNumLines);
 
-    sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xModel ).size() - 1;
+    sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xChartModel 
).size() - 1;
     if( nMaxLines < 0 )
         nMaxLines = 0;
     m_xMF_NumberOfLines->set_max(nMaxLines);
diff --git a/chart2/source/controller/inc/AccessibleBase.hxx 
b/chart2/source/controller/inc/AccessibleBase.hxx
index 92850dccfe44..4bd51c342678 100644
--- a/chart2/source/controller/inc/AccessibleBase.hxx
+++ b/chart2/source/controller/inc/AccessibleBase.hxx
@@ -31,6 +31,7 @@
 #include <cppuhelper/compbase.hxx>
 #include <rtl/ref.hxx>
 #include <tools/color.hxx>
+#include <unotools/weakref.hxx>
 
 #include <map>
 #include <vector>
@@ -61,7 +62,7 @@ struct AccessibleElementInfo
 {
     AccessibleUniqueId m_aOID;
 
-    css::uno::WeakReference< css::chart2::XChartDocument > m_xChartDocument;
+    unotools::WeakReference< ::chart::ChartModel > m_xChartDocument;
     css::uno::WeakReference< css::view::XSelectionSupplier > 
m_xSelectionSupplier;
     css::uno::WeakReference< css::uno::XInterface >   m_xView;
     css::uno::WeakReference< css::awt::XWindow >      m_xWindow;
diff --git a/chart2/source/controller/inc/AccessibleChartView.hxx 
b/chart2/source/controller/inc/AccessibleChartView.hxx
index 2e1473a546dc..eb3367b205d6 100644
--- a/chart2/source/controller/inc/AccessibleChartView.hxx
+++ b/chart2/source/controller/inc/AccessibleChartView.hxx
@@ -102,7 +102,7 @@ private: // methods
 
 private: // members
     css::uno::WeakReference< css::view::XSelectionSupplier >        
m_xSelectionSupplier;
-    css::uno::WeakReference< css::frame::XModel >                   
m_xChartModel;
+    unotools::WeakReference<::chart::ChartModel>                    
m_xChartModel;
     css::uno::WeakReference< css::uno::XInterface >                 
m_xChartView;
     css::uno::WeakReference< css::awt::XWindow >                    m_xWindow;
     css::uno::WeakReference< css::accessibility::XAccessible >      m_xParent;
diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx 
b/chart2/source/controller/inc/AxisItemConverter.hxx
index ffbe6eee4dc4..cbb75d2a1db6 100644
--- a/chart2/source/controller/inc/AxisItemConverter.hxx
+++ b/chart2/source/controller/inc/AxisItemConverter.hxx
@@ -19,6 +19,7 @@
 #pragma once
 
 #include "ItemConverter.hxx"
+#include <rtl/ref.hxx>
 
 #include <vector>
 
@@ -28,6 +29,7 @@ namespace com::sun::star::chart2 { class XAxis; }
 namespace com::sun::star::chart2 { class XChartDocument; }
 namespace chart { struct ExplicitIncrementData; }
 namespace chart { struct ExplicitScaleData; }
+namespace chart { class ChartModel; }
 
 class SdrModel;
 
@@ -39,7 +41,7 @@ public:
     AxisItemConverter(
         const css::uno::Reference<css::beans::XPropertySet>& rPropertySet,
         SfxItemPool& rItemPool, SdrModel& rDrawModel,
-        const css::uno::Reference<css::chart2::XChartDocument> & xChartDoc,
+        const rtl::Reference<::chart::ChartModel> & xChartDoc,
         ExplicitScaleData const * pScale,
         ExplicitIncrementData const * pIncrement,
         const css::awt::Size* pRefSize );
@@ -61,8 +63,7 @@ private:
     css::uno::Reference<
         css::chart2::XAxis >  m_xAxis;
 
-    css::uno::Reference<
-        css::chart2::XChartDocument >      m_xChartDoc;
+    rtl::Reference<::chart::ChartModel>m_xChartDoc;
 
     std::unique_ptr<ExplicitScaleData>  m_pExplicitScale;
     std::unique_ptr<ExplicitIncrementData>  m_pExplicitIncrement;
diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx 
b/chart2/source/controller/inc/DataPointItemConverter.hxx
index 403cd09203eb..1cba4854d890 100644
--- a/chart2/source/controller/inc/DataPointItemConverter.hxx
+++ b/chart2/source/controller/inc/DataPointItemConverter.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/uno/Sequence.h>
 
 #include <tools/color.hxx>
+#include <rtl/ref.hxx>
 
 #include <vector>
 
@@ -30,7 +31,7 @@ namespace com::sun::star::awt { struct Size; }
 namespace com::sun::star::chart2 { class XDataSeries; }
 namespace com::sun::star::frame { class XModel; }
 namespace com::sun::star::uno { class XComponentContext; }
-
+namespace chart { class ChartModel; }
 class SdrModel;
 
 namespace chart::wrapper {
@@ -39,7 +40,7 @@ class DataPointItemConverter final : public ItemConverter
 {
 public:
     DataPointItemConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel,
+        const rtl::Reference<::chart::ChartModel>& xChartModel,
         const css::uno::Reference<css::uno::XComponentContext>& xContext,
         const css::uno::Reference<css::beans::XPropertySet>& rPropertySet,
         const css::uno::Reference<css::chart2::XDataSeries>& xSeries,
diff --git a/chart2/source/controller/inc/MultipleChartConverters.hxx 
b/chart2/source/controller/inc/MultipleChartConverters.hxx
index 14cb52d07095..4fe1bb1de066 100644
--- a/chart2/source/controller/inc/MultipleChartConverters.hxx
+++ b/chart2/source/controller/inc/MultipleChartConverters.hxx
@@ -19,11 +19,12 @@
 #pragma once
 
 #include "MultipleItemConverter.hxx"
+#include <rtl/ref.hxx>
 
 namespace com::sun::star::awt { struct Size; }
 namespace com::sun::star::frame { class XModel; }
 namespace com::sun::star::lang { class XMultiServiceFactory; }
-
+namespace chart { class ChartModel; }
 class SdrModel;
 
 namespace chart::wrapper {
@@ -32,7 +33,7 @@ class AllAxisItemConverter final : public 
MultipleItemConverter
 {
 public:
     AllAxisItemConverter(
-        const css::uno::Reference<css::frame::XModel> & xChartModel,
+        const rtl::Reference<::chart::ChartModel> & xChartModel,
         SfxItemPool& rItemPool,
         SdrModel& rDrawModel,
         const css::awt::Size* pRefSize );
@@ -47,7 +48,7 @@ class AllGridItemConverter final : public 
MultipleItemConverter
 {
 public:
     AllGridItemConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel,
+        const rtl::Reference<::chart::ChartModel>& xChartModel,
         SfxItemPool& rItemPool,
         SdrModel& rDrawModel,
         const css::uno::Reference<css::lang::XMultiServiceFactory> & 
xNamedPropertyContainerFactory );
@@ -61,7 +62,7 @@ class AllDataLabelItemConverter final : public 
MultipleItemConverter
 {
 public:
     AllDataLabelItemConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel,
+        const rtl::Reference<::chart::ChartModel>& xChartModel,
         SfxItemPool& rItemPool,
         SdrModel& rDrawModel,
         const css::uno::Reference<css::lang::XMultiServiceFactory>& 
xNamedPropertyContainerFactory );
@@ -76,7 +77,7 @@ class AllTitleItemConverter final : public 
MultipleItemConverter
 {
 public:
     AllTitleItemConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel,
+        const rtl::Reference<::chart::ChartModel>& xChartModel,
         SfxItemPool& rItemPool, SdrModel& rDrawModel,
         const css::uno::Reference<css::lang::XMultiServiceFactory>& 
xNamedPropertyContainerFactory );
 
@@ -90,7 +91,7 @@ class AllSeriesStatisticsConverter final : public 
MultipleItemConverter
 {
 public:
     AllSeriesStatisticsConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel, 
SfxItemPool& rItemPool );
+        const rtl::Reference<::chart::ChartModel>& xChartModel, SfxItemPool& 
rItemPool );
     virtual ~AllSeriesStatisticsConverter() override;
 
 protected:
diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx 
b/chart2/source/controller/inc/ObjectHierarchy.hxx
index bac8deec2204..d8f7747e8bc6 100644
--- a/chart2/source/controller/inc/ObjectHierarchy.hxx
+++ b/chart2/source/controller/inc/ObjectHierarchy.hxx
@@ -41,7 +41,7 @@ public:
             used for keyboard navigation).
      */
     explicit ObjectHierarchy(
-        const css::uno::Reference< css::chart2::XChartDocument > & 
xChartDocument,
+        const rtl::Reference<::chart::ChartModel> & xChartDocument,
         ExplicitValueProvider * pExplicitValueProvider,
         bool bFlattenDiagram = false,
         bool bOrderingForElementSelector = false );
@@ -63,14 +63,14 @@ public:
     sal_Int32        getIndexInParent( const ObjectIdentifier& rNode ) const;
 
 private:
-    void createTree( const css::uno::Reference< css::chart2::XChartDocument > 
& xChartDocument );
+    void createTree( const rtl::Reference<::chart::ChartModel> & 
xChartDocument );
     void createAxesTree(
         ObjectHierarchy::tChildContainer & rContainer,
-        const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc,
+        const rtl::Reference<::chart::ChartModel> & xChartDoc,
         const css::uno::Reference< css::chart2::XDiagram > & xDiagram  );
     void createDiagramTree(
         ObjectHierarchy::tChildContainer& rContainer,
-        const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc,
+        const rtl::Reference<::chart::ChartModel>& xChartDoc,
         const css::uno::Reference< css::chart2::XDiagram >& xDiagram );
     void createDataSeriesTree(
         ObjectHierarchy::tChildContainer & rOutDiagramSubContainer,
@@ -80,7 +80,7 @@ private:
         const css::uno::Reference< css::chart2::XDiagram > & xDiagram );
     void createLegendTree(
         ObjectHierarchy::tChildContainer & rContainer,
-        const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc,
+        const rtl::Reference<::chart::ChartModel> & xChartDoc,
         const css::uno::Reference< css::chart2::XDiagram > & xDiagram  );
     void createAdditionalShapesTree( ObjectHierarchy::tChildContainer& 
rContainer );
     ObjectIdentifier getParentImpl(
@@ -99,7 +99,7 @@ class ObjectKeyNavigation
 {
 public:
     explicit ObjectKeyNavigation( const ObjectIdentifier & rCurrentOID,
-                                  const css::uno::Reference< 
css::chart2::XChartDocument > & xChartDocument,
+                                  const rtl::Reference<::chart::ChartModel> & 
xChartDocument,
                                   ExplicitValueProvider * 
pExplicitValueProvider );
 
     bool handleKeyEvent( const css::awt::KeyEvent & rEvent );
@@ -117,7 +117,7 @@ private:
     bool veryLast();
 
     ObjectIdentifier m_aCurrentOID;
-    css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument;
+    rtl::Reference<::chart::ChartModel> m_xChartDocument;
     ExplicitValueProvider * m_pExplicitValueProvider;
 };
 
diff --git a/chart2/source/controller/inc/PositionAndSizeHelper.hxx 
b/chart2/source/controller/inc/PositionAndSizeHelper.hxx
index d1c72c20bd1f..f70ccf302f6d 100644
--- a/chart2/source/controller/inc/PositionAndSizeHelper.hxx
+++ b/chart2/source/controller/inc/PositionAndSizeHelper.hxx
@@ -37,7 +37,7 @@ public:
             , const css::awt::Rectangle& rPageRectangle );
 
     static bool moveObject( const OUString& rObjectCID
-            , const css::uno::Reference< css::frame::XModel >& xChartModel
+            , const rtl::Reference<::chart::ChartModel>& xChartModel
             , const css::awt::Rectangle& rNewPositionAndSize
             , const css::awt::Rectangle& rOldPositionAndSize
             , const css::awt::Rectangle& rPageRectangle );
diff --git a/chart2/source/controller/inc/SelectionHelper.hxx 
b/chart2/source/controller/inc/SelectionHelper.hxx
index df19bd4230bf..ae241d61ab42 100644
--- a/chart2/source/controller/inc/SelectionHelper.hxx
+++ b/chart2/source/controller/inc/SelectionHelper.hxx
@@ -38,7 +38,7 @@ public: //methods
     const ObjectIdentifier& getSelectedOID() const { return m_aSelectedOID;}
 
     bool isResizeableObjectSelected() const;
-    bool isRotateableObjectSelected( const css::uno::Reference< 
css::frame::XModel >& xChartModel ) const;
+    bool isRotateableObjectSelected( const 
rtl::Reference<::chart::ChartModel>& xChartModel ) const;
     bool isDragableObjectSelected() const;
 
     bool isAdditionalShapeSelected() const;
@@ -93,7 +93,7 @@ public:
         bool bGetDiagramInsteadOf_Wall=false );
 
     static bool isRotateableObject( const OUString& rCID
-                    , const css::uno::Reference< css::frame::XModel >& 
xChartModel );
+                    , const rtl::Reference<::chart::ChartModel>& xChartModel );
 
     explicit SelectionHelper( SdrObject* pSelectedObj );
     virtual ~SelectionHelper();
diff --git a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx 
b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx
index 05f8ddd187c0..c658b08fa7dc 100644
--- a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx
+++ b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx
@@ -20,10 +20,12 @@
 
 #include "ItemConverter.hxx"
 #include <com/sun/star/uno/Sequence.h>
+#include <rtl/ref.hxx>
 
 namespace com::sun::star::chart2 { class XCoordinateSystem; }
 namespace com::sun::star::frame { class XModel; }
 namespace com::sun::star::uno { class XComponentContext; }
+namespace chart { class ChartModel; }
 
 namespace chart::wrapper
 {
@@ -32,7 +34,7 @@ class SeriesOptionsItemConverter final : public ItemConverter
 {
 public:
     SeriesOptionsItemConverter(
-        const css::uno::Reference< css::frame::XModel > & xChartModel,
+        const rtl::Reference<::chart::ChartModel> & xChartModel,
         const css::uno::Reference< css::uno::XComponentContext > & xContext,
         const css::uno::Reference< css::beans::XPropertySet > & rPropertySet,
         SfxItemPool& rItemPool );
@@ -46,7 +48,7 @@ protected:
     virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & 
rItemSet ) override;
 
 private:
-    css::uno::Reference< css::frame::XModel >  m_xChartModel;
+    rtl::Reference<::chart::ChartModel>  m_xChartModel;
     css::uno::Reference< css::uno::XComponentContext>   m_xCC;
 
     bool m_bAttachToMainAxis;
diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx 
b/chart2/source/controller/inc/StatisticsItemConverter.hxx
index 8d875d029e09..b82c1c230ae8 100644
--- a/chart2/source/controller/inc/StatisticsItemConverter.hxx
+++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx
@@ -19,8 +19,10 @@
 #pragma once
 
 #include "ItemConverter.hxx"
+#include <rtl/ref.hxx>
 
 namespace com::sun::star::frame { class XModel; }
+namespace chart { class ChartModel; }
 
 namespace chart::wrapper
 {
@@ -29,7 +31,7 @@ class StatisticsItemConverter final : public ItemConverter
 {
 public:
     StatisticsItemConverter(
-        const css::uno::Reference< css::frame::XModel > & xChartModel,
+        const rtl::Reference<::chart::ChartModel> & xChartModel,
         const css::uno::Reference< css::beans::XPropertySet > & rPropertySet,
         SfxItemPool& rItemPool );
     virtual ~StatisticsItemConverter() override;
@@ -42,7 +44,7 @@ protected:
     virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & 
rItemSet ) override;
 
 private:
-    css::uno::Reference< css::frame::XModel >  m_xModel;
+    rtl::Reference<::chart::ChartModel>  m_xModel;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/inc/TextLabelItemConverter.hxx 
b/chart2/source/controller/inc/TextLabelItemConverter.hxx
index 6d8c576aafa5..d44138332798 100644
--- a/chart2/source/controller/inc/TextLabelItemConverter.hxx
+++ b/chart2/source/controller/inc/TextLabelItemConverter.hxx
@@ -21,12 +21,13 @@
 #include "ItemConverter.hxx"
 
 #include <com/sun/star/uno/Sequence.h>
-
+#include <rtl/ref.hxx>
 #include <vector>
 
 namespace com::sun::star::awt { struct Size; }
 namespace com::sun::star::chart2 { class XDataSeries; }
 namespace com::sun::star::frame { class XModel; }
+namespace chart { class ChartModel; }
 
 namespace chart::wrapper {
 
@@ -34,7 +35,7 @@ class TextLabelItemConverter final : public ItemConverter
 {
 public:
     TextLabelItemConverter(
-        const css::uno::Reference<css::frame::XModel>& xChartModel,
+        const rtl::Reference<::chart::ChartModel>& xChartModel,
         const css::uno::Reference<css::beans::XPropertySet>& rPropertySet,
         const css::uno::Reference<css::chart2::XDataSeries>& xSeries,
         SfxItemPool& rItemPool,
diff --git a/chart2/source/controller/inc/dlg_ChartType_UNO.hxx 
b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx
index 0377aef8ac0b..4566ec75142d 100644
--- a/chart2/source/controller/inc/dlg_ChartType_UNO.hxx
+++ b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx
@@ -27,6 +27,8 @@ namespace com::sun::star::beans { class XPropertySetInfo; }
 
 namespace chart
 {
+class ChartModel;
+
 typedef ::svt::OGenericUnoDialog ChartTypeUnoDlg_BASE;
 class ChartTypeUnoDlg final : public ChartTypeUnoDlg_BASE
                         ,public ::comphelper::OPropertyArrayUsageHelper< 
ChartTypeUnoDlg >
@@ -57,7 +59,7 @@ private:
     ChartTypeUnoDlg(const ChartTypeUnoDlg&) = delete;
     void operator =(const ChartTypeUnoDlg&) = delete;
 
-    css::uno::Reference< css::frame::XModel >           m_xChartModel;
+    rtl::Reference<::chart::ChartModel>           m_xChartModel;
 };
 
 } //namespace chart
diff --git a/chart2/source/controller/inc/dlg_DataEditor.hxx 
b/chart2/source/controller/inc/dlg_DataEditor.hxx
index 83070d886b60..5156e0831b45 100644
--- a/chart2/source/controller/inc/dlg_DataEditor.hxx
+++ b/chart2/source/controller/inc/dlg_DataEditor.hxx
@@ -33,7 +33,6 @@ namespace com::sun::star {
 
 namespace chart
 {
-
 class ChartModel;
 class DataBrowser;
 
diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
index 893b37564950..cb53acb3a873 100644
--- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
@@ -26,6 +26,7 @@
 #include <chartview/ExplicitValueProvider.hxx>
 #include "SchWhichPairs.hxx"
 #include <ChartModelHelper.hxx>
+#include <ChartModel.hxx>
 #include <AxisHelper.hxx>
 #include <CommonConverters.hxx>
 #include <ChartTypeHelper.hxx>
@@ -81,15 +82,13 @@ AxisItemConverter::AxisItemConverter(
     const Reference< beans::XPropertySet > & rPropertySet,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
-    const Reference< chart2::XChartDocument > & xChartDoc,
+    const rtl::Reference<::chart::ChartModel> & xChartDoc,
     ::chart::ExplicitScaleData const * pScale /* = NULL */,
     ::chart::ExplicitIncrementData const * pIncrement /* = NULL */,
     const awt::Size* pRefSize ) :
         ItemConverter( rPropertySet, rItemPool ),
         m_xChartDoc( xChartDoc )
 {
-    Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( 
xChartDoc, uno::UNO_QUERY );
-
     if( pScale )
         m_pExplicitScale.reset( new ::chart::ExplicitScaleData( *pScale ) );
     if( pIncrement )
@@ -97,7 +96,7 @@ AxisItemConverter::AxisItemConverter(
 
     m_aConverters.emplace_back( new GraphicPropertyItemConverter(
                                  rPropertySet, rItemPool, rDrawModel,
-                                 xNamedPropertyContainerFactory,
+                                 xChartDoc,
                                  GraphicObjectType::LineProperties ));
     m_aConverters.emplace_back(
         new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, 
"ReferencePageSize"));
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index dccfc6f2c562..264bdf92af3b 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -28,6 +28,7 @@
 #include <DataSeriesHelper.hxx>
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
+#include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
 #include <ChartTypeHelper.hxx>
 #include <unonames.hxx>
@@ -198,7 +199,7 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 
nWhichId, const SfxIte
 } // anonymous namespace
 
 DataPointItemConverter::DataPointItemConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     const uno::Reference< uno::XComponentContext > & xContext,
     const uno::Reference< beans::XPropertySet > & rPropertySet,
     const uno::Reference< XDataSeries > & xSeries,
diff --git 
a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx 
b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index 13c1a933b8a2..7c67ef59c139 100644
--- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -25,6 +25,7 @@
 #include <GraphicPropertyItemConverter.hxx>
 #include <DataPointItemConverter.hxx>
 #include <ChartModelHelper.hxx>
+#include <ChartModel.hxx>
 #include <Diagram.hxx>
 #include <TitleHelper.hxx>
 #include <TitleItemConverter.hxx>
@@ -44,7 +45,7 @@ using ::com::sun::star::uno::Sequence;
 namespace chart::wrapper {
 
 AllAxisItemConverter::AllAxisItemConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
     const awt::Size* pRefSize )
@@ -57,7 +58,7 @@ AllAxisItemConverter::AllAxisItemConverter(
         uno::Reference< beans::XPropertySet > xObjectProperties(axis, 
uno::UNO_QUERY);
         m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter(
             xObjectProperties, rItemPool, rDrawModel,
-            uno::Reference< chart2::XChartDocument >( xChartModel, 
uno::UNO_QUERY ), nullptr, nullptr,
+            xChartModel, nullptr, nullptr,
             pRefSize));
     }
 }
@@ -73,7 +74,7 @@ const WhichRangesContainer& 
AllAxisItemConverter::GetWhichPairs() const
 }
 
 AllGridItemConverter::AllGridItemConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
     const uno::Reference< lang::XMultiServiceFactory > & 
xNamedPropertyContainerFactory )
@@ -100,7 +101,7 @@ const WhichRangesContainer& 
AllGridItemConverter::GetWhichPairs() const
 }
 
 AllDataLabelItemConverter::AllDataLabelItemConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
     const uno::Reference< lang::XMultiServiceFactory > & 
xNamedPropertyContainerFactory )
@@ -116,7 +117,7 @@ AllDataLabelItemConverter::AllDataLabelItemConverter(
 
         sal_Int32 
nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( 
xObjectProperties );
         sal_Int32 
nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
-                xObjectProperties,uno::Reference< util::XNumberFormatsSupplier 
>(xChartModel, uno::UNO_QUERY));
+                xObjectProperties,xChartModel);
 
         m_aConverters.emplace_back(
             new ::chart::wrapper::DataPointItemConverter(
@@ -137,7 +138,7 @@ const WhichRangesContainer& 
AllDataLabelItemConverter::GetWhichPairs() const
 }
 
 AllTitleItemConverter::AllTitleItemConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
     const uno::Reference< lang::XMultiServiceFactory > & 
xNamedPropertyContainerFactory )
@@ -166,7 +167,7 @@ const WhichRangesContainer& 
AllTitleItemConverter::GetWhichPairs() const
 }
 
 AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
-    const uno::Reference< frame::XModel > & xChartModel,
+    const rtl::Reference<::chart::ChartModel> & xChartModel,
     SfxItemPool& rItemPool )
         : MultipleItemConverter( rItemPool )
 {
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index b81d50e8f565..4d035c061b6c 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -44,7 +44,7 @@ namespace chart::wrapper
 {
 
 SeriesOptionsItemConverter::SeriesOptionsItemConverter(
-        const uno::Reference< frame::XModel >& xChartModel
+        const rtl::Reference<::chart::ChartModel>& xChartModel
         , const uno::Reference< uno::XComponentContext > & xContext
         , const uno::Reference< beans::XPropertySet >& xPropertySet
         , SfxItemPool& rItemPool )
@@ -131,8 +131,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
         m_nMissingValueTreatment = 
DiagramHelper::getCorrectedMissingValueTreatment(
             ChartModelHelper::findDiagram(m_xChartModel), xChartType );
 
-        uno::Reference< XChartDocument > xChartDoc( m_xChartModel, 
uno::UNO_QUERY );
-        uno::Reference< beans::XPropertySet > xProp( 
xChartDoc->getDataProvider(), uno::UNO_QUERY );
+        uno::Reference< beans::XPropertySet > xProp( 
m_xChartModel->getDataProvider(), uno::UNO_QUERY );
         if( xProp.is() )
         {
             try
@@ -337,9 +336,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( 
sal_uInt16 nWhichId, const Sf
                 bool bIncludeHiddenCells = static_cast<const SfxBoolItem 
&>(rItemSet.Get(nWhichId)).GetValue();
                 if (bIncludeHiddenCells != m_bIncludeHiddenCells)
                 {
-                    ChartModel* pModel = 
dynamic_cast<ChartModel*>(m_xChartModel.get());
-                    if (pModel)
-                        bChanged = ChartModelHelper::setIncludeHiddenCells( 
bIncludeHiddenCells, *pModel );
+                    if (m_xChartModel)
+                        bChanged = ChartModelHelper::setIncludeHiddenCells( 
bIncludeHiddenCells, *m_xChartModel );
                 }
             }
         }
diff --git 
a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index 1e736662ebdd..a900466b85b8 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -22,7 +22,7 @@
 #include <RegressionCurveHelper.hxx>
 #include <ErrorBar.hxx>
 #include <StatisticsHelper.hxx>
-
+#include <ChartModel.hxx>
 #include <unonames.hxx>
 
 #include <svl/stritem.hxx>
@@ -211,7 +211,7 @@ namespace chart::wrapper
 {
 
 StatisticsItemConverter::StatisticsItemConverter(
-    const uno::Reference< frame::XModel > & xModel,
+    const rtl::Reference<::chart::ChartModel> & xModel,
     const uno::Reference< beans::XPropertySet > & rPropertySet,
     SfxItemPool& rItemPool ) :
         ItemConverter( rPropertySet, rItemPool ),
@@ -553,18 +553,17 @@ bool StatisticsItemConverter::ApplySpecialItem(
                 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
             uno::Reference< chart2::data::XDataSource > xErrorBarSource( 
lcl_GetErrorBar( GetPropertySet(), bYError),
                                                                          
uno::UNO_QUERY );
-            uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, 
uno::UNO_QUERY );
             uno::Reference< chart2::data::XDataProvider > xDataProvider;
 
-            if( xChartDoc.is())
-                xDataProvider.set( xChartDoc->getDataProvider());
+            if( m_xModel.is())
+                xDataProvider.set( m_xModel->getDataProvider());
             if( xErrorBarSource.is() && xDataProvider.is())
             {
                 OUString aNewRange( static_cast< const SfxStringItem & >( 
rItemSet.Get( nWhichId )).GetValue());
                 bool bApplyNewRange = false;
 
                 bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
-                if( xChartDoc->hasInternalDataProvider())
+                if( m_xModel->hasInternalDataProvider())
                 {
                     if( !aNewRange.isEmpty())
                     {
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 4291acd02442..36a0686e95f7 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -19,6 +19,7 @@
 
 #include <TextLabelItemConverter.hxx>
 #include <CharacterPropertyItemConverter.hxx>
+#include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
 #include <ChartTypeHelper.hxx>
 #include <DataSeriesHelper.hxx>
@@ -194,7 +195,7 @@ bool useSourceFormatFromItemToPropertySet(
 } // anonymous namespace
 
 TextLabelItemConverter::TextLabelItemConverter(
-    const uno::Reference<frame::XModel>& xChartModel,
+    const rtl::Reference<::chart::ChartModel>& xChartModel,
     const uno::Reference<beans::XPropertySet>& rPropertySet,
     const uno::Reference<XDataSeries>& xSeries,
     SfxItemPool& rItemPool, const awt::Size* pRefSize,
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 5be9cc3fe0c3..5a25f761e896 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -642,7 +642,7 @@ rtl::Reference<::chart::ChartModel> 
ChartController::getChartModel()
 
 rtl::Reference<::chart::Diagram> ChartController::getFirstDiagram()
 {
-    return ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+    return ChartModelHelper::findDiagram( getChartModel() );
 }
 
 uno::Any SAL_CALL ChartController::getViewData()
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx 
b/chart2/source/controller/main/ChartController_Insert.cxx
index d64d7f5ef500..b14a788f2140 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -516,7 +516,7 @@ void ChartController::executeDispatch_InsertErrorBars( bool 
bYError )
 void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
 {
     uno::Reference< chart2::XRegressionCurve > xRegCurve(
-        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
uno::Reference<chart2::XChartDocument>(getChartModel()) ), uno::UNO_QUERY );
+        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() ), uno::UNO_QUERY );
     if( !xRegCurve.is() )
     {
         uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
@@ -544,7 +544,7 @@ void 
ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
 void ChartController::executeDispatch_InsertR2Value()
 {
     uno::Reference< beans::XPropertySet > xEqProp =
-        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() );
     if( xEqProp.is())
     {
         UndoGuard aUndoGuard(
@@ -559,7 +559,7 @@ void ChartController::executeDispatch_InsertR2Value()
 void ChartController::executeDispatch_DeleteR2Value()
 {
     uno::Reference< beans::XPropertySet > xEqProp =
-        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+        ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() );
     if( xEqProp.is())
     {
         UndoGuard aUndoGuard(
@@ -650,7 +650,7 @@ void ChartController::executeDispatch_InsertDataLabel()
     UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( 
ActionDescriptionProvider::ActionType::Insert,
         SchResId( STR_OBJECT_LABEL )),
         m_xUndoManager );
-    DataSeriesHelper::insertDataLabelToPoint( 
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
uno::Reference<chart2::XChartDocument>(getChartModel()) ) );
+    DataSeriesHelper::insertDataLabelToPoint( 
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() ) );
     aUndoGuard.commit();
 }
 
@@ -673,7 +673,7 @@ void ChartController::executeDispatch_DeleteDataLabel()
     UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( 
ActionDescriptionProvider::ActionType::Delete,
         SchResId( STR_OBJECT_LABEL )),
         m_xUndoManager );
-    DataSeriesHelper::deleteDataLabelsFromPoint( 
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
uno::Reference<chart2::XChartDocument>(getChartModel()) ) );
+    DataSeriesHelper::deleteDataLabelsFromPoint( 
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), 
getChartModel() ) );
     aUndoGuard.commit();
 }
 
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx 
b/chart2/source/controller/main/ChartController_Properties.cxx
index 43beea79db7c..df0da042a218 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -92,7 +92,7 @@ wrapper::ItemConverter* createItemConverter(
     if( !bAffectsMultipleObjects )
     {
         uno::Reference< beans::XPropertySet > xObjectProperties =
-            ObjectIdentifier::getObjectPropertySet( aObjectCID, 
uno::Reference<chart2::XChartDocument>(xChartModel ));
+            ObjectIdentifier::getObjectPropertySet( aObjectCID, xChartModel );
         if(!xObjectProperties.is())
             return nullptr;
         //create itemconverter for a single object
@@ -200,7 +200,7 @@ wrapper::ItemConverter* createItemConverter(
                 uno::Reference< XDataSeries > xSeries = 
ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel );
                 uno::Reference< XChartType > xChartType = 
ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
 
-                rtl::Reference< Diagram > xDiagram( 
ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xChartModel );
                 sal_Int32 nDimensionCount = DiagramHelper::getDimension( 
xDiagram );
                 if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, 
nDimensionCount ) )
                     eMapTo = wrapper::GraphicObjectType::LineDataPoint;
@@ -374,14 +374,14 @@ OUString lcl_getAxisCIDForCommand( std::string_view 
rDispatchCommand, const rtl:
         nDimensionIndex=1; bMainAxis=false;
     }
 
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartModel );
     uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, 
bMainAxis, xDiagram ) );
     return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, 
xChartModel );
 }
 
 OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const 
rtl::Reference<::chart::ChartModel>& xChartModel )
 {
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartModel );
 
     if( rDispatchCommand == "DiagramGridAll")
         return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, 
u"ALLELEMENTS" );
@@ -759,7 +759,7 @@ bool 
ChartController::executeDlg_ObjectProperties_withoutUndoGuard(
         if(aDialogParameter.HasSymbolProperties())
         {
             uno::Reference< beans::XPropertySet > xObjectProperties =
-                ObjectIdentifier::getObjectPropertySet( rObjectCID, 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+                ObjectIdentifier::getObjectPropertySet( rObjectCID, 
getChartModel() );
             wrapper::DataPointItemConverter aSymbolItemConverter( 
getChartModel(), m_xCC
                                         , xObjectProperties, 
ObjectIdentifier::getDataSeriesForCID( rObjectCID, getChartModel() )
                                         , 
m_pDrawModelWrapper->getSdrModel().GetItemPool()
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx 
b/chart2/source/controller/main/ChartController_TextEdit.cxx
index be2e54cded4a..100d210c2e9e 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -140,7 +140,7 @@ bool ChartController::EndTextEdit()
     if ( !aObjectCID.isEmpty() )
     {
         uno::Reference< beans::XPropertySet > xPropSet =
-            ObjectIdentifier::getObjectPropertySet( aObjectCID, 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+            ObjectIdentifier::getObjectPropertySet( aObjectCID, 
getChartModel() );
 
         // lock controllers till end of block
         ControllerLockGuardUNO aCLGuard( getChartModel() );
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx 
b/chart2/source/controller/main/ChartController_Tools.cxx
index 280cbf420371..7b9c28de63e5 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -109,7 +109,7 @@ bool lcl_deleteDataSeries(
                     ActionDescriptionProvider::ActionType::Delete, SchResId( 
STR_OBJECT_DATASERIES )),
                 xUndoManager );
 
-            rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ) );
+            rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram( xModel );
             uno::Reference< chart2::XAxis > xAxis( 
DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
 
             DataSeriesHelper::deleteSeries( xSeries, xChartType );
@@ -131,7 +131,7 @@ bool lcl_deleteDataCurve(
     bool bResult = false;
 
     uno::Reference< beans::XPropertySet > xProperties(
-        ObjectIdentifier::getObjectPropertySet( rCID, 
uno::Reference<chart2::XChartDocument>(xModel)));
+        ObjectIdentifier::getObjectPropertySet( rCID, xModel));
 
     uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xProperties, 
uno::UNO_QUERY );
 
@@ -139,7 +139,7 @@ bool lcl_deleteDataCurve(
     {
         uno::Reference< chart2::XRegressionCurveContainer > 
xRegressionCurveContainer(
             ObjectIdentifier::getObjectPropertySet(
-                ObjectIdentifier::getFullParentParticle( rCID ), 
uno::Reference<chart2::XChartDocument>(xModel)), uno::UNO_QUERY );
+                ObjectIdentifier::getFullParentParticle( rCID ), xModel), 
uno::UNO_QUERY );
 
         if( xRegressionCurveContainer.is())
         {
@@ -181,7 +181,7 @@ void ChartController::executeDispatch_NewArrangement()
     try
     {
         rtl::Reference<::chart::ChartModel> xModel( getChartModel() );
-        rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ));
+        rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xModel );
         if( xDiagram.is())
         {
             UndoGuard aUndoGuard(
@@ -661,7 +661,7 @@ bool ChartController::executeDispatch_Delete()
             {
                 uno::Reference< chart2::XRegressionCurveContainer > 
xRegCurveCnt(
                     ObjectIdentifier::getObjectPropertySet(
-                        ObjectIdentifier::getFullParentParticle( aCID ), 
uno::Reference<chart2::XChartDocument>(getChartModel())), uno::UNO_QUERY );
+                        ObjectIdentifier::getFullParentParticle( aCID ), 
getChartModel()), uno::UNO_QUERY );
                 if( xRegCurveCnt.is())
                 {
                     UndoGuard aUndoGuard(
@@ -684,7 +684,7 @@ bool ChartController::executeDispatch_Delete()
             case OBJECTTYPE_DATA_CURVE_EQUATION:
             {
                 uno::Reference< beans::XPropertySet > xEqProp(
-                    ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(getChartModel())));
+                    ObjectIdentifier::getObjectPropertySet( aCID, 
getChartModel()));
 
                 if( xEqProp.is())
                 {
@@ -711,7 +711,7 @@ bool ChartController::executeDispatch_Delete()
             case OBJECTTYPE_DATA_ERRORS_Z:
             {
                 uno::Reference< beans::XPropertySet > xErrorBarProp(
-                    ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(getChartModel()) ));
+                    ObjectIdentifier::getObjectPropertySet( aCID, 
getChartModel() ));
                 if( xErrorBarProp.is())
                 {
                     TranslateId pId;
@@ -744,7 +744,7 @@ bool ChartController::executeDispatch_Delete()
             case OBJECTTYPE_DATA_LABEL:
             {
                 uno::Reference< beans::XPropertySet > xObjectProperties =
-                    ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(getChartModel()) );
+                    ObjectIdentifier::getObjectPropertySet( aCID, 
getChartModel() );
                 if( xObjectProperties.is() )
                 {
                     UndoGuard aUndoGuard(
@@ -927,7 +927,7 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 
nColor)
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPointProperties(
-                ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
             if( xPointProperties.is() )
                 xPointProperties->setPropertyValue( "FillColor", uno::Any( 
nColor ) );
         }
@@ -951,7 +951,7 @@ void ChartController::executeDispatch_FillGradient(OUString 
sJSONGradient)
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPropSet(
-                ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
 
             if( xPropSet.is() )
             {
@@ -982,7 +982,7 @@ void ChartController::executeDispatch_LineColor(sal_uInt32 
nColor)
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPropSet(
-                ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
 
             ObjectType eType = ObjectIdentifier::getObjectType(aCID);
             if (eType == OBJECTTYPE_DIAGRAM)
@@ -1012,7 +1012,7 @@ void 
ChartController::executeDispatch_LineWidth(sal_uInt32 nWidth)
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPropSet(
-                ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
 
             ObjectType eType = ObjectIdentifier::getObjectType(aCID);
             if (eType == OBJECTTYPE_DIAGRAM)
@@ -1073,7 +1073,7 @@ void 
ChartController::executeDispatch_LOKPieSegmentDragging( int nOffset )
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPointProperties(
-                ObjectIdentifier::getObjectPropertySet( aCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
             if( xPointProperties.is() )
                 xPointProperties->setPropertyValue( "Offset", uno::Any( 
nOffset / 100.0 ) );
         }
diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index 14795d4878ee..b8d925427736 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1792,7 +1792,7 @@ bool ChartController::impl_moveOrResizeObject(
 
     rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() );
     uno::Reference< beans::XPropertySet > xObjProp(
-        ObjectIdentifier::getObjectPropertySet( rCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ));
+        ObjectIdentifier::getObjectPropertySet( rCID, xChartModel ));
     if( xObjProp.is())
     {
         awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel );
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index cc62ddbe2d32..9da88ea5d6c7 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -194,7 +194,7 @@ void ControllerState::update(
     bIsPositionableObject = (aObjectType != OBJECTTYPE_DATA_POINT) && 
aSelOID.isDragableObject();
     bIsTextObject = aObjectType == OBJECTTYPE_TITLE;
 
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ));
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xModel 
);
     bIsFormateableObjectSelected = bHasSelectedObject && 
aSelOID.isAutoGeneratedObject();
     if( aObjectType==OBJECTTYPE_DIAGRAM || 
aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR )
         bIsFormateableObjectSelected = 
DiagramHelper::isSupportingFloorAndWall( xDiagram );
@@ -206,12 +206,12 @@ void ControllerState::update(
     bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj 
);
 
     bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && 
DiagramHelper::isSeriesMoveable(
-        ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ),
+        ChartModelHelper::findDiagram( xModel ),
         xGivenDataSeries,
         MOVE_SERIES_FORWARD );
 
     bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && 
DiagramHelper::isSeriesMoveable(
-        ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ),
+        ChartModelHelper::findDiagram( xModel ),
         xGivenDataSeries,
         MOVE_SERIES_BACKWARD );
 
@@ -285,7 +285,7 @@ void ControllerState::update(
         bMayFormatTrendline = true;
         bMayDeleteTrendline = true;
         uno::Reference< chart2::XRegressionCurve > xRegCurve(
-            ObjectIdentifier::getObjectPropertySet( aSelObjCID, 
uno::Reference<chart2::XChartDocument>(xModel) ), uno::UNO_QUERY );
+            ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), 
uno::UNO_QUERY );
 
         // Trendline Equation
         bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = 
RegressionCurveHelper::hasEquation( xRegCurve );
@@ -298,7 +298,7 @@ void ControllerState::update(
         try
         {
             uno::Reference< beans::XPropertySet > xEquationProperties =
-                ObjectIdentifier::getObjectPropertySet( aSelObjCID, 
uno::Reference<chart2::XChartDocument>(xModel) );
+                ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel );
             if( xEquationProperties.is() )
                 xEquationProperties->getPropertyValue( 
"ShowCorrelationCoefficient" ) >>= bHasR2Value;
         }
@@ -400,7 +400,7 @@ ModelState::ModelState() :
 
 void ModelState::update( const rtl::Reference<::chart::ChartModel> & xModel )
 {
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(xModel) ));
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xModel 
);
 
     bIsReadOnly = xModel->isReadonly();
 
diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx 
b/chart2/source/controller/main/DragMethod_PieSegment.cxx
index 3ba3e5a9f205..c2c5db234bd7 100644
--- a/chart2/source/controller/main/DragMethod_PieSegment.cxx
+++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx
@@ -116,7 +116,7 @@ bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/)
         if( xChartModel.is() )
         {
             Reference< beans::XPropertySet > xPointProperties(
-                ObjectIdentifier::getObjectPropertySet( m_aObjectCID, 
uno::Reference<chart2::XChartDocument>(xChartModel) ) );
+                ObjectIdentifier::getObjectPropertySet( m_aObjectCID, 
xChartModel ) );
             if( xPointProperties.is() )
                 xPointProperties->setPropertyValue( "Offset", uno::Any( 
m_fAdditionalOffset+m_fInitialOffset ));
         }
diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx 
b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
index e5d266fbc5f0..030fcd0bf8bc 100644
--- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
+++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx
@@ -74,7 +74,7 @@ DragMethod_RotateDiagram::DragMethod_RotateDiagram( 
DrawViewWrapper& rDrawViewWr
 
     m_aWireframePolyPolygon = m_pScene->CreateWireframe();
 
-    rtl::Reference< Diagram > xDiagram( 
ChartModelHelper::findDiagram(uno::Reference<chart2::XChartDocument>(getChartModel()))
 );
+    rtl::Reference< Diagram > xDiagram = 
ChartModelHelper::findDiagram(getChartModel());
     if( !xDiagram.is() )
         return;
 
@@ -161,12 +161,12 @@ bool DragMethod_RotateDiagram::EndSdrDrag(bool /*bCopy*/)
         if(m_bRightAngledAxes)
             ThreeDHelper::adaptRadAnglesForRightAngledAxes( fResultX, fResultY 
);
 
-        ThreeDHelper::setRotationAngleToDiagram( 
ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(getChartModel()) )
+        ThreeDHelper::setRotationAngleToDiagram( 
ChartModelHelper::findDiagram( getChartModel() )
             , fResultX, fResultY, fResultZ );
     }
     else
     {
-        ThreeDHelper::setRotationToDiagram( ChartModelHelper::findDiagram( 
uno::Reference<chart2::XChartDocument>(getChartModel()) )
+        ThreeDHelper::setRotationToDiagram( ChartModelHelper::findDiagram( 
getChartModel() )
             , 
m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, 
m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree );
     }
 
diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx 
b/chart2/source/controller/main/ObjectHierarchy.cxx
index cefad37c72a8..326d43461d9f 100644
--- a/chart2/source/controller/main/ObjectHierarchy.cxx
+++ b/chart2/source/controller/main/ObjectHierarchy.cxx
@@ -26,6 +26,7 @@
 #include <AxisHelper.hxx>
 #include <chartview/ExplicitValueProvider.hxx>
 #include <ChartTypeHelper.hxx>
+#include <ChartModel.hxx>
 #include <DataSeriesHelper.hxx>
 #include <LegendHelper.hxx>
 #include <chartview/DrawModelWrapper.hxx>
@@ -62,7 +63,7 @@ namespace
 
 struct lcl_ObjectToOID
 {
-    explicit lcl_ObjectToOID( const Reference< chart2::XChartDocument > & 
xChartDoc ) :
+    explicit lcl_ObjectToOID( const rtl::Reference<::chart::ChartModel> & 
xChartDoc ) :
             m_xModel( xChartDoc )
     {}
 
@@ -72,7 +73,7 @@ struct lcl_ObjectToOID
     }
 
 private:
-    Reference< frame::XModel > m_xModel;
+    rtl::Reference<::chart::ChartModel> m_xModel;
 };
 
 void lcl_getChildOIDs(
@@ -105,7 +106,7 @@ void lcl_getChildOIDs(
     }
 }
 
-void lcl_addAxisTitle( const Reference< XAxis >& xAxis, 
::chart::ObjectHierarchy::tChildContainer& rContainer, const Reference< 
frame::XModel >& xChartModel )
+void lcl_addAxisTitle( const Reference< XAxis >& xAxis, 
::chart::ObjectHierarchy::tChildContainer& rContainer, const 
rtl::Reference<::chart::ChartModel>& xChartModel )
 {
     Reference< XTitled > xAxisTitled( xAxis, uno::UNO_QUERY );
     if( xAxisTitled.is())
@@ -121,7 +122,7 @@ void lcl_addAxisTitle( const Reference< XAxis >& xAxis, 
::chart::ObjectHierarchy
 namespace chart
 {
 
-void ObjectHierarchy::createTree( const Reference< XChartDocument >& 
xChartDocument )
+void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& 
xChartDocument )
 {
     m_aChildMap = tChildMap();//clear tree
 
@@ -129,11 +130,10 @@ void ObjectHierarchy::createTree( const Reference< 
XChartDocument >& xChartDocum
         return;
 
     //@todo: change ObjectIdentifier to take an XChartDocument rather than 
XModel
-    Reference< frame::XModel > xModel = xChartDocument;
-    rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( 
xChartDocument ) );
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartDocument );
     ObjectIdentifier aDiaOID;
     if( xDiagram.is() )
-        aDiaOID = ObjectIdentifier( 
ObjectIdentifier::createClassifiedIdentifierForObject( 
uno::Reference<XDiagram>(xDiagram), xModel ) );
+        aDiaOID = ObjectIdentifier( 
ObjectIdentifier::createClassifiedIdentifierForObject( 
static_cast<cppu::OWeakObject*>(xDiagram.get()), xChartDocument ) );
     ObjectHierarchy::tChildContainer aTopLevelContainer;
 
     // First Level
@@ -151,27 +151,23 @@ void ObjectHierarchy::createTree( const Reference< 
XChartDocument >& xChartDocum
     }
 
     // Main Title
-    Reference< XTitled > xDocTitled( xChartDocument, uno::UNO_QUERY );
-    if( xDocTitled.is())
-    {
-        Reference< XTitle > xMainTitle( xDocTitled->getTitleObject());
-        if( xMainTitle.is())
-            aTopLevelContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel ) );
-    }
+    Reference< XTitle > xMainTitle( xChartDocument->getTitleObject());
+    if( xMainTitle.is())
+        aTopLevelContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, 
xChartDocument ) );
 
     if( xDiagram.is())
     {
         // Sub Title.  Note: This is interpreted of being top level
         Reference< XTitle > xSubTitle( xDiagram->getTitleObject());
         if( xSubTitle.is())
-            aTopLevelContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel ) );
+            aTopLevelContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, 
xChartDocument ) );
 
         if( !m_bOrderingForElementSelector )
         {
             // Axis Titles. Note: These are interpreted of being top level
             const Sequence< Reference< XAxis > > aAxes( 
AxisHelper::getAllAxesOfDiagram( xDiagram ) );
             for( Reference< XAxis > const & axis : aAxes )
-                lcl_addAxisTitle( axis, aTopLevelContainer, xModel );
+                lcl_addAxisTitle( axis, aTopLevelContainer, xChartDocument );
 
             // Diagram
             aTopLevelContainer.push_back( aDiaOID );
@@ -207,7 +203,7 @@ void ObjectHierarchy::createTree( const Reference< 
XChartDocument >& xChartDocum
 
 void ObjectHierarchy::createLegendTree(
     ObjectHierarchy::tChildContainer & rContainer,
-    const Reference< XChartDocument > & xChartDoc,
+    const rtl::Reference<::chart::ChartModel> & xChartDoc,
     const Reference< XDiagram > & xDiagram  )
 {
     if( !(xDiagram.is() && LegendHelper::hasLegend( xDiagram )) )
@@ -230,7 +226,7 @@ void ObjectHierarchy::createLegendTree(
 
 void ObjectHierarchy::createAxesTree(
     ObjectHierarchy::tChildContainer & rContainer,
-    const Reference< XChartDocument > & xChartDoc,
+    const rtl::Reference<::chart::ChartModel> & xChartDoc,
     const Reference< XDiagram > & xDiagram  )
 {
     Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, 
uno::UNO_QUERY_THROW );
@@ -249,7 +245,6 @@ void ObjectHierarchy::createAxesTree(
     // get all axes, also invisible ones
     aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram );
     // Grids
-    Reference< frame::XModel > xChartModel = xChartDoc;
     for( Reference< XAxis > const & xAxis : std::as_const(aAxes) )
     {
         if(!xAxis.is())
@@ -266,17 +261,17 @@ void ObjectHierarchy::createAxesTree(
         {
             // axis
             if( AxisHelper::isAxisVisible( xAxis ) )
-                rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) );
+                rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartDoc ) );
 
             // axis title
-            lcl_addAxisTitle( xAxis, rContainer, xChartModel );
+            lcl_addAxisTitle( xAxis, rContainer, xChartDoc );
         }
 
         Reference< beans::XPropertySet > xGridProperties( 
xAxis->getGridProperties() );
         if( AxisHelper::isGridVisible( xGridProperties ) )
         {
             //main grid
-            rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) );
+            rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDoc ) );
         }
 
         Sequence< Reference< beans::XPropertySet > > aSubGrids( 
xAxis->getSubGridProperties() );
@@ -287,7 +282,7 @@ void ObjectHierarchy::createAxesTree(
             if( AxisHelper::isGridVisible( xSubGridProperties ) )
             {
                 //sub grid
-                rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 
nSubGrid ) );
+                rContainer.emplace_back( 
ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDoc, nSubGrid 
) );
             }
         }
     }
@@ -313,7 +308,7 @@ void ObjectHierarchy::createWallAndFloor(
 
 void ObjectHierarchy::createDiagramTree(
     ObjectHierarchy::tChildContainer & rContainer,
-    const Reference< XChartDocument > & xChartDoc,
+    const rtl::Reference<::chart::ChartModel> & xChartDoc,
     const Reference< XDiagram > & xDiagram )
 {
     if( !m_bOrderingForElementSelector )
@@ -540,7 +535,7 @@ ObjectIdentifier ObjectHierarchy::getParent(
 }
 
 ObjectHierarchy::ObjectHierarchy(
-    const Reference< XChartDocument > & xChartDocument,
+    const rtl::Reference<::chart::ChartModel> & xChartDocument,
     ExplicitValueProvider * pExplicitValueProvider /* = 0 */,
     bool bFlattenDiagram /* = false */,
     bool bOrderingForElementSelector /* = false */) :
@@ -588,7 +583,7 @@ sal_Int32 ObjectHierarchy::getIndexInParent(
 
 ObjectKeyNavigation::ObjectKeyNavigation(
     const ObjectIdentifier & rCurrentOID,
-    const Reference< chart2::XChartDocument > & xChartDocument,
+    const rtl::Reference<::chart::ChartModel> & xChartDocument,
     ExplicitValueProvider * pExplicitValueProvider /* = 0 */ ) :
         m_aCurrentOID( rCurrentOID ),
         m_xChartDocument( xChartDocument ),
diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx 
b/chart2/source/controller/main/PositionAndSizeHelper.cxx
index badd2662d125..ec744633ca0c 100644
--- a/chart2/source/controller/main/PositionAndSizeHelper.cxx
+++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx
@@ -27,6 +27,7 @@
 #include <tools/gen.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/awt/Rectangle.hpp>
+#include <ChartModel.hxx>
 #include <Diagram.hxx>
 
 namespace chart
@@ -154,7 +155,7 @@ bool PositionAndSizeHelper::moveObject( ObjectType 
eObjectType
 }
 
 bool PositionAndSizeHelper::moveObject( const OUString& rObjectCID
-                , const uno::Reference< frame::XModel >& xChartModel
+                , const rtl::Reference<::chart::ChartModel>& xChartModel
                 , const awt::Rectangle& rNewPositionAndSize
                 , const awt::Rectangle& rOldPositionAndSize
                 , const awt::Rectangle& rPageRectangle
diff --git a/chart2/source/controller/main/SelectionHelper.cxx 
b/chart2/source/controller/main/SelectionHelper.cxx
index bf9ec005bd76..433a157ba828 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -22,6 +22,7 @@
 #include <DiagramHelper.hxx>
 #include <Diagram.hxx>
 #include <ChartModelHelper.hxx>
+#include <ChartModel.hxx>
 
 #include <com/sun/star/frame/XModel.hpp>
 #include <svx/svdpage.hxx>
@@ -304,7 +305,7 @@ bool Selection::isResizeableObjectSelected() const
     }
 }
 
-bool Selection::isRotateableObjectSelected( const uno::Reference< 
frame::XModel >& xChartModel ) const
+bool Selection::isRotateableObjectSelected( const 
rtl::Reference<::chart::ChartModel>& xChartModel ) const
 {
     return SelectionHelper::isRotateableObject( m_aSelectedOID.getObjectCID(), 
xChartModel );
 }
@@ -443,7 +444,7 @@ OUString SelectionHelper::getHitObjectCID(
 }
 
 bool SelectionHelper::isRotateableObject( const OUString& rCID
-                    , const uno::Reference< frame::XModel >& xChartModel )
+                    , const rtl::Reference<::chart::ChartModel>& xChartModel )
 {
     if( !ObjectIdentifier::isRotateableObject( rCID ) )
         return false;
diff --git a/chart2/source/controller/uitest/uiobject.cxx 
b/chart2/source/controller/uitest/uiobject.cxx
index 45915a62e554..ef4f4d7112c8 100644
--- a/chart2/source/controller/uitest/uiobject.cxx
+++ b/chart2/source/controller/uitest/uiobject.cxx
@@ -12,6 +12,7 @@
 
 #include <ChartWindow.hxx>
 #include <ChartController.hxx>
+#include <ChartModel.hxx>
 #include <ObjectHierarchy.hxx>
 #include <chartview/ExplicitValueProvider.hxx>
 #include <com/sun/star/chart2/XChartDocument.hpp>
@@ -172,7 +173,7 @@ std::set<OUString> ChartWindowUIObject::get_children() const
     if (!pController)
         return aChildren;
 
-    css::uno::Reference< css::chart2::XChartDocument > xChartDoc( 
pController->getModel(), css::uno::UNO_QUERY );
+    rtl::Reference<::chart::ChartModel> xChartDoc( 
pController->getChartModel() );
 
     css::uno::Reference<css::uno::XInterface> xChartView = 
pController->getChartView();
     chart::ExplicitValueProvider* pValueProvider = 
comphelper::getFromUnoTunnel<chart::ExplicitValueProvider>( xChartView );
diff --git a/chart2/source/inc/ChartModelHelper.hxx 
b/chart2/source/inc/ChartModelHelper.hxx
index b4355a6017b6..dfe864eeb0d4 100644
--- a/chart2/source/inc/ChartModelHelper.hxx
+++ b/chart2/source/inc/ChartModelHelper.hxx
@@ -72,6 +72,8 @@ public:
             getDataSeries( const css::uno::Reference< 
css::chart2::XChartDocument > & xChartDoc );
     static std::vector< css::uno::Reference< css::chart2::XDataSeries > >
             getDataSeries( const css::uno::Reference< css::frame::XModel > & 
xModel );
+    static std::vector< css::uno::Reference< css::chart2::XDataSeries > >
+            getDataSeries( const rtl::Reference< ::chart::ChartModel > & 
xModel );
 
     static css::uno::Reference< css::chart2::XChartType >
         getChartTypeOfSeries(
diff --git a/chart2/source/tools/ChartModelHelper.cxx 
b/chart2/source/tools/ChartModelHelper.cxx
index 15643bdceb18..b81d047cc39d 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -164,6 +164,18 @@ std::vector< uno::Reference< XDataSeries > > 
ChartModelHelper::getDataSeries(
     return aResult;
 }
 
+std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
+    const rtl::Reference< ::chart::ChartModel > & xChartDoc )
+{
+    std::vector< uno::Reference< XDataSeries > > aResult;
+
+    rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( 
xChartDoc );
+    if( xDiagram.is())
+        aResult = DiagramHelper::getDataSeriesFromDiagram( xDiagram );
+
+    return aResult;
+}
+
 std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
     const uno::Reference< frame::XModel > & xModel )
 {

Reply via email to