[Libreoffice-commits] core.git: basctl/source chart2/source connectivity/source dbaccess/source desktop/qa framework/source onlineupdate/source oox/source reportdesign/source sc/source sd/source setup_native/source sfx2/source svx/source sw/source toolkit/source tools/source vcl/source writerfilter/source xmloff/source xmlreader/source

Noel Grandin noelgrandin at gmail.com
Thu Mar 31 08:00:36 UTC 2016


 basctl/source/basicide/baside2.cxx                        |    2 -
 chart2/source/view/main/OpenGLRender.cxx                  |    2 -
 connectivity/source/commontools/TDatabaseMetaDataBase.cxx |    2 -
 connectivity/source/drivers/jdbc/DatabaseMetaData.cxx     |    2 -
 connectivity/source/drivers/mork/MColumnAlias.cxx         |    2 -
 dbaccess/source/core/api/RowSet.cxx                       |    2 -
 dbaccess/source/core/api/columnsettings.cxx               |    4 +-
 dbaccess/source/core/api/definitioncolumn.cxx             |    4 +-
 dbaccess/source/core/dataaccess/documentdefinition.cxx    |    4 +-
 dbaccess/source/core/misc/dsntypes.cxx                    |    6 +--
 dbaccess/source/core/recovery/dbdocrecovery.cxx           |    4 +-
 dbaccess/source/ext/macromigration/migrationengine.cxx    |   14 ++++----
 dbaccess/source/filter/xml/xmlExport.cxx                  |   14 ++++----
 dbaccess/source/sdbtools/connection/tablename.cxx         |    4 +-
 dbaccess/source/ui/app/AppController.cxx                  |    4 +-
 dbaccess/source/ui/app/AppDetailPageHelper.cxx            |    4 +-
 dbaccess/source/ui/app/AppIconControl.cxx                 |    4 +-
 dbaccess/source/ui/app/AppTitleWindow.cxx                 |    2 -
 dbaccess/source/ui/browser/dbloader.cxx                   |   10 ++---
 dbaccess/source/ui/browser/unodatbr.cxx                   |    2 -
 dbaccess/source/ui/control/FieldDescControl.cxx           |   18 +++++-----
 dbaccess/source/ui/dlg/TextConnectionHelper.cxx           |    2 -
 dbaccess/source/ui/misc/DExport.cxx                       |    4 +-
 dbaccess/source/ui/misc/UITools.cxx                       |    2 -
 dbaccess/source/ui/misc/WCopyTable.cxx                    |    2 -
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx     |    7 ++--
 dbaccess/source/ui/tabledesign/TEditControl.cxx           |    2 -
 dbaccess/source/ui/uno/copytablewizard.cxx                |    2 -
 desktop/qa/deployment_misc/test_dp_version.cxx            |    2 -
 framework/source/uielement/controlmenucontroller.cxx      |    6 +--
 onlineupdate/source/update/updater/loaddlls.cxx           |    2 -
 oox/source/drawingml/textbodypropertiescontext.cxx        |    2 -
 reportdesign/source/filter/xml/xmlExport.cxx              |    4 +-
 reportdesign/source/ui/dlg/GroupsSorting.cxx              |   24 +++++---------
 reportdesign/source/ui/inspection/DataProviderHandler.cxx |    2 -
 reportdesign/source/ui/inspection/GeometryHandler.cxx     |    2 -
 reportdesign/source/ui/inspection/metadata.cxx            |    4 +-
 reportdesign/source/ui/misc/UITools.cxx                   |    4 +-
 reportdesign/source/ui/report/ReportController.cxx        |   22 ++++++------
 reportdesign/source/ui/report/propbrw.cxx                 |    2 -
 sc/source/ui/unoobj/scdetect.cxx                          |    2 -
 sd/source/filter/html/htmlex.cxx                          |    4 +-
 sd/source/ui/slideshow/slideshowimpl.cxx                  |    6 +--
 setup_native/source/win32/wintools/makecab/parseddf.c     |    2 -
 sfx2/source/appl/shutdowniconw32.cxx                      |    2 -
 sfx2/source/view/frmload.cxx                              |    4 +-
 svx/source/fmcomp/fmgridif.cxx                            |    4 +-
 svx/source/fmcomp/gridcell.cxx                            |    8 ++--
 svx/source/fmcomp/gridctrl.cxx                            |    6 +--
 svx/source/form/fmPropBrw.cxx                             |    2 -
 svx/source/form/fmpage.cxx                                |    2 -
 svx/source/form/fmshimp.cxx                               |   14 ++++----
 svx/source/form/formcontrolling.cxx                       |    2 -
 svx/source/tbxctrls/tbcontrl.cxx                          |    2 -
 svx/source/unodraw/unoprov.cxx                            |    2 -
 sw/source/core/doc/fmtcol.cxx                             |    3 -
 toolkit/source/controls/spinningprogress.cxx              |    2 -
 tools/source/inet/inetmime.cxx                            |    5 +-
 vcl/source/fontsubset/ttcr.cxx                            |    4 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx         |    5 +-
 writerfilter/source/dmapper/StyleSheetTable.cxx           |    6 +--
 xmloff/source/forms/elementexport.cxx                     |   10 ++---
 xmlreader/source/xmlreader.cxx                            |    2 -
 63 files changed, 150 insertions(+), 156 deletions(-)

New commits:
commit 1aa4df615fa5599d05e9dd5e925b5852676185fa
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Mon Mar 28 17:12:04 2016 +0200

    use SAL_N_ELEMENTS in for loops
    
    for with
      git grep -n 'for.*sizeof'
    
    Change-Id: I6211024385e03ac5eeeb38690d2c1c699e015c2f
    Reviewed-on: https://gerrit.libreoffice.org/23569
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index b27605b..046fc92 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1564,7 +1564,7 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
     };
 
     bool bChanged = false;
-    for (unsigned i = 0; i != sizeof vIds / sizeof vIds[0]; ++i)
+    for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i)
     {
         Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
         Color& rMyColor = aColors[vIds[i].eTokenType];
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index e18b0c87..fa369b2 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -330,7 +330,7 @@ OpenGLRender::OpenGLRender()
     , m_SymbolShapeID(0)
 {
     //TODO: moggi: use STL
-    for (size_t i = 0; i < sizeof(m_BackgroundColor) / sizeof(float); i++)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(m_BackgroundColor); i++)
     {
         m_BackgroundColor[i] = 1.0;
     }
diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
index e7d0409..d6bb581 100644
--- a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
+++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
@@ -138,7 +138,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo(  ) throw(SQ
                 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
                 aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
                 const sal_Int32* pType = pTypes;
-                for (sal_Int32 i = 1; i <= sal_Int32(sizeof(pTypes)/sizeof(pTypes[0])); ++i,++pType)
+                for (sal_Int32 i = 1; i <= sal_Int32(SAL_N_ELEMENTS(pTypes)); ++i,++pType)
                 {
                     ORowSetValue aValue;
                     aValue.fill(i,*pType,xRow);
diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
index 2968278..8314dd8 100644
--- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
@@ -446,7 +446,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges(
                 for (sal_Int32 i = 1 ; i <= nCount ; ++i)
                 {
                     sColumnName = xMeta->getColumnName(i);
-                    for (sal_uInt32 j = 0 ; j < sizeof(sPrivs)/sizeof(sPrivs[0]); ++j)
+                    for (sal_uInt32 j = 0 ; j < SAL_N_ELEMENTS(sPrivs); ++j)
                     {
                         if ( sPrivs[j] == sColumnName )
                         {
diff --git a/connectivity/source/drivers/mork/MColumnAlias.cxx b/connectivity/source/drivers/mork/MColumnAlias.cxx
index b171e4f..440e1c0 100644
--- a/connectivity/source/drivers/mork/MColumnAlias.cxx
+++ b/connectivity/source/drivers/mork/MColumnAlias.cxx
@@ -75,7 +75,7 @@ OColumnAlias::OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::
         "Notes",
     };
 
-    for ( size_t i = 0; i < sizeof( s_pProgrammaticNames ) / sizeof( s_pProgrammaticNames[0] ); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS( s_pProgrammaticNames ); ++i )
         m_aAliasMap[ OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i );
 
     initialize( _rxORB );
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 8b1baa7..0e058ac 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -1747,7 +1747,7 @@ void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertyS
             OUString(PROPERTY_ALIGN), OUString(PROPERTY_RELATIVEPOSITION), OUString(PROPERTY_WIDTH), OUString(PROPERTY_HIDDEN), OUString(PROPERTY_CONTROLMODEL),
             OUString(PROPERTY_HELPTEXT), OUString(PROPERTY_CONTROLDEFAULT)
         };
-        for ( size_t i=0; i<sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+        for ( size_t i=0; i<SAL_N_ELEMENTS( aPropertyNames ); ++i )
         {
             if ( xInfo->hasPropertyByName( aPropertyNames[i] ) )
             {
diff --git a/dbaccess/source/core/api/columnsettings.cxx b/dbaccess/source/core/api/columnsettings.cxx
index 9395b22..87aba3e 100644
--- a/dbaccess/source/core/api/columnsettings.cxx
+++ b/dbaccess/source/core/api/columnsettings.cxx
@@ -126,7 +126,7 @@ namespace dbaccess
                 OUString sName;
                 sal_Int32       nHandle;
             };
-            PropertyDescriptor aProps[] =
+            const PropertyDescriptor aProps[] =
             {
                 { OUString(PROPERTY_ALIGN),            PROPERTY_ID_ALIGN },
                 { OUString(PROPERTY_NUMBERFORMAT),     PROPERTY_ID_NUMBERFORMAT },
@@ -138,7 +138,7 @@ namespace dbaccess
                 { OUString(PROPERTY_HIDDEN),           PROPERTY_ID_HIDDEN }
             };
 
-            for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( aProps ); ++i )
             {
                 if ( xPSI->hasPropertyByName( aProps[i].sName ) )
                     if ( !isDefaulted( aProps[i].nHandle, _rxColumn->getPropertyValue( aProps[i].sName ) ) )
diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx
index 2cb8693..d34d729 100644
--- a/dbaccess/source/core/api/definitioncolumn.cxx
+++ b/dbaccess/source/core/api/definitioncolumn.cxx
@@ -193,14 +193,14 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co
         OUString sName;
         sal_Int32       nHandle;
     };
-    PropertyDescriptor aProps[] =
+    const PropertyDescriptor aProps[] =
     {
         { OUString(PROPERTY_CATALOGNAME),      PROPERTY_ID_CATALOGNAME },
         { OUString(PROPERTY_SCHEMANAME),       PROPERTY_ID_SCHEMANAME },
         { OUString(PROPERTY_TABLENAME),        PROPERTY_ID_TABLENAME },
         { OUString(PROPERTY_REALNAME),         PROPERTY_ID_REALNAME }
     };
-    for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aProps ); ++i )
     {
         if ( xPSI->hasPropertyByName( aProps[i].sName ) )
             setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _rxParserColumn->getPropertyValue( aProps[i].sName ) );
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 9a1732f..258be0f 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -1472,11 +1472,11 @@ void ODocumentDefinition::separateOpenCommandArguments( const Sequence< Property
 {
     ::comphelper::NamedValueCollection aOpenCommandArguments( i_rOpenCommandArguments );
 
-    const sal_Char* pObjectDescriptorArgs[] =
+    const char* pObjectDescriptorArgs[] =
     {
         "RecoveryStorage"
     };
-    for ( size_t i=0; i < sizeof( pObjectDescriptorArgs ) / sizeof( pObjectDescriptorArgs[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( pObjectDescriptorArgs ); ++i )
     {
         if ( aOpenCommandArguments.has( pObjectDescriptorArgs[i] ) )
         {
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index 40a511a..54494f1 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -377,7 +377,7 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(const OUString& _rDsn) const
         {
         }
 
-        bool match( const OUString &url)
+        bool match( const OUString &url) const
         {
             if(bMatchComplete)
             {
@@ -389,7 +389,7 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(const OUString& _rDsn) const
             }
         }
     };
-    KnownPrefix aKnowPrefixes[] =
+    const KnownPrefix aKnowPrefixes[] =
     {
         KnownPrefix( "sdbc:calc:",          DST_CALC,               false ),
         KnownPrefix( "sdbc:flat:",          DST_FLAT,               false ),
@@ -414,7 +414,7 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(const OUString& _rDsn) const
         KnownPrefix( "sdbc:address:macab",              DST_MACAB,              true )
     };
 
-    for ( size_t i=0; i < sizeof( aKnowPrefixes ) / sizeof( aKnowPrefixes[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aKnowPrefixes ); ++i )
     {
         if( aKnowPrefixes[i].match(sDsn) )
         {
diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx
index f7960e5..c706375 100644
--- a/dbaccess/source/core/recovery/dbdocrecovery.cxx
+++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx
@@ -307,8 +307,8 @@ namespace dbaccess
 
         // read the map from sub storages to object names
         MapCompTypeToCompDescs aMapCompDescs;
-        SubComponentType aKnownTypes[] = { TABLE, QUERY, FORM, REPORT, RELATION_DESIGN };
-        for ( size_t i = 0; i < sizeof( aKnownTypes ) / sizeof( aKnownTypes[0] ); ++i )
+        const SubComponentType aKnownTypes[] = { TABLE, QUERY, FORM, REPORT, RELATION_DESIGN };
+        for ( size_t i = 0; i < SAL_N_ELEMENTS( aKnownTypes ); ++i )
         {
             if ( !xRecoveryStorage->hasByName( SubComponentRecovery::getComponentsStorageName( aKnownTypes[i] ) ) )
                 continue;
diff --git a/dbaccess/source/ext/macromigration/migrationengine.cxx b/dbaccess/source/ext/macromigration/migrationengine.cxx
index 94dd12c..c4f02cd 100644
--- a/dbaccess/source/ext/macromigration/migrationengine.cxx
+++ b/dbaccess/source/ext/macromigration/migrationengine.cxx
@@ -190,16 +190,16 @@ namespace dbmm
         {
             struct LanguageMapping
             {
-                const sal_Char*     pAsciiLanguage;
+                const char*         pAsciiLanguage;
                 const ScriptType    eScriptType;
 
-                LanguageMapping( const sal_Char* _pAsciiLanguage, const ScriptType _eScriptType )
+                LanguageMapping( const char* _pAsciiLanguage, const ScriptType _eScriptType )
                     :pAsciiLanguage( _pAsciiLanguage )
                     ,eScriptType( _eScriptType )
                 {
                 }
-            }
-            aLanguageMapping[] =
+            };
+            const LanguageMapping aLanguageMapping[] =
             {
                 LanguageMapping( "JavaScript", eJavaScript ),
                 LanguageMapping( "BeanShell",  eBeanShell ),
@@ -207,7 +207,7 @@ namespace dbmm
                 LanguageMapping( "Python",     ePython ),          // TODO: is this correct?
                 LanguageMapping( "Basic",      eBasic )
             };
-            for ( size_t i=0; i < sizeof( aLanguageMapping ) / sizeof( aLanguageMapping[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( aLanguageMapping ); ++i )
             {
                 if ( _rLanguage.equalsAscii( aLanguageMapping[i].pAsciiLanguage ) )
                 {
@@ -1205,10 +1205,10 @@ namespace dbmm
             }
             ::std::set< OUString > aElementNames( aDocStorage.getElementNames() );
 
-            ScriptType aKnownStorageBasedTypes[] = {
+            const ScriptType aKnownStorageBasedTypes[] = {
                 eBeanShell, eJavaScript, ePython, eJava
             };
-            for ( size_t i=0; i<sizeof( aKnownStorageBasedTypes ) / sizeof( aKnownStorageBasedTypes[0] ); ++i )
+            for ( size_t i=0; i<SAL_N_ELEMENTS( aKnownStorageBasedTypes ); ++i )
                 aElementNames.erase( lcl_getScriptsSubStorageName( aKnownStorageBasedTypes[i] ) );
 
             if ( !aElementNames.empty() )
diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx
index 7fcbd4a..0de7d58 100644
--- a/dbaccess/source/filter/xml/xmlExport.cxx
+++ b/dbaccess/source/filter/xml/xmlExport.cxx
@@ -347,7 +347,7 @@ void ODBExport::exportDataSource()
                 }
             };
 
-            PropertyMap aTokens[] =
+            const PropertyMap aTokens[] =
             {
                 PropertyMap( INFO_TEXTFILEHEADER,       XML_IS_FIRST_ROW_HEADER_LINE,       s_sTrue     ),
                 PropertyMap( INFO_SHOWDELETEDROWS,      XML_SHOW_DELETED,                   s_sFalse    ),
@@ -364,7 +364,7 @@ void ODBExport::exportDataSource()
             };
 
             bool bIsXMLDefault = false;
-            for ( size_t i=0; i < sizeof( aTokens ) / sizeof( aTokens[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( aTokens ); ++i )
             {
                 if ( pProperties->Name == aTokens[i].sPropertyName )
                 {
@@ -498,7 +498,7 @@ void ODBExport::exportApplicationConnectionSettings(const TSettingsMap& _aSettin
         ,XML_MAX_ROW_COUNT
         ,XML_SUPPRESS_VERSION_COLUMNS
     };
-    for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
+    for (size_t i = 0; i< SAL_N_ELEMENTS(pSettings); ++i)
     {
         TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
         if ( aFind != _aSettings.end() )
@@ -531,7 +531,7 @@ void ODBExport::exportDriverSettings(const TSettingsMap& _aSettings)
         ,XML_IS_FIRST_ROW_HEADER_LINE
         ,XML_PARAMETER_NAME_SUBSTITUTION
     };
-    for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
+    for (size_t i = 0; i< SAL_N_ELEMENTS(pSettings); ++i)
     {
         TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
         if ( aFind != _aSettings.end() )
@@ -1132,7 +1132,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp)
         };
 
         ::std::vector< XMLPropertyState > aPropertyStates;
-        for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
+        for (size_t i = 0 ; i < SAL_N_ELEMENTS(pExportHelper); ++i)
         {
             aPropertyStates = pExportHelper[i].first->Filter(_xProp);
             if ( !aPropertyStates.empty() )
@@ -1173,11 +1173,11 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp)
     }
     else
     { // here I know I have a column
-        TExportPropMapperPair pExportHelper[] = {
+        const TExportPropMapperPair pExportHelper[] = {
              TExportPropMapperPair(m_xColumnExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_COLUMN ))
             ,TExportPropMapperPair(m_xCellExportHelper,TEnumMapperPair(&m_aCellAutoStyleNames,XML_STYLE_FAMILY_TABLE_CELL))
         };
-        for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
+        for (size_t i = 0 ; i < SAL_N_ELEMENTS(pExportHelper); ++i)
         {
             ::std::vector< XMLPropertyState > aPropStates = pExportHelper[i].first->Filter( _xProp );
             if ( !aPropStates.empty() )
diff --git a/dbaccess/source/sdbtools/connection/tablename.cxx b/dbaccess/source/sdbtools/connection/tablename.cxx
index 0ba4598..c4006a5 100644
--- a/dbaccess/source/sdbtools/connection/tablename.cxx
+++ b/dbaccess/source/sdbtools/connection/tablename.cxx
@@ -180,7 +180,7 @@ namespace sdbtools
         */
         EComposeRule lcl_translateCompositionType_throw( sal_Int32 _nType )
         {
-            struct
+            const struct
             {
                 sal_Int32       nCompositionType;
                 EComposeRule    eComposeRule;
@@ -196,7 +196,7 @@ namespace sdbtools
 
             bool found = false;
             size_t i = 0;
-            for ( ; ( i < sizeof( TypeTable ) / sizeof( TypeTable[0] ) ) && !found; ++i )
+            for ( ; i < SAL_N_ELEMENTS( TypeTable ) && !found; ++i )
                 if ( TypeTable[i].nCompositionType == _nType )
                     found = true;
             if ( !found )
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 7a3de71..1f7bc25 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2643,7 +2643,7 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel >
     {
         if ( m_xDataSource.is() )
         {
-            for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( aPropertyNames ); ++i )
             {
                 m_xDataSource->removePropertyChangeListener( aPropertyNames[i], this );
             }
@@ -2666,7 +2666,7 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel >
     {
         if ( m_xDataSource.is() )
         {
-            for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( aPropertyNames ); ++i )
             {
                 m_xDataSource->addPropertyChangeListener( aPropertyNames[i], this );
             }
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
index 68c2317..7a5457b 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -1152,12 +1152,12 @@ IMPL_LINK_NOARG_TYPED(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, void)
     // execute the menu
     std::unique_ptr<PopupMenu> aMenu(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) ));
 
-    sal_uInt16 pActions[] = { SID_DB_APP_DISABLE_PREVIEW
+    const sal_uInt16 pActions[] = { SID_DB_APP_DISABLE_PREVIEW
                             , SID_DB_APP_VIEW_DOC_PREVIEW
                             , SID_DB_APP_VIEW_DOCINFO_PREVIEW
     };
 
-    for(size_t i=0; i < sizeof(pActions)/sizeof(pActions[0]);++i)
+    for(size_t i=0; i < SAL_N_ELEMENTS(pActions);++i)
     {
         aMenu->CheckItem(pActions[i],m_aMenu->IsItemChecked(pActions[i]));
     }
diff --git a/dbaccess/source/ui/app/AppIconControl.cxx b/dbaccess/source/ui/app/AppIconControl.cxx
index 0fcf1e7..d0c0fde 100644
--- a/dbaccess/source/ui/app/AppIconControl.cxx
+++ b/dbaccess/source/ui/app/AppIconControl.cxx
@@ -36,7 +36,7 @@ OApplicationIconControl::OApplicationIconControl(vcl::Window* _pParent)
     ,m_pActionListener(nullptr)
 {
 
-    struct CategoryDescriptor
+    const struct CategoryDescriptor
     {
         sal_uInt16      nLabelResId;
         ElementType eType;
@@ -47,7 +47,7 @@ OApplicationIconControl::OApplicationIconControl(vcl::Window* _pParent)
         { RID_STR_FORMS_CONTAINER,      E_FORM,     IMG_FORMFOLDER_TREE_L   },
         { RID_STR_REPORTS_CONTAINER,    E_REPORT,   IMG_REPORTFOLDER_TREE_L }
     };
-    for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
+    for ( size_t i=0; i < SAL_N_ELEMENTS(aCategories); ++i)
     {
         SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
             OUString( ModuleRes( aCategories[i].nLabelResId ) ) ,
diff --git a/dbaccess/source/ui/app/AppTitleWindow.cxx b/dbaccess/source/ui/app/AppTitleWindow.cxx
index c0126e1..cb2f052 100644
--- a/dbaccess/source/ui/app/AppTitleWindow.cxx
+++ b/dbaccess/source/ui/app/AppTitleWindow.cxx
@@ -41,7 +41,7 @@ OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _n
 
     const StyleSettings& rStyle = Application::GetSettings().GetStyleSettings();
     vcl::Window* pWindows[] = { m_aSpace1.get(), m_aSpace2.get(), m_aTitle.get() };
-    for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
+    for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
     {
         vcl::Font aFont = pWindows[i]->GetControlFont();
         aFont.SetWeight(WEIGHT_BOLD);
diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx
index 51165c7..72f27a2 100644
--- a/dbaccess/source/ui/browser/dbloader.cxx
+++ b/dbaccess/source/ui/browser/dbloader.cxx
@@ -152,11 +152,11 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU
     m_aURL      = rURL;
     m_aArgs     = rArgs;
 
-    struct ServiceNameToImplName
+    const struct ServiceNameToImplName
     {
-        const sal_Char*     pAsciiServiceName;
-        const sal_Char*     pAsciiImplementationName;
-        ServiceNameToImplName( const sal_Char* _pService, const sal_Char* _pImpl )
+        const char*     pAsciiServiceName;
+        const char*     pAsciiImplementationName;
+        ServiceNameToImplName( const char* _pService, const char* _pImpl )
             :pAsciiServiceName( _pService )
             ,pAsciiImplementationName( _pImpl )
         {
@@ -174,7 +174,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU
     Reference< XController2 > xController;
 
     const OUString sComponentURL( aParser.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
-    for ( size_t i=0; i < sizeof( aImplementations ) / sizeof( aImplementations[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aImplementations ); ++i )
     {
         if ( sComponentURL.equalsAscii( aImplementations[i].pAsciiServiceName ) )
         {
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index b5000d0..1f04843 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1284,7 +1284,7 @@ void SbaTableQueryBrowser::connectExternalDispatches()
                 ID_BROWSER_INSERTCONTENT
             };
 
-            for ( size_t i=0; i < sizeof( pURLs ) / sizeof( pURLs[0] ); ++i )
+            for ( size_t i=0; i < SAL_N_ELEMENTS( pURLs ); ++i )
             {
                 URL aURL;
                 aURL.Complete = OUString::createFromAscii( pURLs[i] );
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
index 97ddddeb..1065ace 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -275,7 +275,7 @@ void OFieldDescControl::CheckScrollBars()
     // horizontal :
     long lMaxXPosition = 0;
     Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
-    for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
         getMaxXPosition(ppAggregates[i],lMaxXPosition);
 
     lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP;
@@ -386,9 +386,9 @@ void OFieldDescControl::ScrollAllAggregates()
                                         , pTextLenText, pLengthText
                                         , pScaleText, m_pColumnNameText
                                         , m_pTypeText, m_pAutoIncrementValueText};
-        OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+        OSL_ENSURE(SAL_N_ELEMENTS(ppAggregates) == SAL_N_ELEMENTS(ppAggregatesText),"Lists are not identical!");
 
-        for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+        for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
             ScrollAggregate(ppAggregatesText[i],ppAggregates[i],nullptr,nDeltaX, nDeltaY);
 
         ScrollAggregate(pFormatText,pFormatSample,pFormat,nDeltaX, nDeltaY);
@@ -399,7 +399,7 @@ sal_uInt16 OFieldDescControl::CountActiveAggregates() const
 {
     Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
     sal_uInt16 nVisibleAggregates = 0;
-    for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
         if (ppAggregates[i])
             ++nVisibleAggregates;
     return nVisibleAggregates;
@@ -409,7 +409,7 @@ sal_Int32 OFieldDescControl::GetMaxControlHeight() const
 {
     Size aHeight;
     Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
-    for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
     {
         if ( ppAggregates[i] )
         {
@@ -438,9 +438,9 @@ void OFieldDescControl::SetReadOnly( bool bReadOnly )
                                         , m_pTypeText, m_pAutoIncrementValueText
                                         , pFormatText};
 
-    OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+    OSL_ENSURE(SAL_N_ELEMENTS(ppAggregates) == SAL_N_ELEMENTS(ppAggregatesText),"Lists are not identical!");
 
-    for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(ppAggregates); ++i)
     {
         if ( ppAggregatesText[i] )
             ppAggregatesText[i]->Enable( !bReadOnly );
@@ -662,7 +662,7 @@ void OFieldDescControl::ArrangeAggregates()
     };
 
     long nMaxWidth = 0;
-    for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
+    for (size_t i=0; i<SAL_N_ELEMENTS(adAggregates); i++)
     {
         if (adAggregates[i].pctrlTextControl)
         {
@@ -675,7 +675,7 @@ void OFieldDescControl::ArrangeAggregates()
     // And go ...
     int nCurrentControlPos = 0;
     Control* pZOrderPredecessor = nullptr;
-    for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
+    for (size_t i=0; i<SAL_N_ELEMENTS(adAggregates); i++)
     {
         if (adAggregates[i].pctrlInputControl)
         {
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
index 7a312f7..ac71da2 100644
--- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -112,7 +112,7 @@ namespace dbaui
             { 0, nullptr }
         };
 
-        for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
+        for ( size_t section=0; section < SAL_N_ELEMENTS( aSections ) - 1; ++section )
         {
             if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
             {
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index 2be4934..4db1645 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -337,7 +337,7 @@ void ODatabaseExport::insertValueIntoColumn()
                             {
                                 Reference< XNumberFormatsSupplier >  xSupplier = m_xFormatter->getNumberFormatsSupplier();
                                 Reference<XNumberFormatTypes> xNumType(xSupplier->getNumberFormats(),UNO_QUERY);
-                                sal_Int16 nFormats[] = {
+                                const sal_Int16 nFormats[] = {
                                     NumberFormat::DATETIME
                                     ,NumberFormat::DATE
                                     ,NumberFormat::TIME
@@ -345,7 +345,7 @@ void ODatabaseExport::insertValueIntoColumn()
                                     ,NumberFormat::NUMBER
                                     ,NumberFormat::LOGICAL
                                 };
-                                for (size_t i = 0; i < sizeof(nFormats)/sizeof(nFormats[0]); ++i)
+                                for (size_t i = 0; i < SAL_N_ELEMENTS(nFormats); ++i)
                                 {
                                     try
                                     {
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 7d62280..475da80 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -893,7 +893,7 @@ bool callColumnFormatDialog(vcl::Window* _pParent,
 
     pFormatDescriptor.reset();
     SfxItemPool::Free(pPool);
-    for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i)
         delete pDefaults[i];
 
     return bRet;
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index bfcdf21..169a0b8 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -143,7 +143,7 @@ void ObjectCopySource::copyUISettingsTo( const Reference< XPropertySet >& _rxObj
     const OUString aCopyProperties[] = {
         OUString(PROPERTY_FONT), OUString(PROPERTY_ROW_HEIGHT), OUString(PROPERTY_TEXTCOLOR),OUString(PROPERTY_TEXTLINECOLOR),OUString(PROPERTY_TEXTEMPHASIS),OUString(PROPERTY_TEXTRELIEF)
     };
-    for ( size_t i=0; i < sizeof( aCopyProperties ) / sizeof( aCopyProperties[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aCopyProperties ); ++i )
     {
         if ( m_xObjectPSI->hasPropertyByName( aCopyProperties[i] ) )
             _rxObject->setPropertyValue( aCopyProperties[i], m_xObject->getPropertyValue( aCopyProperties[i] ) );
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index b548783..255792c 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -173,7 +173,8 @@ void OSelectionBrowseBox::initialize()
     if(xConnection.is())
     {
         const IParseContext& rContext = static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext();
-        IParseContext::InternationalKeyCode eFunctions[] = { IParseContext::InternationalKeyCode::Avg,IParseContext::InternationalKeyCode::Count,IParseContext::InternationalKeyCode::Max
+        const IParseContext::InternationalKeyCode eFunctions[] = {
+            IParseContext::InternationalKeyCode::Avg,IParseContext::InternationalKeyCode::Count,IParseContext::InternationalKeyCode::Max
             ,IParseContext::InternationalKeyCode::Min,IParseContext::InternationalKeyCode::Sum
             ,IParseContext::InternationalKeyCode::Every
             ,IParseContext::InternationalKeyCode::Any
@@ -190,7 +191,7 @@ void OSelectionBrowseBox::initialize()
         OUString sGroup = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';') - 1, ';');
         m_aFunctionStrings = m_aFunctionStrings.getToken(0, ';');
 
-        for (size_t i = 0; i < sizeof (eFunctions) / sizeof (eFunctions[0]); ++i)
+        for (size_t i = 0; i < SAL_N_ELEMENTS(eFunctions); ++i)
         {
             m_aFunctionStrings += ";";
             m_aFunctionStrings += OStringToOUString(rContext.getIntlKeywordAscii(eFunctions[i]),
@@ -341,7 +342,7 @@ void OSelectionBrowseBox::Init()
     Size aHeight;
     const Control* pControls[] = { m_pTextCell,m_pVisibleCell,m_pTableCell,m_pFieldCell };
 
-    for (sal_Size i = 0; i < sizeof (pControls) / sizeof (pControls[0]); ++i)
+    for (sal_Size i = 0; i < SAL_N_ELEMENTS(pControls); ++i)
     {
         const Size aTemp(pControls[i]->GetOptimalSize());
         if ( aTemp.Height() > aHeight.Height() )
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 7586378..f784108 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -234,7 +234,7 @@ void OTableEditorCtrl::InitCellController()
 
     Size aHeight;
     const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell,pHelpTextCell};
-    for(sal_Size i= 0; i < sizeof(pControls) / sizeof(pControls[0]);++i)
+    for(sal_Size i= 0; i < SAL_N_ELEMENTS(pControls); ++i)
     {
         const Size aTemp(pControls[i]->GetOptimalSize());
         if ( aTemp.Height() > aHeight.Height() )
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 9e6c9c2..925936e 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -691,7 +691,7 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X
     const OUString aSettings[] = {
         OUString(PROPERTY_FILTER), OUString(PROPERTY_ORDER), OUString(PROPERTY_HAVING_CLAUSE), OUString(PROPERTY_GROUP_BY)
     };
-    for ( size_t i=0; i < sizeof( aSettings ) / sizeof( aSettings[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS( aSettings ); ++i )
     {
         if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) )
         {
diff --git a/desktop/qa/deployment_misc/test_dp_version.cxx b/desktop/qa/deployment_misc/test_dp_version.cxx
index 5cc24e7..836608d 100644
--- a/desktop/qa/deployment_misc/test_dp_version.cxx
+++ b/desktop/qa/deployment_misc/test_dp_version.cxx
@@ -61,7 +61,7 @@ void Test::test() {
           OUString("9223372036854775807"),
           ::dp_misc::GREATER }
     };
-    for (::std::size_t i = 0; i < sizeof data / sizeof (Data); ++i) {
+    for (::std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
         CPPUNIT_ASSERT_EQUAL(
             data[i].order,
             ::dp_misc::compareVersions(data[i].version1, data[i].version2));
diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index 250be1f..956639e 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -262,7 +262,7 @@ void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu )
     if ( pResMgr->IsAvailable( aResId ))
     {
         ImageList aImageList( aResId );
-        for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i )
+        for ( sal_uInt32 i=0; i < SAL_N_ELEMENTS(nConvertSlots); ++i )
         {
             // das entsprechende Image dran
             if ( m_bShowMenuImages )
@@ -310,7 +310,7 @@ void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Eve
     osl::ResettableMutexGuard aLock( m_aMutex );
 
     sal_uInt16 nMenuId = 0;
-    for (sal_uInt32 i=0; i < sizeof(aCommands) / sizeof (aCommands[0]); ++i)
+    for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(aCommands); ++i)
     {
         if ( Event.FeatureURL.Complete.equalsAscii( aCommands[i] ))
         {
@@ -419,7 +419,7 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (css::uno::RuntimeE
         fillPopupMenu( m_xPopupMenu );
         m_aURLToDispatchMap.free();
 
-        for (sal_uInt32 i=0; i<sizeof(aCommands)/sizeof(aCommands[0]); ++i)
+        for (sal_uInt32 i=0; i<SAL_N_ELEMENTS(aCommands); ++i)
         {
             aTargetURL.Complete = OUString::createFromAscii( aCommands[i] );
             m_xURLTransformer->parseStrict( aTargetURL );
diff --git a/onlineupdate/source/update/updater/loaddlls.cxx b/onlineupdate/source/update/updater/loaddlls.cxx
index 94a4222..0ec061d 100644
--- a/onlineupdate/source/update/updater/loaddlls.cxx
+++ b/onlineupdate/source/update/updater/loaddlls.cxx
@@ -90,7 +90,7 @@ struct AutoLoadSystemDependencies
     }
 
     // For each known DLL ensure it is loaded from the system32 directory
-    for (size_t i = 0; i < sizeof(delayDLLs) / sizeof(delayDLLs[0]); ++i) {
+    for (size_t i = 0; i < SAL_N_ELEMENTS(delayDLLs); ++i) {
       size_t fileLen = wcslen(delayDLLs[i]);
       wcsncpy(systemDirectory + systemDirLen, delayDLLs[i],
               MAX_PATH - systemDirLen);
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index 52aa309..8c19acc 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -49,7 +49,7 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rPa
     // ST_Coordinate
     OUString sValue;
     sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
-    for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
+    for( sal_Int32 i = 0; i < ( sal_Int32 ) SAL_N_ELEMENTS( aIns ); i++)
     {
         sValue = rAttribs.getString( aIns[i] ).get();
         if( !sValue.isEmpty() )
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index 47790b1..b6d936e 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -1566,8 +1566,8 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG
                     sFunctionName = sFunction + "_" + sExpression;
                 if ( !sFunction.isEmpty() )
                 {
-                    sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'};
-                    for(sal_uInt32 j= 0; j < sizeof(pReplaceChars)/sizeof(pReplaceChars[0]);++j)
+                    const sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'};
+                    for(sal_uInt32 j= 0; j < SAL_N_ELEMENTS(pReplaceChars);++j)
                         sFunctionName = sFunctionName.replace(pReplaceChars[j],'_');
 
                     xFunction->setName(sFunctionName);
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index 37b608b..2beba3d 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -393,12 +393,8 @@ void OFieldExpressionControl::lateInit()
         m_pComboCell->SetSelectHdl(LINK(this,OFieldExpressionControl,CBChangeHdl));
         m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION);
 
-        Control* pControls[] = {m_pComboCell};
-        for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
-        {
-            pControls[i]->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
-            pControls[i]->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost));
-        }
+        m_pComboCell->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
+        m_pComboCell->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost));
 
 
         // set browse mode
@@ -965,14 +961,14 @@ OGroupsSortingDialog::OGroupsSortingDialog(vcl::Window* _pParent, bool _bReadOnl
     m_pFieldExpression->set_vexpand(true);
 
     Control* pControlsLst[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst, m_pGroupIntervalEd};
-    for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst); ++i)
     {
         pControlsLst[i]->SetGetFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusGot));
         pControlsLst[i]->SetLoseFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusLost));
         pControlsLst[i]->Show();
     }
 
-    for (size_t i = 0; i < (sizeof (pControlsLst) / sizeof (pControlsLst[0])) - 1; ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst) - 1; ++i)
         static_cast<ListBox*>(pControlsLst[i])->SetSelectHdl(LINK(this,OGroupsSortingDialog,LBChangeHdl));
 
     m_pReportListener = new OPropertyChangeMultiplexer(this,m_pController->getReportDefinition().get());
@@ -1076,7 +1072,7 @@ void OGroupsSortingDialog::SaveData( sal_Int32 _nRow)
         xGroup->setSortAscending( m_pOrderLst->GetSelectEntryPos() == 0 );
 
     ListBox* pControls[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst};
-    for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i)
         pControls[i]->SaveValue();
 }
 
@@ -1108,7 +1104,7 @@ IMPL_LINK_TYPED(OGroupsSortingDialog, OnControlFocusGot, Control&, rControl, voi
     if ( m_pFieldExpression && m_pFieldExpression->getExpressionControl() )
     {
         Control* pControls[] = { m_pFieldExpression->getExpressionControl(), m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pGroupIntervalEd, m_pKeepTogetherLst, m_pOrderLst};
-        for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i)
         {
             if ( &rControl == pControls[i] )
             {
@@ -1252,8 +1248,8 @@ void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _x
         case sdbc::DataType::TIME:
         case sdbc::DataType::TIMESTAMP:
             {
-                sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE };
-                for (sal_uInt16 i = 0; i < sizeof (nIds) / sizeof (nIds[0]); ++i)
+                const sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE };
+                for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(nIds); ++i)
                 {
                     m_pGroupOnLst->InsertEntry(OUString(ModuleRes(nIds[i])));
                     m_pGroupOnLst->SetEntryData(i+1,reinterpret_cast<void*>(i+2));
@@ -1309,12 +1305,12 @@ void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _x
     m_pOrderLst->SelectEntryPos(_xGroup->getSortAscending() ? 0 : 1);
 
     ListBox* pControls[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst};
-    for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i)
         pControls[i]->SaveValue();
 
     ListBox* pControlsLst2[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst};
     bool bReadOnly = !m_pController->isEditable();
-    for (size_t i = 0; i < sizeof(pControlsLst2)/sizeof(pControlsLst2[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst2); ++i)
         pControlsLst2[i]->SetReadOnly(bReadOnly);
     m_pGroupIntervalEd->SetReadOnly(bReadOnly);
 }
diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx
index 1d56abb..9b00832 100644
--- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx
+++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx
@@ -374,7 +374,7 @@ uno::Sequence< beans::Property > SAL_CALL DataProviderHandler::getSupportedPrope
             ,OUString(PROPERTY_PREVIEW_COUNT)
         };
 
-        for (size_t nPos = 0; nPos < sizeof(s_pProperties)/sizeof(s_pProperties[0]) ;++nPos )
+        for (size_t nPos = 0; nPos < SAL_N_ELEMENTS(s_pProperties); ++nPos )
         {
             aValue.Name = s_pProperties[nPos];
             aNewProps.push_back(aValue);
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 44d457a..fd98306 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1309,7 +1309,7 @@ uno::Sequence< beans::Property > SAL_CALL GeometryHandler::getSupportedPropertie
     };
     const uno::Reference < beans::XPropertySetInfo > xInfo = m_xReportComponent->getPropertySetInfo();
     const uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
-    for (size_t i = 0; i < sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i )
+    for (size_t i = 0; i < SAL_N_ELEMENTS(pIncludeProperties); ++i )
     {
         const beans::Property* pIter = aSeq.getConstArray();
         const beans::Property* pEnd  = pIter + aSeq.getLength();
diff --git a/reportdesign/source/ui/inspection/metadata.cxx b/reportdesign/source/ui/inspection/metadata.cxx
index 6cff811..b0c6c4c 100644
--- a/reportdesign/source/ui/inspection/metadata.cxx
+++ b/reportdesign/source/ui/inspection/metadata.cxx
@@ -294,9 +294,9 @@ namespace rptui
         for (; pPropsIter != pPropsEnd; ++pPropsIter)
         {
             size_t nPos = 0;
-            for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos )
+            for (; nPos < SAL_N_ELEMENTS(pExcludeProperties) && pExcludeProperties[nPos] != pPropsIter->Name; ++nPos )
                 ;
-            if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) )
+            if ( nPos == SAL_N_ELEMENTS(pExcludeProperties) )
                 _rExcludeProperties.push_back(*pPropsIter);
         }
     }
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index a070c7e..007892c 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -540,7 +540,7 @@ namespace
                                 ,{ITEMID_LANGUAGE_ASIAN,OUString(PROPERTY_CHARLOCALEASIAN)}
                                 ,{ITEMID_LANGUAGE_COMPLEX,OUString(PROPERTY_CHARLOCALECOMPLEX)}
         };
-        for(size_t k = 0; k < sizeof(pItems)/sizeof(pItems[0]);++k)
+        for(size_t k = 0; k < SAL_N_ELEMENTS(pItems); ++k)
         {
             if ( SfxItemState::SET == _rItemSet.GetItemState( pItems[k].nWhich,true,&pItem) && dynamic_cast< const SvxLanguageItem *>( pItem ) !=  nullptr)
             {
@@ -730,7 +730,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep
     }
 
     SfxItemPool::Free(pPool);
-    for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i)
         delete pDefaults[i];
 
     return bSuccess;
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 661e012..8b42e40 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -2094,7 +2094,7 @@ void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _
             ,OUString("private:resource/toolbar/resizebar")
             ,OUString("private:resource/toolbar/sectionshrinkbar")
         };
-        for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i)
+        for (size_t i = 0; i< SAL_N_ELEMENTS(s_sMenu); ++i)
         {
             _xLayoutManager->createElement( s_sMenu[i] );
             _xLayoutManager->requestElement( s_sMenu[i] );
@@ -2537,7 +2537,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _
     }
     SfxItemPool::Free(pPool);
 
-    for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i)
         delete pDefaults[i];
 
 }
@@ -2724,7 +2724,7 @@ uno::Any SAL_CALL OReportController::getViewData() throw( uno::RuntimeException,
 {
     ::osl::MutexGuard aGuard( getMutex() );
 
-    sal_Int32 nCommandIDs[] =
+    const sal_Int32 nCommandIDs[] =
     {
         SID_GRID_VISIBLE,
         SID_GRID_USE,
@@ -2736,7 +2736,7 @@ uno::Any SAL_CALL OReportController::getViewData() throw( uno::RuntimeException,
     };
 
     ::comphelper::NamedValueCollection aCommandProperties;
-    for ( size_t i=0; i < sizeof (nCommandIDs) / sizeof (nCommandIDs[0]); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS(nCommandIDs); ++i )
     {
         const FeatureState aFeatureState = GetState( nCommandIDs[i] );
 
@@ -3209,7 +3209,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
                                           ,OUString(PROPERTY_FORMATSSUPPLIER)
                                           ,OUString(PROPERTY_BACKGROUNDCOLOR)
             };
-            for(size_t i = 0; i < sizeof (sProps) / sizeof (sProps[0]); ++i)
+            for(size_t i = 0; i < SAL_N_ELEMENTS(sProps); ++i)
             {
                 if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
                     xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
@@ -3493,7 +3493,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
                     OUString sDefaultName;
                     size_t i = 0;
                     OUnoObject* pObjs[2];
-                    for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
+                    for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
                     {
                         pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]);
                         uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
@@ -3508,7 +3508,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
                                                             ,OUString(PROPERTY_BORDER)
                                                             ,OUString(PROPERTY_BACKGROUNDCOLOR)
                         };
-                        for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k)
+                        for(size_t k = 0; k < SAL_N_ELEMENTS(sProps); ++k)
                         {
                             if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) )
                                 xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k]));
@@ -3570,7 +3570,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
                     uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
                     xShapeProp->setName(xShapeProp->getName() + sDefaultName );
 
-                    for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls
+                    for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) // insert controls
                     {
                         correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection());
                     }
@@ -3619,7 +3619,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
             }
             else
             {
-                for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
+                for(size_t i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
                     delete pControl[i];
             }
         }
@@ -3680,7 +3680,7 @@ void OReportController::listen(const bool _bAdd)
     void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const OUString&, const uno::Reference< XPropertyChangeListener >& ) =
         _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
 
-    for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
         (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) );
 
     OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
@@ -4260,7 +4260,7 @@ void OReportController::openZoomDialog()
         }
         SfxItemPool::Free(pPool);
 
-        for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
+        for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i)
             delete pDefaults[i];
     }
 }
diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx
index 77a6c07..6446163 100644
--- a/reportdesign/source/ui/report/propbrw.cxx
+++ b/reportdesign/source/ui/report/propbrw.cxx
@@ -194,7 +194,7 @@ void PropBrw::dispose()
             const OUString pProps[] = { OUString( "ContextDocument" )
                                             ,  OUString( "DialogParentWindow" )
                                             , OUString( "ActiveConnection" )};
-            for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i)
+            for (size_t i = 0; i < SAL_N_ELEMENTS(pProps); ++i)
                 xName->removeByName(pProps[i]);
         }
     }
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 0f8c1ba..3bd8ffc 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -202,7 +202,7 @@ static bool lcl_MayBeDBase( SvStream& rStream )
     rStream.Seek(STREAM_SEEK_TO_BEGIN);
     rStream.ReadUChar( nMark );
     bool bValidMark = false;
-    for (size_t i=0; i < sizeof(nValidMarks)/sizeof(nValidMarks[0]) && !bValidMark; ++i)
+    for (size_t i=0; i < SAL_N_ELEMENTS(nValidMarks) && !bValidMark; ++i)
     {
         if (nValidMarks[i] == nMark)
             bValidMark = true;
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index 06b2375..956a641 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -2939,7 +2939,7 @@ static const char * ASP_Scripts[] = { "common.inc", "webcast.asp", "show.asp", "
 /** creates and saves the ASP scripts for WebShow */
 bool HtmlExport::CreateASPScripts()
 {
-    for( sal_uInt16 n = 0; n < (sizeof( ASP_Scripts ) / sizeof(char *)); n++ )
+    for( sal_uInt16 n = 0; n < SAL_N_ELEMENTS(ASP_Scripts); n++ )
     {
         OUString aScript = OUString::createFromAscii(ASP_Scripts[n]);
 
@@ -2958,7 +2958,7 @@ static const char *PERL_Scripts[] = { "webcast.pl", "common.pl", "editpic.pl", "
 // creates and saves the PERL scripts for WebShow
 bool HtmlExport::CreatePERLScripts()
 {
-    for( sal_uInt16 n = 0; n < (sizeof( PERL_Scripts ) / sizeof(char *)); n++ )
+    for( sal_uInt16 n = 0; n < SAL_N_ELEMENTS(PERL_Scripts); n++ )
     {
         OUString aScript = OUString::createFromAscii(PERL_Scripts[n]);
 
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 954bdd3..482d9cd 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -2418,7 +2418,7 @@ void SlideshowImpl::createSlideList( bool bAll, const OUString& rPresSlide )
 
 typedef sal_uInt16 (*FncGetChildWindowId)();
 
-FncGetChildWindowId aShowChildren[] =
+static const FncGetChildWindowId aShowChildren[] =
 {
     &AnimationChildWindow::GetChildWindowId,
     &Svx3DChildWindow::GetChildWindowId,
@@ -2441,7 +2441,7 @@ void SlideshowImpl::hideChildWindows()
 
         if( pViewFrame )
         {
-            for( sal_uLong i = 0, nCount = sizeof( aShowChildren ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
+            for( sal_uLong i = 0; i < SAL_N_ELEMENTS( aShowChildren ); i++ )
             {
                 const sal_uInt16 nId = ( *aShowChildren[ i ] )();
 
@@ -2462,7 +2462,7 @@ void SlideshowImpl::showChildWindows()
         SfxViewFrame* pViewFrame = getViewFrame();
         if( pViewFrame )
         {
-            for( sal_uLong i = 0, nCount = sizeof( aShowChildren ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
+            for( sal_uLong i = 0; i < SAL_N_ELEMENTS(aShowChildren); i++ )
             {
                 if( mnChildMask & ( 1 << i ) )
                     pViewFrame->SetChildWindow( ( *aShowChildren[ i ] )(), true );
diff --git a/setup_native/source/win32/wintools/makecab/parseddf.c b/setup_native/source/win32/wintools/makecab/parseddf.c
index cf081e3..98dfaa1 100644
--- a/setup_native/source/win32/wintools/makecab/parseddf.c
+++ b/setup_native/source/win32/wintools/makecab/parseddf.c
@@ -252,7 +252,7 @@ DDFERR parseCmd(char * line, PCCAB ccab, char * token)
 
         for (p = token ; *p; ++p) *p = tolower(*p);
         if (isdigit(token[strlen(token)-1])) token[strlen(token)-1] = '\0';
-        for (i = 0; i < (sizeof(VARS)/sizeof(VARS[0])); i++)
+        for (i = 0; i < SAL_N_ELEMENTS(VARS); i++)
         {
             if (strcmp(token, VARS[i]) == 0)
             {
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx
index 34cfb29..ce37d30 100644
--- a/sfx2/source/appl/shutdowniconw32.cxx
+++ b/sfx2/source/appl/shutdowniconw32.cxx
@@ -180,7 +180,7 @@ static HMENU createSystrayMenu( )
     };
 
     // insert the menu entries for launching the applications
-    for ( size_t i = 0; i < sizeof( aMenuItems ) / sizeof( aMenuItems[0] ); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS(aMenuItems); ++i )
     {
         if ( !aModuleOptions.IsModuleInstalled( aMenuItems[i].eModuleIdentifier ) )
             // the complete application is not even installed
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index d304528..c7eea12 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -528,13 +528,13 @@ void SfxFrameLoader_Impl::impl_removeLoaderArguments( ::comphelper::NamedValueCo
 
 ::comphelper::NamedValueCollection SfxFrameLoader_Impl::impl_extractViewCreationArgs( ::comphelper::NamedValueCollection& io_rDescriptor )
 {
-    const sal_Char* pKnownViewArgs[] = {
+    static const char* pKnownViewArgs[] = {
         "JumpMark",
         "PickListEntry"
     };
 
     ::comphelper::NamedValueCollection aViewArgs;
-    for ( size_t i=0; i < sizeof( pKnownViewArgs ) / sizeof( pKnownViewArgs[0] ); ++i )
+    for ( size_t i=0; i < SAL_N_ELEMENTS(pKnownViewArgs); ++i )
     {
         if ( io_rDescriptor.has( pKnownViewArgs[i] ) )
         {
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index a75a10d..912bed3 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -1610,13 +1610,13 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol)
 {
     // the same props as in addColumnListeners ... linux has problems with global static UStrings, so
     // we have to do it this way ....
-    static OUString aPropsListenedTo[] =
+    static const OUString aPropsListenedTo[] =
     {
         OUString(FM_PROP_LABEL), OUString(FM_PROP_WIDTH), OUString(FM_PROP_HIDDEN), OUString(FM_PROP_ALIGN), OUString(FM_PROP_FORMATKEY)
     };
 
     Reference< XPropertySetInfo >  xInfo = xCol->getPropertySetInfo();
-    for (sal_uInt16 i=0; i<sizeof(aPropsListenedTo)/sizeof(aPropsListenedTo[0]); ++i)
+    for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(aPropsListenedTo); ++i)
         if (xInfo->hasPropertyByName(aPropsListenedTo[i]))
             xCol->removePropertyChangeListener(aPropsListenedTo[i], this);
 }
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index cc14e9d..30df2f2 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -718,7 +718,7 @@ void DbCellControl::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet
 
     if ((_eInitWhat & InitWritingMode) != 0)
     {
-        for (size_t i = 0; i < sizeof(pWindows) / sizeof(pWindows[0]); ++i)
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pWindows); ++i)
         {
             if (pWindows[i])
                 pWindows[i]->EnableRTL(rParent.IsRTLEnabled());
@@ -727,7 +727,7 @@ void DbCellControl::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet
 
     if ((_eInitWhat & InitFontFacet) != 0)
     {
-        for (size_t i = 0; i < sizeof(pWindows) / sizeof(pWindows[0]); ++i)
+        for (size_t i = 0; i < SAL_N_ELEMENTS(pWindows); ++i)
         {
             if (!pWindows[i])
                 continue;
@@ -757,7 +757,7 @@ void DbCellControl::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet
         bool bTextLineColor = rParent.IsTextLineColor();
         Color aTextLineColor(rParent.GetTextLineColor());
 
-        for (size_t i=0; i < sizeof(pWindows) / sizeof(pWindows[0]); ++i)
+        for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
         {
             if (pWindows[i])
             {
@@ -778,7 +778,7 @@ void DbCellControl::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet
         if (rParent.IsControlBackground())
         {
             Color aColor(rParent.GetControlBackground());
-            for (size_t i=0; i < sizeof(pWindows) / sizeof(pWindows[0]); ++i)
+            for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
             {
                 if (pWindows[i])
                 {
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index b077027..9d1768c 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -541,7 +541,7 @@ sal_uInt16 DbGridControl::NavigationBar::ArrangeControls()
             m_aNewBtn.get()
         };
 
-        for (size_t i=0; i < (sizeof (pWindows) / sizeof(pWindows[0])); ++i)
+        for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
         {
             if (pWindows[i]->GetPosPixel().X() < 0)
                 pWindows[i]->SetSizePixel(Size(0, nH));
@@ -812,7 +812,7 @@ void DbGridControl::NavigationBar::StateChanged(StateChangedType nType)
         case StateChangedType::Mirroring:
         {
             bool bIsRTLEnabled = IsRTLEnabled();
-            for (size_t i=0; i < (sizeof (pWindows) / sizeof(pWindows[0])); ++i)
+            for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
                 pWindows[i]->EnableRTL( bIsRTLEnabled );
         }
         break;
@@ -826,7 +826,7 @@ void DbGridControl::NavigationBar::StateChanged(StateChangedType nType)
             if (IsControlFont())
                 aFont.Merge(GetControlFont());
 
-            for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
+            for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
             {
                 pWindows[i]->SetZoom(aZoom);
                 pWindows[i]->SetZoomedPointFont(*pWindows[i], aFont);
diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx
index af7487d..f0e3abc 100644
--- a/svx/source/form/fmPropBrw.cxx
+++ b/svx/source/form/fmPropBrw.cxx
@@ -271,7 +271,7 @@ void FmPropBrw::dispose()
                                              , OUString( "DialogParentWindow" )
                                              , OUString( "ControlContext" )
                                              , OUString( "ControlShapeAccess" ) };
-            for ( size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i )
+            for ( size_t i = 0; i < SAL_N_ELEMENTS(pProps); ++i )
                 xName->removeByName( pProps[i] );
         }
     }
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index cf4d591..3dc3c37 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -193,7 +193,7 @@ bool FmFormPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
                     INetProtocol::Https, INetProtocol::Javascript,
                     INetProtocol::Ldap
                 };
-            for (sal_uInt16 i=0; i<sizeof(s_aQuickHelpSupported)/sizeof(s_aQuickHelpSupported[0]); ++i)
+            for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(s_aQuickHelpSupported); ++i)
                 if (s_aQuickHelpSupported[i] == aProtocol)
                 {
                     aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), INetURLObject::DECODE_UNAMBIGUOUS);
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index 0e8f324..fbe33f7 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -1046,7 +1046,7 @@ PopupMenu* FmXFormShell::GetConversionMenu()
     PopupMenu* pNewMenu = new PopupMenu(SVX_RES( RID_FMSHELL_CONVERSIONMENU ));
 
     ImageList aImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL) );
-    for ( size_t i = 0; i < sizeof (nConvertSlots) / sizeof (nConvertSlots[0]); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS(nConvertSlots); ++i )
     {
         // das entsprechende Image dran
         pNewMenu->SetItemImage(nConvertSlots[i], aImageList.GetImage(nCreateSlots[i]));
@@ -1058,7 +1058,7 @@ PopupMenu* FmXFormShell::GetConversionMenu()
 
 bool FmXFormShell::isControlConversionSlot( sal_uInt16 nSlotId )
 {
-    for ( size_t i = 0; i < sizeof (nConvertSlots) / sizeof (nConvertSlots[0]); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS(nConvertSlots); ++i )
         if (nConvertSlots[i] == nSlotId)
             return true;
     return false;
@@ -1094,7 +1094,7 @@ bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent
     OSL_ENSURE( isSolelySelected( _rxObject ),
         "FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant?" );
 
-    for ( size_t lookupSlot = 0; lookupSlot < sizeof( nConvertSlots ) / sizeof( nConvertSlots[0] ); ++lookupSlot )
+    for ( size_t lookupSlot = 0; lookupSlot < SAL_N_ELEMENTS(nConvertSlots); ++lookupSlot )
     {
         if (nConvertSlots[lookupSlot] == _nSlotId)
         {
@@ -1310,10 +1310,10 @@ bool FmXFormShell::canConvertCurrentSelectionToControl( sal_Int16 nConversionSlo
        )
         return false;   // those types cannot be converted
 
-    DBG_ASSERT(sizeof(nConvertSlots)/sizeof(nConvertSlots[0]) == sizeof(nObjectTypes)/sizeof(nObjectTypes[0]),
+    DBG_ASSERT(SAL_N_ELEMENTS(nConvertSlots) == SAL_N_ELEMENTS(nObjectTypes),
         "FmXFormShell::canConvertCurrentSelectionToControl: nConvertSlots & nObjectTypes must have the same size !");
 
-    for ( size_t i = 0; i < sizeof( nConvertSlots ) / sizeof( nConvertSlots[0] ); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS( nConvertSlots ); ++i )
         if (nConvertSlots[i] == nConversionSlot)
             return nObjectTypes[i] != nObjectType;
 
@@ -2031,7 +2031,7 @@ bool FmXFormShell::setCurrentSelection( const InterfaceBag& _rSelection )
         impl_updateCurrentForm( xNewCurrentForm );
 
     // ensure some slots are updated
-    for ( size_t i = 0; i < sizeof( SelObjectSlotMap ) / sizeof( SelObjectSlotMap[0] ); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS(SelObjectSlotMap); ++i )
         InvalidateSlot( SelObjectSlotMap[i], false);
 
     return true;
@@ -2071,7 +2071,7 @@ void FmXFormShell::impl_updateCurrentForm( const Reference< XForm >& _rxNewCurFo
         pPage->GetImpl().setCurForm( m_xCurrentForm );
 
     // ensure the UI which depends on the current form is up-to-date
-    for ( size_t i = 0; i < sizeof( DlgSlotMap ) / sizeof( DlgSlotMap[0] ); ++i )
+    for ( size_t i = 0; i < SAL_N_ELEMENTS( DlgSlotMap ); ++i )
         InvalidateSlot( DlgSlotMap[i], false );
 }
 
diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx
index 0baab09..14bc9c9 100644
--- a/svx/source/form/formcontrolling.cxx
+++ b/svx/source/form/formcontrolling.cxx
@@ -109,7 +109,7 @@ namespace svx
                         { OUString(FMURL_FORM_APPLY_FILTER),    SID_FM_FORM_FILTERED,       FormFeature::ToggleApplyFilter },
                         { OUString(FMURL_FORM_REMOVE_FILTER),   SID_FM_REMOVE_FILTER_SORT,  FormFeature::RemoveFilterAndSort }
                     };
-                    for ( size_t i=0; i<sizeof(aDescriptions)/sizeof(aDescriptions[0]); ++i )
+                    for ( size_t i=0; i<SAL_N_ELEMENTS(aDescriptions); ++i )
                         s_aFeatureDescriptions.push_back( aDescriptions[i] );
                 }
             };
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 0a56901..6637626 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2171,7 +2171,7 @@ struct SvxStyleToolBoxControl::Impl
                 };
                 Reference<container::XNameAccess> xCellStyles;
                 xStylesSupplier->getStyleFamilies()->getByName("CellStyles") >>= xCellStyles;
-                for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle )
+                for( sal_uInt32 nStyle = 0; nStyle < SAL_N_ELEMENTS(aCalcStyles); ++nStyle )
                 {
                     try
                     {
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index ee6635a..678a304 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -849,7 +849,7 @@ const UHashMapImpl& GetUHashImpl()
             { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG },
         };
 
-        for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
+        for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(aInit); i++)
             aImpl[OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
         bInited = true;
     }
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 4644188..333e26b 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -275,8 +275,7 @@ void SwTextFormatColl::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
             bContinue = pNewChgSet->GetTheChgdSet() == &GetAttrSet();
     }
 
-    for( int nC = 0, nArrLen = sizeof(aFontSizeArr) / sizeof( aFontSizeArr[0]);
-            nC < nArrLen; ++nC )
+    for( int nC = 0, nArrLen = SAL_N_ELEMENTS(aFontSizeArr); nC < nArrLen; ++nC )
     {
         const SvxFontHeightItem *pFSize = aFontSizeArr[ nC ], *pOldFSize;
         if( pFSize && SfxItemState::SET == GetItemState(
diff --git a/toolkit/source/controls/spinningprogress.cxx b/toolkit/source/controls/spinningprogress.cxx
index bd1d802..76b36f0 100644
--- a/toolkit/source/controls/spinningprogress.cxx
+++ b/toolkit/source/controls/spinningprogress.cxx
@@ -63,7 +63,7 @@ protected:
                 {
                     Throbber::IMAGES_16_PX, Throbber::IMAGES_32_PX, Throbber::IMAGES_64_PX
                 };
-                for ( size_t i=0; i < sizeof( aImageSets ) / sizeof( aImageSets[0] ); ++i )
+                for ( size_t i=0; i < SAL_N_ELEMENTS(aImageSets); ++i )
                 {
                     const ::std::vector< OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) );
                     const Sequence< OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() );
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 539496c..3491964 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -2046,7 +2046,7 @@ struct EncodingEntry
 // The source for the following table is <ftp://ftp.iana.org/in-notes/iana/
 // assignments/character-sets> as of Jan, 21 2000 12:46:00, unless  otherwise
 // noted:
-EncodingEntry const aEncodingMap[]
+static EncodingEntry const aEncodingMap[]
     = { { "US-ASCII", RTL_TEXTENCODING_ASCII_US },
         { "ANSI_X3.4-1968", RTL_TEXTENCODING_ASCII_US },
         { "ISO-IR-6", RTL_TEXTENCODING_ASCII_US },
@@ -2226,8 +2226,7 @@ EncodingEntry const aEncodingMap[]
 rtl_TextEncoding getCharsetEncoding(sal_Char const * pBegin,
                                               sal_Char const * pEnd)
 {
-    for (sal_Size i = 0; i < sizeof aEncodingMap / sizeof (EncodingEntry);
-         ++i)
+    for (sal_Size i = 0; i < SAL_N_ELEMENTS(aEncodingMap); ++i)
         if (equalIgnoreCase(pBegin, pEnd, aEncodingMap[i].m_aName))
             return aEncodingMap[i].m_eEncoding;
     return RTL_TEXTENCODING_DONTKNOW;
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 5874749..4931160 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -1111,7 +1111,7 @@ int GetRawData(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt3
         _this->rawdata = nullptr;
     }
 
-    for(i=0; i < sizeof(vtable2)/sizeof(*vtable2); i++) {
+    for(i=0; i < SAL_N_ELEMENTS(vtable2); i++) {
         if (_this->tag == vtable2[i].tag) {
             return vtable2[i].f(_this, ptr, len, tag);
         }
@@ -1511,7 +1511,7 @@ extern "C"
 
         if (_this->rawdata) free(_this->rawdata);
 
-        for(i=0; i < sizeof(vcl::vtable1)/sizeof(*vcl::vtable1); i++) {
+        for(i=0; i < SAL_N_ELEMENTS(vcl::vtable1); i++) {
             if (_this->tag == vcl::vtable1[i].tag) {
                 vcl::vtable1[i].f(_this);
                 return;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 653d6ef..bfa18c4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2167,7 +2167,7 @@ style::NumberingType::
     CHARS_CYRILLIC_LOWER_LETTER_N_SR*/
 
         };
-        for( sal_uInt32 nNum = 0; nNum < sizeof(aNumberingPairs)/sizeof( NumberingPairs ); ++nNum)
+        for( sal_uInt32 nNum = 0; nNum < SAL_N_ELEMENTS(aNumberingPairs); ++nNum)
         {
             if( /*sCommand*/sNumber.equalsAscii(aNumberingPairs[nNum].cWordName ))
             {
@@ -3098,8 +3098,7 @@ void DomainMapper_Impl::handleAuthor
         //search for a field mapping
         OUString sFieldServiceName;
         sal_uInt16 nMap = 0;
-        for( ; nMap < sizeof(aDocProperties) / sizeof(DocPropertyMap);
-            ++nMap )
+        for( ; nMap < SAL_N_ELEMENTS(aDocProperties); ++nMap )
         {
             if ((rFirstParam.equalsAscii(aDocProperties[nMap].pDocPropertyName)) && (!xPropertySetInfo->hasPropertyByName(rFirstParam)))
             {
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 14ae7fd..8519e17 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -187,7 +187,7 @@ void lcl_mergeProps( PropertyMapPtr pToFill,  PropertyMapPtr pToAdd, TblStyleTyp
         ( nStyleId == TBL_STYLE_FIRSTCOL )
     };
 
-    for ( unsigned i = 0 ; i != sizeof(pPropsToCheck) / sizeof(PropertyIds); i++ )
+    for ( unsigned i = 0 ; i != SAL_N_ELEMENTS(pPropsToCheck); i++ )
     {
         PropertyIds nId = pPropsToCheck[i];
         boost::optional<PropertyMap::Property> pProp = pToAdd->getProperty(nId);
@@ -232,7 +232,7 @@ PropertyMapPtr TableStyleSheetEntry::GetLocalPropertiesFromMask( sal_Int32 nMask
 
     // Get the properties applying according to the mask
     PropertyMapPtr pProps( new PropertyMap( ) );
-    for (size_t i = 0; i < sizeof(aOrderedStyleTable)/sizeof(aOrderedStyleTable[0]); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(aOrderedStyleTable); ++i)
     {
         TblStylePrs::iterator pIt = m_aStyles.find( aOrderedStyleTable[ i ].type );
         if ( ( nMask & aOrderedStyleTable[ i ].mask ) && ( pIt != m_aStyles.end( ) ) )
@@ -1429,7 +1429,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten
     }
     if(m_pImpl->m_aStyleNameMap.empty())
     {
-        for( sal_uInt32 nPair = 0; nPair < sizeof(aStyleNamePairs) / sizeof( sal_Char*) / 2; ++nPair)
+        for( sal_uInt32 nPair = 0; nPair < SAL_N_ELEMENTS(aStyleNamePairs)/2; ++nPair)
         {
             OUString aFrom = OUString::createFromAscii(aStyleNamePairs[2 * nPair]);
             OUString aTo = OUString::createFromAscii(aStyleNamePairs[2 * nPair + 1]);
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index f39a228..0b24033 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -547,11 +547,11 @@ namespace xmloff
             {
                 PROPERTY_LABEL, PROPERTY_TITLE
             };
-            OSL_ENSURE( sizeof(aStringPropertyNames)/sizeof(aStringPropertyNames[0]) ==
-                        sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]),
+            OSL_ENSURE( SAL_N_ELEMENTS(aStringPropertyNames) ==
+                        SAL_N_ELEMENTS(nStringPropertyAttributeIds),
                         "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (1)!");
 
-            for (i=0; i<sizeof(nStringPropertyAttributeIds)/sizeof(nStringPropertyAttributeIds[0]); ++i)
+            for (i=0; i<SAL_N_ELEMENTS(nStringPropertyAttributeIds); ++i)
                 if (nStringPropertyAttributeIds[i] & m_nIncludeCommon)
                 {
                     exportStringPropertyAttribute(
@@ -590,7 +590,7 @@ namespace xmloff
             OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount),
                 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!");
         #endif
-            for (i=0; i<sizeof(nBooleanPropertyAttributeIds)/sizeof(nBooleanPropertyAttributeIds[0]); ++i)
+            for (i=0; i<SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); ++i)
                 if (nBooleanPropertyAttributeIds[i] & m_nIncludeCommon)
                 {
                     exportBooleanPropertyAttribute(
@@ -631,7 +631,7 @@ namespace xmloff
             OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount),
                 "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!");
         #endif
-            for (i=0; i<sizeof(nIntegerPropertyAttributeIds)/sizeof(nIntegerPropertyAttributeIds[0]); ++i)
+            for (i=0; i<SAL_N_ELEMENTS(nIntegerPropertyAttributeIds); ++i)
                 if (nIntegerPropertyAttributeIds[i] & m_nIncludeCommon)
                 {
                     exportInt16PropertyAttribute(
diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx
index 25b5684..18a6d41 100644
--- a/xmlreader/source/xmlreader.cxx
+++ b/xmlreader/source/xmlreader.cxx
@@ -488,7 +488,7 @@ char const * XmlReader::handleReference(char const * position, char const * end)
               RTL_CONSTASCII_STRINGPARAM("'") },
             { RTL_CONSTASCII_STRINGPARAM("quot;"),
               RTL_CONSTASCII_STRINGPARAM("\"") } };
-        for (std::size_t i = 0; i < sizeof refs / sizeof refs[0]; ++i) {
+        for (std::size_t i = 0; i < SAL_N_ELEMENTS(refs); ++i) {
             if (rtl_str_shortenedCompare_WithLength(
                     position, end - position, refs[i].inBegin, refs[i].inLength,
                     refs[i].inLength) ==


More information about the Libreoffice-commits mailing list