sc/source/ui/dbgui/pvfundlg.cxx   |   16 +++-------
 sc/source/ui/view/prevwsh.cxx     |   53 +++++++++++++---------------------
 sd/source/core/sdpage.cxx         |   58 +++++++++++++++++++-------------------
 sw/source/uibase/uiview/pview.cxx |   14 +++------
 vcl/win/gdi/salfont.cxx           |    7 +---
 5 files changed, 65 insertions(+), 83 deletions(-)

New commits:
commit f5dd208719b6667394b2ab95d4a17296fb898224
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Oct 28 04:12:59 2018 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Oct 28 10:12:39 2018 +0100

    tdf#120703 PVS: V547 Expression is always true/false
    
    Change-Id: I2b2ea62ff4ed3e16cd4fa2a5e588d001d21121cb
    Reviewed-on: https://gerrit.libreoffice.org/62465
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 93a7330571c1..4effd48ae2b8 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -58,18 +58,14 @@ template< typename ListBoxType >
 bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, 
sal_Int32 nEmptyPos = LISTBOX_APPEND )
 {
     bool bEmpty = false;
-    const OUString* pStr = rStrings.getConstArray();
-    if( pStr )
+    for (const OUString& str : rStrings)
     {
-        for( const OUString* pEnd = pStr + rStrings.getLength(); pStr != pEnd; 
++pStr )
+        if (!str.isEmpty())
+            rLBox.InsertEntry(str);
+        else
         {
-            if( !pStr->isEmpty() )
-                rLBox.InsertEntry( *pStr );
-            else
-            {
-                rLBox.InsertEntry( ScResId( STR_EMPTYDATA ), nEmptyPos );
-                bEmpty = true;
-            }
+            rLBox.InsertEntry(ScResId(STR_EMPTYDATA), nEmptyPos);
+            bEmpty = true;
         }
     }
     return bEmpty;
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 42d6700d0ab5..01ca947a8251 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -908,16 +908,13 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence 
< beans::PropertyValue
 {
     rSeq.realloc(3);
     beans::PropertyValue* pSeq = rSeq.getArray();
-    if(pSeq)
-    {
-        sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
-        pSeq[0].Name = SC_VIEWID;
-        pSeq[0].Value <<= SC_VIEW + OUString::number(nViewID);
-        pSeq[1].Name = SC_ZOOMVALUE;
-        pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
-        pSeq[2].Name = "PageNumber";
-        pSeq[2].Value <<= pPreview->GetPageNo();
-    }
+    sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
+    pSeq[0].Name = SC_VIEWID;
+    pSeq[0].Value <<= SC_VIEW + OUString::number(nViewID);
+    pSeq[1].Name = SC_ZOOMVALUE;
+    pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
+    pSeq[2].Name = "PageNumber";
+    pSeq[2].Value <<= pPreview->GetPageNo();
 
     // Common SdrModel processing
     if (ScDrawLayer* pDrawLayer = GetDocument().GetDrawLayer())
@@ -926,31 +923,23 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence 
< beans::PropertyValue
 
 void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < 
beans::PropertyValue >& rSeq)
 {
-    sal_Int32 nCount(rSeq.getLength());
-    if (nCount)
+    for (const auto& propval : rSeq)
     {
-        const beans::PropertyValue* pSeq = rSeq.getConstArray();
-        if(pSeq)
+        if (propval.Name == SC_ZOOMVALUE)
         {
-            for(sal_Int32 i = 0; i < nCount; i++, pSeq++)
-            {
-                OUString sName(pSeq->Name);
-                if(sName == SC_ZOOMVALUE)
-                {
-                    sal_Int32 nTemp = 0;
-                    if (pSeq->Value >>= nTemp)
-                        pPreview->SetZoom(sal_uInt16(nTemp));
-                }
-                else if (sName == "PageNumber")
-                {
-                    sal_Int32 nTemp = 0;
-                    if (pSeq->Value >>= nTemp)
-                        pPreview->SetPageNo(nTemp);
-                }
-                // Fallback to common SdrModel processing
-                else 
pDocShell->MakeDrawLayer()->ReadUserDataSequenceValue(pSeq);
-            }
+            sal_Int32 nTemp = 0;
+            if (propval.Value >>= nTemp)
+                pPreview->SetZoom(sal_uInt16(nTemp));
         }
+        else if (propval.Name == "PageNumber")
+        {
+            sal_Int32 nTemp = 0;
+            if (propval.Value >>= nTemp)
+                pPreview->SetPageNo(nTemp);
+        }
+        // Fallback to common SdrModel processing
+        else
+            pDocShell->MakeDrawLayer()->ReadUserDataSequenceValue(&propval);
     }
 }
 
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 2415061add75..dd593036321c 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -726,40 +726,42 @@ void SdPage::Changed(const SdrObject& rObj, 
SdrUserCallType eType, const ::tools
                 if ( getSdrModelFromSdrPage().isLocked())
                     break;
 
-                SdrObject* pObj = const_cast<SdrObject*>(&rObj);
-
-                if (pObj)
+                if (!mbMaster)
                 {
-                    if (!mbMaster)
+                    if (rObj.GetUserCall())
                     {
-                        if( pObj->GetUserCall() )
-                        {
-                            SfxUndoManager* pUndoManager = static_cast< 
SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager();
-                            const bool bUndo = pUndoManager && 
pUndoManager->IsInListAction() && IsInserted();
-
-                            if( bUndo )
-                                pUndoManager->AddUndoAction( 
o3tl::make_unique<UndoObjectUserCall>(*pObj) );
-
-                            // Object was resized by user and does not listen 
to its slide anymore
-                            pObj->SetUserCall(nullptr);
-                        }
+                        SdrObject& _rObj = const_cast<SdrObject&>(rObj);
+                        SfxUndoManager* pUndoManager
+                            = 
static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
+                                  .GetUndoManager();
+                        const bool bUndo
+                            = pUndoManager && pUndoManager->IsInListAction() 
&& IsInserted();
+
+                        if (bUndo)
+                            pUndoManager->AddUndoAction(
+                                o3tl::make_unique<UndoObjectUserCall>(_rObj));
+
+                        // Object was resized by user and does not listen to 
its slide anymore
+                        _rObj.SetUserCall(nullptr);
                     }
-                    else
+                }
+                else
+                {
+                    // Object of the master page changed, therefore adjust
+                    // object on all pages
+                    sal_uInt16 nPageCount = 
static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
+                                                .GetSdPageCount(mePageKind);
+
+                    for (sal_uInt16 i = 0; i < nPageCount; i++)
                     {
-                        // Object of the master page changed, therefore adjust
-                        // object on all pages
-                        sal_uInt16 nPageCount = static_cast< SdDrawDocument& 
>(getSdrModelFromSdrPage()).GetSdPageCount(mePageKind);
+                        SdPage* pLoopPage = 
static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
+                                                .GetSdPage(i, mePageKind);
 
-                        for (sal_uInt16 i = 0; i < nPageCount; i++)
+                        if (pLoopPage && this == 
&(pLoopPage->TRG_GetMasterPage()))
                         {
-                            SdPage* pLoopPage = static_cast< SdDrawDocument& 
>(getSdrModelFromSdrPage()).GetSdPage(i, mePageKind);
-
-                            if (pLoopPage && this == 
&(pLoopPage->TRG_GetMasterPage()))
-                            {
-                                // Page listens to this master page, therefore
-                                // adjust AutoLayout
-                                
pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
-                            }
+                            // Page listens to this master page, therefore
+                            // adjust AutoLayout
+                            
pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
                         }
                     }
                 }
diff --git a/sw/source/uibase/uiview/pview.cxx 
b/sw/source/uibase/uiview/pview.cxx
index f9da9a579afb..b05db89e897c 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -662,9 +662,8 @@ void SwPagePreview::ExecPgUpAndPgDown( const bool  _bPgUp,
 // Then all for the SwPagePreview
 void  SwPagePreview::Execute( SfxRequest &rReq )
 {
-    int eMvMode;
+    int eMvMode = SwPagePreviewWin::MV_DOC_END;
     sal_uInt8 nRow = 1;
-    bool bRetVal = false;
     bool bRefresh = true;
 
     switch(rReq.GetSlot())
@@ -867,18 +866,15 @@ void  SwPagePreview::Execute( SfxRequest &rReq )
         break;
         case FN_START_OF_LINE:
         case FN_START_OF_DOCUMENT:
-            m_pViewWin->SetSelectedPage( 1 );
-            eMvMode = SwPagePreviewWin::MV_DOC_STT; bRetVal = true; goto 
MOVEPAGE;
+            eMvMode = SwPagePreviewWin::MV_DOC_STT;
+            SAL_FALLTHROUGH;
         case FN_END_OF_LINE:
         case FN_END_OF_DOCUMENT:
-            m_pViewWin->SetSelectedPage( mnPageCount );
-            eMvMode = SwPagePreviewWin::MV_DOC_END; bRetVal = true; goto 
MOVEPAGE;
-MOVEPAGE:
+            m_pViewWin->SetSelectedPage(eMvMode == 
SwPagePreviewWin::MV_DOC_STT ? 1 : mnPageCount);
             {
                 bool bRet = ChgPage( eMvMode );
                 // return value for Basic
-                if(bRetVal)
-                    rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
+                rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
 
                 bRefresh = bRet;
                 rReq.Done();
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 82c69c94a2c7..4409effd789f 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -765,8 +765,8 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
         aName = rFont.GetFamilyName().getToken( 0, ';' );
 
     UINT nNameLen = aName.getLength();
-    if ( nNameLen > (sizeof( rLogFont.lfFaceName )/sizeof( wchar_t ))-1 )
-        nNameLen = (sizeof( rLogFont.lfFaceName )/sizeof( wchar_t ))-1;
+    if (nNameLen >= LF_FACESIZE)
+        nNameLen = LF_FACESIZE - 1;
     memcpy( rLogFont.lfFaceName, aName.getStr(), nNameLen*sizeof( wchar_t ) );
     rLogFont.lfFaceName[nNameLen] = 0;
 
@@ -827,8 +827,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
         {
             // restore non-vertical name if not vertical mode isn't available
             memcpy( &rLogFont.lfFaceName[0], aName.getStr(), 
nNameLen*sizeof(wchar_t) );
-            if( nNameLen < LF_FACESIZE )
-                rLogFont.lfFaceName[nNameLen] = '\0';
+            rLogFont.lfFaceName[nNameLen] = '\0';
             // keep it upright and create the font for sideway glyphs later.
             rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
             rLogFont.lfOrientation = rLogFont.lfEscapement;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to