[Libreoffice-commits] .: canvas/workben i18npool/source l10ntools/source padmin/source rsc/source svl/qa svl/source svtools/source svtools/workben toolkit/source tools/source tools/workben unotools/source vcl/aqua vcl/source vcl/unx

David Tardon dtardon at kemper.freedesktop.org
Mon Oct 18 03:29:02 PDT 2010


 canvas/workben/canvasdemo.cxx                         |    3 
 i18npool/source/localedata/LocaleNode.cxx             |    3 
 i18npool/source/localedata/localedata.cxx             |    3 
 i18npool/source/nativenumber/nativenumbersupplier.cxx |    7 -
 i18npool/source/paper/paper.cxx                       |    5 
 l10ntools/source/export2.cxx                          |    3 
 padmin/source/padialog.cxx                            |    3 
 rsc/source/parser/rscdb.cxx                           |    3 
 svl/qa/test_URIHelper.cxx                             |    5 
 svl/source/items/srchitem.cxx                         |    3 
 svtools/source/config/apearcfg.cxx                    |    3 
 svtools/source/config/htmlcfg.cxx                     |    3 
 svtools/source/config/printoptions.cxx                |    4 
 svtools/source/control/ctrlbox.cxx                    |    5 
 svtools/source/control/ctrltool.cxx                   |    5 
 svtools/source/dialogs/insdlg.cxx                     |    3 
 svtools/source/dialogs/printdlg.cxx                   |    3 
 svtools/workben/toolpanel/toolpaneltest.cxx           |    9 -
 toolkit/source/helper/vclunohelper.cxx                |    3 
 tools/source/debug/debug.cxx                          |    3 
 tools/workben/urltest.cxx                             |   15 +-
 unotools/source/config/fontcfg.cxx                    |    5 
 unotools/source/config/lingucfg.cxx                   |    3 
 unotools/source/config/searchopt.cxx                  |    3 
 unotools/source/i18n/localedatawrapper.cxx            |    3 
 unotools/source/misc/fontcvt.cxx                      |    9 -
 vcl/aqua/source/gdi/salprn.cxx                        |    5 
 vcl/aqua/source/window/salframeview.mm                |    5 
 vcl/source/control/edit.cxx                           |    7 -
 vcl/source/gdi/font.cxx                               |    3 
 vcl/source/gdi/pdfwriter_impl.cxx                     |    4 
 vcl/source/gdi/pdfwriter_impl.hxx                     |    3 
 vcl/source/window/window.cxx                          |    5 
 vcl/unx/gtk/a11y/atkwrapper.cxx                       |    4 
 vcl/unx/gtk/window/gtkframe.cxx                       |    9 -
 vcl/unx/source/app/keysymnames.cxx                    |  107 +++++++++---------
 vcl/unx/source/app/salinst.cxx                        |    3 
 vcl/unx/source/app/wmadaptor.cxx                      |    7 -
 vcl/unx/source/dtrans/X11_selection.cxx               |   11 -
 vcl/unx/source/dtrans/bmp.cxx                         |    3 
 vcl/unx/source/fontmanager/fontmanager.cxx            |   10 +
 vcl/unx/source/gdi/xlfd_attr.cxx                      |   12 +-
 vcl/unx/source/printer/ppdparser.cxx                  |    3 
 vcl/unx/source/printer/printerinfomanager.cxx         |    3 
 vcl/unx/source/printergfx/printerjob.cxx              |    3 
 vcl/unx/source/window/salframe.cxx                    |    3 
 46 files changed, 183 insertions(+), 144 deletions(-)

New commits:
commit bc49ab7509812b643a0b4792cfefc57e91632dc7
Author: Kenneth Venken <kenneth.venken at gmail.com>
Date:   Mon Oct 18 12:28:33 2010 +0200

    replace sizeof(foo)/sizeof(foo[0]) by SAL_N_ELEMENTS

diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx
index 11dd1ab..510cd43 100644
--- a/canvas/workben/canvasdemo.cxx
+++ b/canvas/workben/canvasdemo.cxx
@@ -54,6 +54,7 @@
 #include <vcl/canvastools.hxx>
 
 #include <rtl/bootstrap.hxx>
+#include <sal/macros.h>
 
 #include <com/sun/star/rendering/XCanvas.hpp>
 #include <com/sun/star/rendering/FillRule.hpp>
@@ -251,7 +252,7 @@ class DemoRenderer
         {
             const double SCALE=7.0;
             const char hilbert[] = "urdrrulurulldluuruluurdrurddldrrruluurdrurddldrddlulldrdldrrurd";
-            int nLength = sizeof( hilbert ) / sizeof (hilbert [0]);
+            int nLength = SAL_N_ELEMENTS( hilbert );
 
             uno::Sequence< geometry::RealPoint2D > aPoints( nLength );
             uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 74d3226..95d06b9 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -35,6 +35,7 @@
 #include <set>
 
 #include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
 
 #include "LocaleNode.hxx"
 #include <com/sun/star/i18n/NumberFormatIndex.hpp>
@@ -1487,7 +1488,7 @@ void LCMiscNode::generateCode (const OFileWriter &of) const
     ::rtl::OUString str;
     sal_Int16 i;
 
-    for ( i = 0; i < sal_Int16(sizeof(ReserveWord)/sizeof(ReserveWord[0])); i++,nbOfWords++) {
+    for ( i = 0; i < sal_Int16(SAL_N_ELEMENTS(ReserveWord)); i++,nbOfWords++) {
         const LocaleNode * curNode = (reserveNode ? reserveNode->findNode(
                     ReserveWord[i].name) : 0);
         if (!curNode)
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 0a7e6ca..8ab412f 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <stdio.h>
 #include "rtl/instance.hxx"
+#include <sal/macros.h>
 
 using namespace com::sun::star::i18n;
 using namespace com::sun::star::uno;
@@ -256,7 +257,7 @@ static const struct {
 
 static const sal_Unicode under = sal_Unicode('_');
 
-static const sal_Int16 nbOfLocales = sizeof(aLibTable) / sizeof(aLibTable[0]);
+static const sal_Int16 nbOfLocales = SAL_N_ELEMENTS(aLibTable);
 
 struct LocaleDataLookupTableItem
 {
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 65584e6..a338229 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -30,6 +30,7 @@
 #include "precompiled_i18npool.hxx"
 
 #include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
 #include <nativenumbersupplier.hxx>
 #include <localedata.hxx>
 #include <data/numberchar.h>
@@ -466,7 +467,7 @@ static const sal_Char *natnum1Locales[] = {
     "dz",
     "fa"
 };
-static sal_Int16 nbOfLocale = sizeof(natnum1Locales)/sizeof(natnum1Locales[0]);
+static sal_Int16 nbOfLocale = SAL_N_ELEMENTS(natnum1Locales);
 
 //! ATTENTION: Do not change order of elements!
 //! Number and order must match elements of natnum1Locales!
@@ -497,7 +498,7 @@ static sal_Int16 natnum1[] = {
     NumberChar_dz,
     NumberChar_EastIndic_ar
 };
-static sal_Int16 sizeof_natnum1 = sizeof(natnum1)/sizeof(natnum1[0]);
+static sal_Int16 sizeof_natnum1 = SAL_N_ELEMENTS(natnum1);
 
 //! ATTENTION: Do not change order of elements!
 //! Order must match first elements of natnum1Locales!
@@ -508,7 +509,7 @@ static sal_Int16 natnum2[] = {
     NumberChar_Upper_ko,
     NumberChar_he
 };
-static sal_Int16 sizeof_natnum2 = sizeof(natnum2)/sizeof(natnum2[0]);
+static sal_Int16 sizeof_natnum2 = SAL_N_ELEMENTS(natnum2);
 
 #define isLang(lang) rLocale.Language.equalsAsciiL(lang, 2)
 #define isCtry(ctry) rLocale.Country.equalsAsciiL(ctry, 2)
diff --git a/i18npool/source/paper/paper.cxx b/i18npool/source/paper/paper.cxx
index 1834c32..4d73472 100644
--- a/i18npool/source/paper/paper.cxx
+++ b/i18npool/source/paper/paper.cxx
@@ -29,6 +29,7 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_i18npool.hxx"
 #include <sal/config.h>
+#include <sal/macros.h>
 #include <rtl/ustring.hxx>
 #include <rtl/string.hxx>
 #include <comphelper/processfactory.hxx>
@@ -157,7 +158,7 @@ static PageDesc aDinTab[] =
     { IN2MM100( 36 ),    IN2MM100( 48 ),     "ARCHE",  NULL }
 };
 
-static const size_t nTabSize = sizeof(aDinTab) / sizeof(aDinTab[0]);
+static const size_t nTabSize = SAL_N_ELEMENTS(aDinTab);
 
 #define MAXSLOPPY 11
 
@@ -288,7 +289,7 @@ PaperInfo PaperInfo::getSystemDefaultPaper()
 
                 bool bHalve = false;
 
-                size_t nExtraTabSize = sizeof(aCustoms) / sizeof(aCustoms[0]);
+                size_t nExtraTabSize = SAL_N_ELEMENTS(aCustoms);
                 for (size_t i = 0; i < nExtraTabSize; ++i)
                 {
                     if (rtl_str_compareIgnoreAsciiCase(aCustoms[i].pName, aPaper.getStr()) == 0)
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index 0767c27..d35a357 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -36,6 +36,7 @@
 #include <osl/time.h>
 #include <osl/process.h>
 #include <rtl/ustring.hxx>
+#include <sal/macros.h>
 #include <iostream>
 #include <iomanip>
 #include <tools/urlobj.hxx>
@@ -666,7 +667,7 @@ void Export::getCurrentDir( string& dir )
 void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix )
 {
     static const char LETTERS[]        = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
-    static const int  COUNT_OF_LETTERS = sizeof(LETTERS)/sizeof(LETTERS[0]) - 1;
+    static const int  COUNT_OF_LETTERS = SAL_N_ELEMENTS(LETTERS) - 1;
     sRandStr.Append( sPrefix );
 
     static sal_uInt64 value;
diff --git a/padmin/source/padialog.cxx b/padmin/source/padialog.cxx
index 54680ac..36a0e94 100644
--- a/padmin/source/padialog.cxx
+++ b/padmin/source/padialog.cxx
@@ -54,6 +54,7 @@
 #include "osl/file.hxx"
 
 #include "rtl/ustrbuf.hxx"
+#include <sal/macros.h>
 
 #include "unotools/localedatawrapper.hxx"
 #include "unotools/configitem.hxx"
@@ -455,7 +456,7 @@ void SpaPrinterController::printPage( int ) const
             { NULL, RID_TXT_TESTPAGE_TIME }
         };
 
-    for( unsigned int i = 0; i < sizeof(aResIds)/sizeof(aResIds[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(aResIds); i++ )
     {
         if( aResIds[i].pDirect )
             aToken = String::CreateFromAscii( aResIds[i].pDirect );
diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx
index a21601f..263a409 100644
--- a/rsc/source/parser/rscdb.cxx
+++ b/rsc/source/parser/rscdb.cxx
@@ -39,6 +39,7 @@
 #include <tools/rc.h>
 #include <tools/isofallback.hxx>
 #include <rtl/strbuf.hxx>
+#include <sal/macros.h>
 
 // Programmabhaengige Includes.
 #include <rsctree.hxx>
@@ -836,7 +837,7 @@ void RscTypCont :: WriteSrc( FILE * fOutput, ULONG nFileKey,
     RscEnumerateRef aEnumRef( this, pRoot, fOutput );
 
     unsigned char aUTF8BOM[3] = { 0xef, 0xbb, 0xbf };
-    fwrite( aUTF8BOM, sizeof(unsigned char), sizeof(aUTF8BOM)/sizeof(aUTF8BOM[0]), fOutput );
+    fwrite( aUTF8BOM, sizeof(unsigned char), SAL_N_ELEMENTS(aUTF8BOM), fOutput );
     if( bName )
     {
         WriteInc( fOutput, nFileKey );
diff --git a/svl/qa/test_URIHelper.cxx b/svl/qa/test_URIHelper.cxx
index 6c2436c..5d548f9 100644
--- a/svl/qa/test_URIHelper.cxx
+++ b/svl/qa/test_URIHelper.cxx
@@ -64,6 +64,7 @@
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
+#include <sal/macros.h>
 #include "tools/solar.h"
 #include "unotools/charclass.hxx"
 
@@ -285,7 +286,7 @@ void Test::testNormalizedMakeRelative() {
           "nonex3/nonex4" }
 #endif
     };
-    for (std::size_t i = 0; i < sizeof tests / sizeof tests[0]; ++i) {
+    for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) {
         css::uno::Reference< css::uri::XUriReference > ref(
             URIHelper::normalizedMakeRelative(
                 m_context, rtl::OUString::createFromAscii(tests[i].base),
@@ -415,7 +416,7 @@ void Test::testFindFirstURLInText() {
         com::sun::star::lang::Locale(
             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")),
             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US")), rtl::OUString()));
-    for (std::size_t i = 0; i < sizeof tests / sizeof tests[0]; ++i) {
+    for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) {
         rtl::OUString input(rtl::OUString::createFromAscii(tests[i].input));
         xub_StrLen begin = 0;
         xub_StrLen end = static_cast< xub_StrLen >(input.getLength());
diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx
index 9727976..8455070 100644
--- a/svl/source/items/srchitem.cxx
+++ b/svl/source/items/srchitem.cxx
@@ -32,6 +32,7 @@
 // include ---------------------------------------------------------------
 
 #include <svl/srchitem.hxx>
+#include <sal/macros.h>
 
 #include <unotools/searchopt.hxx>
 #include <com/sun/star/util/XReplaceable.hpp>
@@ -98,7 +99,7 @@ static Sequence< ::rtl::OUString > lcl_GetNotifyNames()
         "Japanese/IsIgnoreMiddleDot"			// 18
     };
 
-    const int nCount = sizeof( aTranslitNames ) / sizeof( aTranslitNames[0] );
+    const int nCount = SAL_N_ELEMENTS( aTranslitNames );
     Sequence< ::rtl::OUString > aNames( nCount );
     ::rtl::OUString* pNames = aNames.getArray();
     for (INT32 i = 0;  i < nCount;  ++i)
diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx
index 1929088..8caa9cd 100644
--- a/svtools/source/config/apearcfg.cxx
+++ b/svtools/source/config/apearcfg.cxx
@@ -36,6 +36,7 @@
 #include "vcl/settings.hxx"
 #include "vcl/svapp.hxx"
 #include <rtl/logfile.hxx>
+#include <sal/macros.h>
 
 #define DEFAULT_LOOKNFEEL   0
 #define DEFAULT_DRAGMODE    2
@@ -129,7 +130,7 @@ const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames()
             ,"FontAntiAliasing/MinPixelHeight"  //  9
 #endif
         };
-        const int nCount = sizeof( aPropNames ) / sizeof( aPropNames[0] );
+        const int nCount = SAL_N_ELEMENTS( aPropNames );
         aNames.realloc(nCount);
 
         const sal_Char** pAsciiNames = aPropNames;
diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx
index 9eb3943..9952d3e 100644
--- a/svtools/source/config/htmlcfg.cxx
+++ b/svtools/source/config/htmlcfg.cxx
@@ -35,6 +35,7 @@
 #include <tools/debug.hxx>
 #include <tools/list.hxx>
 #include <tools/link.hxx>
+#include <sal/macros.h>
 
 // -----------------------------------------------------------------------
 #define HTMLCFG_UNKNOWN_TAGS 			0x01
@@ -111,7 +112,7 @@ const Sequence<OUString>& SvxHtmlOptions::GetPropertyNames()
             "Export/Encoding",  					// 14
             "Import/NumbersEnglishUS"               // 15
         };
-        const int nCount = sizeof(aPropNames) / sizeof(aPropNames[0]);
+        const int nCount = SAL_N_ELEMENTS(aPropNames);
         aNames.realloc(nCount);
         OUString* pNames = aNames.getArray();
         for(int i = 0; i < nCount; i++)
diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx
index 4aa1dc1..fc032ff 100644
--- a/svtools/source/config/printoptions.cxx
+++ b/svtools/source/config/printoptions.cxx
@@ -57,14 +57,14 @@
 
 #include <itemholder2.hxx>
 
-
+#include <sal/macros.h>
 // -----------
 // - statics -
 // -----------
 
 static USHORT aDPIArray[] = { 72, 96, 150, 200, 300, 600 };
 
-#define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ]))
+#define DPI_COUNT (SAL_N_ELEMENTS(aDPIArray))
 
 // -----------
 // - Defines -
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 5dbb8ee..37b01f3 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -33,6 +33,7 @@
 #include <tools/debug.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/field.hxx>
+#include <sal/macros.h>
 #include <comphelper/processfactory.hxx>
 #include <unotools/charclass.hxx>
 
@@ -873,8 +874,8 @@ void FontNameBox::ImplCalcUserItemSize()
         aSz.Width() /= 10;
         if ( bSymbolFont )
         {
-            int nLength = sizeof(aImplSymbolFontText)/sizeof(aImplSymbolFontText[0]) - 1;
-            int nLength2 = sizeof(aImplStarSymbolText)/sizeof(aImplStarSymbolText[0]) - 1;
+            int nLength = SAL_N_ELEMENTS(aImplSymbolFontText) - 1;
+            int nLength2 = SAL_N_ELEMENTS(aImplStarSymbolText) - 1;
             if( bStarSymbol && (nLength < nLength2) )
                 nLength = nLength2;
             aSz.Width() += aOneCharSz.Width() * nLength;
diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx
index 26e599d..8d5f33a 100644
--- a/svtools/source/control/ctrltool.cxx
+++ b/svtools/source/control/ctrltool.cxx
@@ -38,6 +38,7 @@
 #include <vcl/window.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/wrkwin.hxx>
+#include <sal/macros.h>
 
 #include <svtools/svtools.hrc>
 #include <svtools/svtdata.hxx>
@@ -930,7 +931,7 @@ FontSizeNames::FontSizeNames( LanguageType eLanguage )
         case LANGUAGE_CHINESE:
         case LANGUAGE_CHINESE_SIMPLIFIED:
             mpArray = aImplSimplifiedChinese;
-            mnElem = sizeof(aImplSimplifiedChinese) / sizeof(aImplSimplifiedChinese[0]);
+            mnElem = SAL_N_ELEMENTS(aImplSimplifiedChinese);
             break;
 
 #if 0 // #i89077# disabled by popular request
@@ -939,7 +940,7 @@ FontSizeNames::FontSizeNames( LanguageType eLanguage )
         case LANGUAGE_CHINESE_MACAU:
         case LANGUAGE_CHINESE_TRADITIONAL:
             mpArray = aImplTraditionalChinese;
-            mnElem = sizeof(aImplTraditionalChinese) / sizeof(aImplTraditionalChinese[0]);
+            mnElem = SAL_N_ELEMENTS(aImplTraditionalChinese);
             break;
 #endif
             
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
index d3b3cca..b6d01b1 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -41,6 +41,7 @@
 #include <unotools/configmgr.hxx>
 #include <sot/clsids.hxx>
 #include <sot/stg.hxx>
+#include <sal/macros.h>
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
@@ -315,7 +316,7 @@ String SvPasteObjectHelper::GetSotFormatUIName( SotFormatStringId nId )
     String aUIName;
     USHORT nResId = 0;
 
-    for( sal_uInt32 i = 0, nCount = sizeof( aSotResourcePairs ) / sizeof( aSotResourcePairs[ 0 ] ); ( i < nCount ) && !nResId; i++ )
+    for( sal_uInt32 i = 0, nCount = SAL_N_ELEMENTS( aSotResourcePairs ); ( i < nCount ) && !nResId; i++ )
     {
         if( aSotResourcePairs[ i ].mnSotId == nId )
             nResId = aSotResourcePairs[ i ].mnResId;
diff --git a/svtools/source/dialogs/printdlg.cxx b/svtools/source/dialogs/printdlg.cxx
index 67418c8..36c69f8 100644
--- a/svtools/source/dialogs/printdlg.cxx
+++ b/svtools/source/dialogs/printdlg.cxx
@@ -33,6 +33,7 @@
 #include <vcl/print.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/jobset.hxx>
+#include <sal/macros.h>
 #include <tools/urlobj.hxx>
 
 #include "printdlg.hrc"
@@ -338,7 +339,7 @@ void PrintDialog::ImplInitControls()
                                 &maFlSepButtonLine, &maBtnOptions, &maBtnOK,
                                 &maBtnCancel, &maBtnHelp };
         Window** pCtrl = pControls;
-        const sal_Int32 nCount = sizeof( pControls ) / sizeof( pControls[0] );
+        const sal_Int32 nCount = SAL_N_ELEMENTS( pControls );
         for ( sal_Int32 i = 0; i < nCount; ++i, ++pCtrl )
         {
             if ( NULL == *pCtrl )
diff --git a/svtools/workben/toolpanel/toolpaneltest.cxx b/svtools/workben/toolpanel/toolpaneltest.cxx
index 56aecdc..cde428a 100644
--- a/svtools/workben/toolpanel/toolpaneltest.cxx
+++ b/svtools/workben/toolpanel/toolpaneltest.cxx
@@ -48,6 +48,7 @@
 #include <vcl/tabctrl.hxx>
 #include <vcl/taskpanelist.hxx>
 #include <vcl/wrkwin.hxx>
+#include <sal/macros.h>
 
 namespace svt { namespace toolpanel
 {
@@ -93,7 +94,7 @@ public:
         {
             "This", "is a", "Tab", "Control", "intended", "for", "comparison"
         };
-        for ( size_t i=0; i < sizeof( pTabTitles ) / sizeof( pTabTitles[0] ); ++i )
+        for ( size_t i=0; i < SAL_N_ELEMENTS( pTabTitles ); ++i )
         {
             String sText( String::CreateFromAscii( pTabTitles[i] ) );
             m_aTabControl.InsertPage( i + 1, sText );
@@ -415,7 +416,7 @@ OptionsWindow::OptionsWindow( PanelDemoMainWindow& i_rParent )
         "Tab Bar Alignment", "Left", "Right", "Top", "Bottom", "Tab Items", "Images and Text", "Images only",
         "Text only", "Automatic", "Panels", "", "Remove Panel", "", "", "Insert Panel"
     };
-    for ( size_t i=0; i < sizeof( pControls ) / sizeof( pControls[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( pControls ); ++i )
     {
         const WindowType eWindowType = pControls[i]->GetType();
 
@@ -505,7 +506,7 @@ void OptionsWindow::GetFocus()
     {
         &m_aAlignLeft, &m_aAlignRight, &m_aAlignTop, &m_aAlignBottom
     };
-    for ( size_t i=0; i < sizeof( pRadios ) / sizeof( pRadios[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( pRadios ); ++i )
     {
         if ( pRadios[i]->IsChecked() )
         {
@@ -569,7 +570,7 @@ void OptionsWindow::Resize()
         ControlRow( m_aInsertPanel,         true )
     };
     bool bPreviousWasSubordinate = false;
-    for ( size_t i=0; i < sizeof( aControlRows ) / sizeof( aControlRows[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aControlRows ); ++i )
     {
         aItemPos.X() = ( aControlRows[i].bSubordinate ) ? nSubordinateX : nSuperordinateX;
 
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index fa8f837..bd95cd7 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -33,6 +33,7 @@
 #include <tools/stream.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/window.hxx>
+#include <sal/macros.h>
 #include <com/sun/star/util/MeasureUnit.hpp>
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/awt/XWindow.hpp>
@@ -517,7 +518,7 @@ namespace
             { FUNIT_FOOT,       MeasureUnit::FOOT,          1 },
             { FUNIT_MILE,       MeasureUnit::MILE,          1 },
         };
-        for ( size_t i = 0; i < sizeof( aUnits ) / sizeof( aUnits[0] ); ++i )
+        for ( size_t i = 0; i < SAL_N_ELEMENTS( aUnits ); ++i )
         {
             if ( eDirection == FieldUnitToMeasurementUnit )
             {
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index b8618d9..c8234b4 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -63,6 +63,7 @@
 
 #include <tools/debug.hxx>
 #include <rtl/string.h>
+#include <sal/macros.h>
 
 #include <vector>
 
@@ -486,7 +487,7 @@ namespace
         size_t nValueLen = lcl_tryReadConfigString( _pLine, _nLineLen, _pKeyName, aBuf, sizeof( aBuf ) );
         if ( nValueLen )
         {
-            for ( ULONG name = 0; name < sizeof( names ) / sizeof( names[0] ); ++name )
+            for ( ULONG name = 0; name < SAL_N_ELEMENTS( names ); ++name )
             {
                 if ( strcmp( aBuf, names[ name ] ) == 0 )
                 {
diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx
index ab53f67..98424a5 100644
--- a/tools/workben/urltest.cxx
+++ b/tools/workben/urltest.cxx
@@ -39,6 +39,7 @@
 #include "rtl/textenc.h"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
+#include <sal/macros.h>
 
 #include <cstddef>
 #include <cstdlib>
@@ -497,7 +498,7 @@ main()
                 { "vnd.sun.star.help://swriter?foo",
                   "vnd.sun.star.help://swriter/?foo" },
                 { "vnd.sun.star.help://swriter/?foo", 0 } };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS( aTest ); ++i)
         {
             INetURLObject aUrl(aTest[i].in);
             if (aUrl.HasError())
@@ -531,7 +532,7 @@ main()
                 /*TODO "wfs:///c|/xyz/",*/
                 /*TODO "wfs://xxx/yyy?zzz",*/
                 /*TODO "wfs:///x/y/z"*/ };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS(aTest); ++i)
         {
             INetURLObject aUrl(aTest[i]);
             if (aUrl.HasError())
@@ -566,7 +567,7 @@ main()
                 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx",
                 /*TODO "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx;yy",*/
                 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx//yy" };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS(aTest); ++i)
         {
             INetURLObject aUrl(aTest[i]);
             if (aUrl.HasError())
@@ -591,7 +592,7 @@ main()
                 "vnd.sun.star.cmd:log/out",
                 /*TODO "vnd.sun.star.cmd:[logout]",*/
                 "vnd.sun.star.cmd:log[out]" };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS( aTest ); ++i)
         {
             INetURLObject aUrl(aTest[i]);
             if (aUrl.HasError())
@@ -1220,7 +1221,7 @@ main()
                 { "smb://foo", "smb://foo/" },
                 { "smb://x;foo:bar@baz.xyz:12345/ab?cd",
                   "smb://x;foo:bar@baz.xyz:12345/ab?cd" } };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS( aTest ); ++i)
         {
             INetURLObject aUrl(aTest[i].m_pInput);
             if (aTest[i].m_pOutput == 0
@@ -1250,7 +1251,7 @@ main()
         static Test const aTest[]
             = { { "file://d:\\dir1\\file1", "file:///d:/dir1/file1" },
                 { "http://as@alaska:8000/test/test.sxw", 0 } };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS( aTest ); ++i)
         {
             INetURLObject aUrl = INetURLObject(
                 String(aTest[i].m_pInput, RTL_TEXTENCODING_UTF8),
@@ -1379,7 +1380,7 @@ main()
                 { INET_PROT_NEWS, "abc at def.ghi@", 0 },
                 { INET_PROT_NEWS, "!\"#@def", "news:!%22%23 at def" },
                 { INET_PROT_NEWS, " @def", "news:%20 at def" } };
-        for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS( aTest ); ++i)
         {
             INetURLObject aUri;
             bool bOk = aUri.ConcatData(aTest[i].eScheme, String(), String(),
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index f1ff665..0b64ba5 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -37,6 +37,7 @@
 #include <unotools/configpathes.hxx>
 #include <unotools/syslocale.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <sal/macros.h>
 #include <tools/debug.hxx>
 
 #if OSL_DEBUG_LEVEL > 1
@@ -1002,7 +1003,7 @@ FontWeight FontSubstConfiguration::getSubstWeight( const com::sun::star::uno::Re
             const OUString* pLine = (const OUString*)aAny.getValue();
             if( pLine->getLength() )
             {
-                for( weight=sizeof(pWeightNames)/sizeof(pWeightNames[0])-1; weight >= 0; weight-- )
+                for( weight=SAL_N_ELEMENTS(pWeightNames)-1; weight >= 0; weight-- )
                     if( pLine->equalsIgnoreAsciiCaseAscii( pWeightNames[weight].pName ) )
                         break;
             }
@@ -1034,7 +1035,7 @@ FontWidth FontSubstConfiguration::getSubstWidth( const com::sun::star::uno::Refe
             const OUString* pLine = (const OUString*)aAny.getValue();
             if( pLine->getLength() )
             {
-                for( width=sizeof(pWidthNames)/sizeof(pWidthNames[0])-1; width >= 0; width-- )
+                for( width=SAL_N_ELEMENTS(pWidthNames)-1; width >= 0; width-- )
                     if( pLine->equalsIgnoreAsciiCaseAscii( pWidthNames[width].pName ) )
                         break;
             }
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index f6c5bdb..c04ad8b 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -45,6 +45,7 @@
 #include <tools/string.hxx>
 #include <unotools/lingucfg.hxx>
 #include <unotools/linguprops.hxx>
+#include <sal/macros.h>
 
 #include <comphelper/processfactory.hxx>
 
@@ -293,7 +294,7 @@ const uno::Sequence< OUString > & SvtLinguConfigItem::GetPropertyNames()
 
     if (!bInitialized)
     {
-        INT32 nMax = sizeof(aNamesToHdl) / sizeof(aNamesToHdl[0]);
+        INT32 nMax = SAL_N_ELEMENTS(aNamesToHdl);
 
         aNames.realloc( nMax );
         OUString *pNames = aNames.getArray();
diff --git a/unotools/source/config/searchopt.cxx b/unotools/source/config/searchopt.cxx
index cffbf50..a38be3a 100644
--- a/unotools/source/config/searchopt.cxx
+++ b/unotools/source/config/searchopt.cxx
@@ -37,6 +37,7 @@
 #include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/uno/Any.h>
 #include <rtl/logfile.hxx>
+#include <sal/macros.h>
 
 
 using namespace rtl;
@@ -172,7 +173,7 @@ Sequence< OUString > SvtSearchOptions_Impl::GetPropertyNames() const
         "IsNotes"					// 25
     };
 
-    const int nCount = sizeof( aPropNames ) / sizeof( aPropNames[0] );
+    const int nCount = SAL_N_ELEMENTS( aPropNames );
     Sequence< OUString > aNames( nCount );
     OUString* pNames = aNames.getArray();
     for (INT32 i = 0;  i < nCount;  ++i)
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 0d31876..8af5bdd 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -51,6 +51,7 @@
 
 #include <com/sun/star/i18n/NumberFormatIndex.hdl>
 #include <rtl/instance.hxx>
+#include <sal/macros.h>
 
 #define LOCALEDATA_LIBRARYNAME "i18npool"
 #define LOCALEDATA_SERVICENAME "com.sun.star.i18n.LocaleData"
@@ -1741,7 +1742,7 @@ String LocaleDataWrapper::getCurr( sal_Int64 nNumber, USHORT nDecimals,
         new sal_Unicode[nGuess + 16]);
 
     sal_Unicode* const pBuffer =
-        ((size_t(rCurrencySymbol.Len()) + nGuess + 20) < sizeof(aBuf)/sizeof(aBuf[0]) ? aBuf :
+        ((size_t(rCurrencySymbol.Len()) + nGuess + 20) < SAL_N_ELEMENTS(aBuf) ? aBuf :
         new sal_Unicode[ rCurrencySymbol.Len() + nGuess + 20 ]);
     sal_Unicode* pBuf = pBuffer;
 
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index ee734a8..fdacb79 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -30,6 +30,7 @@
 #include "precompiled_unotools.hxx"
 #include <unotools/fontcvt.hxx>
 #include <unotools/fontdefs.hxx>
+#include <sal/macros.h>
 
 #ifndef _STLP_MAP
 #include <map>
@@ -1188,7 +1189,7 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl(bool bPerfectOnly)
 
     //Reverse map from a given starsymbol char to exact matches in ms symbol
     //fonts.
-    int nEntries = sizeof(aConservativeTable) / sizeof(aConservativeTable[0]);
+    int nEntries = SAL_N_ELEMENTS(aConservativeTable);
     int i;
     for (i = 0; i < nEntries; ++i)
     {
@@ -1219,7 +1220,7 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl(bool bPerfectOnly)
 
      //Allow extra conversions that are not perfect, but "good enough"
     if (!bPerfectOnly)
-        nEntries = sizeof(aAgressiveTable) / sizeof(aAgressiveTable[0]);
+        nEntries = SAL_N_ELEMENTS(aAgressiveTable);
     else
         nEntries = 1;
 
@@ -1439,7 +1440,7 @@ const ConvertChar* ConvertChar::GetRecodeData( const String& rOrgFontName, const
     if( aMapName.EqualsAscii( "starsymbol" )
      || aMapName.EqualsAscii( "opensymbol" ) )
     {
-        int nEntries = sizeof(aRecodeTable) / sizeof(aRecodeTable[0]);
+        int nEntries = SAL_N_ELEMENTS(aRecodeTable);
         for( int i = 0; i < nEntries; ++i)
         {
             RecodeTable& r = aRecodeTable[i];
@@ -1470,7 +1471,7 @@ FontToSubsFontConverter CreateFontToSubsFontConverter(
 
     if ( nFlags & FONTTOSUBSFONT_IMPORT )
     {
-        int nEntries = sizeof(aRecodeTable) / sizeof(aRecodeTable[0]);
+        int nEntries = SAL_N_ELEMENTS(aRecodeTable);
         if ( nFlags & FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ) // only StarMath+StarBats
             nEntries = 2;
         for( int i = 0; i < nEntries; ++i )
diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx
index 9f321b5..5de16a0 100644
--- a/vcl/aqua/source/gdi/salprn.cxx
+++ b/vcl/aqua/source/gdi/salprn.cxx
@@ -38,6 +38,7 @@
 #include "vcl/salptype.hxx"
 #include "vcl/print.hxx"
 #include "vcl/unohelp.hxx"
+#include <sal/macros.h>
 
 #include <boost/bind.hpp>
 
@@ -203,7 +204,7 @@ static struct PaperSizeEntry
 
 static bool getPaperSize( double& o_fWidth, double& o_fHeight, const Paper i_ePaper )
 {
-    for(unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
+    for(unsigned int i = 0; i < SAL_N_ELEMENTS(aPaperSizes); i++ )
     {
         if( aPaperSizes[i].nPaper == i_ePaper )
         {
@@ -237,7 +238,7 @@ static Paper recognizePaper( double i_fWidth, double i_fHeight )
     if( aPaper == PAPER_USER )
     {
         // search with fuzz factor
-        for( unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
+        for( unsigned int i = 0; i < SAL_N_ELEMENTS(aPaperSizes); i++ )
         {
             double w = (i_fWidth > aPaperSizes[i].fWidth) ? i_fWidth - aPaperSizes[i].fWidth : aPaperSizes[i].fWidth - i_fWidth;
             double h = (i_fHeight > aPaperSizes[i].fHeight) ? i_fHeight - aPaperSizes[i].fHeight : aPaperSizes[i].fHeight - i_fHeight;
diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm
index 2f9959a..ca9ef4a 100755
--- a/vcl/aqua/source/window/salframeview.mm
+++ b/vcl/aqua/source/window/salframeview.mm
@@ -34,6 +34,7 @@
 #include "salframeview.h"
 #include "aqua11yfactory.h"
 #include <sal/alloca.h>
+#include <sal/macros.h>
 #include "vcl/window.hxx"
 
 #include "vcl/svapp.hxx"
@@ -105,7 +106,7 @@ static USHORT ImplMapCharCode( sal_Unicode aCode )
     };
     
     USHORT nKeyCode = 0;
-    if( aCode < sizeof( aKeyCodeMap) / sizeof( aKeyCodeMap[0] ) )
+    if( aCode < SAL_N_ELEMENTS( aKeyCodeMap)  )
         nKeyCode = aKeyCodeMap[ aCode ];
     else if( aCode >= 0xf700 && aCode < 0xf780 )
         nKeyCode = aFunctionKeyCodeMap[ aCode - 0xf700 ]; 
@@ -878,7 +879,7 @@ private:
         
         // Caution: should the table grow to more than 5 or 6 entries,
         // we must consider moving it to a kind of hash map
-        const unsigned int nExceptions = sizeof( aExceptionalKeys ) / sizeof( aExceptionalKeys[0] );
+        const unsigned int nExceptions = SAL_N_ELEMENTS( aExceptionalKeys );
         for( unsigned int i = 0; i < nExceptions; i++ )
         {
             if( nKeyCode == aExceptionalKeys[i].nKeyCode &&
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index d242c5e..dd223c5 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -73,6 +73,7 @@
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
 #include <rtl/memory.h>
+#include <sal/macros.h>
 
 #include <vcl/unohelp.hxx>
 #include <vcl/unohelp2.hxx>
@@ -508,7 +509,7 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout )
 
     if( aText.Len() )
     {
-        if( 2*aText.Len() > xub_StrLen(sizeof(nDXBuffer)/sizeof(nDXBuffer[0])) )
+        if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
         {
             pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
             pDX = pDXBuffer;
@@ -1172,7 +1173,7 @@ void Edit::ImplShowCursor( BOOL bOnlyIfVisible )
 
     if( aText.Len() )
     {
-        if( 2*aText.Len() > xub_StrLen(sizeof(nDXBuffer)/sizeof(nDXBuffer[0])) )
+        if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
         {
             pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
             pDX = pDXBuffer;
@@ -1296,7 +1297,7 @@ xub_StrLen Edit::ImplGetCharPos( const Point& rWindowPos ) const
     sal_Int32	nDXBuffer[256];
     sal_Int32*	pDXBuffer = NULL;
     sal_Int32*	pDX = nDXBuffer;
-    if( 2*aText.Len() > xub_StrLen(sizeof(nDXBuffer)/sizeof(nDXBuffer[0])) )
+    if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
     {
         pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
         pDX = pDXBuffer;
diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx
index 6037c23..6e89a36 100644
--- a/vcl/source/gdi/font.cxx
+++ b/vcl/source/gdi/font.cxx
@@ -38,6 +38,7 @@
 #include "vcl/impfont.hxx"
 #include "vcl/outfont.hxx"
 #include "unotools/fontcfg.hxx"
+#include <sal/macros.h>
 
 #include <algorithm>
 
@@ -1034,7 +1035,7 @@ namespace
                     aEnt.string = pOpen+1;
                     aEnt.string_len = (pClose-pOpen)-1;
                     aEnt.weight = WEIGHT_NORMAL;
-                    const int nEnt = sizeof( weight_table ) / sizeof( weight_table[0] );
+                    const int nEnt = SAL_N_ELEMENTS( weight_table );
                     WeightSearchEntry* pFound = std::lower_bound( weight_table, weight_table+nEnt, aEnt );
                     if( pFound != (weight_table+nEnt) )
                         o_rResult.SetWeight( pFound->weight );
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 869b892..3ce739a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2210,7 +2210,7 @@ ImplDevFontList* PDFWriterImpl::filterDevFontList( ImplDevFontList* pFontList )
 
     // append the PDF builtin fonts
     if( !m_bIsPDF_A1 && !m_bEmbedStandardFonts)
-        for( unsigned int i = 0; i < sizeof(m_aBuiltinFonts)/sizeof(m_aBuiltinFonts[0]); i++ )
+        for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aBuiltinFonts); i++ )
         {
             ImplFontData* pNewData = new ImplPdfBuiltinFontData( m_aBuiltinFonts[i] );
             pFiltered->Add( pNewData );
@@ -3610,7 +3610,7 @@ std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitEmbeddedFont( const ImplFont
         if( nFontDescriptor )
         {
             if( pEncoding )
-                nToUnicodeStream = createToUnicodeCMap( nEncoding, &aUnicodes[0], pUnicodesPerGlyph, pEncToUnicodeIndex, sizeof(nEncoding)/sizeof(nEncoding[0]) );
+                nToUnicodeStream = createToUnicodeCMap( nEncoding, &aUnicodes[0], pUnicodesPerGlyph, pEncToUnicodeIndex, SAL_N_ELEMENTS(nEncoding) );
             
             // write font object
             sal_Int32 nObject = createObject();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 3ceda58..ce72411 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -44,6 +44,7 @@
 #include "rtl/digest.h"
 #include "com/sun/star/util/XURLTransformer.hpp"
 #include "com/sun/star/lang/Locale.hpp"
+#include <sal/macros.h>
 
 #include <vcl/sallayout.hxx>
 #include "pdffontcache.hxx"
@@ -292,7 +293,7 @@ public:
         GlyphEmit() : m_nUnicodes(0), m_nSubsetGlyphID(0)
         {
             rtl_zeroMemory( m_aBufferedUnicodes, sizeof( m_aBufferedUnicodes ) );
-            m_nMaxUnicodes = sizeof(m_aBufferedUnicodes)/sizeof(m_aBufferedUnicodes[0]);
+            m_nMaxUnicodes = SAL_N_ELEMENTS(m_aBufferedUnicodes);
         }
         ~GlyphEmit()
         {
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index b270fbf..c130c8c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -90,7 +90,7 @@
 #include "vcl/impbmpconv.hxx"
 #include "unotools/confignode.hxx"
 #include "vcl/gdimtf.hxx"
-
+#include <sal/macros.h>
 #include "vcl/pdfextoutdevdata.hxx"
 #include "vcl/lazydelete.hxx"
 
@@ -393,8 +393,7 @@ void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, BOOL bCallHdl )
     };
     static std::set< LanguageType > aBrokenSystemFontSizeLanguagesSet(
         eBrokenSystemFontSizeLanguages,
-        eBrokenSystemFontSizeLanguages + 
-        (sizeof(eBrokenSystemFontSizeLanguages)/sizeof(eBrokenSystemFontSizeLanguages[0]))
+        eBrokenSystemFontSizeLanguages + SAL_N_ELEMENTS(eBrokenSystemFontSizeLanguages)
         );
     LanguageType aLang = Application::GetSettings().GetUILanguage();
     if( aBrokenSystemFontSizeLanguagesSet.find( aLang ) != aBrokenSystemFontSizeLanguagesSet.end() )
diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx
index 235b3d9..0ef9b2d 100644
--- a/vcl/unx/gtk/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk/a11y/atkwrapper.cxx
@@ -516,6 +516,8 @@ wrapper_ref_relation_set( AtkObject *atk_obj )
 /*****************************************************************************/
 
 #if 0
+
+#include <sal/macros.h>
 struct {
     sal_Int16       value;
     const sal_Char* name;
@@ -556,7 +558,7 @@ struct {
 static void printStates(const uno::Sequence<sal_Int16>& rStates)
 {
     sal_Int32 n = rStates.getLength();
-    size_t nTypes = sizeof(aStateTypeTable)/sizeof(aStateTypeTable[0]);
+    size_t nTypes = SAL_N_ELEMENTS(aStateTypeTable);
     for (sal_Int32 i = 0; i < n; ++i)
     {
         for (size_t j = 0; j < nTypes; ++j)
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index cc88d31..0e70fc6 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -52,6 +52,7 @@
 #include <vcl/bitmapex.hxx>
 #include <vcl/impbmp.hxx>
 #include <vcl/svids.hrc>
+#include <sal/macros.h>
 
 #include <algorithm>
 
@@ -418,7 +419,7 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
 
 GtkSalFrame::~GtkSalFrame()
 {
-    for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); ++i )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i )
     {
         if( !m_aGraphics[i].pGraphics )
             continue;
@@ -1739,7 +1740,7 @@ void GtkSalFrame::moveToScreen( int nScreen )
         m_aSystemData.pAppContext	= NULL;
         m_aSystemData.aShellWindow	= m_aSystemData.aWindow;
         // update graphics if necessary
-        for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+        for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
         {
             if( m_aGraphics[i].bInUse )
                 m_aGraphics[i].pGraphics->SetDrawable( GDK_WINDOW_XWINDOW(m_pWindow->window), m_nScreen );
@@ -2400,7 +2401,7 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
     }
 
     // free xrender resources
-    for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
         if( m_aGraphics[i].bInUse )
             m_aGraphics[i].pGraphics->SetDrawable( None, m_nScreen );
 
@@ -2435,7 +2436,7 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
     }
 
     // update graphics
-    for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
     {
         if( m_aGraphics[i].bInUse )
         {
diff --git a/vcl/unx/source/app/keysymnames.cxx b/vcl/unx/source/app/keysymnames.cxx
index b205c7f..023848a 100644
--- a/vcl/unx/source/app/keysymnames.cxx
+++ b/vcl/unx/source/app/keysymnames.cxx
@@ -37,6 +37,7 @@
 
 #include <saldisp.hxx>
 #include <X11/keysym.h>
+#include <sal/macros.h>
 
 #if !defined (SunXK_Undo)
 #define SunXK_Undo		0x0000FF65	// XK_Undo
@@ -360,70 +361,70 @@ namespace vcl_sal {
     static const struct KeyboardReplacements aKeyboards[] =
     {
 #ifdef SOLARIS
-        { "Germany5", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
-        { "Germany4", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
-        { "France5", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
-        { "France6", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
-        { "France_x86", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
-        { "Italy5", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
-        { "Italy5-Hobo", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
-        { "Italy4", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
-        { "Italy6", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
-        { "Italy_x86", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
-        { "Netherland4", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Netherland5", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Netherland5-Hobo", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Netherland6", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Netherland_x86", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Norway5", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
-        { "Norway5-Hobo", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
-        { "Norway4", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
-        { "Norway6", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
-        { "Norway_x86", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
-        { "Portugal5", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Portugal5-Hobo", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Portugal4", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Portugal6", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Portugal_x86", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Spain5", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Spain5-Hobo", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Spain4", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Spain6", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Spain_x86", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Sweden5", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
-        { "Sweden5-Hobo", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
-        { "Sweden4", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
-        { "Sweden6", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
-        { "Sweden_x86", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
+        { "Germany5", aImplReplacements_German, SAL_N_ELEMENTS(aImplReplacements_German) },
+        { "Germany4", aImplReplacements_German, SAL_N_ELEMENTS(aImplReplacements_German) },
+        { "France5",  aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
+        { "France6",  aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
+        { "France_x86", aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
+        { "Italy5", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
+        { "Italy5-Hobo", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
+        { "Italy4", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
+        { "Italy6", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
+        { "Italy_x86", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
+        { "Netherland4", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Netherland5", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Netherland5-Hobo", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Netherland6", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Netherland_x86", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Norway5", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
+        { "Norway5-Hobo", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
+        { "Norway4", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
+        { "Norway6", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
+        { "Norway_x86", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
+        { "Portugal5", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Portugal5-Hobo", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Portugal4", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Portugal6", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Portugal_x86", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Spain5", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Spain5-Hobo", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Spain4", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Spain6", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Spain_x86", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Sweden5", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
+        { "Sweden5-Hobo", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
+        { "Sweden4", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
+        { "Sweden6", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
+        { "Sweden_x86", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
 #endif
-        { "U.S. English", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) },
-        { "United Kingdom", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) },
+        { "U.S. English", aImplReplacements_English, SAL_N_ELEMENTS(aImplReplacements_English) },
+        { "United Kingdom", aImplReplacements_English, SAL_N_ELEMENTS(aImplReplacements_English) },
         // Germany, German
-        { "German", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
-        { "France", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
-        { "French", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
+        { "German", aImplReplacements_German, SAL_N_ELEMENTS(aImplReplacements_German) },
+        { "France", aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
+        { "French", aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
         // Italy, Italian
-        { "Ital", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
+        { "Ital", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
         // Norway, Norwegian
-        { "Norw", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
+        { "Norw", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
         // Portugal, Portuguese
-        { "Portu", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
-        { "Spain", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
-        { "Spanish", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
+        { "Portu", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
+        { "Spain", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
+        { "Spanish", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
         // Sweden, Swedish
-        { "Swed", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
-        { "Netherland", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
-        { "Dutch", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
+        { "Swed", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
+        { "Netherland", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
+        { "Dutch", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
         // Turkish, Turkey
-        { "Turk", aImplReplacements_Turkish, sizeof(aImplReplacements_Turkish)/sizeof(aImplReplacements_Turkish[0]) },
+        { "Turk", aImplReplacements_Turkish, SAL_N_ELEMENTS(aImplReplacements_Turkish) },
         // Russian, Russia
-        { "Russia", aImplReplacements_Russian, sizeof(aImplReplacements_Russian)/sizeof(aImplReplacements_Russian[0]) },
-        { "English", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) }
+        { "Russia", aImplReplacements_Russian, SAL_N_ELEMENTS(aImplReplacements_Russian) },
+        { "English", aImplReplacements_English, SAL_N_ELEMENTS(aImplReplacements_English) }
     };
 
     String getKeysymReplacementName( const char* pKeyboard, KeySym nSymbol )
     {
-        for( unsigned int n = 0; n < sizeof(aKeyboards)/sizeof(aKeyboards[0]); n++ )
+        for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
         {
             if( ! strncasecmp( pKeyboard, aKeyboards[n].pKeyboardName, strlen( aKeyboards[n].pKeyboardName ) ) )
             {
@@ -437,7 +438,7 @@ namespace vcl_sal {
         }
         // try english fallbacks
         const struct KeysymNameReplacement* pRepl = aImplReplacements_English;
-        for( int m = sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) ; m ; )
+        for( int m = SAL_N_ELEMENTS(aImplReplacements_English); m ; )
         {
             if( nSymbol == pRepl[--m].aSymbol )
                 return String( pRepl[m].pName, RTL_TEXTENCODING_UTF8 );
diff --git a/vcl/unx/source/app/salinst.cxx b/vcl/unx/source/app/salinst.cxx
index 961838f..bef4d19 100644
--- a/vcl/unx/source/app/salinst.cxx
+++ b/vcl/unx/source/app/salinst.cxx
@@ -50,6 +50,7 @@
 #include "vcl/helper.hxx"
 #include <tools/solarmutex.hxx>
 #include "vos/mutex.hxx"
+#include <sal/macros.h>
 
 // -------------------------------------------------------------------------
 //
@@ -301,7 +302,7 @@ static void getServerDirectories( std::list< rtl::OString >& o_rFontPaths )
     };
     ::std::list< ByteString > aLines;
 
-    for( unsigned int i = 0; i < sizeof(pCommands)/sizeof(pCommands[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(pCommands); i++ )
     {
         FILE* pPipe = popen( pCommands[i], "r" );
         aLines.clear();
diff --git a/vcl/unx/source/app/wmadaptor.cxx b/vcl/unx/source/app/wmadaptor.cxx
index 7e27a4d..6338f24 100644
--- a/vcl/unx/source/app/wmadaptor.cxx
+++ b/vcl/unx/source/app/wmadaptor.cxx
@@ -41,6 +41,7 @@
 #include <osl/thread.h>
 #include <rtl/locale.h>
 #include <osl/process.h>
+#include <sal/macros.h>
 
 #include <tools/prex.h>
 #include <X11/X.h>
@@ -493,7 +494,7 @@ NetWMAdaptor::NetWMAdaptor( SalDisplay* pSalDisplay ) :
                     WMAdaptorProtocol* pMatch = (WMAdaptorProtocol*)
                         bsearch( &aSearch,
                                  aProtocolTab,
-                                 sizeof( aProtocolTab )/sizeof( aProtocolTab[0] ),
+                                 SAL_N_ELEMENTS( aProtocolTab ),
                                  sizeof( struct WMAdaptorProtocol ),
                                  compareProtocol );
                     if( pMatch )
@@ -749,7 +750,7 @@ GnomeWMAdaptor::GnomeWMAdaptor( SalDisplay* pSalDisplay ) :
                     WMAdaptorProtocol* pMatch = (WMAdaptorProtocol*)
                         bsearch( &aSearch,
                                  aProtocolTab,
-                                 sizeof( aProtocolTab )/sizeof( aProtocolTab[0] ),
+                                 SAL_N_ELEMENTS( aProtocolTab ),
                                  sizeof( struct WMAdaptorProtocol ),
                                  compareProtocol );
                     if( pMatch )
@@ -1006,7 +1007,7 @@ bool GnomeWMAdaptor::isValid() const
 void WMAdaptor::initAtoms()
 {
     // get basic atoms
-    for( unsigned int i = 0; i < sizeof( aAtomTab )/sizeof( aAtomTab[0] ); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS( aAtomTab ); i++ )
         m_aWMAtoms[ aAtomTab[i].nProtocol ] = XInternAtom( m_pDisplay, aAtomTab[i].pProtocol, False );
     m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ]	= XInternAtom( m_pDisplay, "_NET_SUPPORTING_WM_CHECK", True );
     m_aWMAtoms[ NET_WM_NAME ]				= XInternAtom( m_pDisplay, "_NET_WM_NAME", True );
diff --git a/vcl/unx/source/dtrans/X11_selection.cxx b/vcl/unx/source/dtrans/X11_selection.cxx
index cea2194..8ec576b 100644
--- a/vcl/unx/source/dtrans/X11_selection.cxx
+++ b/vcl/unx/source/dtrans/X11_selection.cxx
@@ -48,6 +48,7 @@
 #include <poll.h>
 #endif
 #include <sal/alloca.h>
+#include <sal/macros.h>
 
 #include <X11_selection.hxx>
 #include <X11_clipboard.hxx>
@@ -816,9 +817,7 @@ bool SelectionManager::requestOwnership( Atom selection )
 void SelectionManager::convertTypeToNative( const OUString& rType, Atom selection, int& rFormat, ::std::list< Atom >& rConversions, bool bPushFront )
 {
     NativeTypeEntry* pTab = selection == m_nXdndSelection ? aXdndConversionTab : aNativeConversionTab;
-    int nTabEntries = selection == m_nXdndSelection
-        ? sizeof(aXdndConversionTab)/sizeof(aXdndConversionTab[0]) :
-        sizeof(aNativeConversionTab)/sizeof(aNativeConversionTab[0]);
+    int nTabEntries = selection == m_nXdndSelection ? SAL_N_ELEMENTS(aXdndConversionTab) : SAL_N_ELEMENTS(aNativeConversionTab);
 
     OString aType( OUStringToOString( rType, RTL_TEXTENCODING_ISO_8859_1 ) );
     rFormat = 0;
@@ -891,10 +890,8 @@ void SelectionManager::getNativeTypeList( const Sequence< DataFlavor >& rTypes,
 
 OUString SelectionManager::convertTypeFromNative( Atom nType, Atom selection, int& rFormat )
 {
-    NativeTypeEntry* pTab = selection == m_nXdndSelection ? aXdndConversionTab : aNativeConversionTab;
-    int nTabEntries = selection == m_nXdndSelection
-        ? sizeof(aXdndConversionTab)/sizeof(aXdndConversionTab[0]) :
-        sizeof(aNativeConversionTab)/sizeof(aNativeConversionTab[0]);
+    NativeTypeEntry* pTab = (selection == m_nXdndSelection) ? aXdndConversionTab : aNativeConversionTab;
+    int nTabEntries = (selection == m_nXdndSelection) ? SAL_N_ELEMENTS(aXdndConversionTab) : SAL_N_ELEMENTS(aNativeConversionTab);
 
     for( int i = 0; i < nTabEntries; i++ )
     {
diff --git a/vcl/unx/source/dtrans/bmp.cxx b/vcl/unx/source/dtrans/bmp.cxx
index 4a5822b..f42cf73 100644
--- a/vcl/unx/source/dtrans/bmp.cxx
+++ b/vcl/unx/source/dtrans/bmp.cxx
@@ -36,6 +36,7 @@
 #include <bmp.hxx>
 
 #include <X11_selection.hxx>
+#include <sal/macros.h>
 
 using namespace x11;
 using namespace com::sun::star::uno;
@@ -424,7 +425,7 @@ PixmapHolder::PixmapHolder( Display* pDisplay ) :
         { "StaticGray", "GrayScale", "StaticColor", "PseudoColor", "TrueColor", "DirectColor" };
     fprintf( stderr, "PixmapHolder visual: id = 0x%lx, class = %s (%d), depth=%d; color map = 0x%lx\n",
              m_aInfo.visualid,
-             (m_aInfo.c_class >= 0 && unsigned(m_aInfo.c_class) < sizeof(pClasses)/sizeof(pClasses[0])) ? pClasses[m_aInfo.c_class] : "<unknown>",
+             (m_aInfo.c_class >= 0 && unsigned(m_aInfo.c_class) < SAL_N_ELEMENTS(pClasses)) ? pClasses[m_aInfo.c_class] : "<unknown>",
              m_aInfo.c_class,
              m_aInfo.depth,
              m_aColormap  );
diff --git a/vcl/unx/source/fontmanager/fontmanager.cxx b/vcl/unx/source/fontmanager/fontmanager.cxx
index 212e35a..b215edc 100644
--- a/vcl/unx/source/fontmanager/fontmanager.cxx
+++ b/vcl/unx/source/fontmanager/fontmanager.cxx
@@ -59,6 +59,8 @@
 #include "rtl/ustrbuf.hxx"
 #include "rtl/strbuf.hxx"
 
+#include <sal/macros.h>
+
 #include "i18npool/mslangid.hxx"
 
 
@@ -854,7 +856,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
                 RTL_TEXTENCODING_JIS_X_0208
             };
 
-        for( unsigned int enc = 0; enc < sizeof( aEncs )/sizeof(aEncs[0]) && m_aEncoding == RTL_TEXTENCODING_DONTKNOW; enc++ )
+        for( unsigned int enc = 0; enc < SAL_N_ELEMENTS( aEncs ) && m_aEncoding == RTL_TEXTENCODING_DONTKNOW; enc++ )
         {
             sal_Int32 nIndex = 0, nOffset = 1;
             do
@@ -1187,7 +1189,7 @@ PrintFontManager::PrintFontManager() :
         m_pFontCache( NULL ),
         m_bFontconfigSuccess( false )
 {
-    for( unsigned int i = 0; i < sizeof( aAdobeCodes )/sizeof( aAdobeCodes[0] ); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS( aAdobeCodes ); i++ )
     {
         m_aUnicodeToAdobename.insert( ::std::hash_multimap< sal_Unicode, ::rtl::OString >::value_type( aAdobeCodes[i].aUnicode, aAdobeCodes[i].pAdobename ) );
         m_aAdobenameToUnicode.insert( ::std::hash_multimap< ::rtl::OString, sal_Unicode, ::rtl::OStringHash >::value_type( aAdobeCodes[i].pAdobename, aAdobeCodes[i].aUnicode ) );
@@ -1297,7 +1299,7 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, co
         // first look for an adjacent file
         static const char* pSuffix[] = { ".afm", ".AFM" };
         
-        for( unsigned int i = 0; i < sizeof(pSuffix)/sizeof(pSuffix[0]); i++ )
+        for( unsigned int i = 0; i < SAL_N_ELEMENTS(pSuffix); i++ )
         {
             ByteString aName( rFontFile );
             aName.Erase( aName.Len()-4 );
@@ -2805,7 +2807,7 @@ family::type PrintFontManager::matchFamilyName( const ::rtl::OUString& rFamily )
 
     rtl::OString aFamily = rtl::OUStringToOString( rFamily, RTL_TEXTENCODING_ASCII_US );
     sal_uInt32 nLower = 0;
-    sal_uInt32 nUpper = sizeof(pFamilyMatch) / sizeof(pFamilyMatch[0]);
+    sal_uInt32 nUpper = SAL_N_ELEMENTS(pFamilyMatch);
 
     while( nLower < nUpper )
     {
diff --git a/vcl/unx/source/gdi/xlfd_attr.cxx b/vcl/unx/source/gdi/xlfd_attr.cxx
index 94fd054..787832e 100644
--- a/vcl/unx/source/gdi/xlfd_attr.cxx
+++ b/vcl/unx/source/gdi/xlfd_attr.cxx
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sal/alloca.h>
+#include <sal/macros.h>
 #include "xlfd_attr.hxx"
 #include <rtl/tencinfo.h>
 #include <vcl/vclenum.hxx>
@@ -235,7 +236,6 @@ Attribute::TagFeature( unsigned short nFeature )
 // order, since they are treated by binary search algorithm
 
 #define InitializeAttributeWith( p, a ) p, sizeof(p) - 1, a, 0, NULL, NULL
-#define MembersOf( p ) (sizeof(p) / sizeof(p[0]) )
 
 const Attribute pFamilyAttribute[] = {
     { InitializeAttributeWith( "arial", 				FAMILY_SWISS )  },
@@ -388,7 +388,7 @@ AnnotateSlant( const Attribute& rAttribute )
             { "ot", "Other" }
     };
 
-    for ( unsigned int i = 0; i < MembersOf(pTranslation); i++ )
+    for ( unsigned int i = 0; i < SAL_N_ELEMENTS(pTranslation); i++ )
         if ( strcmp(pStr, pTranslation[i].pFrom) == 0 )
         {
             return new String( pTranslation[i].pTo,
@@ -638,16 +638,16 @@ AttributeProvider::AddClassification()
     /* mpField[ eXLFDFoundry ] doesn't need classification */
     mpField[ eXLFDFamilyName   ]->AddClassification(
                                     (Attribute*)pFamilyAttribute,
-                                    MembersOf(pFamilyAttribute) );
+                                    SAL_N_ELEMENTS(pFamilyAttribute) );
     mpField[ eXLFDWeightName   ]->AddClassification(
                                     (Attribute*)pWeightAttribute,
-                                    MembersOf(pWeightAttribute) );
+                                    SAL_N_ELEMENTS(pWeightAttribute) );
     mpField[ eXLFDSlant        ]->AddClassification(
                                     (Attribute*)pSlantAttribute,
-                                    MembersOf(pSlantAttribute) );
+                                    SAL_N_ELEMENTS(pSlantAttribute) );
     mpField[ eXLFDSetwidthName ]->AddClassification(
                                     (Attribute*)pSetwidthAttribute,
-                                    MembersOf(pSetwidthAttribute) );
+                                    SAL_N_ELEMENTS(pSetwidthAttribute) );
     mpField[ eXLFDAddstyleName ]->AddClassification(
                                     GetTextEncodingFromAddStylename );
     mpField[ eXLFDCharset      ]->AddClassification(
diff --git a/vcl/unx/source/printer/ppdparser.cxx b/vcl/unx/source/printer/ppdparser.cxx
index f9f3ceb..2c589b4 100644
--- a/vcl/unx/source/printer/ppdparser.cxx
+++ b/vcl/unx/source/printer/ppdparser.cxx
@@ -49,6 +49,7 @@
 #include "osl/thread.h"
 #include "rtl/strbuf.hxx"
 #include "rtl/ustrbuf.hxx"
+#include <sal/macros.h>
 
 #include "com/sun/star/lang/Locale.hpp"
 
@@ -403,7 +404,7 @@ void PPDParser::scanPPDDir( const String& rDir )
     } const pSuffixes[] =
     { { ".PS", 3 },  { ".PPD", 4 }, { ".PS.GZ", 6 }, { ".PPD.GZ", 7 } };
 
-    const int nSuffixes = sizeof(pSuffixes)/sizeof(pSuffixes[0]);
+    const int nSuffixes = SAL_N_ELEMENTS(pSuffixes);
 
     osl::Directory aDir( rDir );
     aDir.open();
diff --git a/vcl/unx/source/printer/printerinfomanager.cxx b/vcl/unx/source/printer/printerinfomanager.cxx
index e0d05ee..389475f 100644
--- a/vcl/unx/source/printer/printerinfomanager.cxx
+++ b/vcl/unx/source/printer/printerinfomanager.cxx
@@ -45,6 +45,7 @@
 #include "i18npool/paper.hxx"
 
 #include "rtl/strbuf.hxx"
+#include <sal/macros.h>
 
 #include "osl/thread.hxx"
 #include "osl/mutex.hxx"
@@ -1370,7 +1371,7 @@ void SystemQueueInfo::run()
     std::list< rtl::OString > aLines;
     
     /* Discover which command we can use to get a list of all printer queues */
-    for( unsigned int i = 0; i < sizeof(aParms)/sizeof(aParms[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(aParms); i++ )
     {
         aLines.clear();
         rtl::OStringBuffer aCmdLine( 128 );
diff --git a/vcl/unx/source/printergfx/printerjob.cxx b/vcl/unx/source/printergfx/printerjob.cxx
index 0f04d92..8c7c710 100644
--- a/vcl/unx/source/printergfx/printerjob.cxx
+++ b/vcl/unx/source/printergfx/printerjob.cxx
@@ -51,6 +51,7 @@
 
 #include "osl/thread.h"
 #include "sal/alloca.h"
+#include <sal/macros.h>
 
 #include <algorithm>
 #include <vector>
@@ -428,7 +429,7 @@ PrinterJob::StartJob (
     sal_Char pCreationDate [256];
     WritePS (mpJobHeader, "%%CreationDate: (");
     getLocalTime(pCreationDate);
-    for( unsigned int i = 0; i < sizeof(pCreationDate)/sizeof(pCreationDate[0]); i++ )
+    for( unsigned int i = 0; i < SAL_N_ELEMENTS(pCreationDate); i++ )
     {
         if( pCreationDate[i] == '\n' )
         {
diff --git a/vcl/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx
index 559ee1b..b1fb134 100644
--- a/vcl/unx/source/window/salframe.cxx
+++ b/vcl/unx/source/window/salframe.cxx
@@ -70,6 +70,7 @@
 #include "tools/debug.hxx"
 
 #include "sal/alloca.h"
+#include <sal/macros.h>
 #include <com/sun/star/uno/Exception.hpp>
 
 #include <algorithm>
@@ -180,7 +181,7 @@ void X11SalFrame::setXEmbedInfo()
                          32,
                          PropModeReplace,
                          reinterpret_cast<unsigned char*>(aInfo),
-                         sizeof(aInfo)/sizeof(aInfo[0]) );
+                         SAL_N_ELEMENTS(aInfo) );
     }
 }
 


More information about the Libreoffice-commits mailing list