[Libreoffice-commits] .: oox/source sdext/source slideshow/test svx/source sw/source unotools/source unoxml/test vcl/aqua vcl/ios vcl/source vcl/test vcl/win

Thomas Arnhold tarnhold at kemper.freedesktop.org
Tue Jan 10 07:52:55 PST 2012


 oox/source/token/propertynames.cxx   |    2 +-
 sdext/source/pdfimport/filterdet.cxx |    4 ++--
 slideshow/test/demoshow.cxx          |    2 +-
 svx/source/dialog/linkwarn.cxx       |    2 +-
 svx/source/svdraw/svdotext.cxx       |    2 +-
 sw/source/filter/ww1/w1class.cxx     |    2 +-
 sw/source/filter/ww1/w1sprm.cxx      |    2 +-
 sw/source/filter/ww8/ww8par6.cxx     |    4 ++--
 unotools/source/misc/fontdefs.cxx    |    2 +-
 unoxml/test/domtest.cxx              |   10 +++++-----
 vcl/aqua/source/gdi/salgdi.cxx       |    2 +-
 vcl/ios/source/gdi/salgdi.cxx        |    2 +-
 vcl/source/gdi/sallayout.cxx         |    2 +-
 vcl/source/window/window.cxx         |    2 +-
 vcl/test/canvasbitmaptest.cxx        |    2 +-
 vcl/win/source/gdi/salgdi3.cxx       |    4 ++--
 16 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit 2c3d0ff9f83aab89980529da2aa3837390b84ef7
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Tue Jan 10 16:00:18 2012 +0100

    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

diff --git a/oox/source/token/propertynames.cxx b/oox/source/token/propertynames.cxx
index a7c9b87..d65c8d2 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 28fd126..969f378 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 f52ba55..692251e 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 5beecf0..6bc3a1b 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 620b677..e43b160 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 a7e35cd..c1630ca 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 14d9f77..a2d451f 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 845a381..4db2f04 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 aad3670..cca8040 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 ff44e2b..a9d95b5 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 307ecfe..34b1091 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 76a51ee..f6ffbaa 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 fb540ef..95118bf 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 dfd68cc..54ac8b2 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 66e68c1..9f753ff 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 8d86069..6b6b917 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;


More information about the Libreoffice-commits mailing list