summaryrefslogtreecommitdiff
path: root/scripting/source
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/source')
-rw-r--r--scripting/source/basprov/basmethnode.cxx16
-rw-r--r--scripting/source/basprov/basprov.cxx7
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx13
-rw-r--r--scripting/source/protocolhandler/scripthandler.cxx19
-rw-r--r--scripting/source/provider/BrowseNodeFactoryImpl.cxx25
-rw-r--r--scripting/source/provider/ProviderCache.cxx27
-rw-r--r--scripting/source/provider/ProviderCache.hxx14
-rw-r--r--scripting/source/provider/URIHelper.cxx26
-rw-r--r--scripting/source/stringresource/stringresource.cxx5
-rw-r--r--scripting/source/vbaevents/eventhelper.cxx22
10 files changed, 68 insertions, 106 deletions
diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx
index a0104f260950..2b950556c9e8 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -205,17 +205,11 @@ namespace basprov
if ( sDocURL.isEmpty() )
{
Sequence < PropertyValue > aProps = xModel->getArgs();
- sal_Int32 nProps = aProps.getLength();
- const PropertyValue* pProps = aProps.getConstArray();
- for ( sal_Int32 i = 0; i < nProps; ++i )
- {
- // TODO: according to MBA the property 'Title' may change in future
- if ( pProps[i].Name == "Title" )
- {
- pProps[i].Value >>= sDocURL;
- break;
- }
- }
+ // TODO: according to MBA the property 'Title' may change in future
+ const PropertyValue* pProp = std::find_if(aProps.begin(), aProps.end(),
+ [](const PropertyValue& rProp) { return rProp.Name == "Title"; });
+ if (pProp != aProps.end())
+ pProp->Value >>= sDocURL;
}
}
}
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 692f198cc960..1f0926abfa25 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -427,17 +427,16 @@ namespace basprov
{
Sequence< OUString > aLibNames = xLibContainer->getElementNames();
sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
aChildNodes.realloc( nLibCount );
Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
sal_Int32 childrenFound = 0;
- for ( sal_Int32 i = 0 ; i < nLibCount ; ++i )
+ for ( const OUString& rLibName : aLibNames )
{
bool bCreate = false;
if ( m_bIsAppScriptCtx )
{
- const bool bShared = isLibraryShared( xLibContainer, pLibNames[i] );
+ const bool bShared = isLibraryShared( xLibContainer, rLibName );
if (m_bIsUserCtx != bShared)
bCreate = true;
}
@@ -449,7 +448,7 @@ namespace basprov
{
pChildNodes[childrenFound++]
= new BasicLibraryNodeImpl(m_xContext, m_sScriptingContext, pBasicManager,
- xLibContainer, pLibNames[i], m_bIsAppScriptCtx);
+ xLibContainer, rLibName, m_bIsAppScriptCtx);
}
}
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 2bdcf0d2cfba..691b12ca757b 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -221,14 +221,12 @@ namespace dlgprov
if ( xEventCont.is() )
{
Sequence< OUString > aNames = xEventCont->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nNameCount = aNames.getLength();
- for ( sal_Int32 j = 0; j < nNameCount; ++j )
+ for ( const OUString& rName : aNames )
{
ScriptEventDescriptor aDesc;
- Any aElement = xEventCont->getByName( pNames[ j ] );
+ Any aElement = xEventCont->getByName( rName );
aElement >>= aDesc;
OUString sKey = aDesc.ScriptType;
if ( aDesc.ScriptType == "Script" || aDesc.ScriptType == "UNO" )
@@ -277,15 +275,12 @@ namespace dlgprov
void DialogEventsAttacherImpl::nestedAttachEvents( const Sequence< Reference< XInterface > >& Objects, const Any& Helper, OUString& sDialogCodeName )
{
- const Reference< XInterface >* pObjects = Objects.getConstArray();
- sal_Int32 nObjCount = Objects.getLength();
-
- for ( sal_Int32 i = 0; i < nObjCount; ++i )
+ for ( const Reference< XInterface >& rObject : Objects )
{
// We know that we have to do with instances of XControl.
// Otherwise this is not the right implementation for
// XScriptEventsAttacher and we have to give up.
- Reference< XControl > xControl( pObjects[ i ], UNO_QUERY );
+ Reference< XControl > xControl( rObject, UNO_QUERY );
Reference< XControlContainer > xControlContainer( xControl, UNO_QUERY );
Reference< XDialog > xDialog( xControl, UNO_QUERY );
if ( !xControl.is() )
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index c4b7a519beb6..d1a7fb9e8bb1 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -111,12 +111,9 @@ const Sequence < DispatchDescriptor >& seqDescriptor )
{
sal_Int32 nCount = seqDescriptor.getLength();
Sequence< Reference< XDispatch > > lDispatcher( nCount );
- for ( sal_Int32 i = 0; i < nCount; ++i )
- {
- lDispatcher[ i ] = queryDispatch( seqDescriptor[ i ].FeatureURL,
- seqDescriptor[ i ].FrameName,
- seqDescriptor[ i ].SearchFlags );
- }
+ std::transform(seqDescriptor.begin(), seqDescriptor.end(), lDispatcher.begin(),
+ [this](const DispatchDescriptor& rDescr) -> Reference<XDispatch> {
+ return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return lDispatcher;
}
@@ -184,18 +181,18 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
if ( lArgs.hasElements() )
{
int argCount = 0;
- for ( int index = 0; index < lArgs.getLength(); index++ )
+ for ( const auto& rArg : lArgs )
{
// Sometimes we get a propertyval with name = "Referer" or "SynchronMode". These
// are not actual arguments to be passed to script, but flags describing the
// call, so ignore. Who thought that passing such "meta-arguments" mixed in with
// real arguments was a good idea?
- if ( (lArgs[ index ].Name != "Referer" &&
- lArgs[ index ].Name != "SynchronMode") ||
- lArgs[ index ].Name.isEmpty() ) //TODO:???
+ if ( (rArg.Name != "Referer" &&
+ rArg.Name != "SynchronMode") ||
+ rArg.Name.isEmpty() ) //TODO:???
{
inArgs.realloc( ++argCount );
- inArgs[ argCount - 1 ] = lArgs[ index ].Value;
+ inArgs[ argCount - 1 ] = rArg.Value;
}
}
}
diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
index 909443f5f511..c7a7829d900f 100644
--- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx
+++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
@@ -109,10 +109,8 @@ public:
sal_Int32 index = 0;
for ( Sequence< Reference < browse::XBrowseNode > >& children : seqs )
{
- for ( sal_Int32 j = 0; j < children.getLength(); j++ )
- {
- result[ index++ ] = children[ j ];
- }
+ std::copy(children.begin(), children.end(), std::next(result.begin(), index));
+ index += children.getLength();
if (index >= numChildren)
break;
@@ -220,25 +218,23 @@ private:
Sequence< Reference< browse::XBrowseNode > > langNodes =
m_origNode->getChildNodes();
- for ( sal_Int32 i = 0; i < langNodes.getLength(); i++ )
+ for ( const auto& rLangNode : langNodes )
{
Reference< browse::XBrowseNode > xbn;
- if ( langNodes[ i ]->getName() == "uno_packages" )
+ if ( rLangNode->getName() == "uno_packages" )
{
- xbn.set( new LocationBrowseNode( langNodes[ i ] ) );
+ xbn.set( new LocationBrowseNode( rLangNode ) );
}
else
{
- xbn.set( langNodes[ i ] );
+ xbn.set( rLangNode );
}
Sequence< Reference< browse::XBrowseNode > > grandchildren =
xbn->getChildNodes();
- for ( sal_Int32 j = 0; j < grandchildren.getLength(); j++ )
+ for ( const Reference< browse::XBrowseNode >& grandchild : grandchildren )
{
- Reference< browse::XBrowseNode > grandchild(grandchildren[j]);
-
auto h_it =
m_hBNA->find( grandchild->getName() );
@@ -289,11 +285,11 @@ std::vector< Reference< browse::XBrowseNode > > getAllBrowseNodes( const Referen
return locnBNs;
}
- for ( sal_Int32 i = 0; i < openDocs.getLength(); i++ )
+ for ( const auto& rDoc : openDocs )
{
try
{
- Reference< frame::XModel > model( MiscUtils::tDocUrlToModel( openDocs[ i ] ), UNO_SET_THROW );
+ Reference< frame::XModel > model( MiscUtils::tDocUrlToModel( rDoc ), UNO_SET_THROW );
// #i44599 Check if it's a real document or something special like Hidden/Preview
css::uno::Reference< css::frame::XController > xCurrentController = model->getCurrentController();
@@ -401,9 +397,8 @@ public:
vXBrowseNodes aVNodes;
Sequence < Reference< browse::XBrowseNode > > nodes =
m_xWrappedBrowseNode->getChildNodes();
- for ( sal_Int32 i=0; i<nodes.getLength(); i++ )
+ for ( const Reference< browse::XBrowseNode >& xBrowseNode : nodes )
{
- Reference< browse::XBrowseNode > xBrowseNode = nodes[ i ];
OSL_ENSURE( xBrowseNode.is(), "DefaultBrowseNode::getChildNodes(): Invalid BrowseNode" );
if( xBrowseNode.is() )
aVNodes.push_back( new DefaultBrowseNode( m_xCtx, xBrowseNode ) );
diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx
index cf54ea0aee22..e97be35acb6f 100644
--- a/scripting/source/provider/ProviderCache.cxx
+++ b/scripting/source/provider/ProviderCache.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/sequence.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/factory.hxx>
#include <tools/diagnose_ex.h>
@@ -150,17 +151,17 @@ ProviderCache::populateCache()
if ( serviceNames.hasElements() )
{
- for ( sal_Int32 index = 0; index < serviceNames.getLength(); index++ )
+ auto pName = std::find_if(serviceNames.begin(), serviceNames.end(),
+ [this](const OUString& rName) {
+ return rName.startsWith("com.sun.star.script.provider.ScriptProviderFor")
+ && !isInBlackList(rName);
+ });
+ if (pName != serviceNames.end())
{
- if ( serviceNames[ index ].startsWith( "com.sun.star.script.provider.ScriptProviderFor" )
- && !isInBlackList( serviceNames[ index ] ) )
- {
- serviceName = serviceNames[ index ];
- ProviderDetails details;
- details.factory = factory;
- m_hProviderDetailsCache[ serviceName ] = details;
- break;
- }
+ serviceName = *pName;
+ ProviderDetails details;
+ details.factory = factory;
+ m_hProviderDetailsCache[ serviceName ] = details;
}
}
}
@@ -193,6 +194,12 @@ ProviderCache::createProvider( ProviderDetails& details )
return details.provider;
}
+
+bool
+ProviderCache::isInBlackList( const OUString& serviceName )
+{
+ return comphelper::findValue(m_sBlackList, serviceName) != -1;
+}
} //end namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/scripting/source/provider/ProviderCache.hxx b/scripting/source/provider/ProviderCache.hxx
index bd13ec9545da..3ad9bc5fab1a 100644
--- a/scripting/source/provider/ProviderCache.hxx
+++ b/scripting/source/provider/ProviderCache.hxx
@@ -67,19 +67,9 @@ private:
void populateCache();
/// @throws css::uno::RuntimeException
- css::uno::Reference< css::script::provider::XScriptProvider >
+ css::uno::Reference< css::script::provider::XScriptProvider >
createProvider( ProviderDetails& details );
- bool isInBlackList( const OUString& serviceName )
- {
- for ( sal_Int32 index = 0; index < m_sBlackList.getLength(); index++ )
- {
- if ( m_sBlackList[ index ] == serviceName )
- {
- return true;
- }
- }
- return false;
- }
+ bool isInBlackList( const OUString& serviceName );
css::uno::Sequence< OUString > m_sBlackList;
ProviderDetails_hash m_hProviderDetailsCache;
osl::Mutex m_mutex;
diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx
index 172f0ac0ae66..650d019d1779 100644
--- a/scripting/source/provider/URIHelper.cxx
+++ b/scripting/source/provider/URIHelper.cxx
@@ -144,23 +144,21 @@ ScriptingFrameworkURIHelper::initBaseURI()
uno::Sequence< OUString > children =
m_xSimpleFileAccess->getFolderContents( uri, true );
- for ( sal_Int32 i = 0; i < children.getLength(); i++ )
- {
- OUString child = children[i];
+ auto pChild = std::find_if(children.begin(), children.end(), [&test](const OUString& child) {
sal_Int32 idx = child.lastIndexOf(test);
-
- if ( idx != -1 && (idx + test.getLength()) == child.getLength() )
+ return idx != -1 && (idx + test.getLength()) == child.getLength();
+ });
+ if (pChild != children.end())
+ {
+ if ( bAppendScriptsPart )
{
- if ( bAppendScriptsPart )
- {
- m_sBaseURI = child.concat( SCRIPTS_PART );
- }
- else
- {
- m_sBaseURI = child;
- }
- return true;
+ m_sBaseURI = pChild->concat( SCRIPTS_PART );
}
+ else
+ {
+ m_sBaseURI = *pChild;
+ }
+ return true;
}
return false;
}
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index a50076ffc762..2c4c2f8a785d 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -1532,11 +1532,8 @@ void StringResourcePersistenceImpl::implScanLocaleNames( const Sequence< OUStrin
Locale aDefaultLocale;
bool bDefaultFound = false;
- sal_Int32 nCount = aContentSeq.getLength();
- const OUString* pFiles = aContentSeq.getConstArray();
- for( int i = 0 ; i < nCount ; i++ )
+ for( const OUString& aCompleteName : aContentSeq )
{
- OUString aCompleteName = pFiles[i];
OUString aPureName;
OUString aExtension;
sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 8388450aa2b2..d987c5206999 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -382,21 +382,13 @@ ScriptEventHelper::getEventListeners()
xIntrospection->inspect( makeAny( m_xControl ) );
Sequence< Type > aControlListeners =
xIntrospectionAccess->getSupportedListeners();
- sal_Int32 nLength = aControlListeners.getLength();
- for ( sal_Int32 i = 0; i< nLength; ++i )
+ for ( const Type& listType : aControlListeners )
{
- Type& listType = aControlListeners[ i ];
OUString sFullTypeName = listType.getTypeName();
Sequence< OUString > sMeths =
comphelper::getEventMethodsForType( listType );
- sal_Int32 sMethLen = sMeths.getLength();
- for ( sal_Int32 j=0 ; j < sMethLen; ++j )
- {
- OUString sEventMethod = sFullTypeName;
- sEventMethod += DELIM;
- sEventMethod += sMeths[ j ];
- eventMethods.push_back( sEventMethod );
- }
+ std::transform(sMeths.begin(), sMeths.end(), std::back_inserter(eventMethods),
+ [&sFullTypeName](const OUString& rMeth) -> OUString { return sFullTypeName + DELIM + rMeth; });
}
return comphelper::containerToSequence(eventMethods);
@@ -476,16 +468,14 @@ typedef std::unordered_map< OUString, Any > EventSupplierHash;
ReadOnlyEventsNameContainer::ReadOnlyEventsNameContainer( const Sequence< OUString >& eventMethods, const OUString& sCodeName )
{
- const OUString* pSrc = eventMethods.getConstArray();
- sal_Int32 nLen = eventMethods.getLength();
- for ( sal_Int32 index = 0; index < nLen; ++index, ++pSrc )
+ for ( const OUString& rSrc : eventMethods )
{
Any aDesc;
ScriptEventDescriptor evtDesc;
- if ( eventMethodToDescriptor( *pSrc, evtDesc, sCodeName ) )
+ if ( eventMethodToDescriptor( rSrc, evtDesc, sCodeName ) )
{
aDesc <<= evtDesc;
- m_hEvents[ *pSrc ] = aDesc;
+ m_hEvents[ rSrc ] = aDesc;
}
}
}