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

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

Change-Id: I2b2ea62ff4ed3e16cd4fa2a5e588d001d21121cb
Reviewed-on: https://gerrit.libreoffice.org/62465
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 1132e591
...@@ -58,18 +58,14 @@ template< typename ListBoxType > ...@@ -58,18 +58,14 @@ template< typename ListBoxType >
bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, sal_Int32 nEmptyPos = LISTBOX_APPEND ) bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, sal_Int32 nEmptyPos = LISTBOX_APPEND )
{ {
bool bEmpty = false; bool bEmpty = false;
const OUString* pStr = rStrings.getConstArray(); for (const OUString& str : rStrings)
if( pStr )
{ {
for( const OUString* pEnd = pStr + rStrings.getLength(); pStr != pEnd; ++pStr ) if (!str.isEmpty())
rLBox.InsertEntry(str);
else
{ {
if( !pStr->isEmpty() ) rLBox.InsertEntry(ScResId(STR_EMPTYDATA), nEmptyPos);
rLBox.InsertEntry( *pStr ); bEmpty = true;
else
{
rLBox.InsertEntry( ScResId( STR_EMPTYDATA ), nEmptyPos );
bEmpty = true;
}
} }
} }
return bEmpty; return bEmpty;
......
...@@ -908,16 +908,13 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue ...@@ -908,16 +908,13 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue
{ {
rSeq.realloc(3); rSeq.realloc(3);
beans::PropertyValue* pSeq = rSeq.getArray(); beans::PropertyValue* pSeq = rSeq.getArray();
if(pSeq) sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
{ pSeq[0].Name = SC_VIEWID;
sal_uInt16 nViewID(GetViewFrame()->GetCurViewId()); pSeq[0].Value <<= SC_VIEW + OUString::number(nViewID);
pSeq[0].Name = SC_VIEWID; pSeq[1].Name = SC_ZOOMVALUE;
pSeq[0].Value <<= SC_VIEW + OUString::number(nViewID); pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
pSeq[1].Name = SC_ZOOMVALUE; pSeq[2].Name = "PageNumber";
pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom()); pSeq[2].Value <<= pPreview->GetPageNo();
pSeq[2].Name = "PageNumber";
pSeq[2].Value <<= pPreview->GetPageNo();
}
// Common SdrModel processing // Common SdrModel processing
if (ScDrawLayer* pDrawLayer = GetDocument().GetDrawLayer()) if (ScDrawLayer* pDrawLayer = GetDocument().GetDrawLayer())
...@@ -926,31 +923,23 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue ...@@ -926,31 +923,23 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue
void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq) void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq)
{ {
sal_Int32 nCount(rSeq.getLength()); for (const auto& propval : rSeq)
if (nCount)
{ {
const beans::PropertyValue* pSeq = rSeq.getConstArray(); if (propval.Name == SC_ZOOMVALUE)
if(pSeq)
{ {
for(sal_Int32 i = 0; i < nCount; i++, pSeq++) sal_Int32 nTemp = 0;
{ if (propval.Value >>= nTemp)
OUString sName(pSeq->Name); pPreview->SetZoom(sal_uInt16(nTemp));
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);
}
} }
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);
} }
} }
......
...@@ -726,40 +726,42 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools ...@@ -726,40 +726,42 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools
if ( getSdrModelFromSdrPage().isLocked()) if ( getSdrModelFromSdrPage().isLocked())
break; break;
SdrObject* pObj = const_cast<SdrObject*>(&rObj); if (!mbMaster)
if (pObj)
{ {
if (!mbMaster) if (rObj.GetUserCall())
{ {
if( pObj->GetUserCall() ) SdrObject& _rObj = const_cast<SdrObject&>(rObj);
{ SfxUndoManager* pUndoManager
SfxUndoManager* pUndoManager = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager(); = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); .GetUndoManager();
const bool bUndo
if( bUndo ) = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectUserCall>(*pObj) );
if (bUndo)
// Object was resized by user and does not listen to its slide anymore pUndoManager->AddUndoAction(
pObj->SetUserCall(nullptr); 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 SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
// object on all pages .GetSdPage(i, mePageKind);
sal_uInt16 nPageCount = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPageCount(mePageKind);
for (sal_uInt16 i = 0; i < nPageCount; i++) if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
{ {
SdPage* pLoopPage = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPage(i, mePageKind); // Page listens to this master page, therefore
// adjust AutoLayout
if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage())) pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
{
// Page listens to this master page, therefore
// adjust AutoLayout
pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
}
} }
} }
} }
......
...@@ -662,9 +662,8 @@ void SwPagePreview::ExecPgUpAndPgDown( const bool _bPgUp, ...@@ -662,9 +662,8 @@ void SwPagePreview::ExecPgUpAndPgDown( const bool _bPgUp,
// Then all for the SwPagePreview // Then all for the SwPagePreview
void SwPagePreview::Execute( SfxRequest &rReq ) void SwPagePreview::Execute( SfxRequest &rReq )
{ {
int eMvMode; int eMvMode = SwPagePreviewWin::MV_DOC_END;
sal_uInt8 nRow = 1; sal_uInt8 nRow = 1;
bool bRetVal = false;
bool bRefresh = true; bool bRefresh = true;
switch(rReq.GetSlot()) switch(rReq.GetSlot())
...@@ -867,18 +866,15 @@ void SwPagePreview::Execute( SfxRequest &rReq ) ...@@ -867,18 +866,15 @@ void SwPagePreview::Execute( SfxRequest &rReq )
break; break;
case FN_START_OF_LINE: case FN_START_OF_LINE:
case FN_START_OF_DOCUMENT: case FN_START_OF_DOCUMENT:
m_pViewWin->SetSelectedPage( 1 ); eMvMode = SwPagePreviewWin::MV_DOC_STT;
eMvMode = SwPagePreviewWin::MV_DOC_STT; bRetVal = true; goto MOVEPAGE; SAL_FALLTHROUGH;
case FN_END_OF_LINE: case FN_END_OF_LINE:
case FN_END_OF_DOCUMENT: case FN_END_OF_DOCUMENT:
m_pViewWin->SetSelectedPage( mnPageCount ); m_pViewWin->SetSelectedPage(eMvMode == SwPagePreviewWin::MV_DOC_STT ? 1 : mnPageCount);
eMvMode = SwPagePreviewWin::MV_DOC_END; bRetVal = true; goto MOVEPAGE;
MOVEPAGE:
{ {
bool bRet = ChgPage( eMvMode ); bool bRet = ChgPage( eMvMode );
// return value for Basic // return value for Basic
if(bRetVal) rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), !bRet));
bRefresh = bRet; bRefresh = bRet;
rReq.Done(); rReq.Done();
......
...@@ -765,8 +765,8 @@ void ImplGetLogFontFromFontSelect( HDC hDC, ...@@ -765,8 +765,8 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
aName = rFont.GetFamilyName().getToken( 0, ';' ); aName = rFont.GetFamilyName().getToken( 0, ';' );
UINT nNameLen = aName.getLength(); UINT nNameLen = aName.getLength();
if ( nNameLen > (sizeof( rLogFont.lfFaceName )/sizeof( wchar_t ))-1 ) if (nNameLen >= LF_FACESIZE)
nNameLen = (sizeof( rLogFont.lfFaceName )/sizeof( wchar_t ))-1; nNameLen = LF_FACESIZE - 1;
memcpy( rLogFont.lfFaceName, aName.getStr(), nNameLen*sizeof( wchar_t ) ); memcpy( rLogFont.lfFaceName, aName.getStr(), nNameLen*sizeof( wchar_t ) );
rLogFont.lfFaceName[nNameLen] = 0; rLogFont.lfFaceName[nNameLen] = 0;
...@@ -827,8 +827,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC, ...@@ -827,8 +827,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
{ {
// restore non-vertical name if not vertical mode isn't available // restore non-vertical name if not vertical mode isn't available
memcpy( &rLogFont.lfFaceName[0], aName.getStr(), nNameLen*sizeof(wchar_t) ); 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. // keep it upright and create the font for sideway glyphs later.
rLogFont.lfEscapement = rLogFont.lfEscapement - 2700; rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
rLogFont.lfOrientation = rLogFont.lfEscapement; rLogFont.lfOrientation = rLogFont.lfEscapement;
......
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