include/vbahelper/vbashaperange.hxx | 7 ++++++- include/vbahelper/vbashapes.hxx | 6 +++++- vbahelper/source/vbahelper/vbashaperange.cxx | 12 +++++++++++- vbahelper/source/vbahelper/vbashapes.cxx | 12 +++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-)
New commits: commit 5e5f40a4a92a31b0932c690219d002fcf18598cf Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 20 18:50:07 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 21 06:42:34 2022 +0000 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 <sberg...@redhat.com> 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 ) { commit 27b35b2c215b4832d4378ec3a7ecbba926552d06 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 20 18:56:34 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 21 06:42:22 2022 +0000 loplugin:unocast (ScVbaShapeRange) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I4a66df07f2e768ee3203b730b50be4b9ec6a01a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144634 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/vbahelper/vbashaperange.hxx b/include/vbahelper/vbashaperange.hxx index dfcca6c82549..a814de1afba1 100644 --- a/include/vbahelper/vbashaperange.hxx +++ b/include/vbahelper/vbashaperange.hxx @@ -21,6 +21,7 @@ #include <exception> +#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> @@ -49,7 +50,7 @@ namespace ooo::vba { namespace msforms { class XShape; } } -typedef CollTestImplHelper< ov::msforms::XShapeRange > ScVbaShapeRange_BASE; +typedef CollTestImplHelper< ov::msforms::XShapeRange, css::lang::XUnoTunnel > ScVbaShapeRange_BASE; class VBAHELPER_DLLPUBLIC ScVbaShapeRange final : public ScVbaShapeRange_BASE { @@ -96,6 +97,10 @@ public: //XEnumerationAccess 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(); + // ScVbaCollectionBaseImpl virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override; }; diff --git a/vbahelper/source/vbahelper/vbashaperange.cxx b/vbahelper/source/vbahelper/vbashaperange.cxx index 4dd837259bf7..53d9d4268401 100644 --- a/vbahelper/source/vbahelper/vbashaperange.cxx +++ b/vbahelper/source/vbahelper/vbashaperange.cxx @@ -24,6 +24,7 @@ #include <ooo/vba/office/MsoShapeType.hpp> #include <utility> +#include <comphelper/servicehelper.hxx> #include <vbahelper/vbashaperange.hxx> #include <vbahelper/vbashape.hxx> using namespace ::ooo::vba; @@ -44,7 +45,7 @@ public: } virtual uno::Any SAL_CALL nextElement( ) override { - ScVbaShapeRange* pCollectionImpl = dynamic_cast< ScVbaShapeRange* >(m_xParent.get()); + ScVbaShapeRange* pCollectionImpl = comphelper::getFromUnoTunnel< ScVbaShapeRange >(m_xParent); if ( pCollectionImpl && hasMoreElements() ) return pCollectionImpl->createCollectionObject( m_xIndexAccess->getByIndex( nIndex++ ) ); throw container::NoSuchElementException(); @@ -391,6 +392,15 @@ ScVbaShapeRange::createEnumeration() return new VbShapeRangeEnumHelper( this, m_xIndexAccess ); } +sal_Int64 ScVbaShapeRange::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const & ScVbaShapeRange::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + uno::Any ScVbaShapeRange:: createCollectionObject( const css::uno::Any& aSource ) {