summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-29 10:00:35 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-30 22:04:01 +0200
commit22ba855d1a2317361c6ad8b631ae1bd707887435 (patch)
treeddbacfd89b4f6ed6696f773bc1a4f1d0395b74d9 /scripting
parentf528fff9b58e95ed572b226c0fec29f9a0464725 (diff)
Prepare for removal of non-const operator[] from Sequence in scripting
Change-Id: Ia85fe6de38674c7982b0f983a798a4d99ec1fb70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124384 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/basmethnode.cxx20
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx2
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx16
-rw-r--r--scripting/source/protocolhandler/scripthandler.cxx6
-rw-r--r--scripting/source/provider/ActiveMSPList.cxx7
-rw-r--r--scripting/source/provider/BrowseNodeFactoryImpl.cxx12
-rw-r--r--scripting/source/provider/MasterScriptProvider.cxx12
-rw-r--r--scripting/source/provider/ProviderCache.cxx5
-rw-r--r--scripting/source/vbaevents/eventhelper.cxx28
9 files changed, 49 insertions, 59 deletions
diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx
index 688b4ef2140f..fca2cafe8d72 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
+
+#include <comphelper/propertyvalue.hxx>
#include <vcl/svapp.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmeth.hxx>
@@ -237,17 +239,13 @@ namespace basprov
{
Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create( m_xContext ) );
- Sequence < PropertyValue > aArgs(7);
- aArgs[0].Name = "Document";
- aArgs[0].Value <<= sDocURL;
- aArgs[1].Name = "LibName";
- aArgs[1].Value <<= sLibName;
- aArgs[2].Name = "Name";
- aArgs[2].Value <<= sModName;
- aArgs[3].Name = "Type";
- aArgs[3].Value <<= OUString("Module");
- aArgs[4].Name = "Line";
- aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 );
+ Sequence < PropertyValue > aArgs{
+ comphelper::makePropertyValue("Document", sDocURL),
+ comphelper::makePropertyValue("LibName", sLibName),
+ comphelper::makePropertyValue("Name", sModName),
+ comphelper::makePropertyValue("Type", OUString("Module")),
+ comphelper::makePropertyValue("Line", static_cast< sal_uInt32 >( nLine1 ))
+ };
xHelper->executeDispatch( xProv, ".uno:BasicIDEAppear", OUString(), 0, aArgs );
}
}
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 43b5851c225a..704518e07aef 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -113,7 +113,7 @@ namespace dlgprov
Sequence< Any > args(1);
if ( xSMgr.is() )
{
- args[0] <<= xModel;
+ args.getArray()[0] <<= xModel;
mxListener.set( xSMgr->createInstanceWithArgumentsAndContext( "ooo.vba.EventListener", args, m_xContext ), UNO_QUERY );
}
if ( !rxControl.is() )
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index d52660904471..5a4e5c7eb124 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -71,15 +71,15 @@ namespace dlgprov
OUString aDlgLocation = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
css::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
- Sequence<Any> aArgs( 6 );
- aArgs[0] <<= aDlgLocation;
- aArgs[1] <<= true; // bReadOnly
- aArgs[2] <<= aLocale;
- aArgs[3] <<= aDlgName;
- aArgs[4] <<= OUString();
-
Reference< task::XInteractionHandler > xDummyHandler;
- aArgs[5] <<= xDummyHandler;
+
+ Sequence<Any> aArgs{ Any(aDlgLocation),
+ Any(true), // bReadOnly
+ Any(aLocale),
+ Any(aDlgName),
+ Any(OUString()),
+ Any(xDummyHandler) };
+
Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_SET_THROW );
// TODO: Ctor
Reference< resource::XStringResourceManager > xStringResourceManager( xSMgr_->createInstanceWithContext
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index db9d746c81be..0ef2fdad21db 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -176,8 +176,8 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
"ScriptProtocolHandler::dispatchWithNotification: validate xFunc - unable to obtain XScript interface" );
- Sequence< Any > inArgs( 0 );
- Sequence< Any > outArgs( 0 );
+ Sequence< Any > inArgs;
+ Sequence< Any > outArgs;
Sequence< sal_Int16 > outIndex;
if ( lArgs.hasElements() )
@@ -194,7 +194,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
rArg.Name.isEmpty() ) //TODO:???
{
inArgs.realloc( ++argCount );
- inArgs[ argCount - 1 ] = rArg.Value;
+ inArgs.getArray()[ argCount - 1 ] = rArg.Value;
}
}
}
diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx
index 35d50dea1b67..85ff36fb1b86 100644
--- a/scripting/source/provider/ActiveMSPList.cxx
+++ b/scripting/source/provider/ActiveMSPList.cxx
@@ -275,19 +275,18 @@ ActiveMSPList::createNonDocMSPs()
{
// do creation of user and share MSPs here
OUString serviceName("com.sun.star.script.provider.MasterScriptProvider");
- Sequence< Any > args(1);
- args[ 0 ] <<= userDirString;
+ Sequence< Any > args{ Any(userDirString) };
Reference< provider::XScriptProvider > userMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
// should check if provider reference is valid
m_hMsps[ userDirString ] = userMsp;
- args[ 0 ] <<= shareDirString;
+ args = { Any(shareDirString) };
Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
// should check if provider reference is valid
m_hMsps[ shareDirString ] = shareMsp;
- args[ 0 ] <<= bundledDirString;
+ args = { Any(bundledDirString) };
Reference< provider::XScriptProvider > bundledMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
// should check if provider reference is valid
m_hMsps[ bundledDirString ] = bundledMsp;
diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
index 6caa71c406b6..15055eb8514c 100644
--- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx
+++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
@@ -182,11 +182,12 @@ public:
}
Sequence< Reference< browse::XBrowseNode > > children( m_hBNA->size() );
+ auto childrenRange = asNonConstRange(children);
sal_Int32 index = 0;
for ( const auto& str : m_vStr )
{
- children[ index ].set( m_hBNA->find( str )->second );
+ childrenRange[ index ].set( m_hBNA->find( str )->second );
++index;
}
@@ -404,10 +405,11 @@ public:
::std::sort( aVNodes.begin(), aVNodes.end(), alphaSortForBNodes() );
Sequence < Reference< browse::XBrowseNode > > children( aVNodes.size() );
+ auto childrenRange = asNonConstRange(children);
sal_Int32 i = 0;
for ( const auto& rxNode : aVNodes )
{
- children[ i ].set( rxNode );
+ childrenRange[ i ].set( rxNode );
i++;
}
return children;
@@ -495,10 +497,11 @@ public:
// no need to sort user, share, doc1...docN
//::std::sort( m_vNodes.begin(), m_vNodes.end(), alphaSortForBNodes() );
Sequence < Reference< browse::XBrowseNode > > children( m_vNodes.size() );
+ auto childrenRange = asNonConstRange(children);
sal_Int32 i = 0;
for ( const auto& rxNode : m_vNodes )
{
- children[ i ].set( rxNode );
+ childrenRange[ i ].set( rxNode );
i++;
}
return children;
@@ -553,10 +556,11 @@ public:
Sequence< Reference< browse::XBrowseNode > > children(
locnBNs.size() );
+ auto childrenRange = asNonConstRange(children);
for ( size_t j = 0; j < locnBNs.size(); j++ )
{
- children[j] = new LocationBrowseNode( locnBNs[j] );
+ childrenRange[j] = new LocationBrowseNode( locnBNs[j] );
}
return children;
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 57cc596a7878..c30a290a0c64 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -97,13 +97,14 @@ void SAL_CALL MasterScriptProvider::initialize( const Sequence < Any >& args )
if ( len != 0 )
{
+ auto pinvokeArgs = invokeArgs.getArray();
// check if first parameter is a string
// if it is, this implies that this is a MSP created
// with a user or share ctx ( used for browse functionality )
if ( args[ 0 ] >>= m_sCtxString )
{
- invokeArgs[ 0 ] = args[ 0 ];
+ pinvokeArgs[ 0 ] = args[ 0 ];
if ( m_sCtxString.startsWith( "vnd.sun.star.tdoc" ) )
{
m_xModel = MiscUtils::tDocUrlToModel( m_sCtxString );
@@ -152,9 +153,9 @@ void SAL_CALL MasterScriptProvider::initialize( const Sequence < Any >& args )
}
if ( m_xInvocationContext.is() && m_xInvocationContext != m_xModel )
- invokeArgs[ 0 ] <<= m_xInvocationContext;
+ pinvokeArgs[ 0 ] <<= m_xInvocationContext;
else
- invokeArgs[ 0 ] <<= m_sCtxString;
+ pinvokeArgs[ 0 ] <<= m_sCtxString;
}
OUString pkgSpec = "uno_packages";
@@ -395,15 +396,16 @@ MasterScriptProvider::getChildNodes()
size++;
}
Sequence< Reference< browse::XBrowseNode > > children( size );
+ auto childrenRange = asNonConstRange(children);
sal_Int32 provIndex = 0;
for ( ; provIndex < providers.getLength(); provIndex++ )
{
- children[ provIndex ].set( providers[ provIndex ], UNO_QUERY );
+ childrenRange[ provIndex ].set( providers[ provIndex ], UNO_QUERY );
}
if ( hasPkgs )
{
- children[ provIndex ].set( m_xMSPPkg, UNO_QUERY );
+ childrenRange[ provIndex ].set( m_xMSPPkg, UNO_QUERY );
}
diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx
index be134725635e..8533fc384ed6 100644
--- a/scripting/source/provider/ProviderCache.cxx
+++ b/scripting/source/provider/ProviderCache.cxx
@@ -91,13 +91,14 @@ ProviderCache::getAllProviders()
// should assert if size !> 0
if ( !m_hProviderDetailsCache.empty() )
{
+ auto pproviders = providers.getArray();
sal_Int32 providerIndex = 0;
for (auto& rDetail : m_hProviderDetailsCache)
{
Reference<provider::XScriptProvider> xScriptProvider = rDetail.second.provider;
if ( xScriptProvider.is() )
{
- providers[ providerIndex++ ] = xScriptProvider;
+ pproviders[ providerIndex++ ] = xScriptProvider;
}
else
{
@@ -105,7 +106,7 @@ ProviderCache::getAllProviders()
try
{
xScriptProvider = createProvider(rDetail.second);
- providers[ providerIndex++ ] = xScriptProvider;
+ pproviders[ providerIndex++ ] = xScriptProvider;
}
catch ( const Exception& )
{
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 9bc86023c2e8..d89cce2a36a1 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -102,56 +102,42 @@ static Sequence< Any > ooMouseEvtToVBADblClick( const Sequence< Any >& params )
static Sequence< Any > ooMouseEvtToVBAMouseEvt( const Sequence< Any >& params )
{
- Sequence< Any > translatedParams;
awt::MouseEvent evt;
if ( !isMouseEventOk(evt, params) )
return Sequence< Any >();
- translatedParams.realloc(4);
-
- // Buttons
- translatedParams[ 0 ] <<= evt.Buttons;
- // Shift
- translatedParams[ 1 ] <<= evt.Modifiers;
- // X
- translatedParams[ 2 ] <<= evt.X;
- // Y
- translatedParams[ 3 ] <<= evt.Y;
+ Sequence< Any > translatedParams{ Any(evt.Buttons), // Buttons
+ Any(evt.Modifiers), // Shift
+ Any(evt.X), // X
+ Any(evt.Y) }; // Y
return translatedParams;
}
static Sequence< Any > ooKeyPressedToVBAKeyPressed( const Sequence< Any >& params )
{
- Sequence< Any > translatedParams;
awt::KeyEvent evt;
if ( !isKeyEventOk( evt, params ) )
return Sequence< Any >();
- translatedParams.realloc(1);
-
Reference< msforms::XReturnInteger> xKeyCode = new ReturnInteger( sal_Int32( evt.KeyCode ) );
- translatedParams[0] <<= xKeyCode;
+ Sequence< Any > translatedParams{ Any(xKeyCode) };
return translatedParams;
}
static Sequence< Any > ooKeyPressedToVBAKeyUpDown( const Sequence< Any >& params )
{
- Sequence< Any > translatedParams;
awt::KeyEvent evt;
if ( !isKeyEventOk( evt, params ) )
return Sequence< Any >();
- translatedParams.realloc(2);
-
Reference< msforms::XReturnInteger> xKeyCode = new ReturnInteger( evt.KeyCode );
sal_Int8 shift = sal::static_int_cast<sal_Int8>( evt.Modifiers );
// #TODO check whether values from OOO conform to values generated from vba
- translatedParams[0] <<= xKeyCode;
- translatedParams[1] <<= shift;
+ Sequence< Any > translatedParams{ Any(xKeyCode), Any(shift) };
return translatedParams;
}
@@ -423,7 +409,7 @@ ScriptEventHelper::createEvents( const OUString& sCodeName )
++nEvts;
if ( nEvts > aDest.getLength() )
aDest.realloc( nEvts );// should never happen
- aDest[ dIndex ] = evtDesc;
+ aDest.getArray()[ dIndex ] = evtDesc;
}
}
aDest.realloc( nEvts );