From be27055b341c3f9877ee855f501a28f8b2b1dbcb Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 26 Jun 2026 10:34:52 +0200 Subject: [PATCH] tdf#172532 basprov: Use new concrete interfaces for optional methods Instead of using XInvocation and XPropertySet to expose the optional edit method, the BASIC script provider now uses the new concrete interface XEditableBrowseNode. Change-Id: I7a99a1c335f408da9b0ac26c741577eb449e63c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207348 Reviewed-by: Neil Roberts Tested-by: Jenkins --- scripting/source/basprov/basmethnode.cxx | 54 ++---------------------- scripting/source/basprov/basmethnode.hxx | 19 +++------ 2 files changed, 8 insertions(+), 65 deletions(-) diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx index 8a75b1e570b7..30e90c699ae9 100644 --- a/scripting/source/basprov/basmethnode.cxx +++ b/scripting/source/basprov/basmethnode.cxx @@ -42,10 +42,8 @@ using namespace ::com::sun::star::script; using namespace ::sf_misc; #define BASPROV_PROPERTY_ID_URI 1 -#define BASPROV_PROPERTY_ID_EDITABLE 2 constexpr OUStringLiteral BASPROV_PROPERTY_URI = u"URI"; -constexpr OUString BASPROV_PROPERTY_EDITABLE = u"Editable"_ustr; #define BASPROV_DEFAULT_ATTRIBS() PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY @@ -64,7 +62,6 @@ namespace basprov ,m_sScriptingContext(std::move( sScriptingContext )) ,m_pMethod( pMethod ) ,m_bIsAppScript( isAppScript ) - ,m_bEditable( true ) { if ( m_pMethod ) { @@ -90,7 +87,6 @@ namespace basprov } registerProperty( BASPROV_PROPERTY_URI, BASPROV_PROPERTY_ID_URI, BASPROV_DEFAULT_ATTRIBS(), &m_sURI, cppu::UnoType::get() ); - registerProperty( BASPROV_PROPERTY_EDITABLE, BASPROV_PROPERTY_ID_EDITABLE, BASPROV_DEFAULT_ATTRIBS(), &m_bEditable, cppu::UnoType::get() ); } @@ -143,25 +139,11 @@ namespace basprov } - // XInvocation + sal_Bool BasicMethodNodeImpl::isEditableNode( ) { return true; } - Reference< XIntrospectionAccess > BasicMethodNodeImpl::getIntrospection( ) + sal_Bool BasicMethodNodeImpl::editNode( ) { - return Reference< XIntrospectionAccess >(); - } - - - Any BasicMethodNodeImpl::invoke( const OUString& aFunctionName, const Sequence< Any >&, - Sequence< sal_Int16 >&, Sequence< Any >& ) - { - if ( aFunctionName != BASPROV_PROPERTY_EDITABLE ) - { - throw IllegalArgumentException( - u"BasicMethodNodeImpl::invoke: function name not supported!"_ustr, - Reference< XInterface >(), 1 ); - } - OUString sDocURL, sLibName, sModName; sal_uInt16 nLine1 = 0; @@ -220,37 +202,7 @@ namespace basprov } - return Any(); - } - - - void BasicMethodNodeImpl::setValue( const OUString&, const Any& ) - { - throw UnknownPropertyException( - u"BasicMethodNodeImpl::setValue: property name is unknown!"_ustr ); - } - - - Any BasicMethodNodeImpl::getValue( const OUString& ) - { - throw UnknownPropertyException( - u"BasicMethodNodeImpl::getValue: property name is unknown!"_ustr ); - } - - - sal_Bool BasicMethodNodeImpl::hasMethod( const OUString& aName ) - { - bool bReturn = false; - if ( aName == BASPROV_PROPERTY_EDITABLE ) - bReturn = true; - - return bReturn; - } - - - sal_Bool BasicMethodNodeImpl::hasProperty( const OUString& ) - { - return false; + return true; } diff --git a/scripting/source/basprov/basmethnode.hxx b/scripting/source/basprov/basmethnode.hxx index 1baa5904028f..065e68125c42 100644 --- a/scripting/source/basprov/basmethnode.hxx +++ b/scripting/source/basprov/basmethnode.hxx @@ -19,8 +19,8 @@ #pragma once -#include #include +#include #include #include @@ -35,7 +35,7 @@ namespace basprov : public comphelper::OPropertyContainerImplHelper< comphelper::WeakImplHelper< css::script::browse::XBrowseNode, - css::script::XInvocation>, + css::script::browse::XEditableBrowseNode>, BasicMethodNodeImpl> { private: @@ -46,7 +46,6 @@ namespace basprov // properties OUString m_sURI; - bool m_bEditable; protected: // OPropertyArrayUsageHelper @@ -64,17 +63,9 @@ namespace basprov virtual sal_Bool SAL_CALL hasChildNodes( ) override; virtual sal_Int16 SAL_CALL getType( ) override; - // XInvocation - virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) override; - virtual css::uno::Any SAL_CALL invoke( - const OUString& aFunctionName, - const css::uno::Sequence< css::uno::Any >& aParams, - css::uno::Sequence< sal_Int16 >& aOutParamIndex, - css::uno::Sequence< css::uno::Any >& aOutParam ) override; - virtual void SAL_CALL setValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; - virtual css::uno::Any SAL_CALL getValue( const OUString& aPropertyName ) override; - virtual sal_Bool SAL_CALL hasMethod( const OUString& aName ) override; - virtual sal_Bool SAL_CALL hasProperty( const OUString& aName ) override; + // XEditableBrowseNode + virtual sal_Bool SAL_CALL isEditableNode( ) override; + virtual sal_Bool SAL_CALL editNode( ) override; };