summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 10:53:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 13:06:24 +0200
commitb9de047454c2603e2f5a5108254cd3f967e8a88b (patch)
tree589c20e48bfed9c3cfe6696c24c67d49f568c6bd /scripting
parent448e9da1b440561441602e3a0956218b2702767e (diff)
loplugin:flatten in scaddins..sd
Change-Id: I190323ce910224f883c4370b2c752644a5a35edd Reviewed-on: https://gerrit.libreoffice.org/42626 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/basmethnode.cxx111
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx17
-rw-r--r--scripting/source/provider/MasterScriptProvider.cxx51
3 files changed, 83 insertions, 96 deletions
diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx
index e13f149aefcc..a0104f260950 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -185,80 +185,79 @@ namespace basprov
Any BasicMethodNodeImpl::invoke( const OUString& aFunctionName, const Sequence< Any >&,
Sequence< sal_Int16 >&, Sequence< Any >& )
{
- if ( aFunctionName == BASPROV_PROPERTY_EDITABLE )
+ if ( aFunctionName != BASPROV_PROPERTY_EDITABLE )
{
- OUString sDocURL, sLibName, sModName;
- sal_uInt16 nLine1 = 0, nLine2;
+ throw IllegalArgumentException(
+ "BasicMethodNodeImpl::invoke: function name not supported!",
+ Reference< XInterface >(), 1 );
+ }
- if ( !m_bIsAppScript )
- {
- Reference< frame::XModel > xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext );
+ OUString sDocURL, sLibName, sModName;
+ sal_uInt16 nLine1 = 0, nLine2;
+
+ if ( !m_bIsAppScript )
+ {
+ Reference< frame::XModel > xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext );
- if ( xModel.is() )
+ if ( xModel.is() )
+ {
+ sDocURL = xModel->getURL();
+ if ( sDocURL.isEmpty() )
{
- sDocURL = xModel->getURL();
- 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 )
{
- 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" )
{
- // TODO: according to MBA the property 'Title' may change in future
- if ( pProps[i].Name == "Title" )
- {
- pProps[i].Value >>= sDocURL;
- break;
- }
+ pProps[i].Value >>= sDocURL;
+ break;
}
}
}
}
+ }
- if ( m_pMethod )
+ if ( m_pMethod )
+ {
+ m_pMethod->GetLineRange( nLine1, nLine2 );
+ SbModule* pModule = m_pMethod->GetModule();
+ if ( pModule )
{
- m_pMethod->GetLineRange( nLine1, nLine2 );
- SbModule* pModule = m_pMethod->GetModule();
- if ( pModule )
- {
- sModName = pModule->GetName();
- StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
- if ( pBasic )
- sLibName = pBasic->GetName();
- }
+ sModName = pModule->GetName();
+ StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
+ if ( pBasic )
+ sLibName = pBasic->GetName();
}
+ }
- if ( m_xContext.is() )
- {
- Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext );
+ if ( m_xContext.is() )
+ {
+ Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext );
- Reference < frame::XDispatchProvider > xProv( xDesktop->getCurrentFrame(), UNO_QUERY );
+ Reference < frame::XDispatchProvider > xProv( xDesktop->getCurrentFrame(), UNO_QUERY );
- if ( xProv.is() )
- {
- 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 );
- xHelper->executeDispatch( xProv, ".uno:BasicIDEAppear", OUString(), 0, aArgs );
- }
+ if ( xProv.is() )
+ {
+ 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 );
+ xHelper->executeDispatch( xProv, ".uno:BasicIDEAppear", OUString(), 0, aArgs );
}
}
- else
- {
- throw IllegalArgumentException(
- "BasicMethodNodeImpl::invoke: function name not supported!",
- Reference< XInterface >(), 1 );
- }
+
return Any();
}
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 2d41725882ce..d58c7ec0f4e3 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -335,19 +335,14 @@ namespace dlgprov
if ( !m_xEventAttacher.is() )
{
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
- if ( xSMgr.is() )
- {
- m_xEventAttacher.set( xSMgr->createInstanceWithContext(
- "com.sun.star.script.EventAttacher", m_xContext ), UNO_QUERY );
-
- if ( !m_xEventAttacher.is() )
- throw ServiceNotRegisteredException();
- }
- else
- {
+ if ( !xSMgr.is() )
throw RuntimeException();
- }
+ m_xEventAttacher.set( xSMgr->createInstanceWithContext(
+ "com.sun.star.script.EventAttacher", m_xContext ), UNO_QUERY );
+
+ if ( !m_xEventAttacher.is() )
+ throw ServiceNotRegisteredException();
}
}
OUString sDialogCodeName;
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 972097da4fb1..d9d829197e6c 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -300,23 +300,7 @@ MasterScriptProvider::getScript( const OUString& scriptURI )
buf.append( "com.sun.star.script.provider.ScriptProviderFor");
buf.append( language );
OUString serviceName = buf.makeStringAndClear();
- if ( providerCache() )
- {
- try
- {
- xScriptProvider.set(
- providerCache()->getProvider( serviceName ),
- UNO_QUERY_THROW );
- }
- catch( const Exception& e )
- {
- throw provider::ScriptFrameworkErrorException(
- e.Message, Reference< XInterface >(),
- sfUri->getName(), language,
- provider::ScriptFrameworkErrorType::NOTSUPPORTED );
- }
- }
- else
+ if ( !providerCache() )
{
throw provider::ScriptFrameworkErrorException(
"No LanguageProviders detected",
@@ -324,6 +308,21 @@ MasterScriptProvider::getScript( const OUString& scriptURI )
sfUri->getName(), language,
provider::ScriptFrameworkErrorType::NOTSUPPORTED );
}
+
+ try
+ {
+ xScriptProvider.set(
+ providerCache()->getProvider( serviceName ),
+ UNO_QUERY_THROW );
+ }
+ catch( const Exception& e )
+ {
+ throw provider::ScriptFrameworkErrorException(
+ e.Message, Reference< XInterface >(),
+ sfUri->getName(), language,
+ provider::ScriptFrameworkErrorType::NOTSUPPORTED );
+ }
+
xScript=xScriptProvider->getScript( scriptURI );
}
else
@@ -457,16 +456,13 @@ MasterScriptProvider::insertByName( const OUString& aName, const Any& aElement )
{
if ( !m_bIsPkgMSP )
{
- if ( m_xMSPPkg.is() )
- {
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
- xCont->insertByName( aName, aElement );
- }
- else
+ if ( !m_xMSPPkg.is() )
{
throw RuntimeException( "PackageMasterScriptProvider is unitialised" );
}
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
+ xCont->insertByName( aName, aElement );
}
else
{
@@ -529,16 +525,13 @@ MasterScriptProvider::removeByName( const OUString& Name )
{
if ( !m_bIsPkgMSP )
{
- if ( m_xMSPPkg.is() )
- {
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
- xCont->removeByName( Name );
- }
- else
+ if ( !m_xMSPPkg.is() )
{
throw RuntimeException( "PackageMasterScriptProvider is unitialised" );
}
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
+ xCont->removeByName( Name );
}
else
{