diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-24 21:55:10 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-25 09:13:12 +0100 |
commit | f2cd9c0c789b5825b4d5bb84b352d089e231e527 (patch) | |
tree | 95f6ecfaf25231ee4de3320995263780cd655792 | |
parent | e1cbd518118a5f2889213e5725e0e0a3c133de5d (diff) |
tdf#120703 PVS: V560 A part of conditional expression is always true/false
Change-Id: If173f42302553b164267909a0a3156bb25a6d558
Reviewed-on: https://gerrit.libreoffice.org/63957
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
37 files changed, 95 insertions, 114 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 858812193b8f..871545f55d9b 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -558,7 +558,7 @@ void ODbaseTable::ReadMemoHeader() (*m_pMemoStream).ReadUInt16( m_aMemoHeader.db_size ); if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size != 512) // 1 is also for dBase 3 m_aMemoHeader.db_typ = MemodBaseIV; - else if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size == 512) + else if (m_aMemoHeader.db_size == 512) { // There are files using size specification, though they are dBase-files char sHeader[4]; diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index aab666131456..3df5480422e8 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1305,12 +1305,11 @@ void EditView::ChangeFontSize( bool bGrow, const FontList* pFontList ) bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList ) { - static const sal_uInt16 gFontSizeWichMap[] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL, 0 }; - - const SvxFontItem* pFontItem = &rSet.Get( EE_CHAR_FONTINFO ); - if( !pFontItem || !pFontList ) + if (!pFontList) return false; + static const sal_uInt16 gFontSizeWichMap[] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL, 0 }; + const SvxFontItem& rFontItem = rSet.Get(EE_CHAR_FONTINFO); bool bRet = false; const sal_uInt16* pWhich = gFontSizeWichMap; @@ -1321,7 +1320,7 @@ bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFo const MapUnit eUnit = rSet.GetPool()->GetMetric( *pWhich ); nHeight = OutputDevice::LogicToLogic(nHeight * 10, eUnit, MapUnit::MapPoint); - FontMetric aFontMetric = pFontList->Get( pFontItem->GetFamilyName(), pFontItem->GetStyleName() ); + FontMetric aFontMetric = pFontList->Get( rFontItem.GetFamilyName(), rFontItem.GetStyleName() ); const sal_IntPtr* pAry = pFontList->GetSizeAry( aFontMetric ); if( bGrow ) diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx index 12fb9e2e22ee..c9f16b6772df 100644 --- a/editeng/source/editeng/eehtml.cxx +++ b/editeng/source/editeng/eehtml.cxx @@ -625,7 +625,7 @@ void EditHTMLParser::ImpSetStyleSheet( sal_uInt16 nHLevel ) aItems.Put( aHeightItemCTL ); // Paragraph margins, when Heading: - if ( !nHLevel || ((nHLevel >= 1) && (nHLevel <= 6)) ) + if (nHLevel <= 6) { SvxULSpaceItem aULSpaceItem( EE_PARA_ULSPACE ); aULSpaceItem.SetUpper( static_cast<sal_uInt16>(OutputDevice::LogicToLogic( 42, MapUnit::Map10thMM, eUnit )) ); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index a41f5c1d9be9..151fbc3cb8ff 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -3905,7 +3905,7 @@ EscherBlibEntry::EscherBlibEntry( sal_uInt32 nPictureOffset, const GraphicObject sal_uInt32 nLen = static_cast<sal_uInt32>(rId.getLength()); const sal_Char* pData = rId.getStr(); GraphicType eType( rObject.GetType() ); - if ( nLen && pData && ( eType != GraphicType::NONE ) ) + if (nLen && (eType != GraphicType::NONE)) { mnIdentifier[ 0 ] = rtl_crc32( 0,pData, nLen ); mnIdentifier[ 1 ] = 0; diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index ccf4562fec9d..e98d34a549e1 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1360,11 +1360,10 @@ void FormulaCompiler::Factor() CurrentFactor pFacToken( this ); OpCode eOp = mpToken->GetOpCode(); - if( eOp == ocPush || eOp == ocColRowNameAuto || eOp == ocMatRef || - eOp == ocDBArea || eOp == ocTableRef - || (!mbJumpCommandReorder && ((eOp == ocName) || (eOp == ocDBArea) - || (eOp == ocTableRef) || (eOp == ocColRowName) || (eOp == ocBad))) - ) + if (eOp == ocPush || eOp == ocColRowNameAuto || eOp == ocMatRef || eOp == ocDBArea + || eOp == ocTableRef + || (!mbJumpCommandReorder && ((eOp == ocName) || (eOp == ocColRowName) || (eOp == ocBad))) + ) { PutCode( mpToken ); eOp = NextToken(); diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx index 2e83e322aa30..5a8b39f9f58f 100644 --- a/jvmfwk/source/fwkbase.cxx +++ b/jvmfwk/source/fwkbase.cxx @@ -365,9 +365,7 @@ OUString BootParams::getJREHome() "Using bootstrap parameter " UNO_JAVA_JFW_ENV_JREHOME " with JAVA_HOME = " << pJRE); } - else if (getMode() == JFW_MODE_DIRECT - && !bEnvJRE - && !bJRE) + else if (getMode() == JFW_MODE_DIRECT && !bJRE) { throw FrameworkException( JFW_E_CONFIGURATION, diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 3d4c2f3b279c..bb760bda8c57 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -584,7 +584,7 @@ void ScDocument::FillInfo( ++nArrRow; } - else if (bRowHidden && nLastHiddenRow >= 0) + else if (nLastHiddenRow >= 0) { nCurRow = nLastHiddenRow; if (nCurRow > nThisRow) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index aadb8e11b4d0..bdc832c55d39 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3219,7 +3219,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( if (!bHasRefs) { bHasColRowNames = (formula::FormulaTokenArrayPlainIterator(*pCode).GetNextColRowName() != nullptr); - bHasRefs = bHasRefs || bHasColRowNames; + bHasRefs = bHasColRowNames; } bool bOnRefMove = pCode->IsRecalcModeOnRefMove(); @@ -3347,7 +3347,7 @@ bool ScFormulaCell::UpdateReferenceOnMove( if (!bHasRefs) { bHasColRowNames = (formula::FormulaTokenArrayPlainIterator(*pCode).GetNextColRowName() != nullptr); - bHasRefs = bHasRefs || bHasColRowNames; + bHasRefs = bHasColRowNames; } bool bOnRefMove = pCode->IsRecalcModeOnRefMove(); diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx index 221f274f3038..c45bca6e26a8 100644 --- a/sc/source/filter/excel/excel.cxx +++ b/sc/source/filter/excel/excel.cxx @@ -217,10 +217,7 @@ ErrCode ScFormatFilterPluginImpl::ScExportExcel5( SfxMedium& rMedium, ScDocument OSL_ENSURE( pMedStrm, "::ScExportExcel5 - medium without output stream" ); if( !pMedStrm ) return SCERR_IMPORT_OPEN; // should not happen - ErrCode eRet = SCERR_IMPORT_UNKNOWN_BIFF; - if( eFormat == ExpBiff5 || eFormat == ExpBiff8 ) - eRet = lcl_ExportExcelBiff( rMedium, pDocument, pMedStrm, eFormat == ExpBiff8, eNach ); - + ErrCode eRet = lcl_ExportExcelBiff(rMedium, pDocument, pMedStrm, eFormat == ExpBiff8, eNach); return eRet; } diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 242c3fc57a75..d688bf7977d8 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -265,7 +265,7 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq ) SvxLinkInsertMode eMode = pHyper->GetInsertMode(); bool bDone = false; - if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) ) + if (eMode == HLINK_DEFAULT || eMode == HLINK_FIELD) { const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); if (pFieldItem) diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx index 65a3f0b843da..d0cd38557ec6 100644 --- a/sc/source/ui/drawfunc/fudraw.cxx +++ b/sc/source/ui/drawfunc/fudraw.cxx @@ -487,7 +487,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt) else { // move handle with index nHandleIndex - if(pHdl && (nX || nY)) + if (nX || nY) { // now move the Handle (nX, nY) Point aStartPoint(pHdl->GetPos()); diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index ba3896ecab2e..cc4fa6fa9ed9 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -393,7 +393,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq ) pStyleSheet = &(pStylePool->Make( aStyleName, eFamily, SfxStyleSearchBits::UserDefined ) ); - if ( pStyleSheet && pStyleSheet->HasParentSupport() ) + if (pStyleSheet->HasParentSupport()) pStyleSheet->SetParent(aRefName); } break; @@ -2180,7 +2180,7 @@ void ScFormatShell::GetAttrState( SfxItemSet& rSet ) rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); rSet.InvalidateItem(SID_FRAME_LINECOLOR); } - else if( !bCol && !bColDisable) // if no line available + else if (!bCol) // if no line available { aCol = COL_AUTO; rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx index 0b66bd873c96..3ae91c8cfb59 100644 --- a/scaddins/source/analysis/financial.cxx +++ b/scaddins/source/analysis/financial.cxx @@ -126,7 +126,7 @@ double SAL_CALL AnalysisAddIn::getCumprinc( double fRate, sal_Int32 nNumPeriods, { double fPmt, fPpmt; - if( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0.0 || nEndPer > nNumPeriods || nNumPeriods <= 0 || + if( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0.0 || nEndPer > nNumPeriods || fVal <= 0.0 || ( nPayType != 0 && nPayType != 1 ) ) throw css::lang::IllegalArgumentException(); @@ -164,7 +164,7 @@ double SAL_CALL AnalysisAddIn::getCumipmt( double fRate, sal_Int32 nNumPeriods, { double fPmt, fIpmt; - if( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0.0 || nEndPer > nNumPeriods || nNumPeriods <= 0 || + if( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0.0 || nEndPer > nNumPeriods || fVal <= 0.0 || ( nPayType != 0 && nPayType != 1 ) ) throw css::lang::IllegalArgumentException(); diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx index ac64ac4ccde1..ddf4866b95bb 100644 --- a/sd/source/ui/func/fupoor.cxx +++ b/sd/source/ui/func/fupoor.cxx @@ -722,7 +722,7 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt) else { // move handle with index nHandleIndex - if(pHdl && (nX || nY)) + if (nX || nY) { // now move the Handle (nX, nY) Point aStartPoint(pHdl->GetPos()); diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 365a3b57b21e..ec8cdbb1e273 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -632,22 +632,22 @@ IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab, void ) /// inherited from sd::ViewShell SdPage* DrawViewShell::getCurrentPage() const { - const sal_Int32 nPageCount = (meEditMode == EditMode::Page)? + const sal_uInt16 nPageCount = (meEditMode == EditMode::Page)? GetDoc()->GetSdPageCount(mePageKind): GetDoc()->GetMasterSdPageCount(mePageKind); - sal_Int32 nCurrentPage = maTabControl->GetCurPagePos(); - DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" ); - if( (nPageCount < 0) || (nCurrentPage>=nPageCount) ) + sal_uInt16 nCurrentPage = maTabControl->GetCurPagePos(); + DBG_ASSERT((nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!"); + if (nCurrentPage >= nPageCount) nCurrentPage = 0; // play safe here if (meEditMode == EditMode::Page) { - return GetDoc()->GetSdPage(static_cast<sal_uInt16>(nCurrentPage), mePageKind); + return GetDoc()->GetSdPage(nCurrentPage, mePageKind); } else // EditMode::MasterPage { - return GetDoc()->GetMasterSdPage(static_cast<sal_uInt16>(nCurrentPage), mePageKind); + return GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind); } } diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 7fc676643d6d..73c1e7253a67 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1836,7 +1836,7 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) { nLeft = static_cast<const SvxLongLRSpaceItem*>(pPoolItem)->GetLeft(); nRight = static_cast<const SvxLongLRSpaceItem*>(pPoolItem)->GetRight(); - if (nLeft != -1 && nUpper == -1) + if (nLeft != -1) { nUpper = pPage->GetUpperBorder(); nLower = pPage->GetLowerBorder(); @@ -1851,7 +1851,7 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) { nUpper = static_cast<const SvxLongULSpaceItem*>(pPoolItem)->GetUpper(); nLower = static_cast<const SvxLongULSpaceItem*>(pPoolItem)->GetLower(); - if (nLeft == -1 && nUpper != -1) + if (nUpper != -1) { nLeft = pPage->GetLeftBorder(); nRight = pPage->GetRightBorder(); diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index de870e3370bd..9c5408111185 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -491,7 +491,7 @@ void ExtendedColorConfig_Impl::UnlockBroadcast() m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != nullptr; if ( m_bBroadcastWhenUnlocked ) { - if ( ExtendedColorConfig::m_pImpl && ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled ) + if (ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled) { m_bBroadcastWhenUnlocked = false; ExtendedColorConfig::m_pImpl->Broadcast(SfxHint(SfxHintId::ColorsChanged)); diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 6db43dd3c449..15a419881e30 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1218,8 +1218,7 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev()); else {// find OutDev - SdrPageView* pPageView = m_pView->GetSdrPageView(); - if( pPageView && !pOutDev ) + if (SdrPageView* pPageView = m_pView->GetSdrPageView()) { // const SdrPageViewWinList& rWinList = pPageView->GetWinList(); // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows(); @@ -1368,8 +1367,7 @@ SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescr pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev()); else {// find OutDev - SdrPageView* pPageView = m_pView->GetSdrPageView(); - if( pPageView && !pOutDev ) + if (SdrPageView* pPageView = m_pView->GetSdrPageView()) { // const SdrPageViewWinList& rWinList = pPageView->GetWinList(); // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows(); diff --git a/svx/source/gallery2/galexpl.cxx b/svx/source/gallery2/galexpl.cxx index ce8dea401515..1f5122fd97b5 100644 --- a/svx/source/gallery2/galexpl.cxx +++ b/svx/source/gallery2/galexpl.cxx @@ -213,7 +213,7 @@ bool GalleryExplorer::GetSdrObj( const OUString& rThemeName, sal_uInt32 nSdrMode if( nActPos++ == nSdrModelPos ) { if( pModel ) - bRet = bRet || pTheme->GetModel( i, *pModel ); + bRet = pTheme->GetModel(i, *pModel); if( pThumb ) bRet = bRet || pTheme->GetThumb( i, *pThumb ); diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index 577db70611ff..659acaf4e97a 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -65,15 +65,13 @@ namespace ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks ) { - for(const auto & rLink : rLinks) + for (const auto& rLinkIter : rLinks) { - ::sfx2::SvBaseLink* pLnk = &(*rLink); - if( pLnk && - ( OBJECT_CLIENT_GRF == pLnk->GetObjType() || - OBJECT_CLIENT_FILE == pLnk->GetObjType() ) && - dynamic_cast<const SwBaseLink*>( pLnk) != nullptr ) + ::sfx2::SvBaseLink& rLnk = *rLinkIter; + if ((OBJECT_CLIENT_GRF == rLnk.GetObjType() || OBJECT_CLIENT_FILE == rLnk.GetObjType()) + && dynamic_cast<const SwBaseLink*>(&rLnk) != nullptr) { - tools::SvRef<sfx2::SvBaseLink> xLink = pLnk; + tools::SvRef<sfx2::SvBaseLink> xLink(&rLnk); OUString sFName; sfx2::LinkManager::GetDisplayNames( xLink.get(), nullptr, &sFName ); @@ -81,7 +79,7 @@ namespace INetURLObject aURL( sFName ); if( INetProtocol::File == aURL.GetProtocol() || INetProtocol::Cid == aURL.GetProtocol() ) - return pLnk; + return &rLnk; } } return nullptr; diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 0fa554afb4be..70436dd66f2e 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -633,7 +633,7 @@ void SwDrawView::ObjOrderChanged( SdrObject* pObj, size_t nOldPos, // adjust loop counter if ( bMovedForward ) ++i; - else if ( !bMovedForward && i > 0 ) + else if (i > 0) --i; } diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 5da40eb2555b..f87679332f42 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -2213,22 +2213,22 @@ void SwEditShell::FillByEx(SwTextFormatColl* pColl) // Do NOT copy AutoNumRules into the template const SfxPoolItem* pItem; const SwNumRule* pRule = nullptr; - if( SfxItemState::SET == pSet->GetItemState( RES_BREAK, false ) || - SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC,false ) || - ( SfxItemState::SET == pSet->GetItemState( RES_PARATR_NUMRULE, - false, &pItem ) && nullptr != (pRule = GetDoc()->FindNumRulePtr( - static_cast<const SwNumRuleItem*>(pItem)->GetValue() )) && - pRule && pRule->IsAutoRule() ) - ) + if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false) + || SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false) + || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem) + && nullptr != (pRule = GetDoc()->FindNumRulePtr( + static_cast<const SwNumRuleItem*>(pItem)->GetValue())) + && pRule->IsAutoRule())) { SfxItemSet aSet( *pSet ); aSet.ClearItem( RES_BREAK ); aSet.ClearItem( RES_PAGEDESC ); - if( pRule || (SfxItemState::SET == pSet->GetItemState( RES_PARATR_NUMRULE, - false, &pItem ) && nullptr != (pRule = GetDoc()->FindNumRulePtr( - static_cast<const SwNumRuleItem*>(pItem)->GetValue() )) && - pRule && pRule->IsAutoRule() )) + if (pRule + || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem) + && nullptr != (pRule = GetDoc()->FindNumRulePtr( + static_cast<const SwNumRuleItem*>(pItem)->GetValue())) + && pRule->IsAutoRule())) aSet.ClearItem( RES_PARATR_NUMRULE ); if( aSet.Count() ) diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 80526cc81b5f..2495fc8de524 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -154,17 +154,16 @@ void SwEditShell::InsertTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet ) } /// update tables of content -void SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet ) +void SwEditShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet) { - OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOX) != nullptr, "no TOXBaseSection!" ); - SwTOXBaseSection* pTOX = const_cast<SwTOXBaseSection*>(static_cast<const SwTOXBaseSection*>(&rTOX)); - OSL_ENSURE(pTOX, "no current listing"); - if( pTOX && nullptr != pTOX->GetFormat()->GetSectionNode() ) + assert(dynamic_cast<const SwTOXBaseSection*>(&rTOX) && "no TOXBaseSection!"); + SwTOXBaseSection& rTOXSect = static_cast<SwTOXBaseSection&>(const_cast<SwTOXBase&>(rTOX)); + if (rTOXSect.GetFormat()->GetSectionNode()) { SwDoc* pMyDoc = GetDoc(); SwDocShell* pDocSh = pMyDoc->GetDocShell(); - bool bInIndex = pTOX == GetCurTOX(); + bool bInIndex = &rTOX == GetCurTOX(); SET_CURR_SHELL( this ); StartAllAction(); @@ -174,17 +173,17 @@ void SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet ) pMyDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::TOXCHANGE, nullptr); // create listing stub - pTOX->Update(pSet); + rTOXSect.Update(pSet); // correct Cursor if( bInIndex ) - pTOX->SetPosAtStartEnd( *GetCursor()->GetPoint() ); + rTOXSect.SetPosAtStartEnd(*GetCursor()->GetPoint()); // start formatting CalcLayout(); // insert page numbering - pTOX->UpdatePageNum(); + rTOXSect.UpdatePageNum(); pMyDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::TOXCHANGE, nullptr); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index d94ee5c8e6ad..107bb3feac55 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -978,7 +978,6 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr ) StartAllAction(); StartUndo(); - long nNewPage; SwRootFrame* pTmpRootFrame = GetLayout(); sal_uInt16 nMaxPage = pTmpRootFrame->GetPageNum(); bool bTmpAssert = false; @@ -989,13 +988,11 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr ) // FlyFormat is still valid, therefore process SwFormatAnchor aNewAnchor( pFormat->GetAnchor() ); - if ((RndStdIds::FLY_AT_PAGE != aNewAnchor.GetAnchorId()) || - 0 >= ( nNewPage = aNewAnchor.GetPageNum() + 1 ) ) - // Anchor has been changed or invalid page number, - // therefore: do not change! + if (RndStdIds::FLY_AT_PAGE != aNewAnchor.GetAnchorId()) + // Anchor has been changed, therefore: do not change! continue; - - if( sal_uInt16(nNewPage) > nMaxPage ) + sal_uInt16 nNewPage = aNewAnchor.GetPageNum() + 1; + if (nNewPage > nMaxPage) { if ( RES_DRAWFRMFMT == pFormat->Which() ) pFormat->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::PAGE_OUT_OF_BOUNDS)); @@ -1003,7 +1000,7 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr ) pFormat->DelFrames(); bTmpAssert = true; } - aNewAnchor.SetPageNum( sal_uInt16(nNewPage) ); + aNewAnchor.SetPageNum(nNewPage); mxDoc->SetAttr( aNewAnchor, *pFormat ); } } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index ae1259ce55ca..4abc8f16aea1 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -348,14 +348,14 @@ static bool LessY( Point const & aPt1, Point const & aPt2, bool bOld ) bool SwFEShell::MoveAnchor( SwMove nDir ) { - const SdrMarkList* pMrkList; - if( !Imp()->GetDrawView() || - nullptr == (pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList()) || - 1 != pMrkList->GetMarkCount()) + if (!Imp()->GetDrawView()) + return false; + const SdrMarkList& pMrkList = Imp()->GetDrawView()->GetMarkedObjectList(); + if (1 != pMrkList.GetMarkCount()) return false; SwFrame* pOld; SwFlyFrame* pFly = nullptr; - SdrObject *pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj(); + SdrObject *pObj = pMrkList.GetMark( 0 )->GetMarkedSdrObj(); if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj)) { pFly = pVirtO->GetFlyFrame(); @@ -1546,7 +1546,7 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool (pVirtO && pVirtO->IsTextBox()) || ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) || ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) || - ( pFilter && !pFilter->includeObject( *pObj ) ) ) + !pFilter->includeObject( *pObj ) ) continue; if (pVirtO) { diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index a38f9f989529..a0c0eceebfac 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -395,8 +395,8 @@ const SwContentFrame* SwContentFrame::ImplGetNextContentFrame( bool bFwd ) const } bGoingUp = !(bGoingFwdOrBwd || bGoingDown); - - if ( !bFwd && bGoingDown && p ) + assert(p); + if (!bFwd && bGoingDown) { while ( p->GetNext() ) p = p->GetNext(); diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 6dde1f694242..680632625da7 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -123,7 +123,7 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) } // #i28701# - use new method <GetPageFrame()> - if( !GetPageFrame() && GetAnchorFrame() && GetAnchorFrame()->IsInFly() ) + if( !GetPageFrame() && GetAnchorFrame()->IsInFly() ) { SwFlyFrame* pFly = AnchorFrame()->FindFlyFrame(); SwPageFrame *pPageFrame = pFly ? pFly->FindPageFrame() : nullptr; diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index ef0d950e62b3..7cc0b077e6eb 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -1346,7 +1346,7 @@ void SwFootnoteBossFrame::InsertFootnote( SwFootnoteFrame* pNew ) } if ( !bEnd && pSibling ) nCmpPos = ::lcl_FindFootnotePos( pDoc, pSibling->GetAttr() ); - if ( pSibling && pLastSib && (pSibling != pLastSib) ) + if (pSibling && (pSibling != pLastSib)) { // too far? if ( (nLastPos < nCmpPos) && (nCmpPos > nStPos) ) diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 24d91cba54f0..7d5bcf66a9fa 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2561,12 +2561,11 @@ TextFrameIndex SwFont::GetTextBreak(SwDrawTextInfo const & rInf, long nTextWidth bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont ) { const vcl::Font& rFnt = pFont ? *pFont : GetOut().GetFont(); - bool bPrt = GetShell() && ! GetShell()->GetWin(); Color nNewColor = COL_BLACK; bool bChgFntColor = false; bool bChgLineColor = false; - if( bPrt && GetShell() && GetShell()->GetViewOptions()->IsBlackFont() ) + if (GetShell() && !GetShell()->GetWin() && GetShell()->GetViewOptions()->IsBlackFont()) { if ( COL_BLACK != rFnt.GetColor() ) bChgFntColor = true; @@ -2582,7 +2581,7 @@ bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont ) // LineColor has to be changed if: // 1. IsAlwaysAutoColor is set - bChgLineColor = ! bPrt && GetShell() && + bChgLineColor = GetShell() && GetShell()->GetWin() && GetShell()->GetAccessibilityOptions()->IsAlwaysAutoColor(); bChgFntColor = COL_AUTO == rFnt.GetColor() || bChgLineColor; diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index f5720c7aad77..73105e2f5a02 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -133,7 +133,7 @@ size_t UndoManager::GetRedoActionCount(const bool bCurrentLevel) const if (!pAction) return nRet; - if (m_pView && !m_bRepair) + if (!m_bRepair) { // If another view created the first redo action, prevent redoing it from this view. ViewShellId nViewShellId = m_pView->GetViewShellId(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 016851c4d892..a7851e49e49f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3188,10 +3188,10 @@ static void impl_borders( FSHelperPtr const & pSerializer, // If there is a shadow, and it's not the regular 'Bottom-Right', // then write only the 'shadowed' sides of the border if ( - ( ( rOptions.aShadowLocation == SvxShadowLocation::TopLeft || rOptions.aShadowLocation == SvxShadowLocation::TopRight ) && *pBrd == SvxBoxItemLine::TOP ) || - ( ( rOptions.aShadowLocation == SvxShadowLocation::TopLeft || rOptions.aShadowLocation == SvxShadowLocation::BottomLeft ) && *pBrd == SvxBoxItemLine::LEFT ) || - ( ( rOptions.aShadowLocation == SvxShadowLocation::BottomLeft || rOptions.aShadowLocation == SvxShadowLocation::BottomRight ) && *pBrd == SvxBoxItemLine::BOTTOM) || - ( ( rOptions.aShadowLocation == SvxShadowLocation::TopRight || rOptions.aShadowLocation == SvxShadowLocation::BottomRight ) && *pBrd == SvxBoxItemLine::RIGHT ) + ((rOptions.aShadowLocation == SvxShadowLocation::TopLeft || rOptions.aShadowLocation == SvxShadowLocation::TopRight ) && *pBrd == SvxBoxItemLine::TOP ) || + ((rOptions.aShadowLocation == SvxShadowLocation::TopLeft || rOptions.aShadowLocation == SvxShadowLocation::BottomLeft) && *pBrd == SvxBoxItemLine::LEFT ) || + ((rOptions.aShadowLocation == SvxShadowLocation::BottomLeft ) && *pBrd == SvxBoxItemLine::BOTTOM) || + ((rOptions.aShadowLocation == SvxShadowLocation::TopRight ) && *pBrd == SvxBoxItemLine::RIGHT ) ) { bWriteShadow = true; diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 23ceeca5a22b..1dcf34f2d88e 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -1284,7 +1284,7 @@ void SwEditWin::ChangeDrawing( sal_uInt8 nDir ) else { // move handle with index nHandleIndex - if(pHdl && (nX || nY)) + if (nX || nY) { if( SdrHdlKind::Anchor == pHdl->GetKind() || SdrHdlKind::Anchor_TR == pHdl->GetKind() ) @@ -3114,8 +3114,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) // only try to select frame, if pointer already was // switched accordingly if ( m_aActHitType != SdrHitKind::NONE && !rSh.IsSelFrameMode() && - !GetView().GetViewFrame()->GetDispatcher()->IsLocked() && - !bExecDrawTextLink) + !GetView().GetViewFrame()->GetDispatcher()->IsLocked()) { // Test if there is a draw object at that position and if it should be selected. bool bShould = rSh.ShouldObjectBeSelected(aDocPos); diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 52c8a12bd17e..5ada2a617ae4 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -883,7 +883,7 @@ bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp ) return pSh->MoveFieldType( nullptr, bNext, SwFieldIds::Database ); } - return pTyp && pSh && pSh->MoveFieldType( pTyp, bNext ); + return pTyp && pSh->MoveFieldType(pTyp, bNext); } // insert field types diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 59220ac21258..7e70ddb554f6 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -152,7 +152,7 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue, } } } - if ( !bNegative && bCurrency && !aStr.isEmpty() ) + if (!bNegative && !aStr.isEmpty()) { sal_uInt16 nFormat = rLocaleDataWrappper.getCurrNegativeFormat(); if ( (nFormat == 3) || (nFormat == 6) || // $1- || 1-$ diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 3413d5533082..cfef2ecdc002 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -368,11 +368,10 @@ static void ImplPatternProcessStrictModify( Edit* pEdit, const OUString& rLiteralMask, bool bSameMask ) { - sal_uInt16 nFormatFlags = 0; OUString aText = pEdit->GetText(); // remove leading blanks - if ( bSameMask && !(nFormatFlags & PATTERN_FORMAT_EMPTYLITERALS) && !rEditMask.isEmpty() ) + if (bSameMask && !rEditMask.isEmpty()) { sal_Int32 i = 0; sal_Int32 nMaxLen = aText.getLength(); @@ -390,7 +389,7 @@ static void ImplPatternProcessStrictModify( Edit* pEdit, aText = aText.copy( i ); } - OUString aNewText = ImplPatternReformat( aText, rEditMask, rLiteralMask, nFormatFlags ); + OUString aNewText = ImplPatternReformat(aText, rEditMask, rLiteralMask, 0); if ( aNewText != aText ) { // adjust selection such that it remains at the end if it was there before @@ -399,7 +398,7 @@ static void ImplPatternProcessStrictModify( Edit* pEdit, if ( nMaxSel >= aText.getLength() ) { sal_Int32 nMaxPos = aNewText.getLength(); - ImplPatternMaxPos( aNewText, rEditMask, nFormatFlags, bSameMask, nMaxSel, nMaxPos ); + ImplPatternMaxPos(aNewText, rEditMask, 0, bSameMask, nMaxSel, nMaxPos); if ( aSel.Min() == aSel.Max() ) { aSel.Min() = nMaxPos; @@ -1757,7 +1756,7 @@ bool DateField::EventNotify( NotifyEvent& rNEvt ) Reformat(); } } - else if ( !bTextLen && IsEmptyFieldValueEnabled() ) + else { ResetLastDate(); SetEmptyFieldValueData( true ); @@ -1859,7 +1858,7 @@ bool DateBox::EventNotify( NotifyEvent& rNEvt ) bool bTextLen = !GetText().isEmpty(); if ( bTextLen || !IsEmptyFieldValueEnabled() ) Reformat(); - else if ( !bTextLen && IsEmptyFieldValueEnabled() ) + else { ResetLastDate(); SetEmptyFieldValueData( true ); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 5e9bed49044a..56a03ec877c8 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1810,8 +1810,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) PropertyMap * pTargetContext = rContext.get(); - if (pSectionContext != nullptr && - nSprmId == NS_ooxml::LN_EG_SectPrContents_textDirection) + if (pSectionContext) { pTargetContext = pSectionContext; } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ae045d57e200..1a0238e59fac 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1489,7 +1489,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con // tdf#118521 set paragraph top or bottom margin based on the paragraph style // if we already set the other margin with direct formatting - if ( pParaContext && m_xPreviousParagraph.is() ) + if (m_xPreviousParagraph) { const bool bTopSet = pParaContext->isSet(PROP_PARA_TOP_MARGIN); const bool bBottomSet = pParaContext->isSet(PROP_PARA_BOTTOM_MARGIN); @@ -1519,7 +1519,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con // Left, Right, and Hanging settings are also grouped. Ensure that all or none are set. // m_xPreviousParagraph was set earlier, so really it still is the current paragraph... - if ( pParaContext && m_xPreviousParagraph.is() ) + if (m_xPreviousParagraph) { const bool bLeftSet = pParaContext->isSet(PROP_PARA_LEFT_MARGIN); const bool bRightSet = pParaContext->isSet(PROP_PARA_RIGHT_MARGIN); |