summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2015-01-16 13:24:42 +0000
committerNoel Grandin <noelgrandin@gmail.com>2015-01-19 08:37:57 +0000
commit08f9bd504de9bcb267a0e71b07759080592bd0d8 (patch)
tree5c8fbd72aa809e3dc0b5ef5fd04ad0f5d0d87beb
parent0a612a5c5c2982bccfe0cd6c5a3bba8d9107e043 (diff)
fdo#39440 sw: reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: I2368fc0a1c6dd73125d4770d06063ea3e3d8c713 Reviewed-on: https://gerrit.libreoffice.org/13961 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx9
-rw-r--r--sw/source/core/text/itradj.cxx3
-rw-r--r--sw/source/core/text/itrform2.cxx3
-rw-r--r--sw/source/core/text/txtdrop.cxx3
-rw-r--r--sw/source/core/text/txtfrm.cxx3
-rw-r--r--sw/source/core/txtnode/atrftn.cxx2
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx6
-rw-r--r--sw/source/core/txtnode/thints.cxx9
-rw-r--r--sw/source/core/undo/rolbck.cxx7
-rw-r--r--sw/source/core/undo/unattr.cxx3
-rw-r--r--sw/source/core/undo/undraw.cxx3
-rw-r--r--sw/source/core/undo/unins.cxx4
-rw-r--r--sw/source/core/unocore/unochart.cxx3
-rw-r--r--sw/source/core/unocore/unostyle.cxx18
-rw-r--r--sw/source/core/unocore/unotbl.cxx9
15 files changed, 42 insertions, 43 deletions
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 78bfda42d2a8..8b16c9cec956 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -325,7 +325,6 @@ bool SwTaggedPDFHelper::CheckReopenTag()
{
const SwFrm& rFrm = mpFrmInfo->mrFrm;
const SwFrm* pKeyFrm = 0;
- void* pKey = 0;
// Reopen an existing structure element if
// - rFrm is not the first page frame (reopen Document tag)
@@ -356,7 +355,7 @@ bool SwTaggedPDFHelper::CheckReopenTag()
if ( pKeyFrm )
{
- pKey = lcl_GetKeyFromFrame( *pKeyFrm );
+ void* pKey = lcl_GetKeyFromFrame( *pKeyFrm );
if ( pKey )
{
@@ -1258,10 +1257,11 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
// FlyFrm: Figure, Formula, Control
// fly in content or fly at page
{
- bool bFormula = false;
const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pFrm);
if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
{
+ bool bFormula = false;
+
const SwNoTxtFrm* pNoTxtFrm = static_cast<const SwNoTxtFrm*>(pFly->Lower());
SwOLENode* pOLENd = const_cast<SwOLENode*>(pNoTxtFrm->GetNode()->GetOLENode());
if ( pOLENd )
@@ -1409,10 +1409,9 @@ void SwTaggedPDFHelper::BeginInlineStructureElements()
rInf.GetIdx() - 1 :
rInf.GetIdx();
const SwTxtAttr* pHint = mpPorInfo->mrTxtPainter.GetAttr( nIdx );
- const SwField* pFld = 0;
if ( pHint && RES_TXTATR_FIELD == pHint->Which() )
{
- pFld = (SwField*)pHint->GetFmtFld().GetField();
+ const SwField* pFld = (SwField*)pHint->GetFmtFld().GetField();
if ( RES_GETREFFLD == pFld->Which() )
{
nPDFType = vcl::PDFWriter::Link;
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index 56302eae61a7..2c03d1998f17 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -194,10 +194,9 @@ static bool lcl_CheckKashidaWidth ( SwScriptInfo& rSI, SwTxtSizeInfo& rInf, SwTx
// check kashida width
// if width is smaller than minimal kashida width allowed by fonts in the current line
// drop one kashida after the other until kashida width is OK
- bool bAddSpaceChanged;
while (rKashidas)
{
- bAddSpaceChanged = false;
+ bool bAddSpaceChanged = false;
sal_Int32 nIdx = rItr.GetStart();
sal_Int32 nEnd = rItr.GetEnd();
while ( nIdx < nEnd )
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 3b5d6bcef966..e72a7e9078cc 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -414,7 +414,6 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
sal_uInt8 nNxtActual = rInf.GetFont()->GetActual();
sal_uInt8 nLstActual = nNxtActual;
sal_uInt16 nLstHeight = (sal_uInt16)rInf.GetFont()->GetHeight();
- bool bAllowBefore = false;
bool bAllowBehind = false;
const CharClass& rCC = GetAppCharClass();
@@ -443,6 +442,8 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
const SwLinePortion* pLast = rInf.GetLast();
if ( bAllowBehind && pLast )
{
+ bool bAllowBefore = false;
+
if ( pLast->InFldGrp() )
{
OUString aAltTxt;
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 836436fd8736..95b4ebe57e0b 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -756,7 +756,6 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf )
// reset pCurrPart to first part
pCurrPart = pDrop->GetPart();
bool bFirstGlyphRect = true;
- bool bHaveGlyphRect = false;
Rectangle aCommonRect, aRect;
while ( pCurrPart )
@@ -779,7 +778,7 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf )
nAscent = rFnt.GetAscent( rInf.GetVsh(), *pOut );
// we get the rectangle that covers all chars
- bHaveGlyphRect = pOut->GetTextBoundRect( aRect, rInf.GetTxt(), 0,
+ bool bHaveGlyphRect = pOut->GetTextBoundRect( aRect, rInf.GetTxt(), 0,
nIdx, pCurrPart->GetLen() ) &&
! aRect.IsEmpty();
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 5b379f33cd25..cc22073131c5 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -390,7 +390,6 @@ SwTxtFrm::~SwTxtFrm()
size_t nPos = 0;
sal_uLong nIndex = pCNd->GetIndex();
rFtnIdxs.SeekEntry( *pTxtNd, &nPos );
- SwTxtFtn* pTxtFtn;
if( nPos < rFtnIdxs.size() )
{
while( nPos && pTxtNd == &(rFtnIdxs[ nPos ]->GetTxtNode()) )
@@ -400,7 +399,7 @@ SwTxtFrm::~SwTxtFrm()
}
while( nPos < rFtnIdxs.size() )
{
- pTxtFtn = rFtnIdxs[ nPos ];
+ SwTxtFtn* pTxtFtn = rFtnIdxs[ nPos ];
if( pTxtFtn->GetTxtNode().GetIndex() > nIndex )
break;
pTxtFtn->DelFrms( this );
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 80b5e757b374..a71f11cd0b6b 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -345,12 +345,12 @@ void SwTxtFtn::SetNumber( const sal_uInt16 nNewNum, const OUString &sNumStr )
if ( m_pStartNode )
{
// must iterate over all TxtNodes because of footnotes on other pages
- SwNode* pNd;
sal_uLong nSttIdx = m_pStartNode->GetIndex() + 1;
sal_uLong nEndIdx = m_pStartNode->GetNode().EndOfSectionIndex();
for( ; nSttIdx < nEndIdx; ++nSttIdx )
{
// Es koennen ja auch Grafiken in der Fussnote stehen ...
+ SwNode* pNd;
if( ( pNd = rNodes[ nSttIdx ] )->IsTxtNode() )
static_cast<SwTxtNode*>(pNd)->ModifyNotification( 0, &rFtn );
}
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 7d56f646d7da..e063459cff60 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -299,7 +299,6 @@ static void lcl_ChangeFtnRef( SwTxtNode &rNode )
SwpHints *pSwpHints = rNode.GetpSwpHints();
if( pSwpHints && rNode.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
{
- SwTxtAttr* pHt;
SwCntntFrm* pFrm = NULL;
// OD 07.11.2002 #104840# - local variable to remember first footnote
// of node <rNode> in order to invalidate position of its first content.
@@ -307,7 +306,7 @@ static void lcl_ChangeFtnRef( SwTxtNode &rNode )
SwFtnFrm* pFirstFtnOfNode = 0;
for( size_t j = pSwpHints->Count(); j; )
{
- pHt = pSwpHints->GetTextHint(--j);
+ SwTxtAttr* pHt = pSwpHints->GetTextHint(--j);
if (RES_TXTATR_FTN == pHt->Which())
{
if( !pFrm )
@@ -1412,11 +1411,10 @@ static SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const OUString&
{
if( !rName.isEmpty() )
{
- SwCharFmt* pFmt;
const size_t nArrLen = pCharFmts->size();
for( size_t i = 1; i < nArrLen; i++ )
{
- pFmt = (*pCharFmts)[ i ];
+ SwCharFmt* pFmt = (*pCharFmts)[ i ];
if( pFmt->GetName()==rName )
return pFmt;
}
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 4ba366200924..4ab895595e1a 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -881,11 +881,12 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint,
// Remove any attributes which are already set at the whole paragraph:
bool bOptimizeAllowed = true;
- SfxItemSet* pNewSet = 0;
// #i75750# Remove attributes already set at whole paragraph
// #i81764# This should not be applied for no length attributes!!! <--
if ( !bNoLengthAttribute && rNode.HasSwAttrSet() && pNewStyle->Count() )
{
+ SfxItemSet* pNewSet = 0;
+
SfxItemIter aIter2( *pNewStyle );
const SfxPoolItem* pItem = aIter2.GetCurItem();
const SfxItemSet& rWholeParaAttrSet = rNode.GetSwAttrSet();
@@ -1403,10 +1404,12 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode )
sal_uLong nSttIdx =
static_cast<SwTxtFtn*>(pAttr)->GetStartNode()->GetIndex();
sal_uLong nEndIdx = rNodes[ nSttIdx++ ]->EndOfSectionIndex();
- SwCntntNode* pCNd;
for( ; nSttIdx < nEndIdx; ++nSttIdx )
- if( 0 != ( pCNd = rNodes[ nSttIdx ]->GetCntntNode() ))
+ {
+ SwCntntNode* pCNd = rNodes[ nSttIdx ]->GetCntntNode();
+ if( 0 != pCNd )
pCNd->DelFrms();
+ }
}
if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nInsMode) )
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 6ccd46da19d8..f98e3cb975a1 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1133,10 +1133,9 @@ bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
if ( !Count() )
return false;
- SwHistoryHint * pHHt;
for ( sal_uInt16 i = Count(); i > nStart ; )
{
- pHHt = m_SwpHstry[ --i ];
+ SwHistoryHint * pHHt = m_SwpHstry[ --i ];
pHHt->SetInDoc( pDoc, false );
delete pHHt;
}
@@ -1245,13 +1244,13 @@ void SwHistory::CopyAttr(
// copy all attributes of the TextNode in the area from nStart to nEnd
SwTxtAttr* pHt;
- const sal_Int32 * pEndIdx;
for( size_t n = 0; n < pHts->Count(); ++n )
{
// nAttrStt must even be set when !pEndIdx
pHt = pHts->GetTextHint(n);
const sal_Int32 nAttrStt = pHt->GetStart();
- if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt > nEnd )
+ const sal_Int32 * pEndIdx = pHt->GetEnd();
+ if( 0 != pEndIdx && nAttrStt > nEnd )
break;
// never copy Flys and Ftn !!
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index f1b886ded356..f0d36ce59119 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -894,13 +894,12 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
if ( SfxItemState::SET != m_AttrSet.GetItemState( RES_TXTATR_FTN, false ))
return ;
- SwHistoryHint* pHstHnt;
SwNodes& rNds = rDoc.GetNodes();
for ( sal_uInt16 n = 0; n < m_pHistory->Count(); ++n )
{
sal_Int32 nCntnt = 0;
sal_uLong nNode = 0;
- pHstHnt = (*m_pHistory)[ n ];
+ SwHistoryHint* pHstHnt = (*m_pHistory)[ n ];
switch ( pHstHnt->Which() )
{
case HSTRY_RESETTXTHNT:
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index 1a94cecbda8f..3be72dd8d6b2 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -259,13 +259,12 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &)
// remove from array
SwDoc* pDoc = pObjArr->pFmt->GetDoc();
SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts();
- SdrObject* pObj;
for( sal_uInt16 n = 1; n < nSize; ++n )
{
SwUndoGroupObjImpl& rSave = *( pObjArr + n );
- pObj = rSave.pObj;
+ SdrObject* pObj = rSave.pObj;
SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index a156a4a9b614..4025583d9a61 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -171,11 +171,11 @@ bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
{
SwRedlineData aRData( nsRedlineType_t::REDLINE_INSERT, rDoc.getIDocumentRedlineAccess().GetRedlineAuthor() );
const SwIndexReg* pIReg = rPos.nContent.GetIdxReg();
- SwIndex* pIdx;
for( size_t i = 0; i < rTbl.size(); ++i )
{
SwRangeRedline* pRedl = rTbl[ i ];
- if( pIReg == (pIdx = &pRedl->End()->nContent)->GetIdxReg() &&
+ SwIndex* pIdx = &pRedl->End()->nContent;
+ if( pIReg == pIdx->GetIdxReg() &&
nCntnt == pIdx->GetIndex() )
{
if( !pRedl->HasMark() || !pRedlData ||
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 0fbd89f7a9dd..0c501d59c3ca 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1704,11 +1704,10 @@ void SwChartDataProvider::AddRowCols(
const sal_Int32 nLen = xRef->getTextualData().getLength();
if (nLen > 1) // value data-sequence ?
{
- SwChartDataSequence *pDataSeq = 0;
uno::Reference< lang::XUnoTunnel > xTunnel( xRef, uno::UNO_QUERY );
if(xTunnel.is())
{
- pDataSeq = reinterpret_cast< SwChartDataSequence * >(
+ SwChartDataSequence *pDataSeq = reinterpret_cast< SwChartDataSequence * >(
sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwChartDataSequence::getUnoTunnelId() )));
if (pDataSeq)
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 7f2e84250da2..89f184f19b11 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -330,19 +330,20 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
std::exception)
{
SolarMutexGuard aGuard;
- bool bLoadStyleText = true;
- bool bLoadStylePage = true;
- bool bLoadStyleOverwrite = true;
- bool bLoadStyleNumbering = true;
- bool bLoadStyleFrame = true;
if(IsValid() && !rURL.isEmpty())
{
- const uno::Any* pVal;
+ bool bLoadStyleText = true;
+ bool bLoadStylePage = true;
+ bool bLoadStyleOverwrite = true;
+ bool bLoadStyleNumbering = true;
+ bool bLoadStyleFrame = true;
+
int nCount = aOptions.getLength();
const beans::PropertyValue* pArray = aOptions.getConstArray();
for(int i = 0; i < nCount; i++)
- if( ( pVal = &pArray[i].Value)->getValueType() ==
- ::getBooleanCppuType() )
+ {
+ const uno::Any* pVal = &pArray[i].Value;
+ if( pVal->getValueType() == ::getBooleanCppuType() )
{
const OUString sName = pArray[i].Name;
bool bVal = *(sal_Bool*)pVal->getValue();
@@ -357,6 +358,7 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
else if( sName == UNO_NAME_LOAD_TEXT_STYLES )
bLoadStyleText = bVal;
}
+ }
SwgReaderOption aOpt;
aOpt.SetFrmFmts( bLoadStyleFrame );
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 0d04f838fb8f..5f14c5de007d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2773,7 +2773,6 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount();
const sal_uInt16 nColCount = getColumnCount();
- bool bChanged = false;
if(!nRowCount || !nColCount)
{
@@ -2785,6 +2784,8 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
SwFrmFmt* pFmt = GetFrmFmt();
if(pFmt )
{
+ bool bChanged = false;
+
const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
if(rData.getLength() < nRowCount - nRowStart)
{
@@ -3619,15 +3620,17 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException,
if(pFmt)
{
const OUString aOldName( pFmt->GetName() );
- const SwFrmFmt* pTmpFmt;
const SwFrmFmts* pTbl = pFmt->GetDoc()->GetTblFrmFmts();
for( size_t i = pTbl->size(); i; )
- if( !( pTmpFmt = (*pTbl)[ --i ] )->IsDefault() &&
+ {
+ const SwFrmFmt* pTmpFmt = (*pTbl)[ --i ] ;
+ if( !pTmpFmt->IsDefault() &&
pTmpFmt->GetName() == rName &&
pFmt->GetDoc()->IsUsed( *pTmpFmt ))
{
throw uno::RuntimeException();
}
+ }
pFmt->SetName( rName );