From 45d56f7175f34368db201f872091472f4a39c968 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Tue, 5 Oct 2010 07:56:37 -0500 Subject: [PATCH 1/2] Do not use magic number instead of the size of objects. --- editeng/source/items/itemtype.cxx | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/editeng/source/items/itemtype.cxx b/editeng/source/items/itemtype.cxx index a5c7110..dea8037 100644 --- a/editeng/source/items/itemtype.cxx +++ b/editeng/source/items/itemtype.cxx @@ -155,10 +155,9 @@ XubString GetColorString( const Color& rCol ) { XubString sStr; - FASTBOOL bFound = sal_False; ColorData nColData = RGB_COLORDATA( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() ); - sal_uInt16 nColor = 0, nColCount = 16; + sal_uInt16 nColor = 0; static ColorData aColAry[] = { COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, @@ -166,15 +165,13 @@ XubString GetColorString( const Color& rCol ) COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTGREEN, COL_LIGHTCYAN, COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE }; - while ( !bFound && nColor < nColCount ) + while ( nColor < sizeof(aColAry)/sizeof(ColorData) && + aColAry[nColor] != nColData ) { - if ( aColAry[nColor] == nColData ) - bFound = sal_True; - else - nColor++; + nColor += 1; } - if ( nColor < nColCount ) + if ( nColor < sizeof(aColAry)/sizeof(ColorData) ) sStr = EE_RESSTR( RID_SVXITEMS_COLOR_BEGIN + nColor + 1 ); if ( !sStr.Len() ) -- 1.7.1