fdo#39440 reduce scope of local variables

This addresses some cppcheck warnings.
in addition: simplified some simple bool checks:
    "if (!bVar)" instead of "if(bVar == false)"

Change-Id: I609b4a3ee7d43bbeeb91ba141af2c90511d0c8d7
Reviewed-on: https://gerrit.libreoffice.org/13455
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Michael Weghorn
2014-12-12 19:34:29 +01:00
committed by Noel Grandin
parent ec382367c8
commit c1fcafb4ac
10 changed files with 24 additions and 35 deletions

View File

@@ -308,11 +308,9 @@ void METWriter::WriteClipRect( const Rectangle& rRect )
void METWriter::CountActionsAndBitmaps(const GDIMetaFile * pMTF)
{
const MetaAction* pMA;
for( size_t nAction = 0, nActionCount=pMTF->GetActionSize(); nAction < nActionCount; nAction++ )
{
pMA = pMTF->GetAction(nAction);
const MetaAction* pMA = pMTF->GetAction(nAction);
switch (pMA->GetType())
{
@@ -398,16 +396,15 @@ void METWriter::WriteFieldId(sal_uInt32 nId)
void METWriter::CreateChrSets(const GDIMetaFile * pMTF)
{
size_t nAction, nActionCount;
const MetaAction * pMA;
if (bStatus==false)
if (!bStatus)
return;
nActionCount = pMTF->GetActionSize();
for (nAction = 0; nAction < nActionCount; nAction++)
{
pMA = pMTF->GetAction(nAction);
const MetaAction * pMA = pMTF->GetAction(nAction);
switch (pMA->GetType())
{
@@ -734,14 +731,12 @@ void METWriter::WriteImageObject(const Bitmap & rBitmap)
void METWriter::WriteImageObjects(const GDIMetaFile * pMTF)
{
const MetaAction* pMA;
if (bStatus==false)
if (!bStatus)
return;
for ( size_t nAction = 0, nActionCount = pMTF->GetActionSize(); nAction < nActionCount; nAction++)
{
pMA = pMTF->GetAction(nAction);
const MetaAction* pMA = pMTF->GetAction(nAction);
switch (pMA->GetType())
{
@@ -808,7 +803,7 @@ void METWriter::WriteImageObjects(const GDIMetaFile * pMTF)
break;
}
if (bStatus==false)
if (!bStatus)
break;
}
@@ -818,7 +813,7 @@ void METWriter::WriteImageObjects(const GDIMetaFile * pMTF)
void METWriter::WriteDataDescriptor(const GDIMetaFile *)
{
if (bStatus==false)
if (!bStatus)
return;
WriteFieldIntroducer(0,DscGrfObjMagic,0,0);

View File

@@ -160,10 +160,9 @@ void PBMWriter::ImplWriteBody()
}
else
{
int nxCount;
for ( sal_uLong y = 0; y < mnHeight; y++ )
{
nxCount = 70;
int nxCount = 70;
for ( sal_uLong x = 0; x < mnWidth; x++ )
{
if (!( --nxCount ) )

View File

@@ -195,13 +195,12 @@ void PictWriter::MayCallback()
void PictWriter::CountActionsAndBitmaps(const GDIMetaFile & rMTF)
{
size_t nAction, nActionCount;
const MetaAction* pMA;
nActionCount = rMTF.GetActionSize();
for (nAction=0; nAction < nActionCount; nAction++)
{
pMA = rMTF.GetAction( nAction );
const MetaAction* pMA = rMTF.GetAction( nAction );
switch( pMA->GetType() )
{
@@ -223,7 +222,7 @@ void PictWriter::CountActionsAndBitmaps(const GDIMetaFile & rMTF)
Polygon PictWriter::PolyPolygonToPolygon(const tools::PolyPolygon & rPolyPoly)
{
sal_uInt16 nCount,nSize1,nSize2,np,i1,i2,i3,nBestIdx1,nBestIdx2;
long nDistSqr,nBestDistSqr, nCountdownTests;
long nDistSqr;
Point aP1,aPRel;
Polygon aPoly1, aPoly2, aPoly3;
@@ -244,8 +243,8 @@ Polygon PictWriter::PolyPolygonToPolygon(const tools::PolyPolygon & rPolyPoly)
// pictures would need infinite time to export, we limit the number of test
// by the number of 1000 and cancel the search if necessary preliminarily.
// The result of this will not be wrong but rather not so beautiful.
nCountdownTests=1000;
nBestDistSqr=0x7fffffff;
long nCountdownTests = 1000;
long nBestDistSqr = 0x7fffffff;
nBestIdx1=0;
nBestIdx2=0;
for (i1=0; i1<nSize1; i1++) {

View File

@@ -542,13 +542,12 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview )
nLines++;
nLines *= aSizeBitmap.Height();
ImplWriteLong( nLines );
char nVal;
sal_Int32 nX, nY, nCount2, nCount = 4;
const BitmapColor aBlack( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
for ( nY = 0; nY < aSizeBitmap.Height(); nY++ )
{
nCount2 = 0;
nVal = 0;
char nVal = 0;
for ( nX = 0; nX < aSizeBitmap.Width(); nX++ )
{
if ( !nCount2 )

View File

@@ -53,10 +53,10 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
CGMOutAct ( rCGM ),
nFinalTextCount ( 0 )
{
bool bStatRet = false;
if ( mpCGM->mbStatus )
{
bool bStatRet = false;
uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY );
if( aDrawPageSup.is() )
{

View File

@@ -714,7 +714,6 @@ ImportCGM( OUString const & rFileName, uno::Reference< frame::XModel > const & r
sal_uInt32 nStatus = 0; // retvalue == 0 -> ERROR
// == 0xffrrggbb -> background color in the lower 24 bits
bool bProgressBar = false;
if( rXModel.is() )
{
@@ -734,7 +733,7 @@ ImportCGM( OUString const & rFileName, uno::Reference< frame::XModel > const & r
sal_uInt32 nNext = 0;
sal_uInt32 nAdd = nInSize / 20;
bProgressBar = aXStatInd.is();
bool bProgressBar = aXStatInd.is();
if ( bProgressBar )
aXStatInd->start( "CGM Import" , nInSize );

View File

@@ -26,7 +26,6 @@
void CGM::ImplDoClass3()
{
sal_uInt32 nUInteger;
long nI0, nI1;
switch ( mnElementID )
{
case 0x01 : /*VDC Integer Precision*/
@@ -42,8 +41,8 @@ void CGM::ImplDoClass3()
case 0x02 : /*VDC Real Precision*/
{
nUInteger = ImplGetUI16();
nI0 = ImplGetI( pElement->nIntegerPrecision ); // exponent
nI1 = ImplGetI( pElement->nIntegerPrecision ); // mantisse
const long nI0 = ImplGetI( pElement->nIntegerPrecision ); // exponent
const long nI1 = ImplGetI( pElement->nIntegerPrecision ); // mantisse
switch( nUInteger )
{
case 0 :

View File

@@ -75,10 +75,9 @@ DXFLineInfo DXF2GDIMetaFile::LTypeToDXFLineInfo(OString const& rLineType)
}
else {
sal_Int32 i;
double x;
aDXFLineInfo.eStyle = LINE_DASH;
for (i=0; i < (pLT->nDashCount); i++) {
x = pLT->fDash[i] * pDXF->getGlobalLineTypeScale();
const double x = pLT->fDash[i] * pDXF->getGlobalLineTypeScale();
if ( x >= 0.0 ) {
if ( aDXFLineInfo.nDotCount == 0 ) {
aDXFLineInfo.nDotCount ++;

View File

@@ -539,7 +539,6 @@ GraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
Graphic aGraphic;
bool bRetValue = false;
bool bHasPreview = false;
bool bGraphicLinkCreated = false;
sal_uInt32 nSignature, nPSStreamPos, nPSSize;
sal_uInt32 nSizeWMF = 0;
sal_uInt32 nPosWMF = 0;
@@ -593,6 +592,8 @@ GraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
if ( ImplSearchEntry( pHeader, (sal_uInt8*)"%!PS-Adobe", 10, 10 ) &&
ImplSearchEntry( &pHeader[ 15 ], (sal_uInt8*)"EPS", 3, 3 ) )
{
bool bGraphicLinkCreated = false;
rStream.Seek( nPSStreamPos );
sal_uInt8* pBuf = new sal_uInt8[ nPSSize ];
if ( pBuf )
@@ -621,13 +622,12 @@ GraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
BitmapWriteAccess* pAcc = aBitmap.AcquireWriteAccess();
if ( pAcc )
{
int nBitsLeft;
bool bIsValid = true;
sal_uInt8 nDat = 0;
char nByte;
for ( long y = 0; bIsValid && ( y < nHeight ); y++ )
{
nBitsLeft = 0;
int nBitsLeft = 0;
for ( long x = 0; x < nWidth; x++ )
{
if ( --nBitsLeft < 0 )

View File

@@ -1328,7 +1328,6 @@ void OS2METReader::ReadFilletSharp(bool bGivenPos, sal_uInt16 nOrderLen)
void OS2METReader::ReadMarker(bool bGivenPos, sal_uInt16 nOrderLen)
{
sal_uInt16 i,nNumPoints;
long x,y;
SetPen( aAttr.aMrkCol );
SetRasterOp(aAttr.eMrkMix);
@@ -1344,7 +1343,8 @@ void OS2METReader::ReadMarker(bool bGivenPos, sal_uInt16 nOrderLen)
if (!bGivenPos) nNumPoints++;
for (i=0; i<nNumPoints; i++) {
if (i!=0 || bGivenPos) aAttr.aCurPos=ReadPoint();
x=aAttr.aCurPos.X(); y=aAttr.aCurPos.Y();
const long x = aAttr.aCurPos.X();
const long y=aAttr.aCurPos.Y();
aCalcBndRect.Union(Rectangle(x-5,y-5,x+5,y+5));
switch (aAttr.nMrkSymbol) {
case 2: // PLUS