diff options
author | Kayo Hamid <revol.code@yahoo.com> | 2010-10-14 21:14:52 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-10-14 21:15:24 +0100 |
commit | b7c82daa28526c566047e158ab2ace522fc442dc (patch) | |
tree | c71f33ee622add8de9013a170a7463ed564ad6e8 | |
parent | 1b0c6da1c3bcc6a9c1412d221d029885f9998fa1 (diff) |
Switch to use SAL_N_ELEMENTS macro, everywhere
64 files changed, 142 insertions, 148 deletions
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 08554b4d9258..8c85df4f383e 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -85,7 +85,7 @@ friend class VBABlackListQuery; VBABlacklist() { const char* list[] = { "Red" }; - sal_Int32 nSize = sizeof( list ) / sizeof( list[ 0 ] ); + sal_Int32 nSize = SAL_N_ELEMENTS( list ); for ( sal_Int32 index = 0; index < nSize; ++index ) { mBlackList[ String::CreateFromAscii( list[ index ] ).ToLowerAscii() ] = true; diff --git a/configmgr/source/xmlreader.cxx b/configmgr/source/xmlreader.cxx index c3851763956f..4865c87cf81a 100644 --- a/configmgr/source/xmlreader.cxx +++ b/configmgr/source/xmlreader.cxx @@ -430,7 +430,7 @@ XmlReader::Namespace XmlReader::scanNamespaceIri( XmlReader::NAMESPACE_XSI }, { RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/XML/1998/namespace"), XmlReader::NAMESPACE_XML } }; - for (std::size_t i = 0; i < sizeof iris / sizeof iris[0]; ++i) { + for (std::size_t i = 0; i < SAL_N_ELEMENTS( iris ); ++i) { if (rtl_str_compare_WithLength( iri.begin, iri.length, iris[i].begin, iris[i].length) == 0) @@ -550,7 +550,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) == diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx index 192834be2d49..62656173afa6 100644 --- a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx +++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx @@ -149,7 +149,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) throw(SQ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow; aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); 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/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index f57d3c311763..25931b86d96d 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -354,7 +354,7 @@ namespace dbtools { const ::rtl::OUString url = m_pImpl->xConnectionMetaData->getURL(); char pMySQL[] = "sdbc:mysql"; - bSupport = url.matchAsciiL(pMySQL,(sizeof(pMySQL)/sizeof(pMySQL[0]))-1); + bSupport = url.matchAsciiL(pMySQL,(SAL_N_ELEMENTS(pMySQL))-1); } } catch( const Exception& ) diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx index ba743482f027..befa4f09da50 100644 --- a/connectivity/source/drivers/adabas/BDriver.cxx +++ b/connectivity/source/drivers/adabas/BDriver.cxx @@ -1299,7 +1299,7 @@ void ODriver::fillEnvironmentVariables() { "DBROOT", &m_sDbRoot, &m_sDbRootURL } }; - for ( size_t i = 0; i < sizeof( EnvData ) / sizeof( EnvData[0] ); ++i ) + for ( size_t i = 0; i < SAL_N_ELEMENTS( EnvData ); ++i ) { ::rtl::OUString sVarName = ::rtl::OUString::createFromAscii( EnvData[i].pAsciiEnvName ); ::rtl::OUString sEnvValue; diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx index 3c7bbf4f8c07..911fbddcc9f9 100644 --- a/connectivity/source/drivers/adabas/BUser.cxx +++ b/connectivity/source/drivers/adabas/BUser.cxx @@ -163,7 +163,7 @@ void OAdabasUser::getAnyTablePrivileges(const ::rtl::OUString& objName, sal_Int3 { "SEL", Privilege::SELECT }, { "REF", Privilege::REFERENCE } }; - for ( size_t i = 0; i < sizeof( privileges ) / sizeof( privileges[0] ); ++i ) + for ( size_t i = 0; i < SAL_N_ELEMENTS( privileges ); ++i ) { sal_Int32 nIndex = sPrivs.indexOf( ::rtl::OUString::createFromAscii( privileges[i].pAsciiName ) ); if ( nIndex == -1 ) diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index f19b2a9845c5..ced9e8891931 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -1641,7 +1641,7 @@ ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1682,7 +1682,7 @@ ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1725,7 +1725,7 @@ ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1766,7 +1766,7 @@ ADORecordset* WpADOConnection::getIndexInfo( // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1809,7 +1809,7 @@ ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno:: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1856,7 +1856,7 @@ ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::A // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1906,7 +1906,7 @@ ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1948,7 +1948,7 @@ ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2020,7 +2020,7 @@ ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& cata varCriteria[nPos].setString(sTypeNames); // Create SafeArray Bounds and initialize the array - const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0]; + const sal_Int32 nCrit = SAL_N_ELEMENTS( varCriteria ); SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = nCrit; @@ -2058,7 +2058,7 @@ ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& cat // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2103,7 +2103,7 @@ ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS( varCriteria ); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2138,7 +2138,7 @@ ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/) { // Create elements used in the array OLEVariant varCriteria[2]; - const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; + const int nCrit = SAL_N_ELEMENTS( varCriteria ); // Create SafeArray Bounds and initialize the array SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index ac4729296325..87a2967b48c7 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -462,7 +462,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/mozab/MColumnAlias.cxx b/connectivity/source/drivers/mozab/MColumnAlias.cxx index ca3f8a41741e..dff72cebf09d 100644 --- a/connectivity/source/drivers/mozab/MColumnAlias.cxx +++ b/connectivity/source/drivers/mozab/MColumnAlias.cxx @@ -91,7 +91,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[ ::rtl::OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i ); initialize( _rxORB ); diff --git a/connectivity/source/drivers/mozab/MDriver.cxx b/connectivity/source/drivers/mozab/MDriver.cxx index 61e707806853..31635c07b48a 100644 --- a/connectivity/source/drivers/mozab/MDriver.cxx +++ b/connectivity/source/drivers/mozab/MDriver.cxx @@ -259,7 +259,7 @@ EDriverType MozabDriver::impl_classifyURL( const ::rtl::OUString& url ) { LDAP, "ldap" } }; - for ( size_t i=0; i < sizeof( aSchemeMap ) / sizeof( aSchemeMap[0] ); ++i ) + for ( size_t i=0; i < SAL_N_ELEMENTS( aSchemeMap ); ++i ) { if ( aAddrbookScheme.compareToAscii( aSchemeMap[i].pScheme ) == 0 ) return aSchemeMap[i].eType; diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index c4d48d55a913..a43289c36675 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1428,7 +1428,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::other_like_predicate_part_2, "other_like_predicate_part_2" }, { OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" } }; - size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); + size_t nRuleMapCount = SAL_N_ELEMENTS( aRuleDescriptions ); OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" ); for ( size_t mapEntry = 0; mapEntry < nRuleMapCount; ++mapEntry ) diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 0c4639675986..c54904d3cd76 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -148,7 +148,7 @@ LanguageType lcl_CheckLanguage( lang::Locale a3( SvxCreateLocale( aLangList[3] ) ); #endif - INT32 nCount = sizeof(aLangList) / sizeof(aLangList[0]); + INT32 nCount = SAL_N_ELEMENTS(aLangList); for (INT32 i = 0; i < nCount; i++) { INT16 nTmpLang = aLangList[i]; diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index d1cbae28bbd4..8df3c7ec05f5 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -346,7 +346,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create { FormulaMapGroupSpecialOffset::MACRO , ocMacro } , { FormulaMapGroupSpecialOffset::COL_ROW_NAME , ocColRowName } }; - const size_t nCount = sizeof(aMap)/sizeof(aMap[0]); + const size_t nCount = SAL_N_ELEMENTS(aMap); // Preallocate vector elements. if (aVec.size() < nCount) { @@ -386,7 +386,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create SC_OPCODE_CLOSE, SC_OPCODE_SEP, }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); + lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, SAL_N_ELEMENTS(aOpCodes) ); } if ((nGroups & FormulaMapGroup::ARRAY_SEPARATORS) != 0) { @@ -396,7 +396,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create SC_OPCODE_ARRAY_ROW_SEP, SC_OPCODE_ARRAY_COL_SEP }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); + lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, SAL_N_ELEMENTS(aOpCodes) ); } if ((nGroups & FormulaMapGroup::UNARY_OPERATORS) != 0) { @@ -452,7 +452,7 @@ uno::Sequence< sheet::FormulaOpCodeMapEntry > FormulaCompiler::OpCodeMap::create SC_OPCODE_NOT, SC_OPCODE_NEG }; - lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, sizeof(aOpCodes)/sizeof(aOpCodes[0]) ); + lclPushOpCodeMapEntries( aVec, mpTable, aOpCodes, SAL_N_ELEMENTS(aOpCodes) ); // functions with 2 or more parameters. for (USHORT nOp = SC_OPCODE_START_2_PAR; nOp < SC_OPCODE_STOP_2_PAR && nOp < mnSymbols; ++nOp) { diff --git a/fpicker/source/office/OfficeControlAccess.cxx b/fpicker/source/office/OfficeControlAccess.cxx index 3ba82e3aeb03..b0c501ba0e6d 100644 --- a/fpicker/source/office/OfficeControlAccess.cxx +++ b/fpicker/source/office/OfficeControlAccess.cxx @@ -116,7 +116,7 @@ namespace svt }; // ................................................................ - static const sal_Int32 s_nControlCount = sizeof( aDescriptions ) / sizeof( aDescriptions[0] ); + static const sal_Int32 s_nControlCount = SAL_N_ELEMENTS( aDescriptions ); static ControlDescIterator s_pControls = aDescriptions; static ControlDescIterator s_pControlsEnd = aDescriptions + s_nControlCount; @@ -166,7 +166,7 @@ namespace svt }; // ................................................................ - static const int s_nPropertyCount = sizeof( aProperties ) / sizeof( aProperties[0] ); + static const int s_nPropertyCount = SAL_N_ELEMENTS( aProperties ); static ControlPropertyIterator s_pProperties = aProperties; static ControlPropertyIterator s_pPropertiesEnd = aProperties + s_nPropertyCount; diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index da20643858ea..fe84c6937bcc 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -2571,7 +2571,7 @@ void SvtFileDialog::implArrangeControls() // loop through all these controls and adjust the z-order Window* pPreviousWin = NULL; Control** pCurrent = pControls; - for ( sal_Int32 i = 0; i < sal_Int32(sizeof( pControls ) / sizeof( pControls[ 0 ] )); ++i, ++pCurrent ) + for ( sal_Int32 i = 0; i < sal_Int32(SAL_N_ELEMENTS( pControls )); ++i, ++pCurrent ) { if ( !*pCurrent ) // this control is not available in the current operation mode -> skip @@ -2751,7 +2751,7 @@ void SvtFileDialog::Resize() _pPbPlay, _pImp->_pCbPassword, _pImp->_pCbAutoExtension, _pImp->_pCbOptions, _pCbSelection }; Control** ppMoveControls = aMoveControlsVert; - Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsVert ) / sizeof( aMoveControlsVert[0] ); + Control** ppMoveControlsEnd = ppMoveControls + SAL_N_ELEMENTS( aMoveControlsVert ); for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls ) lcl_MoveControl( *ppMoveControls, 0, nDeltaY ); } @@ -2763,7 +2763,7 @@ void SvtFileDialog::Resize() _pImp->_pBtnFileOpen, _pImp->_pBtnCancel, _pImp->_pBtnHelp }; Control** ppMoveControls = aMoveControlsBoth; - Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsBoth ) / sizeof( aMoveControlsBoth[0] ); + Control** ppMoveControlsEnd = ppMoveControls + SAL_N_ELEMENTS( aMoveControlsBoth ); for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls ) lcl_MoveControl( *ppMoveControls, nDeltaX, nDeltaY ); } @@ -2775,7 +2775,7 @@ void SvtFileDialog::Resize() _pImp->_pBtnUp, _pImp->_pBtnNewFolder, _pImp->_pBtnStandard }; Control** ppMoveControls = aMoveControlsHor; - Control** ppMoveControlsEnd = ppMoveControls + sizeof( aMoveControlsHor ) / sizeof( aMoveControlsHor[0] ); + Control** ppMoveControlsEnd = ppMoveControls + SAL_N_ELEMENTS( aMoveControlsHor ); for ( ; ppMoveControls != ppMoveControlsEnd; ++ppMoveControls ) lcl_MoveControl( *ppMoveControls, nDeltaX, 0 ); } @@ -2788,7 +2788,7 @@ void SvtFileDialog::Resize() _pImp->_pEdFileName, _pImp->_pLbFileVersion, _pImp->_pLbTemplates, _pImp->_pLbImageTemplates, _pImp->GetFilterListControl(), _pImp->_pFtCurrentPath, }; - sal_Int32 nSizeControls = sizeof( aSizeControls ) / sizeof( aSizeControls[0] ); + sal_Int32 nSizeControls = SAL_N_ELEMENTS( aSizeControls ); Control** ppSizeControls = aSizeControls; for ( sal_Int32 j=0; j<nSizeControls; ++j, ++ppSizeControls ) { diff --git a/fpicker/source/win32/filepicker/controlaccess.cxx b/fpicker/source/win32/filepicker/controlaccess.cxx index 68ce0ee59e06..adf9d305e311 100644 --- a/fpicker/source/win32/filepicker/controlaccess.cxx +++ b/fpicker/source/win32/filepicker/controlaccess.cxx @@ -184,8 +184,7 @@ namespace // private stc2, // LISTBOX_FILTER_LABEL stc3 // LISTBOX_FILE_NAME_LABEL }; - const int SIZE_WINDOWS_FILEOPEN_CTRL_IDS = - sizeof(WindowsFileOpenCtrlIds)/sizeof(WindowsFileOpenCtrlIds[0]); + const int SIZE_WINDOWS_FILEOPEN_CTRL_IDS = SAL_N_ELEMENTS(WindowsFileOpenCtrlIds); }; // end namespace diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index f132e263a5fb..d46a536d2433 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -684,7 +684,7 @@ void BackingWindow::layoutButton( long nTextWidth = i_rBtn.GetTextWidth( i_rBtn.GetText() ); nTextWidth += maButtonImageSize.Width() + 8; // add some fuzz to be on the safe side - if( nColumn >= 0 && nColumn < static_cast<int>(sizeof(mnColumnWidth)/sizeof(mnColumnWidth[0])) ) + if( nColumn >= 0 && nColumn < static_cast<int>(SAL_N_ELEMENTS(mnColumnWidth)) ) { if( nTextWidth > mnColumnWidth[nColumn] ) mnColumnWidth[nColumn] = nTextWidth; diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 166bb11ff69a..ebcf9cc82a50 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -240,7 +240,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 ) @@ -291,7 +291,7 @@ void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Eve osl::ResettableMutexGuard aLock( m_aMutex ); USHORT 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] )) { @@ -417,7 +417,7 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star:: 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 = rtl::OUString::createFromAscii( aCommands[i] ); m_xURLTransformer->parseStrict( aTargetURL ); diff --git a/framework/source/xml/menudocumenthandler.cxx b/framework/source/xml/menudocumenthandler.cxx index 38506b042f63..bfc4acd04450 100644 --- a/framework/source/xml/menudocumenthandler.cxx +++ b/framework/source/xml/menudocumenthandler.cxx @@ -140,7 +140,7 @@ MenuStyleItem MenuItemStyles[ ] = { }; -sal_Int32 nMenuStyleItemEntries = sizeof( MenuItemStyles ) / sizeof( MenuItemStyles[ 0 ] ); +sal_Int32 nMenuStyleItemEntries = SAL_N_ELEMENTS( MenuItemStyles ); static void ExtractMenuParameters( const Sequence< PropertyValue > rProp, ::rtl::OUString& rCommandURL, diff --git a/framework/source/xml/toolboxdocumenthandler.cxx b/framework/source/xml/toolboxdocumenthandler.cxx index a9244bdece5e..fa799b4e2f57 100644 --- a/framework/source/xml/toolboxdocumenthandler.cxx +++ b/framework/source/xml/toolboxdocumenthandler.cxx @@ -135,7 +135,7 @@ ToolboxStyleItem Styles[ ] = { { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, }; -sal_Int32 nStyleItemEntries = sizeof( Styles ) / sizeof( Styles[ 0 ] ); +sal_Int32 nStyleItemEntries = SAL_N_ELEMENTS( Styles ); struct ToolBarEntryProperty { diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 866a92b22bd6..ba1ce29e2337 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -138,7 +138,7 @@ static sal_Unicode aWhiteSpaces[] = 0xfffb /* INTERLINEAR ANNOTATION TERMINATOR */ }; -static int nWhiteSpaces = sizeof( aWhiteSpaces ) / sizeof( aWhiteSpaces[0] ); +static int nWhiteSpaces = SAL_N_ELEMENTS( aWhiteSpaces ); static bool lcl_IsWhiteSpace( sal_Unicode cChar ) { diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index d70aec887eab..1f9a63071795 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -298,7 +298,7 @@ OUString LinguOptions::GetName( INT32 nWID ) OUString aRes; - INT32 nLen = sizeof( aWID_Name ) / sizeof( aWID_Name[0] ); + INT32 nLen = SAL_N_ELEMENTS( aWID_Name ); if (0 <= nWID && nWID < nLen && aWID_Name[ nWID ].nWID == nWID) { diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx index 37d4d86198b0..7a13b36b1f71 100644 --- a/linguistic/source/lngprophelp.cxx +++ b/linguistic/source/lngprophelp.cxx @@ -64,7 +64,7 @@ static const char *aCH[] = UPN_IS_USE_DICTIONARY_LIST, }; -static int nCHCount = sizeof(aCH) / sizeof(aCH[0]); +static int nCHCount = SAL_N_ELEMENTS(aCH); PropertyChgHelper::PropertyChgHelper( @@ -389,7 +389,7 @@ PropertyHelper_Spell::PropertyHelper_Spell( Reference< XPropertySet > &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, AE_SPELLCHECKER ) { - AddPropNames( aSP, sizeof(aSP) / sizeof(aSP[0]) ); + AddPropNames( aSP, SAL_N_ELEMENTS(aSP)); SetDefaultValues(); GetCurrentValues(); @@ -577,7 +577,7 @@ PropertyHelper_Hyphen::PropertyHelper_Hyphen( Reference< XPropertySet > &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, AE_HYPHENATOR ) { - AddPropNames( aHP, sizeof(aHP) / sizeof(aHP[0]) ); + AddPropNames( aHP, SAL_N_ELEMENTS(aHP)); SetDefaultValues(); GetCurrentValues(); } diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 8991095369f0..0568fab4bdfe 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -836,7 +836,7 @@ static const sal_uInt32 the_aDigitZeroes [] = BOOL HasDigits( const OUString &rText ) { - static const int nNumDigitZeroes = sizeof(the_aDigitZeroes) / sizeof(the_aDigitZeroes[0]); + static const int nNumDigitZeroes = SAL_N_ELEMENTS(the_aDigitZeroes); const sal_Int32 nLen = rText.getLength(); sal_Int32 i = 0; diff --git a/linguistic/workben/sprophelp.cxx b/linguistic/workben/sprophelp.cxx index ced3e205dc96..d2ac04abb714 100644 --- a/linguistic/workben/sprophelp.cxx +++ b/linguistic/workben/sprophelp.cxx @@ -193,7 +193,7 @@ static const char *aSP[] = PropertyHelper_Spell::PropertyHelper_Spell( const Reference< XInterface > & rxSource, Reference< XPropertySet > &rxPropSet ) : - PropertyChgHelper ( rxSource, rxPropSet, aSP, sizeof(aSP) / sizeof(aSP[0]) ) + PropertyChgHelper ( rxSource, rxPropSet, aSP, SAL_N_ELEMENTS(aSP)) { SetDefault(); INT32 nLen = GetPropNames().getLength(); diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index b75c6d61e7b2..591f3202c05f 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -416,7 +416,7 @@ EventInfoHash& getEventTransInfo() { rtl::OUString sEventInfo = MAP_CHAR_LEN(""); TranslatePropMap* pTransProp = aTranslatePropMap_Impl; - int nCount = sizeof(aTranslatePropMap_Impl) / sizeof(aTranslatePropMap_Impl[0]); + int nCount = SAL_N_ELEMENTS(aTranslatePropMap_Impl); int i = 0; while (i < nCount) diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 1e5bf369a6a9..6aa9ea0b1a7b 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -251,7 +251,7 @@ static HMENU createSystrayMenu( ) OUString aEmpty; // 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/dialog/alienwarn.cxx b/sfx2/source/dialog/alienwarn.cxx index 571a056f3070..09aebb25949e 100644 --- a/sfx2/source/dialog/alienwarn.cxx +++ b/sfx2/source/dialog/alienwarn.cxx @@ -144,7 +144,7 @@ void SfxAlienWarningDialog::InitSize() &m_aSaveODFBtn, &m_aKeepCurrentBtn, &m_aMoreInfoBtn, &m_aOptionLine, &m_aWarningOnBox }; Window** pCurrent = pWins; - for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { Point aNewPos = (*pCurrent)->GetPosPixel(); aNewPos.Y() -= nDelta; diff --git a/sfx2/source/dialog/printopt.cxx b/sfx2/source/dialog/printopt.cxx index 45a3aa287ddc..7e3a2e8b02dd 100644 --- a/sfx2/source/dialog/printopt.cxx +++ b/sfx2/source/dialog/printopt.cxx @@ -44,8 +44,6 @@ static USHORT aDPIArray[] = { 72, 96, 150, 200, 300, 600 }; static BOOL bOutputForPrinter = TRUE; -#define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ])) - SfxCommonPrintOptionsTabPage::SfxCommonPrintOptionsTabPage( Window* pParent, const SfxItemSet& rSet ) : SfxTabPage( pParent, SfxResId( TP_COMMONPRINTOPTIONS ), rSet ), @@ -233,7 +231,7 @@ void SfxCommonPrintOptionsTabPage::ImplUpdateControls( const PrinterOptions* pCu aReduceBitmapsResolutionLB.SelectEntryPos( 0 ); else { - for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- ) + for( long i = ( SAL_N_ELEMENTS(aDPIArray) - 1 ); i >= 0; i-- ) { if( nDPI >= aDPIArray[ i ] ) { @@ -362,7 +360,7 @@ void SfxCommonPrintOptionsTabPage::ImplSaveControls( PrinterOptions* pCurrentOpt pCurrentOptions->SetReducedBitmapMode( aReduceBitmapsOptimalRB.IsChecked() ? PRINTER_BITMAP_OPTIMAL : ( aReduceBitmapsNormalRB.IsChecked() ? PRINTER_BITMAP_NORMAL : PRINTER_BITMAP_RESOLUTION ) ); pCurrentOptions->SetReducedBitmapResolution( aDPIArray[ Min( (USHORT) aReduceBitmapsResolutionLB.GetSelectEntryPos(), - (USHORT)( sizeof( aDPIArray ) / sizeof( aDPIArray[ 0 ] ) - 1 ) ) ] ); + (USHORT)( SAL_N_ELEMENTS( aDPIArray ) - 1 ) ) ] ); pCurrentOptions->SetReducedBitmapIncludesTransparency( aReduceBitmapsTransparencyCB.IsChecked() ); pCurrentOptions->SetConvertToGreyscales( aConvertToGreyscalesCB.IsChecked() ); } diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 51d3e06f5922..4c810bda1fbc 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -459,7 +459,7 @@ void SfxFrameLoader_Impl::impl_removeLoaderArguments( ::comphelper::NamedValueCo }; ::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/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx index eff0bf4bbdb6..243032fbebe7 100644 --- a/shell/source/backends/gconfbe/gconfaccess.cxx +++ b/shell/source/backends/gconfbe/gconfaccess.cxx @@ -819,8 +819,7 @@ ConfigurationValue const ConfigurationValues[] = #endif // ENABLE_LOCKDOWN }; -std::size_t const nConfigurationValues = - sizeof ConfigurationValues / sizeof ConfigurationValues[0]; +std::size_t const nConfigurationValues = SAL_N_ELEMENTS(ConfigurationValues); css::beans::Optional< css::uno::Any > getValue(ConfigurationValue const & data) { diff --git a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx index 21cd81a1cf80..bf83bb954bd5 100644 --- a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx +++ b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx @@ -53,7 +53,7 @@ namespace /* private */ {{PSGUID_SUMMARYINFORMATION, PIDSI_PAGECOUNT},VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Pagecount", L"Pagecount"} }; - size_t ColumnInfoTableSize = sizeof(ColumnInfoTable)/sizeof(ColumnInfoTable[0]); + size_t ColumnInfoTableSize = SAL_N_ELEMENTS(ColumnInfoTable); } //---------------------------- diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx index 8e7413b6cd66..8326ec38c0fa 100644 --- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -68,7 +68,7 @@ PROPERTYMAP g_rgPROPERTYMAP[] = { PKEY_Comment, L"OpenOffice.org", L"Comments" }, }; -size_t gPropertyMapTableSize = sizeof(g_rgPROPERTYMAP)/sizeof(g_rgPROPERTYMAP[0]); +size_t gPropertyMapTableSize = SAL_N_ELEMENTS(g_rgPROPERTYMAP); //---------------------------- // diff --git a/shell/source/win32/shlxthandler/util/fileextensions.cxx b/shell/source/win32/shlxthandler/util/fileextensions.cxx index 7a5c76154222..6318f9e943b0 100644 --- a/shell/source/win32/shlxthandler/util/fileextensions.cxx +++ b/shell/source/win32/shlxthandler/util/fileextensions.cxx @@ -68,7 +68,7 @@ FileExtensionEntry OOFileExtensionTable[] = { }; -size_t OOFileExtensionTableSize = sizeof(OOFileExtensionTable)/sizeof(OOFileExtensionTable[0]); +size_t OOFileExtensionTableSize = SAL_N_ELEMENTS(OOFileExtensionTable); //--------------------------------- /** Return the extension of a file diff --git a/shell/source/win32/simplemail/senddoc.cxx b/shell/source/win32/simplemail/senddoc.cxx index 0c205a25baac..72ef052a142b 100644 --- a/shell/source/win32/simplemail/senddoc.cxx +++ b/shell/source/win32/simplemail/senddoc.cxx @@ -187,7 +187,7 @@ char* KnownParameter[] = "--mapi-logon-ui" }; -const size_t nKnownParameter = (sizeof(KnownParameter)/sizeof(KnownParameter[0])); +const size_t nKnownParameter = (SAL_N_ELEMENTS(KnownParameter)); /** @internal */ bool isKnownParameter(const char* aParameterName) diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx index 487e58b4c5a9..b501d5e95c6f 100644 --- a/svx/source/dialog/docrecovery.cxx +++ b/svx/source/dialog/docrecovery.cxx @@ -1863,7 +1863,7 @@ void BrokenRecoveryDialog::impl_askForSavePath() } // loop through all the other windows and adjust their size - for ( ; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( ; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { Size aSize = (*pCurrent)->GetSizePixel(); aSize.Width() -= nDelta; @@ -1934,7 +1934,7 @@ void BrokenRecoveryDialog::impl_askForSavePath() &maProxyServerEd, &maProxyPortFT, &maProxyPortEd, &maDescriptionFT }; Window** pCurrent = pWins; - for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { Point aPos = (*pCurrent)->GetPosPixel(); aPos.Y() -= nDelta; diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 1cd87c635008..d49a792786c0 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -895,7 +895,7 @@ void SvxSearchDialog::CalculateDelta_Impl() if ( nOffset > 0 ) { long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height(); - for ( i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { if ( ( bCalcApp && i < nCalcCtrlCount ) || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() ) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 37ae1ba1322d..76d1b23ae1cf 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1696,7 +1696,7 @@ void FmXGridPeer::addColumnListeners(const Reference< XPropertySet >& xCol) Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo(); Property aPropDesc; const ::rtl::OUString* pProps = aPropsListenedTo; - const ::rtl::OUString* pPropsEnd = pProps + sizeof( aPropsListenedTo ) / sizeof( aPropsListenedTo[ 0 ] ); + const ::rtl::OUString* pPropsEnd = pProps + SAL_N_ELEMENTS( aPropsListenedTo ); for (; pProps != pPropsEnd; ++pProps) { if ( xInfo->hasPropertyByName( *pProps ) ) @@ -1719,7 +1719,7 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol) }; 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); } @@ -2765,7 +2765,7 @@ Sequence<sal_uInt16>& FmXGridPeer::getSupportedGridSlots() DbGridControl::NavigationBar::RECORD_NEW, SID_FM_RECORD_UNDO }; - aSupported.realloc(sizeof(nSupported)/sizeof(nSupported[0])); + aSupported.realloc(SAL_N_ELEMENTS(nSupported)); sal_uInt16* pSupported = aSupported.getArray(); for (sal_uInt16 i=0; i<aSupported.getLength(); ++i, ++pSupported) *pSupported = nSupported[i]; @@ -2787,7 +2787,7 @@ Sequence< ::com::sun::star::util::URL>& FmXGridPeer::getSupportedURLs() FMURL_RECORD_MOVETONEW, FMURL_RECORD_UNDO }; - aSupported.realloc(sizeof(sSupported)/sizeof(sSupported[0])); + aSupported.realloc(SAL_N_ELEMENTS(sSupported)); ::com::sun::star::util::URL* pSupported = aSupported.getArray(); sal_uInt16 i; diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 30235a49f33b..91c48d63a438 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -736,7 +736,7 @@ void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eIni 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() ); @@ -745,7 +745,7 @@ void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eIni if ( ( _eInitWhat & InitFont ) != 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; @@ -777,7 +777,7 @@ void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eIni sal_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] ) { @@ -798,7 +798,7 @@ void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eIni 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 2cc46797f91b..fee65148e79a 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -778,7 +778,7 @@ void DbGridControl::NavigationBar::StateChanged( StateChangedType nType ) case STATE_CHANGE_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; @@ -792,7 +792,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(aFont); diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index 8ae03e65cbbd..e1fc934aa4c8 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -171,7 +171,7 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const :: KEY_COLLECT, KEY_FUSION, KEY_INTERSECTION }; - sal_uInt32 nCount = sizeof Intl_TokenID / sizeof Intl_TokenID[0]; + sal_uInt32 nCount = SAL_N_ELEMENTS( Intl_TokenID ); for (sal_uInt32 i = 0; i < nCount; i++) { ::rtl::OString aKey = getIntlKeywordAscii(Intl_TokenID[i]); diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index 25f3102a115e..636ae515c49b 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -2925,7 +2925,7 @@ namespace svxform &m_aCalculateBtn }; Window** pCurrent = pWinsForHide; - for ( ; i < sizeof( pWinsForHide ) / sizeof( pWinsForHide[ 0 ] ); ++i, ++pCurrent ) + for ( ; i < SAL_N_ELEMENTS( pWinsForHide ); ++i, ++pCurrent ) (*pCurrent)->Hide(); Window* pWinsForMove[] = @@ -2933,7 +2933,7 @@ namespace svxform &m_aButtonsFL, &m_aOKBtn, &m_aEscBtn, &m_aHelpBtn }; pCurrent = pWinsForMove; - for ( i = 0; i < sizeof( pWinsForMove ) / sizeof( pWinsForMove[ 0 ] ); ++i, ++pCurrent ) + for ( i = 0; i < SAL_N_ELEMENTS( pWinsForMove ); ++i, ++pCurrent ) { Point aNewPos = (*pCurrent)->GetPosPixel(); aNewPos.Y() -= nDelta; diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index e6fd5a47a9e0..b5ae7f609e49 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -307,7 +307,7 @@ FmPropBrw::~FmPropBrw() , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ) , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "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] ); } } @@ -594,7 +594,7 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap ) ) }; m_xInspectorContext.set( - ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), + ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), xOwnContext ) ); bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx index d92754c86b99..b875acf5bf9f 100644 --- a/svx/source/form/fmdmod.cxx +++ b/svx/source/form/fmdmod.cxx @@ -87,7 +87,7 @@ using namespace ::svxform; FM_SUN_COMPONENT_IMAGECONTROL }; - static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] ); + static const sal_uInt16 nSvxComponentServiceNameListCount = SAL_N_ELEMENTS(aSvxComponentServiceNameList); ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount ); ::rtl::OUString* pStrings = aSeq.getArray(); diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index 42fe624bf80e..386ebbec87df 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -230,7 +230,7 @@ sal_Bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView, INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3, INET_PROT_VIM, INET_PROT_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 09110e2d9b0f..7e084cac3043 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -1139,7 +1139,7 @@ PopupMenu* FmXFormShell::GetConversionMenu() PopupMenu* pNewMenu = new PopupMenu(SVX_RES( RID_FMSHELL_CONVERSIONMENU )); ImageList aImageList( SVX_RES( bIsHiContrastMode ? RID_SVXIMGLIST_FMEXPL_HC : 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])); @@ -1152,7 +1152,7 @@ PopupMenu* FmXFormShell::GetConversionMenu() bool FmXFormShell::isControlConversionSlot( sal_uInt16 nSlotId ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::isControlConversionSlot" ); - 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; @@ -1190,7 +1190,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) { @@ -1406,10 +1406,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; @@ -2168,7 +2168,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], sal_False); return true; @@ -2211,7 +2211,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], sal_False ); } diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 318524005e16..6135b9ab4b30 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -596,8 +596,8 @@ void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt) FM_PROP_TEXT, FM_PROP_STATE, FM_PROP_DATE, FM_PROP_TIME, FM_PROP_VALUE, FM_PROP_SELECT_SEQ, FM_PROP_EFFECTIVE_VALUE }; - sal_Int32 nDefaultValueProps = sizeof(pDefaultValueProperties)/sizeof(pDefaultValueProperties[0]); - OSL_ENSURE(sizeof(aValueProperties)/sizeof(aValueProperties[0]) == nDefaultValueProps, + sal_Int32 nDefaultValueProps = SAL_N_ELEMENTS(pDefaultValueProperties); + OSL_ENSURE(SAL_N_ELEMENTS(aValueProperties) == nDefaultValueProps, "FmXUndoEnvironment::propertyChange: inconsistence!"); for (sal_Int32 i=0; i<nDefaultValueProps; ++i) { diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index af078e933847..afa9b8090b68 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -121,7 +121,7 @@ namespace svx { FMURL_FORM_APPLY_FILTER, SID_FM_FORM_FILTERED, FormFeature::ToggleApplyFilter }, { 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] ); } }; @@ -534,7 +534,7 @@ namespace svx SID_FM_FILTER_START, SID_FM_VIEW_AS_GRID }; - sal_Int32 nFeatureCount = sizeof( pSupportedFeatures ) / sizeof( pSupportedFeatures[ 0 ] ); + sal_Int32 nFeatureCount = SAL_N_ELEMENTS( pSupportedFeatures ); aSupportedFeatures.resize( nFeatureCount ); ::std::copy( pSupportedFeatures, pSupportedFeatures + nFeatureCount, aSupportedFeatures.begin() ); diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index 71d8d865db5f..8b7461e7660d 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -879,7 +879,7 @@ namespace { { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG }, { 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[rtl::OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id; bInited = true; } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index f4300bdd09d6..2859eaedcf18 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -551,7 +551,7 @@ String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) con { const ByteString aExt( rFileName.Copy( rFileName.Len() - 3 ), RTL_TEXTENCODING_ASCII_US ); - for( long i = 0, nCount = sizeof( aMapper ) / sizeof( aMapper[ 0 ] ); ( i < nCount ) && !aMimeType.Len(); i++ ) + for( long i = 0, nCount = SAL_N_ELEMENTS( aMapper ); ( i < nCount ) && !aMimeType.Len(); i++ ) if( aExt == aMapper[ i ].pExt ) aMimeType = String( aMapper[ i ].pMimeType, RTL_TEXTENCODING_ASCII_US ); } diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index b6a3adb89576..f1e2b0347634 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -620,7 +620,7 @@ namespace ucb { namespace ucp { namespace ext PropertyAttribute::BOUND | PropertyAttribute::READONLY ) }; - return Sequence< Property >( aProperties, sizeof( aProperties ) / sizeof( aProperties[0] ) ); + return Sequence< Property >( aProperties, SAL_N_ELEMENTS( aProperties )); } //------------------------------------------------------------------------------------------------------------------ diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx index b8ed01b9ed8e..cfdd14b70773 100644 --- a/ucb/source/ucp/gio/gio_content.cxx +++ b/ucb/source/ucp/gio/gio_content.cxx @@ -1255,7 +1255,7 @@ uno::Sequence< beans::Property > Content::getProperties( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) }; - const int nProps = sizeof (aGenericProperties) / sizeof (aGenericProperties[0]); + const int nProps = SAL_N_ELEMENTS(aGenericProperties); return uno::Sequence< beans::Property > ( aGenericProperties, nProps ); } @@ -1297,7 +1297,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< uc -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) ) }; - const int nProps = sizeof (aCommandInfoTable) / sizeof (aCommandInfoTable[0]); + const int nProps = SAL_N_ELEMENTS(aCommandInfoTable); return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2); } diff --git a/ucb/source/ucp/gvfs/gvfs_content.cxx b/ucb/source/ucp/gvfs/gvfs_content.cxx index 748751f34de1..a9f94f0768e0 100644 --- a/ucb/source/ucp/gvfs/gvfs_content.cxx +++ b/ucb/source/ucp/gvfs/gvfs_content.cxx @@ -1355,7 +1355,7 @@ uno::Sequence< beans::Property > Content::getProperties( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) }; - const int nProps = sizeof (aGenericProperties) / sizeof (aGenericProperties[0]); + const int nProps = SAL_N_ELEMENTS(aGenericProperties); return uno::Sequence< beans::Property > ( aGenericProperties, nProps ); @@ -1399,8 +1399,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) ) }; - const int nProps - = sizeof( aCommandInfoTable ) / sizeof( aCommandInfoTable[ 0 ] ); + const int nProps = SAL_N_ELEMENTS( aCommandInfoTable ); return uno::Sequence< ucb::CommandInfo >( aCommandInfoTable, isFolder( xEnv ) ? nProps : nProps - 2 ); } diff --git a/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx b/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx index 4dbbd97e6298..aae23c0adf18 100644 --- a/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx +++ b/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx @@ -78,10 +78,10 @@ using namespace hierarchy_ucp; //========================================================================= #define MAKEPROPSEQUENCE( a ) \ - uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) ) #define MAKECMDSEQUENCE( a ) \ - uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) ) //========================================================================= // diff --git a/ucb/source/ucp/package/pkgcontentcaps.cxx b/ucb/source/ucp/package/pkgcontentcaps.cxx index 9b8e0e51b146..84eabe6f5b37 100644 --- a/ucb/source/ucp/package/pkgcontentcaps.cxx +++ b/ucb/source/ucp/package/pkgcontentcaps.cxx @@ -79,10 +79,10 @@ using namespace package_ucp; //========================================================================= #define MAKEPROPSEQUENCE( a ) \ - uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< beans::Property >( a, SAL_N_ELEMENTS( a ) ) #define MAKECMDSEQUENCE( a ) \ - uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) ) //========================================================================= // diff --git a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx index 2bf29b150ed5..bd8ed490fb8d 100644 --- a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx +++ b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx @@ -89,10 +89,10 @@ using namespace tdoc_ucp; //========================================================================= #define MAKEPROPSEQUENCE( a ) \ - uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< beans::Property >( a, SAL_N_ELEMTS( a ) ) #define MAKECMDSEQUENCE( a ) \ - uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS( a ) ) //========================================================================= // diff --git a/uui/source/masterpasscrtdlg.cxx b/uui/source/masterpasscrtdlg.cxx index 9d027f89ffbc..c96e319fb5fe 100644 --- a/uui/source/masterpasscrtdlg.cxx +++ b/uui/source/masterpasscrtdlg.cxx @@ -126,7 +126,7 @@ MasterPasswordCreateDialog::MasterPasswordCreateDialog aFTMasterPasswordWarning.SetPosSizePixel( aFTMasterPasswordWarning.GetPosPixel(), aNewWarningSize ); Window* pControls[] = { &aFL, &aOKBtn, &aCancelBtn, &aHelpBtn }; - const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[0] ); + const sal_Int32 nCCount = SAL_N_ELEMENTS( pControls ); for ( int i = 0; i < nCCount; ++i ) { Point aNewPos =(*pControls[i]).GetPosPixel(); @@ -149,7 +149,7 @@ void MasterPasswordCreateDialog::CalculateTextHeight() &aFTMasterPasswordRepeat, &aEDMasterPasswordRepeat, &aFTCautionText, &aFLCautionText, &aOKBtn, &aCancelBtn, &aHelpBtn }; Window** pWindow = pWins; - const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[0] ); + const sal_Int32 nCount = SAL_N_ELEMENTS( pWins ); for ( sal_Int32 i = 0; i < nCount; ++i, ++pWindow ) { Point aNewPos = (*pWindow)->GetPosPixel(); @@ -168,7 +168,7 @@ void MasterPasswordCreateDialog::CalculateTextHeight() nDelta += nTemp; Window* pWins[] = { &aFLCautionText, &aOKBtn, &aCancelBtn, &aHelpBtn }; Window** pWindow = pWins; - const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[0] ); + const sal_Int32 nCount = SAL_N_ELEMENTS( pWins ); for ( sal_Int32 i = 0; i < nCount; ++i, ++pWindow ) { Point aNewPos = (*pWindow)->GetPosPixel(); diff --git a/uui/source/passcrtdlg.cxx b/uui/source/passcrtdlg.cxx index 843d3bf15263..77b14f3bf38f 100644 --- a/uui/source/passcrtdlg.cxx +++ b/uui/source/passcrtdlg.cxx @@ -115,7 +115,7 @@ PasswordCreateDialog::PasswordCreateDialog( Window* _pParent, ResMgr * pResMgr, aFTWarning.SetPosSizePixel( aFTWarning.GetPosPixel(), aNewWarningSize ); Window* pControls[] = { &aFixedLine1, &aOKBtn, &aCancelBtn, &aHelpBtn }; - const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[0] ); + const sal_Int32 nCCount = SAL_N_ELEMENTS( pControls ); for ( int i = 0; i < nCCount; ++i ) { Point aNewPos =(*pControls[i]).GetPosPixel(); diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx index 34d886ca2e26..bb81e612e086 100644 --- a/uui/source/passworddlg.cxx +++ b/uui/source/passworddlg.cxx @@ -103,7 +103,7 @@ PasswordDialog::PasswordDialog( aFTPassword.SetPosSizePixel( aFTPassword.GetPosPixel(), aNewLabelSize ); Window* pControls[] = { &aEDPassword, &aFixedLine1, &aOKBtn, &aCancelBtn, &aHelpBtn }; - const sal_Int32 nCCount = sizeof( pControls ) / sizeof( pControls[0] ); + const sal_Int32 nCCount = SAL_N_ELEMENTS( pControls ); for ( int i = 0; i < nCCount; ++i ) { Point aNewPos =(*pControls[i]).GetPosPixel(); diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index e384dc7dfabc..6447cc20526e 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -225,7 +225,7 @@ void MacroWarning::InitControls() &maBottomSepFL, &maEnableBtn, &maDisableBtn, &maHelpBtn }; Window** pCurrent = pWins; - for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { Point aNewPos = (*pCurrent)->GetPosPixel(); aNewPos.Y() -= nDelta; @@ -323,7 +323,7 @@ void MacroWarning::FitControls() &maDescr2FI, &maAlwaysTrustCB, &maBottomSepFL, &maEnableBtn, &maDisableBtn, &maHelpBtn }; Window** pCurrent = pWins; - for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) + for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent ) { Point aNewPos = (*pCurrent)->GetPosPixel(); aNewPos.Y() -= nDelta; diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 1320cf046d8b..7daed9e574c1 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -352,7 +352,7 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, con // handle the arguments const uno::Any* aArgsPtrArray[] = { &varg1, &varg2, &varg3, &varg4, &varg5, &varg6, &varg7, &varg8, &varg9, &varg10, &varg11, &varg12, &varg13, &varg14, &varg15, &varg16, &varg17, &varg18, &varg19, &varg20, &varg21, &varg22, &varg23, &varg24, &varg25, &varg26, &varg27, &varg28, &varg29, &varg30 }; - int nArg = sizeof( aArgsPtrArray ) / sizeof( aArgsPtrArray[0] ); + int nArg = SAL_N_ELEMENTS( aArgsPtrArray ); uno::Sequence< uno::Any > aArgs( nArg ); const uno::Any** pArg = aArgsPtrArray; diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index e64085bd0991..767049396db4 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -60,7 +60,7 @@ const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& s }; // don't pass a delegate, this seems to introduce yet another cyclic dependency ( and // some strange behavior - mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), NULL ); + mxContext = ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), NULL ); } VbaGlobalsBase::~VbaGlobalsBase() @@ -137,7 +137,7 @@ VbaGlobalsBase::getAvailableServiceNames( ) throw (uno::RuntimeException) // common ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.msforms.UserForm" ) ), }; - static uno::Sequence< rtl::OUString > serviceNames( names, sizeof( names )/ sizeof( names[0] ) ); + static uno::Sequence< rtl::OUString > serviceNames( names, SAL_N_ELEMENTS( names ) ); return serviceNames; } diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index e6cce2937a90..02d6d5f8f48d 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3157,7 +3157,7 @@ namespace xmloff { namespace token { #endif DBG_ASSERT( eToken > XML_TOKEN_INVALID, "token value too low!" ); DBG_ASSERT( eToken < XML_TOKEN_END, "token value too high!" ); - DBG_ASSERT(sal_uInt16(eToken) < sizeof(aTokenList)/sizeof(aTokenList[0]),"Illegal position!"); + DBG_ASSERT(sal_uInt16(eToken) < SAL_N_ELEMENTS(aTokenList),"Illegal position!"); XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken]; if (!pToken->pOUString) diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 563ac7fa6aff..90c1243f51b3 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -500,11 +500,10 @@ 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( @@ -535,13 +534,13 @@ namespace xmloff BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE | BOOLATTR_INVERSE_SEMANTICS, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_VOID, BOOLATTR_DEFAULT_FALSE }; #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]); - sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); - sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); + sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); + sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags); 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( @@ -578,13 +577,13 @@ namespace xmloff exportedProperty(PROPERTY_MAXTEXTLENGTH); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nIdCount = sizeof(nIntegerPropertyAttributeIds) / sizeof(nIntegerPropertyAttributeIds[0]); - sal_Int32 nNameCount = sizeof(pIntegerPropertyNames) / sizeof(pIntegerPropertyNames[0]); - sal_Int32 nDefaultCount = sizeof(nIntegerPropertyAttrDefaults) / sizeof(nIntegerPropertyAttrDefaults[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(nIntegerPropertyAttributeIds); + sal_Int32 nNameCount = SAL_N_ELEMENTS(pIntegerPropertyNames); + sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nIntegerPropertyAttrDefaults); 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( @@ -933,9 +932,9 @@ namespace xmloff &PROPERTY_STRICTFORMAT, &PROPERTY_MULTILINE, &PROPERTY_AUTOCOMPLETE, &PROPERTY_MULTISELECTION, &PROPERTY_DEFAULTBUTTON, &PROPERTY_TRISTATE, &PROPERTY_TOGGLE, &PROPERTY_FOCUS_ON_CLICK }; - sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); + sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); OSL_ENSURE((nIdCount == nNameCount), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!"); #endif @@ -975,12 +974,12 @@ namespace xmloff 10 }; - sal_Int32 nIdCount = sizeof( nIntegerPropertyAttributeIds ) / sizeof( nIntegerPropertyAttributeIds[0] ); + sal_Int32 nIdCount = SAL_N_ELEMENTS( nIntegerPropertyAttributeIds ); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof( pIntegerPropertyNames ) / sizeof( pIntegerPropertyNames[0] ); + sal_Int32 nNameCount = SAL_N_ELEMENTS( pIntegerPropertyNames ); OSL_ENSURE( ( nIdCount == nNameCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" ); - sal_Int32 nDefaultCount = sizeof( nIntegerPropertyAttrDefaults ) / sizeof( nIntegerPropertyAttrDefaults[0] ); + sal_Int32 nDefaultCount = SAL_N_ELEMENTS( nIntegerPropertyAttrDefaults ); OSL_ENSURE( ( nIdCount == nDefaultCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" ); #endif @@ -1119,9 +1118,9 @@ namespace xmloff &PROPERTY_GROUP_NAME }; - sal_Int32 nIdCount = sizeof( nStringPropertyAttributeIds ) / sizeof( nStringPropertyAttributeIds[0] ); + sal_Int32 nIdCount = SAL_N_ELEMENTS( nStringPropertyAttributeIds ); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof( pStringPropertyNames ) / sizeof( pStringPropertyNames[0] ); + sal_Int32 nNameCount = SAL_N_ELEMENTS( pStringPropertyNames ); OSL_ENSURE( ( nIdCount == nNameCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" ); #endif @@ -2058,9 +2057,9 @@ namespace xmloff { PROPERTY_NAME, /*PROPERTY_TARGETURL,*/ PROPERTY_COMMAND, PROPERTY_FILTER, PROPERTY_ORDER }; - sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(eStringPropertyIds); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof(aStringPropertyNames) / sizeof(aStringPropertyNames[0]); + sal_Int32 nNameCount = SAL_N_ELEMENTS(aStringPropertyNames); OSL_ENSURE((nIdCount == nNameCount), "OFormExport::exportAttributes: somebody tampered with the maps (1)!"); #endif @@ -2107,10 +2106,10 @@ namespace xmloff { BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE }; - sal_Int32 nIdCount = sizeof(eBooleanPropertyIds) / sizeof(eBooleanPropertyIds[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(eBooleanPropertyIds); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); - sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]); + sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); + sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags); OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount), "OFormExport::exportAttributes: somebody tampered with the maps (2)!"); #endif @@ -2146,12 +2145,12 @@ namespace xmloff { sal_False, sal_False, sal_False, sal_False, sal_True }; - sal_Int32 nIdCount = sizeof(eEnumPropertyIds) / sizeof(eEnumPropertyIds[0]); + sal_Int32 nIdCount = SAL_N_ELEMENTS(eEnumPropertyIds); #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nNameCount = sizeof(pEnumPropertyNames) / sizeof(pEnumPropertyNames[0]); - sal_Int32 nDefaultCount = sizeof(nEnumPropertyAttrDefaults) / sizeof(nEnumPropertyAttrDefaults[0]); - sal_Int32 nDefaultFlagCount = sizeof(nEnumPropertyAttrDefaultFlags) / sizeof(nEnumPropertyAttrDefaultFlags[0]); - sal_Int32 nMapCount = sizeof(eEnumPropertyMaps) / sizeof(eEnumPropertyMaps[0]); + sal_Int32 nNameCount = SAL_N_ELEMENTS(pEnumPropertyNames); + sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nEnumPropertyAttrDefaults); + sal_Int32 nDefaultFlagCount = SAL_N_ELEMENTS(nEnumPropertyAttrDefaultFlags); + sal_Int32 nMapCount = SAL_N_ELEMENTS(eEnumPropertyMaps); OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount) && (nDefaultCount == nDefaultFlagCount) && (nDefaultFlagCount == nMapCount), "OFormExport::exportAttributes: somebody tampered with the maps (3)!"); #endif |