summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-09-30 09:37:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-09-30 12:36:51 +0200
commitb29ec8b26bddc03661c527b603863d9e738d1210 (patch)
tree829f01d36d867f717d4a3c9373842510bbc76e77 /sc/source/ui/view
parent9373320fc88c1582a2ad25bda9c5264c7c58a97e (diff)
loplugin:reducevarscope in sc
Change-Id: If88c71351fb157b8eab242fceb65422f05eec3d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103645 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/cellsh1.cxx9
-rw-r--r--sc/source/ui/view/cellsh3.cxx2
-rw-r--r--sc/source/ui/view/drawvie4.cxx3
-rw-r--r--sc/source/ui/view/editsh.cxx5
-rw-r--r--sc/source/ui/view/formatsh.cxx4
-rw-r--r--sc/source/ui/view/output.cxx3
-rw-r--r--sc/source/ui/view/output2.cxx2
-rw-r--r--sc/source/ui/view/tabview.cxx12
-rw-r--r--sc/source/ui/view/tabvwshf.cxx3
-rw-r--r--sc/source/ui/view/viewfun2.cxx2
-rw-r--r--sc/source/ui/view/viewfunc.cxx5
11 files changed, 19 insertions, 31 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index a55673827585..1da99b474f0a 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -802,7 +802,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
SCROW nStartRow;
SCCOL nEndCol;
SCROW nEndRow;
- SCTAB nStartTab, nEndTab;
GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
SCCOL nFillCol = GetViewData()->GetRefEndX();
@@ -825,6 +824,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
}
+ SCTAB nStartTab, nEndTab;
GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
nEndCol,nEndRow,nEndTab );
}
@@ -1336,16 +1336,15 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case FID_INS_CELL_CONTENTS:
{
- InsertDeleteFlags nFlags = InsertDeleteFlags::NONE;
- ScPasteFunc nFunction = ScPasteFunc::NONE;
- InsCellCmd eMoveMode = INS_NONE;
-
ScDocument& rDoc = GetViewData()->GetDocument();
bool bOtherDoc = !rDoc.IsClipboardSource();
// keep a reference in case the clipboard is changed during dialog or PasteFromClip
const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin()));
if ( pOwnClip )
{
+ InsertDeleteFlags nFlags = InsertDeleteFlags::NONE;
+ ScPasteFunc nFunction = ScPasteFunc::NONE;
+ InsCellCmd eMoveMode = INS_NONE;
bool bSkipEmpty = false;
bool bTranspose = false;
bool bAsLink = false;
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 5cc6e7691813..538f8a4bb949 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -576,7 +576,6 @@ void ScCellShell::Execute( SfxRequest& rReq )
SCTAB i=1;
OUString aBaseName;
OUString aName;
- OUString aComment;
Color aColor;
ScScenarioFlags nFlags;
@@ -630,6 +629,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
ScopedVclPtr<AbstractScNewScenarioDlg> pNewDlg(pFact->CreateScNewScenarioDlg(pTabViewShell->GetFrameWeld(), aName, false, bSheetProtected));
if ( pNewDlg->Execute() == RET_OK )
{
+ OUString aComment;
pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index 3066fe253ba9..3584e270e3be 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -459,10 +459,9 @@ void ScDrawView::SetMarkedOriginalSize()
else
{
MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( static_cast<SdrOle2Obj*>(pObj)->GetAspect() ) );
- awt::Size aSz;
try
{
- aSz = xObj->getVisualAreaSize( static_cast<SdrOle2Obj*>(pObj)->GetAspect() );
+ awt::Size aSz = xObj->getVisualAreaSize( static_cast<SdrOle2Obj*>(pObj)->GetAspect() );
aOriginalSize = OutputDevice::LogicToLogic(
Size( aSz.Width, aSz.Height ),
MapMode(aUnit),
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c86437f6de8a..9e8768fe27d6 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -949,13 +949,12 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq)
{
if (pArgs)
{
- Color aColor;
- OUString sColor;
const SfxPoolItem* pColorStringItem = nullptr;
if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_ATTR_COLOR_STR, false, &pColorStringItem ) )
{
- sColor = static_cast<const SfxStringItem*>( pColorStringItem )->GetValue();
+ Color aColor;
+ OUString sColor = static_cast<const SfxStringItem*>( pColorStringItem )->GetValue();
if ( sColor == "transparent" )
aColor = COL_TRANSPARENT;
else
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 7075fbd5d02a..585e19c02a0b 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1466,8 +1466,6 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
case SID_ATTR_CHAR_UNDERLINE:
{
- FontLineStyle eUnderline;
-
if( pSet )
{
const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
@@ -1490,7 +1488,7 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
else
{
SvxUnderlineItem aUnderline( pAttrs->GetItem( ATTR_FONT_UNDERLINE ) );
- eUnderline = (LINESTYLE_NONE != aUnderline.GetLineStyle())
+ FontLineStyle eUnderline = (LINESTYLE_NONE != aUnderline.GetLineStyle())
? LINESTYLE_NONE
: LINESTYLE_SINGLE;
aUnderline.SetLineStyle( eUnderline );
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 046c70e4b4b1..584125b5cef8 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -2236,10 +2236,9 @@ void ScOutputData::DrawChangeTrack()
const ScChangeAction* pAction = pTrack->GetFirst();
while (pAction)
{
- ScChangeActionType eActionType;
if ( pAction->IsVisible() )
{
- eActionType = pAction->GetType();
+ ScChangeActionType eActionType = pAction->GetType();
const ScBigRange& rBig = pAction->GetBigRange();
if ( rBig.aStart.Tab() == nTab )
{
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 6d123bccacf6..39aaf01d9957 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -840,11 +840,11 @@ static void lcl_DoHyperlinkResult( const OutputDevice* pDev, const tools::Rectan
{
vcl::PDFExtOutDevData* pPDFData = dynamic_cast< vcl::PDFExtOutDevData* >( pDev->GetExtOutDevData() );
- OUString aCellText;
OUString aURL;
if (rCell.meType == CELLTYPE_FORMULA)
{
ScFormulaCell* pFCell = rCell.mpFormula;
+ OUString aCellText;
if ( pFCell->IsHyperLinkCell() )
pFCell->GetURLResult( aURL, aCellText );
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index cc89c444c2e2..40a42ea8d86d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -827,7 +827,6 @@ IMPL_LINK_NOARG(ScTabView, TabBarResize, TabBar*, void)
if (!aViewData.IsHScrollMode())
return;
- const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel();
long nSize = pTabControl->GetSplitSize();
if (aViewData.GetHSplitMode() != SC_SPLIT_FIX)
@@ -841,7 +840,7 @@ IMPL_LINK_NOARG(ScTabView, TabBarResize, TabBar*, void)
if ( nSize != pTabControl->GetSizePixel().Width() )
{
- pTabControl->SetSizePixel( Size( nSize+nOverlap,
+ pTabControl->SetSizePixel( Size( nSize,
pTabControl->GetSizePixel().Height() ) );
RepeatResize();
}
@@ -1530,8 +1529,6 @@ void ScTabView::DoHSplit(long nSplitPos)
long nMinPos;
long nMaxPos;
- SCCOL nOldDelta;
- SCCOL nNewDelta;
nMinPos = SPLIT_MARGIN;
if ( pRowBar[SC_SPLIT_BOTTOM] && pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() >= nMinPos )
@@ -1561,10 +1558,10 @@ void ScTabView::DoHSplit(long nSplitPos)
}
else
{
- nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT );
+ SCCOL nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT );
long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
if ( nLeftWidth < 0 ) nLeftWidth = 0;
- nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT,
+ SCCOL nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT,
static_cast<sal_uInt16>(nLeftWidth) );
ScDocument& rDoc = aViewData.GetDocument();
if ( nNewDelta > rDoc.MaxCol() )
@@ -1596,7 +1593,6 @@ void ScTabView::DoVSplit(long nSplitPos)
long nMinPos;
long nMaxPos;
SCROW nOldDelta;
- SCROW nNewDelta;
nMinPos = SPLIT_MARGIN;
if ( pColBar[SC_SPLIT_LEFT] && pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() >= nMinPos )
@@ -1637,7 +1633,7 @@ void ScTabView::DoVSplit(long nSplitPos)
aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta );
long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
if ( nTopHeight < 0 ) nTopHeight = 0;
- nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP,
+ SCROW nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP,
static_cast<sal_uInt16>(nTopHeight) );
ScDocument& rDoc = aViewData.GetDocument();
if ( nNewDelta > rDoc.MaxRow() )
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index f73a5c1636b5..95e566267ae1 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -114,14 +114,13 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
case FID_TABLE_SHOW:
{
- OUString aName;
std::vector<OUString> rNames;
if ( pReqArgs )
{
const SfxPoolItem* pItem;
if( pReqArgs->HasItem( FID_TABLE_SHOW, &pItem ) )
{
- aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ OUString aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
rNames.push_back(aName);
ShowTable( rNames );
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index f3dbeece26b7..90ddff57df08 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2891,9 +2891,9 @@ void ScViewFunc::MoveTable(
nDestTab1++;
}
}
- OUString sName;
if (!bNewDoc && bUndo)
{
+ OUString sName;
rDestDoc.GetName(nDestTab, sName);
pDestShell->GetUndoManager()->AddUndoAction(
std::make_unique<ScUndoImportTab>( pDestShell, nDestTab,
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index d8dbe9ce748e..60674776e7fd 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1168,7 +1168,6 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
SCROW nEndRow = aMarkRange.aEnd.Row();
SCTAB nEndTab = aMarkRange.aEnd.Tab();
- ScUndoSelectionAttr* pUndoAttr = nullptr;
ScEditDataArray* pEditDataArray = nullptr;
if (bRecord)
{
@@ -1185,7 +1184,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
aFuncMark.MarkToMulti();
- pUndoAttr = new ScUndoSelectionAttr(
+ ScUndoSelectionAttr* pUndoAttr = new ScUndoSelectionAttr(
pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
nEndCol, nEndRow, nEndTab, std::move(pUndoDoc), bMulti, &rAttr );
pDocSh->GetUndoManager()->AddUndoAction(std::unique_ptr<ScUndoSelectionAttr>(pUndoAttr));
@@ -2354,7 +2353,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
{
//! step size adjustable
// step size is also minimum
- sal_uInt16 nStepX = STD_COL_WIDTH / 5;
+ constexpr sal_uInt16 nStepX = STD_COL_WIDTH / 5;
sal_uInt16 nStepY = ScGlobal::nStdRowHeight;
ScModule* pScMod = SC_MOD();