diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 12:31:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 14:58:51 +0200 |
commit | 29489b33b435683021b72cb2bce27aba8cb7a430 (patch) | |
tree | 8e4e1c59d56d5ed0d0ca4d088419067041e4553a /sc | |
parent | a4244c0f05b95ded277a3a7ed217bf0451daa996 (diff) |
loplugin:flatten
Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/column2.cxx | 28 | ||||
-rw-r--r-- | sc/source/filter/oox/autofilterbuffer.cxx | 42 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 50 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 32 | ||||
-rw-r--r-- | sc/source/ui/dbgui/filtdlg.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 74 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 52 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 30 |
9 files changed, 182 insertions, 182 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 86460ac576cc..b86da08c6a38 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -661,21 +661,21 @@ class MaxStrLenFinder ScCellFormat::GetString( rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), mrDoc); - if (aValStr.getLength() > mnMaxLen) + if (aValStr.getLength() <= mnMaxLen) + return; + + switch (rCell.meType) { - switch (rCell.meType) - { - case CELLTYPE_NONE: - case CELLTYPE_VALUE: - mnMaxLen = aValStr.getLength(); - maMaxLenStr = aValStr; - break; - case CELLTYPE_EDIT: - case CELLTYPE_STRING: - case CELLTYPE_FORMULA: - default: - checkLineBreak(aValStr); - } + case CELLTYPE_NONE: + case CELLTYPE_VALUE: + mnMaxLen = aValStr.getLength(); + maMaxLenStr = aValStr; + break; + case CELLTYPE_EDIT: + case CELLTYPE_STRING: + case CELLTYPE_FORMULA: + default: + checkLineBreak(aValStr); } } diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index 951347b62fcd..211511e52367 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -820,30 +820,30 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa } // set sort parameter if we have detected it - if (aParam.bUserDef) - { - 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); - - aParam.maKeyState[0].bDoSort = true; - aParam.maKeyState[0].bAscending = false; - aParam.maKeyState[0].nField += nStartPos; - } + if (!aParam.bUserDef) + return; - ScDocument& rDoc = getScDocument(); - ScDBData* pDBData = rDoc.GetDBAtArea( - nSheet, - maRange.aStart.Col(), maRange.aStart.Row(), - maRange.aEnd.Col(), maRange.aEnd.Row()); + 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); - if (pDBData) - pDBData->SetSortParam(aParam); - else - OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); + 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()); + + if (pDBData) + pDBData->SetSortParam(aParam); + else + OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); } AutoFilterBuffer::AutoFilterBuffer( const WorkbookHelper& rHelper ) : diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 97c86b34b00d..01f2b9e9d1d6 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1735,36 +1735,36 @@ void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName) EditView* pEditView = pTopView ? pTopView : pTableView; - if (pActiveViewSh && pEditView) + if (!pActiveViewSh || !pEditView) + return; + + bool bEdit = false; + OUString aFormula; + const EditEngine* pEditEngine = pEditView->GetEditEngine(); + if (pEditEngine) { - bool bEdit = false; - OUString aFormula; - const EditEngine* pEditEngine = pEditView->GetEditEngine(); - if (pEditEngine) - { - aFormula = pEditEngine->GetText(0); - bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); - } + aFormula = pEditEngine->GetText(0); + bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); + } - if ( !bEdit ) - { - OUString aNewFormula('='); - if ( aFormula.startsWith("=") ) - aNewFormula = aFormula; + if ( !bEdit ) + { + OUString aNewFormula('='); + if ( aFormula.startsWith("=") ) + aNewFormula = aFormula; - InputReplaceSelection( aNewFormula ); - } + InputReplaceSelection( aNewFormula ); + } - if (pFormulaData) - { - OUString aNew; - ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); + if (pFormulaData) + { + OUString aNew; + ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); - if (aPos != pFormulaData->end()) - { - miAutoPosFormula = aPos; - PasteFunctionData(); - } + if (aPos != pFormulaData->end()) + { + miAutoPosFormula = aPos; + PasteFunctionData(); } } } diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 1747639c611a..32412c39b1be 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1314,25 +1314,25 @@ void ScTextWnd::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangl else WeldEditView::Paint(rRenderContext, rRect); - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + bool bIsFocused = false; + if (HasFocus()) { - bool bIsFocused = false; - if (HasFocus()) - { - vcl::Cursor* pCursor = m_xEditView->GetCursor(); - if (pCursor) - bIsFocused = true; - } + vcl::Cursor* pCursor = m_xEditView->GetCursor(); + if (pCursor) + bIsFocused = true; + } - VclPtr<vcl::Window> pParent = mrGroupBar.GetVclParent().GetParentWithLOKNotifier(); - if (!pParent) - return; + VclPtr<vcl::Window> pParent = mrGroupBar.GetVclParent().GetParentWithLOKNotifier(); + if (!pParent) + return; - const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back("visible", bIsFocused ? "true" : "false"); - pNotifier->notifyWindow(pParent->GetLOKWindowId(), "cursor_visible", aItems); - } + const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); + std::vector<vcl::LOKPayloadItem> aItems; + aItems.emplace_back("visible", bIsFocused ? "true" : "false"); + pNotifier->notifyWindow(pParent->GetLOKWindowId(), "cursor_visible", aItems); } EditView* ScTextWnd::GetEditView() const diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 06df4ae300f2..525e74c4a915 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -1224,19 +1224,19 @@ IMPL_LINK( ScFilterDlg, CheckBoxHdl, weld::Toggleable&, rBox, void ) UpdateHdrInValueList( 4 ); } - if ( &rBox == m_xBtnCase.get() ) // Complete value list - { - m_EntryLists.clear(); - UpdateValueList( 1 ); // current text is recorded - UpdateValueList( 2 ); - UpdateValueList( 3 ); - UpdateValueList( 4 ); - - UpdateColorList( 1 ); - UpdateColorList( 2 ); - UpdateColorList( 3 ); - UpdateColorList( 4 ); - } + if ( &rBox != m_xBtnCase.get() ) // Complete value list + return; + + m_EntryLists.clear(); + UpdateValueList( 1 ); // current text is recorded + UpdateValueList( 2 ); + UpdateValueList( 3 ); + UpdateValueList( 4 ); + + UpdateColorList( 1 ); + UpdateColorList( 2 ); + UpdateColorList( 3 ); + UpdateColorList( 4 ); } IMPL_LINK( ScFilterDlg, ValModifyHdl, weld::ComboBox&, rEd, void ) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 311a59d8dbcd..9282acef724d 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3132,23 +3132,23 @@ void ScGridWindow::Command( const CommandEvent& rCEvt ) } } - if (!bDone) - { - // tdf#140361 at this context menu popup time get what the - // DisableEditHyperlink would be for this position - bool bShouldDisableEditHyperlink = mrViewData.GetViewShell()->ShouldDisableEditHyperlink(); + if (bDone) + return; - SfxDispatcher::ExecutePopup( this, &aMenuPos ); + // tdf#140361 at this context menu popup time get what the + // DisableEditHyperlink would be for this position + bool bShouldDisableEditHyperlink = mrViewData.GetViewShell()->ShouldDisableEditHyperlink(); - if (!bShouldDisableEditHyperlink) - { - SfxBindings& rBindings = mrViewData.GetBindings(); - // tdf#140361 set what the menu popup state for this was - mrViewData.GetViewShell()->EnableEditHyperlink(); - // ensure moAtContextMenu_DisableEditHyperlink will be cleared - // in the case that EditHyperlink is not dispatched by the menu - rBindings.Invalidate(SID_EDIT_HYPERLINK); - } + SfxDispatcher::ExecutePopup( this, &aMenuPos ); + + if (!bShouldDisableEditHyperlink) + { + SfxBindings& rBindings = mrViewData.GetBindings(); + // tdf#140361 set what the menu popup state for this was + mrViewData.GetViewShell()->EnableEditHyperlink(); + // ensure moAtContextMenu_DisableEditHyperlink will be cleared + // in the case that EditHyperlink is not dispatched by the menu + rBindings.Invalidate(SID_EDIT_HYPERLINK); } } diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9ee886d1ad50..07b73255c5eb 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -2398,44 +2398,44 @@ void ScGridWindow::initiatePageBreaks() IMPL_LINK(ScGridWindow, InitiatePageBreaksTimer, Timer*, pTimer, void) { - if (pTimer == &maShowPageBreaksTimer) - { - const ScViewOptions& rOpts = mrViewData.GetOptions(); - const bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS); - // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page - // breaks is enabled, breaks should be visible. If the document is - // opened the first time or a tab is activated the first time, the - // breaks are not calculated yet, so this initialization is done here. - if (bPage) + if (pTimer != &maShowPageBreaksTimer) + return; + + const ScViewOptions& rOpts = mrViewData.GetOptions(); + const bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS); + // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page + // breaks is enabled, breaks should be visible. If the document is + // opened the first time or a tab is activated the first time, the + // breaks are not calculated yet, so this initialization is done here. + if (bPage) + { + const SCTAB nCurrentTab = mrViewData.GetTabNo(); + ScDocument& rDoc = mrViewData.GetDocument(); + const Size aPageSize = rDoc.GetPageSize(nCurrentTab); + // Do not attempt to calculate a page size here if it is empty if + // that involves counting pages. + // An earlier implementation did + // ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); + // rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); + // which resulted in tremendous waiting times after having loaded + // larger documents i.e. imported from CSV, in which UI is entirely + // blocked. All time is spent under ScPrintFunc::CountPages() in + // ScTable::ExtendPrintArea() in the loop that calls + // MaybeAddExtraColumn() to do stuff for each text string content + // cell (each row in each column). Maybe that can be optimized, or + // obtaining page size without that overhead would be possible, but + // as is calling that from here is a no-no so this is a quick + // disable things. + if (!aPageSize.IsEmpty()) { - const SCTAB nCurrentTab = mrViewData.GetTabNo(); - ScDocument& rDoc = mrViewData.GetDocument(); - const Size aPageSize = rDoc.GetPageSize(nCurrentTab); - // Do not attempt to calculate a page size here if it is empty if - // that involves counting pages. - // An earlier implementation did - // ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); - // rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); - // which resulted in tremendous waiting times after having loaded - // larger documents i.e. imported from CSV, in which UI is entirely - // blocked. All time is spent under ScPrintFunc::CountPages() in - // ScTable::ExtendPrintArea() in the loop that calls - // MaybeAddExtraColumn() to do stuff for each text string content - // cell (each row in each column). Maybe that can be optimized, or - // obtaining page size without that overhead would be possible, but - // as is calling that from here is a no-no so this is a quick - // disable things. - if (!aPageSize.IsEmpty()) - { - ScDocShell* pDocSh = mrViewData.GetDocShell(); - const bool bModified = pDocSh->IsModified(); - // Even setting the same size sets page size valid, so - // UpdatePageBreaks() actually does something. - rDoc.SetPageSize( nCurrentTab, aPageSize); - rDoc.UpdatePageBreaks(nCurrentTab); - pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid); - pDocSh->SetModified(bModified); - } + ScDocShell* pDocSh = mrViewData.GetDocShell(); + const bool bModified = pDocSh->IsModified(); + // Even setting the same size sets page size valid, so + // UpdatePageBreaks() actually does something. + rDoc.SetPageSize( nCurrentTab, aPageSize); + rDoc.UpdatePageBreaks(nCurrentTab); + pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid); + pDocSh->SetModified(bModified); } } } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index d1238009fa89..098d66048e91 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -3226,34 +3226,34 @@ void ScOutputData::ShowClipMarks( DrawEditParam& rParam, tools::Long nEngineWidt // with the default right position of the text. // Only with automatic line breaks, to avoid having to find // the cells with the horizontal end of the text again. - if (nEngineWidth - aCellSize.Width() > 100 && rParam.mbBreak && bMarkClipped - && (rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1)) + if (nEngineWidth - aCellSize.Width() <= 100 || !rParam.mbBreak || !bMarkClipped + || (rParam.mpEngine->GetParagraphCount() <= 1 && rParam.mpEngine->GetLineCount(0) <= 1)) + return; + + CellInfo* pClipMarkCell = nullptr; + if (bMerged) { - CellInfo* pClipMarkCell = nullptr; - if (bMerged) - { - // anywhere in the merged area... - SCCOL nClipX = (rParam.mnX < nX1) ? nX1 : rParam.mnX; - pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX + 1]; - } - else - pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX + 1]; + // anywhere in the merged area... + SCCOL nClipX = (rParam.mnX < nX1) ? nX1 : rParam.mnX; + pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX + 1]; + } + else + pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX + 1]; - bAnyClipped = true; - bVertical = true; - const tools::Long nMarkPixel = static_cast<tools::Long>(SC_CLIPMARK_SIZE * mnPPTX); - if (bTop) - { - pClipMarkCell->nClipMark |= ScClipMark::Top; - if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) - aAreaParam.maClipRect.AdjustTop(+nMarkPixel); - } - else - { - pClipMarkCell->nClipMark |= ScClipMark::Bottom; - if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) - aAreaParam.maClipRect.AdjustBottom(-nMarkPixel); - } + bAnyClipped = true; + bVertical = true; + const tools::Long nMarkPixel = static_cast<tools::Long>(SC_CLIPMARK_SIZE * mnPPTX); + if (bTop) + { + pClipMarkCell->nClipMark |= ScClipMark::Top; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustTop(+nMarkPixel); + } + else + { + pClipMarkCell->nClipMark |= ScClipMark::Bottom; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustBottom(-nMarkPixel); } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index cf43eee2403a..60cd39fd03fd 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -3205,24 +3205,24 @@ void ScViewData::CalcPPT() } } - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + SCTAB nTabCount = maTabData.size(); + bool bResetWidths = (nPPTX != nOldPPTX); + bool bResetHeights = (nPPTY != nOldPPTY); + for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx) { - SCTAB nTabCount = maTabData.size(); - bool bResetWidths = (nPPTX != nOldPPTX); - bool bResetHeights = (nPPTY != nOldPPTY); - for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx) - { - if (!maTabData[nTabIdx]) - continue; + if (!maTabData[nTabIdx]) + continue; - if (bResetWidths) - if (auto* pWHelper = GetLOKWidthHelper(nTabIdx)) - pWHelper->invalidateByPosition(0L); + if (bResetWidths) + if (auto* pWHelper = GetLOKWidthHelper(nTabIdx)) + pWHelper->invalidateByPosition(0L); - if (bResetHeights) - if (auto* pHHelper = GetLOKHeightHelper(nTabIdx)) - pHHelper->invalidateByPosition(0L); - } + if (bResetHeights) + if (auto* pHHelper = GetLOKHeightHelper(nTabIdx)) + pHHelper->invalidateByPosition(0L); } } |