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 <sbergman@redhat.com>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user