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

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

Change-Id: Ic92cc594979cac2edac04a085957398672a5dfcc
Reviewed-on: https://gerrit.libreoffice.org/62450
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 8522572c
......@@ -194,11 +194,9 @@ sal_Size IsciiDevanagariToUnicode::convert(
continue;
if (eAction == BAD_INPUT_STOP)
break;
if (eAction == BAD_INPUT_NO_OUTPUT)
{
nInfo |= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL;
break;
}
assert(eAction == BAD_INPUT_NO_OUTPUT);
nInfo |= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL;
break;
}
++nConverted;
if (bDouble)
......
......@@ -1739,14 +1739,6 @@ bool ScQueryCellIterator::BinarySearch()
{
size_t nMid = (nLo+nHi)/2;
size_t i = nMid;
if (i > nHi)
{
if (nMid > 0)
nHi = nMid - 1;
else
bDone = true;
continue; // while
}
aCellData = aIndexer.getCell(i);
aCell = aCellData.first;
......
......@@ -445,24 +445,21 @@ void ScAccessibleCell::AddRelation(const ScRange& rRange,
uno::Reference < XAccessibleTable > xTable ( getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY );
if (xTable.is())
{
sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() -
const sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() -
rRange.aStart.Col() + 1) * (rRange.aEnd.Row() -
rRange.aStart.Row() + 1));
uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount );
uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray();
if (pTargetSet)
sal_uInt32 nPos(0);
for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow)
{
sal_uInt32 nPos(0);
for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow)
for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol)
{
for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol)
{
pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol);
++nPos;
}
pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol);
++nPos;
}
OSL_ENSURE(nCount == nPos, "something wents wrong");
}
OSL_ENSURE(nCount == nPos, "something wents wrong");
AccessibleRelation aRelation;
aRelation.RelationType = aRelationType;
aRelation.TargetSet = aTargetSet;
......
......@@ -1860,17 +1860,13 @@ void SAL_CALL
if (xAccessible.is())
{
bool bWasTableSelected(IsTableSelected());
if (mpChildrenShapes)
mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high
mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high
if (bWasTableSelected)
mpViewShell->SelectAll();
}
else
{
if (mpViewShell)
mpViewShell->SelectAll();
mpViewShell->SelectAll();
}
}
}
......@@ -1998,9 +1994,7 @@ void SAL_CALL
uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
if (xAccessible.is())
{
if (mpChildrenShapes)
mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high
mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is too high
if (bTabMarked)
mpViewShell->SelectAll(); // select the table again
}
......
......@@ -444,10 +444,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
{
OSL_ENSURE(!((nX > 0) && (nY > 0)), "should not be possible to add row and column at the same time");
nId = AccessibleTableModelChangeType::INSERT;
if (nX < 0)
nY = aRange.aEnd.Row() - aRange.aStart.Row();
else
nX = aRange.aEnd.Col() - aRange.aStart.Col();
nX = aRange.aEnd.Col() - aRange.aStart.Col();
}
else
{
......
......@@ -171,11 +171,7 @@ void ScClient::ObjectAreaChanged()
pDrawObj->setSuppressSetVisAreaSize(false);
// set document modified (SdrModel::SetChanged is not used)
// TODO/LATER: is there a reason that this code is not executed in Draw?
// SfxViewShell* pSfxViewSh = GetViewShell();
// ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( pSfxViewSh );
if (pViewSh)
pViewSh->GetViewData().GetDocShell()->SetDrawModified();
pViewSh->GetViewData().GetDocShell()->SetDrawModified();
}
if (pDrawObj)
......
......@@ -1242,14 +1242,11 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
return CreatePivotTable(*pNewObj, bRecord, bApi);
}
if (pOldObj)
{
if (!pNewObj)
return RemovePivotTable(*pOldObj, bRecord, bApi);
if (!pNewObj)
return RemovePivotTable(*pOldObj, bRecord, bApi);
if (pOldObj == pNewObj)
return UpdatePivotTable(*pOldObj, bRecord, bApi);
}
if (pOldObj == pNewObj)
return UpdatePivotTable(*pOldObj, bRecord, bApi);
OSL_ASSERT(pOldObj && pNewObj && pOldObj != pNewObj);
......
......@@ -580,7 +580,7 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
nEndCol+nFormulaCols, nEndRow, nTab,
InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, *pRedoDoc);
std::unique_ptr<ScDBData> pRedoDBData(pDBData ? new ScDBData( *pDBData ) : nullptr);
std::unique_ptr<ScDBData> pRedoDBData(new ScDBData(*pDBData));
rDocShell.GetUndoManager()->AddUndoAction(
o3tl::make_unique<ScUndoImportData>( &rDocShell, nTab,
......
......@@ -779,7 +779,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
bool bChecked = aWarningBox.get_active();
if (bChecked)
{
aAppOptions.SetShowSharedDocumentWarning( !bChecked );
aAppOptions.SetShowSharedDocumentWarning(false);
SC_MOD()->SetAppOptions( aAppOptions );
}
}
......@@ -1772,17 +1772,11 @@ bool ScDocShell::Save()
PrepareSaveGuard aPrepareGuard( *this);
SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
if (pFrame1)
if (const auto pFrame1 = SfxViewFrame::GetFirst(this))
{
vcl::Window* pWindow = &pFrame1->GetWindow();
if ( pWindow )
if (auto pSysWin = pFrame1->GetWindow().GetSystemWindow())
{
vcl::Window* pSysWin = pWindow->GetSystemWindow();
if ( pSysWin )
{
pSysWin->SetAccessibleName(OUString());
}
pSysWin->SetAccessibleName(OUString());
}
}
// wait cursor is handled with progress bar
......
......@@ -313,18 +313,12 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
break;
case SID_OPEN_HYPERLINK:
if (const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection())
{
if ( pOutView )
const SvxFieldData* pField = pFieldItem->GetField();
if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
{
const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
if ( pFieldItem )
{
const SvxFieldData* pField = pFieldItem->GetField();
if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
{
ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
}
}
ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame());
}
}
break;
......
......@@ -1523,7 +1523,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if ( bRet )
{
rReq.SetReturnValue(SfxInt16Item(nSlot, bRet ? 1 : 0)); // 1 = success, 0 = fail
rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
rReq.Done();
}
else
......@@ -2482,20 +2482,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if ( pReqArgs )
{
const SfxStringItem* pItem =
static_cast<const SfxStringItem*>(&pReqArgs->Get( SID_SELECT_SCENARIO ));
if( pItem )
{
pTabViewShell->UseScenario( pItem->GetValue() );
//! why should the return value be valid?!?!
rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
rReq.Done();
}
else
{
OSL_FAIL("nullptr");
}
const SfxStringItem& rItem
= static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_SCENARIO));
pTabViewShell->UseScenario(rItem.GetValue());
//! why should the return value be valid?!?!
rReq.SetReturnValue(SfxStringItem(SID_SELECT_SCENARIO, rItem.GetValue()));
rReq.Done();
}
}
break;
......
......@@ -713,18 +713,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
{
if ( pReqArgs )
{
const SfxStringItem* pItem =
static_cast<const SfxStringItem*>(&pReqArgs->Get( SID_SELECT_DB ));
if( pItem )
{
pTabViewShell->GotoDBArea( pItem->GetValue() );
rReq.Done();
}
else
{
OSL_FAIL("NULL");
}
const SfxStringItem& rItem
= static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_DB));
pTabViewShell->GotoDBArea(rItem.GetValue());
rReq.Done();
}
else
{
......
......@@ -2132,7 +2132,6 @@ IMPL_LINK_NOARG(SfxCustomPropertiesPage, AddHdl, Button*, void)
bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet* rSet )
{
bool bModified = false;
const SfxPoolItem* pItem = nullptr;
SfxDocumentInfoItem* pInfo = nullptr;
bool bMustDelete = false;
......@@ -2168,16 +2167,13 @@ bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet* rSet )
}
}
bModified = true; //!!!
if (pInfo)
{
if ( bModified )
rSet->Put( *pInfo );
rSet->Put(*pInfo);
if ( bMustDelete )
delete pInfo;
}
return bModified;
return true;
}
void SfxCustomPropertiesPage::Reset( const SfxItemSet* rItemSet )
......
......@@ -1543,10 +1543,10 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempIfNo )
// The versions are numbered starting with 1, versions with
// negative versions numbers are counted backwards from the
// current version
short nVersion = pVersion ? pVersion->GetValue() : 0;
short nVersion = pVersion->GetValue();
if ( nVersion<0 )
nVersion = static_cast<short>(pImpl->aVersions.getLength()) + nVersion;
else if ( nVersion )
else // nVersion > 0; pVersion->GetValue() != 0 was the condition to this block
nVersion--;
util::RevisionTag& rTag = pImpl->aVersions[nVersion];
......
......@@ -222,8 +222,7 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReaderPtr& rpRdr,
pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
aOpt.ReadUserData( static_cast<const SfxStringItem*>(pItem)->GetValue() );
if( pRead )
pRead->GetReaderOpt().SetASCIIOpts( aOpt );
pRead->GetReaderOpt().SetASCIIOpts( aOpt );
}
return pRead;
......@@ -239,17 +238,11 @@ bool SwDocShell::ConvertFrom( SfxMedium& rMedium )
tools::SvRef<SotStorage> pStg=pRead->getSotStorageRef(); // #i45333# save sot storage ref in case of recursive calls
m_xDoc->setDocAccTitle(OUString());
SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
if (pFrame1)
if (const auto pFrame1 = SfxViewFrame::GetFirst(this))
{
vcl::Window* pWindow = &pFrame1->GetWindow();
if ( pWindow )
if (auto pSysWin = pFrame1->GetWindow().GetSystemWindow())
{
vcl::Window* pSysWin = pWindow->GetSystemWindow();
if ( pSysWin )
{
pSysWin->SetAccessibleName(OUString());
}
pSysWin->SetAccessibleName(OUString());
}
}
SwWait aWait( *this, true );
......
......@@ -747,7 +747,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
GetDoc()->getIDocumentDeviceAccess().setPrinter( pSavePrinter, true, true);
//pSavePrinter must not be deleted again
}
pViewFrame->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2));
pViewFrame->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, false)); // not SID_VIEWSHELL2
pViewFrame->GetBindings().Invalidate( SID_NEWWINDOW );
pViewFrame->GetBindings().Invalidate( SID_BROWSER_MODE );
pViewFrame->GetBindings().Invalidate( FN_PRINT_LAYOUT );
......
......@@ -2357,12 +2357,9 @@ bool SwDBManager::ToRecordId(sal_Int32 nSet)
return false;
bool bRet = false;
sal_Int32 nAbsPos = nSet;
if(nAbsPos >= 0)
{
bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
pImpl->pMergeData->bEndOfDB = !bRet;
}
assert(nAbsPos >= 0);
bRet = lcl_MoveAbsolute(pImpl->pMergeData, nAbsPos);
pImpl->pMergeData->bEndOfDB = !bRet;
return bRet;
}
......
......@@ -1458,7 +1458,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
if( KEY_UP == nKey ) nKey = KEY_LEFT;
else if( KEY_DOWN == nKey ) nKey = KEY_RIGHT;
else if( KEY_LEFT == nKey ) nKey = KEY_DOWN;
else if( KEY_RIGHT == nKey ) nKey = KEY_UP;
else /* KEY_RIGHT == nKey */ nKey = KEY_UP;
}
if ( rSh.IsInRightToLeftText() )
......
......@@ -54,10 +54,8 @@ void SwPageExample::UpdateExample( const SfxItemSet& rSet )
if ( rSet.GetItemState( nWhich, false ) == SfxItemState::SET )
{
// alignment
const SvxPageItem* pPage = static_cast<const SvxPageItem*>(&rSet.Get( nWhich ));
if ( pPage )
SetUsage( pPage->GetPageUsage() );
const SvxPageItem& rPage = static_cast<const SvxPageItem&>(rSet.Get(nWhich));
SetUsage(rPage.GetPageUsage());
}
nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE );
......
......@@ -1679,7 +1679,7 @@ sal_Bool SAL_CALL CachedContentResultSet
if( m_nRow )
return false;
if( m_nKnownCount )
return !m_nRow;
return true;
if( m_bFinalCount )
return false;
......@@ -1717,7 +1717,7 @@ sal_Bool SAL_CALL CachedContentResultSet
if( m_nRow != 1 )
return false;
if( m_nKnownCount )
return m_nRow == 1;
return true;
if( m_bFinalCount )
return false;
......
......@@ -156,11 +156,8 @@ namespace DOM
if (nullptr == m_aAttrPtr->children) {
return OUString();
}
char const*const pContent((m_aAttrPtr->children)
? reinterpret_cast<char const*>(m_aAttrPtr->children->content)
: "");
OUString const ret(pContent, strlen(pContent), RTL_TEXTENCODING_UTF8);
return ret;
char const*const pContent(reinterpret_cast<char const*>(m_aAttrPtr->children->content));
return OUString(pContent, strlen(pContent), RTL_TEXTENCODING_UTF8);
}
/**
......
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