chart2/inc/ChartView.hxx                                          |    6 -----
 chart2/source/controller/accessibility/AccessibleBase.cxx         |    8 
+++----
 chart2/source/controller/accessibility/AccessibleChartView.cxx    |    2 -
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx |   11 
++++------
 chart2/source/controller/inc/AccessibleBase.hxx                   |    3 +-
 chart2/source/inc/chartview/ExplicitValueProvider.hxx             |    5 +---
 chart2/source/view/main/ChartView.cxx                             |    6 -----
 chart2/source/view/main/ExplicitValueProvider.cxx                 |    6 -----
 svx/source/svdraw/charthelper.cxx                                 |    7 ++----
 9 files changed, 17 insertions(+), 37 deletions(-)

New commits:
commit 90d658d6d1054ac352e1b074a37b8963514a05f8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Jan 14 12:27:44 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jan 18 09:08:49 2023 +0000

    XUnoTunnel->dynamic_cast in ExplicitValueProvider
    
    Change-Id: I72b85a18d0a754f81a136fd79e56789aa926f425
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145617
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 5f0665877e3d..d0f64d047b05 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -30,7 +30,6 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/qa/XDumper.hpp>
 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
 #include <com/sun/star/util/XModifyListener.hpp>
@@ -86,7 +85,6 @@ class OOO_DLLPUBLIC_CHARTVIEW ChartView final : public 
::cppu::WeakImplHelper<
     css::lang::XInitialization
         ,css::lang::XServiceInfo
         ,css::datatransfer::XTransferable
-        ,css::lang::XUnoTunnel
         ,css::util::XModifyListener
         ,css::util::XModeChangeBroadcaster
         ,css::util::XUpdatable2
@@ -173,10 +171,6 @@ public:
         const OUString& ServiceSpecifier, const css::uno::Sequence< 
css::uno::Any >& Arguments ) override;
     virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() 
override;
 
-    // for ExplicitValueProvider
-    // ____ XUnoTunnel ___
-    virtual ::sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
::sal_Int8 >& aIdentifier ) override;
-
     // XDumper
     virtual OUString SAL_CALL dump(OUString const & kind) override;
 
diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx 
b/chart2/source/controller/accessibility/AccessibleBase.cxx
index 5ba72c5dbec6..b7ae9a67ebe0 100644
--- a/chart2/source/controller/accessibility/AccessibleBase.cxx
+++ b/chart2/source/controller/accessibility/AccessibleBase.cxx
@@ -21,6 +21,7 @@
 #include "AccessibleChartShape.hxx"
 #include <ObjectHierarchy.hxx>
 #include <ObjectIdentifier.hxx>
+#include <ChartView.hxx>
 #include <chartview/ExplicitValueProvider.hxx>
 
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
@@ -612,12 +613,11 @@ Reference< XAccessible > SAL_CALL 
AccessibleBase::getAccessibleAtPoint( const aw
 
 awt::Rectangle SAL_CALL AccessibleBase::getBounds()
 {
-    ExplicitValueProvider *pExplicitValueProvider(
-        comphelper::getFromUnoTunnel<ExplicitValueProvider>( 
m_aAccInfo.m_xView ));
-    if( pExplicitValueProvider )
+    rtl::Reference<ChartView> pChartView = m_aAccInfo.m_xView.get();
+    if( pChartView )
     {
         VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( 
m_aAccInfo.m_xWindow ));
-        awt::Rectangle aLogicRect( 
pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aOID.getObjectCID() 
));
+        awt::Rectangle aLogicRect( pChartView->getRectangleOfObject( 
m_aAccInfo.m_aOID.getObjectCID() ));
         if( pWindow )
         {
             tools::Rectangle aRect( aLogicRect.X, aLogicRect.Y,
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx 
b/chart2/source/controller/accessibility/AccessibleChartView.cxx
index 8e35e05706ac..1f23976d44e5 100644
--- a/chart2/source/controller/accessibility/AccessibleChartView.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx
@@ -303,7 +303,7 @@ void SAL_CALL AccessibleChartView::initialize( const 
Sequence< Any >& rArguments
         MutexGuard aGuard( m_aMutex);
         if( xChartModel.is())
             m_spObjectHierarchy =
-                std::make_shared<ObjectHierarchy>( xChartModel, 
comphelper::getFromUnoTunnel<ExplicitValueProvider>(m_xChartView) );
+                std::make_shared<ObjectHierarchy>( xChartModel, 
m_xChartView.get().get() );
         else
             m_spObjectHierarchy.reset();
     }
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 7b911fbd3820..51f066c3ba3e 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -1045,11 +1045,10 @@ rtl::Reference<SvxDrawPage> 
ChartDocumentWrapper::impl_getDrawPage() const
 
 namespace {
 
-uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const 
uno::Reference<uno::XInterface>& xChartView)
+uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const 
rtl::Reference<ChartView>& xChartView)
 {
-    auto pProvider = 
comphelper::getFromUnoTunnel<ExplicitValueProvider>(xChartView);
-    if( pProvider )
-        return pProvider->getDrawModelWrapper()->getShapeFactory();
+    if( xChartView )
+        return xChartView->getDrawModelWrapper()->getShapeFactory();
 
     return uno::Reference< lang::XMultiServiceFactory >();
 }
@@ -1257,7 +1256,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
         {
             if( !m_xShapeFactory.is() && m_xChartView.is() )
             {
-                m_xShapeFactory = getShapeFactory( 
static_cast<cppu::OWeakObject*>(m_xChartView.get()) );
+                m_xShapeFactory = getShapeFactory( m_xChartView );
             }
             else
             {
@@ -1265,7 +1264,7 @@ uno::Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::createInstance(
                 if(pModel)
                 {
                     m_xChartView = pModel->getChartView();
-                    m_xShapeFactory = getShapeFactory( 
static_cast<cppu::OWeakObject*>(m_xChartView.get()) );
+                    m_xShapeFactory = getShapeFactory( m_xChartView );
                 }
             }
 
diff --git a/chart2/source/controller/inc/AccessibleBase.hxx 
b/chart2/source/controller/inc/AccessibleBase.hxx
index 58e122e8a2d2..6c1bc93b326f 100644
--- a/chart2/source/controller/inc/AccessibleBase.hxx
+++ b/chart2/source/controller/inc/AccessibleBase.hxx
@@ -53,6 +53,7 @@ namespace chart
 {
 
 class AccessibleBase;
+class ChartView;
 class ObjectHierarchy;
 
 typedef ObjectIdentifier AccessibleUniqueId;
@@ -63,7 +64,7 @@ struct AccessibleElementInfo
 
     unotools::WeakReference< ::chart::ChartModel > m_xChartDocument;
     css::uno::WeakReference< css::view::XSelectionSupplier > 
m_xSelectionSupplier;
-    css::uno::WeakReference< css::uno::XInterface >   m_xView;
+    unotools::WeakReference< ::chart::ChartView >   m_xView;
     css::uno::WeakReference< css::awt::XWindow >      m_xWindow;
 
     std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy;
diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx 
b/chart2/source/inc/chartview/ExplicitValueProvider.hxx
index d97de84586a1..35b2dd15fa4c 100644
--- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx
+++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx
@@ -18,6 +18,7 @@
  */
 #pragma once
 
+#include <sal/types.h>
 #include <chartview/chartviewdllapi.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/ustring.hxx>
@@ -47,7 +48,7 @@ class ChartModel;
 struct ExplicitIncrementData;
 struct ExplicitScaleData;
 
-class OOO_DLLPUBLIC_CHARTVIEW ExplicitValueProvider
+class OOO_DLLPUBLIC_CHARTVIEW SAL_LOPLUGIN_ANNOTATE("crosscast") 
ExplicitValueProvider
 {
 public:
     /** Gives calculated scale and increment values for a given xAxis in the 
current view.
@@ -72,8 +73,6 @@ public:
 
     virtual std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() = 0;
 
-    static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
-
     static css::awt::Rectangle
         AddSubtractAxisTitleSizes(
                 ChartModel& rModel
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 37d237e7ee7a..da37dd659f9e 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -308,12 +308,6 @@ sal_Bool SAL_CALL ChartView::isDataFlavorSupported( const 
datatransfer::DataFlav
              aFlavor.MimeType == lcl_aGDIMetaFileMIMETypeHighContrast );
 }
 
-// ____ XUnoTunnel ___
-::sal_Int64 SAL_CALL ChartView::getSomething( const uno::Sequence< ::sal_Int8 
>& aIdentifier )
-{
-    return comphelper::getSomethingImpl<ExplicitValueProvider>(aIdentifier, 
this);
-}
-
 // lang::XServiceInfo
 
 OUString SAL_CALL ChartView::getImplementationName()
diff --git a/chart2/source/view/main/ExplicitValueProvider.cxx 
b/chart2/source/view/main/ExplicitValueProvider.cxx
index 4b07b8d6659e..fc1307fe8820 100644
--- a/chart2/source/view/main/ExplicitValueProvider.cxx
+++ b/chart2/source/view/main/ExplicitValueProvider.cxx
@@ -77,12 +77,6 @@ sal_Int32 
ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
         true /*bSearchForParallelAxisIfNothingIsFound*/);
 }
 
-const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId()
-{
-    static const comphelper::UnoIdInit theExplicitValueProviderUnoTunnelId;
-    return theExplicitValueProviderUnoTunnelId.getSeq();
-}
-
 sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
     const uno::Reference<beans::XPropertySet>& xSeriesOrPointProp)
 {
diff --git a/svx/source/svdraw/charthelper.cxx 
b/svx/source/svdraw/charthelper.cxx
index c8ddd987f265..4a50b07783ab 100644
--- a/svx/source/svdraw/charthelper.cxx
+++ b/svx/source/svdraw/charthelper.cxx
@@ -40,14 +40,13 @@ void ChartHelper::updateChart( const uno::Reference< 
::frame::XModel >& rXModel
     try
     {
         const uno::Reference< lang::XMultiServiceFactory > xChartFact(rXModel, 
uno::UNO_QUERY_THROW);
-        const uno::Reference< lang::XUnoTunnel > 
xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), 
uno::UNO_QUERY_THROW);
-        const uno::Reference<util::XUpdatable2> xUpdatable(xChartView, 
uno::UNO_QUERY_THROW);
+        const uno::Reference< util::XUpdatable2 > 
xChartView(xChartFact->createInstance("com.sun.star.chart2.ChartView"), 
uno::UNO_QUERY_THROW);
 
-        xUpdatable->updateHard();
+        xChartView->updateHard();
     }
     catch(uno::Exception&)
     {
-        OSL_ENSURE(false, "Unexpected exception!");
+        TOOLS_WARN_EXCEPTION("svx", "");
     }
 }
 

Reply via email to