From cd9aa5bc508244082b4baf4a3094875bf2c6f992 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 20 Oct 2018 10:38:32 +0200 Subject: tdf#120703 (PVS): redundant comparisons, dynamic_cast in dtor V560 A part of conditional expression is always true: (nHintStart >= nStartIdx) V509 The 'dynamic_cast' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. V560 A part of conditional expression is always true: pHint. Change-Id: Icfb9a2961f5db034fd19f4665fe3ceaae6232350 Reviewed-on: https://gerrit.libreoffice.org/62039 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/txtnode/ndtxt.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 30bfd26ac35f..cb3bfa5686b7 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2706,8 +2706,7 @@ void SwTextNode::EraseText(const SwIndex &rIdx, const sal_Int32 nCount, { // attribute with neither end nor CH_TXTATR? assert(pHt->HasDummyChar()); - if (isTXTATR(nWhich) && - (nHintStart >= nStartIdx) && (nHintStart < nEndIdx)) + if (isTXTATR(nWhich) && (nHintStart < nEndIdx)) { m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); @@ -5082,10 +5081,17 @@ namespace { } // #i70748# // #i105562# - else if ( mrTextNode.GetpSwAttrSet() && - dynamic_cast(mrTextNode.GetAttr( RES_PARATR_OUTLINELEVEL, false )).GetValue() > 0 ) + else { - mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr(); + assert(!mrTextNode.GetpSwAttrSet() + || dynamic_cast( + &mrTextNode.GetAttr(RES_PARATR_OUTLINELEVEL, false))); + if (mrTextNode.GetpSwAttrSet() + && static_cast( + mrTextNode.GetAttr(RES_PARATR_OUTLINELEVEL, false)).GetValue() > 0) + { + mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr(); + } } } @@ -5319,9 +5325,9 @@ void SwTextNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SetXParagraph(css::uno::Reference(nullptr)); } } - else if (auto pHint = dynamic_cast(&rHint)) + else if (dynamic_cast(&rHint)) { - if ( pHint && &rModify == GetRegisteredIn() ) + if (&rModify == GetRegisteredIn()) ChkCondColl(); } } -- cgit v1.2.3