summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-09-30 09:38:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-09-30 12:32:18 +0200
commit9373320fc88c1582a2ad25bda9c5264c7c58a97e (patch)
treeee2df8944d7af2080498b991ed46429e0a020947 /sw/source/core
parent37b81dd54a915223780a6b5efa54ce45db332604 (diff)
loplugin:reducevarscope in sw
Change-Id: Ifed7220c6acf7049b2985f1911a806b37a54d794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103646 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/access/accdoc.cxx8
-rw-r--r--sw/source/core/attr/swatrset.cxx3
-rw-r--r--sw/source/core/crsr/crsrsh.cxx3
-rw-r--r--sw/source/core/crsr/crstrvl.cxx13
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx2
-rw-r--r--sw/source/core/doc/DocumentLinksAdministrationManager.cxx6
-rw-r--r--sw/source/core/doc/docnum.cxx4
-rw-r--r--sw/source/core/doc/docredln.cxx4
-rw-r--r--sw/source/core/doc/tblrwcl.cxx2
-rw-r--r--sw/source/core/docnode/ndtbl.cxx3
-rw-r--r--sw/source/core/docnode/node.cxx2
-rw-r--r--sw/source/core/fields/fldbas.cxx6
-rw-r--r--sw/source/core/layout/trvlfrm.cxx2
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx2
-rw-r--r--sw/source/core/text/porfld.cxx2
-rw-r--r--sw/source/core/unocore/unochart.cxx3
-rw-r--r--sw/source/core/unocore/unoframe.cxx3
17 files changed, 26 insertions, 42 deletions
diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx
index 53a974acc96a..cf59efdb21ce 100644
--- a/sw/source/core/access/accdoc.cxx
+++ b/sw/source/core/access/accdoc.cxx
@@ -524,15 +524,13 @@ uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes()
SwFEShell* pFEShell = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr
? static_cast<SwFEShell*>( pCursorShell )
: nullptr;
- OUString sValue;
- sal_uInt16 nPage, nLogPage;
- OUString sDisplay;
-
if( pFEShell )
{
+ OUString sDisplay;
+ sal_uInt16 nPage, nLogPage;
pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay);
- sValue = "page-name:" + sDisplay +
+ OUString sValue = "page-name:" + sDisplay +
";page-number:" +
OUString::number( nPage ) +
";total-pages:" +
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 35f711297789..e2c96e069879 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -368,11 +368,10 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const
std::unique_ptr< SfxItemSet > tmpSet;
- const SwPageDesc* pPgDesc;
if( pSrcDoc != pDstDoc && SfxItemState::SET == GetItemState(
RES_PAGEDESC, false, &pItem ))
{
- pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
+ const SwPageDesc* pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
if( pPgDesc )
{
tmpSet.reset(new SfxItemSet(*this));
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 7c7471b081b5..db3106707482 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -193,11 +193,10 @@ SwPaM* SwCursorShell::GetCursor( bool bMakeTableCursor ) const
if( bMakeTableCursor && m_pTableCursor->IsCursorMovedUpdate() )
{
//don't re-create 'parked' cursors
- const SwContentNode* pCNd;
if( m_pTableCursor->GetPoint()->nNode.GetIndex() &&
m_pTableCursor->GetMark()->nNode.GetIndex() )
{
- pCNd = m_pTableCursor->GetContentNode();
+ const SwContentNode* pCNd = m_pTableCursor->GetContentNode();
if( pCNd && pCNd->getLayoutFrame( GetLayout() ) )
{
pCNd = m_pTableCursor->GetContentNode(false);
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 804bdab8a05a..7e27e1ee899a 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -438,13 +438,12 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors )
( !bOnlyErrors ||
!pFormulaItem->HasValidBoxes() ) )
{
- const SwContentFrame* pCFrame;
SwNodeIndex aIdx( *pTBox->GetSttNd() );
const SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
std::pair<Point, bool> const tmp(aPt, false);
if (pCNd)
{
- pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
+ const SwContentFrame* pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
if (pCFrame && (IsReadOnlyAvailable() || !pCFrame->IsProtected() ))
{
SetGetExpField aCmp( *pTBox );
@@ -1258,8 +1257,6 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
SwPosition aPos( *m_pCurrentCursor->GetPoint() );
SwTextNode* pTextNd;
- SwContentFrame *pFrame(nullptr);
- SwTextAttr* pTextAttr;
SwCursorMoveState aTmpState;
aTmpState.m_bFieldInfo = true;
aTmpState.m_bExactOnly = !( IsAttrAtPos::Outline & rContentAtPos.eContentAtPos );
@@ -1305,8 +1302,10 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
}
else if( bCursorFoundExact && pTextNd )
{
+ SwContentFrame *pFrame(nullptr);
if( !aTmpState.m_bPosCorr )
{
+ SwTextAttr* pTextAttr;
if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos
&& !aTmpState.m_bFootnoteNoInfo )
{
@@ -2425,11 +2424,10 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext )
if( aCurPos.GetNode() < nBodySttNdIdx )
{
const SwContentNode* pCNd = aCurPos.GetNodeFromContent()->GetContentNode();
- SwContentFrame* pFrame;
std::pair<Point, bool> tmp(aPt, true);
if (pCNd)
{
- pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
+ SwContentFrame* pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
if( pFrame )
aCurPos.SetBodyPos( *pFrame );
}
@@ -2451,11 +2449,10 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext )
SwTextINetFormat& rAttr = *pFnd;
SwPosition aTmpPos( *pTextNd );
SetGetExpField aPos( aTmpPos.nNode, rAttr );
- SwContentFrame* pFrame;
if (pTextNd->GetIndex() < nBodySttNdIdx)
{
std::pair<Point, bool> tmp(aPt, true);
- pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
+ SwContentFrame* pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
if (pFrame)
{
aPos.SetBodyPos( *pFrame );
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 0e732759def1..db76efdfcd45 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -810,7 +810,6 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt )
if( pTableNd->GetIndex() < m_rDoc.GetNodes().GetEndOfExtras().GetIndex() )
{
// is in the special section, that's expensive!
- Point aPt; // return the first frame of the layout - Tab.Headline!!
SwNodeIndex aCNdIdx( *pTableNd, +2 );
SwContentNode* pCNd = aCNdIdx.GetNode().GetContentNode();
if( !pCNd )
@@ -818,6 +817,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt )
if (pCNd)
{
+ Point aPt; // return the first frame of the layout - Tab.Headline!!
std::pair<Point, bool> const tmp(aPt, true);
pFrame = pCNd->getLayoutFrame(pLayout, nullptr, &tmp);
if( pFrame )
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index c5ca5b11eae6..85a4d3a12856 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -483,15 +483,13 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
}
else if( sCmp == "frame" )
{
- SwNodeIndex* pIdx;
- SwNode* pNd;
const SwFlyFrameFormat* pFlyFormat = m_rDoc.FindFlyByName( sName );
if( pFlyFormat )
{
- pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx());
+ SwNodeIndex* pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx());
if( pIdx )
{
- pNd = &pIdx->GetNode();
+ SwNode* pNd = &pIdx->GetNode();
if( !pNd->IsNoTextNode() )
{
rpRange.reset(new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() ));
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 0f03a9265670..c1b5d550ca1f 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1525,11 +1525,9 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
pNd = aIdx.GetNode().GetTextNode();
const SwNumRule* pRule = pNd->GetNumRule();
- sal_uInt8 nTmpNum;
-
if( pRule )
{
- nTmpNum = static_cast<sal_uInt8>(pNd->GetActualListLevel());
+ sal_uInt8 nTmpNum = static_cast<sal_uInt8>(pNd->GetActualListLevel());
if( pNd->IsCountedInList() || (nTmpNum < nSrchNum ) )
break; // found it!
}
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 5162c68db6f7..c700d39d731d 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -656,7 +656,7 @@ SwRedlineTable::size_type SwRedlineTable::FindPrevOfSeqNo( size_type nSttPos ) c
/// We can limit the search using look ahead (0 searches the whole array).
SwRedlineTable::size_type SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const
{
- auto const nLookahead = 20;
+ auto constexpr nLookahead = 20;
size_type nRet = npos;
if( nSeqNo && nSttPos < size() )
{
@@ -679,7 +679,7 @@ SwRedlineTable::size_type SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, size
SwRedlineTable::size_type SwRedlineTable::FindPrevSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const
{
- auto const nLookahead = 20;
+ auto constexpr nLookahead = 20;
size_type nRet = npos;
if( nSeqNo && nSttPos < size() )
{
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index c62bbf5b7a35..e98d44c14e80 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -250,9 +250,9 @@ static void lcl_CopyCol( FndBox_ & rFndBox, CpyPara *const pCpyPara)
SwTableBox* pBox = rFndBox.GetBox();
CpyTabFrame aFindFrame(pBox->GetFrameFormat());
- sal_uInt16 nFndPos;
if( pCpyPara->nCpyCnt )
{
+ sal_uInt16 nFndPos;
CpyTabFrames::const_iterator itFind = pCpyPara->rTabFrameArr.lower_bound( aFindFrame );
nFndPos = itFind - pCpyPara->rTabFrameArr.begin();
if( itFind == pCpyPara->rTabFrameArr.end() || !(*itFind == aFindFrame) )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c9c3e4546b8d..3c66f9d43b86 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4443,11 +4443,10 @@ bool SwDoc::UnProtectTableCells( SwTable& rTable )
void SwDoc::UnProtectCells( const OUString& rName )
{
- bool bChgd = false;
SwTableFormat* pFormat = FindTableFormatByName( rName );
if( pFormat )
{
- bChgd = UnProtectTableCells( *SwTable::FindTable( pFormat ) );
+ bool bChgd = UnProtectTableCells( *SwTable::FindTable( pFormat ) );
if( bChgd )
getIDocumentState().SetModified();
}
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 0f352dc28e69..94beca340c78 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -116,10 +116,10 @@ static void SetParent( std::shared_ptr<const SfxItemSet>& rpAttrSet,
aNewSet.SetParent( pParentSet );
aNewSet.ClearItem( RES_FRMATR_STYLE_NAME );
aNewSet.ClearItem( RES_FRMATR_CONDITIONAL_STYLE_NAME );
- OUString sVal;
if ( pParentFormat )
{
+ OUString sVal;
SwStyleNameMapper::FillProgName( pParentFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl );
const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal );
aNewSet.Put( aAnyFormatColl );
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 00e4a6ef3419..b932744fb588 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -518,20 +518,18 @@ OUString SwValueFieldType::ExpandValue( const double& rVal,
if( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && LANGUAGE_SYSTEM != nFormatLng )
{
- SvNumFormatType nType = SvNumFormatType::DEFINED;
- sal_Int32 nDummy;
-
const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat);
if (pEntry && nLng != pEntry->GetLanguage())
{
sal_uInt32 nNewFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nFormat,
nFormatLng);
-
if (nNewFormat == nFormat)
{
// probably user-defined format
OUString sFormat(pEntry->GetFormatstring());
+ sal_Int32 nDummy;
+ SvNumFormatType nType = SvNumFormatType::DEFINED;
pFormatter->PutandConvertEntry(sFormat, nDummy, nType, nFormat,
pEntry->GetLanguage(), nFormatLng, false);
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index d8714479ba75..30633ba4bd2d 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -338,9 +338,9 @@ bool SwPageFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
{
// FIXME There are still cases were we don't have the proper node here.
SwContentFrame* pBackFrame = pBackNd->getLayoutFrame( getRootFrame( ) );
- SwRect rBackRect;
if (pBackFrame)
{
+ SwRect rBackRect;
pBackFrame->GetCharRect( rBackRect, aBackPos );
nBackDistance = lcl_getDistance( rBackRect, rPoint );
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index d5d9621670c5..2efac690cf89 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -487,7 +487,6 @@ void SwTaggedPDFHelper::EndTag()
// Sets the attributes according to the structure type.
void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
{
- vcl::PDFWriter::StructAttributeValue eVal;
sal_Int32 nVal;
/*
@@ -495,6 +494,7 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType )
*/
if ( mpFrameInfo )
{
+ vcl::PDFWriter::StructAttributeValue eVal;
const SwFrame* pFrame = &mpFrameInfo->mrFrame;
SwRectFnSet aRectFnSet(pFrame);
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index b278484fc955..a2c1fb739255 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -295,11 +295,11 @@ void SwFieldPortion::CheckScript( const SwTextSizeInfo &rInf )
bool SwFieldPortion::Format( SwTextFormatInfo &rInf )
{
// Scope wegen aDiffText::DTOR!
- TextFrameIndex nRest;
bool bFull = false;
bool bEOL = false;
TextFrameIndex const nTextRest = TextFrameIndex(rInf.GetText().getLength()) - rInf.GetIdx();
{
+ TextFrameIndex nRest;
SwFieldSlot aDiffText( &rInf, this );
SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
aLayoutModeModifier.SetAuto();
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 42c4b9876c53..666ed4a3dd57 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -279,14 +279,13 @@ static bool GetTableAndCellsFromRangeRep(
// parse range representation for table name and cell/range names
// accepted format sth like: "Table1.A2:C5" , "Table2.A2.1:B3.2"
OUString aTableName; // table name
- OUString aRange; // cell range
OUString aStartCell; // name of top left cell
OUString aEndCell; // name of bottom right cell
sal_Int32 nIdx = rRangeRepresentation.indexOf( '.' );
if (nIdx >= 0)
{
aTableName = rRangeRepresentation.copy( 0, nIdx );
- aRange = rRangeRepresentation.copy( nIdx + 1 );
+ OUString aRange = rRangeRepresentation.copy( nIdx + 1 ); // cell range
sal_Int32 nPos = aRange.indexOf( ':' );
if (nPos >= 0) // a cell-range like "Table1.A2:D4"
{
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 5c7bffdc8663..e8461393ea6f 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2462,7 +2462,6 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName )
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw uno::RuntimeException("setPropertyToDefault: property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- bool bNextFrame;
if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
{
SwDoc* pDoc = pFormat->GetDoc();
@@ -2521,7 +2520,7 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName )
}
else
{
- bNextFrame = rPropertyName == UNO_NAME_CHAIN_NEXT_NAME;
+ bool bNextFrame = rPropertyName == UNO_NAME_CHAIN_NEXT_NAME;
if( bNextFrame || rPropertyName == UNO_NAME_CHAIN_PREV_NAME )
{
SwDoc* pDoc = pFormat->GetDoc();