[Libreoffice-commits] core.git: vcl/generic vcl/quartz vcl/source
Michael Weghorn
m.weghorn at posteo.de
Sun Jan 18 23:21:29 PST 2015
vcl/generic/fontmanager/parseAFM.cxx | 18 ++++++------------
vcl/generic/print/bitmap_gfx.cxx | 3 +--
vcl/generic/print/text_gfx.cxx | 3 ++-
vcl/quartz/salgdicommon.cxx | 3 +--
vcl/source/control/field2.cxx | 3 ++-
vcl/source/control/ilstbox.cxx | 7 ++++---
vcl/source/filter/graphicfilter2.cxx | 6 ++++--
vcl/source/filter/sgfbram.cxx | 3 +--
vcl/source/filter/sgvspln.cxx | 11 ++++-------
vcl/source/filter/sgvtext.cxx | 9 +++------
vcl/source/filter/wmf/enhwmf.cxx | 4 ++--
vcl/source/filter/wmf/winwmf.cxx | 3 +--
vcl/source/filter/wmf/wmfwr.cxx | 4 +---
13 files changed, 32 insertions(+), 45 deletions(-)
New commits:
commit ec9c7ebb575b592e188c5f6b545570b11744d063
Author: Michael Weghorn <m.weghorn at posteo.de>
Date: Sat Jan 17 00:59:10 2015 +0100
fdo#39440 vcl: reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: Ib6b9651b828287665f7248052855f0da2779806e
Reviewed-on: https://gerrit.libreoffice.org/13968
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/vcl/generic/fontmanager/parseAFM.cxx b/vcl/generic/fontmanager/parseAFM.cxx
index b3a7f7a..6d341ba 100644
--- a/vcl/generic/fontmanager/parseAFM.cxx
+++ b/vcl/generic/fontmanager/parseAFM.cxx
@@ -360,13 +360,12 @@ static int parseGlobals( FileInputStream* fp, GlobalFontInfo* gfi )
{
bool cont = true, save = (gfi != NULL);
int error = ok;
- char *keyword;
int direction = -1;
int tokenlen;
while (cont)
{
- keyword = token(fp, tokenlen);
+ char *keyword = token(fp, tokenlen);
if (keyword == NULL)
/* Have reached an early and unexpected EOF. */
@@ -564,11 +563,10 @@ static int parseCharWidths( FileInputStream* fp, int* cwi)
{
bool cont = true, save = (cwi != NULL);
int pos = 0, error = ok, tokenlen;
- char *keyword;
while (cont)
{
- keyword = token(fp,tokenlen);
+ char *keyword = token(fp,tokenlen);
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
if (keyword == NULL)
@@ -717,11 +715,10 @@ static int parseCharMetrics( FileInputStream* fp, FontInfo* fi)
bool cont = true, firstTime = true;
int error = ok, count = 0, tokenlen;
CharMetricInfo *temp = fi->cmi;
- char *keyword;
while (cont)
{
- keyword = token(fp,tokenlen);
+ char *keyword = token(fp,tokenlen);
if (keyword == NULL)
{
error = earlyEOF;
@@ -873,11 +870,10 @@ static int parseTrackKernData( FileInputStream* fp, FontInfo* fi)
{
bool cont = true, save = (fi->tkd != NULL);
int pos = 0, error = ok, tcount = 0, tokenlen;
- char *keyword;
while (cont)
{
- keyword = token(fp,tokenlen);
+ char *keyword = token(fp,tokenlen);
if (keyword == NULL)
{
@@ -980,11 +976,10 @@ static int parsePairKernData( FileInputStream* fp, FontInfo* fi)
{
bool cont = true, save = (fi->pkd != NULL);
int pos = 0, error = ok, pcount = 0, tokenlen;
- char *keyword;
while (cont)
{
- keyword = token(fp,tokenlen);
+ char *keyword = token(fp,tokenlen);
if (keyword == NULL)
{
@@ -1109,11 +1104,10 @@ static int parseCompCharData( FileInputStream* fp, FontInfo* fi)
{
bool cont = true, firstTime = true, save = (fi->ccd != NULL);
int pos = 0, j = 0, error = ok, ccount = 0, pcount = 0, tokenlen;
- char *keyword;
while (cont)
{
- keyword = token(fp,tokenlen);
+ char *keyword = token(fp,tokenlen);
if (keyword == NULL)
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
diff --git a/vcl/generic/print/bitmap_gfx.cxx b/vcl/generic/print/bitmap_gfx.cxx
index 9a6d7e8..dc6997d 100644
--- a/vcl/generic/print/bitmap_gfx.cxx
+++ b/vcl/generic/print/bitmap_gfx.cxx
@@ -625,12 +625,11 @@ PrinterGfx::DrawPS2MonoImage (const PrinterBmp& rBitmap, const Rectangle& rArea)
for (long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++)
{
long nBitPos = 0;
- unsigned char nBit = 0;
unsigned char nByte = 0;
for (long nColumn = rArea.Left(); nColumn <= rArea.Right(); nColumn++)
{
- nBit = rBitmap.GetPixelIdx (nRow, nColumn);
+ unsigned char nBit = rBitmap.GetPixelIdx (nRow, nColumn);
nByte |= nBit << (7 - nBitPos);
if (++nBitPos == 8)
diff --git a/vcl/generic/print/text_gfx.cxx b/vcl/generic/print/text_gfx.cxx
index a262b82..eeaa029 100644
--- a/vcl/generic/print/text_gfx.cxx
+++ b/vcl/generic/print/text_gfx.cxx
@@ -442,7 +442,7 @@ bool PrinterGfx::drawVerticalizedText(
int nTextScale = maVirtualStatus.mnTextWidth ? maVirtualStatus.mnTextWidth : maVirtualStatus.mnTextHeight;
int nNormalAngle = mnTextAngle;
- int nDeltaAngle, nLastPos = 0;
+ int nLastPos = 0;
double fSin = sin( -2.0*M_PI*nNormalAngle/3600 );
double fCos = cos( -2.0*M_PI*nNormalAngle/3600 );
@@ -453,6 +453,7 @@ bool PrinterGfx::drawVerticalizedText(
Point aPoint( rPoint );
for( int i = 0; i < nLen; )
{
+ int nDeltaAngle;
while( ( nDeltaAngle = getVerticalDeltaAngle( pStr[i] ) ) == 0 && i < nLen )
i++;
if( i <= nLen && i > nLastPos )
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 1c119ab7..5e53a25 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -1694,12 +1694,11 @@ CGPoint* AquaSalGraphics::makeCGptArray(sal_uInt32 nPoints, const SalPoint* pPtA
void AquaSalGraphics::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nSalFlags )
{
- CGPoint* CGpoints ;
if ( CheckContext() )
{
CG_TRACE("CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth);
CGContextSaveGState(mrContext);
- CGpoints = makeCGptArray(nPoints,pPtAry);
+ CGPoint* CGpoints = makeCGptArray(nPoints,pPtAry);
CGContextAddLines ( mrContext, CGpoints, nPoints );
if ( nSalFlags & SAL_INVERT_TRACKFRAME )
{
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 759b3f6..efd5549 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -1008,7 +1008,6 @@ static bool ImplDateGetValue( const OUString& rStr, Date& rDate, ExtDateFieldFor
sal_uInt16 nDay = 0;
sal_uInt16 nMonth = 0;
sal_uInt16 nYear = 0;
- bool bYear = true;
bool bError = false;
OUString aStr( rStr );
@@ -1037,6 +1036,8 @@ static bool ImplDateGetValue( const OUString& rStr, Date& rDate, ExtDateFieldFor
}
else
{
+ bool bYear = true;
+
// Check if year is present:
OUString aDateSep = ImplGetDateSep( rLocaleDataWrapper, eDateFormat );
sal_Int32 nSepPos = aStr.indexOf( aDateSep );
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 8b6af6a..f01c0ec3 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -1019,11 +1019,12 @@ void ImplListBoxWindow::SelectEntry( sal_Int32 nPos, bool bSelect )
bool ImplListBoxWindow::SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift, bool bCtrl, bool bSelectPosChange /*=FALSE*/ )
{
- bool bFocusChanged = false;
bool bSelectionChanged = false;
if( IsEnabled() && mpEntryList->IsEntrySelectable( nSelect ) )
{
+ bool bFocusChanged = false;
+
// here (Single-ListBox) only one entry can be deselected
if( !mbMulti )
{
@@ -2643,10 +2644,10 @@ void ImplWin::ImplDraw( bool bLayout )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- bool bNativeOK = false;
-
if( ! bLayout )
{
+ bool bNativeOK = false;
+
ControlState nState = ControlState::ENABLED;
if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
&& IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) )
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx
index 1d55f8c..4d8e5c3 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -606,7 +606,6 @@ bool GraphicDescriptor::ImpDetectPNG( SvStream& rStm, bool bExtendedInfo )
bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo )
{
- bool bDetectOk = false;
bool bRet = false;
sal_uInt8 cByte1 = 0;
sal_uInt8 cByte2 = 1;
@@ -616,6 +615,8 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo )
rStm.ReadUChar( cByte2 );
if ( cByte1 == cByte2 )
{
+ bool bDetectOk = false;
+
if ( cByte1 == 0x49 )
{
rStm.SetEndian( SvStreamEndian::LITTLE );
@@ -642,7 +643,6 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo )
sal_uLong nCount;
sal_uLong nMax = DATA_SIZE - 48;
sal_uInt32 nTemp32 = 0;
- bool bOk = false;
// Offset of the first IFD
rStm.ReadUInt32( nTemp32 );
@@ -650,6 +650,8 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo )
if ( nCount < nMax )
{
+ bool bOk = false;
+
// read tags till we find Tag256 ( Width )
// do not read more bytes than DATA_SIZE
rStm.ReadUInt16( nTemp16 );
diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx
index 8a05999..0d10492 100644
--- a/vcl/source/filter/sgfbram.cxx
+++ b/vcl/source/filter/sgfbram.cxx
@@ -397,7 +397,6 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt
sal_uInt8 nLTyp;
sal_uInt8 nOTyp;
bool bEoDt=false;
- bool bPDwn=false;
Point aP0(0,0);
Point aP1(0,0);
sal_uInt16 RecNr=0;
@@ -412,7 +411,7 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt
nLTyp=(sal_uInt8)((aVect.Flag & 0x00F0) >>4);
nOTyp=(sal_uInt8)((aVect.Flag & 0x0F00) >>8);
bEoDt=(aVect.Flag & 0x4000) !=0;
- bPDwn=(aVect.Flag & 0x8000) !=0;
+ bool bPDwn=(aVect.Flag & 0x8000) !=0;
long x=aVect.x-rHead.Xoffs;
long y=rHead.Ysize-(aVect.y-rHead.Yoffs);
diff --git a/vcl/source/filter/sgvspln.cxx b/vcl/source/filter/sgvspln.cxx
index 94f2a82..0d892b9 100644
--- a/vcl/source/filter/sgvspln.cxx
+++ b/vcl/source/filter/sgvspln.cxx
@@ -692,13 +692,10 @@ bool Spline2Poly(Polygon& rSpln, bool Periodic, Polygon& rPoly)
double Step; // stepsize for t
double dt1,dt2,dt3; // delta t, y, ^3
- double t;
- bool bEnd; // partial polynom ended?
sal_uInt16 n; // number of partial polynoms to draw
sal_uInt16 i; // actual partial polynom
bool bOk; // all still ok?
sal_uInt16 PolyMax=16380; // max number of polygon points
- long x,y;
bOk=CalcSpline(rSpln,Periodic,n,ax,ay,bx,by,cx,cy,dx,dy,tv);
if (bOk) {
@@ -708,14 +705,14 @@ bool Spline2Poly(Polygon& rSpln, bool Periodic, Polygon& rPoly)
rPoly.SetPoint(Point(short(ax[0]),short(ay[0])),0); // first point
i=0;
while (i<n) { // draw n partial polynoms
- t=tv[i]+Step;
- bEnd=false;
+ double t=tv[i]+Step;
+ bool bEnd=false; // partial polynom ended?
while (!bEnd) { // extrapolate one partial polynom
bEnd=t>=tv[i+1];
if (bEnd) t=tv[i+1];
dt1=t-tv[i]; dt2=dt1*dt1; dt3=dt2*dt1;
- x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3);
- y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3);
+ long x=long(ax[i]+bx[i]*dt1+cx[i]*dt2+dx[i]*dt3);
+ long y=long(ay[i]+by[i]*dt1+cy[i]*dt2+dy[i]*dt3);
if (x<MinKoord) x=MinKoord; if (x>MaxKoord) x=MaxKoord;
if (y<MinKoord) y=MinKoord; if (y>MaxKoord) y=MaxKoord;
if (rPoly.GetSize()<PolyMax) {
diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx
index 234be20..e73dd09 100644
--- a/vcl/source/filter/sgvtext.cxx
+++ b/vcl/source/filter/sgvtext.cxx
@@ -411,7 +411,6 @@ UCHAR GetTextCharConv(UCHAR* TBuf, sal_uInt16& Index,
sal_uInt16 GetLineFeed(UCHAR* TBuf, sal_uInt16 Index, ObjTextType Atr0, ObjTextType AktAtr,
sal_uInt16 nChar, sal_uInt16& LF, sal_uInt16& MaxGrad)
{
- UCHAR c=0;
bool AbsEnd=false;
sal_uLong LF100=0;
sal_uLong MaxLF100=0;
@@ -424,7 +423,7 @@ sal_uInt16 GetLineFeed(UCHAR* TBuf, sal_uInt16 Index, ObjTextType Atr0, ObjTextT
MaxGrad=0;
while (!AbsEnd && nChar>0) {
nChar--;
- c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,false);
+ UCHAR c=GetTextChar(TBuf,Index,Atr0,AktAtr,nChar,false);
i++;
AbsEnd=(c==TextEnd || c==AbsatzEnd);
if (First || (!AbsEnd && c!=' ' && c!=HardTrenn)) {
@@ -666,7 +665,6 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
{
VirtualDevice vOut;
UCHAR c,c0;
- UCHAR ct;
bool First; // first char ?
sal_uInt8 Just = 0; // paragraph format
bool Border; // border of box reached ?
@@ -734,7 +732,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
(*TRrec)=(*R); TRnChar=nChars;
Border0=false; Border=false;
do { // first check how many syllables fit
- ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
+ UCHAR ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars);
@@ -953,9 +951,8 @@ void TextType::Draw(OutputDevice& rOut)
if (TextFit) {
if (LineFit) FitXDiv=xLine[lc+1];
if (FitXDiv>0) {
- long Temp;
for (i=1;i<=l+1;i++) {
- Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv);
+ const long Temp=long(xLine[i])*long(FitXMul) /long(FitXDiv);
xLine[i]=short(Temp);
}
LF=MulDiv(LF,FitYMul,FitYDiv);
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 95790be..606a9f3 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -622,7 +622,7 @@ bool EnhWMFReader::ReadEnhWMF()
nDat32(0), nNom1(0), nDen1(0), nNom2(0), nDen2(0);
sal_Int32 nX32(0), nY32(0), nx32(0), ny32(0);
- bool bFlag(false), bStatus = ReadHeader();
+ bool bStatus = ReadHeader();
bool bHaveDC = false;
static bool bEnableEMFPlus = ( getenv( "EMF_PLUS_DISABLE" ) == NULL );
@@ -652,7 +652,7 @@ bool EnhWMFReader::ReadEnhWMF()
pOut->ResolveBitmapActions( aBmpSaveList );
}
- bFlag = false;
+ bool bFlag = false;
SAL_INFO ("vcl.emf", "0x" << std::hex << (nNextPos - nRecSize) << "-0x" << nNextPos << " " << record_type_name(nRecType) << " size: " << nRecSize << std::dec);
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index b7e63d7..aef13a1 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1285,8 +1285,6 @@ void WMFReader::ReadWMF()
nEMFRec = 0;
nEMFSize = 0;
- bool bEMFAvailable = false;
-
pOut->SetMapMode( MM_ANISOTROPIC );
pOut->SetWinOrg( Point() );
pOut->SetWinExt( Size( 1, 1 ) );
@@ -1298,6 +1296,7 @@ void WMFReader::ReadWMF()
if ( ReadHeader( ) )
{
+ bool bEMFAvailable = false;
nPos = pWMF->Tell();
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index 6e4c6cb..e0a6597 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -1008,8 +1008,6 @@ void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx:
void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
{
- MetaAction* pMA;
-
if( bStatus )
{
size_t nACount = rMTF.GetActionSize();
@@ -1018,7 +1016,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
for( size_t nA = 0; nA < nACount; nA++ )
{
- pMA = rMTF.GetAction( nA );
+ MetaAction* pMA = rMTF.GetAction( nA );
switch( pMA->GetType() )
{
More information about the Libreoffice-commits
mailing list