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 <nroberts@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Neil Roberts
2026-07-15 09:08:17 +02:00
parent b447e5d7b2
commit be27055b34
2 changed files with 8 additions and 65 deletions
+3 -51
View File
@@ -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<decltype(m_sURI)>::get() );
registerProperty( BASPROV_PROPERTY_EDITABLE, BASPROV_PROPERTY_ID_EDITABLE, BASPROV_DEFAULT_ATTRIBS(), &m_bEditable, cppu::UnoType<decltype(m_bEditable)>::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;
}
+5 -14
View File
@@ -19,8 +19,8 @@
#pragma once
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/script/browse/XBrowseNode.hpp>
#include <com/sun/star/script/browse/XEditableBrowseNode.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/propcontainerimplhelper.hxx>
@@ -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;
};