[Libreoffice-commits] core.git: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Oct 21 21:46:28 UTC 2018


 sc/source/ui/view/viewfun3.cxx |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

New commits:
commit dfee8f56dda26857cad4feba5703eb23420ea6e6
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Oct 21 18:21:42 2018 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Oct 21 23:46:01 2018 +0200

    tdf#120703 (PVS): redundant nullptr checks
    
    V668 There is no sense in testing the 'pClipDoc' pointer against null, as
         the memory was allocated using the 'new' operator. The exception will
         be generated in the case of memory allocation error.
    
    V560 A part of conditional expression is always true: pDoc.
    
    V560 A part of conditional expression is always true: pMergeFlagAttr.
    
    V560 A part of conditional expression is always true: pMergeFlag.
    
    Change-Id: Ief75a140cca58fe458dc3c1fd18a9bbaa1ea39cb
    Reviewed-on: https://gerrit.libreoffice.org/62143
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 6565b0a7b042..28413a8a7c35 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -245,21 +245,17 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* pClipDoc, const ScRangeList&
     }
 
     pDoc->CopyToClip( aClipParam, pClipDoc, &rMark, false, bIncludeObjects );
-    if ( pDoc && pClipDoc )
+    if (ScDrawLayer* pDrawLayer = pClipDoc->GetDrawLayer())
     {
-        ScDrawLayer* pDrawLayer = pClipDoc->GetDrawLayer();
-        if ( pDrawLayer )
+        ScClipParam& rClipDocClipParam = pClipDoc->GetClipParam();
+        ScRangeListVector& rRangesVector = rClipDocClipParam.maProtectedChartRangesVector;
+        SCTAB nTabCount = pClipDoc->GetTableCount();
+        for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
         {
-            ScClipParam& rClipDocClipParam = pClipDoc->GetClipParam();
-            ScRangeListVector& rRangesVector = rClipDocClipParam.maProtectedChartRangesVector;
-            SCTAB nTabCount = pClipDoc->GetTableCount();
-            for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
+            SdrPage* pPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) );
+            if ( pPage )
             {
-                SdrPage* pPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) );
-                if ( pPage )
-                {
-                    ScChartHelper::FillProtectedChartRangesVector( rRangesVector, pDoc, pPage );
-                }
+                ScChartHelper::FillProtectedChartRangesVector( rRangesVector, pDoc, pPage );
             }
         }
     }
@@ -1219,9 +1215,9 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
             SCROW nRow2 = -1;
             while ( ( pPattern = aIter.GetNext( nCol, nRow1, nRow2 ) ) != nullptr )
             {
-                const ScMergeAttr* pMergeFlag = &pPattern->GetItem(ATTR_MERGE);
-                const ScMergeFlagAttr* pMergeFlagAttr = &pPattern->GetItem(ATTR_MERGE_FLAG);
-                if( ( pMergeFlag && pMergeFlag->IsMerged() ) || ( pMergeFlagAttr && pMergeFlagAttr->IsOverlapped() ) )
+                const ScMergeAttr& rMergeFlag = pPattern->GetItem(ATTR_MERGE);
+                const ScMergeFlagAttr& rMergeFlagAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
+                if (rMergeFlag.IsMerged() || rMergeFlagAttr.IsOverlapped())
                 {
                     ScRange aRange(nCol, nRow1, nStartTab);
                     pDoc->ExtendOverlapped(aRange);


More information about the Libreoffice-commits mailing list