scripting/source/protocolhandler/scripthandler.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
New commits: commit 7743f64869d650d5e6a8fb34bb14b2d1be0b05ce Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Nov 11 11:46:52 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Nov 11 15:52:07 2024 +0100 tdf#163486: PVS: simplify while loop V1044 Loop break conditions do not depend on the number of iterations. Change-Id: Id43a749c090d26b6db174a1ad44df904d20863d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176397 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index d108cdac7c30..683007e7c825 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -120,7 +120,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( if (officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get()) return; - bool bSuccess = false; + sal_Int16 aState = css::frame::DispatchResultState::FAILURE; Any invokeResult; bool bCaughtException = false; Any aException; @@ -204,14 +204,14 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( if ( bIsDocumentScript ) pUndoGuard.reset( new ::framework::DocumentUndoGuard( m_xScriptInvocation ) ); - bSuccess = false; - while ( !bSuccess ) + while ( true ) { std::exception_ptr aFirstCaughtException; try { invokeResult = xFunc->invoke( inArgs, outIndex, outArgs ); - bSuccess = true; + aState = css::frame::DispatchResultState::SUCCESS; + break; } catch( const provider::ScriptFrameworkErrorException& se ) { @@ -265,14 +265,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( aEvent.Source = getXWeak(); aEvent.Result = invokeResult; - if ( bSuccess ) - { - aEvent.State = css::frame::DispatchResultState::SUCCESS; - } - else - { - aEvent.State = css::frame::DispatchResultState::FAILURE; - } + aEvent.State = aState; try {