diff options
author | Thomas Arnhold <thomas@arnhold.org> | 2012-01-10 16:00:18 +0100 |
---|---|---|
committer | Thomas Arnhold <thomas@arnhold.org> | 2012-01-10 16:52:33 +0100 |
commit | 2c3d0ff9f83aab89980529da2aa3837390b84ef7 (patch) | |
tree | a7ff1a3e2271c219b29c4ab3a4e54411c22ed20c | |
parent | a2dd79d14ee2e76e3b6c13f2880706292ea90c26 (diff) |
Use SAL_N_ELEMENTS
Some more like Thorstens diff 9c59cd15b150638c845bbc275b9b04460afc23bd
Done with some regex magic (and a check if this var is an array):
s/sizeof\(\s*$var\s*\)\s*\/\s*sizeof\(\s*\*$var\s*/SAL_N_ELEMENTS\($var/gs
-rw-r--r-- | oox/source/token/propertynames.cxx | 2 | ||||
-rw-r--r-- | sdext/source/pdfimport/filterdet.cxx | 4 | ||||
-rw-r--r-- | slideshow/test/demoshow.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/linkwarn.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1class.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1sprm.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 4 | ||||
-rw-r--r-- | unotools/source/misc/fontdefs.cxx | 2 | ||||
-rw-r--r-- | unoxml/test/domtest.cxx | 10 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 2 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salgdi.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 2 | ||||
-rw-r--r-- | vcl/test/canvasbitmaptest.cxx | 2 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 4 |
16 files changed, 23 insertions, 23 deletions
diff --git a/oox/source/token/propertynames.cxx b/oox/source/token/propertynames.cxx index a7c9b87e4982..d65c8d23d801 100644 --- a/oox/source/token/propertynames.cxx +++ b/oox/source/token/propertynames.cxx @@ -41,7 +41,7 @@ PropertyNameVector::PropertyNameVector() "" }; - size_t nArraySize = (sizeof( sppcPropertyNames ) / sizeof( *sppcPropertyNames )) - 1; + size_t nArraySize = SAL_N_ELEMENTS(sppcPropertyNames) - 1; reserve( nArraySize ); for( size_t nIndex = 0; nIndex < nArraySize; ++nIndex ) push_back( ::rtl::OUString::createFromAscii( sppcPropertyNames[ nIndex ] ) ); diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx index 28fd12621ab3..969f378e03a0 100644 --- a/sdext/source/pdfimport/filterdet.cxx +++ b/sdext/source/pdfimport/filterdet.cxx @@ -139,8 +139,8 @@ namespace { xPropSet->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ))) >>= aLabel; const char pFileName[] = "%FILENAME"; aLabel = aLabel.replaceAt( - aLabel.indexOfAsciiL(pFileName,sizeof(pFileName)/sizeof(*pFileName)-1), - sizeof(pFileName)/sizeof(*pFileName)-1, + aLabel.indexOfAsciiL(pFileName,SAL_N_ELEMENTS(pFileName)-1), + SAL_N_ELEMENTS(pFileName)-1, aFilename ); xPropSet->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), uno::makeAny(aLabel)); diff --git a/slideshow/test/demoshow.cxx b/slideshow/test/demoshow.cxx index f52ba553b260..692251edbeb0 100644 --- a/slideshow/test/demoshow.cxx +++ b/slideshow/test/demoshow.cxx @@ -278,7 +278,7 @@ private: }; static PropMapT aMap( lcl_propertyMap, - sizeof(lcl_propertyMap)/sizeof(*lcl_propertyMap), + SAL_N_ELEMENTS(lcl_propertyMap), true ); sal_Int16 aRes; diff --git a/svx/source/dialog/linkwarn.cxx b/svx/source/dialog/linkwarn.cxx index 5beecf0c3172..6bc3a1b21fbd 100644 --- a/svx/source/dialog/linkwarn.cxx +++ b/svx/source/dialog/linkwarn.cxx @@ -114,7 +114,7 @@ void SvxLinkWarningDialog::InitSize() &m_aLinkGraphicBtn, &m_aEmbedGraphicBtn, &m_aOptionLine, &m_aWarningOnBox }; Window** pCurrent = pWins; - for ( sal_uInt32 i = 0; i < sizeof(pWins) / sizeof(*pWins); ++i, ++pCurrent ) + for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS(pWins); ++i, ++pCurrent ) { Point aNewPos = (*pCurrent)->GetPosPixel(); aNewPos.Y() -= nDelta; diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 620b67736c51..e43b160cc81b 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1281,7 +1281,7 @@ void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize, // loop early-exits if we detect an already attained value sal_uInt16 nMinStretchX=0, nMinStretchY=0; sal_uInt16 aOldStretchXVals[]={0,0,0,0,0,0,0,0,0,0}; - const size_t aStretchArySize=sizeof(aOldStretchXVals)/sizeof(*aOldStretchXVals); + const size_t aStretchArySize=SAL_N_ELEMENTS(aOldStretchXVals); for(unsigned int i=0; i<aStretchArySize; ++i) { const Size aCurrTextSize = rOutliner.CalcTextSizeNTP(); diff --git a/sw/source/filter/ww1/w1class.cxx b/sw/source/filter/ww1/w1class.cxx index a7e35cd65e41..c1630cab5a04 100644 --- a/sw/source/filter/ww1/w1class.cxx +++ b/sw/source/filter/ww1/w1class.cxx @@ -160,7 +160,7 @@ sal_uInt16 Ww1Style::ReadName( sal_uInt8*&p, sal_uInt16& rnCountBytes, sal_uInt1 size_t nSize(stc); if (!nSize) pStr = "W1 Normal"; - else if (nSize - 222 >= sizeof(names) / sizeof(*names)) + else if (nSize - 222 >= SAL_N_ELEMENTS(names)) pStr = "?"; else pStr = names[nSize-222]; diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx index 14d9f773313b..a2d451f91d5b 100644 --- a/sw/source/filter/ww1/w1sprm.cxx +++ b/sw/source/filter/ww1/w1sprm.cxx @@ -172,7 +172,7 @@ void Ww1SingleSprmPJc::Start( SVX_ADJUST_RIGHT, SVX_ADJUST_BLOCK }; sal_uInt8 nPara = SVBT8ToByte(pSprm); - nPara %=(sizeof(aAdj)/sizeof(*aAdj)); + nPara %=SAL_N_ELEMENTS(aAdj); rOut << SvxAdjustItem(aAdj[nPara], RES_PARATR_ADJUST); } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 845a381c40ea..4db2f0495834 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -4931,7 +4931,7 @@ long SwWW8ImplReader::ImportExtSprm(WW8PLCFManResult* pRes) if( pRes->nSprmId < 280 ) { sal_uInt8 nIdx = static_cast< sal_uInt8 >(pRes->nSprmId - eFTN); - if( nIdx < sizeof( aWwSprmTab ) / sizeof( *aWwSprmTab ) + if( nIdx < SAL_N_ELEMENTS(aWwSprmTab) && aWwSprmTab[nIdx] ) return (this->*aWwSprmTab[nIdx])(pRes); else @@ -4955,7 +4955,7 @@ void SwWW8ImplReader::EndExtSprm(sal_uInt16 nSprmId) }; sal_uInt8 nIdx = static_cast< sal_uInt8 >(nSprmId - eFTN); - if( nIdx < sizeof( aWwSprmTab ) / sizeof( *aWwSprmTab ) + if( nIdx < SAL_N_ELEMENTS(aWwSprmTab) && aWwSprmTab[nIdx] ) (this->*aWwSprmTab[nIdx])(); } diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx index aad3670570a8..cca8040c5bf6 100644 --- a/unotools/source/misc/fontdefs.cxx +++ b/unotools/source/misc/fontdefs.cxx @@ -420,7 +420,7 @@ void GetEnglishSearchFontName( String& rName ) if( bNeedTranslation ) { typedef boost::unordered_map<const String, const char*,FontNameHash> FontNameDictionary; - static FontNameDictionary aDictionary( sizeof(aImplLocalizedNamesList) / sizeof(*aImplLocalizedNamesList) ); + static FontNameDictionary aDictionary( SAL_N_ELEMENTS(aImplLocalizedNamesList) ); // the font name dictionary needs to be intialized once if( aDictionary.empty() ) { diff --git a/unoxml/test/domtest.cxx b/unoxml/test/domtest.cxx index ff44e2b9dc3e..a9d95b58bbb6 100644 --- a/unoxml/test/domtest.cxx +++ b/unoxml/test/domtest.cxx @@ -220,13 +220,13 @@ struct BasicTest : public CppUnit::TestFixture mxErrHandler.set( new ErrorHandler() ); mxDomBuilder.set( new CDocumentBuilder(Reference< XMultiServiceFactory >() )); mxValidInStream.set( new SequenceInputStream(ByteSequence((sal_Int8*)validTestFile, - sizeof(validTestFile)/sizeof(*validTestFile))) ); + SAL_N_ELEMENTS(validTestFile))) ); mxWarningInStream.set( new SequenceInputStream(ByteSequence((sal_Int8*)warningTestFile, - sizeof(warningTestFile)/sizeof(*warningTestFile))) ); + SAL_N_ELEMENTS(warningTestFile))) ); mxErrorInStream.set( new SequenceInputStream(ByteSequence((sal_Int8*)errorTestFile, - sizeof(errorTestFile)/sizeof(*errorTestFile))) ); + SAL_N_ELEMENTS(errorTestFile))) ); mxFatalInStream.set( new SequenceInputStream(ByteSequence((sal_Int8*)fatalTestFile, - sizeof(fatalTestFile)/sizeof(*fatalTestFile))) ); + SAL_N_ELEMENTS(fatalTestFile))) ); mxDomBuilder->setErrorHandler(mxErrHandler.get()); } @@ -331,7 +331,7 @@ struct SerializerTest : public CppUnit::TestFixture mxCtx->getServiceManager(), uno::UNO_QUERY ))); mxInStream.set( new SequenceInputStream(ByteSequence((sal_Int8*)validTestFile, - sizeof(validTestFile)/sizeof(*validTestFile))) ); + SAL_N_ELEMENTS(validTestFile))) ); mxDomBuilder->setErrorHandler(mxErrHandler.get()); mxHandler.set( new DocumentHandler() ); diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 307ecfe3d6fd..34b10919e935 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -1966,7 +1966,7 @@ sal_uInt16 AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbac &aVerticalCharacterType }; - static const int nTagCount = sizeof(aTag) / sizeof(*aTag); + static const int nTagCount = SAL_N_ELEMENTS(aTag); OSStatus eStatus = ATSUSetAttributes( maATSUStyle, nTagCount, aTag, aValueSize, aValue ); // reset ATSUstyle if there was an error diff --git a/vcl/ios/source/gdi/salgdi.cxx b/vcl/ios/source/gdi/salgdi.cxx index 76a51eee94d6..f6ffbaa84b2f 100644 --- a/vcl/ios/source/gdi/salgdi.cxx +++ b/vcl/ios/source/gdi/salgdi.cxx @@ -1677,7 +1677,7 @@ sal_uInt16 IosSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallback &aVerticalCharacterType }; - static const int nTagCount = sizeof(aTag) / sizeof(*aTag); + static const int nTagCount = SAL_N_ELEMENTS(aTag); OSStatus eStatus = ATSUSetAttributes( maATSUStyle, nTagCount, aTag, aValueSize, aValue ); // reset ATSUstyle if there was an error diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index fb540ef4e51e..95118bfe2686 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -101,7 +101,7 @@ bool IsDiacritic( sal_UCS4 nChar ) }; // TODO: almost anything is faster than an O(n) search - static const int nCount = sizeof(aRanges) / sizeof(*aRanges); + static const int nCount = SAL_N_ELEMENTS(aRanges); const DiaRange* pRange = &aRanges[0]; for( int i = nCount; --i >= 0; ++pRange ) if( (pRange->mnMin <= nChar) && (nChar < pRange->mnEnd) ) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index dfd68ccafffd..54ac8b2ad68d 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -276,7 +276,7 @@ bool Window::ImplCheckUIFont( const Font& rFont ) BUTTON_RETRY, BUTTON_HELP }; - const int nTestButtonCount = sizeof(aTestButtons)/sizeof(*aTestButtons); + const int nTestButtonCount = SAL_N_ELEMENTS(aTestButtons); for( int n = 0; n < nTestButtonCount; ++n ) { String aButtonStr = Button::GetStandardText( aTestButtons[n] ); diff --git a/vcl/test/canvasbitmaptest.cxx b/vcl/test/canvasbitmaptest.cxx index 66e68c10a93e..9f753ff44923 100644 --- a/vcl/test/canvasbitmaptest.cxx +++ b/vcl/test/canvasbitmaptest.cxx @@ -877,7 +877,7 @@ void TestWindow::Paint( const Rectangle& ) // Testing VclCanvasBitmap wrapper // =============================== - for( unsigned int i=0; i<sizeof(lcl_depths)/sizeof(*lcl_depths); ++i ) + for( unsigned int i=0; i<SAL_N_ELEMENTS(lcl_depths); ++i ) { const sal_Int8 nDepth( lcl_depths[i] ); Bitmap aBitmap(Size(200,200),nDepth); diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 8d86069d72af..6b6b9176cef0 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -449,7 +449,7 @@ LanguageType MapCharToLanguage( sal_UCS4 uChar ) } // change the marked entries to prefered language - static const int nCount = (sizeof(aLangFromCodeChart) / sizeof(*aLangFromCodeChart)); + static const int nCount = SAL_N_ELEMENTS(aLangFromCodeChart); for( int i = 0; i < nCount; ++i ) { if( aLangFromCodeChart[ i].mnLangID == LANGUAGE_DEFAULT_CJK ) @@ -459,7 +459,7 @@ LanguageType MapCharToLanguage( sal_UCS4 uChar ) // binary search int nLow = 0; - int nHigh = (sizeof(aLangFromCodeChart) / sizeof(*aLangFromCodeChart)) - 1; + int nHigh = SAL_N_ELEMENTS(aLangFromCodeChart) - 1; while( nLow <= nHigh ) { int nMiddle = (nHigh + nLow) / 2; |