summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-21 09:40:04 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-21 12:50:17 +0000
commita97e2d2702d9a6f37775ccee2c08c4f3b2479c4b (patch)
treeebd1f3405a8bda00b2674c2d0afdd9e223dd1cd5 /sc
parent19dfdf86ad1f5b08041d8b7a9f196caf881231ab (diff)
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 <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/vba/vbapagebreaks.cxx20
1 files changed, 17 insertions, 3 deletions
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 );