hey, more use of the SAL_N_ELEMENTS macro like replacing the STATIC_TABLE_SIZE macro.
-- Kenneth
>From 62a94ea8d83b129ef479304865d3f2085b191c32 Mon Sep 17 00:00:00 2001 From: Kenneth Venken <kenneth.ven...@gmail.com> Date: Fri, 3 Dec 2010 01:41:20 +0100 Subject: [PATCH] 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 d7f630d..bd10a5c 100644 --- a/chart2/source/tools/ConfigColorScheme.cxx +++ b/chart2/source/tools/ConfigColorScheme.cxx @@ -34,6 +34,7 @@ #include "macros.hxx" #include <unotools/configitem.hxx> +#include <sal/macros.h> #include <set> @@ -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 4474a59..93550a9 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -50,6 +50,7 @@ #include <svl/zformat.hxx> #include <vcl/image.hxx> #include <vcl/virdev.hxx> +#include <sal/macros.h> #include <tools/rcid.h> #include <unotools/charclass.hxx> #include <stdlib.h> @@ -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<ScResourcePublisher> 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 599d2ba..eabcc29 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 f7b414d..7248ba7 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -38,6 +38,7 @@ #include "funcdesc.hxx" #include <unotools/charclass.hxx> #include <tools/debug.hxx> +#include <sal/macros.h> #include <string.h> #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 8295128..99f7d12 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -84,6 +84,7 @@ #include <editeng/eeitem.hxx> #include <editeng/colritem.hxx> #include <svx/xflclit.hxx> +#include <sal/macros.h> #include <editeng/adjitem.hxx> #include <svx/xlineit.hxx> #include <svx/xlinjoit.hxx> @@ -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 f15a6dd..62541f9 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -53,6 +53,7 @@ #include <editeng/eeitem.hxx> #include <editeng/flstitem.hxx> #include <editeng/justifyitem.hxx> +#include <sal/macros.h> #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 a4279c2..fe26ad5 100644 --- a/sc/source/filter/excel/xlchart.cxx +++ b/sc/source/filter/excel/xlchart.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart2/Symbol.hpp> +#include <sal/macros.h> #include <rtl/math.hxx> #include <svl/itemset.hxx> #include <svx/xfillit0.hxx> @@ -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 6a68867..9cf52de 100644 --- a/sc/source/filter/excel/xlpage.cxx +++ b/sc/source/filter/excel/xlpage.cxx @@ -33,6 +33,7 @@ #include <editeng/svxenum.hxx> #include <editeng/paperinf.hxx> #include <vcl/svapp.hxx> +#include <sal/macros.h> #include "scitems.hxx" #include <editeng/brshitem.hxx> #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 e144c0b..6033958 100644 --- a/sc/source/filter/excel/xlstyle.cxx +++ b/sc/source/filter/excel/xlstyle.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/i18n/ScriptType.hpp> #include <vcl/svapp.hxx> #include <vcl/font.hxx> +#include <sal/macros.h> #include <rtl/tencinfo.h> #include <toolkit/unohlp.hxx> #include <editeng/svxfont.hxx> @@ -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 36505c8..eb262bd 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -34,6 +34,7 @@ #include <sal/mathconf.h> #include <unotools/fontcvt.hxx> #include <sfx2/objsh.hxx> +#include <sal/macros.h> #include <editeng/editstat.hxx> #include <filter/msfilter/msvbahelper.hxx> #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 8e90e7e..c04ad3e 100644 --- a/sc/source/filter/inc/ftools.hxx +++ b/sc/source/filter/inc/ftools.hxx @@ -36,6 +36,7 @@ #include <tools/string.hxx> #include <tools/list.hxx> #include <tools/debug.hxx> +#include <sal/macros.h> #include <oox/helper/helper.hxx> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> @@ -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 1450a35..ae1f5e5 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -38,6 +38,7 @@ #include <svtools/colorcfg.hxx> #include <svl/smplhint.hxx> +#include <sal/macros.h> #include <tools/poly.hxx> #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 5b4df99..0afd6a9 100644 --- a/sc/source/ui/vba/vbainterior.cxx +++ b/sc/source/ui/vba/vbainterior.cxx @@ -43,13 +43,13 @@ #include <map> +#include <sal/macros.h> #include <svx/xtable.hxx> #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 7e5f55d..b3fb762 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -55,6 +55,7 @@ #include <vcl/hatch.hxx> #include <sot/formats.hxx> #include <sot/clsids.hxx> +#include <sal/macros.h> #include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT) #include <editeng/outliner.hxx> // 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<nDefCount; i++) { String aEntry( (ScResId) nDefIDs[i] ); diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index 5c146c8..b07c863 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -32,6 +32,7 @@ #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> #include <rtl/math.hxx> +#include <sal/macros.h> #include <string.h> #include <tools/resmgr.hxx> @@ -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 dc88b53..e4651a4 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -32,6 +32,7 @@ #include <stdio.h> #include <tools/resary.hxx> #include <rtl/math.hxx> +#include <sal/macros.h> #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 e350bc2..e3ca928 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() { -- 1.7.1
>From 9088472c16451d79f29d73b0bc93c345cc30bbb0 Mon Sep 17 00:00:00 2001 From: Kenneth Venken <kenneth.ven...@gmail.com> Date: Fri, 3 Dec 2010 01:41:21 +0100 Subject: [PATCH] more Sal n elements --- automation/source/testtool/registry_win.cxx | 5 +- cui/source/dialogs/cuifmsearch.cxx | 2 +- cui/source/options/opthtml.cxx | 3 +- cui/source/tabpages/border.cxx | 5 +- cui/source/tabpages/page.cxx | 9 +- cui/source/tabpages/swpossizetabpage.cxx | 106 ++++++++++---------- extensions/source/nsplugin/source/npshell.cxx | 1 + extensions/source/nsplugin/source/so_main.cxx | 4 +- extensions/source/propctrlr/formmetadata.cxx | 4 +- extensions/source/update/check/updatecheck.cxx | 5 +- .../source/update/check/updatecheckconfig.cxx | 3 +- setup_native/source/ulfconv/ulfconv.cxx | 3 +- .../mscrypt/securityenvironment_mscryptimpl.cxx | 4 +- xmlsecurity/source/xmlsec/nss/secerror.cxx | 3 +- .../xmlsec/nss/securityenvironment_nssimpl.cxx | 3 +- 15 files changed, 82 insertions(+), 78 deletions(-) diff --git a/automation/source/testtool/registry_win.cxx b/automation/source/testtool/registry_win.cxx index 0e77790..009f24c 100644 --- a/automation/source/testtool/registry_win.cxx +++ b/automation/source/testtool/registry_win.cxx @@ -46,6 +46,7 @@ #include "registry_win.hxx" #include <osl/thread.h> +#include <sal/macros.h> String ReadRegistry( String aKey, String aValueName ) @@ -70,8 +71,8 @@ String ReadRegistry( String aKey, String aValueName ) &hRegKey ) == ERROR_SUCCESS ) { LONG lRet; - sal_Unicode PathW[_MAX_PATH]; - DWORD lSize = sizeof(PathW) / sizeof( sal_Unicode ); + sal_Unicode PathW[_MAX_PATH ]; + DWORD lSize = SAL_N_ELEMENTS(PathW); DWORD Type = REG_SZ; lRet = RegQueryValueExW(hRegKey, reinterpret_cast<LPCWSTR>(aValueName.GetBuffer()), NULL, &Type, (LPBYTE)PathW, &lSize); diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx index b38e4bb..b4f3290 100644 --- a/cui/source/dialogs/cuifmsearch.cxx +++ b/cui/source/dialogs/cuifmsearch.cxx @@ -492,7 +492,7 @@ IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox*, pBox) { // die beiden jeweils anderen Boxes disablen oder enablen CheckBox* pBoxes[] = { &m_cbWildCard, &m_cbRegular, &m_cbApprox }; - for (sal_uInt32 i=0; i<sizeof(pBoxes)/sizeof(CheckBox*); ++i) + for (sal_uInt32 i=0; i< SAL_N_ELEMENTS(pBoxes); ++i) { if (pBoxes[i] != pBox) { diff --git a/cui/source/options/opthtml.cxx b/cui/source/options/opthtml.cxx index 5a992c8..8119726 100644 --- a/cui/source/options/opthtml.cxx +++ b/cui/source/options/opthtml.cxx @@ -38,6 +38,7 @@ #include <cuires.hrc> #include "helpid.hrc" #include <dialmgr.hxx> +#include <sal/macros.h> // Umwandlung der Modi zu den Positionen in der Listbox const USHORT aPosToExportArr[] = @@ -186,7 +187,7 @@ void OfaHtmlTabPage::Reset( const SfxItemSet& ) aUnknownTagCB.Check(pHtmlOpt->IsImportUnknown()); aIgnoreFontNamesCB.Check(pHtmlOpt->IsIgnoreFontFamily()); USHORT nExport = pHtmlOpt->GetExportMode(); - if( nExport >= ( sizeof( aExportToPosArr ) / sizeof( USHORT ) ) ) + if( nExport >= SAL_N_ELEMENTS( aExportToPosArr ) ) nExport = 4; // default for bad config entry is NS 4.0 USHORT nPosArr = aExportToPosArr[ nExport ]; // if( nPosArr == DEPRECATED_ENTRY ) diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 22c8468..481d0fa 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -56,6 +56,7 @@ #include <sfx2/request.hxx> #include <svl/intitem.hxx> #include <sfx2/itemconnect.hxx> +#include <sal/macros.h> #include "borderconn.hxx" // ----------------------------------------------------------------------- @@ -691,7 +692,7 @@ BOOL SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs ) TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT), }; - for (sal_uInt32 i=0; i < sizeof(eTypes1)/sizeof(TBorderPair); ++i) + for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i) aBoxItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second ); //-------------------------------- @@ -701,7 +702,7 @@ BOOL SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs ) TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI), TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT) }; - for (sal_uInt32 j=0; j < sizeof(eTypes2)/sizeof(TBorderPair); ++j) + for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j) aBoxInfoItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second ); aBoxInfoItem.EnableHor( mbHorEnabled ); diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 49d7221..6b8f9f5 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -40,6 +40,7 @@ #include <vcl/msgbox.hxx> #include <unotools/configitem.hxx> #include "svx/htmlmode.hxx" +#include <sal/macros.h> #define _SVX_PAGE_CXX @@ -155,9 +156,7 @@ USHORT aArr[] = USHORT PageUsageToPos_Impl( USHORT nUsage ) { - const USHORT nCount = sizeof(aArr) / sizeof(USHORT); - - for ( USHORT i = 0; i < nCount; ++i ) + for ( USHORT i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) if ( aArr[i] == ( nUsage & 0x000f ) ) return i; return SVX_PAGE_ALL; @@ -167,9 +166,7 @@ USHORT PageUsageToPos_Impl( USHORT nUsage ) USHORT PosToPageUsage_Impl( USHORT nPos ) { - const USHORT nCount = sizeof(aArr) / sizeof(USHORT); - - if ( nPos >= nCount ) + if ( nPos >= SAL_N_ELEMENTS(aArr) ) return 0; return aArr[nPos]; } diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 20f93fb..e4841ab 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -43,6 +43,7 @@ #include <svx/svdview.hxx> #include <svx/svdpagv.hxx> #include <svx/rectenum.hxx> +#include <sal/macros.h> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> @@ -368,55 +369,53 @@ static FrmMap __FAR_DATA aVAsCharHtmlMap[] = std::size_t lcl_GetFrmMapCount(const FrmMap* pMap) { - if ( pMap ) + if( pMap ) { - std::size_t aSizeOf = sizeof(FrmMap); - if( pMap == aVParaHtmlMap) - return sizeof(aVParaHtmlMap) / aSizeOf; - if( pMap == aVAsCharHtmlMap) - return sizeof(aVAsCharHtmlMap) / aSizeOf; - if( pMap == aHParaHtmlMap) - return sizeof(aHParaHtmlMap) / aSizeOf; - if( pMap == aHParaHtmlAbsMap) - return sizeof(aHParaHtmlAbsMap) / aSizeOf; - if ( pMap == aVPageMap ) - return sizeof(aVPageMap) / aSizeOf; - if ( pMap == aVPageHtmlMap ) - return sizeof(aVPageHtmlMap) / aSizeOf; - if ( pMap == aVAsCharMap ) - return sizeof(aVAsCharMap) / aSizeOf; - if ( pMap == aVParaMap ) - return sizeof(aVParaMap) / aSizeOf; - if ( pMap == aHParaMap ) - return sizeof(aHParaMap) / aSizeOf; - if ( pMap == aHFrameMap ) - return sizeof(aHFrameMap) / aSizeOf; - // OD 19.09.2003 #i18732# - own vertical alignment map for to frame anchored objects - if ( pMap == aVFrameMap ) - return sizeof(aVFrameMap) / aSizeOf; - if ( pMap == aHCharMap ) - return sizeof(aHCharMap) / aSizeOf; - if ( pMap == aHCharHtmlMap ) - return sizeof(aHCharHtmlMap) / aSizeOf; - if ( pMap == aHCharHtmlAbsMap ) - return sizeof(aHCharHtmlAbsMap) / aSizeOf; - if ( pMap == aVCharMap ) - return sizeof(aVCharMap) / aSizeOf; - if ( pMap == aVCharHtmlMap ) - return sizeof(aVCharHtmlMap) / aSizeOf; - if ( pMap == aVCharHtmlAbsMap ) - return sizeof(aVCharHtmlAbsMap) / aSizeOf; - if ( pMap == aHPageHtmlMap ) - return sizeof(aHPageHtmlMap) / aSizeOf; - if ( pMap == aHFlyHtmlMap ) - return sizeof(aHFlyHtmlMap) / aSizeOf; - if ( pMap == aVFlyHtmlMap ) - return sizeof(aVFlyHtmlMap) / aSizeOf; - if( pMap == aVMultiSelectionMap) - return sizeof(aVMultiSelectionMap) / aSizeOf; - if( pMap == aHMultiSelectionMap) - return sizeof(aHMultiSelectionMap) / aSizeOf; - return sizeof(aHPageMap) / aSizeOf; + if( pMap == aVParaHtmlMap ) + return SAL_N_ELEMENTS(aVParaHtmlMap); + if( pMap == aVAsCharHtmlMap ) + return SAL_N_ELEMENTS( aVAsCharHtmlMap ); + if( pMap == aHParaHtmlMap ) + return SAL_N_ELEMENTS( aHParaHtmlMap ); + if( pMap == aHParaHtmlAbsMap ) + return SAL_N_ELEMENTS( aHParaHtmlAbsMap ); + if( pMap == aVPageMap ) + return SAL_N_ELEMENTS( aVPageMap ); + if( pMap == aVPageHtmlMap ) + return SAL_N_ELEMENTS( aVPageHtmlMap ); + if( pMap == aVAsCharMap ) + return SAL_N_ELEMENTS( aVAsCharMap ); + if( pMap == aVParaMap ) + return SAL_N_ELEMENTS( aVParaMap ); + if( pMap == aHParaMap ) + return SAL_N_ELEMENTS( aHParaMap ); + if( pMap == aHFrameMap ) + return SAL_N_ELEMENTS( aHFrameMap ); + if( pMap == aVFrameMap ) + return SAL_N_ELEMENTS( aVFrameMap ); + if( pMap == aHCharMap ) + return SAL_N_ELEMENTS( aHCharMap ); + if( pMap == aHCharHtmlMap ) + return SAL_N_ELEMENTS( aHCharHtmlMap ); + if( pMap == aHCharHtmlAbsMap ) + return SAL_N_ELEMENTS( aHCharHtmlAbsMap ); + if( pMap == aVCharMap ) + return SAL_N_ELEMENTS( aVCharMap ); + if( pMap == aVCharHtmlMap ) + return SAL_N_ELEMENTS( aVCharHtmlMap ); + if( pMap == aVCharHtmlAbsMap ) + return SAL_N_ELEMENTS( aVCharHtmlAbsMap ); + if( pMap == aHPageHtmlMap ) + return SAL_N_ELEMENTS( aHPageHtmlMap ); + if( pMap == aHFlyHtmlMap ) + return SAL_N_ELEMENTS( aHFlyHtmlMap ); + if( pMap == aVFlyHtmlMap ) + return SAL_N_ELEMENTS( aVFlyHtmlMap ); + if( pMap == aVMultiSelectionMap ) + return SAL_N_ELEMENTS( aVMultiSelectionMap ); + if( pMap == aHMultiSelectionMap ) + return SAL_N_ELEMENTS( aHMultiSelectionMap ); + return SAL_N_ELEMENTS(aHPageMap); } return 0; } @@ -458,7 +457,7 @@ SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( {SwFPos::REL_FRM_BOTTOM, SwFPos::REL_FRM_RIGHT } }; USHORT nIndex; - for(nIndex = 0; nIndex < sizeof(aHoriIds) / sizeof(StringIdPair_Impl); ++nIndex) + for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex) { if(aHoriIds[nIndex].eHori == eStringId) { @@ -467,7 +466,7 @@ SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( } } nIndex = 0; - for(nIndex = 0; nIndex < sizeof(aVertIds) / sizeof(StringIdPair_Impl); ++nIndex) + for(nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex) { if(aVertIds[nIndex].eHori == eStringId) { @@ -484,8 +483,7 @@ ULONG lcl_GetLBRelationsForRelations( const USHORT _nRel ) { ULONG nLBRelations = 0L; - sal_uInt16 nRelMapSize = sizeof(aRelationMap) / sizeof(RelationMap); - for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < nRelMapSize; ++nRelMapPos ) + for ( sal_uInt16 nRelMapPos = 0; nRelMapPos < SAL_N_ELEMENTS(aRelationMap); ++nRelMapPos ) { if ( aRelationMap[nRelMapPos].nRelation == _nRel ) { @@ -1628,7 +1626,7 @@ ULONG SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, USHORT nMapPos, USHORT nAlign if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap) { String sOldEntry(rLB.GetSelectEntry()); - USHORT nRelCount = sizeof(aAsCharRelationMap) / sizeof(RelationMap); + USHORT nRelCount = SAL_N_ELEMENTS(aAsCharRelationMap); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++) @@ -1675,7 +1673,7 @@ ULONG SvxSwPosSizeTabPage::FillRelLB(FrmMap *pMap, USHORT nMapPos, USHORT nAlign } else { - USHORT nRelCount = sizeof(aRelationMap) / sizeof(RelationMap); + USHORT nRelCount = SAL_N_ELEMENTS(aRelationMap); // OD 14.11.2003 #i22341# - special handling for map <aVCharMap>, // because its ambigous in its <eStrId>/<eMirrorStrId>. diff --git a/extensions/source/nsplugin/source/npshell.cxx b/extensions/source/nsplugin/source/npshell.cxx index d19b7b6..8e7bc55 100644 --- a/extensions/source/nsplugin/source/npshell.cxx +++ b/extensions/source/nsplugin/source/npshell.cxx @@ -72,6 +72,7 @@ #include <string.h> #include <errno.h> +#include <sal/macros.h> #include "boost/scoped_array.hpp" #include "tools/pathutils.hxx" diff --git a/extensions/source/nsplugin/source/so_main.cxx b/extensions/source/nsplugin/source/so_main.cxx index eaead5f..3211c00 100644 --- a/extensions/source/nsplugin/source/so_main.cxx +++ b/extensions/source/nsplugin/source/so_main.cxx @@ -66,6 +66,7 @@ #include "nsp_func.hxx" #include "sal/main.h" +#include <sal/macros.h> #include "rtl/process.h" #include "rtl/bootstrap.hxx" @@ -85,7 +86,6 @@ #include "com/sun/star/bridge/XUnoUrlResolver.hpp" #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) -#define ARLEN(x) sizeof (x) / sizeof *(x) using namespace ::rtl; using namespace ::osl; @@ -389,7 +389,7 @@ Reference< lang::XMultiServiceFactory > SAL_CALL start_office(NSP_PIPE_FD read_f oslProcessError rc = osl_executeProcess( aOfficePath.pData, ar_args, - ARLEN( ar_args ), + SAL_N_ELEMENTS( ar_args ), osl_Process_DETACHED, sec.getHandle(), 0, // => current working dir diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx index ae14c90..9f6e4b2 100644 --- a/extensions/source/propctrlr/formmetadata.cxx +++ b/extensions/source/propctrlr/formmetadata.cxx @@ -36,7 +36,7 @@ #include <svtools/localresaccess.hxx> #include <tools/debug.hxx> #include <cppuhelper/extract.hxx> - +#include <sal/macros.h> #include <algorithm> #include <functional> @@ -360,7 +360,7 @@ namespace pcr }; s_pPropertyInfos = aPropertyInfos; - s_nCount = sizeof(aPropertyInfos) / sizeof(OPropertyInfoImpl); + s_nCount = SAL_N_ELEMENTS(aPropertyInfos); // sort ::std::sort( s_pPropertyInfos, s_pPropertyInfos + s_nCount, PropertyInfoLessByName() ); diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index 310d585..ef93d21 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -49,6 +49,7 @@ #include <osl/process.h> #include <osl/module.hxx> #include <osl/file.hxx> +#include <sal/macros.h> #ifdef WNT #ifdef _MSC_VER @@ -577,7 +578,7 @@ UpdateCheckThread::run() // Increase next by 15, 60, .. minutes static const sal_Int32 nRetryInterval[] = { 900, 3600, 14400, 86400 }; - if( n < sizeof(nRetryInterval) / sizeof(sal_Int32) ) + if( n < SAL_N_ELEMENTS(nRetryInterval) ) ++n; tv.Seconds = nRetryInterval[n-1]; @@ -689,7 +690,7 @@ DownloadThread::run() // Increase next by 1, 5, 15, 60, .. minutes static const sal_Int16 nRetryInterval[] = { 60, 300, 900, 3600 }; - if( n < sizeof(nRetryInterval) / sizeof(sal_Int16) ) + if( n < SAL_N_ELEMENTS(nRetryInterval) ) ++n; tv.Seconds = nRetryInterval[n-1]; diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index 6f875a7..c8b9749 100644 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -39,6 +39,7 @@ #include <osl/security.hxx> #include <osl/time.h> #include <osl/file.hxx> +#include <sal/macros.h> #ifdef WNT #ifdef _MSC_VER @@ -91,7 +92,7 @@ static const sal_Char * const aUpdateEntryProperties[] = { OLD_VERSION }; -static const sal_uInt32 nUpdateEntryProperties = sizeof(aUpdateEntryProperties) / sizeof(sal_Char *); +static const sal_uInt32 nUpdateEntryProperties = SAL_N_ELEMENTS(aUpdateEntryProperties); //------------------------------------------------------------------------------ diff --git a/setup_native/source/ulfconv/ulfconv.cxx b/setup_native/source/ulfconv/ulfconv.cxx index 201685c..11f1316 100644 --- a/setup_native/source/ulfconv/ulfconv.cxx +++ b/setup_native/source/ulfconv/ulfconv.cxx @@ -34,6 +34,7 @@ #include <unistd.h> #include <ctype.h> #include <sal/alloca.h> +#include <sal/macros.h> #include <rtl/ustring.hxx> @@ -189,7 +190,7 @@ void read_encoding_table(char * file, EncodingMap& aEncodingMap) *cp = '\0'; // find the correct mapping for codepage - const unsigned int members = sizeof( _ms_encoding_list ) / sizeof( _pair ); + const unsigned int members = SAL_N_ELEMENTS( _ms_encoding_list ); const _pair *encoding = _pair_search( codepage, _ms_encoding_list, members ); if ( encoding != NULL ) { diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index dd47d27..be0e1ec 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -38,6 +38,7 @@ #pragma warning(pop) #endif #include <sal/config.h> +#include <sal/macros.h> #include <osl/thread.h> #include "securityenvironment_mscryptimpl.hxx" @@ -114,11 +115,10 @@ CertErrorToString arErrStrings[] = void traceTrustStatus(DWORD err) { - int numErrors = sizeof(arErrStrings) / sizeof(CertErrorToString); xmlsec_trace("The certificate error status is: "); if (err == 0) xmlsec_trace("%s", arErrStrings[0].name); - for (int i = 1; i < numErrors; i++) + for (int i = 1; i < SAL_N_ELEMENTS(arErrStrings); i++) { if (arErrStrings[i].error & err) xmlsec_trace("%s", arErrStrings[i].name); diff --git a/xmlsecurity/source/xmlsec/nss/secerror.cxx b/xmlsecurity/source/xmlsec/nss/secerror.cxx index 8c44540..274841e 100644 --- a/xmlsecurity/source/xmlsec/nss/secerror.cxx +++ b/xmlsecurity/source/xmlsec/nss/secerror.cxx @@ -34,6 +34,7 @@ #include "sslerr.h" #include "nspr.h" #include "certt.h" +#include <sal/macros.h> #include "../diagnose.hxx" @@ -61,7 +62,7 @@ const char * getCertError(PRErrorCode errNum) { static char sEmpty[] = ""; - const int numDesc = sizeof(allDesc) / sizeof(ErrDesc); + const int numDesc = SAL_N_ELEMENTS(allDesc); for (int i = 0; i < numDesc; i++) { if (allDesc[i].errNum == errNum) diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx index 0dada06..466c532 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -37,6 +37,7 @@ #include "ocsp.h" #include <sal/config.h> +#include <sal/macros.h> #include "securityenvironment_nssimpl.hxx" #include "x509certificate_nssimpl.hxx" #include <rtl/uuid.h> @@ -882,7 +883,7 @@ verifyCertificate( const Reference< csss::XCertificate >& aCert, {certificateUsageEmailRecipient, "certificateUsageEmailRecipient"} }; - int numUsages = sizeof(arUsages) / sizeof(UsageDescription); + int numUsages = SAL_N_ELEMENTS(arUsages); for (int i = 0; i < numUsages; i++) { xmlsec_trace("Testing usage %d of %d: %s (0x%x)", i + 1, -- 1.7.1
>From d7233454f171a9612ad033510672dbff89901c5d Mon Sep 17 00:00:00 2001 From: Kenneth Venken <kenneth.ven...@gmail.com> Date: Fri, 3 Dec 2010 01:41:22 +0100 Subject: [PATCH] more Sal n elements --- sdext/source/minimizer/configurationaccess.cxx | 3 ++- sdext/source/minimizer/informationdialog.cxx | 11 ++++++----- sdext/source/minimizer/optimizerdialog.cxx | 5 +++-- sdext/source/minimizer/optimizerdialogcontrols.cxx | 19 ++++++++++--------- sdext/source/minimizer/pppoptimizertoken.cxx | 3 ++- sdext/source/pdfimport/filterdet.cxx | 1 + 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx index 83187bc..0965c50 100644 --- a/sdext/source/minimizer/configurationaccess.cxx +++ b/sdext/source/minimizer/configurationaccess.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <sal/macros.h> using namespace ::rtl; using namespace ::com::sun::star; @@ -133,7 +134,7 @@ void OptimizerSettings::SaveSettingsToConfiguration( const Reference< XNameRepla // Any( maFilterName ), Any( mbOpenNewDocument ) }; - sal_Int32 i, nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 i, nCount = SAL_N_ELEMENTS( pNames ); for ( i = 0; i < nCount; i++ ) { diff --git a/sdext/source/minimizer/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx index de6bd58..124695f 100644 --- a/sdext/source/minimizer/informationdialog.cxx +++ b/sdext/source/minimizer/informationdialog.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <rtl/ustrbuf.hxx> +#include <sal/macros.h> #include "com/sun/star/util/URL.hpp" #include "com/sun/star/util/XURLTransformer.hpp" @@ -88,7 +89,7 @@ rtl::OUString InsertFixedText( InformationDialog& rInformationDialog, const rtl: Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -117,7 +118,7 @@ rtl::OUString InsertImage( InformationDialog& rInformationDialog, const OUString Any( nPosY ), Any( sal_True ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -150,7 +151,7 @@ rtl::OUString InsertCheckBox( InformationDialog& rInformationDialog, const OUStr Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -187,7 +188,7 @@ rtl::OUString InsertButton( InformationDialog& rInformationDialog, const OUStrin Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -269,7 +270,7 @@ void InformationDialog::InitDialog() Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ), Any( sal_Int32( DIALOG_WIDTH ) ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index 32bac31..f50e5ee 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/util/XCloseBroadcaster.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> +#include <sal/macros.h> #include <osl/time.h> // ------------------- @@ -80,7 +81,7 @@ void OptimizerDialog::InitDialog() Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ), Any( sal_Int32( OD_DIALOG_WIDTH ) ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -110,7 +111,7 @@ void OptimizerDialog::InitRoadmap() Any( mnTabIndex++ ), Any( sal_Int32( 85 ) ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index a72ec14..d35054f 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/awt/FontWeight.hpp> #include <rtl/ustrbuf.hxx> +#include <sal/macros.h> using namespace ::rtl; using namespace ::com::sun::star::awt; @@ -89,7 +90,7 @@ rtl::OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString Any( sal_Int16( 0 ) ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -127,7 +128,7 @@ rtl::OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& r Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -161,7 +162,7 @@ rtl::OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const rtl::OUS Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -198,7 +199,7 @@ rtl::OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -241,7 +242,7 @@ rtl::OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUS Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -287,7 +288,7 @@ rtl::OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -323,7 +324,7 @@ rtl::OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const rtl::O Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -366,7 +367,7 @@ rtl::OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& Any( nTabIndex ), Any( nWidth ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); @@ -867,7 +868,7 @@ void OptimizerDialog::InitPage4() Any( (sal_Int32)( 0 ) ), Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) }; - sal_Int32 nCount = sizeof( pNames ) / sizeof( OUString ); + sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); Sequence< rtl::OUString > aNames( pNames, nCount ); Sequence< Any > aValues( pValues, nCount ); diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index e213a06..74f6a40 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -31,6 +31,7 @@ #include "pppoptimizertoken.hxx" #include <osl/mutex.hxx> +#include <sal/macros.h> #include <hash_map> #include <string.h> @@ -311,7 +312,7 @@ PPPOptimizerTokenEnum TKGet( const rtl::OUString& rToken ) { TypeNameHashMap* pH = new TypeNameHashMap; const TokenTable* pPtr = pTokenTableArray; - const TokenTable* pEnd = pPtr + ( sizeof( pTokenTableArray ) / sizeof( TokenTable ) ); + const TokenTable* pEnd = pPtr + SAL_N_ELEMENTS( pTokenTableArray ); for ( ; pPtr < pEnd; pPtr++ ) (*pH)[ pPtr->pS ] = pPtr->pE; pHashMap = pH; diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index 265ccbc..079bd38 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -37,6 +37,7 @@ #include <osl/thread.h> #include <rtl/digest.h> #include <rtl/ref.hxx> +#include <sal/macros.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/XWindow.hpp> -- 1.7.1
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice