[Libreoffice-commits] core.git: vcl/source
Michael Weghorn
m.weghorn at posteo.de
Sun Jan 18 22:20:01 PST 2015
vcl/source/font/PhysicalFontCollection.cxx | 3 +--
vcl/source/fontsubset/sft.cxx | 15 ++++++++-------
vcl/source/fontsubset/ttcr.cxx | 13 ++++---------
vcl/source/gdi/animate.cxx | 4 +---
vcl/source/gdi/impvect.cxx | 6 ++----
vcl/source/gdi/octree.cxx | 20 ++++++++------------
vcl/source/glyphs/graphite_layout.cxx | 3 +--
vcl/source/outdev/gradient.cxx | 12 ++++--------
vcl/source/window/builder.cxx | 3 +--
vcl/source/window/floatwin.cxx | 3 +--
10 files changed, 31 insertions(+), 51 deletions(-)
New commits:
commit 5f01eb5d7a3927d31b7dd268562a59e3dacdd8e8
Author: Michael Weghorn <m.weghorn at posteo.de>
Date: Sat Jan 17 01:18:38 2015 +0100
fdo#39440 vcl: reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: Ibebfe89ad1874f5fa9e20fb76a534d9c2da01e3f
Reviewed-on: https://gerrit.libreoffice.org/13969
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 6754e1b..5f51a3f 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -490,7 +490,6 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByAttributes( sal_uLong nSea
InitMatchData();
PhysicalFontFamily* pFoundData = NULL;
- long nTestMatch;
long nBestMatch = 40000;
sal_uLong nBestType = 0;
@@ -517,7 +516,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByAttributes( sal_uLong nSea
// Otherstyle, +Special, +Decorative,
// 1000 Typewriter, Rounded, Gothic, Schollbook
// 100
- nTestMatch = 0;
+ long nTestMatch = 0;
// test CJK script attributes
if ( nSearchType & IMPL_FONT_ATTR_CJK )
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 1adaf79..737a7a7 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -904,7 +904,7 @@ static int findname( const sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID,
{
if (n == 0) return -1;
- int l = 0, r = n-1, i;
+ int l = 0, r = n-1;
sal_uInt32 t1, t2;
sal_uInt32 m1, m2;
@@ -912,7 +912,7 @@ static int findname( const sal_uInt8 *name, sal_uInt16 n, sal_uInt16 platformID,
m2 = (languageID << 16) | nameID;
do {
- i = (l + r) >> 1;
+ const int i = (l + r) >> 1;
t1 = GetUInt32(name + 6, i * 12 + 0, 1);
t2 = GetUInt32(name + 6, i * 12 + 4, 1);
@@ -1044,10 +1044,11 @@ static void GetNames(TrueTypeFont *t)
bPSNameOK = false;
if( !bPSNameOK )
{
- bool bReplace = true;
/* check if family is a suitable replacement */
if( t->ufamily && t->family )
{
+ bool bReplace = true;
+
for( i = 0; t->ufamily[ i ] != 0 && bReplace; i++ )
if( t->ufamily[ i ] < 33 || t->ufamily[ i ] > 127 )
bReplace = false;
@@ -1167,7 +1168,7 @@ static sal_uInt32 getGlyph6(const sal_uInt8 *cmap, sal_uInt32, sal_uInt32 c) {
}
static sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSearch) {
- signed int low, mid, high, lastfound = 0xffff;
+ signed int low, high, lastfound = 0xffff;
sal_uInt16 res;
if(length == (sal_uInt16)0 || length == (sal_uInt16)0xFFFF) {
return (sal_uInt16)0xFFFF;
@@ -1175,7 +1176,7 @@ static sal_uInt16 GEbinsearch(sal_uInt16 *ar, sal_uInt16 length, sal_uInt16 toSe
low = 0;
high = length - 1;
while(high >= low) {
- mid = (high + low)/2;
+ int mid = (high + low)/2;
res = Int16FromMOTA(*(ar+mid));
if(res >= toSearch) {
lastfound = mid;
@@ -1820,7 +1821,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname,
{
ControlPoint *pa;
PSPathElement *path;
- int i, j, r, n;
+ int i, j, n;
const sal_uInt8* table = getTable(ttf, O_head);
TTGlyphMetrics metrics;
int UPEm = ttf->unitsPerEm;
@@ -1909,7 +1910,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname,
for (i = 0; i < nGlyphs; i++) {
fprintf(outf, h33, i);
- r = GetTTGlyphOutline(ttf, glyphArray[i] < ttf->nglyphs ? glyphArray[i] : 0, &pa, &metrics, 0);
+ int r = GetTTGlyphOutline(ttf, glyphArray[i] < ttf->nglyphs ? glyphArray[i] : 0, &pa, &metrics, 0);
if (r > 0) {
n = BSplineToPSPath(pa, r, &path);
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 1f019cf..e65c7cc 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -482,16 +482,12 @@ static void TrueTypeTableDispose_glyf(TrueTypeTable *_this)
static void TrueTypeTableDispose_cmap(TrueTypeTable *_this)
{
- table_cmap *t;
- CmapSubTable *s;
- sal_uInt32 i;
-
if (_this) {
- t = (table_cmap *) _this->data;
+ table_cmap *t = (table_cmap *) _this->data;
if (t) {
- s = t->s;
+ CmapSubTable *s = t->s;
if (s) {
- for (i = 0; i < t->m; i++) {
+ for (sal_uInt32 i = 0; i < t->m; i++) {
if (s[i].xc) free(s[i].xc);
if (s[i].xg) free(s[i].xg);
}
@@ -1195,7 +1191,6 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt
list l;
sal_uInt32 currentID;
int ret, n, ncomponents;
- GlyphData *gd;
assert(table != 0);
assert(table->tag == T_glyf);
@@ -1235,7 +1230,7 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt
} while (listNext(l));
if (!found) {
- gd = GetTTRawGlyphData(fnt, currentID);
+ GlyphData *gd = GetTTRawGlyphData(fnt, currentID);
gd->newID = n++;
listAppend(l, gd);
}
diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx
index 7b8fbbe..66cfe54 100644
--- a/vcl/source/gdi/animate.cxx
+++ b/vcl/source/gdi/animate.cxx
@@ -365,8 +365,6 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl)
if( maNotifyLink.IsSet() )
{
- AInfo* pAInfo;
-
// create AInfo-List
for( size_t i = 0, n = maViewList.size(); i < n; ++i )
aAInfoList.push_back( maViewList[ i ]->createAInfo() );
@@ -376,7 +374,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl)
// set view state from AInfo structure
for( size_t i = 0, n = aAInfoList.size(); i < n; ++i )
{
- pAInfo = aAInfoList[ i ];
+ AInfo* pAInfo = aAInfoList[ i ];
if( !pAInfo->pViewData )
{
pView = new ImplAnimView( this, pAInfo->pOutDev,
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index e61364d..32727c4 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -1014,8 +1014,6 @@ bool ImplVectorizer::ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, Im
{
long nActX = rStartPt.X();
long nActY = rStartPt.Y();
- long nTryX;
- long nTryY;
sal_uLong nFound;
sal_uLong nLastDir = 0UL;
sal_uLong nDir;
@@ -1025,8 +1023,8 @@ bool ImplVectorizer::ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, Im
nFound = 0UL;
// first try last direction
- nTryX = nActX + aImplMove[ nLastDir ].nDX;
- nTryY = nActY + aImplMove[ nLastDir ].nDY;
+ long nTryX = nActX + aImplMove[ nLastDir ].nDX;
+ long nTryY = nActY + aImplMove[ nLastDir ].nDY;
if( pMap->IsCont( nTryY, nTryX ) )
{
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx
index 4517b9d..eac0f52 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/gdi/octree.cxx
@@ -242,8 +242,6 @@ void Octree::GetPalIndex( PNODE pNode )
InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) :
nBits( 8 - OCTREE_BITS )
{
- sal_uLong* cdp;
- sal_uInt8* crgbp;
const sal_uLong nColorMax = 1 << OCTREE_BITS;
const sal_uLong xsqr = 1 << ( nBits << 1 );
const sal_uLong xsqr2 = xsqr << 1;
@@ -252,8 +250,6 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) :
const long x2 = x >> 1L;
sal_uLong r, g, b;
long rxx, gxx, bxx;
- long rdist, gdist, bdist;
- long crinc, cginc, cbinc;
ImplCreateBuffers( nColorMax );
@@ -264,17 +260,17 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) :
const long cGreen = rColor.GetGreen();
const long cBlue = rColor.GetBlue();
- rdist = cRed - x2;
- gdist = cGreen - x2;
- bdist = cBlue - x2;
+ long rdist = cRed - x2;
+ long gdist = cGreen - x2;
+ long bdist = cBlue - x2;
rdist = rdist*rdist + gdist*gdist + bdist*bdist;
- crinc = ( xsqr - ( cRed << nBits ) ) << 1L;
- cginc = ( xsqr - ( cGreen << nBits ) ) << 1L;
- cbinc = ( xsqr - ( cBlue << nBits ) ) << 1L;
+ const long crinc = ( xsqr - ( cRed << nBits ) ) << 1L;
+ const long cginc = ( xsqr - ( cGreen << nBits ) ) << 1L;
+ const long cbinc = ( xsqr - ( cBlue << nBits ) ) << 1L;
- cdp = (sal_uLong*) pBuffer;
- crgbp = pMap;
+ sal_uLong* cdp = (sal_uLong*) pBuffer;
+ sal_uInt8* crgbp = pMap;
for( r = 0, rxx = crinc; r < nColorMax; rdist += rxx, r++, rxx += xsqr2 )
{
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index 6f7cbb2..f72b780 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -919,10 +919,9 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt
size_t j = i + 1;
int nLastChar = i;
int nLastGlyph = nChar2Base;
- int nChar2BaseJ = -1;
for (; j < nChars; j++)
{
- nChar2BaseJ = mvChar2BaseGlyph[j];
+ const int nChar2BaseJ = mvChar2BaseGlyph[j];
assert((nChar2BaseJ >= -1) && (nChar2BaseJ < (signed)mvGlyphs.size()));
if (nChar2BaseJ != -1 )
{
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 7031103..d6239d1 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -366,9 +366,7 @@ void OutputDevice::DrawLinearGradient( const Rectangle& rRect,
double fGradientLine = (double)aRect.Top();
double fMirrorGradientLine = (double) aMirrorRect.Bottom();
- double fAlpha = 0.0;
const double fStepsMinus1 = ((double)nSteps) - 1.0;
- double fTempColor;
if ( !bLinear)
{
nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap
@@ -376,8 +374,8 @@ void OutputDevice::DrawLinearGradient( const Rectangle& rRect,
for ( long i = 0; i < nSteps; i++ )
{
// linear interpolation of color
- fAlpha = ((double)i) / fStepsMinus1;
- fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha;
+ const double fAlpha = ((double)i) / fStepsMinus1;
+ double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha;
nRed = GetGradientColorValue((long)fTempColor);
fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha;
nGreen = GetGradientColorValue((long)fTempColor);
@@ -711,9 +709,7 @@ void OutputDevice::DrawLinearGradientToMetafile( const Rectangle& rRect,
double fGradientLine = (double)aRect.Top();
double fMirrorGradientLine = (double) aMirrorRect.Bottom();
- double fAlpha = 0.0;
const double fStepsMinus1 = ((double)nSteps) - 1.0;
- double fTempColor;
if ( !bLinear)
{
nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap
@@ -721,8 +717,8 @@ void OutputDevice::DrawLinearGradientToMetafile( const Rectangle& rRect,
for ( long i = 0; i < nSteps; i++ )
{
// linear interpolation of color
- fAlpha = ((double)i) / fStepsMinus1;
- fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha;
+ double fAlpha = ((double)i) / fStepsMinus1;
+ double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha;
nRed = GetGradientColorValue((long)fTempColor);
fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha;
nGreen = GetGradientColorValue((long)fTempColor);
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 2510202..e6d675d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1679,10 +1679,9 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
#ifndef DISABLE_DYNLOADING
OUString sModule = sModuleBuf.makeStringAndClear();
ModuleMap::iterator aI = m_aModuleMap.find(sModule);
- osl::Module* pModule = NULL;
if (aI == m_aModuleMap.end())
{
- pModule = new osl::Module;
+ osl::Module* pModule = new osl::Module;
pModule->loadRelative(&thisModule, sModule);
aI = m_aModuleMap.insert(sModule, pModule).first;
}
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index ed0e3c1..3734081 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -236,7 +236,6 @@ Point FloatingWindow::ImplCalcPos( vcl::Window* pWindow,
sal_uInt16 nArrangeAry[5];
sal_uInt16 nArrangeIndex;
- bool bBreak;
Point e1,e2; // the common edge between the item rect and the floating window
if ( nFlags & FLOATWIN_POPUPMODE_LEFT )
@@ -278,7 +277,7 @@ Point FloatingWindow::ImplCalcPos( vcl::Window* pWindow,
for ( ; nArrangeIndex < 5; nArrangeIndex++ )
{
- bBreak = true;
+ bool bBreak = true;
switch ( nArrangeAry[nArrangeIndex] )
{
More information about the Libreoffice-commits
mailing list