diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-03-26 13:35:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-26 18:02:19 +0100 |
commit | b624b13b3d5a8e573c7de8158cadc66b1982d157 (patch) | |
tree | 56948e6a5e8d7f5a7cbde6328a27f13ecd8a72bc /sc/source | |
parent | 8136620ff432bf17815bef1f88c7531edb839d23 (diff) |
loplugin:flatten
Change-Id: Ib7a895fba66f8dc9b6501e61631c02694053b7fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113157
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/oox/autofilterbuffer.cxx | 90 | ||||
-rw-r--r-- | sc/source/filter/oox/querytablebuffer.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 92 | ||||
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 21 | ||||
-rw-r--r-- | sc/source/ui/dbgui/tpsubt.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh2.cxx | 124 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/futext.cxx | 30 |
7 files changed, 194 insertions, 190 deletions
diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index e09bd084e7f3..464c7e4a51dd 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -725,63 +725,63 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa aDescProps.setProperty( PROP_UseRegularExpressions, bUseRegExp ); // sort - if (!maSortConditions.empty()) - { - const SortConditionVector::value_type& xSortConditionPointer = *maSortConditions.begin(); - const SortCondition& rSorConditionLoaded = *xSortConditionPointer; + if (maSortConditions.empty()) + return; + + const SortConditionVector::value_type& xSortConditionPointer = *maSortConditions.begin(); + const SortCondition& rSorConditionLoaded = *xSortConditionPointer; - ScSortParam aParam; - aParam.bUserDef = false; - aParam.nUserIndex = 0; - aParam.bByRow = false; + ScSortParam aParam; + aParam.bUserDef = false; + aParam.nUserIndex = 0; + aParam.bByRow = false; - ScUserList* pUserList = ScGlobal::GetUserList(); - if (!rSorConditionLoaded.maSortCustomList.isEmpty()) + ScUserList* pUserList = ScGlobal::GetUserList(); + if (!rSorConditionLoaded.maSortCustomList.isEmpty()) + { + for (size_t i=0; pUserList && i < pUserList->size(); i++) { - for (size_t i=0; pUserList && i < pUserList->size(); i++) + const OUString aEntry((*pUserList)[i].GetString()); + if (aEntry.equalsIgnoreAsciiCase(rSorConditionLoaded.maSortCustomList)) { - const OUString aEntry((*pUserList)[i].GetString()); - if (aEntry.equalsIgnoreAsciiCase(rSorConditionLoaded.maSortCustomList)) - { - aParam.bUserDef = true; - aParam.nUserIndex = i; - break; - } + aParam.bUserDef = true; + aParam.nUserIndex = i; + break; } } + } - if (!aParam.bUserDef) - { - pUserList->push_back(new ScUserListData(rSorConditionLoaded.maSortCustomList)); - aParam.bUserDef = true; - aParam.nUserIndex = pUserList->size()-1; - } + if (!aParam.bUserDef) + { + pUserList->push_back(new ScUserListData(rSorConditionLoaded.maSortCustomList)); + aParam.bUserDef = true; + aParam.nUserIndex = pUserList->size()-1; + } - // set sort parameter if we have detected it - if (aParam.bUserDef) + // set sort parameter if we have detected it + if (aParam.bUserDef) + { + SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row(); + if (rSorConditionLoaded.mbDescending) { - SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row(); - if (rSorConditionLoaded.mbDescending) - { - // descending sort - need to enable 1st SortParam slot - assert(aParam.GetSortKeyCount() == DEFSORT); + // descending sort - need to enable 1st SortParam slot + assert(aParam.GetSortKeyCount() == DEFSORT); - aParam.maKeyState[0].bDoSort = true; - aParam.maKeyState[0].bAscending = false; - aParam.maKeyState[0].nField += nStartPos; - } + aParam.maKeyState[0].bDoSort = true; + aParam.maKeyState[0].bAscending = false; + aParam.maKeyState[0].nField += nStartPos; + } - ScDocument& rDoc = getScDocument(); - ScDBData* pDBData = rDoc.GetDBAtArea( - nSheet, - maRange.aStart.Col(), maRange.aStart.Row(), - maRange.aEnd.Col(), maRange.aEnd.Row()); + ScDocument& rDoc = getScDocument(); + ScDBData* pDBData = rDoc.GetDBAtArea( + nSheet, + maRange.aStart.Col(), maRange.aStart.Row(), + maRange.aEnd.Col(), maRange.aEnd.Row()); - if (pDBData) - pDBData->SetSortParam(aParam); - else - OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); - } + if (pDBData) + pDBData->SetSortParam(aParam); + else + OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); } } diff --git a/sc/source/filter/oox/querytablebuffer.cxx b/sc/source/filter/oox/querytablebuffer.cxx index b6614068c2ff..0f561c5ab629 100644 --- a/sc/source/filter/oox/querytablebuffer.cxx +++ b/sc/source/filter/oox/querytablebuffer.cxx @@ -241,7 +241,10 @@ void QueryTable::finalizeImport() // find tables mode: entire document, all tables, or specific tables OUString aTables = pWebPr->mbHtmlTables ? lclBuildWebQueryTables( pWebPr->maTables ) : "HTML_all"; - if( !aTables.isEmpty() ) try + if( aTables.isEmpty() ) + return; + + try { PropertySet aDocProps( getDocument() ); Reference< XAreaLinks > xAreaLinks( aDocProps.getAnyProperty( PROP_AreaLinks ), UNO_QUERY_THROW ); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 926157e71d83..c7beb52ed9e6 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -995,34 +995,34 @@ void ScInputBarGroup::DecrementVerticalSize() void ScInputWindow::MenuHdl(std::string_view command) { - if (!command.empty()) - { - bool bSubTotal = false; - bool bRangeFinder = false; - OpCode eCode = ocSum; - if ( command == "sum" ) - { - eCode = ocSum; - } - else if ( command == "average" ) - { - eCode = ocAverage; - } - else if ( command == "max" ) - { - eCode = ocMax; - } - else if ( command == "min" ) - { - eCode = ocMin; - } - else if ( command == "count" ) - { - eCode = ocCount; - } + if (command.empty()) + return; - AutoSum( bRangeFinder, bSubTotal, eCode ); + bool bSubTotal = false; + bool bRangeFinder = false; + OpCode eCode = ocSum; + if ( command == "sum" ) + { + eCode = ocSum; + } + else if ( command == "average" ) + { + eCode = ocAverage; } + else if ( command == "max" ) + { + eCode = ocMax; + } + else if ( command == "min" ) + { + eCode = ocMin; + } + else if ( command == "count" ) + { + eCode = ocCount; + } + + AutoSum( bRangeFinder, bSubTotal, eCode ); } IMPL_LINK_NOARG(ScInputWindow, DropdownClickHdl, ToolBox *, void) @@ -1340,31 +1340,31 @@ int ScTextWnd::GetEditEngTxtHeight() const void ScTextWnd::SetScrollBarRange() { - if (m_xEditView) - { - OutputDevice& rDevice = GetDrawingArea()->get_ref_device(); - Size aOutputSize = rDevice.GetOutputSize(); + if (!m_xEditView) + return; - int nUpper = GetEditEngTxtHeight(); - int nCurrentDocPos = m_xEditView->GetVisArea().Top(); - int nStepIncrement = GetTextHeight(); - int nPageIncrement = aOutputSize.Height(); - int nPageSize = aOutputSize.Height(); + OutputDevice& rDevice = GetDrawingArea()->get_ref_device(); + Size aOutputSize = rDevice.GetOutputSize(); - /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has - effectively... + int nUpper = GetEditEngTxtHeight(); + int nCurrentDocPos = m_xEditView->GetVisArea().Top(); + int nStepIncrement = GetTextHeight(); + int nPageIncrement = aOutputSize.Height(); + int nPageSize = aOutputSize.Height(); - lower = gtk_adjustment_get_lower - upper = gtk_adjustment_get_upper - gtk_adjustment_get_page_size + /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has + effectively... - and requires that upper > lower or the deceleration animation never ends - */ - nPageSize = std::min(nPageSize, nUpper); + lower = gtk_adjustment_get_lower + upper = gtk_adjustment_get_upper - gtk_adjustment_get_page_size - weld::ScrolledWindow& rVBar = mrGroupBar.GetScrollWin(); - rVBar.vadjustment_configure(nCurrentDocPos, 0, nUpper, - nStepIncrement, nPageIncrement, nPageSize); - } + and requires that upper > lower or the deceleration animation never ends + */ + nPageSize = std::min(nPageSize, nUpper); + + weld::ScrolledWindow& rVBar = mrGroupBar.GetScrollWin(); + rVBar.vadjustment_configure(nCurrentDocPos, 0, nUpper, + nStepIncrement, nPageIncrement, nPageSize); } void ScTextWnd::DoScroll() diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 44f64b8bc4a7..201313f0e41e 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1395,17 +1395,18 @@ void ScCheckListMenuControl::launch(const tools::Rectangle& rRect) void ScCheckListMenuControl::NotifyCloseLOK() { VclPtr<vcl::Window> aNotifierWindow = mxFrame->GetParentWithLOKNotifier(); - if (aNotifierWindow) { - const vcl::ILibreOfficeKitNotifier* pNotifier = aNotifierWindow->GetLOKNotifier(); - if (pNotifier) - { - tools::JsonWriter aJsonWriter; - aJsonWriter.put("jsontype", "autofilter"); - aJsonWriter.put("action", "close"); + if (!aNotifierWindow) + return; - const std::string message = aJsonWriter.extractAsStdString(); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); - } + const vcl::ILibreOfficeKitNotifier* pNotifier = aNotifierWindow->GetLOKNotifier(); + if (pNotifier) + { + tools::JsonWriter aJsonWriter; + aJsonWriter.put("jsontype", "autofilter"); + aJsonWriter.put("action", "close"); + + const std::string message = aJsonWriter.extractAsStdString(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); } } diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx index b5acbc6cdb60..4b8c2e1396be 100644 --- a/sc/source/ui/dbgui/tpsubt.cxx +++ b/sc/source/ui/dbgui/tpsubt.cxx @@ -590,19 +590,19 @@ IMPL_LINK(ScTpSubTotalOptions, CheckHdl, weld::Button&, rBox, void) IMPL_LINK(ScTpSubTotalGroup, CheckBoxHdl, weld::Button&, rBox, void) { - if (&rBox == mxLbSelectAllColumns.get()) - { - bool bChecked = mxLbSelectAllColumns->get_active(); + if (&rBox != mxLbSelectAllColumns.get()) + return; - mxLbColumns->all_foreach([&](const weld::TreeIter& rEntry) { - if ( bChecked ) - mxLbColumns->set_toggle(rEntry, TRISTATE_TRUE); - else - mxLbColumns->set_toggle(rEntry, TRISTATE_FALSE); + bool bChecked = mxLbSelectAllColumns->get_active(); - return false; - }); - } + mxLbColumns->all_foreach([&](const weld::TreeIter& rEntry) { + if ( bChecked ) + mxLbColumns->set_toggle(rEntry, TRISTATE_TRUE); + else + mxLbColumns->set_toggle(rEntry, TRISTATE_FALSE); + + return false; + }); } ScTpSubTotalGroup1::~ScTpSubTotalGroup1() diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 1b2ef3240c1e..22f28e52efe8 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -311,69 +311,69 @@ void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // disable functions static void setupFillColorForChart(SfxViewShell* pShell, SfxItemSet& rSet) { - if (pShell) + if (!pShell) + return; + + SfxInPlaceClient* pIPClient = pShell->GetIPClient(); + if (!pIPClient) + return; + + const css::uno::Reference<::css::embed::XEmbeddedObject>& xEmbObj = pIPClient->GetObject(); + if( !xEmbObj.is() ) + return; + + ::css::uno::Reference<::css::chart2::XChartDocument> xChart( xEmbObj->getComponent(), uno::UNO_QUERY ); + if( !xChart.is() ) + return; + + css::uno::Reference<css::beans::XPropertySet> xPropSet = xChart->getPageBackground(); + if (!xPropSet.is()) + return; + + css::uno::Reference<css::beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo()); + if (!xInfo.is()) + return; + + if (xInfo->hasPropertyByName("FillColor")) { - SfxInPlaceClient* pIPClient = pShell->GetIPClient(); - if (pIPClient) - { - const css::uno::Reference<::css::embed::XEmbeddedObject>& xEmbObj = pIPClient->GetObject(); - if( xEmbObj.is() ) - { - ::css::uno::Reference<::css::chart2::XChartDocument> xChart( xEmbObj->getComponent(), uno::UNO_QUERY ); - if( xChart.is() ) - { - css::uno::Reference<css::beans::XPropertySet> xPropSet = xChart->getPageBackground(); - if (xPropSet.is()) - { - css::uno::Reference<css::beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo()); - if (xInfo.is()) - { - if (xInfo->hasPropertyByName("FillColor")) - { - sal_uInt32 nFillColor = 0; - xPropSet->getPropertyValue("FillColor") >>= nFillColor; - - XFillColorItem aFillColorItem("", Color(ColorTransparency, nFillColor)); - rSet.Put(aFillColorItem); - - if (comphelper::LibreOfficeKit::isActive()) - pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, - (".uno:FillColor=" + std::to_string(nFillColor)).c_str()); - } - - if (comphelper::LibreOfficeKit::isActive() && xInfo->hasPropertyByName("FillGradientName")) - { - OUString aGradientName; - xPropSet->getPropertyValue("FillGradientName") >>= aGradientName; - - ::css::uno::Reference< ::css::frame::XController > xChartController = xChart->getCurrentController(); - if( xChartController.is() ) - { - css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xChartController->getModel(), css::uno::UNO_QUERY); - - if (xFact.is()) - { - css::uno::Reference<css::container::XNameAccess> xNameAccess( - xFact->createInstance("com.sun.star.drawing.GradientTable"), css::uno::UNO_QUERY); - - if (xNameAccess.is() && xNameAccess->hasByName(aGradientName)) - { - css::uno::Any aAny = xNameAccess->getByName(aGradientName); - - XFillGradientItem aItem; - aItem.SetName(aGradientName); - aItem.PutValue(aAny, MID_FILLGRADIENT); - - rSet.Put(aItem); - } - } - } - } - } - } - } - } - } + sal_uInt32 nFillColor = 0; + xPropSet->getPropertyValue("FillColor") >>= nFillColor; + + XFillColorItem aFillColorItem("", Color(ColorTransparency, nFillColor)); + rSet.Put(aFillColorItem); + + if (comphelper::LibreOfficeKit::isActive()) + pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, + (".uno:FillColor=" + std::to_string(nFillColor)).c_str()); + } + + if (!(comphelper::LibreOfficeKit::isActive() && xInfo->hasPropertyByName("FillGradientName"))) + return; + + OUString aGradientName; + xPropSet->getPropertyValue("FillGradientName") >>= aGradientName; + + ::css::uno::Reference< ::css::frame::XController > xChartController = xChart->getCurrentController(); + if( !xChartController.is() ) + return; + + css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xChartController->getModel(), css::uno::UNO_QUERY); + + if (!xFact.is()) + return; + + css::uno::Reference<css::container::XNameAccess> xNameAccess( + xFact->createInstance("com.sun.star.drawing.GradientTable"), css::uno::UNO_QUERY); + + if (xNameAccess.is() && xNameAccess->hasByName(aGradientName)) + { + css::uno::Any aAny = xNameAccess->getByName(aGradientName); + + XFillGradientItem aItem; + aItem.SetName(aGradientName); + aItem.PutValue(aAny, MID_FILLGRADIENT); + + rSet.Put(aItem); } } diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index 9e412449917c..30ab23371d2f 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -600,23 +600,23 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, return; OutlinerView* pOLV = pView->GetTextEditOutlinerView(); - if (pOLV) - { - if ( pMousePixel ) - { - MouseEvent aEditEvt( *pMousePixel, 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0 ); - pOLV->MouseButtonDown(aEditEvt); - pOLV->MouseButtonUp(aEditEvt); - } - else if ( bCursorToEnd ) - { - ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); - pOLV->SetSelection(aNewSelection); - } + if (!pOLV) + return; - if ( pInitialKey ) - pOLV->PostKeyEvent( *pInitialKey ); + if ( pMousePixel ) + { + MouseEvent aEditEvt( *pMousePixel, 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0 ); + pOLV->MouseButtonDown(aEditEvt); + pOLV->MouseButtonUp(aEditEvt); } + else if ( bCursorToEnd ) + { + ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); + pOLV->SetSelection(aNewSelection); + } + + if ( pInitialKey ) + pOLV->PostKeyEvent( *pInitialKey ); } // Create default drawing objects via keyboard |