summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-20 18:50:07 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-21 06:42:34 +0000
commit5e5f40a4a92a31b0932c690219d002fcf18598cf (patch)
tree17f4dfe07d07154f9f1bead242bf880e024fc04e
parent27b35b2c215b4832d4378ec3a7ecbba926552d06 (diff)
loplugin:unocast (ScVbaShapes)
(See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I913565ccd93472f2a8893c4251e80d0309827c34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144633 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--include/vbahelper/vbashapes.hxx6
-rw-r--r--vbahelper/source/vbahelper/vbashapes.cxx12
2 files changed, 16 insertions, 2 deletions
diff --git a/include/vbahelper/vbashapes.hxx b/include/vbahelper/vbashapes.hxx
index 7131d8118031..fabacae0732c 100644
--- a/include/vbahelper/vbashapes.hxx
+++ b/include/vbahelper/vbashapes.hxx
@@ -23,6 +23,7 @@
#include <string_view>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
@@ -50,7 +51,7 @@ namespace ooo::vba {
namespace msforms { class XShapeRange; }
}
-typedef CollTestImplHelper< ov::msforms::XShapes > ScVbaShapes_BASE;
+typedef CollTestImplHelper< ov::msforms::XShapes, css::lang::XUnoTunnel > ScVbaShapes_BASE;
class VBAHELPER_DLLPUBLIC ScVbaShapes final : public ScVbaShapes_BASE
{
@@ -85,6 +86,9 @@ public:
virtual css::uno::Type SAL_CALL getElementType() override;
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+ static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
+
virtual void SAL_CALL SelectAll() override;
//helper::calc
virtual css::uno::Any SAL_CALL AddLine( sal_Int32 StartX, sal_Int32 StartY, sal_Int32 endX, sal_Int32 endY ) override;
diff --git a/vbahelper/source/vbahelper/vbashapes.cxx b/vbahelper/source/vbahelper/vbashapes.cxx
index 02630a75c520..a61fbddfb350 100644
--- a/vbahelper/source/vbahelper/vbashapes.cxx
+++ b/vbahelper/source/vbahelper/vbashapes.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/drawing/XShapes.hpp>
#include <utility>
+#include <comphelper/servicehelper.hxx>
#include <vbahelper/vbahelper.hxx>
#include <vbahelper/vbashape.hxx>
#include <vbahelper/vbashapes.hxx>
@@ -63,7 +64,7 @@ public:
}
virtual uno::Any SAL_CALL nextElement( ) override
{
- ScVbaShapes* pShapes = dynamic_cast< ScVbaShapes* >(m_xParent.get());
+ ScVbaShapes* pShapes = comphelper::getFromUnoTunnel< ScVbaShapes >(m_xParent);
if ( pShapes && hasMoreElements() )
return pShapes->createCollectionObject( m_xIndexAccess->getByIndex( nIndex++ ) );
throw container::NoSuchElementException();
@@ -101,6 +102,15 @@ ScVbaShapes::createEnumeration()
return new VbShapeEnumHelper( this, m_xIndexAccess );
}
+sal_Int64 ScVbaShapes::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(aIdentifier, this);
+}
+
+css::uno::Sequence<sal_Int8> const & ScVbaShapes::getUnoTunnelId() {
+ static comphelper::UnoIdInit const id;
+ return id.getSeq();
+}
+
uno::Any
ScVbaShapes::createCollectionObject( const css::uno::Any& aSource )
{