summaryrefslogtreecommitdiff
path: root/scripting/source/dlgprov/dlgevtatt.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-02 10:45:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-02 20:05:25 +0200
commitd9946e6d0ba81071f3e50622e5cae9e2ffc9bfb0 (patch)
tree795444cdd46cc3f0b93f5363e7699f01b1b974e2 /scripting/source/dlgprov/dlgevtatt.cxx
parenta3695d24087b7958850d73eee7e665c1d78a041b (diff)
loplugin:flatten in scripting
Change-Id: I8df38b4b581fb674a050ef32624b22498a8e340f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91549 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting/source/dlgprov/dlgevtatt.cxx')
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx168
1 files changed, 84 insertions, 84 deletions
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 1269395b01f5..b1a3fceee7ec 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -118,37 +118,37 @@ namespace dlgprov
args[0] <<= xModel;
mxListener.set( xSMgr->createInstanceWithArgumentsAndContext( "ooo.vba.EventListener", args, m_xContext ), UNO_QUERY );
}
- if ( rxControl.is() )
+ if ( !rxControl.is() )
+ return;
+
+ try
{
- try
- {
- Reference< XPropertySet > xProps( rxControl->getModel(), UNO_QUERY_THROW );
- xProps->getPropertyValue("Name") >>= msDialogCodeName;
- xProps.set( mxListener, UNO_QUERY_THROW );
- xProps->setPropertyValue("Model", args[ 0 ] );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("scripting");
- }
+ Reference< XPropertySet > xProps( rxControl->getModel(), UNO_QUERY_THROW );
+ xProps->getPropertyValue("Name") >>= msDialogCodeName;
+ xProps.set( mxListener, UNO_QUERY_THROW );
+ xProps->setPropertyValue("Model", args[ 0 ] );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("scripting");
}
}
void DialogVBAScriptListenerImpl::firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* )
{
- if ( aScriptEvent.ScriptType == "VBAInterop" && mxListener.is() )
+ if ( !(aScriptEvent.ScriptType == "VBAInterop" && mxListener.is()) )
+ return;
+
+ ScriptEvent aScriptEventCopy( aScriptEvent );
+ aScriptEventCopy.ScriptCode = msDialogLibName.concat( "." ).concat( msDialogCodeName );
+ try
{
- ScriptEvent aScriptEventCopy( aScriptEvent );
- aScriptEventCopy.ScriptCode = msDialogLibName.concat( "." ).concat( msDialogCodeName );
- try
- {
- mxListener->firing( aScriptEventCopy );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("scripting");
- }
+ mxListener->firing( aScriptEventCopy );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("scripting");
}
}
@@ -215,62 +215,62 @@ namespace dlgprov
void DialogEventsAttacherImpl::attachEventsToControl( const Reference< XControl>& xControl, const Reference< XScriptEventsSupplier >& xEventsSupplier, const Any& Helper )
{
- if ( xEventsSupplier.is() )
- {
- Reference< container::XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ if ( !xEventsSupplier.is() )
+ return;
- Reference< XControlModel > xControlModel = xControl->getModel();
- if ( xEventCont.is() )
- {
- const Sequence< OUString > aNames = xEventCont->getElementNames();
+ Reference< container::XNameContainer > xEventCont = xEventsSupplier->getEvents();
- for ( const OUString& rName : aNames )
- {
- ScriptEventDescriptor aDesc;
+ Reference< XControlModel > xControlModel = xControl->getModel();
+ if ( !xEventCont.is() )
+ return;
- Any aElement = xEventCont->getByName( rName );
- aElement >>= aDesc;
- OUString sKey = aDesc.ScriptType;
- if ( aDesc.ScriptType == "Script" || aDesc.ScriptType == "UNO" )
- {
- sal_Int32 nIndex = aDesc.ScriptCode.indexOf( ':' );
- sKey = aDesc.ScriptCode.copy( 0, nIndex );
- }
- Reference< XAllListener > xAllListener =
- new DialogAllListenerImpl( getScriptListenerForKey( sKey ), aDesc.ScriptType, aDesc.ScriptCode );
+ const Sequence< OUString > aNames = xEventCont->getElementNames();
- // try first to attach event to the ControlModel
- bool bSuccess = false;
- try
- {
- Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
- xControlModel, xAllListener, Helper, aDesc.ListenerType,
- aDesc.AddListenerParam, aDesc.EventMethod );
+ for ( const OUString& rName : aNames )
+ {
+ ScriptEventDescriptor aDesc;
- if ( xListener_.is() )
- bSuccess = true;
- }
- catch ( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("scripting");
- }
+ Any aElement = xEventCont->getByName( rName );
+ aElement >>= aDesc;
+ OUString sKey = aDesc.ScriptType;
+ if ( aDesc.ScriptType == "Script" || aDesc.ScriptType == "UNO" )
+ {
+ sal_Int32 nIndex = aDesc.ScriptCode.indexOf( ':' );
+ sKey = aDesc.ScriptCode.copy( 0, nIndex );
+ }
+ Reference< XAllListener > xAllListener =
+ new DialogAllListenerImpl( getScriptListenerForKey( sKey ), aDesc.ScriptType, aDesc.ScriptCode );
- try
- {
- // if we had no success, try to attach to the control
- if ( !bSuccess )
- {
- m_xEventAttacher->attachSingleEventListener(
- xControl, xAllListener, Helper, aDesc.ListenerType,
- aDesc.AddListenerParam, aDesc.EventMethod );
- }
- }
- catch ( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("scripting");
- }
+ // try first to attach event to the ControlModel
+ bool bSuccess = false;
+ try
+ {
+ Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
+ xControlModel, xAllListener, Helper, aDesc.ListenerType,
+ aDesc.AddListenerParam, aDesc.EventMethod );
+
+ if ( xListener_.is() )
+ bSuccess = true;
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("scripting");
+ }
+
+ try
+ {
+ // if we had no success, try to attach to the control
+ if ( !bSuccess )
+ {
+ m_xEventAttacher->attachSingleEventListener(
+ xControl, xAllListener, Helper, aDesc.ListenerType,
+ aDesc.AddListenerParam, aDesc.EventMethod );
}
}
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("scripting");
+ }
}
}
@@ -507,21 +507,21 @@ namespace dlgprov
OUString sScriptURL;
OUString sScriptCode( aScriptEvent.ScriptCode );
- if ( aScriptEvent.ScriptType == "StarBasic" )
+ if ( aScriptEvent.ScriptType != "StarBasic" )
+ return;
+
+ // StarBasic script: convert ScriptCode to scriptURL
+ sal_Int32 nIndex = sScriptCode.indexOf( ':' );
+ if ( nIndex >= 0 && nIndex < sScriptCode.getLength() )
{
- // StarBasic script: convert ScriptCode to scriptURL
- sal_Int32 nIndex = sScriptCode.indexOf( ':' );
- if ( nIndex >= 0 && nIndex < sScriptCode.getLength() )
- {
- sScriptURL = "vnd.sun.star.script:" +
- sScriptCode.copy( nIndex + 1 ) +
- "?language=Basic&location=" +
- sScriptCode.copy( 0, nIndex );
- }
- ScriptEvent aSFScriptEvent( aScriptEvent );
- aSFScriptEvent.ScriptCode = sScriptURL;
- DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet );
+ sScriptURL = "vnd.sun.star.script:" +
+ sScriptCode.copy( nIndex + 1 ) +
+ "?language=Basic&location=" +
+ sScriptCode.copy( 0, nIndex );
}
+ ScriptEvent aSFScriptEvent( aScriptEvent );
+ aSFScriptEvent.ScriptCode = sScriptURL;
+ DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet );
}
void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )