[Libreoffice-commits] core.git: basctl/source embedserv/source framework/source sc/source sd/source sfx2/source svtools/source svx/source sw/source vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Nov 18 11:32:41 UTC 2018


 basctl/source/dlged/dlgedfunc.cxx                       |   62 +++++++---------
 embedserv/source/inprocserv/dllentry.cxx                |    2 
 framework/source/uielement/controlmenucontroller.cxx    |    5 -
 sc/source/core/tool/charthelper.cxx                     |    2 
 sc/source/ui/docshell/docfunc.cxx                       |   18 ++--
 sd/source/ui/sidebar/DocumentHelper.cxx                 |    3 
 sfx2/source/view/classificationhelper.cxx               |    6 -
 svtools/source/control/ctrlbox.cxx                      |    4 -
 svx/source/accessibility/ChildrenManagerImpl.cxx        |   10 +-
 sw/source/core/crsr/crsrsh.cxx                          |    6 +
 sw/source/core/crsr/crstrvl.cxx                         |    6 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    2 
 sw/source/core/doc/DocumentFieldsManager.cxx            |    2 
 sw/source/core/doc/docredln.cxx                         |    2 
 sw/source/uibase/app/docsh.cxx                          |    3 
 vcl/source/window/dialog.cxx                            |    4 -
 16 files changed, 64 insertions(+), 73 deletions(-)

New commits:
commit a208ece66416048cdc99235a569bd8c928a07394
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Nov 13 00:40:43 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Nov 18 12:32:18 2018 +0100

    tdf#120703 PVS: V560 A part of conditional expression is always true/false
    
    Change-Id: I60bb778a88dd5619efd4858eb74d56d28616c777
    Reviewed-on: https://gerrit.libreoffice.org/63520
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
index 665bd7c147d3..78fe1ef96966 100644
--- a/basctl/source/dlged/dlgedfunc.cxx
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -256,43 +256,39 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
                         }
                     }
                 }
-                else
+                else if (nX || nY)
                 {
-                    // move the handle
-                    if ( pHdl && ( nX || nY ) )
-                    {
-                        Point aStartPoint( pHdl->GetPos() );
-                        Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
-                        const SdrDragStat& rDragStat = rView.GetDragStat();
+                    Point aStartPoint(pHdl->GetPos());
+                    Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
+                    const SdrDragStat& rDragStat = rView.GetDragStat();
 
-                        // start dragging
-                        rView.BegDragObj( aStartPoint, nullptr, pHdl, 0 );
+                    // start dragging
+                    rView.BegDragObj(aStartPoint, nullptr, pHdl, 0);
 
-                        if ( rView.IsDragObj() )
-                        {
-                            bool const bWasNoSnap = rDragStat.IsNoSnap();
-                            bool const bWasSnapEnabled = rView.IsSnapEnabled();
-
-                            // switch snapping off
-                            if ( !bWasNoSnap )
-                                const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
-                            if ( bWasSnapEnabled )
-                                rView.SetSnapEnabled(false);
-
-                            rView.MovAction( aEndPoint );
-                            rView.EndDragObj();
-
-                            // restore snap
-                            if ( !bWasNoSnap )
-                                const_cast<SdrDragStat&>(rDragStat).SetNoSnap( bWasNoSnap );
-                            if ( bWasSnapEnabled )
-                                rView.SetSnapEnabled( bWasSnapEnabled );
-                        }
-
-                        // make moved handle visible
-                        tools::Rectangle aVisRect( aEndPoint - Point( 100, 100 ), Size( 200, 200 ) );
-                        rView.MakeVisible( aVisRect, rWindow );
+                    if (rView.IsDragObj())
+                    {
+                        bool const bWasNoSnap = rDragStat.IsNoSnap();
+                        bool const bWasSnapEnabled = rView.IsSnapEnabled();
+
+                        // switch snapping off
+                        if (!bWasNoSnap)
+                            const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
+                        if (bWasSnapEnabled)
+                            rView.SetSnapEnabled(false);
+
+                        rView.MovAction(aEndPoint);
+                        rView.EndDragObj();
+
+                        // restore snap
+                        if (!bWasNoSnap)
+                            const_cast<SdrDragStat&>(rDragStat).SetNoSnap(bWasNoSnap);
+                        if (bWasSnapEnabled)
+                            rView.SetSnapEnabled(bWasSnapEnabled);
                     }
+
+                    // make moved handle visible
+                    tools::Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
+                    rView.MakeVisible(aVisRect, rWindow);
                 }
             }
             else
diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx
index 963342c819f8..5c8c4f6bdd2d 100644
--- a/embedserv/source/inprocserv/dllentry.cxx
+++ b/embedserv/source/inprocserv/dllentry.cxx
@@ -52,7 +52,7 @@ namespace {
             char nSign = ( nValue / ( 1 << ( ( nLen - nInd - 1 ) * 4 ) ) ) % 16;
             if ( nSign >= 0 && nSign <= 9 )
                 pBuf[nInd] = nSign + L'0';
-            else if ( nSign >= 10 && nSign <= 15 )
+            else if (nSign >= 10)
                 pBuf[nInd] = nSign - 10 + L'a';
 
             nInd++;
diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index 9685ac385a95..bcb88030a8e3 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -292,9 +292,8 @@ void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
         // Check if some modes have changed so we have to update our menu images
         const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
         bool bShowMenuImages    = rSettings.GetUseImagesInMenus();
-        bool bUpdateImages      = (bShowMenuImages != m_bShowMenuImages);
 
-        if ( bUpdateImages )
+        if (bShowMenuImages != m_bShowMenuImages)
         {
             m_bShowMenuImages   = bShowMenuImages;
 
@@ -302,7 +301,7 @@ void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
             if ( pPopupMenu )
             {
                 PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
-                if ( pVCLPopupMenu && bUpdateImages )
+                if (pVCLPopupMenu)
                     updateImagesPopupMenu( pVCLPopupMenu );
             }
         }
diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx
index 9b36ea8020b0..b7ca0240bbe9 100644
--- a/sc/source/core/tool/charthelper.cxx
+++ b/sc/source/core/tool/charthelper.cxx
@@ -415,7 +415,7 @@ void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, co
                             }
                         }
 
-                        if ( pModelObj && pModelObj->HasChangesListeners() )
+                        if (pModelObj->HasChangesListeners())
                         {
                             tools::Rectangle aRectangle = pSdrOle2Obj->GetSnapRect();
                             ScRange aRange( pDoc->GetRange( nTab, aRectangle ) );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index ad5251543cc6..2a0f21fa5299 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1862,13 +1862,12 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
             ScDocAttrIterator aTestIter( &rDoc, i, nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow );
             ScRange aExtendRange( nMergeTestStartCol, nMergeTestStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
             const ScPatternAttr* pPattern = nullptr;
-            const ScMergeFlagAttr* pMergeFlagAttr = nullptr;
             while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != nullptr )
             {
-                const ScMergeAttr* pMergeFlag = &pPattern->GetItem(ATTR_MERGE);
-                pMergeFlagAttr = &pPattern->GetItem(ATTR_MERGE_FLAG);
-                ScMF nNewFlags = pMergeFlagAttr->GetValue() & ( ScMF::Hor | ScMF::Ver );
-                if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver )
+                const ScMergeAttr& rMergeFlag = pPattern->GetItem(ATTR_MERGE);
+                const ScMergeFlagAttr& rMergeFlagAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
+                ScMF nNewFlags = rMergeFlagAttr.GetValue() & (ScMF::Hor | ScMF::Ver);
+                if (rMergeFlag.IsMerged() || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver)
                 {
                     ScRange aRange( nTestCol, nTestRow1, i );
                     rDoc.ExtendOverlapped(aRange);
@@ -2338,13 +2337,12 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
             ScDocAttrIterator aTestIter( &rDoc, i, nUndoStartCol, nUndoStartRow, nMergeTestEndCol, nMergeTestEndRow );
             ScRange aExtendRange( nUndoStartCol, nUndoStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
             const ScPatternAttr* pPattern = nullptr;
-            const ScMergeFlagAttr* pMergeFlagAttr = nullptr;
             while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != nullptr )
             {
-                const ScMergeAttr* pMergeFlag = &pPattern->GetItem( ATTR_MERGE );
-                pMergeFlagAttr = &pPattern->GetItem( ATTR_MERGE_FLAG );
-                ScMF nNewFlags = pMergeFlagAttr->GetValue() & ( ScMF::Hor | ScMF::Ver );
-                if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver )
+                const ScMergeAttr& rMergeFlag = pPattern->GetItem(ATTR_MERGE);
+                const ScMergeFlagAttr& rMergeFlagAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
+                ScMF nNewFlags = rMergeFlagAttr.GetValue() & (ScMF::Hor | ScMF::Ver);
+                if (rMergeFlag.IsMerged() || nNewFlags == ScMF::Hor || nNewFlags == ScMF::Ver)
                 {
                     ScRange aRange( nTestCol, nTestRow1, i );
                     rDoc.ExtendOverlapped( aRange );
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx
index f48065ca6923..9392d5fa4ab6 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -95,8 +95,7 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
         for (sal_uInt16 nMaster=0; nMaster<nMasterPageCount; nMaster++)
         {
             SdPage* pCandidate = rTargetDocument.GetMasterSdPage (nMaster, PageKind::Standard);
-            if (pMasterPage!=nullptr
-                && pCandidate->GetName() == pMasterPage->GetName())
+            if (pCandidate->GetName() == pMasterPage->GetName())
             {
                 bPageExists = true;
                 pNewMasterPage = pCandidate;
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 9d83d337ed09..049f8008c4e5 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -490,14 +490,12 @@ bool SfxClassificationHelper::IsClassified(const uno::Reference<document::XDocum
 SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(const uno::Reference<document::XDocumentProperties>& xSource,
         const uno::Reference<document::XDocumentProperties>& xDestination)
 {
-    bool bSourceClassified = SfxClassificationHelper::IsClassified(xSource);
-    if (!bSourceClassified)
+    if (!SfxClassificationHelper::IsClassified(xSource))
         // No classification on the source side. Return early, regardless the
         // state of the destination side.
         return SfxClassificationCheckPasteResult::None;
 
-    bool bDestinationClassified = SfxClassificationHelper::IsClassified(xDestination);
-    if (bSourceClassified && !bDestinationClassified)
+    if (!SfxClassificationHelper::IsClassified(xDestination))
     {
         // Paste from a classified document to a non-classified one -> deny.
         return SfxClassificationCheckPasteResult::TargetDocNotClassified;
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 112ce7ea2da2..a5625a1a0001 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -155,14 +155,14 @@ long BorderWidthImpl::GuessWidth( long nLine1, long nLine2, long nGap )
     double nWidth1 = lcl_getGuessedWidth( nLine1, m_nRate1, bLine1Change );
     if ( bLine1Change )
         aToCompare.push_back( nWidth1 );
-    else if ( !bLine1Change && nWidth1 < 0 )
+    else if (nWidth1 < 0)
         bInvalid = true;
 
     bool bLine2Change = bool( m_nFlags & BorderWidthImplFlags::CHANGE_LINE2 );
     double nWidth2 = lcl_getGuessedWidth( nLine2, m_nRate2, bLine2Change );
     if ( bLine2Change )
         aToCompare.push_back( nWidth2 );
-    else if ( !bLine2Change && nWidth2 < 0 )
+    else if (nWidth2 < 0)
         bInvalid = true;
 
     bool bGapChange = bool( m_nFlags & BorderWidthImplFlags::CHANGE_DIST );
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
index 74a956befb7e..ce77aed85e13 100644
--- a/svx/source/accessibility/ChildrenManagerImpl.cxx
+++ b/svx/source/accessibility/ChildrenManagerImpl.cxx
@@ -783,12 +783,12 @@ AccessibleControlShape * ChildrenManagerImpl::GetAccControlShapeFromModel(css::b
     for (sal_Int32 index=0;index<count;index++)
     {
         AccessibleShape* pAccShape = maVisibleChildren[index].GetAccessibleShape();
-            if (pAccShape  && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == DRAWING_CONTROL)
-            {
-            ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
-            if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet)
+        if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId(pAccShape->GetXShape()) == DRAWING_CONTROL)
+        {
+            auto* pCtlAccShape = static_cast<::accessibility::AccessibleControlShape*>(pAccShape);
+            if (pCtlAccShape->GetControlModel() == pSet)
                 return pCtlAccShape;
-                }
+        }
     }
     return nullptr;
 }
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index d02eca62ac64..84e6ab9f62b4 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1714,7 +1714,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
                 m_pVisibleCursor->Show(); // show again
             }
             m_eMvState = MV_NONE;  // state for cursor travelling - GetCursorOfst
-            if( pTableFrame && Imp()->IsAccessible() )
+            if (Imp()->IsAccessible())
                 Imp()->InvalidateAccessibleCursorPosition( pTableFrame );
             return;
         }
@@ -1957,6 +1957,8 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
 
     } while( eFlags & SwCursorShell::SCROLLWIN );
 
+    assert(pFrame);
+
     if( m_pBlockCursor )
         RefreshBlockCursor();
 
@@ -1984,7 +1986,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
 
     m_eMvState = MV_NONE; // state for cursor travelling - GetCursorOfst
 
-    if( pFrame && Imp()->IsAccessible() )
+    if (Imp()->IsAccessible())
         Imp()->InvalidateAccessibleCursorPosition( pFrame );
 
     // switch from blinking cursor to read-only-text-selection cursor
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 7b14d3156938..9a899ba19023 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1314,8 +1314,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
         {
             if( !aTmpState.m_bPosCorr )
             {
-                if ( !bRet
-                     && IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
+                if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
                      && !aTmpState.m_bFootnoteNoInfo )
                 {
                     const SwWrongList* pSmartTagList = pTextNd->GetSmartTags();
@@ -1427,7 +1426,8 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
                 {
                     IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
                     sw::mark::IFieldmark* pFieldBookmark = pMarksAccess->getFieldmarkFor( aPos );
-                    if( bCursorFoundExact && pTextNd && pFieldBookmark) {
+                    if (bCursorFoundExact && pFieldBookmark)
+                    {
                         rContentAtPos.eContentAtPos = IsAttrAtPos::FormControl;
                         rContentAtPos.aFnd.pFieldmark = pFieldBookmark;
                         bRet=true;
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 72e0c5f81547..2dd37a5180a9 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -446,7 +446,7 @@ namespace
                     bRet = false;
                     break;
                 }
-            } while ( pTextNd && pTextNd != pEndTextNd );
+            } while (pTextNd != pEndTextNd);
         }
 
         return bRet;
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 15b89a5bdc71..25beaac622d5 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -1442,7 +1442,7 @@ void DocumentFieldsManager::SetFixFields( const DateTime* pNewDateTime )
         SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
         for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
         {
-            if( pFormatField && pFormatField->GetTextField() )
+            if (pFormatField->GetTextField())
             {
                 bool bChgd = false;
                 switch( aType )
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index a323b595f0fc..f9fe20b8953a 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1453,7 +1453,7 @@ void SwRangeRedline::CopyToSection()
 
     if( pCSttNd )
     {
-        SwTextFormatColl* pColl = (pCSttNd && pCSttNd->IsTextNode() )
+        SwTextFormatColl* pColl = pCSttNd->IsTextNode()
                                 ? pCSttNd->GetTextNode()->GetTextColl()
                                 : pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD);
 
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 3559a500fba6..b91e5a912218 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1402,12 +1402,11 @@ bool SwDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas
     bool bRes = false;
 
     const SfxAllItemSet aSet( GetPool() );
-    const SfxItemSet*   pArgs = &aSet;
     const SfxPoolItem*  pItem = nullptr;
 
     IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
     const Sequence< sal_Int8 >& aPasswdHash( rIDRA.GetRedlinePassword() );
-    if (pArgs && SfxItemState::SET == pArgs->GetItemState( FN_REDLINE_PROTECT, false, &pItem )
+    if (SfxItemState::SET == aSet.GetItemState(FN_REDLINE_PROTECT, false, &pItem)
         && static_cast<const SfxBoolItem*>(pItem)->GetValue() == (aPasswdHash.getLength() != 0))
         return false;
     rPasswordHash = aPasswdHash;
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index b426ad39a613..d91f5aea30f0 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -148,7 +148,7 @@ vcl::Window * nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::
         pChild = pParent->GetWindow(GetWindowType::Next);
     }
 
-    if (pChild && isContainerWindow(*pChild))
+    if (isContainerWindow(*pChild))
         pChild = nextLogicalChildOfParent(pTopLevel, pChild);
 
     return const_cast<vcl::Window *>(pChild);
@@ -176,7 +176,7 @@ vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::
         pChild = pParent->GetWindow(GetWindowType::Prev);
     }
 
-    if (pChild && isContainerWindow(*pChild))
+    if (isContainerWindow(*pChild))
         pChild = prevLogicalChildOfParent(pTopLevel, pChild);
 
     return const_cast<vcl::Window *>(pChild);


More information about the Libreoffice-commits mailing list