basic/source/sbx/sbxexec.cxx | 16 +++++----------- include/basic/sbmod.hxx | 3 ++- include/basic/sbxobj.hxx | 5 ++--- 3 files changed, 9 insertions(+), 15 deletions(-)
New commits: commit bc86ef1e0ec2801d8fead9b98cbe8d4129f3e244 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Feb 21 08:00:26 2023 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Mon Feb 27 07:21:02 2023 +0000 Related: tdf#153752 Use virtual method to avoid dynamic casts Change-Id: I97c09d82699621d5a43a525b5f2cf75ff5d131c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147353 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147752 Tested-by: Tor Lillqvist <t...@collabora.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx index de711944d36c..af7d12c00651 100644 --- a/basic/source/sbx/sbxexec.cxx +++ b/basic/source/sbx/sbxexec.cxx @@ -19,7 +19,6 @@ #include <sal/config.h> -#include <basic/sbmod.hxx> #include <basic/sbx.hxx> #include <basic/sberrors.hxx> #include <rtl/character.hxx> @@ -350,7 +349,7 @@ SbxVariable* SbxObject::Execute( const OUString& rTxt ) { SetError( ERRCODE_BASIC_SYNTAX ); break; } - pVar = Assign( this, this, &p, IsModuleCompatible() ); + pVar = Assign( this, this, &p, IsOptionCompatible() ); if( !pVar.is() ) { break; @@ -373,7 +372,7 @@ SbxVariable* SbxObject::FindQualified( const OUString& rName, SbxClassType t ) { return nullptr; } - pVar = QualifiedName( this, this, &p, t, IsModuleCompatible() ); + pVar = QualifiedName( this, this, &p, t, IsOptionCompatible() ); p = SkipWhitespace( p ); if( *p ) { @@ -382,15 +381,10 @@ SbxVariable* SbxObject::FindQualified( const OUString& rName, SbxClassType t ) return pVar.get(); } -bool SbxObject::IsModuleCompatible() const +bool SbxObject::IsOptionCompatible() const { - const SbxObject* pObj = this; - while (pObj) - { - if (auto pMod = dynamic_cast<const SbModule*>(pObj)) - return pMod->IsCompatible(); - pObj = pObj->GetParent(); - } + if (const SbxObject* pObj = GetParent()) + return pObj->IsOptionCompatible(); return false; } diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index fac7f9e50121..7ca52276d012 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -94,6 +94,8 @@ protected: SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; SAL_DLLPRIVATE void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint ); virtual ~SbModule() override; + bool IsOptionCompatible() const override { return mbCompat; } + public: SBX_DECL_PERSIST_NODATA(SBXID_BASICMOD,2); SbModule( const OUString&, bool bVBASupport = false ); @@ -123,7 +125,6 @@ public: SAL_DLLPRIVATE bool HasExeCode(); bool IsVBASupport() const { return mbVBASupport; } SAL_DLLPRIVATE void SetVBASupport( bool bSupport ); - bool IsCompatible() const { return mbCompat; } sal_Int32 GetModuleType() const { return mnType; } void SetModuleType( sal_Int32 nType ) { mnType = nType; } bool isProxyModule() const { return bIsProxyModule; } diff --git a/include/basic/sbxobj.hxx b/include/basic/sbxobj.hxx index 34c117d33853..33ffc98c77d9 100644 --- a/include/basic/sbxobj.hxx +++ b/include/basic/sbxobj.hxx @@ -41,6 +41,8 @@ protected: virtual bool StoreData( SvStream& ) const override; virtual ~SbxObject() override; virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + virtual bool IsOptionCompatible() const; // Module's Option Compatible + public: SBX_DECL_PERSIST_NODATA(SBXID_OBJECT,1); SbxObject( const OUString& rClassname ); @@ -78,9 +80,6 @@ public: SbxArray* GetObjects() { return pObjs.get(); } // Debugging void Dump( SvStream&, bool bDumpAll ); - -private: - bool IsModuleCompatible() const; // Module's Option Compatible }; #endif // INCLUDED_BASIC_SBXOBJ_HXX