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 ) ...@@ -166,75 +166,39 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
// SdrMeasureLineDistItem // SdrMeasureLineDistItem
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
if( pItem ) SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
{
long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
SetMetricValue( *m_xMtrFldLineDist, nValue, eUnit );
}
else
{
m_xMtrFldLineDist->set_text(OUString());
}
m_xMtrFldLineDist->save_value(); m_xMtrFldLineDist->save_value();
// SdrMeasureHelplineOverhangItem // SdrMeasureHelplineOverhangItem
pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG ); pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
if( pItem ) SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
{ eUnit);
long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
SetMetricValue( *m_xMtrFldHelplineOverhang, nValue, eUnit );
}
else
{
m_xMtrFldHelplineOverhang->set_text(OUString());
}
m_xMtrFldHelplineOverhang->save_value(); m_xMtrFldHelplineOverhang->save_value();
// SdrMeasureHelplineDistItem // SdrMeasureHelplineDistItem
pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST ); pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
if( pItem ) SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
{ eUnit);
long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
SetMetricValue( *m_xMtrFldHelplineDist, nValue, eUnit );
}
else
{
m_xMtrFldHelplineDist->set_text(OUString());
}
m_xMtrFldHelplineDist->save_value(); m_xMtrFldHelplineDist->save_value();
// SdrMeasureHelpline1LenItem // SdrMeasureHelpline1LenItem
pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN ); pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
if( pItem ) SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
{ eUnit);
long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
SetMetricValue( *m_xMtrFldHelpline1Len, nValue, eUnit );
}
else
{
m_xMtrFldHelpline1Len->set_text(OUString());
}
m_xMtrFldHelpline1Len->save_value(); m_xMtrFldHelpline1Len->save_value();
// SdrMeasureHelpline2LenItem // SdrMeasureHelpline2LenItem
pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN ); pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
if( pItem ) SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
{ eUnit);
long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
SetMetricValue( *m_xMtrFldHelpline2Len, nValue, eUnit );
}
else
{
m_xMtrFldHelpline2Len->set_text(OUString());
}
m_xMtrFldHelpline2Len->save_value(); m_xMtrFldHelpline2Len->save_value();
// SdrMeasureBelowRefEdgeItem // SdrMeasureBelowRefEdgeItem
...@@ -253,15 +217,8 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) ...@@ -253,15 +217,8 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES ); pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
if( pItem == nullptr ) if( pItem == nullptr )
pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES ); pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
if( pItem ) m_xMtrFldDecimalPlaces->set_value(
{ static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue());
sal_Int16 nValue = static_cast<const SdrMeasureDecimalPlacesItem*>( pItem )->GetValue();
m_xMtrFldDecimalPlaces->set_value(nValue);
}
else
{
m_xMtrFldDecimalPlaces->set_text(OUString());
}
m_xMtrFldDecimalPlaces->save_value(); m_xMtrFldDecimalPlaces->save_value();
// SdrMeasureTextRota90Item // SdrMeasureTextRota90Item
......
...@@ -73,11 +73,10 @@ static void checkLdapReturnCode(const sal_Char *aOperation, ...@@ -73,11 +73,10 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
message += OUString::createFromAscii(aOperation) + ": "; message += OUString::createFromAscii(aOperation) + ": ";
} }
message += OUString::createFromAscii(ldap_err2string(aRetCode)) + " (" ; message += OUString::createFromAscii(ldap_err2string(aRetCode)) + " (" ;
sal_Char *stub = nullptr ;
#ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP #ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP
sal_Char* stub = nullptr;
ldap_get_lderrno(aConnection, NULL, &stub) ; ldap_get_lderrno(aConnection, NULL, &stub) ;
#endif
if (stub != nullptr) if (stub != nullptr)
{ {
message += OUString::createFromAscii(stub) ; message += OUString::createFromAscii(stub) ;
...@@ -88,7 +87,10 @@ static void checkLdapReturnCode(const sal_Char *aOperation, ...@@ -88,7 +87,10 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
// This call is thus disabled for the moment. // This call is thus disabled for the moment.
//ldap_memfree(stub) ; //ldap_memfree(stub) ;
} }
else { message += "No additional information" ; } else
#endif
{ message += "No additional information"; }
message += ")" ; message += ")" ;
throw ldap::LdapGenericException(message, nullptr, aRetCode) ; throw ldap::LdapGenericException(message, nullptr, aRetCode) ;
} }
......
...@@ -923,7 +923,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo ...@@ -923,7 +923,7 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
if (nRowBytes < 8 || nPackType == 1) if (nRowBytes < 8 || nPackType == 1)
{ {
if (nWidth && nHeight > pPict->remainingSize() / (sizeof(sal_uInt16) * nWidth)) if (nHeight > pPict->remainingSize() / (sizeof(sal_uInt16) * nWidth))
return 0xffffffff; return 0xffffffff;
} }
else else
...@@ -1021,10 +1021,10 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo ...@@ -1021,10 +1021,10 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
if ( nRowBytes < 8 || nPackType == 1 ) if ( nRowBytes < 8 || nPackType == 1 )
{ {
const size_t nMaxPixels = pPict->remainingSize() / 4; 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) if (nHeight > nMaxRows)
return 0xffffffff; return 0xffffffff;
const size_t nMaxCols = nHeight ? nMaxPixels / nHeight : SAL_MAX_UINT16; const size_t nMaxCols = nMaxPixels / nHeight;
if (nWidth > nMaxCols) if (nWidth > nMaxCols)
return 0xffffffff; return 0xffffffff;
...@@ -1044,10 +1044,10 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo ...@@ -1044,10 +1044,10 @@ sal_uLong PictReader::ReadPixMapEtc( BitmapEx &rBitmap, bool bBaseAddr, bool bCo
else if ( nPackType == 2 ) else if ( nPackType == 2 )
{ {
const size_t nMaxPixels = pPict->remainingSize() / 3; 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) if (nHeight > nMaxRows)
return 0xffffffff; return 0xffffffff;
const size_t nMaxCols = nHeight ? nMaxPixels / nHeight : SAL_MAX_UINT16; const size_t nMaxCols = nMaxPixels / nHeight;
if (nWidth > nMaxCols) if (nWidth > nMaxCols)
return 0xffffffff; return 0xffffffff;
......
...@@ -1238,7 +1238,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki ...@@ -1238,7 +1238,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
m_aAsyncLayoutTimer.Stop(); m_aAsyncLayoutTimer.Stop();
bool bAutomaticToolbars( m_bAutomaticToolbars ); bool bAutomaticToolbars( m_bAutomaticToolbars );
std::vector< Reference< awt::XWindow > > oldDockingAreaWindows;
ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
...@@ -1261,7 +1260,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki ...@@ -1261,7 +1260,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) ); pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
} }
Reference< ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor );
m_xDockingAreaAcceptor = xDockingAreaAcceptor; m_xDockingAreaAcceptor = xDockingAreaAcceptor;
if ( m_xDockingAreaAcceptor.is() ) if ( m_xDockingAreaAcceptor.is() )
{ {
...@@ -1302,13 +1300,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki ...@@ -1302,13 +1300,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki
else else
implts_destroyElements(); // remove all elements 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 ( pToolbarManager && xDockingAreaAcceptor.is() )
{ {
if ( bAutomaticToolbars ) if ( bAutomaticToolbars )
......
...@@ -584,8 +584,6 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt ...@@ -584,8 +584,6 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt
if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet()) if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet())
{ {
sal_Int16 nLngSvcFlags = LinguServiceEventFlags::HYPHENATE_AGAIN;
sal_Int16 *pnVal = nullptr; sal_Int16 *pnVal = nullptr;
switch (rEvt.PropertyHandle) switch (rEvt.PropertyHandle)
{ {
...@@ -601,11 +599,8 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt ...@@ -601,11 +599,8 @@ bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt
bRes = (pnVal != nullptr); bRes = (pnVal != nullptr);
if (bRes) if (bRes)
{ {
if (nLngSvcFlags) LinguServiceEvent aEvt(GetEvtObj(), LinguServiceEventFlags::HYPHENATE_AGAIN);
{ LaunchEvent(aEvt);
LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
LaunchEvent( aEvt );
}
} }
} }
......
...@@ -1204,54 +1204,52 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_ ...@@ -1204,54 +1204,52 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
return; return;
XFColor aNullColor = XFColor(); 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(); pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt));
bool bColorMod = false; XFColor aColor = pNumStyle->GetColor();
XFNumberStyle* pNumStyle = nullptr; if ( aColor != aNullColor )
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); bColorMod = true;//end
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()); XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
if ((pStyle && pStyle->GetNumberRight()) || bColorMod) if ((pStyle && pStyle->GetNumberRight()) || bColorMod)
{ {
std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle); std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
if (pStyle) if (pStyle)
{ {
*xOverStyle = *pStyle; *xOverStyle = *pStyle;
if (pStyle->GetNumberRight()) if (pStyle->GetNumberRight())
xOverStyle->SetAlignType(enumXFAlignEnd); xOverStyle->SetAlignType(enumXFAlignEnd);
} }
if (bColorMod) if (bColorMod)
{
rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
if (xFont.is())
{ {
rtl::Reference<XFFont> xFont = xOverStyle->GetFont(); XFColor aColor = xFont->GetColor();
if (xFont.is()) if (aColor == aNullColor)
{ {
XFColor aColor = xFont->GetColor(); rtl::Reference<XFFont> pNewFont(new XFFont);
if ( aColor == aNullColor ) aColor = pNumStyle->GetColor();
{ pNewFont->SetColor(aColor);
rtl::Reference<XFFont> pNewFont(new XFFont); xOverStyle->SetFont(pNewFont);
aColor = pNumStyle->GetColor();
pNewFont->SetColor(aColor);
xOverStyle->SetFont(pNewFont);
}
} }
} }
}
xOverStyle->SetStyleName(""); xOverStyle->SetStyleName("");
OUString StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName(); 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 ...@@ -219,8 +219,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nCnt, const sal_Char* pExtStri
for( nLauf = nLast - 1 ; nLauf >= 0 ; nLauf-- ) 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) ...@@ -383,9 +383,8 @@ void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout)
case ViewShell::ST_IMPRESS: case ViewShell::ST_IMPRESS:
{ {
DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell); DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
if (pDrawViewShell != nullptr) if (pDrawViewShell->GetEditMode() == EditMode::MasterPage)
if (pDrawViewShell->GetEditMode() == EditMode::MasterPage) bMasterPageMode = true;
bMasterPageMode = true;
break; break;
} }
default: default:
......
...@@ -90,16 +90,13 @@ inline LRU_Cache< t_Key, t_Val, t_KeyHash >::LRU_Cache() ...@@ -90,16 +90,13 @@ inline LRU_Cache< t_Key, t_Val, t_KeyHash >::LRU_Cache()
, _pHead( nullptr ) , _pHead( nullptr )
, _pTail( 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]); _pBlock[nPos].pPred = _pBlock.get() + nPos - 1;
_pHead = _pBlock.get(); _pBlock[nPos].pSucc = _pBlock.get() + nPos + 1;
_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;
}
} }
} }
......
...@@ -792,7 +792,7 @@ void LinePropertyPanelBase::SelectLineStyle() ...@@ -792,7 +792,7 @@ void LinePropertyPanelBase::SelectLineStyle()
return; return;
} }
const drawing::LineStyle eXLS(mpStyleItem ? mpStyleItem->GetValue() : drawing::LineStyle_NONE); const drawing::LineStyle eXLS(mpStyleItem->GetValue());
bool bSelected(false); bool bSelected(false);
switch(eXLS) switch(eXLS)
...@@ -804,7 +804,7 @@ void LinePropertyPanelBase::SelectLineStyle() ...@@ -804,7 +804,7 @@ void LinePropertyPanelBase::SelectLineStyle()
bSelected = true; bSelected = true;
break; break;
default: default:
if(mpDashItem && mxLineStyleList.is()) if(mxLineStyleList.is())
{ {
const XDash& rDash = mpDashItem->GetDashValue(); const XDash& rDash = mpDashItem->GetDashValue();
for(long a(0);!bSelected && a < mxLineStyleList->Count(); a++) for(long a(0);!bSelected && a < mxLineStyleList->Count(); a++)
...@@ -840,7 +840,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart) ...@@ -840,7 +840,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
return; return;
} }
if (mpStartItem && mxLineEndList.is()) if (mxLineEndList.is())
{ {
const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue(); const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
for(long a(0);!bSelected && a < mxLineEndList->Count(); a++) for(long a(0);!bSelected && a < mxLineEndList->Count(); a++)
...@@ -869,7 +869,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart) ...@@ -869,7 +869,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
return; return;
} }
if (mpEndItem && mxLineEndList.is()) if (mxLineEndList.is())
{ {
const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue(); const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
for(long a(0);!bSelected && a < mxLineEndList->Count(); a++) 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