Kaydet (Commit) 628e96ce authored tarafından Mike Kaganski's avatar Mike Kaganski

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

Change-Id: I3432afca1ee9bf9e8adce1d55d58d57bf1a09cb4
Reviewed-on: https://gerrit.libreoffice.org/62847
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 9d5365f7
......@@ -166,75 +166,39 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
// 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 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
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
......
......@@ -73,11 +73,10 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
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 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
// 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) ;
}
......
......@@ -923,7 +923,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
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 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
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 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
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;
......
......@@ -1238,7 +1238,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
m_aAsyncLayoutTimer.Stop();
bool bAutomaticToolbars( m_bAutomaticToolbars );
std::vector< Reference< awt::XWindow > > oldDockingAreaWindows;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
......@@ -1261,7 +1260,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
}
Reference< ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor );
m_xDockingAreaAcceptor = xDockingAreaAcceptor;
if ( m_xDockingAreaAcceptor.is() )
{
......@@ -1302,13 +1300,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
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 )
......
......@@ -584,8 +584,6 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt
if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet())
{
sal_Int16 nLngSvcFlags = LinguServiceEventFlags::HYPHENATE_AGAIN;
sal_Int16 *pnVal = nullptr;
switch (rEvt.PropertyHandle)
{
......@@ -601,11 +599,8 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt
bRes = (pnVal != nullptr);
if (bRes)
{
if (nLngSvcFlags)
{
LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
LaunchEvent( aEvt );
}
LinguServiceEvent aEvt(GetEvtObj(), LinguServiceEventFlags::HYPHENATE_AGAIN);
LaunchEvent(aEvt);
}
}
......
......@@ -1204,54 +1204,52 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
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
}
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);
XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
if ((pStyle && pStyle->GetNumberRight()) || bColorMod)
{
std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
if (pStyle)
{
*xOverStyle = *pStyle;
if (pStyle)
{
*xOverStyle = *pStyle;
if (pStyle->GetNumberRight())
xOverStyle->SetAlignType(enumXFAlignEnd);
}
if (pStyle->GetNumberRight())
xOverStyle->SetAlignType(enumXFAlignEnd);
}
if (bColorMod)
if (bColorMod)
{
rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
if (xFont.is())
{
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();
xOverStyle->SetStyleName("");
OUString StyleName
= pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
pXFPara->SetStyleName(StyleName);
}
pXFPara->SetStyleName(StyleName);
}
}
}
......
......@@ -219,8 +219,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nCnt, const sal_Char* pExtStri
for( nLauf = nLast - 1 ; nLauf >= 0 ; nLauf-- )
{
if( nLauf != -1 ) // lists the parameter to be excluded
aPool << ocSep << eParam[ nLauf ];
aPool << ocSep << eParam[nLauf];
}
}
}
......
......@@ -383,9 +383,8 @@ void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout)
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:
......
......@@ -90,16 +90,13 @@ inline LRU_Cache< t_Key, t_Val, t_KeyHash >::LRU_Cache()
, _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;
}
}
......
......@@ -792,7 +792,7 @@ void LinePropertyPanelBase::SelectLineStyle()
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 @@ void LinePropertyPanelBase::SelectLineStyle()
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 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
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 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
return;
}
if (mpEndItem && mxLineEndList.is())
if (mxLineEndList.is())
{
const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment