tdf#120703 PVS: V547 Expression is always true/false

Change-Id: I3432afca1ee9bf9e8adce1d55d58d57bf1a09cb4
Reviewed-on: https://gerrit.libreoffice.org/62847
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx
index 977c9c2..e27e1c8 100644
--- a/cui/source/tabpages/measure.cxx
+++ b/cui/source/tabpages/measure.cxx
@@ -166,75 +166,39 @@
    // SdrMeasureLineDistItem
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_xMtrFldLineDist, nValue, eUnit );
    }
    else
    {
        m_xMtrFldLineDist->set_text(OUString());
    }
    SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
    m_xMtrFldLineDist->save_value();

    // SdrMeasureHelplineOverhangItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_xMtrFldHelplineOverhang, nValue, eUnit );
    }
    else
    {
        m_xMtrFldHelplineOverhang->set_text(OUString());
    }
    SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
                   eUnit);
    m_xMtrFldHelplineOverhang->save_value();

    // SdrMeasureHelplineDistItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_xMtrFldHelplineDist, nValue, eUnit );
    }
    else
    {
        m_xMtrFldHelplineDist->set_text(OUString());
    }
    SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
                   eUnit);
    m_xMtrFldHelplineDist->save_value();

    // SdrMeasureHelpline1LenItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_xMtrFldHelpline1Len, nValue, eUnit );
    }
    else
    {
        m_xMtrFldHelpline1Len->set_text(OUString());
    }
    SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
                   eUnit);
    m_xMtrFldHelpline1Len->save_value();

    // SdrMeasureHelpline2LenItem
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
    if( pItem )
    {
        long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
        SetMetricValue( *m_xMtrFldHelpline2Len, nValue, eUnit );
    }
    else
    {
        m_xMtrFldHelpline2Len->set_text(OUString());
    }
    SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
                   eUnit);
    m_xMtrFldHelpline2Len->save_value();

    // SdrMeasureBelowRefEdgeItem
@@ -253,15 +217,8 @@
    pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
    if( pItem == nullptr )
        pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
    if( pItem )
    {
        sal_Int16 nValue = static_cast<const SdrMeasureDecimalPlacesItem*>( pItem )->GetValue();
        m_xMtrFldDecimalPlaces->set_value(nValue);
    }
    else
    {
        m_xMtrFldDecimalPlaces->set_text(OUString());
    }
    m_xMtrFldDecimalPlaces->set_value(
      static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue());
    m_xMtrFldDecimalPlaces->save_value();

    // SdrMeasureTextRota90Item
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index caece9d..e6a44aa 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -73,11 +73,10 @@
        message += OUString::createFromAscii(aOperation) + ": ";
    }
    message += OUString::createFromAscii(ldap_err2string(aRetCode)) + " (" ;
    sal_Char *stub = nullptr ;

#ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP
    sal_Char* stub = nullptr;
    ldap_get_lderrno(aConnection, NULL, &stub) ;
#endif
    if (stub != nullptr)
    {
        message += OUString::createFromAscii(stub) ;
@@ -88,7 +87,10 @@
        // This call is thus disabled for the moment.
        //ldap_memfree(stub) ;
    }
    else { message += "No additional information" ; }
    else
#endif
    { message += "No additional information"; }

    message += ")" ;
    throw ldap::LdapGenericException(message, nullptr, aRetCode) ;
}
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index 8b99ccb..01e6fe2 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -923,7 +923,7 @@

        if (nRowBytes < 8 || nPackType == 1)
        {
            if (nWidth && nHeight > pPict->remainingSize() / (sizeof(sal_uInt16) * nWidth))
            if (nHeight > pPict->remainingSize() / (sizeof(sal_uInt16) * nWidth))
                return 0xffffffff;
        }
        else
@@ -1021,10 +1021,10 @@
        if ( nRowBytes < 8 || nPackType == 1 )
        {
            const size_t nMaxPixels = pPict->remainingSize() / 4;
            const size_t nMaxRows = nWidth ? nMaxPixels / nWidth : SAL_MAX_UINT16;
            const size_t nMaxRows = nMaxPixels / nWidth;
            if (nHeight > nMaxRows)
                return 0xffffffff;
            const size_t nMaxCols = nHeight ? nMaxPixels / nHeight : SAL_MAX_UINT16;
            const size_t nMaxCols = nMaxPixels / nHeight;
            if (nWidth > nMaxCols)
                return 0xffffffff;

@@ -1044,10 +1044,10 @@
        else if ( nPackType == 2 )
        {
            const size_t nMaxPixels = pPict->remainingSize() / 3;
            const size_t nMaxRows = nWidth ? nMaxPixels / nWidth : SAL_MAX_UINT16;
            const size_t nMaxRows = nMaxPixels / nWidth;
            if (nHeight > nMaxRows)
                return 0xffffffff;
            const size_t nMaxCols = nHeight ? nMaxPixels / nHeight : SAL_MAX_UINT16;
            const size_t nMaxCols = nMaxPixels / nHeight;
            if (nWidth > nMaxCols)
                return 0xffffffff;

diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index d11dc8e..b33f925 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -1238,7 +1238,6 @@
        m_aAsyncLayoutTimer.Stop();

    bool bAutomaticToolbars( m_bAutomaticToolbars );
    std::vector< Reference< awt::XWindow > > oldDockingAreaWindows;

    ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();

@@ -1261,7 +1260,6 @@
            pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
    }

    Reference< ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor );
    m_xDockingAreaAcceptor = xDockingAreaAcceptor;
    if ( m_xDockingAreaAcceptor.is() )
    {
@@ -1302,13 +1300,6 @@
    else
        implts_destroyElements(); // remove all elements

    if ( !oldDockingAreaWindows.empty() )
    {
        // Reset docking area size for our old docking area acceptor
        awt::Rectangle aEmptyRect;
        xOldDockingAreaAcceptor->setDockingAreaSpace( aEmptyRect );
    }

    if ( pToolbarManager && xDockingAreaAcceptor.is() )
    {
        if ( bAutomaticToolbars )
diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx
index fd633f4..7c061be 100644
--- a/linguistic/source/lngprophelp.cxx
+++ b/linguistic/source/lngprophelp.cxx
@@ -584,8 +584,6 @@

    if (!bRes  &&  GetPropSet().is()  &&  rEvt.Source == GetPropSet())
    {
        sal_Int16 nLngSvcFlags = LinguServiceEventFlags::HYPHENATE_AGAIN;

        sal_Int16   *pnVal = nullptr;
        switch (rEvt.PropertyHandle)
        {
@@ -601,11 +599,8 @@
        bRes = (pnVal != nullptr);
        if (bRes)
        {
            if (nLngSvcFlags)
            {
                LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
                LaunchEvent( aEvt );
            }
            LinguServiceEvent aEvt(GetEvtObj(), LinguServiceEventFlags::HYPHENATE_AGAIN);
            LaunchEvent(aEvt);
        }
    }

diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index b88a23b..b595dc1 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -1204,54 +1204,52 @@
            return;
        XFColor aNullColor = XFColor();

        if ( pXFPara)
        OUString sNumfmt = pCellLayout->GetNumfmtName();
        bool bColorMod = false;
        XFNumberStyle* pNumStyle = nullptr;
        XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
        if (!sNumfmt.isEmpty())
        {
            OUString sNumfmt = pCellLayout->GetNumfmtName();
            bool bColorMod = false;
            XFNumberStyle* pNumStyle = nullptr;
            XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
            if (!sNumfmt.isEmpty())
            pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt));
            XFColor aColor = pNumStyle->GetColor();
            if ( aColor != aNullColor )
                bColorMod = true;//end
        }

        XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
        if ((pStyle && pStyle->GetNumberRight()) || bColorMod)
        {
            std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);

            if (pStyle)
            {
                pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle( sNumfmt));
                XFColor aColor = pNumStyle->GetColor();
                if ( aColor != aNullColor )
                    bColorMod = true;//end
                *xOverStyle = *pStyle;

                if (pStyle->GetNumberRight())
                    xOverStyle->SetAlignType(enumXFAlignEnd);
            }

            XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
            if ((pStyle && pStyle->GetNumberRight()) || bColorMod)
            if (bColorMod)
            {
                std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);

                if (pStyle)
                rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
                if (xFont.is())
                {
                    *xOverStyle = *pStyle;

                    if (pStyle->GetNumberRight())
                        xOverStyle->SetAlignType(enumXFAlignEnd);
                }

                if (bColorMod)
                {
                    rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
                    if (xFont.is())
                    XFColor aColor = xFont->GetColor();
                    if (aColor == aNullColor)
                    {
                        XFColor aColor = xFont->GetColor();
                        if ( aColor == aNullColor )
                        {
                            rtl::Reference<XFFont> pNewFont(new XFFont);
                            aColor = pNumStyle->GetColor();
                            pNewFont->SetColor(aColor);
                            xOverStyle->SetFont(pNewFont);
                        }
                        rtl::Reference<XFFont> pNewFont(new XFFont);
                        aColor = pNumStyle->GetColor();
                        pNewFont->SetColor(aColor);
                        xOverStyle->SetFont(pNewFont);
                    }
                }

                xOverStyle->SetStyleName("");
                OUString StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();

                pXFPara->SetStyleName(StyleName);
            }

            xOverStyle->SetStyleName("");
            OUString StyleName
                = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();

            pXFPara->SetStyleName(StyleName);
        }
    }
}
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index f696c06..2c745ca 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -219,8 +219,7 @@

            for( nLauf = nLast - 1 ; nLauf >= 0 ; nLauf-- )
            {
                if( nLauf != -1 ) // lists the parameter to be excluded
                    aPool << ocSep << eParam[ nLauf ];
                aPool << ocSep << eParam[nLauf];
            }
        }
    }
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx
index 13c554ac..e0da346 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -383,9 +383,8 @@
            case ViewShell::ST_IMPRESS:
            {
                DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
                if (pDrawViewShell != nullptr)
                    if (pDrawViewShell->GetEditMode() == EditMode::MasterPage)
                        bMasterPageMode = true;
                if (pDrawViewShell->GetEditMode() == EditMode::MasterPage)
                    bMasterPageMode = true;
                break;
            }
            default:
diff --git a/stoc/source/corereflection/lrucache.hxx b/stoc/source/corereflection/lrucache.hxx
index e9a89be..b52a05f 100644
--- a/stoc/source/corereflection/lrucache.hxx
+++ b/stoc/source/corereflection/lrucache.hxx
@@ -90,16 +90,13 @@
    , _pHead( nullptr )
    , _pTail( nullptr )
{
    if (_nCachedElements > 0)
    _pBlock.reset(new CacheEntry[_nCachedElements]);
    _pHead = _pBlock.get();
    _pTail = _pBlock.get() + _nCachedElements - 1;
    for (sal_Int32 nPos = _nCachedElements; nPos--;)
    {
        _pBlock.reset(new CacheEntry[_nCachedElements]);
        _pHead  = _pBlock.get();
        _pTail  = _pBlock.get() + _nCachedElements -1;
        for ( sal_Int32 nPos = _nCachedElements; nPos--; )
        {
            _pBlock[nPos].pPred = _pBlock.get() + nPos -1;
            _pBlock[nPos].pSucc = _pBlock.get() + nPos +1;
        }
        _pBlock[nPos].pPred = _pBlock.get() + nPos - 1;
        _pBlock[nPos].pSucc = _pBlock.get() + nPos + 1;
    }
}

diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
index 10dad03..9b1b815 100644
--- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
@@ -792,7 +792,7 @@
        return;
    }

    const drawing::LineStyle eXLS(mpStyleItem ? mpStyleItem->GetValue() : drawing::LineStyle_NONE);
    const drawing::LineStyle eXLS(mpStyleItem->GetValue());
    bool bSelected(false);

    switch(eXLS)
@@ -804,7 +804,7 @@
            bSelected = true;
            break;
        default:
            if(mpDashItem && mxLineStyleList.is())
            if(mxLineStyleList.is())
            {
                const XDash& rDash = mpDashItem->GetDashValue();
                for(long a(0);!bSelected &&  a < mxLineStyleList->Count(); a++)
@@ -840,7 +840,7 @@
            return;
        }

        if (mpStartItem && mxLineEndList.is())
        if (mxLineEndList.is())
        {
            const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
            for(long a(0);!bSelected &&  a < mxLineEndList->Count(); a++)
@@ -869,7 +869,7 @@
            return;
        }

        if (mpEndItem && mxLineEndList.is())
        if (mxLineEndList.is())
        {
            const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
            for(long a(0);!bSelected &&  a < mxLineEndList->Count(); a++)