sc/source/ui/vba/vbapagebreaks.cxx |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit a97e2d2702d9a6f37775ccee2c08c4f3b2479c4b
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Dec 21 09:40:04 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Dec 21 12:50:17 2022 +0000

    loplugin:unocast (RangePageBreaks)
    
    (See the upcoming commit introducing that loplugin:unocast on why such
    dynamic_casts from UNO types are dangerous.)
    
    Change-Id: I16297c96e60d76a15b59aedc4e88164bb782c61e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144652
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/sc/source/ui/vba/vbapagebreaks.cxx 
b/sc/source/ui/vba/vbapagebreaks.cxx
index b9a0235c34f3..ea89c79819d3 100644
--- a/sc/source/ui/vba/vbapagebreaks.cxx
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -22,9 +22,11 @@
 #include <cppuhelper/implbase.hxx>
 #include <ooo/vba/excel/XWorksheet.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/sheet/XSheetPageBreak.hpp>
 #include <com/sun/star/table/XColumnRowRange.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/servicehelper.hxx>
 #include <utility>
 
 using namespace ::com::sun::star;
@@ -32,7 +34,8 @@ using namespace ::ooo::vba;
 
 namespace {
 
-class RangePageBreaks : public ::cppu::WeakImplHelper<container::XIndexAccess >
+class RangePageBreaks :
+    public ::cppu::WeakImplHelper<container::XIndexAccess, 
css::lang::XUnoTunnel >
 {
 private:
     uno::Reference< XHelperInterface > mxParent;
@@ -103,6 +106,15 @@ public:
     {
         return true;
     }
+
+    sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & 
aIdentifier) override {
+        return comphelper::getSomethingImpl(aIdentifier, this);
+    }
+
+    static css::uno::Sequence<sal_Int8> const & getUnoTunnelId() {
+        static comphelper::UnoIdInit const id;
+        return id.getSeq();
+    }
 };
 
 }
@@ -221,7 +233,8 @@ ScVbaHPageBreaks::ScVbaHPageBreaks( const uno::Reference< 
XHelperInterface >& xP
 
 uno::Any SAL_CALL ScVbaHPageBreaks::Add( const uno::Any& Before)
 {
-    RangePageBreaks* pPageBreaks = dynamic_cast< RangePageBreaks* >( 
m_xIndexAccess.get() );
+    RangePageBreaks* pPageBreaks
+        = comphelper::getFromUnoTunnel< RangePageBreaks >( m_xIndexAccess );
     if( pPageBreaks )
     {
         return pPageBreaks->Add( Before );
@@ -278,7 +291,8 @@ ScVbaVPageBreaks::~ScVbaVPageBreaks()
 uno::Any SAL_CALL
 ScVbaVPageBreaks::Add( const uno::Any& Before )
 {
-    RangePageBreaks* pPageBreaks = dynamic_cast< RangePageBreaks* >( 
m_xIndexAccess.get() );
+    RangePageBreaks* pPageBreaks
+        = comphelper::getFromUnoTunnel< RangePageBreaks >( m_xIndexAccess );
     if( pPageBreaks )
     {
         return pPageBreaks->Add( Before );

Reply via email to