chart2/source/controller/chartapiwrapper/AxisWrapper.hxx          |   10 +-
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx |   12 ++-
 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx       |   10 +-
 chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx       |   37 
+++-------
 chart2/source/controller/chartapiwrapper/TitleWrapper.hxx         |    2 
 chart2/source/controller/inc/ChartDocumentWrapper.hxx             |    9 +-
 chart2/source/view/diagram/VDiagram.cxx                           |    5 -
 chart2/source/view/inc/VDiagram.hxx                               |    2 
 include/comphelper/types.hxx                                      |   10 ++
 include/svx/unoshape.hxx                                          |    3 
 10 files changed, 54 insertions(+), 46 deletions(-)

New commits:
commit 451a66438a58505d2e89e76c7559a9dac1bbc00e
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 13 11:16:12 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Sep 13 18:51:41 2024 +0200

    use more concrete UNO types in chart2
    
    Change-Id: Id2d58ad76b6e8ff569bd7b65f86a7fdd0152f3d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173324
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
index e70c85b23ff8..3b63c45c100d 100644
--- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
@@ -27,7 +27,7 @@
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-
+#include <rtl/ref.hxx>
 #include <memory>
 
 namespace com::sun::star::chart2 { class XAxis; }
@@ -35,6 +35,8 @@ namespace com::sun::star::chart2 { class XAxis; }
 namespace chart::wrapper
 {
 class Chart2ModelContact;
+class TitleWrapper;
+class GridWrapper;
 
 class AxisWrapper : public ::cppu::ImplInheritanceHelper<
                       WrappedPropertySet
@@ -113,9 +115,9 @@ private: //member
 
     tAxisType           m_eType;
 
-    css::uno::Reference< css::beans::XPropertySet >   m_xAxisTitle;
-    css::uno::Reference< css::beans::XPropertySet >   m_xMajorGrid;
-    css::uno::Reference< css::beans::XPropertySet >   m_xMinorGrid;
+    rtl::Reference< TitleWrapper >   m_xAxisTitle;
+    rtl::Reference< GridWrapper >   m_xMajorGrid;
+    rtl::Reference< GridWrapper >   m_xMinorGrid;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index f7825b714855..ab6de48e0fe1 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -858,7 +858,11 @@ void SAL_CALL ChartDocumentWrapper::dispose()
     try
     {
         Reference< lang::XComponent > xFormerDelegator( m_xDelegator, 
uno::UNO_QUERY );
-        DisposeHelper::DisposeAndClear( m_xTitle );
+        if (m_xTitle)
+        {
+            m_xTitle->dispose();
+            m_xTitle.clear();
+        }
         DisposeHelper::DisposeAndClear( m_xSubTitle );
         DisposeHelper::DisposeAndClear( m_xLegend );
         DisposeHelper::DisposeAndClear( m_xChartData );
@@ -1344,11 +1348,11 @@ uno::Any SAL_CALL 
ChartDocumentWrapper::queryAggregation( const uno::Type& rType
 // ____ ::utl::OEventListenerAdapter ____
 void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource )
 {
-    if( rSource.Source == m_xTitle )
+    if( rSource.Source == cppu::getXWeak(m_xTitle.get()) )
         m_xTitle.clear();
-    else if( rSource.Source == m_xSubTitle )
+    else if( rSource.Source == cppu::getXWeak(m_xSubTitle.get()) )
         m_xSubTitle.clear();
-    else if( rSource.Source == m_xLegend )
+    else if( rSource.Source == cppu::getXWeak(m_xLegend.get()) )
         m_xLegend.clear();
     else if( rSource.Source == m_xChartData )
         m_xChartData.clear();
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index 1b9da6491134..12b7e1b11c7b 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -887,7 +887,7 @@ Reference< beans::XPropertySet > SAL_CALL 
DiagramWrapper::getZAxis()
 {
     if( ! m_xZAxis.is())
         m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, 
m_spChart2ModelContact );
-    return Reference< beans::XPropertySet >( m_xZAxis, uno::UNO_QUERY );
+    return m_xZAxis;
 }
 
 // ____ XTwoAxisXSupplier ____
@@ -895,7 +895,7 @@ Reference< beans::XPropertySet > SAL_CALL 
DiagramWrapper::getSecondaryXAxis()
 {
     if( ! m_xSecondXAxis.is())
         m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, 
m_spChart2ModelContact );
-    return Reference< beans::XPropertySet >( m_xSecondXAxis, uno::UNO_QUERY );
+    return m_xSecondXAxis;
 }
 
 // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
@@ -912,7 +912,7 @@ Reference< beans::XPropertySet > SAL_CALL 
DiagramWrapper::getXAxis()
 {
     if( ! m_xXAxis.is())
         m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, 
m_spChart2ModelContact );
-    return Reference< beans::XPropertySet >( m_xXAxis, uno::UNO_QUERY );
+    return m_xXAxis;
 }
 
 Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid()
@@ -938,7 +938,7 @@ Reference< beans::XPropertySet > SAL_CALL 
DiagramWrapper::getSecondaryYAxis()
 {
     if( ! m_xSecondYAxis.is())
         m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, 
m_spChart2ModelContact );
-    return Reference< beans::XPropertySet >( m_xSecondYAxis, uno::UNO_QUERY );
+    return m_xSecondYAxis;
 }
 
 // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
@@ -955,7 +955,7 @@ Reference< beans::XPropertySet > SAL_CALL 
DiagramWrapper::getYAxis()
 {
     if( ! m_xYAxis.is())
         m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, 
m_spChart2ModelContact );
-    return Reference< beans::XPropertySet >( m_xYAxis, uno::UNO_QUERY );
+    return m_xYAxis;
 }
 
 Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid()
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
index 2e00c0941e58..99fdf7fa02d4 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
@@ -43,7 +43,10 @@ namespace chart { class Diagram; }
 
 namespace chart::wrapper
 {
-
+class AxisWrapper;
+class WallFloorWrapper;
+class MinMaxLineWrapper;
+class UpDownBarWrapper;
 class Chart2ModelContact;
 
 class DiagramWrapper : public cppu::ImplInheritanceHelper<
@@ -191,28 +194,16 @@ private:
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
     ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aEventListenerContainer;
 
-    css::uno::Reference<
-        css::chart::XAxis >        m_xXAxis;
-    css::uno::Reference<
-        css::chart::XAxis >        m_xYAxis;
-    css::uno::Reference<
-        css::chart::XAxis >        m_xZAxis;
-    css::uno::Reference<
-        css::chart::XAxis >        m_xSecondXAxis;
-    css::uno::Reference<
-        css::chart::XAxis >        m_xSecondYAxis;
-
-    css::uno::Reference<
-        css::beans::XPropertySet > m_xWall;
-    css::uno::Reference<
-        css::beans::XPropertySet > m_xFloor;
-
-    css::uno::Reference<
-        css::beans::XPropertySet > m_xMinMaxLineWrapper;
-    css::uno::Reference<
-        css::beans::XPropertySet > m_xUpBarWrapper;
-    css::uno::Reference<
-        css::beans::XPropertySet > m_xDownBarWrapper;
+    rtl::Reference< AxisWrapper >        m_xXAxis;
+    rtl::Reference< AxisWrapper >        m_xYAxis;
+    rtl::Reference< AxisWrapper >        m_xZAxis;
+    rtl::Reference< AxisWrapper >        m_xSecondXAxis;
+    rtl::Reference< AxisWrapper >        m_xSecondYAxis;
+    rtl::Reference< WallFloorWrapper > m_xWall;
+    rtl::Reference< WallFloorWrapper > m_xFloor;
+    rtl::Reference< MinMaxLineWrapper > m_xMinMaxLineWrapper;
+    rtl::Reference< UpDownBarWrapper > m_xUpBarWrapper;
+    rtl::Reference< UpDownBarWrapper > m_xDownBarWrapper;
 };
 
 } //  namespace chart::wrapper
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx 
b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
index 91a48258174d..03c551fcf52d 100644
--- a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
@@ -58,7 +58,6 @@ public:
     virtual css::uno::Any getReferenceSize() override;
     virtual css::awt::Size getCurrentSizeForReference() override;
 
-private:
     // ____ XShape ____
     virtual css::awt::Point SAL_CALL getPosition() override;
     virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) 
override;
@@ -95,6 +94,7 @@ private:
     virtual const css::uno::Sequence< css::beans::Property >& 
getPropertySequence() override;
     virtual std::vector< std::unique_ptr<WrappedProperty> > 
createWrappedProperties() override;
 
+private:
     css::uno::Reference< css::chart2::XTitle > getTitleObject();
 
     std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
diff --git a/chart2/source/controller/inc/ChartDocumentWrapper.hxx 
b/chart2/source/controller/inc/ChartDocumentWrapper.hxx
index 008296b6a358..e06c2db0353b 100644
--- a/chart2/source/controller/inc/ChartDocumentWrapper.hxx
+++ b/chart2/source/controller/inc/ChartDocumentWrapper.hxx
@@ -36,8 +36,9 @@ namespace chart { class ChartView; }
 
 namespace chart::wrapper
 {
-
 class DiagramWrapper;
+class LegendWrapper;
+class TitleWrapper;
 class Chart2ModelContact;
 
 class ChartDocumentWrapper_Base : public ::cppu::ImplInheritanceHelper
@@ -152,9 +153,9 @@ private: //member
 
     css::uno::Reference< css::uno::XInterface >   m_xDelegator;
 
-    css::uno::Reference< css::drawing::XShape >   m_xTitle;
-    css::uno::Reference< css::drawing::XShape >   m_xSubTitle;
-    css::uno::Reference< css::drawing::XShape >   m_xLegend;
+    rtl::Reference< TitleWrapper >   m_xTitle;
+    rtl::Reference< TitleWrapper >   m_xSubTitle;
+    rtl::Reference< LegendWrapper >   m_xLegend;
     css::uno::Reference< css::chart::XChartData > m_xChartData;
     rtl::Reference< DiagramWrapper >   m_xDiagram;
     css::uno::Reference< css::beans::XPropertySet > m_xArea;
diff --git a/chart2/source/view/diagram/VDiagram.cxx 
b/chart2/source/view/diagram/VDiagram.cxx
index 4a4ec0428dbc..df804f4c42ff 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -438,9 +438,10 @@ void VDiagram::createShapes_3d()
     rtl::Reference<SvxShapeGroupAnyD> xOuterGroup_Shapes = m_xOuterGroupShape;
 
     //create additional group to manipulate the aspect ratio of the whole 
diagram:
-    xOuterGroup_Shapes = ShapeFactory::createGroup3D( xOuterGroup_Shapes );
+    rtl::Reference<Svx3DSceneObject> xAdditionalGroup = 
ShapeFactory::createGroup3D( xOuterGroup_Shapes );
+    xOuterGroup_Shapes = xAdditionalGroup;
 
-    m_xAspectRatio3D = xOuterGroup_Shapes;
+    m_xAspectRatio3D = xAdditionalGroup;
 
     bool bAddFloorAndWall = m_xDiagram->isSupportingFloorAndWall();
 
diff --git a/chart2/source/view/inc/VDiagram.hxx 
b/chart2/source/view/inc/VDiagram.hxx
index ab391f7bc0d3..04f1a288317f 100644
--- a/chart2/source/view/inc/VDiagram.hxx
+++ b/chart2/source/view/inc/VDiagram.hxx
@@ -97,7 +97,7 @@ private: //members
     rtl::Reference< ::chart::Diagram > m_xDiagram;
 
     css::drawing::Direction3D                                  
m_aPreferredAspectRatio;
-    css::uno::Reference< css::beans::XPropertySet > m_xAspectRatio3D;
+    rtl::Reference< Svx3DSceneObject > m_xAspectRatio3D;
 
     double m_fXAnglePi;
     double m_fYAnglePi;
diff --git a/include/comphelper/types.hxx b/include/comphelper/types.hxx
index 203bbbe0235e..9e6a4eff0e5d 100644
--- a/include/comphelper/types.hxx
+++ b/include/comphelper/types.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
 
 namespace com::sun::star::awt {
     struct FontDescriptor;
@@ -49,6 +50,15 @@ namespace comphelper
             _rxComp = nullptr;
         }
     }
+    template <class TYPE>
+    void disposeComponent(rtl::Reference<TYPE>& _rxComp)
+    {
+        if (_rxComp.is())
+        {
+            _rxComp->dispose();
+            _rxComp = nullptr;
+        }
+    }
 
 
     /** get a css::awt::FontDescriptor that is fully initialized with
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index 763e70e210b3..589aa4250d8f 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -665,11 +665,10 @@ class UNLESS_MERGELIBS(SAL_DLLPUBLIC_RTTI) 
Svx3DSceneObject final : public SvxSh
 private:
     rtl::Reference< SvxDrawPage > mxPage;
 
-protected:
+public:
     using SvxShape::setPropertyValue;
     using SvxShape::getPropertyValue;
 
-public:
     UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) Svx3DSceneObject(SdrObject* pObj, 
SvxDrawPage* pDrawPage);
     // override these for special property handling in subcasses. Return true 
if property is handled
     virtual bool setPropertyValueImpl( const OUString& rName, const 
SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) override;

Reply via email to