From e67657d5211f6e95ddf8bd621108608573b00d5d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Aug 2020 13:32:43 +0200 Subject: loplugin:simplifybool more look for expressions like !(a && !b) which can be expanded out Change-Id: I72515a9638762b050f9a258c08da39ebfa2ef8e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100579 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/core/data/attarray.cxx | 2 +- sc/source/core/data/documen5.cxx | 2 +- sc/source/core/data/dptabres.cxx | 6 +++--- sc/source/core/data/table3.cxx | 2 +- sc/source/core/tool/chgtrack.cxx | 2 +- sc/source/filter/excel/xepivot.cxx | 2 +- sc/source/filter/oox/autofilterbuffer.cxx | 2 +- sc/source/filter/oox/formulabase.cxx | 2 +- sc/source/filter/oox/pivottablebuffer.cxx | 2 +- sc/source/filter/oox/querytablebuffer.cxx | 2 +- sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx | 2 +- sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 2 +- sc/source/filter/xml/XMLStylesExportHelper.cxx | 4 ++-- sc/source/filter/xml/XMLTableShapeResizer.cxx | 2 +- sc/source/filter/xml/xmlcelli.cxx | 6 +++--- sc/source/filter/xml/xmlexprt.cxx | 2 +- sc/source/ui/Accessibility/AccessibleContextBase.cxx | 2 +- sc/source/ui/Accessibility/AccessibleDocument.cxx | 2 +- sc/source/ui/docshell/docsh2.cxx | 4 ++-- sc/source/ui/formdlg/formula.cxx | 2 +- sc/source/ui/unoobj/cellsuno.cxx | 4 ++-- sc/source/ui/view/cellsh.cxx | 2 +- sc/source/ui/view/output.cxx | 2 +- sc/source/ui/view/select.cxx | 2 +- sc/source/ui/view/tabview2.cxx | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 8174eeb84bbb..201c7698d9a6 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -52,7 +52,7 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr nTab( nNewTab ), pDocument( pDoc ) { - if ( !(nCol != -1 && pDefaultColAttrArray && !pDefaultColAttrArray->mvData.empty())) + if ( nCol == -1 || !pDefaultColAttrArray || pDefaultColAttrArray->mvData.empty() ) return; ScAddress aAdrStart( nCol, 0, nTab ); diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx index 598643b7f473..2702e1e65e54 100644 --- a/sc/source/core/data/documen5.cxx +++ b/sc/source/core/data/documen5.cxx @@ -371,7 +371,7 @@ void ScDocument::RestoreChartListener( const OUString& rName ) uno::Reference< util::XCloseable > xComponent = xObject->getComponent(); uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY ); uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY ); - if ( !(xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider())) + if ( !xChartDoc.is() || !xReceiver.is() || xChartDoc->hasInternalDataProvider() ) return; const uno::Sequence aRepresentations( xReceiver->getUsedRangeRepresentations() ); diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 8519edb13122..0fa8647cecb1 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -1455,7 +1455,7 @@ void ScDPResultMember::FillMemberResults( long nUserSubStart; long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( !(nUserSubCount && pChildDimension && !bSubTotalInTitle) ) + if ( !nUserSubCount || !pChildDimension || bSubTotalInTitle ) return; long nMemberMeasure = nMeasure; @@ -1581,7 +1581,7 @@ void ScDPResultMember::FillDataResults( long nUserSubStart; long nUserSubCount = GetSubTotalCount(&nUserSubStart); - if ( !(nUserSubCount || !bHasChild) ) + if ( !nUserSubCount && bHasChild ) return; // Calculate at least automatic if no subtotals are selected, @@ -2093,7 +2093,7 @@ void ScDPDataMember::FillDataRow( long nUserSubStart; long nUserSubCount = pRefMember->GetSubTotalCount(&nUserSubStart); - if ( !(nUserSubCount || !bHasChild) ) + if ( !nUserSubCount && bHasChild ) return; // Calculate at least automatic if no subtotals are selected, diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 2ce838df8477..449a4a900a7e 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -3001,7 +3001,7 @@ public: if (pEntry) { SvNumFormatType nNumFmtType = pEntry->GetType(); - if (!((nNumFmtType & SvNumFormatType::DATE) && !(nNumFmtType & SvNumFormatType::TIME))) + if (!(nNumFmtType & SvNumFormatType::DATE) || (nNumFmtType & SvNumFormatType::TIME)) rItem.meType = ScQueryEntry::ByValue; // not a date only } else diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 4f12df13ec42..ca79af8606d6 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -3217,7 +3217,7 @@ void ScChangeTrack::MergePrepare( const ScChangeAction* pFirstMerge, bool bShare void ScChangeTrack::MergeOwn( ScChangeAction* pAct, sal_uLong nFirstMerge, bool bShared ) { // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong - if ( !(bShared || !ScChangeTrack::MergeIgnore( *pAct, nFirstMerge )) ) + if ( !bShared && ScChangeTrack::MergeIgnore( *pAct, nFirstMerge ) ) return; SetMergeState( SC_CTMS_OWN ); diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx index 8200d281e501..0d8909b01793 100644 --- a/sc/source/filter/excel/xepivot.cxx +++ b/sc/source/filter/excel/xepivot.cxx @@ -1335,7 +1335,7 @@ void XclExpPivotTable::SetFieldPropertiesFromDim( const ScDPSaveDimension& rSave bool bDataLayout = nFieldIdx == EXC_SXIVD_DATA; bool bMultiData = maDataFields.size() > 1; - if( !(!bDataLayout || bMultiData) ) + if( bDataLayout && !bMultiData ) return; switch( eOrient ) diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index 6cb33c4d2658..1136425465eb 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -666,7 +666,7 @@ void AutoFilterBuffer::finalizeImport( sal_Int16 nSheet ) // first, try to create an auto filter bool bHasAutoFilter = finalizeImport( xDatabaseRange ); // no success: try to create an advanced filter - if( !(!bHasAutoFilter && xDatabaseRange.is()) ) + if( bHasAutoFilter || !xDatabaseRange.is() ) return; // the built-in defined name 'Criteria' must exist diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index afd418acaf85..f6553af07cd9 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -1687,7 +1687,7 @@ void FormulaProcessorBase::convertStringToStringList( ApiTokenSequence& orTokens, sal_Unicode cStringSep, bool bTrimLeadingSpaces ) const { OUString aString; - if( !(extractString( aString, orTokens ) && !aString.isEmpty()) ) + if( !extractString( aString, orTokens ) || aString.isEmpty() ) return; ::std::vector< ApiToken > aNewTokens; diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx index 23889b790774..2717fff2a610 100644 --- a/sc/source/filter/oox/pivottablebuffer.cxx +++ b/sc/source/filter/oox/pivottablebuffer.cxx @@ -1208,7 +1208,7 @@ void PivotTable::finalizeImport() return; mpPivotCache = getPivotCaches().importPivotCacheFragment( maDefModel.mnCacheId ); - if( !(mpPivotCache && mpPivotCache->isValidDataSource() && !maDefModel.maName.isEmpty()) ) + if( !mpPivotCache || !mpPivotCache->isValidDataSource() || maDefModel.maName.isEmpty() ) return; // clear destination area of the original pivot table diff --git a/sc/source/filter/oox/querytablebuffer.cxx b/sc/source/filter/oox/querytablebuffer.cxx index fc1110406dd8..8d5ec052d139 100644 --- a/sc/source/filter/oox/querytablebuffer.cxx +++ b/sc/source/filter/oox/querytablebuffer.cxx @@ -219,7 +219,7 @@ void QueryTable::finalizeImport() // check that valid web query properties exist const WebPrModel* pWebPr = xConnection->getModel().mxWebPr.get(); - if( !(pWebPr && !pWebPr->mbXml) ) + if( !pWebPr || pWebPr->mbXml ) return; OUString aFileUrl = getBaseFilter().getAbsoluteUrl( pWebPr->maUrl ); diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index 7eddf7c25ece..02e0b7b2cbec 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -507,7 +507,7 @@ void ScChangeTrackingExportHelper::AddDeletionAttributes(const ScChangeActionDel return; rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE, OUString::number(nStartSheet)); - if (!(pDelAction->IsMultiDelete() && !pDelAction->GetDx() && !pDelAction->GetDy())) + if (!pDelAction->IsMultiDelete() || pDelAction->GetDx() || pDelAction->GetDy()) return; const ScChangeAction* p = pDelAction->GetNext(); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index dc1a93a7c913..c3d505143536 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -653,7 +653,7 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio assert(dynamic_cast(pChangeAction)); ScChangeActionContent* pChangeActionContent = static_cast(pChangeAction); - if (!(pChangeActionContent->IsTopContent() && !pChangeActionContent->IsDeletedIn())) + if (!pChangeActionContent->IsTopContent() || pChangeActionContent->IsDeletedIn()) return; sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2; diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index 5a66ece4bd7d..bdf2e4cf7972 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -114,8 +114,8 @@ void ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny, bool bShowInputMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(gsSHOWINP)); sheet::ValidationType aValidationType; xPropertySet->getPropertyValue(gsTYPE) >>= aValidationType; - if (!(bShowErrorMessage || bShowInputMessage || aValidationType != sheet::ValidationType_ANY || - !sErrorMessage.isEmpty() || !sErrorTitle.isEmpty() || !sInputMessage.isEmpty() || !sInputTitle.isEmpty())) + if (!bShowErrorMessage && !bShowInputMessage && aValidationType == sheet::ValidationType_ANY && + sErrorMessage.isEmpty() && sErrorTitle.isEmpty() && sInputMessage.isEmpty() && sInputTitle.isEmpty()) return; ScMyValidation aValidation; diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx index 84577bcaf2e6..b5c3b56e4f8e 100644 --- a/sc/source/filter/xml/XMLTableShapeResizer.cxx +++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx @@ -117,7 +117,7 @@ void ScMyOLEFixer::AddOLE(const uno::Reference & rShape, void ScMyOLEFixer::FixupOLEs() { - if (!(!aShapes.empty() && rImport.GetModel().is())) + if (aShapes.empty() || !rImport.GetModel().is()) return; OUString sPersistName ("PersistName"); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index cb8e50a1acc0..1551fb9fbb6f 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -947,7 +947,7 @@ void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos) void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition ) { ScDocument* pDoc = rXMLImport.GetDocument(); - if( !(pDoc && cellExists(*pDoc, rPosition) && pDetectiveObjVec && !pDetectiveObjVec->empty()) ) + if( !pDoc || !cellExists(*pDoc, rPosition) || !pDetectiveObjVec || pDetectiveObjVec->empty() ) return; LockSolarMutex(); @@ -969,8 +969,8 @@ void ScXMLTableRowCellContext::SetDetectiveObj( const ScAddress& rPosition ) void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition ) { ScDocument* pDoc = rXMLImport.GetDocument(); - if( !(pDoc && cellExists(*pDoc, rPosition) && pCellRangeSource && !pCellRangeSource->sSourceStr.isEmpty() && - !pCellRangeSource->sFilterName.isEmpty() && !pCellRangeSource->sURL.isEmpty()) ) + if( !pDoc || !cellExists(*pDoc, rPosition) || !pCellRangeSource || pCellRangeSource->sSourceStr.isEmpty() || + pCellRangeSource->sFilterName.isEmpty() || pCellRangeSource->sURL.isEmpty() ) return; LockSolarMutex(); diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index cf05f7814ac9..1c35e014a6c8 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3510,7 +3510,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) void ScXMLExport::WriteTableShapes() { ScMyTableShapes* pTableShapes(pSharedData->GetTableShapes()); - if (!(pTableShapes && !(*pTableShapes)[nCurrentTable].empty())) + if (!pTableShapes || (*pTableShapes)[nCurrentTable].empty()) return; OSL_ENSURE(pTableShapes->size() > static_cast(nCurrentTable), "wrong Table"); diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx index 14d660c7fd91..f775a1137459 100644 --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx @@ -384,7 +384,7 @@ void SAL_CALL return; SolarMutexGuard aGuard; - if (!(!IsDefunc() && mnClientId)) + if (IsDefunc() || !mnClientId) return; sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 737590610bf5..836e63e0c28b 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -684,7 +684,7 @@ void ScChildrenShapes::Select(sal_Int32 nIndex) return; uno::Reference xShape; - if (!(!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable)) + if (IsSelected(nIndex, xShape) || !maZOrderedShapes[nIndex]->bSelectable) return; uno::Reference xShapes(mpViewShell->getSelectedXShapes()); diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index f9aca0c64d6c..1c819a021ae2 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -114,8 +114,8 @@ void ScDocShell::InitItems() PutItem( SvxColorListItem( XColorList::GetStdColorList(), SID_COLOR_TABLE ) ); } - if (!(!utl::ConfigManager::IsFuzzing() && - (!m_aDocument.GetForbiddenCharacters() || !m_aDocument.IsValidAsianCompression() || !m_aDocument.IsValidAsianKerning()))) + if (utl::ConfigManager::IsFuzzing() || + (m_aDocument.GetForbiddenCharacters() && m_aDocument.IsValidAsianCompression() && m_aDocument.IsValidAsianKerning())) return; // get settings from SvxAsianConfig diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index c21a8d859cbc..4c756ca3b646 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -484,7 +484,7 @@ bool ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const { // not allowed: different from this doc, and no name // pDocSh is always a ScDocShell - return !(pDocSh && &static_cast(pDocSh)->GetDocument() != m_pDoc && !pDocSh->HasName()); // everything else is allowed + return !pDocSh || &static_cast(pDocSh)->GetDocument() == m_pDoc || pDocSh->HasName(); // everything else is allowed } void ScFormulaDlg::SetActive() diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index b4b9e6498c21..bf47a5608406 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1680,7 +1680,7 @@ ScDocument* ScCellRangesBase::GetDocument() const void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR) { - if ( !(!pDocShell && pDocSh) ) + if ( pDocShell || !pDocSh ) return; pDocShell = pDocSh; @@ -3238,7 +3238,7 @@ void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Refe chart::XChartDataChangeEventListener >& aListener ) { SolarMutexGuard aGuard; - if ( !(pDocShell && !aRanges.empty()) ) + if ( !pDocShell || aRanges.empty() ) return; //! test for duplicates ? diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index ff7e37538c08..3885415df7a6 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -271,7 +271,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) //! is not called, when protected AND matrix, we will have //! to live with this... is caught in Copy-Routine, otherwise //! work is to be done once more - if ( !(!bEditable && bOnlyNotBecauseOfMatrix) ) + if ( bEditable || !bOnlyNotBecauseOfMatrix ) bNeedEdit = false; // allowed when protected/ReadOnly bDisable = GetObjectShell()->isContentExtractionLocked(); break; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 1a73ffb7169e..046c70e4b4b1 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2068,7 +2068,7 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, if (bRight) mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) ); } - if ( !(bHandle && bRight && bBottom && !comphelper::LibreOfficeKit::isActive()) ) + if ( !bHandle || !bRight || !bBottom || comphelper::LibreOfficeKit::isActive() ) return; mpDev->SetLineColor( rColor ); diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index e1463ccebf53..3aa42c29a77f 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -166,7 +166,7 @@ void ScViewFunctionSet::BeginDrag() ScMarkData& rMark = pViewData->GetMarkData(); rMark.MarkToSimple(); - if ( !(rMark.IsMarked() && !rMark.IsMultiMarked()) ) + if ( !rMark.IsMarked() || rMark.IsMultiMarked() ) return; ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 99eb33fa9670..7442cb261acb 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -411,7 +411,7 @@ void ScTabView::DoneBlockMode( bool bContinue ) // because the other engine does not have any anchor. // bMoveIsShift prevents the selection to be canceled. - if (!(IsBlockMode() && !bMoveIsShift)) + if (!IsBlockMode() || bMoveIsShift) return; ScMarkData& rMark = aViewData.GetMarkData(); -- cgit