summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-10-28 00:13:29 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-10-28 07:55:59 +0100
commit5f0ddb2d2068a4388a7df12cd0e11f628b91e4c0 (patch)
tree2007c4a1f6c21a9f0d5a11aab60a10cd178d1d8b /sc/source/ui
parent8522572cdd27f62a031bb07c9cf7f6f85e8453ad (diff)
tdf#120703 PVS: V547 Expression is always true/false
Change-Id: Ic92cc594979cac2edac04a085957398672a5dfcc Reviewed-on: https://gerrit.libreoffice.org/62450 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/Accessibility/AccessibleCell.cxx17
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx12
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx5
-rw-r--r--sc/source/ui/app/client.cxx6
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx11
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx2
-rw-r--r--sc/source/ui/docshell/docsh.cxx14
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx14
-rw-r--r--sc/source/ui/view/cellsh1.cxx22
-rw-r--r--sc/source/ui/view/cellsh2.cxx16
10 files changed, 36 insertions, 83 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx
index d07a2a07f3fb..0c414eaf1beb 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -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;
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 6966e9ac9428..fc59f7a4acc8 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -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
}
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index faff13dda9f7..d69114e07517 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -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
{
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
index 06b13352aeba..316e31bf875f 100644
--- a/sc/source/ui/app/client.cxx
+++ b/sc/source/ui/app/client.cxx
@@ -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)
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index b2270a2bd80c..622d54755641 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -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);
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index a83b0c376ab5..3cae1be94c0b 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -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,
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 2968ea7f53c0..0a2a3525e11e 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -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
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 385fbbee115e..1bbfe5144d1a 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -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;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 432469836a38..c57d3e75ac98 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -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;
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 390e396b43c4..41343911fe3f 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -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
{