chart2/source/controller/chartapiwrapper/AreaWrapper.cxx                       
    |    2 
 chart2/source/controller/chartapiwrapper/AxisWrapper.cxx                       
    |   12 -
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx                
    |   74 +++-----
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx                
    |   13 -
 chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx                  
    |   18 +-
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx              
    |   89 ++++------
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx                    
    |   36 ++--
 chart2/source/controller/chartapiwrapper/TitleWrapper.cxx                      
    |    6 
 
chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
 |    6 
 chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx        
    |    4 
 chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx            
    |    8 
 11 files changed, 126 insertions(+), 142 deletions(-)

New commits:
commit e1802876e0773d57631f6a8f773fafaf4cfc7926
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Jan 15 17:21:12 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jan 15 20:32:21 2022 +0100

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

diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
index 8920b1eda076..7cbef7d67e2c 100644
--- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
@@ -132,7 +132,7 @@ void SAL_CALL AreaWrapper::removeEventListener(
 // WrappedPropertySet
 Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
 {
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( xChartDoc.is() )
         return xChartDoc->getPageBackground();
     OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
index b15f33f1871a..37835448d14e 100644
--- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
@@ -490,18 +490,18 @@ OUString SAL_CALL AxisWrapper::getShapeType()
 // ____ XNumberFormatsSupplier ____
 uno::Reference< beans::XPropertySet > SAL_CALL 
AxisWrapper::getNumberFormatSettings()
 {
-    Reference< util::XNumberFormatsSupplier > xNumSuppl( 
m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
-    if( xNumSuppl.is() )
-        return xNumSuppl->getNumberFormatSettings();
+    rtl::Reference<ChartModel> xChartModel( 
m_spChart2ModelContact->getDocumentModel() );
+    if( xChartModel )
+        return xChartModel->getNumberFormatSettings();
 
     return uno::Reference< beans::XPropertySet >();
 }
 
 uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
 {
-    Reference< util::XNumberFormatsSupplier > xNumSuppl( 
m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
-    if( xNumSuppl.is() )
-        return xNumSuppl->getNumberFormats();
+    rtl::Reference<ChartModel> xChartModel( 
m_spChart2ModelContact->getDocumentModel() );
+    if( xChartModel )
+        return xChartModel->getNumberFormats();
 
     return uno::Reference< util::XNumberFormats >();
 }
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx 
b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 8f1f3ad23e9d..8759cc6f54b7 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -43,8 +43,7 @@ namespace chart::wrapper
 Chart2ModelContact::Chart2ModelContact(
     const Reference< uno::XComponentContext > & xContext ) :
         m_xContext( xContext ),
-        m_xChartModel( nullptr ),
-        mpModel( nullptr )
+        m_xChartModel( nullptr )
 {
 }
 
@@ -53,20 +52,18 @@ Chart2ModelContact::~Chart2ModelContact()
     clear();
 }
 
-void Chart2ModelContact::setModel( const css::uno::Reference< 
css::frame::XModel >& xChartModel )
+void Chart2ModelContact::setDocumentModel( ChartModel* pChartModel )
 {
     clear();
-    m_xChartModel = xChartModel;
-    mpModel = dynamic_cast<ChartModel*>(xChartModel.get());
-    uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, 
uno::UNO_QUERY );
-    if( !xTableFactory.is() )
+    m_xChartModel = pChartModel;
+    if( !pChartModel )
         return;
 
-    uno::Reference< container::XNameContainer > xDashTable( 
xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY 
);
-    uno::Reference< container::XNameContainer > xGradientTable( 
xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), 
uno::UNO_QUERY );
-    uno::Reference< container::XNameContainer > xHatchTable( 
xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), 
uno::UNO_QUERY );
-    uno::Reference< container::XNameContainer > xBitmapTable( 
xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), 
uno::UNO_QUERY );
-    uno::Reference< container::XNameContainer > xTransparencyGradientTable( 
xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
 uno::UNO_QUERY );
+    uno::Reference< container::XNameContainer > xDashTable( 
pChartModel->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
+    uno::Reference< container::XNameContainer > xGradientTable( 
pChartModel->createInstance("com.sun.star.drawing.GradientTable"), 
uno::UNO_QUERY );
+    uno::Reference< container::XNameContainer > xHatchTable( 
pChartModel->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY 
);
+    uno::Reference< container::XNameContainer > xBitmapTable( 
pChartModel->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY 
);
+    uno::Reference< container::XNameContainer > xTransparencyGradientTable( 
pChartModel->createInstance("com.sun.star.drawing.TransparencyGradientTable"), 
uno::UNO_QUERY );
     m_aTableMap["LineDashName"] = xDashTable;
     m_aTableMap["FillGradientName"] = xGradientTable;
     m_aTableMap["FillHatchName"] = xHatchTable;
@@ -78,22 +75,16 @@ void Chart2ModelContact::clear()
 {
     m_xChartModel.clear();
     m_xChartView.clear();
-    mpModel = nullptr;
 }
 
-Reference< frame::XModel > Chart2ModelContact::getChartModel() const
+rtl::Reference< ChartModel > Chart2ModelContact::getDocumentModel() const
 {
-    return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY );
-}
-
-Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() 
const
-{
-    return Reference< chart2::XChartDocument >( m_xChartModel.get(), 
uno::UNO_QUERY );
+    return m_xChartModel;
 }
 
 Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const
 {
-    return ChartModelHelper::findDiagram( getChartModel() );
+    return ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) );
 }
 
 uno::Reference< lang::XUnoTunnel > const & Chart2ModelContact::getChartView() 
const
@@ -101,10 +92,9 @@ uno::Reference< lang::XUnoTunnel > const & 
Chart2ModelContact::getChartView() co
     if(!m_xChartView.is())
     {
         // get the chart view
-        Reference<frame::XModel> xModel(m_xChartModel);
-        uno::Reference< lang::XMultiServiceFactory > xFact( xModel, 
uno::UNO_QUERY );
-        if( xFact.is() )
-            m_xChartView.set( xFact->createInstance( CHART_VIEW_SERVICE_NAME 
), uno::UNO_QUERY );
+        rtl::Reference<ChartModel> xChartModel( m_xChartModel );
+        if( xChartModel )
+            m_xChartView.set( xChartModel->createInstance( 
CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
     }
     return m_xChartView;
 }
@@ -146,10 +136,10 @@ sal_Int32 
Chart2ModelContact::getExplicitNumberFormatKeyForAxis(
 {
     Reference< chart2::XCoordinateSystem > xCooSys(
         AxisHelper::getCoordinateSystemOfAxis(
-              xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) );
+              xAxis, ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) ) );
 
     return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, 
xCooSys
-              , getChart2Document());
+              , m_xChartModel.get() );
 }
 
 sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
@@ -161,13 +151,13 @@ sal_Int32 
Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
 
 awt::Size Chart2ModelContact::GetPageSize() const
 {
-    return ChartModelHelper::getPageSize(m_xChartModel);
+    return ChartModelHelper::getPageSize(m_xChartModel.get());
 }
 
 awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const 
awt::Rectangle& rPositionRect )
 {
     awt::Rectangle aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes(
-        *mpModel, getChartView(), rPositionRect, true );
+        *m_xChartModel.get(), getChartView(), rPositionRect, true );
     return aRect;
 }
 
@@ -177,7 +167,7 @@ awt::Rectangle 
Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
 
     //add axis title sizes to the diagram size
     aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes(
-        *mpModel, getChartView(), aRect, false );
+        *m_xChartModel.get(), getChartView(), aRect, false );
 
     return aRect;
 }
@@ -185,10 +175,10 @@ awt::Rectangle 
Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
 awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
 {
     awt::Rectangle aRect(0,0,0,0);
-    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( 
m_xChartModel ) );
+    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
 
     if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == 
DiagramPositioningMode_INCLUDING )
-        aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+        aRect = 
DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get());
     else
     {
         ExplicitValueProvider* pProvider( getExplicitValueProvider() );
@@ -201,10 +191,10 @@ awt::Rectangle 
Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
 awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const
 {
     awt::Rectangle aRect(0,0,0,0);
-    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( 
m_xChartModel ) );
+    uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( 
uno::Reference<XChartDocument>(m_xChartModel.get()) ) );
 
     if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == 
DiagramPositioningMode_EXCLUDING )
-        aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+        aRect = 
DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get());
     else
     {
         ExplicitValueProvider* pProvider( getExplicitValueProvider() );
@@ -220,8 +210,8 @@ awt::Size Chart2ModelContact::GetLegendSize() const
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider )
     {
-        uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*mpModel ) );
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, *mpModel ) );
+        uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_xChartModel.get() ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, *m_xChartModel.get() ) );
         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     }
     return aSize;
@@ -233,8 +223,8 @@ awt::Point Chart2ModelContact::GetLegendPosition() const
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider )
     {
-        uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*mpModel ) );
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, *mpModel ) );
+        uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_xChartModel.get() ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xLegend, *m_xChartModel.get() ) );
         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     }
     return aPoint;
@@ -246,7 +236,7 @@ awt::Size Chart2ModelContact::GetTitleSize( const 
uno::Reference< css::chart2::X
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider && xTitle.is() )
     {
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, m_xChartModel ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, m_xChartModel.get() ) );
         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     }
     return aSize;
@@ -258,7 +248,7 @@ awt::Point Chart2ModelContact::GetTitlePosition( const 
uno::Reference< css::char
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider && xTitle.is() )
     {
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, m_xChartModel ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xTitle, m_xChartModel.get() ) );
         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     }
     return aPoint;
@@ -270,7 +260,7 @@ awt::Size Chart2ModelContact::GetAxisSize( const 
uno::Reference< css::chart2::XA
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider && xAxis.is() )
     {
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xAxis, m_xChartModel ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xAxis, m_xChartModel.get() ) );
         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     }
     return aSize;
@@ -282,7 +272,7 @@ awt::Point Chart2ModelContact::GetAxisPosition( const 
uno::Reference< css::chart
     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     if( pProvider && xAxis.is() )
     {
-        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xAxis, m_xChartModel ) );
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( 
xAxis, m_xChartModel.get() ) );
         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     }
     return aPoint;
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx 
b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
index d101198a12d9..3b1cef1e2412 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
@@ -24,6 +24,8 @@
 #include <com/sun/star/awt/Rectangle.hpp>
 #include <rtl/ref.hxx>
 #include <svx/unopage.hxx>
+#include <unotools/weakref.hxx>
+#include <ChartModel.hxx>
 #include <map>
 
 namespace chart { struct ExplicitIncrementData; }
@@ -55,14 +57,11 @@ public:
     ~Chart2ModelContact();
 
 public:
-    void setModel( const css::uno::Reference< css::frame::XModel >& 
xChartModel );
+    void setDocumentModel( ChartModel* pChartModel );
     void clear();
 
-    css::uno::Reference< css::frame::XModel > getChartModel() const;
+    rtl::Reference<ChartModel> getDocumentModel() const;
 
-    ChartModel* getModel() const { return mpModel;}
-
-    css::uno::Reference< css::chart2::XChartDocument > getChart2Document() 
const;
     css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const;
 
     rtl::Reference<SvxDrawPage> getDrawPage() const;
@@ -137,9 +136,7 @@ public: //member
     css::uno::Reference< css::uno::XComponentContext >  m_xContext;
 
 private: //member
-    css::uno::WeakReference< css::frame::XModel >   m_xChartModel;
-
-    ChartModel* mpModel;
+    unotools::WeakReference< ChartModel >   m_xChartModel;
 
     mutable css::uno::Reference< css::lang::XUnoTunnel > m_xChartView;
 
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
index 0880cfba525f..d69d67676c66 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -465,24 +465,24 @@ void SAL_CALL ChartDataWrapper::setData( const Sequence< 
Sequence< double > >& r
 }
 void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString 
>& rRowDescriptions )
 {
-    lcl_RowDescriptionsOperator aOperator( rRowDescriptions, 
m_spChart2ModelContact->getChart2Document() );
+    lcl_RowDescriptionsOperator aOperator( rRowDescriptions, 
m_spChart2ModelContact->getDocumentModel() );
     applyData( aOperator );
 }
 void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< 
OUString >& rColumnDescriptions )
 {
-    lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, 
m_spChart2ModelContact->getChart2Document() );
+    lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, 
m_spChart2ModelContact->getDocumentModel() );
     applyData( aOperator );
 }
 
 // ____ XComplexDescriptionAccess (write) ____
 void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< 
Sequence< OUString > >& rRowDescriptions )
 {
-    lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, 
m_spChart2ModelContact->getChart2Document() );
+    lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, 
m_spChart2ModelContact->getDocumentModel() );
     applyData( aOperator );
 }
 void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< 
Sequence< OUString > >& rColumnDescriptions )
 {
-    lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, 
m_spChart2ModelContact->getChart2Document() );
+    lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, 
m_spChart2ModelContact->getDocumentModel() );
     applyData( aOperator );
 }
 
@@ -501,7 +501,7 @@ void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( 
const Sequence< Sequen
 // ____ XDateCategories (write) ____
 void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& 
rDates )
 {
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
     lcl_DateCategoriesOperator aOperator( rDates );
     applyData( aOperator );
@@ -573,7 +573,7 @@ void ChartDataWrapper::fireChartDataChangeEvent( 
css::chart::ChartDataChangeEven
 void ChartDataWrapper::switchToInternalDataProvider()
 {
     //create an internal data provider that is connected to the model
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( xChartDoc.is() )
         xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ );
     initDataAccess();
@@ -581,7 +581,7 @@ void ChartDataWrapper::switchToInternalDataProvider()
 
 void ChartDataWrapper::initDataAccess()
 {
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( !xChartDoc.is() )
         return;
     if( xChartDoc->hasInternalDataProvider() )
@@ -597,7 +597,7 @@ void ChartDataWrapper::initDataAccess()
 void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
 {
     //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( !xChartDoc.is() )
         return;
 
@@ -605,7 +605,7 @@ void ChartDataWrapper::applyData( lcl_Operator& 
rDataOperator )
     bool bStacked = false;
     bool bPercent = false;
     bool bDeep = false;
-    uno::Reference< css::chart::XChartDocument > xOldDoc( xChartDoc, 
uno::UNO_QUERY );
+    uno::Reference< css::chart::XChartDocument > xOldDoc( 
static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY );
     OSL_ASSERT( xOldDoc.is());
     uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), 
uno::UNO_QUERY );
     if( xDiaProp.is())
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index aa5d09c2c99a..98085165da86 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -291,19 +291,19 @@ void 
WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOu
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( !DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
         return;
 
     if( bUseColumns && bNewValue != bFirstCellAsLabel )
     {
         DataSourceHelper::setRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aSequenceMapping, 
bUseColumns ,bNewValue, bHasCategories );
+            m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, 
bUseColumns ,bNewValue, bHasCategories );
     }
     else if( !bUseColumns && bNewValue != bHasCategories )
     {
         DataSourceHelper::setRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aSequenceMapping, 
bUseColumns , bFirstCellAsLabel, bNewValue );
+            m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, 
bUseColumns , bFirstCellAsLabel, bNewValue );
     }
 }
 
@@ -316,7 +316,7 @@ Any 
WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
     {
         bool bLabelsInFirstRow = true;
@@ -381,19 +381,19 @@ void 
WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any&
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( !DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
         return;
 
     if( bUseColumns && bNewValue != bHasCategories )
     {
         DataSourceHelper::setRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aSequenceMapping, 
bUseColumns, bFirstCellAsLabel, bNewValue );
+            m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, 
bUseColumns, bFirstCellAsLabel, bNewValue );
     }
     else if( !bUseColumns && bNewValue != bFirstCellAsLabel )
     {
         DataSourceHelper::setRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aSequenceMapping, 
bUseColumns , bNewValue, bHasCategories );
+            m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, 
bUseColumns , bNewValue, bHasCategories );
     }
 }
 
@@ -406,7 +406,7 @@ Any 
WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Refere
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
     {
         bool bLabelsInFirstColumn = true;
@@ -461,7 +461,7 @@ void WrappedHasLegendProperty::setPropertyValue( const Any& 
rOuterValue, const R
 
     try
     {
-        Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_spChart2ModelContact->getModel(), 
m_spChart2ModelContact->m_xContext,bNewValue ));
+        Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( 
*m_spChart2ModelContact->getDocumentModel(), 
m_spChart2ModelContact->m_xContext,bNewValue ));
         if(xLegend.is())
         {
             Reference< beans::XPropertySet > xLegendProp( xLegend, 
uno::UNO_QUERY_THROW );
@@ -484,7 +484,7 @@ Any WrappedHasLegendProperty::getPropertyValue( const 
Reference< beans::XPropert
     try
     {
         Reference< beans::XPropertySet > xLegendProp(
-            LegendHelper::getLegend( *m_spChart2ModelContact->getModel() ), 
uno::UNO_QUERY );
+            LegendHelper::getLegend( 
*m_spChart2ModelContact->getDocumentModel() ), uno::UNO_QUERY );
         if( xLegendProp.is())
             aRet = xLegendProp->getPropertyValue("Show");
         else
@@ -539,9 +539,9 @@ void WrappedHasMainTitleProperty::setPropertyValue( const 
Any& rOuterValue, cons
     try
     {
         if( bNewValue )
-            TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", 
m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+            TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", 
m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext 
);
         else
-            TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, 
m_spChart2ModelContact->getChartModel() );
+            TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, 
m_spChart2ModelContact->getDocumentModel() );
     }
     catch (const uno::Exception&)
     {
@@ -554,7 +554,7 @@ Any WrappedHasMainTitleProperty::getPropertyValue( const 
Reference< beans::XProp
     Any aRet;
     try
     {
-        aRet <<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE, 
m_spChart2ModelContact->getChartModel() ).is();
+        aRet <<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE, 
m_spChart2ModelContact->getDocumentModel() ).is();
     }
     catch (const uno::Exception&)
     {
@@ -605,9 +605,9 @@ void WrappedHasSubTitleProperty::setPropertyValue( const 
Any& rOuterValue, const
     try
     {
         if( bNewValue )
-            TitleHelper::createTitle( TitleHelper::SUB_TITLE, "", 
m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+            TitleHelper::createTitle( TitleHelper::SUB_TITLE, "", 
m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext 
);
         else
-            TitleHelper::removeTitle( TitleHelper::SUB_TITLE, 
m_spChart2ModelContact->getChartModel() );
+            TitleHelper::removeTitle( TitleHelper::SUB_TITLE, 
m_spChart2ModelContact->getDocumentModel() );
     }
     catch (const uno::Exception&)
     {
@@ -620,7 +620,7 @@ Any WrappedHasSubTitleProperty::getPropertyValue( const 
Reference< beans::XPrope
     Any aRet;
     try
     {
-        aRet <<= TitleHelper::getTitle( TitleHelper::SUB_TITLE, 
m_spChart2ModelContact->getChartModel() ).is();
+        aRet <<= TitleHelper::getTitle( TitleHelper::SUB_TITLE, 
m_spChart2ModelContact->getDocumentModel() ).is();
     }
     catch (const uno::Exception&)
     {
@@ -664,7 +664,7 @@ Reference< drawing::XShape > SAL_CALL 
ChartDocumentWrapper::getTitle()
 {
     if( !m_xTitle.is()  )
     {
-        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChart2Document() );
+        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
         m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, 
m_spChart2ModelContact );
     }
     return m_xTitle;
@@ -674,7 +674,7 @@ Reference< drawing::XShape > SAL_CALL 
ChartDocumentWrapper::getSubTitle()
 {
     if( !m_xSubTitle.is() )
     {
-        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChart2Document() );
+        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
         m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, 
m_spChart2ModelContact );
     }
     return m_xSubTitle;
@@ -734,7 +734,7 @@ void SAL_CALL ChartDocumentWrapper::setDiagram( const 
Reference< XDiagram >& xDi
 
         try
         {
-            Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+            rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
             if( xChartDoc.is() )
             {
                 // set the new diagram
@@ -765,7 +765,7 @@ void SAL_CALL ChartDocumentWrapper::attachData( const 
Reference< XChartData >& x
     if( !xNewData.is() )
         return;
 
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChart2Document() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) 
);
 }
 
@@ -774,7 +774,7 @@ sal_Bool SAL_CALL ChartDocumentWrapper::attachResource(
     const OUString& URL,
     const Sequence< beans::PropertyValue >& Arguments )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->attachResource( URL, Arguments );
     return false;
@@ -782,7 +782,7 @@ sal_Bool SAL_CALL ChartDocumentWrapper::attachResource(
 
 OUString SAL_CALL ChartDocumentWrapper::getURL()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->getURL();
     return OUString();
@@ -790,7 +790,7 @@ OUString SAL_CALL ChartDocumentWrapper::getURL()
 
 Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->getArgs();
     return Sequence< beans::PropertyValue >();
@@ -798,7 +798,7 @@ Sequence< beans::PropertyValue > SAL_CALL 
ChartDocumentWrapper::getArgs()
 
 void SAL_CALL ChartDocumentWrapper::connectController( const Reference< 
frame::XController >& Controller )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->connectController( Controller );
 }
@@ -806,28 +806,28 @@ void SAL_CALL ChartDocumentWrapper::connectController( 
const Reference< frame::X
 void SAL_CALL ChartDocumentWrapper::disconnectController(
     const Reference< frame::XController >& Controller )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->disconnectController( Controller );
 }
 
 void SAL_CALL ChartDocumentWrapper::lockControllers()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->lockControllers();
 }
 
 void SAL_CALL ChartDocumentWrapper::unlockControllers()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->unlockControllers();
 }
 
 sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->hasControllersLocked();
     return false;
@@ -835,7 +835,7 @@ sal_Bool SAL_CALL 
ChartDocumentWrapper::hasControllersLocked()
 
 Reference< frame::XController > SAL_CALL 
ChartDocumentWrapper::getCurrentController()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->getCurrentController();
     return nullptr;
@@ -844,14 +844,14 @@ Reference< frame::XController > SAL_CALL 
ChartDocumentWrapper::getCurrentControl
 void SAL_CALL ChartDocumentWrapper::setCurrentController(
     const Reference< frame::XController >& Controller )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->setCurrentController( Controller );
 }
 
 Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::getCurrentSelection()
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         return xModel->getCurrentSelection();
     return nullptr;
@@ -940,7 +940,7 @@ void ChartDocumentWrapper::impl_resetAddIn()
 
 void ChartDocumentWrapper::setBaseDiagram( const OUString& rBaseDiagram )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     m_aBaseDiagram = rBaseDiagram;
 
     uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( 
rBaseDiagram ), uno::UNO_QUERY );
@@ -953,7 +953,7 @@ void ChartDocumentWrapper::setAddIn( const Reference< 
util::XRefreshable >& xAdd
     if( m_xAddIn == xAddIn )
         return;
 
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     impl_resetAddIn();
     m_xAddIn = xAddIn;
     // initialize AddIn with this as chart document
@@ -1017,14 +1017,14 @@ Reference< drawing::XShapes > 
ChartDocumentWrapper::getAdditionalShapes() const
 
 void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< 
lang::XEventListener >& xListener )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->addEventListener( xListener );
 }
 
 void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< 
lang::XEventListener >& aListener )
 {
-    Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() 
);
+    rtl::Reference< ChartModel > xModel( 
m_spChart2ModelContact->getDocumentModel() );
     if( xModel.is() )
         xModel->removeEventListener( aListener );
 }
@@ -1059,7 +1059,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
 {
     uno::Reference< uno::XInterface > xResult;
 
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( !xChartDoc.is() )
         return xResult;
 
@@ -1176,12 +1176,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
             case SERVICE_NAME_BITMAP_TABLE:
             case SERVICE_NAME_TRANSP_GRADIENT_TABLE:
             case SERVICE_NAME_MARKER_TABLE:
-                {
-                    uno::Reference< lang::XMultiServiceFactory > 
xTableFactory( xChartDoc, uno::UNO_QUERY );
-                    OSL_ENSURE( xTableFactory.get() != this, "new model is 
expected to implement service factory for gradient table etc" );
-                    if( xTableFactory.is() && xTableFactory.get() != this )
-                        xResult.set( xTableFactory->createInstance( aIt->first 
), uno::UNO_QUERY );
-                }
+                xResult.set( xChartDoc->createInstance( aIt->first ), 
uno::UNO_QUERY );
                 break;
 
             case SERVICE_NAME_NAMESPACE_MAP:
@@ -1201,7 +1196,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
                 {
                     // locked controllers
                     ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
-                    Reference< chart2::XDiagram > xDiagram = 
ChartModelHelper::findDiagram( 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 );
                     DiagramHelper::tTemplateWithServiceName 
aTemplateWithService(
@@ -1243,7 +1238,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
     {
         if( !m_xChartView.is() )
         {
-            ChartModel* pModel = m_spChart2ModelContact->getModel();
+            rtl::Reference<ChartModel> pModel = 
m_spChart2ModelContact->getDocumentModel();
             ChartView* pChartView = pModel->getChartView();
             if(pChartView)
             {
@@ -1275,7 +1270,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
             }
             else
             {
-                ChartModel* pModel = m_spChart2ModelContact->getModel();
+                rtl::Reference<ChartModel> pModel = 
m_spChart2ModelContact->getDocumentModel();
                 if(pModel)
                 {
                     m_xChartView = pModel->getChartView();
@@ -1347,7 +1342,9 @@ void SAL_CALL ChartDocumentWrapper::setDelegator(
     if( rDelegator.is())
     {
         m_xDelegator = rDelegator;
-        m_spChart2ModelContact->setModel( uno::Reference< frame::XModel 
>(m_xDelegator, uno::UNO_QUERY) );
+        ChartModel* pChartModel = dynamic_cast<ChartModel*>(rDelegator.get());
+        assert(pChartModel);
+        m_spChart2ModelContact->setDocumentModel( pChartModel );
     }
     else
     {
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index f46abaae3027..cb19a9b4a578 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -584,11 +584,11 @@ OUString SAL_CALL DiagramWrapper::getDiagramType()
 {
     OUString aRet;
 
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
     if( xChartDoc.is() && xDiagram.is() )
     {
-        Reference< beans::XPropertySet > xChartDocProp( xChartDoc, 
uno::UNO_QUERY );
+        Reference< beans::XPropertySet > xChartDocProp( 
static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY );
         if( xChartDocProp.is() )
         {
             uno::Reference< util::XRefreshable > xAddIn;
@@ -671,7 +671,7 @@ awt::Point SAL_CALL DiagramWrapper::getPosition()
 
 void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
     if( !xProp.is() )
         return;
@@ -701,7 +701,7 @@ awt::Size SAL_CALL DiagramWrapper::getSize()
 
 void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
     if( !xProp.is() )
         return;
@@ -734,7 +734,7 @@ OUString SAL_CALL DiagramWrapper::getShapeType()
 
 void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning()
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), 
uno::UNO_QUERY );
     if( xDiaProps.is() )
     {
@@ -756,8 +756,8 @@ sal_Bool SAL_CALL 
DiagramWrapper::isAutomaticDiagramPositioning(  )
 }
 void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const 
awt::Rectangle& rPositionRect )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
-    DiagramHelper::setDiagramPositioning( 
m_spChart2ModelContact->getChartModel(), rPositionRect );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
+    DiagramHelper::setDiagramPositioning( 
m_spChart2ModelContact->getDocumentModel(), rPositionRect );
     uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), 
uno::UNO_QUERY );
     if( xDiaProps.is() )
         xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(true) );
@@ -784,8 +784,8 @@ awt::Rectangle SAL_CALL 
DiagramWrapper::calculateDiagramPositionExcludingAxes(
 }
 void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const 
awt::Rectangle& rPositionRect )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
-    DiagramHelper::setDiagramPositioning( 
m_spChart2ModelContact->getChartModel(), rPositionRect );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
+    DiagramHelper::setDiagramPositioning( 
m_spChart2ModelContact->getDocumentModel(), rPositionRect );
     uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), 
uno::UNO_QUERY );
     if( xDiaProps.is() )
         xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(false) );
@@ -796,7 +796,7 @@ awt::Rectangle SAL_CALL 
DiagramWrapper::calculateDiagramPositionIncludingAxes(
 }
 void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( 
const awt::Rectangle& rPositionRect )
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     awt::Rectangle aRect( 
m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) );
     DiagramWrapper::setDiagramPositionIncludingAxes( aRect );
 }
@@ -1144,14 +1144,14 @@ void WrappedDataRowSourceProperty::setPropertyValue( 
const Any& rOuterValue, con
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
     {
         if( bUseColumns != bNewUseColumns )
         {
             aSequenceMapping.realloc(0);
             DataSourceHelper::setRangeSegmentation(
-                m_spChart2ModelContact->getChartModel(), aSequenceMapping, 
bNewUseColumns , bFirstCellAsLabel , bHasCategories);
+                m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, 
bNewUseColumns , bFirstCellAsLabel , bHasCategories);
         }
     }
 }
@@ -1165,7 +1165,7 @@ Any WrappedDataRowSourceProperty::getPropertyValue( const 
Reference< beans::XPro
     uno::Sequence< sal_Int32 > aSequenceMapping;
 
     if( DataSourceHelper::detectRangeSegmentation(
-            m_spChart2ModelContact->getChartModel(), aRangeString, 
aSequenceMapping, bUseColumns
+            m_spChart2ModelContact->getDocumentModel(), aRangeString, 
aSequenceMapping, bUseColumns
             , bFirstCellAsLabel, bHasCategories ) )
     {
         css::chart::ChartDataRowSource eChartDataRowSource = 
css::chart::ChartDataRowSource_ROWS;
@@ -1456,7 +1456,7 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( 
uno::Any& rInnerValue ) con
     sal_Int32 nNumberOfLines = 0;
     bool bHasDetectableInnerValue = false;
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
-    uno::Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     if( xDiagram.is() && xChartDoc.is() )
     {
         std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
@@ -1494,7 +1494,7 @@ void WrappedNumberOfLinesProperty::setPropertyValue( 
const Any& rOuterValue, con
 
     m_aOuterValue = rOuterValue;
 
-    uno::Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
     sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
     if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) )
@@ -1541,7 +1541,7 @@ void WrappedNumberOfLinesProperty::setPropertyValue( 
const Any& rOuterValue, con
     try
     {
         // locked controllers
-        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
         uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY 
);
         xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) );
         xTemplate->changeDiagram( xDiagram );
@@ -1830,12 +1830,12 @@ void 
WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue
     if( ! (rOuterValue >>= bNewValue) )
         throw lang::IllegalArgumentException( "Property IncludeHiddenCells 
requires boolean value", nullptr, 0 );
 
-    ChartModelHelper::setIncludeHiddenCells( bNewValue, 
*m_spChart2ModelContact->getModel() );
+    ChartModelHelper::setIncludeHiddenCells( bNewValue, 
*m_spChart2ModelContact->getDocumentModel() );
 }
 
 Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< 
beans::XPropertySet >& /*xInnerPropertySet*/ ) const
 {
-    bool bValue = ChartModelHelper::isIncludeHiddenCells( 
m_spChart2ModelContact->getChartModel() );
+    bool bValue = ChartModelHelper::isIncludeHiddenCells( 
m_spChart2ModelContact->getDocumentModel() );
     return uno::Any(bValue);
 }
 
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
index 712ef0613c26..074a37778e65 100644
--- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
@@ -195,9 +195,9 @@ TitleWrapper::TitleWrapper( 
::chart::TitleHelper::eTitleType eTitleType,
         m_aEventListenerContainer( m_aMutex ),
         m_eTitleType(eTitleType)
 {
-    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChart2Document() );
+    ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
     if( !getTitleObject().is() ) //#i83831# create an empty title at the 
model, thus references to properties can be mapped correctly
-        TitleHelper::createTitle( m_eTitleType, OUString(), 
m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+        TitleHelper::createTitle( m_eTitleType, OUString(), 
m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext 
);
 }
 
 TitleWrapper::~TitleWrapper()
@@ -457,7 +457,7 @@ awt::Size TitleWrapper::getCurrentSizeForReference()
 
 Reference< chart2::XTitle > TitleWrapper::getTitleObject()
 {
-    return TitleHelper::getTitle( m_eTitleType, 
m_spChart2ModelContact->getChartModel() );
+    return TitleHelper::getTitle( m_eTitleType, 
m_spChart2ModelContact->getDocumentModel() );
 }
 
 // WrappedPropertySet
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
 
b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
index 5ee50f4dbd73..4a43b4ccfbb1 100644
--- 
a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
+++ 
b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
@@ -275,11 +275,11 @@ void WrappedAxisTitleExistenceProperty::setPropertyValue( 
const Any& rOuterValue
     if( bNewValue )
     {
         TitleHelper::createTitle(  m_eTitleType, OUString()
-            , m_spChart2ModelContact->getChartModel(), 
m_spChart2ModelContact->m_xContext );
+            , m_spChart2ModelContact->getDocumentModel(), 
m_spChart2ModelContact->m_xContext );
     }
     else
     {
-        TitleHelper::removeTitle( m_eTitleType, 
m_spChart2ModelContact->getChartModel() );
+        TitleHelper::removeTitle( m_eTitleType, 
m_spChart2ModelContact->getDocumentModel() );
     }
 }
 
@@ -287,7 +287,7 @@ Any WrappedAxisTitleExistenceProperty::getPropertyValue( 
const Reference< beans:
 {
     bool bHasTitle = false;
 
-    Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, 
m_spChart2ModelContact->getChartModel() ) );
+    Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, 
m_spChart2ModelContact->getDocumentModel() ) );
     if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() )
         bHasTitle = true;
 
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
index 6e12bea50e0a..bc83ba60df87 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
@@ -126,8 +126,8 @@ uno::Reference< chart2::data::XDataProvider > 
lcl_getDataProviderFromContact(
     uno::Reference< chart2::data::XDataProvider > xResult;
     if( spChart2ModelContact)
     {
-        uno::Reference< chart2::XChartDocument > xChartDoc(
-            spChart2ModelContact->getChart2Document());
+        rtl::Reference< ChartModel > xChartDoc(
+            spChart2ModelContact->getDocumentModel());
         if( xChartDoc.is())
             xResult.set( xChartDoc->getDataProvider());
     }
diff --git 
a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx 
b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
index 54027301f53b..4dc252cc5a4c 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -75,7 +75,7 @@ void WrappedStockProperty::setPropertyValue( const 
css::uno::Any& rOuterValue, c
 
     m_aOuterValue = rOuterValue;
 
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
     sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
     if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) )
@@ -94,7 +94,7 @@ void WrappedStockProperty::setPropertyValue( const 
css::uno::Any& rOuterValue, c
     try
     {
         // locked controllers
-        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getChartModel() );
+        ControllerLockGuardUNO aCtrlLockGuard( 
m_spChart2ModelContact->getDocumentModel() );
         xTemplate->changeDiagram( xDiagram );
     }
     catch( const uno::Exception & )
@@ -129,7 +129,7 @@ WrappedVolumeProperty::WrappedVolumeProperty(const 
std::shared_ptr<Chart2ModelCo
 
 css::uno::Any WrappedVolumeProperty::getPropertyValue( const 
css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const
 {
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
     if( xDiagram.is() && xChartDoc.is() )
     {
@@ -198,7 +198,7 @@ WrappedUpDownProperty::WrappedUpDownProperty(const 
std::shared_ptr<Chart2ModelCo
 
 css::uno::Any WrappedUpDownProperty::getPropertyValue( const 
css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const
 {
-    Reference< chart2::XChartDocument > xChartDoc( 
m_spChart2ModelContact->getChart2Document() );
+    rtl::Reference< ChartModel > xChartDoc( 
m_spChart2ModelContact->getDocumentModel() );
     Reference< chart2::XDiagram > xDiagram( 
m_spChart2ModelContact->getChart2Diagram() );
     if( xDiagram.is() && xChartDoc.is() )
     {

Reply via email to