summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2011-08-16 23:55:45 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2011-08-17 00:04:10 +0900
commit13021dae515db60405a255aab388318e54df99a6 (patch)
tree21d26c15545cc20fb8a6f046fcbf784a5941d28b
parentdca2588b6430e084eb708cfe69d36c3d46a5411e (diff)
cppcheck: reduced scope of variable
-rw-r--r--filter/source/config/cache/filtercache.cxx2
-rw-r--r--rsc/source/res/rsccont.cxx20
-rw-r--r--sc/source/ui/view/viewfunc.cxx2
3 files changed, 11 insertions, 13 deletions
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index b3f5c91ab00c..37983d349883 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -2018,10 +2018,10 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
// to a list of names ...
// But note: because we work directly on a reference to the cache item,
// its not allowd to change the value here. We must work on a copy!
- sal_Int32 nFlags = 0;
pIt = aItem.find(PROPNAME_FLAGS);
if (pIt != aItem.end())
{
+ sal_Int32 nFlags = 0;
pIt->second >>= nFlags;
css::uno::Any aFlagNameList;
aFlagNameList <<= FilterCache::impl_convertFlagField2FlagNames(nFlags);
diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx
index c39be82b5c7e..a122ebfc4cff 100644
--- a/rsc/source/res/rsccont.cxx
+++ b/rsc/source/res/rsccont.cxx
@@ -100,10 +100,9 @@ RSCCLASS_TYPE RscBaseCont::GetClassType() const
*************************************************************************/
void RscBaseCont::DestroyElements( RscBaseContInst * pClassData )
{
- sal_uInt32 i = 0;
-
if( pClassData->nEntries ){
- for( i = 0; i < pClassData->nEntries; i++ ){
+ for (sal_uInt32 i = 0; i < pClassData->nEntries; i++ )
+ {
pClassData->pEntries[ i ].Destroy();
};
rtl_freeMemory( pClassData->pEntries );
@@ -120,7 +119,6 @@ void RscBaseCont::DestroyElements( RscBaseContInst * pClassData )
RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt,
sal_Bool bOwnClass )
{
- sal_uInt32 i = 0;
RSCINST aInst;
RscBaseContInst * pClassData;
@@ -151,7 +149,8 @@ RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt,
pClassData->pEntries =
(ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT )
* pClassData->nEntries );
- for( i = 0; i < pClassData->nEntries; i++ ){
+ for (sal_uInt32 i = 0; i < pClassData->nEntries; i++ )
+ {
pClassData->pEntries[ i ].Create();
pClassData->pEntries[ i ].aName =
pDfltClassData->pEntries[ i ].aName;
@@ -187,7 +186,6 @@ void RscBaseCont::Destroy( const RSCINST & rInst ){
RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName,
RscTop * pClass, sal_uInt32 nPos )
{
- sal_uInt32 i = 0;
RscBaseContInst * pClassData;
pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
@@ -195,7 +193,8 @@ RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName
pClass = pTypeClass;
if( rEleName.IsId() ){
- for( i = nPos; i < pClassData->nEntries; i++ ){
+ for (sal_uInt32 i = nPos; i < pClassData->nEntries; i++ )
+ {
if( pClassData->pEntries[ i ].aName == rEleName
&& pClassData->pEntries[ i ].aInst.pClass == pClass )
{
@@ -727,7 +726,6 @@ void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass,
*************************************************************************/
void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ){
RscBaseContInst * pClassData;
- sal_uInt32 i = 0;
pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
@@ -737,7 +735,7 @@ void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ){
else{
pClassData->pEntries[ nPos ].Destroy();
pClassData->nEntries--;
- for( i = nPos; i < pClassData->nEntries; i++ )
+ for (sal_uInt32 i = nPos; i < pClassData->nEntries; i++ )
pClassData->pEntries[ i ] = pClassData->pEntries[ i + 1 ];
};
};
@@ -777,7 +775,6 @@ void RscBaseCont::ContWriteSrc( const RSCINST & rInst, FILE * fOutput,
ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem,
RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
{
- sal_uInt32 i = 0;
RscBaseContInst * pClassData;
ERRTYPE aError;
@@ -785,7 +782,8 @@ ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem,
{ // Nur Subresourcen schreiben, wenn bExtra == sal_True
pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
- for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ){
+ for (sal_uInt32 i = 0; i < pClassData->nEntries && aError.IsOk(); i++ )
+ {
aError = pClassData->pEntries[ i ].aInst.pClass->
WriteRcHeader( pClassData->pEntries[ i ].aInst,
rMem, pTC,
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 2b934eed59c4..34a34b9c26af 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -693,10 +693,10 @@ void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& r
{
ScDocument* pDoc = GetViewData()->GetDocument();
ScDocShell* pDocSh = GetViewData()->GetDocShell();
- sal_Bool bUndo (pDoc->IsUndoEnabled());
if ( pDoc && pDocSh )
{
+ sal_Bool bUndo(pDoc->IsUndoEnabled());
ScDocShellModificator aModificator( *pDocSh );
ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow );