From f8e081876fa321cbf6072472ef5b5ee0aa050260 Mon Sep 17 00:00:00 2001 From: Kenneth Venken Date: Fri, 3 Dec 2010 13:59:12 +0000 Subject: more Sal n elements --- chart2/source/tools/ConfigColorScheme.cxx | 3 ++- sc/source/core/data/global.cxx | 4 ++-- sc/source/core/tool/interpr2.cxx | 2 +- sc/source/core/tool/parclass.cxx | 3 ++- sc/source/filter/excel/xiescher.cxx | 3 ++- sc/source/filter/excel/xistyle.cxx | 3 ++- sc/source/filter/excel/xlchart.cxx | 11 ++++++----- sc/source/filter/excel/xlpage.cxx | 3 ++- sc/source/filter/excel/xlstyle.cxx | 9 +++++---- sc/source/filter/excel/xltools.cxx | 11 ++++++----- sc/source/filter/inc/ftools.hxx | 5 ++--- sc/source/ui/dbgui/csvgrid.cxx | 3 ++- sc/source/ui/vba/vbainterior.cxx | 4 ++-- sc/source/ui/view/gridwin.cxx | 3 ++- scaddins/source/analysis/analysis.cxx | 3 ++- scaddins/source/analysis/analysishelper.cxx | 5 ++--- scaddins/source/datefunc/datefunc.cxx | 6 ++---- 17 files changed, 44 insertions(+), 37 deletions(-) diff --git a/chart2/source/tools/ConfigColorScheme.cxx b/chart2/source/tools/ConfigColorScheme.cxx index d0d0d722b764..23fcd4fa9e72 100644 --- a/chart2/source/tools/ConfigColorScheme.cxx +++ b/chart2/source/tools/ConfigColorScheme.cxx @@ -34,6 +34,7 @@ #include "macros.hxx" #include +#include #include @@ -175,7 +176,7 @@ void ConfigColorScheme::retrieveConfigColors() 0xff00ff, 0x00ffff, 0xffff00 }; - static const sal_Int32 nMaxDefaultColors = sizeof( nDefaultColors ) / sizeof( sal_Int32 ); + static const sal_Int32 nMaxDefaultColors = SAL_N_ELEMENTS( nDefaultColors ); return nDefaultColors[ nIndex % nMaxDefaultColors ]; } diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index faede3eb6482..6b8c3c4231b7 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -1219,11 +1220,10 @@ ScFunctionList::ScFunctionList() : RID_SC_FUNCTION_DESCRIPTIONS1, RID_SC_FUNCTION_DESCRIPTIONS2 }; - const USHORT nBlocks = sizeof(nDescBlock) / sizeof(USHORT); aFunctionList.Clear(); - for ( USHORT k = 0; k < nBlocks; k++ ) + for ( USHORT k = 0; k < SAL_N_ELEMENTS(nDescBlock); k++ ) { ::std::auto_ptr pBlock( new ScResourcePublisher( ScResId( nDescBlock[k] ) ) ); // Browse for all possible OpCodes. This is not the fastest method, but diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 599d2ba08e3b..eabcc2943fc4 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -2235,7 +2235,7 @@ void ScInterpreter::ScBase() 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 0 }; - static const int nDigits = (sizeof(pDigits)/sizeof(sal_Unicode))-1; + static const int nDigits = SAL_N_ELEMENTS(pDigits)-1; xub_StrLen nMinLen; if ( nParamCount == 3 ) { diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 9af15044f69a..9542d61c2515 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -38,6 +38,7 @@ #include "funcdesc.hxx" #include #include +#include #include #if OSL_DEBUG_LEVEL > 1 @@ -214,7 +215,7 @@ void ScParameterClassification::Init() memset( pData, 0, sizeof(RunData) * (SC_OPCODE_LAST_OPCODE_ID + 1)); // init from specified static data above - for ( size_t i=0; i < sizeof(pRawData) / sizeof(RawData); ++i ) + for ( size_t i=0; i < SAL_N_ELEMENTS(pRawData); ++i ) { const RawData* pRaw = &pRawData[i]; if ( pRaw->eOp > SC_OPCODE_LAST_OPCODE_ID ) diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 968fd5e67edf..c674851e5e74 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include @@ -657,7 +658,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 }, { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 } }; - const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, STATIC_TABLE_SIZE( sppnPatterns ) ) ]; + const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, SAL_N_ELEMENTS( sppnPatterns ) ) ]; // create 2-colored 8x8 DIB SvMemoryStream aMemStrm; aMemStrm << sal_uInt32( 12 ) << sal_Int16( 8 ) << sal_Int16( 8 ) << sal_uInt16( 1 ) << sal_uInt16( 1 ); diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index f15a6dde0d14..62541f992da7 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include "document.hxx" #include "docpool.hxx" #include "attrib.hxx" @@ -904,7 +905,7 @@ bool lclConvertBorderLine( SvxBorderLine& rLine, const XclImpPalette& rPalette, if( nXclLine == EXC_LINE_NONE ) return false; - if( nXclLine >= STATIC_TABLE_SIZE( ppnLineParam ) ) + if( nXclLine >= SAL_N_ELEMENTS( ppnLineParam ) ) nXclLine = EXC_LINE_THIN; rLine.SetColor( rPalette.GetColor( nXclColor ) ); diff --git a/sc/source/filter/excel/xlchart.cxx b/sc/source/filter/excel/xlchart.cxx index ae84e288f635..8fcace686292 100644 --- a/sc/source/filter/excel/xlchart.cxx +++ b/sc/source/filter/excel/xlchart.cxx @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -405,7 +406,7 @@ sal_uInt16 XclChartHelper::GetSeriesLineAutoColorIdx( sal_uInt16 nFormatIdx ) 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 63 }; - return spnLineColors[ nFormatIdx % STATIC_TABLE_SIZE( spnLineColors ) ]; + return spnLineColors[ nFormatIdx % SAL_N_ELEMENTS( spnLineColors ) ]; } sal_uInt16 XclChartHelper::GetSeriesFillAutoColorIdx( sal_uInt16 nFormatIdx ) @@ -420,13 +421,13 @@ sal_uInt16 XclChartHelper::GetSeriesFillAutoColorIdx( sal_uInt16 nFormatIdx ) 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; - return spnFillColors[ nFormatIdx % STATIC_TABLE_SIZE( spnFillColors ) ]; + return spnFillColors[ nFormatIdx % SAL_N_ELEMENTS( spnFillColors ) ]; } sal_uInt8 XclChartHelper::GetSeriesFillAutoTransp( sal_uInt16 nFormatIdx ) { static const sal_uInt8 spnTrans[] = { 0x00, 0x40, 0x20, 0x60, 0x70 }; - return spnTrans[ (nFormatIdx / 56) % STATIC_TABLE_SIZE( spnTrans ) ]; + return spnTrans[ (nFormatIdx / 56) % SAL_N_ELEMENTS( spnTrans ) ]; } sal_uInt16 XclChartHelper::GetAutoMarkerType( sal_uInt16 nFormatIdx ) @@ -435,14 +436,14 @@ sal_uInt16 XclChartHelper::GetAutoMarkerType( sal_uInt16 nFormatIdx ) EXC_CHMARKERFORMAT_DIAMOND, EXC_CHMARKERFORMAT_SQUARE, EXC_CHMARKERFORMAT_TRIANGLE, EXC_CHMARKERFORMAT_CROSS, EXC_CHMARKERFORMAT_STAR, EXC_CHMARKERFORMAT_CIRCLE, EXC_CHMARKERFORMAT_PLUS, EXC_CHMARKERFORMAT_DOWJ, EXC_CHMARKERFORMAT_STDDEV }; - return spnSymbols[ nFormatIdx % STATIC_TABLE_SIZE( spnSymbols ) ]; + return spnSymbols[ nFormatIdx % SAL_N_ELEMENTS( spnSymbols ) ]; } bool XclChartHelper::HasMarkerFillColor( sal_uInt16 nMarkerType ) { static const bool spbFilled[] = { false, true, true, true, false, false, false, false, true, false }; - return (nMarkerType < STATIC_TABLE_SIZE( spbFilled )) && spbFilled[ nMarkerType ]; + return (nMarkerType < SAL_N_ELEMENTS( spbFilled )) && spbFilled[ nMarkerType ]; } OUString XclChartHelper::GetErrorBarValuesRole( sal_uInt8 nBarType ) diff --git a/sc/source/filter/excel/xlpage.cxx b/sc/source/filter/excel/xlpage.cxx index 53cdd0550081..1fd4d155f5c4 100644 --- a/sc/source/filter/excel/xlpage.cxx +++ b/sc/source/filter/excel/xlpage.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include "scitems.hxx" #include #include "global.hxx" @@ -209,7 +210,7 @@ void XclPageData::SetDefaults() Size XclPageData::GetScPaperSize() const { const XclPaperSize* pEntry = pPaperSizeTable; - if( mnPaperSize < STATIC_TABLE_SIZE( pPaperSizeTable ) ) + if( mnPaperSize < SAL_N_ELEMENTS( pPaperSizeTable ) ) pEntry += mnPaperSize; Size aSize; diff --git a/sc/source/filter/excel/xlstyle.cxx b/sc/source/filter/excel/xlstyle.cxx index cb95fd1658ed..83f19f994ce8 100644 --- a/sc/source/filter/excel/xlstyle.cxx +++ b/sc/source/filter/excel/xlstyle.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -112,20 +113,20 @@ XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) : { case EXC_BIFF2: mpnColorTable = spnDefColorTable2; - mnTableSize = STATIC_TABLE_SIZE( spnDefColorTable2 ); + mnTableSize = SAL_N_ELEMENTS( spnDefColorTable2 ); break; case EXC_BIFF3: case EXC_BIFF4: mpnColorTable = spnDefColorTable3; - mnTableSize = STATIC_TABLE_SIZE( spnDefColorTable3 ); + mnTableSize = SAL_N_ELEMENTS( spnDefColorTable3 ); break; case EXC_BIFF5: mpnColorTable = spnDefColorTable5; - mnTableSize = STATIC_TABLE_SIZE( spnDefColorTable5 ); + mnTableSize = SAL_N_ELEMENTS( spnDefColorTable5 ); break; case EXC_BIFF8: mpnColorTable = spnDefColorTable8; - mnTableSize = STATIC_TABLE_SIZE( spnDefColorTable8 ); + mnTableSize = SAL_N_ELEMENTS( spnDefColorTable8 ); break; default: DBG_ERROR_BIFF(); diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index 5ee9429ebac7..f4b79daa7e66 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include "xestream.hxx" @@ -358,7 +359,7 @@ Color XclTools::GetPatternColor( const Color& rPattColor, const Color& rBackColo 0x40, 0x40, 0x20, 0x60, 0x60, 0x60, 0x60, 0x48, // 08 - 15 0x50, 0x70, 0x78 // 16 - 18 }; - return (nXclPattern < STATIC_TABLE_SIZE( pnRatioTable )) ? + return (nXclPattern < SAL_N_ELEMENTS( pnRatioTable )) ? ScfTools::GetMixedColor( rPattColor, rBackColor, pnRatioTable[ nXclPattern ] ) : rPattColor; } @@ -488,10 +489,10 @@ static const sal_Char* const ppcDefNames[] = String XclTools::GetXclBuiltInDefName( sal_Unicode cBuiltIn ) { - DBG_ASSERT( STATIC_TABLE_SIZE( ppcDefNames ) == EXC_BUILTIN_UNKNOWN, + DBG_ASSERT( SAL_N_ELEMENTS( ppcDefNames ) == EXC_BUILTIN_UNKNOWN, "XclTools::GetXclBuiltInDefName - built-in defined name list modified" ); String aDefName; - if( cBuiltIn < STATIC_TABLE_SIZE( ppcDefNames ) ) + if( cBuiltIn < SAL_N_ELEMENTS( ppcDefNames ) ) aDefName.AssignAscii( ppcDefNames[ cBuiltIn ] ); else aDefName = String::CreateFromInt32( cBuiltIn ); @@ -555,7 +556,7 @@ String XclTools::GetBuiltInStyleName( sal_uInt8 nStyleId, const String& rName, s else { aStyleName = maStyleNamePrefix1; - if( nStyleId < STATIC_TABLE_SIZE( ppcStyleNames ) ) + if( nStyleId < SAL_N_ELEMENTS( ppcStyleNames ) ) aStyleName.AppendAscii( ppcStyleNames[ nStyleId ] ); else if( rName.Len() > 0 ) aStyleName.Append( rName ); @@ -595,7 +596,7 @@ bool XclTools::IsBuiltInStyleName( const String& rStyleName, sal_uInt8* pnStyleI if( nPrefixLen > 0 ) { String aShortName; - for( sal_uInt8 nId = 0; nId < STATIC_TABLE_SIZE( ppcStyleNames ); ++nId ) + for( sal_uInt8 nId = 0; nId < SAL_N_ELEMENTS( ppcStyleNames ); ++nId ) { if( nId != EXC_STYLE_NORMAL ) { diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx index 9e0c461ed058..d420fef5acc1 100644 --- a/sc/source/filter/inc/ftools.hxx +++ b/sc/source/filter/inc/ftools.hxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -44,10 +45,8 @@ // Common macros ============================================================== -/** Expands to the size of a STATIC data array. */ -#define STATIC_TABLE_SIZE( array ) (sizeof(array)/sizeof(*(array))) /** Expands to a pointer behind the last element of a STATIC data array (like STL end()). */ -#define STATIC_TABLE_END( array ) ((array)+STATIC_TABLE_SIZE(array)) +#define STATIC_TABLE_END( array ) ((array)+SAL_N_ELEMENTS(array)) /** Expands to a temporary String, created from an ASCII character array. */ #define CREATE_STRING( ascii ) String( RTL_CONSTASCII_USTRINGPARAM( ascii ) ) diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index 565942b0cc9d..eb179a83d3c5 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -38,6 +38,7 @@ #include #include +#include #include #include "scmod.hxx" #include "asciiopt.hxx" @@ -523,7 +524,7 @@ sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType ) { static sal_uInt8 pExtTypes[] = { SC_COL_STANDARD, SC_COL_TEXT, SC_COL_DMY, SC_COL_MDY, SC_COL_YMD, SC_COL_ENGLISH, SC_COL_SKIP }; - static sal_Int32 nExtTypeCount = sizeof( pExtTypes ) / sizeof( *pExtTypes ); + static sal_Int32 nExtTypeCount = SAL_N_ELEMENTS(pExtTypes); return pExtTypes[ ((0 <= nIntType) && (nIntType < nExtTypeCount)) ? nIntType : 0 ]; } diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx index e767ce2b73a2..30268e14583e 100644 --- a/sc/source/ui/vba/vbainterior.cxx +++ b/sc/source/ui/vba/vbainterior.cxx @@ -43,13 +43,13 @@ #include +#include #include #include "vbainterior.hxx" #include "vbapalette.hxx" #include "document.hxx" -#define STATIC_TABLE_SIZE( array ) (sizeof(array)/sizeof(*(array))) #define COLORMAST 0xFFFFFF const sal_uInt16 EXC_COLOR_WINDOWBACK = 65; typedef std::map< sal_Int32, sal_Int32 > PatternMap; @@ -240,7 +240,7 @@ ScVbaInterior::GetPatternColor( const Color& rPattColor, const Color& rBackColor 0x40, 0x40, 0x20, 0x60, 0x60, 0x60, 0x60, 0x48, // 08 - 15 0x50, 0x70, 0x78 // 16 - 18 }; - return ( nXclPattern < STATIC_TABLE_SIZE( pnRatioTable ) ) ? + return ( nXclPattern < SAL_N_ELEMENTS( pnRatioTable ) ) ? GetMixedColor( rPattColor, rBackColor, pnRatioTable[ nXclPattern ] ) : rPattColor; } Color diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1f21e93d28d3..234ce36cc5de 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -55,6 +55,7 @@ #include #include #include +#include #include // fuer Command-Handler (COMMAND_INSERTTEXT) #include // fuer Command-Handler (COMMAND_INSERTTEXT) @@ -953,7 +954,7 @@ void ScGridWindow::DoAutoFilterMenue( SCCOL nCol, SCROW nRow, BOOL bDataSelect ) // default entries static const USHORT nDefIDs[] = { SCSTR_ALLFILTER, SCSTR_TOP10FILTER, SCSTR_STDFILTER, SCSTR_EMPTY, SCSTR_NOTEMPTY }; - const USHORT nDefCount = sizeof(nDefIDs) / sizeof(USHORT); + const USHORT nDefCount = SAL_N_ELEMENTS(nDefIDs); for (i=0; i #include #include +#include #include #include @@ -510,7 +511,7 @@ STRING SAL_CALL AnalysisAddIn::getDisplayCategoryName( const STRING& aProgrammat static const sal_Char* pLang[] = { "de", "en" }; static const sal_Char* pCoun[] = { "DE", "US" }; -static const sal_uInt32 nNumOfLoc = sizeof( pLang ) / sizeof( sal_Char* ); +static const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS(pLang); void AnalysisAddIn::InitDefLocales( void ) diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 4f0711678a03..c2e61f567157 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include "analysishelper.hxx" #include "analysis.hrc" @@ -1413,9 +1414,7 @@ sal_uInt16 FuncData::GetStrIndex( sal_uInt16 nParamNum ) const FuncDataList::FuncDataList( ResMgr& rResMgr ) { - const sal_uInt32 nNum = sizeof( pFuncDatas ) / sizeof( FuncDataBase ); - - for( sal_uInt16 n = 0 ; n < nNum ; n++ ) + for( sal_uInt16 n = 0 ; n < SAL_N_ELEMENTS(pFuncDatas) ; n++ ) Append( new FuncData( pFuncDatas[ n ], rResMgr ) ); } diff --git a/scaddins/source/datefunc/datefunc.cxx b/scaddins/source/datefunc/datefunc.cxx index fb2d6b2e82f8..68f26f3b81de 100644 --- a/scaddins/source/datefunc/datefunc.cxx +++ b/scaddins/source/datefunc/datefunc.cxx @@ -178,9 +178,7 @@ sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) : nLast( 0xFFFFFFFF ) { - const sal_uInt32 nCnt = sizeof( pFuncDataArr ) / sizeof( ScaFuncDataBase ); - - for( sal_uInt16 nIndex = 0; nIndex < nCnt; nIndex++ ) + for( sal_uInt16 nIndex = 0; nIndex < SAL_N_ELEMENTS(pFuncDataArr); nIndex++ ) Append( new ScaFuncData( pFuncDataArr[ nIndex ], rResMgr ) ); } @@ -323,7 +321,7 @@ ScaDateAddIn::~ScaDateAddIn() static const sal_Char* pLang[] = { "de", "en" }; static const sal_Char* pCoun[] = { "DE", "US" }; -static const sal_uInt32 nNumOfLoc = sizeof( pLang ) / sizeof( sal_Char* ); +static const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS( pLang ); void ScaDateAddIn::InitDefLocales() { -- cgit v1.2.3