diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 13:51:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 17:14:42 +0100 |
commit | 82233965486f88f4ce1313dcf35b4bc688e1832a (patch) | |
tree | ba10593b268cec21107c4d718629da118c3c6bea /desktop | |
parent | 489bce598626390d9c0aa5e5b8514e26070add61 (diff) |
loplugin:flatten in desktop..drawinglayer
Change-Id: Ie6594c9961aba5517c6ff61fb3bc1142081b1197
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127225
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 48 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_interact.cxx | 40 | ||||
-rw-r--r-- | desktop/source/deployment/registry/script/dp_script.cxx | 46 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 84 |
4 files changed, 108 insertions, 110 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index ceccee017442..f66c016ea6a7 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -765,39 +765,37 @@ OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect) bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() ) + if ( !rMEvt.IsLeft() ) + return false; + + if (rMEvt.IsMod1() && m_bHasActive) + selectEntry(ExtensionBox_Impl::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one + else { - if (rMEvt.IsMod1() && m_bHasActive) - selectEntry(ExtensionBox_Impl::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one - else - { - auto nPos = PointToPos( rMEvt.GetPosPixel() ); + auto nPos = PointToPos( rMEvt.GetPosPixel() ); - if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) ) + if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) ) + { + const auto& rEntry = m_vEntries[nPos]; + if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel())) { - const auto& rEntry = m_vEntries[nPos]; - if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel())) + try + { + css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute( + css::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); + //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException + xSystemShellExecute->execute(rEntry->m_sPublisherURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY); + } + catch (...) { - try - { - css::uno::Reference<css::system::XSystemShellExecute> xSystemShellExecute( - css::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); - //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException - xSystemShellExecute->execute(rEntry->m_sPublisherURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY); - } - catch (...) - { - } - return true; } + return true; } - - selectEntry( nPos ); } - return true; - } - return false; + selectEntry( nPos ); + } + return true; } bool ExtensionBox_Impl::KeyInput(const KeyEvent& rKEvt) diff --git a/desktop/source/deployment/misc/dp_interact.cxx b/desktop/source/deployment/misc/dp_interact.cxx index 9c5818cc669a..ae928a28e889 100644 --- a/desktop/source/deployment/misc/dp_interact.cxx +++ b/desktop/source/deployment/misc/dp_interact.cxx @@ -98,25 +98,27 @@ bool interactContinuation( Any const & request, OSL_ASSERT( cppu::UnoType<task::XInteractionContinuation>::get().isAssignableFrom( continuation ) ); - if (xCmdEnv.is()) { - Reference<task::XInteractionHandler> xInteractionHandler( - xCmdEnv->getInteractionHandler() ); - if (xInteractionHandler.is()) { - bool cont = false; - bool abort = false; - std::vector< Reference<task::XInteractionContinuation> > conts { - new InteractionContinuationImpl(continuation, &cont ), - new InteractionContinuationImpl( cppu::UnoType<task::XInteractionAbort>::get(), &abort ) }; - xInteractionHandler->handle( - new ::comphelper::OInteractionRequest( request, std::move(conts) ) ); - if (cont || abort) { - if (pcont != nullptr) - *pcont = cont; - if (pabort != nullptr) - *pabort = abort; - return true; - } - } + if (!xCmdEnv) + return false; + + Reference<task::XInteractionHandler> xInteractionHandler( + xCmdEnv->getInteractionHandler() ); + if (!xInteractionHandler) + return false; + + bool cont = false; + bool abort = false; + std::vector< Reference<task::XInteractionContinuation> > conts { + new InteractionContinuationImpl(continuation, &cont ), + new InteractionContinuationImpl( cppu::UnoType<task::XInteractionAbort>::get(), &abort ) }; + xInteractionHandler->handle( + new ::comphelper::OInteractionRequest( request, std::move(conts) ) ); + if (cont || abort) { + if (pcont != nullptr) + *pcont = cont; + if (pabort != nullptr) + *pabort = abort; + return true; } return false; } diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 4dd3d3b3eb79..3dc951a6f1d4 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -347,36 +347,36 @@ lcl_maybeAddScript( OUString const& rScriptURL, Reference<css::script::XLibraryContainer3> const& xScriptLibs) { - if (bExists && xScriptLibs.is()) + if (!bExists || !xScriptLibs) + return false; + + bool bCanAdd = true; + if (xScriptLibs->hasByName(rName)) { - bool bCanAdd = true; - if (xScriptLibs->hasByName(rName)) + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(rName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE") + || sOriginalUrl.match("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE") + || sOriginalUrl.match("vnd.sun.star.expand:$BUNDLED_EXTENSIONS") + || sOriginalUrl.match("$(INST)/share/basic/Access2Base/")) { - const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(rName); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE") - || sOriginalUrl.match("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE") - || sOriginalUrl.match("vnd.sun.star.expand:$BUNDLED_EXTENSIONS") - || sOriginalUrl.match("$(INST)/share/basic/Access2Base/")) - { - xScriptLibs->removeLibrary(rName); - bCanAdd = true; - } - else - { - bCanAdd = false; - } + xScriptLibs->removeLibrary(rName); + bCanAdd = true; } - - if (bCanAdd) + else { - xScriptLibs->createLibraryLink(rName, rScriptURL, false); - return xScriptLibs->hasByName(rName); + bCanAdd = false; } } + if (bCanAdd) + { + xScriptLibs->createLibraryLink(rName, rScriptURL, false); + return xScriptLibs->hasByName(rName); + } + return false; } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 434c7d80e01e..fc43e606d7bb 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -564,25 +564,25 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload) tools::Rectangle RectangleAndPart::SanitizedRectangle(tools::Long nLeft, tools::Long nTop, tools::Long nWidth, tools::Long nHeight) { - if (nWidth > 0 && nHeight > 0) - { - // The top-left corner starts at (0, 0). - // Anything negative is invalid. - if (nLeft < 0) - { - nWidth += nLeft; - nLeft = 0; - } + if (nWidth <= 0 || nHeight <= 0) + return tools::Rectangle(); - if (nTop < 0) - { - nHeight += nTop; - nTop = 0; - } + // The top-left corner starts at (0, 0). + // Anything negative is invalid. + if (nLeft < 0) + { + nWidth += nLeft; + nLeft = 0; + } - if (nWidth > 0 && nHeight > 0) - return tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight); + if (nTop < 0) + { + nHeight += nTop; + nTop = 0; } + + if (nWidth > 0 && nHeight > 0) + return tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight); // Else set empty rect. return tools::Rectangle(); } @@ -2699,41 +2699,39 @@ static int lo_runMacro(LibreOfficeKit* pThis, const char *pURL) xFactory = xContext->getServiceManager(); - if (xFactory.is()) - { - uno::Reference<frame::XDispatchProvider> xDP; - xSFactory.set(xFactory, uno::UNO_QUERY_THROW); - xDP.set( xSFactory->createInstance("com.sun.star.comp.sfx2.SfxMacroLoader"), uno::UNO_QUERY ); - uno::Reference<frame::XDispatch> xD = xDP->queryDispatch( aURL, OUString(), 0); + if (!xFactory) + return false; - if (!xD.is()) - { - pLib->maLastExceptionMsg = "Macro loader is not available"; - SAL_INFO("lok", "Macro loader is not available"); - return false; - } + uno::Reference<frame::XDispatchProvider> xDP; + xSFactory.set(xFactory, uno::UNO_QUERY_THROW); + xDP.set( xSFactory->createInstance("com.sun.star.comp.sfx2.SfxMacroLoader"), uno::UNO_QUERY ); + uno::Reference<frame::XDispatch> xD = xDP->queryDispatch( aURL, OUString(), 0); - uno::Reference < frame::XSynchronousDispatch > xSyncDisp( xD, uno::UNO_QUERY_THROW ); - uno::Sequence<css::beans::PropertyValue> aEmpty; - css::beans::PropertyValue aErr; - uno::Any aRet = xSyncDisp->dispatchWithReturnValue( aURL, aEmpty ); - aRet >>= aErr; + if (!xD.is()) + { + pLib->maLastExceptionMsg = "Macro loader is not available"; + SAL_INFO("lok", "Macro loader is not available"); + return false; + } - if (aErr.Name == "ErrorCode") - { - sal_uInt32 nErrCode = 0; // ERRCODE_NONE - aErr.Value >>= nErrCode; + uno::Reference < frame::XSynchronousDispatch > xSyncDisp( xD, uno::UNO_QUERY_THROW ); + uno::Sequence<css::beans::PropertyValue> aEmpty; + css::beans::PropertyValue aErr; + uno::Any aRet = xSyncDisp->dispatchWithReturnValue( aURL, aEmpty ); + aRet >>= aErr; - pLib->maLastExceptionMsg = "An error occurred running macro (error code: " + OUString::number( nErrCode ) + ")"; - SAL_INFO("lok", "Macro execution terminated with error code " << nErrCode); + if (aErr.Name == "ErrorCode") + { + sal_uInt32 nErrCode = 0; // ERRCODE_NONE + aErr.Value >>= nErrCode; - return false; - } + pLib->maLastExceptionMsg = "An error occurred running macro (error code: " + OUString::number( nErrCode ) + ")"; + SAL_INFO("lok", "Macro execution terminated with error code " << nErrCode); - return true; + return false; } - return false; + return true; } static bool lo_signDocument(LibreOfficeKit* /*pThis*/, |