diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-03-29 10:25:17 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-03-31 11:30:36 +0200 |
commit | 6439005484bdf6754b910b1ce025b3fb33b6623f (patch) | |
tree | 1a00f48ae11d3da3d928f2d3d68b3e299216328c | |
parent | 1aa4df615fa5599d05e9dd5e925b5852676185fa (diff) |
use SAL_N_ELEMENTS more widely
found using
git grep -n 'sizeof.*/.*sizeof.*[0]'
Change-Id: Icd4a6cc1ca8ec8ebd68e1701a02789c74cf0eb2a
101 files changed, 252 insertions, 265 deletions
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx index da663e1fdcae..45189d7e0000 100644 --- a/avmedia/source/vlc/vlcframegrabber.cxx +++ b/avmedia/source/vlc/vlcframegrabber.cxx @@ -59,7 +59,7 @@ namespace VLCFrameGrabber::VLCFrameGrabber( wrapper::EventHandler& eh, const rtl::OUString& url ) : FrameGrabber_BASE() - , mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ) + , mInstance( SAL_N_ELEMENTS(VLC_ARGS), VLC_ARGS ) , mMedia( url, mInstance ) , mPlayer( mMedia ) , mEventHandler( eh ) diff --git a/avmedia/source/vlc/vlcmanager.cxx b/avmedia/source/vlc/vlcmanager.cxx index abdfaf260460..cc9bc840cfec 100644 --- a/avmedia/source/vlc/vlcmanager.cxx +++ b/avmedia/source/vlc/vlcmanager.cxx @@ -49,7 +49,7 @@ Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) m_is_vlc_found = success; if (m_is_vlc_found) { - mInstance.reset(new Instance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS )); + mInstance.reset(new Instance( SAL_N_ELEMENTS(VLC_ARGS) ), VLC_ARGS )); //Check VLC version std::vector<std::string> verComponents; const std::string str(Common::Version()); diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 26f857fe8948..f1a66cf791d1 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -336,8 +336,7 @@ namespace dbtools if ( !bSupport ) { const OUString url = m_pImpl->xConnectionMetaData->getURL(); - char pMySQL[] = "sdbc:mysql"; - bSupport = url.matchAsciiL(pMySQL,(sizeof(pMySQL)/sizeof(pMySQL[0]))-1); + bSupport = url.startsWith("sdbc:mysql"); } } catch( const Exception& ) diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index bed72dd5831e..bde92c9b67f4 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -1628,7 +1628,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; @@ -1668,7 +1668,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; @@ -1710,7 +1710,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; @@ -1750,7 +1750,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; @@ -1792,7 +1792,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; @@ -1838,7 +1838,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; @@ -1887,7 +1887,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; @@ -1928,7 +1928,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; @@ -2000,7 +2000,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; @@ -2037,7 +2037,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; @@ -2081,7 +2081,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; @@ -2116,7 +2116,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/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx index ffc95798a3cf..66a399bdedcd 100644 --- a/connectivity/source/drivers/postgresql/pq_statics.cxx +++ b/connectivity/source/drivers/postgresql/pq_statics.cxx @@ -217,7 +217,7 @@ Statics & getStatics() PropertyDef( statics.SCHEMA_NAME , tString ) }; statics.refl.tableDescriptor.pProps = createPropertyArrayHelper( - tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 ); + tableDescDef, SAL_N_ELEMENTS(tableDescDef), 0 ); // Column props set statics.refl.column.implName = "org.openoffice.comp.pq.sdbcx.Column"; @@ -265,7 +265,7 @@ Statics & getStatics() }; statics.refl.columnDescriptor.pProps = createPropertyArrayHelper( - columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 ); + columnDescDef, SAL_N_ELEMENTS(columnDescDef), 0 ); // Key properties statics.refl.key.implName = "org.openoffice.comp.pq.sdbcx.Key"; @@ -300,7 +300,7 @@ Statics & getStatics() PropertyDef( statics.UPDATE_RULE, tInt ) }; statics.refl.keyDescriptor.pProps = createPropertyArrayHelper( - keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 ); + keyDescDef, SAL_N_ELEMENTS(keyDescDef), 0 ); // KeyColumn props set @@ -338,7 +338,7 @@ Statics & getStatics() PropertyDef( statics.RELATED_COLUMN, tString ) }; statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper( - keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 ); + keycolumnDescDef, SAL_N_ELEMENTS(keycolumnDescDef), 0 ); // view props set statics.refl.view.implName = "org.openoffice.comp.pq.sdbcx.View"; @@ -360,7 +360,7 @@ Statics & getStatics() statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 ); statics.refl.viewDescriptor.serviceNames[0] = "com.sun.star.sdbcx.ViewDescriptor"; statics.refl.viewDescriptor.pProps = createPropertyArrayHelper( - viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical + viewDef, SAL_N_ELEMENTS(viewDef), 0 ); // reuse view, as it is identical // user props set statics.refl.user.implName = "org.openoffice.comp.pq.sdbcx.User"; statics.refl.user.serviceNames = Sequence< OUString > ( 1 ); @@ -384,7 +384,7 @@ Statics & getStatics() PropertyDef( statics.PASSWORD , tString ) }; statics.refl.userDescriptor.pProps = createPropertyArrayHelper( - userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 ); + userDefWR, SAL_N_ELEMENTS(userDefWR), 0 ); // index props set statics.refl.index.implName = "org.openoffice.comp.pq.sdbcx.Index"; @@ -409,7 +409,7 @@ Statics & getStatics() statics.refl.indexDescriptor.serviceNames[0] = "com.sun.star.sdbcx.IndexDescriptor"; statics.refl.indexDescriptor.pProps = createPropertyArrayHelper( - indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 ); + indexDef, SAL_N_ELEMENTS(indexDef), 0 ); // indexColumn props set statics.refl.indexColumn.implName = "org.openoffice.comp.pq.sdbcx.IndexColumn"; @@ -446,7 +446,7 @@ Statics & getStatics() PropertyDef( statics.NAME , tString ) }; statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper( - indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 ); + indexColumnDescDef, SAL_N_ELEMENTS(indexColumnDescDef), 0 ); // resultset statics.refl.resultSet.implName = "org.openoffice.comp.pq.ResultSet"; @@ -464,7 +464,7 @@ Statics & getStatics() PropertyDef( statics.RESULT_SET_TYPE , tInt ) }; statics.refl.resultSet.pProps = createPropertyArrayHelper( - resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + resultSet, SAL_N_ELEMENTS(resultSet), 0 ); // updateableResultset statics.refl.updateableResultSet.implName = "org.openoffice.comp.pq.UpdateableResultSet"; @@ -472,7 +472,7 @@ Statics & getStatics() statics.refl.updateableResultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet"; statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ ); statics.refl.updateableResultSet.pProps = createPropertyArrayHelper( - resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + resultSet, SAL_N_ELEMENTS(resultSet), 0 ); // databasemetadata statics.tablesRowNames = std::vector< OUString > ( 5 ); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 57db13ec1158..e203e644758f 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1331,7 +1331,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: static_assert(OSQLParseNode::UNKNOWN_RULE==0, "UNKNOWN_RULE must be 0 for memset to 0 to work"); memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs)); - struct + const struct { OSQLParseNode::Rule eRule; // the parse node's ID for the rule OString sRuleName; // the name of the rule ("select_statement") @@ -1439,7 +1439,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::cast_spec, "cast_spec" }, { OSQLParseNode::window_function, "window_function" } }; - const size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); + const size_t nRuleMapCount = SAL_N_ELEMENTS( aRuleDescriptions ); // added a new rule? Adjust this map! // +1 for UNKNOWN_RULE static_assert(nRuleMapCount + 1 == static_cast<size_t>(OSQLParseNode::rule_count), "must be equal"); diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx index 31564763122f..101b9e92b606 100644 --- a/cui/source/options/optcolor.cxx +++ b/cui/source/options/optcolor.cxx @@ -633,7 +633,7 @@ void ColorConfigWindow_Impl::SetAppearance () vEntries[i]->SetTextColor(aRCheckCol); } - OSL_ENSURE( vEntries.size() >= sizeof vEntryInfo / sizeof vEntryInfo[0], "wrong number of helpIDs for color listboxes" ); + OSL_ENSURE( vEntries.size() >= SAL_N_ELEMENTS(vEntryInfo), "wrong number of helpIDs for color listboxes" ); // creating a sample color listbox with the color entries ScopedVclPtrInstance< ColorListBox > aSampleColorList(this); diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 3cbac3de7189..f0a5b97a053b 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -337,7 +337,7 @@ ObjectType OTableContainer::appendObject( const OUString& _rForName, const Refer , OUString(PROPERTY_ROW_HEIGHT), OUString(PROPERTY_TEXTCOLOR) , OUString(PROPERTY_TEXTLINECOLOR), OUString(PROPERTY_TEXTEMPHASIS) , OUString(PROPERTY_TEXTRELIEF) }; - Sequence< OUString> aNames(s_pTableProps,sizeof(s_pTableProps)/sizeof(s_pTableProps[0])); + Sequence< OUString> aNames(s_pTableProps, SAL_N_ELEMENTS(s_pTableProps)); if ( bModified || !lcl_isPropertySetDefaulted(aNames,xTableDefinition) ) ::dbaccess::notifyDataSourceModified(m_xTableDefinitions,true); diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 2e71809c1f75..8efb513ba073 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -787,7 +787,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(bool _bHasCategor if ( !nRowCount ) { nRowCount = 3; - const double fDefaultData[ ] = + static const double fDefaultData[ ] = { 9.10, 3.20, 4.54, 2.40, 8.80, 9.65, 3.10, 1.50, 3.70, @@ -796,7 +796,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(bool _bHasCategor { aRowLabels.push_back(OUString::number(h+1)); ::std::vector< double > aRow; - const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); + const sal_Int32 nSize = SAL_N_ELEMENTS(fDefaultData); for (size_t j = 0; j < (aColumns.size()-1); ++j,++k) { if ( k >= nSize ) diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 6439cd797ff8..19d51528df6a 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -1153,11 +1153,11 @@ namespace "com.sun.star.formula.FormularProperties", "smath", "com.sun.star.chart.ChartDocument", "schart" }; - OSL_ENSURE( ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) % 2 == 0, + OSL_ENSURE( SAL_N_ELEMENTS( pTransTable ) % 2 == 0, "lcl_getModuleHelpModuleName: odd size of translation table!" ); // loop through the table - sal_Int32 nTableEntries = ( sizeof( pTransTable ) / sizeof( pTransTable[0] ) ) / 2; + sal_Int32 nTableEntries = SAL_N_ELEMENTS( pTransTable ) / 2; const sal_Char** pDocumentService = pTransTable; const sal_Char** pHelpModuleName = pTransTable + 1; for ( sal_Int32 j=0; j<nTableEntries; ++j ) diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index ac87241dad9b..6ba1e0799d9b 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -434,7 +434,7 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp {0,false} }; - OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == DSID_LAST_ITEM_ID,"Invalid Ids!"); + OSL_ENSURE(SAL_N_ELEMENTS(aItemInfos) == DSID_LAST_ITEM_ID,"Invalid Ids!"); _rpPool = new SfxItemPool(OUString("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID, aItemInfos, _rppDefaults); _rpPool->FreezeIdRanges(); diff --git a/dbaccess/source/ui/querydesign/LimitBox.cxx b/dbaccess/source/ui/querydesign/LimitBox.cxx index 445d0380a91f..a5047cf6abcd 100644 --- a/dbaccess/source/ui/querydesign/LimitBox.cxx +++ b/dbaccess/source/ui/querydesign/LimitBox.cxx @@ -100,8 +100,7 @@ void LimitBox::LoadDefaultLimits() { InsertValue( ALL_INT ); - const unsigned nSize = - sizeof(global::aDefLimitAry)/sizeof(global::aDefLimitAry[0]); + const unsigned nSize = SAL_N_ELEMENTS(global::aDefLimitAry); for( unsigned nIndex = 0; nIndex< nSize; ++nIndex) { InsertValue( global::aDefLimitAry[nIndex] ); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 255792cd56f3..234838971c0a 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2090,7 +2090,7 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const { sal_Int32 nErg(0); // only the first 11 row are interesting - sal_Int32 nSize = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]); + sal_Int32 nSize = SAL_N_ELEMENTS(nVisibleRowMask); for(sal_Int32 i=0;i<nSize;i++) { if(!m_bVisibleRow[i]) @@ -2102,7 +2102,7 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const void OSelectionBrowseBox::SetNoneVisbleRow(long nRows) { // only the first 11 row are interesting - sal_Int32 nSize = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]); + sal_Int32 nSize = SAL_N_ELEMENTS(nVisibleRowMask); for(sal_Int32 i=0;i< nSize;i++) m_bVisibleRow[i] = !(nRows & nVisibleRowMask[i]); } diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 58463e6fee62..af172944b8d5 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -132,7 +132,7 @@ LanguageType EditView::CheckLanguage( lang::Locale a3( LanguageTag::convertToLocale( aLangList[3] ) ); #endif - sal_Int32 nCount = sizeof (aLangList) / sizeof (aLangList[0]); + sal_Int32 nCount = SAL_N_ELEMENTS(aLangList); for (sal_Int32 i = 0; i < nCount; i++) { sal_Int16 nTmpLang = aLangList[i]; diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index ba0e03e194ff..2560e39ca3aa 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -365,7 +365,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) { @@ -405,7 +405,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) { @@ -415,7 +415,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) { @@ -475,7 +475,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 (sal_uInt16 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 e2ebc2777c53..c373cc93dca9 100644 --- a/fpicker/source/office/OfficeControlAccess.cxx +++ b/fpicker/source/office/OfficeControlAccess.cxx @@ -106,7 +106,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; @@ -142,7 +142,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/win32/filepicker/controlaccess.cxx b/fpicker/source/win32/filepicker/controlaccess.cxx index 4dc8950566d1..51dbbdd7f001 100644 --- a/fpicker/source/win32/filepicker/controlaccess.cxx +++ b/fpicker/source/win32/filepicker/controlaccess.cxx @@ -143,7 +143,7 @@ namespace // private return CtrlClassGetValueFunctionTable[aCtrlClass]; } - int WindowsFileOpenCtrlIds[] = + const int WindowsFileOpenCtrlIds[] = { 0, IDOK, // PUSHBUTTON_OK @@ -154,8 +154,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/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index 5f5925873a8a..e3cb6b54f176 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -101,13 +101,13 @@ struct MenuStyleItem const char* attrName; }; -MenuStyleItem MenuItemStyles[ ] = { +const MenuStyleItem MenuItemStyles[ ] = { { css::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE }, { css::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, { css::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO } }; -sal_Int32 nMenuStyleItemEntries = (sizeof (MenuItemStyles) / sizeof (MenuItemStyles[0])); +sal_Int32 nMenuStyleItemEntries = SAL_N_ELEMENTS(MenuItemStyles); static void ExtractMenuParameters( const Sequence< PropertyValue >& rProp, OUString& rCommandURL, @@ -904,7 +904,7 @@ void OWriteMenuDocumentHandler::WriteMenuItem( const OUString& aCommandURL, cons if ( nStyle > 0 ) { OUString aValue; - MenuStyleItem* pStyle = MenuItemStyles; + const MenuStyleItem* pStyle = MenuItemStyles; for ( sal_Int32 nIndex = 0; nIndex < nMenuStyleItemEntries; ++nIndex, ++pStyle ) { diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx index c00266227ad4..2fcf4b13385c 100644 --- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx +++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx @@ -88,7 +88,7 @@ struct ToolboxStyleItem const char* attrName; }; -ToolboxStyleItem Styles[ ] = { +const ToolboxStyleItem Styles[ ] = { { css::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO }, { css::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT }, { css::ui::ItemStyle::AUTO_SIZE, ATTRIBUTE_ITEMSTYLE_AUTO }, @@ -99,7 +99,7 @@ ToolboxStyleItem Styles[ ] = { { css::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, }; -sal_Int32 nStyleItemEntries = sizeof (Styles) / sizeof (Styles[0]); +sal_Int32 nStyleItemEntries = SAL_N_ELEMENTS(Styles); struct ToolBarEntryProperty { @@ -757,7 +757,7 @@ throw ( SAXException, RuntimeException ) if ( nStyle > 0 ) { OUString aValue; - ToolboxStyleItem* pStyle = Styles; + const ToolboxStyleItem* pStyle = Styles; for ( sal_Int32 nIndex = 0; nIndex < nStyleItemEntries; ++nIndex, ++pStyle ) { diff --git a/hwpfilter/source/mapping.h b/hwpfilter/source/mapping.h index e8d6c0d33a7c..6a6fb8a912f4 100644 --- a/hwpfilter/source/mapping.h +++ b/hwpfilter/source/mapping.h @@ -363,7 +363,7 @@ const struct FormulaEntry FormulaMapTab[] = { #ifndef DEBUG hchar_string getMathMLEntity(const char *tex) { - static const size_t tabSize = sizeof(FormulaMapTab) / sizeof(FormulaMapTab[0]); + static const size_t tabSize = SAL_N_ELEMENTS(FormulaMapTab); hchar_string buf; for (size_t i = 0 ; i < tabSize ; i++) { diff --git a/i18nutil/source/utility/paper.cxx b/i18nutil/source/utility/paper.cxx index 93f81ce58673..09440f46be6d 100644 --- a/i18nutil/source/utility/paper.cxx +++ b/i18nutil/source/utility/paper.cxx @@ -347,7 +347,7 @@ PaperInfo PaperInfo::getSystemDefaultPaper() PaperInfo::PaperInfo(Paper eType) : m_eType(eType) { - OSL_ENSURE( sizeof(aDinTab) / sizeof(aDinTab[0]) == NUM_PAPER_ENTRIES, + OSL_ENSURE( SAL_N_ELEMENTS(aDinTab) == NUM_PAPER_ENTRIES, "mismatch between array entries and enum values" ); m_nPaperWidth = aDinTab[m_eType].m_nWidth; diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 92e27b2a36f3..22b475ec56b3 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -126,7 +126,7 @@ static const sal_Unicode aWhiteSpaces[] = 0xfffb /* INTERLINEAR ANNOTATION TERMINATOR */ }; -static const int nWhiteSpaces = sizeof( aWhiteSpaces ) / sizeof( aWhiteSpaces[0] ); +static const 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 4c5f832a4255..891164b5feaa 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -126,7 +126,7 @@ OUString LinguOptions::GetName( sal_Int32 nWID ) OUString aRes; - sal_Int32 nLen = sizeof (aWID_Name) / sizeof (aWID_Name[0]); + sal_Int32 nLen = SAL_N_ELEMENTS(aWID_Name); if (0 <= nWID && nWID < nLen && aWID_Name[ nWID ].nWID == nWID) aRes = OUString::createFromAscii(aWID_Name[nWID].pPropertyName); else diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx index 68851a0e1b23..8dccc52a1627 100644 --- a/linguistic/source/lngprophelp.cxx +++ b/linguistic/source/lngprophelp.cxx @@ -51,7 +51,7 @@ static const char *aCH[] = UPN_IS_USE_DICTIONARY_LIST, }; -static const int nCHCount = sizeof(aCH) / sizeof(aCH[0]); +static const int nCHCount = SAL_N_ELEMENTS(aCH); PropertyChgHelper::PropertyChgHelper( @@ -344,7 +344,7 @@ PropertyHelper_Spell::PropertyHelper_Spell( Reference< XLinguProperties > &rxPropSet ) : PropertyChgHelper ( rxSource, rxPropSet, AE_SPELLCHECKER ) { - AddPropNames( aSP, sizeof(aSP) / sizeof(aSP[0]) ); + AddPropNames( aSP, SAL_N_ELEMENTS(aSP) ); SetDefaultValues(); GetCurrentValues(); @@ -526,7 +526,7 @@ PropertyHelper_Hyphen::PropertyHelper_Hyphen( Reference< XLinguProperties > &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 ba7bf6230e38..a44fb0ed10ca 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -681,7 +681,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 8ff57ef41601..e957a06742fe 100644 --- a/linguistic/workben/sprophelp.cxx +++ b/linguistic/workben/sprophelp.cxx @@ -174,7 +174,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(); sal_Int32 nLen = GetPropNames().getLength(); diff --git a/onlineupdate/source/update/common/uachelper.cxx b/onlineupdate/source/update/common/uachelper.cxx index 4cae3ad4e5fc..6937e0003109 100644 --- a/onlineupdate/source/update/common/uachelper.cxx +++ b/onlineupdate/source/update/common/uachelper.cxx @@ -191,7 +191,7 @@ BOOL UACHelper::DisablePrivileges(HANDLE token) { static const size_t PrivsToDisableSize = - sizeof(UACHelper::PrivsToDisable) / sizeof(UACHelper::PrivsToDisable[0]); + SAL_N_ELEMENTS(UACHelper::PrivsToDisable); return DisableUnneededPrivileges(token, UACHelper::PrivsToDisable, PrivsToDisableSize); diff --git a/onlineupdate/source/update/common/updatehelper.cxx b/onlineupdate/source/update/common/updatehelper.cxx index c10ea8d580d4..704dde8224c5 100644 --- a/onlineupdate/source/update/common/updatehelper.cxx +++ b/onlineupdate/source/update/common/updatehelper.cxx @@ -100,7 +100,7 @@ LaunchWinPostProcess(const WCHAR *installationDir, if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeAsync", L"TRUE", exeasync, - sizeof(exeasync)/sizeof(exeasync[0]), + SAL_N_ELEMENTS(exeasync), inifile)) { return FALSE; } @@ -123,7 +123,7 @@ LaunchWinPostProcess(const WCHAR *installationDir, } WCHAR dummyArg[14] = { L'\0' }; - wcsncpy(dummyArg, L"argv0ignored ", sizeof(dummyArg) / sizeof(dummyArg[0]) - 1); + wcsncpy(dummyArg, L"argv0ignored ", SAL_N_ELEMENTS(dummyArg) - 1); size_t len = wcslen(exearg) + wcslen(dummyArg); WCHAR *cmdline = (WCHAR *) malloc((len + 1) * sizeof(WCHAR)); @@ -266,8 +266,7 @@ StartServiceUpdate(LPCWSTR installDir) si.lpDesktop = L""; PROCESS_INFORMATION pi = {0}; WCHAR cmdLine[64] = { '\0' }; - wcsncpy(cmdLine, L"dummyparam.exe upgrade", - sizeof(cmdLine) / sizeof(cmdLine[0]) - 1); + wcsncpy(cmdLine, L"dummyparam.exe upgrade", SAL_N_ELEMENTS(cmdLine) - 1); BOOL svcUpdateProcessStarted = CreateProcessW(tmpService, cmdLine, nullptr, nullptr, FALSE, diff --git a/onlineupdate/source/update/common/updatelogging.cxx b/onlineupdate/source/update/common/updatelogging.cxx index 22a74e17e953..c1ffcb00a3ab 100644 --- a/onlineupdate/source/update/common/updatelogging.cxx +++ b/onlineupdate/source/update/common/updatelogging.cxx @@ -30,11 +30,11 @@ void UpdateLog::Init(NS_tchar* sourcePathParam, sourcePath = sourcePathParam; NS_tchar logFile[MAXPATHLEN]; - NS_tsnprintf(logFile, sizeof(logFile)/sizeof(logFile[0]), + NS_tsnprintf(logFile, SAL_N_ELEMENTS(logFile), NS_T("%s/%s"), sourcePathParam, fileName); if (alternateFileName && NS_taccess(logFile, F_OK)) { - NS_tsnprintf(logFile, sizeof(logFile)/sizeof(logFile[0]), + NS_tsnprintf(logFile, SAL_N_ELEMENTS(logFile), NS_T("%s/%s"), sourcePathParam, alternateFileName); } diff --git a/onlineupdate/source/update/updater/progressui_win.cxx b/onlineupdate/source/update/updater/progressui_win.cxx index 7a0ff249442f..cdef03f17039 100644 --- a/onlineupdate/source/update/updater/progressui_win.cxx +++ b/onlineupdate/source/update/updater/progressui_win.cxx @@ -111,9 +111,9 @@ InitDialog(HWND hDlg) WCHAR szwInfo[MAX_TEXT_LEN]; MultiByteToWideChar(CP_UTF8, 0, sUIStrings.title, -1, szwTitle, - sizeof(szwTitle)/sizeof(szwTitle[0])); + SAL_N_ELEMENTS(szwTitle)); MultiByteToWideChar(CP_UTF8, 0, sUIStrings.info, -1, szwInfo, - sizeof(szwInfo)/sizeof(szwInfo[0])); + SAL_N_ELEMENTS(szwInfo)); SetWindowTextW(hDlg, szwTitle); SetWindowTextW(GetDlgItem(hDlg, IDC_INFO), szwInfo); diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index 2d5e614dbf59..22472ec48f30 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -502,7 +502,7 @@ static int ensure_remove_recursive(const NS_tchar *path, if (NS_tstrcmp(entry->d_name, NS_T(".")) && NS_tstrcmp(entry->d_name, NS_T(".."))) { NS_tchar childPath[MAXPATHLEN]; - NS_tsnprintf(childPath, sizeof(childPath)/sizeof(childPath[0]), + NS_tsnprintf(childPath, SAL_N_ELEMENTS(childPath), NS_T("%s/%s"), path, entry->d_name); rv = ensure_remove_recursive(childPath); if (rv && !continueEnumOnFailure) { @@ -788,13 +788,13 @@ static int ensure_copy_recursive(const NS_tchar *path, const NS_tchar *dest, if (NS_tstrcmp(entry->d_name, NS_T(".")) && NS_tstrcmp(entry->d_name, NS_T(".."))) { NS_tchar childPath[MAXPATHLEN]; - NS_tsnprintf(childPath, sizeof(childPath)/sizeof(childPath[0]), + NS_tsnprintf(childPath, SAL_N_ELEMENTS(childPath), NS_T("%s/%s"), path, entry->d_name); if (skiplist.find(childPath)) { continue; } NS_tchar childPathDest[MAXPATHLEN]; - NS_tsnprintf(childPathDest, sizeof(childPathDest)/sizeof(childPathDest[0]), + NS_tsnprintf(childPathDest, SAL_N_ELEMENTS(childPathDest), NS_T("%s/%s"), dest, entry->d_name); rv = ensure_copy_recursive(childPath, childPathDest, skiplist); if (rv) { @@ -893,7 +893,7 @@ static int remove_recursive_on_reboot(const NS_tchar *path, const NS_tchar *dele if (NS_tstrcmp(entry->d_name, NS_T(".")) && NS_tstrcmp(entry->d_name, NS_T(".."))) { NS_tchar childPath[MAXPATHLEN]; - NS_tsnprintf(childPath, sizeof(childPath)/sizeof(childPath[0]), + NS_tsnprintf(childPath, SAL_N_ELEMENTS(childPath), NS_T("%s/%s"), path, entry->d_name); // There is no need to check the return value of this call since this // function is only called after an update is successful and there is not @@ -923,7 +923,7 @@ static int remove_recursive_on_reboot(const NS_tchar *path, const NS_tchar *dele static int backup_create(const NS_tchar *path) { NS_tchar backup[MAXPATHLEN]; - NS_tsnprintf(backup, sizeof(backup)/sizeof(backup[0]), + NS_tsnprintf(backup, SAL_N_ELEMENTS(backup), NS_T("%s") BACKUP_EXT, path); return rename_file(path, backup); @@ -934,7 +934,7 @@ static int backup_create(const NS_tchar *path) static int backup_restore(const NS_tchar *path) { NS_tchar backup[MAXPATHLEN]; - NS_tsnprintf(backup, sizeof(backup)/sizeof(backup[0]), + NS_tsnprintf(backup, SAL_N_ELEMENTS(backup), NS_T("%s") BACKUP_EXT, path); if (NS_taccess(backup, F_OK)) { @@ -949,7 +949,7 @@ static int backup_restore(const NS_tchar *path) static int backup_discard(const NS_tchar *path) { NS_tchar backup[MAXPATHLEN]; - NS_tsnprintf(backup, sizeof(backup)/sizeof(backup[0]), + NS_tsnprintf(backup, SAL_N_ELEMENTS(backup), NS_T("%s") BACKUP_EXT, path); // Nothing to discard @@ -1447,7 +1447,7 @@ PatchFile::Prepare() // extract the patch to a temporary file mPatchIndex = sPatchIndex++; - NS_tsnprintf(spath, sizeof(spath)/sizeof(spath[0]), + NS_tsnprintf(spath, SAL_N_ELEMENTS(spath), NS_T("%s/updating/%d.patch"), gWorkingDirPath, mPatchIndex); NS_tremove(spath); @@ -1837,7 +1837,7 @@ static bool WriteStatusFile(const char* aStatus) { NS_tchar filename[MAXPATHLEN]; - NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]), + NS_tsnprintf(filename, SAL_N_ELEMENTS(filename), NS_T("%s/update.status"), gPatchDirPath); // Make sure that the directory for the update status file exists @@ -1867,7 +1867,7 @@ WriteStatusFile(int status) text = "succeeded\n"; } } else { - snprintf(buf, sizeof(buf)/sizeof(buf[0]), "failed: %d\n", status); + snprintf(buf, SAL_N_ELEMENTS(buf), "failed: %d\n", status); text = buf; } @@ -1888,7 +1888,7 @@ static bool IsUpdateStatusPendingService() { NS_tchar filename[MAXPATHLEN]; - NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]), + NS_tsnprintf(filename, SAL_N_ELEMENTS(filename), NS_T("%s/update.status"), gPatchDirPath); AutoFile file(NS_tfopen(filename, NS_T("rb"))); @@ -1922,7 +1922,7 @@ IsUpdateStatusSucceeded(bool &isSucceeded) { isSucceeded = false; NS_tchar filename[MAXPATHLEN]; - NS_tsnprintf(filename, sizeof(filename)/sizeof(filename[0]), + NS_tsnprintf(filename, SAL_N_ELEMENTS(filename), NS_T("%s/update.status"), gPatchDirPath); AutoFile file(NS_tfopen(filename, NS_T("rb"))); @@ -1984,7 +1984,7 @@ ProcessReplaceRequest() #ifdef MACOSX NS_tchar destDir[MAXPATHLEN]; - NS_tsnprintf(destDir, sizeof(destDir)/sizeof(destDir[0]), + NS_tsnprintf(destDir, SAL_N_ELEMENTS(destDir), NS_T("%s/Contents"), gInstallDirPath); #elif defined(WNT) // Windows preserves the case of the file/directory names. We use the @@ -1993,7 +1993,7 @@ ProcessReplaceRequest() // application, the installation directory's name does not change. NS_tchar destDir[MAXPATHLEN]; if (!GetLongPathNameW(gInstallDirPath, destDir, - sizeof(destDir)/sizeof(destDir[0]))) { + SAL_N_ELEMENTS(destDir))) { return NO_INSTALLDIR_ERROR; } #else @@ -2001,11 +2001,11 @@ ProcessReplaceRequest() #endif NS_tchar tmpDir[MAXPATHLEN]; - NS_tsnprintf(tmpDir, sizeof(tmpDir)/sizeof(tmpDir[0]), + NS_tsnprintf(tmpDir, SAL_N_ELEMENTS(tmpDir), NS_T("%s.bak"), destDir); NS_tchar newDir[MAXPATHLEN]; - NS_tsnprintf(newDir, sizeof(newDir)/sizeof(newDir[0]), + NS_tsnprintf(newDir, SAL_N_ELEMENTS(newDir), #ifdef MACOSX NS_T("%s/Contents"), gWorkingDirPath); @@ -2077,7 +2077,7 @@ ProcessReplaceRequest() LOG(("Removing tmpDir failed, err: %d", rv)); #ifdef _WIN32 NS_tchar deleteDir[MAXPATHLEN]; - NS_tsnprintf(deleteDir, sizeof(deleteDir)/sizeof(deleteDir[0]), + NS_tsnprintf(deleteDir, SAL_N_ELEMENTS(deleteDir), NS_T("%s\\%s"), destDir, DELETE_DIR); // Attempt to remove the tobedeleted directory and then recreate it if it // was successfully removed. @@ -2093,7 +2093,7 @@ ProcessReplaceRequest() // On OS X, we we need to remove the staging directory after its Contents // directory has been moved. NS_tchar updatedAppDir[MAXPATHLEN]; - NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir)/sizeof(updatedAppDir[0]), + NS_tsnprintf(updatedAppDir, SAL_N_ELEMENTS(updatedAppDir), NS_T("%s/Updated.app"), gPatchDirPath); ensure_remove_recursive(updatedAppDir); #endif @@ -2147,7 +2147,7 @@ GetUpdateFileName(NS_tchar *fileName, int maxChars) // of the update file (terminated by a newline). NS_tchar linkFileName[MAXPATHLEN]; - NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]), + NS_tsnprintf(linkFileName, SAL_N_ELEMENTS(linkFileName), NS_T("%s/update.link"), gPatchDirPath); AutoFile linkFile(NS_tfopen(linkFileName, NS_T("rb"))); if (linkFile == nullptr) { @@ -2192,7 +2192,7 @@ UpdateThreadFunc(void * /*param*/) rv = ProcessReplaceRequest(); } else { NS_tchar dataFile[MAXPATHLEN]; - rv = GetUpdateFileName(dataFile, sizeof(dataFile)/sizeof(dataFile[0])); + rv = GetUpdateFileName(dataFile, SAL_N_ELEMENTS(dataFile)); if (rv == OK) { rv = gArchiveReader.Open(dataFile); } @@ -2241,7 +2241,7 @@ UpdateThreadFunc(void * /*param*/) if (rv == OK) { NS_tchar updateSettingsPath[MAX_TEXT_LEN]; NS_tsnprintf(updateSettingsPath, - sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]), + SAL_N_ELEMENTS(updateSettingsPath), #ifdef MACOSX NS_T("%s/Contents/Resources/update-settings.ini"), #else @@ -2280,7 +2280,7 @@ UpdateThreadFunc(void * /*param*/) rv = DoUpdate(); gArchiveReader.Close(); NS_tchar updatingDir[MAXPATHLEN]; - NS_tsnprintf(updatingDir, sizeof(updatingDir)/sizeof(updatingDir[0]), + NS_tsnprintf(updatingDir, SAL_N_ELEMENTS(updatingDir), NS_T("%s/updating"), gWorkingDirPath); ensure_remove_recursive(updatingDir); } @@ -2473,7 +2473,7 @@ int NS_main(int argc, NS_tchar **argv) NS_tchar* logDir = gPatchDirPath; #else NS_tchar logDir[MAXPATHLEN]; - NS_tsnprintf(logDir, sizeof(logDir)/sizeof(logDir[0]), + NS_tsnprintf(logDir, SAL_N_ELEMENTS(logDir), NS_T("%s/updated/updates"), gInstallDirPath); #endif @@ -2585,7 +2585,7 @@ int NS_main(int argc, NS_tchar **argv) // When staging an update, the lock file is: // <install_dir>\updated.update_in_progress.lock NS_tsnprintf(updateLockFilePath, - sizeof(updateLockFilePath)/sizeof(updateLockFilePath[0]), + SAL_N_ELEMENTS(updateLockFilePath), NS_T("%s/updated.update_in_progress.lock"), gInstallDirPath); } else if (sReplaceRequest) { // When processing a replace request, the lock file is: @@ -2595,13 +2595,13 @@ int NS_main(int argc, NS_tchar **argv) NS_tchar *slash = (NS_tchar *) NS_tstrrchr(installDir, NS_SLASH); *slash = NS_T('\0'); NS_tsnprintf(updateLockFilePath, - sizeof(updateLockFilePath)/sizeof(updateLockFilePath[0]), + SAL_N_ELEMENTS(updateLockFilePath), NS_T("%s\\moz_update_in_progress.lock"), installDir); } else { // In the non-staging update case, the lock file is: // <install_dir>\<app_name>.exe.update_in_progress.lock NS_tsnprintf(updateLockFilePath, - sizeof(updateLockFilePath)/sizeof(updateLockFilePath[0]), + SAL_N_ELEMENTS(updateLockFilePath), NS_T("%s.update_in_progress.lock"), argv[callbackIndex]); } @@ -2630,7 +2630,7 @@ int NS_main(int argc, NS_tchar **argv) nullptr); NS_tsnprintf(elevatedLockFilePath, - sizeof(elevatedLockFilePath)/sizeof(elevatedLockFilePath[0]), + SAL_N_ELEMENTS(elevatedLockFilePath), NS_T("%s/update_elevated.lock"), gPatchDirPath); // Even if a file has no sharing access, you can still get its attributes @@ -2933,7 +2933,7 @@ int NS_main(int argc, NS_tchar **argv) NS_tchar applyDirLongPath[MAXPATHLEN]; if (!GetLongPathNameW(gWorkingDirPath, applyDirLongPath, - sizeof(applyDirLongPath)/sizeof(applyDirLongPath[0]))) { + SAL_N_ELEMENTS(applyDirLongPath))) { LOG(("NS_main: unable to find apply to dir: " LOG_S, gWorkingDirPath)); LogFinish(); WriteStatusFile(WRITE_ERROR_APPLY_DIR_PATH); @@ -2986,7 +2986,7 @@ int NS_main(int argc, NS_tchar **argv) targetPath = buffer; } if (!GetLongPathNameW(targetPath, callbackLongPath, - sizeof(callbackLongPath)/sizeof(callbackLongPath[0]))) { + SAL_N_ELEMENTS(callbackLongPath))) { LOG(("NS_main: unable to find callback file: " LOG_S, targetPath)); LogFinish(); WriteStatusFile(WRITE_ERROR_CALLBACK_PATH); @@ -3026,7 +3026,7 @@ int NS_main(int argc, NS_tchar **argv) // Make a copy of the callback executable so it can be read when patching. NS_tsnprintf(gCallbackBackupPath, - sizeof(gCallbackBackupPath)/sizeof(gCallbackBackupPath[0]), + SAL_N_ELEMENTS(gCallbackBackupPath), NS_T("%s" CALLBACK_BACKUP_EXT), argv[callbackIndex]); NS_tremove(gCallbackBackupPath); CopyFileW(argv[callbackIndex], gCallbackBackupPath, false); @@ -3150,17 +3150,17 @@ int NS_main(int argc, NS_tchar **argv) // directory under Contents/MacOS (see Bug 1068439). if (gSucceeded && !sStagedUpdate) { NS_tchar oldPrecomplete[MAXPATHLEN]; - NS_tsnprintf(oldPrecomplete, sizeof(oldPrecomplete)/sizeof(oldPrecomplete[0]), + NS_tsnprintf(oldPrecomplete, SAL_N_ELEMENTS(oldPrecomplete), NS_T("%s/precomplete"), gInstallDirPath); NS_tremove(oldPrecomplete); NS_tchar oldDistDir[MAXPATHLEN]; - NS_tsnprintf(oldDistDir, sizeof(oldDistDir)/sizeof(oldDistDir[0]), + NS_tsnprintf(oldDistDir, SAL_N_ELEMENTS(oldDistDir), NS_T("%s/Contents/MacOS/distribution"), gInstallDirPath); int rv = NS_taccess(oldDistDir, F_OK); if (!rv) { NS_tchar newDistDir[MAXPATHLEN]; - NS_tsnprintf(newDistDir, sizeof(newDistDir)/sizeof(newDistDir[0]), + NS_tsnprintf(newDistDir, SAL_N_ELEMENTS(newDistDir), NS_T("%s/Contents/Resources/distribution"), gInstallDirPath); rv = NS_taccess(newDistDir, F_OK); if (!rv) { @@ -3344,7 +3344,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) NS_tchar searchspec[MAXPATHLEN]; NS_tchar foundpath[MAXPATHLEN]; - NS_tsnprintf(searchspec, sizeof(searchspec)/sizeof(searchspec[0]), + NS_tsnprintf(searchspec, SAL_N_ELEMENTS(searchspec), NS_T("%s*"), dirpath); const NS_tchar *pszSpec = get_full_path(searchspec); @@ -3356,10 +3356,10 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) NS_tstrcmp(finddata.cFileName, NS_T("..")) == 0) continue; - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s%s"), dirpath, finddata.cFileName); if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s/"), foundpath); // Recurse into the directory. rv = add_dir_entries(foundpath, list); @@ -3418,7 +3418,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) struct dirent* ent; - NS_tsnprintf(searchpath, sizeof(searchpath)/sizeof(searchpath[0]), NS_T("%s"), + NS_tsnprintf(searchpath, SAL_N_ELEMENTS(searchpath), NS_T("%s"), dirpath); // Remove the trailing slash so the paths don't contain double slashes. The // existence of the slash has already been checked in DoUpdate. @@ -3436,7 +3436,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) (strcmp(ent->d_name, "..") == 0)) continue; - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s%s"), dirpath, ent->d_name); struct stat64 st_buf; int test = stat64(foundpath, &st_buf); @@ -3445,7 +3445,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) return UNEXPECTED_FILE_OPERATION_ERROR; } if (S_ISDIR(st_buf.st_mode)) { - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s/"), foundpath); // Recurse into the directory. rv = add_dir_entries(foundpath, list); @@ -3503,7 +3503,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) FTSENT *ftsdirEntry; NS_tchar searchpath[MAXPATHLEN]; - NS_tsnprintf(searchpath, sizeof(searchpath)/sizeof(searchpath[0]), NS_T("%s"), + NS_tsnprintf(searchpath, SAL_N_ELEMENTS(searchpath), NS_T("%s"), dirpath); // Remove the trailing slash so the paths don't contain double slashes. The // existence of the slash has already been checked in DoUpdate. @@ -3535,7 +3535,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) case FTS_F: case FTS_NSOK: // Add the file to be removed to the ActionList. - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s"), ftsdirEntry->fts_accpath); quotedpath = get_quoted_path(foundpath); if (!quotedpath) { @@ -3552,7 +3552,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) case FTS_DP: rv = OK; // Add the directory to be removed to the ActionList. - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), + NS_tsnprintf(foundpath, SAL_N_ELEMENTS(foundpath), NS_T("%s/"), ftsdirEntry->fts_accpath); quotedpath = get_quoted_path(foundpath); if (!quotedpath) { @@ -3725,7 +3725,7 @@ int AddPreCompleteActions(ActionList *list) int DoUpdate() { NS_tchar manifest[MAXPATHLEN]; - NS_tsnprintf(manifest, sizeof(manifest)/sizeof(manifest[0]), + NS_tsnprintf(manifest, SAL_N_ELEMENTS(manifest), NS_T("%s/updating/update.manifest"), gWorkingDirPath); ensure_parent_dir(manifest); diff --git a/onlineupdate/source/update/updater/win_dirent.cxx b/onlineupdate/source/update/updater/win_dirent.cxx index d7bf872194f6..3db80d4ca46e 100644 --- a/onlineupdate/source/update/updater/win_dirent.cxx +++ b/onlineupdate/source/update/updater/win_dirent.cxx @@ -19,8 +19,8 @@ DIR::DIR(const WCHAR* path) : findHandle(INVALID_HANDLE_VALUE) { memset(name, 0, sizeof(name)); - wcsncpy(name, path, sizeof(name)/sizeof(name[0])); - wcsncat(name, L"\\*", sizeof(name)/sizeof(name[0]) - wcslen(name) - 1); + wcsncpy(name, path, SAL_N_ELEMENTS(name)); + wcsncat(name, L"\\*", SAL_N_ELEMENTS(name) - wcslen(name) - 1); } DIR::~DIR() @@ -73,7 +73,7 @@ dirent* readdir(DIR* dir) } memset(gDirEnt.d_name, 0, sizeof(gDirEnt.d_name)); wcsncpy(gDirEnt.d_name, data.cFileName, - sizeof(gDirEnt.d_name)/sizeof(gDirEnt.d_name[0])); + SAL_N_ELEMENTS(gDirEnt.d_name)); return &gDirEnt; } #endif diff --git a/reportdesign/source/core/api/FixedLine.cxx b/reportdesign/source/core/api/FixedLine.cxx index 3adbba16ddda..a8102db79718 100644 --- a/reportdesign/source/core/api/FixedLine.cxx +++ b/reportdesign/source/core/api/FixedLine.cxx @@ -124,7 +124,7 @@ uno::Sequence< OUString > lcl_getLineOptionals() }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } OFixedLine::OFixedLine(uno::Reference< uno::XComponentContext > const & _xContext) diff --git a/reportdesign/source/core/api/FixedText.cxx b/reportdesign/source/core/api/FixedText.cxx index a58030bb346c..0a11eaed06c6 100644 --- a/reportdesign/source/core/api/FixedText.cxx +++ b/reportdesign/source/core/api/FixedText.cxx @@ -36,10 +36,11 @@ namespace reportdesign using namespace com::sun::star; using namespace comphelper; + uno::Sequence< OUString > lcl_getFixedTextOptionals() { OUString pProps[] = { OUString(PROPERTY_DATAFIELD),OUString(PROPERTY_MASTERFIELDS),OUString(PROPERTY_DETAILFIELDS) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } OFixedText::OFixedText(uno::Reference< uno::XComponentContext > const & _xContext) diff --git a/reportdesign/source/core/api/FormattedField.cxx b/reportdesign/source/core/api/FormattedField.cxx index da050bd73dac..61905623ed5c 100644 --- a/reportdesign/source/core/api/FormattedField.cxx +++ b/reportdesign/source/core/api/FormattedField.cxx @@ -46,7 +46,7 @@ uno::Reference< uno::XInterface > OFormattedField::create(uno::Reference< uno::X uno::Sequence< OUString > lcl_getFormattedFieldOptionals() { OUString pProps[] = { OUString(PROPERTY_MASTERFIELDS),OUString(PROPERTY_DETAILFIELDS) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } OFormattedField::OFormattedField(uno::Reference< uno::XComponentContext > const & _xContext) diff --git a/reportdesign/source/core/api/ImageControl.cxx b/reportdesign/source/core/api/ImageControl.cxx index faf823eabafa..ad9645733ce9 100644 --- a/reportdesign/source/core/api/ImageControl.cxx +++ b/reportdesign/source/core/api/ImageControl.cxx @@ -109,7 +109,7 @@ uno::Sequence< OUString > lcl_getImageOptionals() , OUString(PROPERTY_CHARLOCALECOMPLEX) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 4babedf66051..db18d3f4b4cf 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -1686,7 +1686,7 @@ void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue aArguments.get_ensureType( "ReadOnly", bReadOnly ); nFirstOpenMode = bReadOnly ? 1 : 0; } - const size_t nLastOpenMode = sizeof( nOpenModes ) / sizeof( nOpenModes[0] ) - 1; + const size_t nLastOpenMode = SAL_N_ELEMENTS( nOpenModes ) - 1; for ( size_t i=nFirstOpenMode; i <= nLastOpenMode; ++i ) { uno::Sequence< uno::Any > aStorageCreationArgs(2); @@ -2249,7 +2249,7 @@ uno::Sequence< OUString > SAL_CALL OReportDefinition::getAvailableServiceNames() OUString("com.sun.star.drawing.MarkerTable") }; - static const sal_uInt16 nSvxComponentServiceNameListCount = sizeof(aSvxComponentServiceNameList) / sizeof ( aSvxComponentServiceNameList[0] ); + static const sal_uInt16 nSvxComponentServiceNameListCount = SAL_N_ELEMENTS(aSvxComponentServiceNameList); uno::Sequence< OUString > aSeq( nSvxComponentServiceNameListCount ); OUString* pStrings = aSeq.getArray(); diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index f203f890fe4b..1b5199d3009d 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -48,12 +48,12 @@ namespace reportdesign uno::Sequence< OUString> lcl_getGroupAbsent() { - OUString pProps[] = { + const OUString pProps[] = { OUString(PROPERTY_CANGROW) ,OUString(PROPERTY_CANSHRINK) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } @@ -61,7 +61,7 @@ uno::Sequence< OUString> lcl_getAbsent(bool _bPageSection) { if ( _bPageSection ) { - OUString pProps[] = { + const OUString pProps[] = { OUString(PROPERTY_FORCENEWPAGE) ,OUString(PROPERTY_NEWROWORCOL) ,OUString(PROPERTY_KEEPTOGETHER) @@ -69,16 +69,16 @@ uno::Sequence< OUString> lcl_getAbsent(bool _bPageSection) ,OUString(PROPERTY_CANSHRINK) ,OUString(PROPERTY_REPEATSECTION) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } - OUString pProps[] = { + const OUString pProps[] = { OUString(PROPERTY_CANGROW) ,OUString(PROPERTY_CANSHRINK) ,OUString(PROPERTY_REPEATSECTION) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } uno::Reference<report::XSection> OSection::createOSection( diff --git a/reportdesign/source/core/api/Shape.cxx b/reportdesign/source/core/api/Shape.cxx index e02132b5f8c5..3ee21c955646 100644 --- a/reportdesign/source/core/api/Shape.cxx +++ b/reportdesign/source/core/api/Shape.cxx @@ -43,12 +43,12 @@ namespace reportdesign using namespace comphelper; uno::Sequence< OUString > lcl_getShapeOptionals() { - OUString pProps[] = { + const OUString pProps[] = { OUString(PROPERTY_DATAFIELD) ,OUString(PROPERTY_CONTROLBACKGROUND) ,OUString(PROPERTY_CONTROLBACKGROUNDTRANSPARENT) }; - return uno::Sequence< OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); + return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps)); } diff --git a/reportdesign/source/ui/inspection/DefaultInspection.cxx b/reportdesign/source/ui/inspection/DefaultInspection.cxx index 766660acf4e1..cd68746685b1 100644 --- a/reportdesign/source/ui/inspection/DefaultInspection.cxx +++ b/reportdesign/source/ui/inspection/DefaultInspection.cxx @@ -116,7 +116,7 @@ namespace rptui }; - const size_t nFactories = sizeof( aFactories ) / sizeof( aFactories[ 0 ] ); + const size_t nFactories = SAL_N_ELEMENTS( aFactories ); Sequence< Any > aReturn( nFactories ); Any* pReturn = aReturn.getArray(); for ( size_t i = 0; i < nFactories; ++i ) @@ -214,7 +214,7 @@ namespace rptui { "Data", RID_STR_PROPPAGE_DATA, HID_RPT_PROPDLG_TAB_DATA }, }; - const size_t nCategories = sizeof( aCategories ) / sizeof( aCategories[0] ); + const size_t nCategories = SAL_N_ELEMENTS( aCategories ); Sequence< PropertyCategoryDescriptor > aReturn( nCategories ); PropertyCategoryDescriptor* pReturn = aReturn.getArray(); for ( size_t i=0; i<nCategories; ++i, ++pReturn ) diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index 007892cee423..4ab8226d84c8 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -693,7 +693,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep }; - OSL_ASSERT((sizeof(pDefaults)/sizeof(pDefaults[0])) == (sizeof(aItemInfos)/sizeof(aItemInfos[0]))); + OSL_ASSERT( SAL_N_ELEMENTS(pDefaults) == SAL_N_ELEMENTS(aItemInfos) ); static const sal_uInt16 pRanges[] = { diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 8b42e4017233..5d36d3236b12 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -3689,7 +3689,7 @@ void OReportController::listen(const bool _bAdd) const beans::Property* pIter = aSeq.getConstArray(); const beans::Property* pEnd = pIter + aSeq.getLength(); const OUString* pPropsBegin = &aProps[0]; - const OUString* pPropsEnd = pPropsBegin + (sizeof(aProps)/sizeof(aProps[0])) - 3; + const OUString* pPropsEnd = pPropsBegin + SAL_N_ELEMENTS(aProps) - 3; for(;pIter != pEnd;++pIter) { if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd ) @@ -4075,7 +4075,7 @@ css::uno::Sequence< OUString > SAL_CALL OReportController::getSupportedModes( ) { static const OUString s_sModes[] = { OUString("remote"), OUString("normal") }; - return uno::Sequence< OUString> (&s_sModes[0],sizeof(s_sModes)/sizeof(s_sModes[0])); + return uno::Sequence< OUString> (&s_sModes[0],SAL_N_ELEMENTS(s_sModes)); } sal_Bool SAL_CALL OReportController::supportsMode( const OUString& aMode ) throw (css::uno::RuntimeException, std::exception) { diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index 64461637c975..c6d3297908af 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -122,7 +122,7 @@ PropBrw::PropBrw(const Reference< XComponentContext >& _xORB, vcl::Window* pPare ::cppu::ContextEntry_Init( OUString( "ActiveConnection" ), makeAny( m_pDesignView->getController().getConnection() ) ), }; m_xInspectorContext.set( - ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), + ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), m_xORB ) ); // create a property browser controller bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index fdc7ecb5ca34..7324c7f6428e 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1543,7 +1543,7 @@ bool parseFunction( const OUString& rList, sal_Int32 nStartPos, sal_Int32& rEndP { aFuncStr = comphelper::string::strip(aFuncStr, ' '); - const sal_Int32 nFuncCount = sizeof(aFunctions) / sizeof(aFunctions[0]); + const sal_Int32 nFuncCount = SAL_N_ELEMENTS(aFunctions); for ( sal_Int32 nFunc=0; nFunc<nFuncCount && !bFound; nFunc++ ) { if (aFuncStr.equalsIgnoreAsciiCaseAscii(aFunctions[nFunc].pName)) diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index b425de6e222e..f3480a2436f0 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2652,7 +2652,7 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray ) // Renamed new names, prepare to read future names: //{ "ORG.OPENOFFICE.XXX", ocXXX } // XXX -> ORG.OPENOFFICE.XXX }; - static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); + static const size_t nOdffAliases = SAL_N_ELEMENTS(aOdffAliases); for (size_t i=0; i<nOdffAliases; ++i) { if (rName.equalsIgnoreAsciiCaseAscii( aOdffAliases[i].pName)) diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index d5a50ad0c10b..13e50c16e012 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -144,7 +144,7 @@ EditTextObject* ScEditUtil::CreateURLObjectFromURL( ScDocument& rDoc, const OUSt void ScEditUtil::RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr ) { - const struct { + static const struct { sal_uInt16 nAttrType; sal_uInt16 nCharType; } AttrTypeMap[] = { @@ -153,7 +153,7 @@ void ScEditUtil::RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAt { ATTR_FONT_WEIGHT, EE_CHAR_WEIGHT }, { ATTR_FONT_COLOR, EE_CHAR_COLOR } }; - sal_uInt16 nMapCount = sizeof (AttrTypeMap) / sizeof (AttrTypeMap[0]); + sal_uInt16 nMapCount = SAL_N_ELEMENTS(AttrTypeMap); const SfxItemSet& rSet = rAttr.GetItemSet(); const SfxPoolItem* pItem; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index f25c14f3f622..2a481d18a1b9 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -2533,7 +2533,7 @@ void ScInterpreter::ScBase() 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 0 }; - static const int nDigits = (sizeof (pDigits)/sizeof(pDigits[0]))-1; + static const int nDigits = SAL_N_ELEMENTS(pDigits) - 1; sal_Int32 nMinLen; if ( nParamCount == 3 ) { @@ -2740,7 +2740,7 @@ void ScInterpreter::ScRoman() { static const sal_Unicode pChars[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' }; static const sal_uInt16 pValues[] = { 1000, 500, 100, 50, 10, 5, 1 }; - static const sal_uInt16 nMaxIndex = (sal_uInt16)((sizeof(pValues)/sizeof(pValues[0])) - 1); + static const sal_uInt16 nMaxIndex = (sal_uInt16)(SAL_N_ELEMENTS(pValues) - 1); OUString aRoman; sal_uInt16 nVal = (sal_uInt16) fVal; @@ -2990,7 +2990,7 @@ static bool lclConvertMoney( const OUString& aSearchUnit, double& rfRate, int& r { "LTL", 3.45280, 2 } }; - static const size_t nConversionCount = sizeof( aConvertTable ) / sizeof( aConvertTable[0] ); + static const size_t nConversionCount = SAL_N_ELEMENTS( aConvertTable ); for ( size_t i = 0; i < nConversionCount; ++i ) if ( aSearchUnit.equalsIgnoreAsciiCaseAscii( aConvertTable[i].pCurrText ) ) { diff --git a/sc/source/core/tool/odffmap.cxx b/sc/source/core/tool/odffmap.cxx index 4db554dd1eef..d0a62cde6d31 100644 --- a/sc/source/core/tool/odffmap.cxx +++ b/sc/source/core/tool/odffmap.cxx @@ -142,7 +142,7 @@ const ScCompiler::AddInMap* ScCompiler::GetAddInMap() size_t ScCompiler::GetAddInMapCount() { - return sizeof(maAddInMap)/sizeof(maAddInMap[0]); + return SAL_N_ELEMENTS(maAddInMap); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index e91f55f2f3f5..667cd4a1b2b3 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -540,7 +540,7 @@ static const struct { ocNoName, FT_NotImpl } // gives properties of DOS menus }; -const int nIndexCount = sizeof( aFuncMap ) / sizeof( aFuncMap[ 0 ] ); +const int nIndexCount = SAL_N_ELEMENTS( aFuncMap ); DefTokenId QProToSc::IndexToToken( sal_uInt16 nIndex ) { diff --git a/sc/source/filter/xml/editattributemap.cxx b/sc/source/filter/xml/editattributemap.cxx index 014edd3a6495..057adc0d932d 100644 --- a/sc/source/filter/xml/editattributemap.cxx +++ b/sc/source/filter/xml/editattributemap.cxx @@ -64,7 +64,7 @@ ScXMLEditAttributeMap::Entry aEntries[] = { ScXMLEditAttributeMap::ScXMLEditAttributeMap() { - size_t n = sizeof(aEntries) / sizeof(aEntries[0]); + size_t n = SAL_N_ELEMENTS(aEntries); for (size_t i = 0; i < n; ++i) { maAPIEntries.insert( diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 02bb1e17282b..5292f57b256b 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -2115,8 +2115,7 @@ ScXMLImport::ScXMLImport( { XML_CURRENCY, util::NumberFormat::CURRENCY }, { XML_BOOLEAN, util::NumberFormat::LOGICAL } }; - size_t n = sizeof(aCellTypePairs)/sizeof(aCellTypePairs[0]); - for (size_t i = 0; i < n; ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(aCellTypePairs); ++i) { aCellTypeMap.insert( CellTypeMap::value_type( diff --git a/sc/source/ui/dbgui/dpgroupdlg.cxx b/sc/source/ui/dbgui/dpgroupdlg.cxx index 8db25e49938f..214cf1612023 100644 --- a/sc/source/ui/dbgui/dpgroupdlg.cxx +++ b/sc/source/ui/dbgui/dpgroupdlg.cxx @@ -227,7 +227,7 @@ ScDPDateGroupDlg::ScDPDateGroupDlg( vcl::Window* pParent, maStartHelper ( mpRbAutoStart, mpRbManStart, mpEdStart, rNullDate ), maEndHelper ( mpRbAutoEnd, mpRbManEnd, mpEdEnd, rNullDate ) { - static const size_t nCount = sizeof( nDatePartResIds ) / sizeof( nDatePartResIds[0] ); + static const size_t nCount = SAL_N_ELEMENTS( nDatePartResIds ); for( size_t nIdx = 0 ; nIdx < nCount; ++nIdx ) mpLbUnits->InsertEntry( ScGlobal::GetRscString( nDatePartResIds[nIdx] ) ); diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx index bb0860deaaec..b7e5e0eea0e3 100644 --- a/sc/source/ui/miscdlgs/protectiondlg.cxx +++ b/sc/source/ui/miscdlgs/protectiondlg.cxx @@ -29,7 +29,7 @@ static const ScTableProtection::Option aOptions[] = { ScTableProtection::SELECT_LOCKED_CELLS, ScTableProtection::SELECT_UNLOCKED_CELLS, }; -static const sal_uInt16 nOptionCount = sizeof(aOptions) / sizeof (aOptions[0]); +static const sal_uInt16 nOptionCount = SAL_N_ELEMENTS(aOptions); ScTableProtectionDlg::ScTableProtectionDlg(vcl::Window* pParent) : ModalDialog( pParent, "ProtectSheetDialog", "modules/scalc/ui/protectsheetdlg.ui" ) diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index b723de895cca..c87d296c00cb 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -586,7 +586,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( uno::Sequence<OUString> ScServiceProvider::GetAllServiceNames() { - const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); + const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId); uno::Sequence<OUString> aRet(nEntries); OUString* pArray = aRet.getArray(); for (sal_uInt16 i = 0; i < nEntries; i++) diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index edea996935c6..a684a61991a8 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -96,7 +96,7 @@ void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const formula::FormulaGrammar::CONV_XL_OOX, // <- AddressConvention::XL_OOX formula::FormulaGrammar::CONV_LOTUS_A1 // <- AddressConvention::LOTUS_A1 }; - static const sal_Int16 nConvMapCount = sizeof(aConvMap)/sizeof(aConvMap[0]); + static const sal_Int16 nConvMapCount = SAL_N_ELEMENTS(aConvMap); // If mxOpCodeMap is not empty it overrides mbEnglish, and vice versa. We // don't need to initialize things twice. diff --git a/sc/source/ui/vba/vbaborders.cxx b/sc/source/ui/vba/vbaborders.cxx index 8ecf3f6b5fc0..86e8ddcd29c1 100644 --- a/sc/source/ui/vba/vbaborders.cxx +++ b/sc/source/ui/vba/vbaborders.cxx @@ -322,7 +322,7 @@ public: // XIndexAccess virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException, std::exception) override { - return sizeof( supportedIndexTable ) / sizeof( supportedIndexTable[0] ); + return SAL_N_ELEMENTS( supportedIndexTable ); } virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override { diff --git a/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx index c921cfd0ad64..1bdae4c0cf15 100644 --- a/sc/source/ui/vba/vbadialog.cxx +++ b/sc/source/ui/vba/vbadialog.cxx @@ -52,7 +52,7 @@ static const OUString aStringList[]= OUString( ".uno:AutoFormat" ) }; -const sal_Int32 nDialogSize = sizeof (aStringList) / sizeof (aStringList[0]); +const sal_Int32 nDialogSize = SAL_N_ELEMENTS(aStringList); OUString ScVbaDialog::mapIndexToName( sal_Int32 nIndex ) diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 3b7f90e04e2f..930f5972073f 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -239,7 +239,7 @@ ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException, std::ex static uno::Sequence< OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() ); if ( !bInit ) { - OUString names[] = { + const OUString names[] = { OUString( "ooo.vba.excel.Range" ), OUString( "ooo.vba.excel.Workbook" ), OUString( "ooo.vba.excel.Window" ), @@ -248,7 +248,7 @@ ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException, std::ex OUString( "ooo.vba.excel.Hyperlink" ), OUString( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) }; - sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) ); + sal_Int32 nExcelServices = SAL_N_ELEMENTS( names ); sal_Int32 startIndex = serviceNames.getLength(); serviceNames.realloc( serviceNames.getLength() + nExcelServices ); for ( sal_Int32 index = 0; index < nExcelServices; ++index ) diff --git a/sc/source/ui/vba/vbapalette.cxx b/sc/source/ui/vba/vbapalette.cxx index 77a0d5dec03a..4c75a37923df 100644 --- a/sc/source/ui/vba/vbapalette.cxx +++ b/sc/source/ui/vba/vbapalette.cxx @@ -56,7 +56,7 @@ public: // Methods XIndexAccess virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException, std::exception) override { - return sizeof(spnDefColorTable8) / sizeof(spnDefColorTable8[0]); + return SAL_N_ELEMENTS(spnDefColorTable8); } virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index fdc80e336b6f..10e8c24dd24a 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -280,7 +280,7 @@ EventInfoHash& getEventTransInfo() { OUString sEventInfo; 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/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 24d0e68d1394..569469065e15 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -1041,7 +1041,7 @@ Color AnnotationManagerImpl::GetColor(sal_uInt16 aAuthorIndex) COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL, COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL }; - return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]); + return Color( aArrayNormal[ aAuthorIndex % SAL_N_ELEMENTS( aArrayNormal ) ] ); } return Color(COL_WHITE); @@ -1056,7 +1056,7 @@ Color AnnotationManagerImpl::GetColorLight(sal_uInt16 aAuthorIndex) COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT, COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT }; - return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]); + return Color( aArrayLight[ aAuthorIndex % SAL_N_ELEMENTS( aArrayLight ) ] ); } return Color(COL_WHITE); @@ -1071,7 +1071,7 @@ Color AnnotationManagerImpl::GetColorDark(sal_uInt16 aAuthorIndex) COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; - return Color( aArrayAnkor[ aAuthorIndex % (sizeof( aArrayAnkor ) / sizeof( aArrayAnkor[0] ))]); + return Color( aArrayAnkor[ aAuthorIndex % SAL_N_ELEMENTS( aArrayAnkor ) ] ); } return Color(COL_WHITE); diff --git a/setup_native/source/win32/wintools/makecab/makecab.c b/setup_native/source/win32/wintools/makecab/makecab.c index 4acdc9fc315d..a5c7acda1a8e 100644 --- a/setup_native/source/win32/wintools/makecab/makecab.c +++ b/setup_native/source/win32/wintools/makecab/makecab.c @@ -61,7 +61,7 @@ void cabLogErr(PERF erf, char * msg) if (erf->erfOper >= 0) { - if (erf->erfOper < (sizeof(FCI_ERRS)/sizeof(FCI_ERRS[0]))) + if (erf->erfOper < SAL_N_ELEMENTS(FCI_ERRS)) cabLog(CABLOG_ERR, "%s: %s", msg, FCI_ERRS[erf->erfOper]); else cabLog(CABLOG_ERR, "%s: Unknown error", msg); diff --git a/setup_native/source/win32/wintools/msidb/msidb.c b/setup_native/source/win32/wintools/msidb/msidb.c index 733fe58b1205..2c100975fe7b 100644 --- a/setup_native/source/win32/wintools/msidb/msidb.c +++ b/setup_native/source/win32/wintools/msidb/msidb.c @@ -441,7 +441,7 @@ static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[]) MSIHANDLE dbhandle, tableListView, rec; LPWSTR tableFile = 0; WCHAR tableName[MAX_TABLE_NAME]; - DWORD size = sizeof(tableName) / sizeof(tableName[0]); + DWORD size = SAL_N_ELEMENTS(tableName); int i = 0; r = MsiOpenDatabaseW(dbfile, (LPCWSTR) MSIDBOPEN_READONLY, &dbhandle); @@ -456,7 +456,7 @@ static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[]) while (r == ERROR_SUCCESS) { - size = sizeof(tableName) / sizeof(tableName[0]); + size = SAL_N_ELEMENTS(tableName); r = MsiRecordGetStringW(rec, 1, tableName, &size); if (r == ERROR_SUCCESS) { diff --git a/sfx2/source/dialog/printopt.cxx b/sfx2/source/dialog/printopt.cxx index e68ab4cd6827..9ae649655c24 100644 --- a/sfx2/source/dialog/printopt.cxx +++ b/sfx2/source/dialog/printopt.cxx @@ -34,7 +34,7 @@ static sal_uInt16 aDPIArray[] = { 72, 96, 150, 200, 300, 600 }; static bool bOutputForPrinter = true; -#define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ])) +#define DPI_COUNT SAL_N_ELEMENTS(aDPIArray) SfxCommonPrintOptionsTabPage::SfxCommonPrintOptionsTabPage( vcl::Window* pParent, const SfxItemSet& rSet ) : SfxTabPage(pParent, "OptPrintPage", "sfx/ui/optprintpage.ui", &rSet) @@ -257,8 +257,8 @@ void SfxCommonPrintOptionsTabPage::ImplSaveControls( PrinterOptions* pCurrentOpt pCurrentOptions->SetReduceBitmaps( m_pReduceBitmapsCB->IsChecked() ); pCurrentOptions->SetReducedBitmapMode( m_pReduceBitmapsOptimalRB->IsChecked() ? PRINTER_BITMAP_OPTIMAL : ( m_pReduceBitmapsNormalRB->IsChecked() ? PRINTER_BITMAP_NORMAL : PRINTER_BITMAP_RESOLUTION ) ); - pCurrentOptions->SetReducedBitmapResolution( aDPIArray[ std::min( (sal_uInt16) m_pReduceBitmapsResolutionLB->GetSelectEntryPos(), - (sal_uInt16)( (sizeof (aDPIArray) / sizeof (aDPIArray[0])) - 1 ) ) ] ); + pCurrentOptions->SetReducedBitmapResolution( aDPIArray[ std::min<sal_uInt16>( m_pReduceBitmapsResolutionLB->GetSelectEntryPos(), + SAL_N_ELEMENTS(aDPIArray) - 1 ) ] ); pCurrentOptions->SetReducedBitmapIncludesTransparency( m_pReduceBitmapsTransparencyCB->IsChecked() ); pCurrentOptions->SetConvertToGreyscales( m_pConvertToGreyscalesCB->IsChecked() ); bool bOrigBackEnd = pCurrentOptions->IsPDFAsStandardPrintJobFormat(); diff --git a/shell/inc/internal/fileextensions.hxx b/shell/inc/internal/fileextensions.hxx index 119c626da881..53c91064b2a8 100644 --- a/shell/inc/internal/fileextensions.hxx +++ b/shell/inc/internal/fileextensions.hxx @@ -39,9 +39,9 @@ struct FileExtensionEntry const char* RegistryForwardKey; // e.g. "soffice.StarWriterDocument.6" }; -extern FileExtensionEntry OOFileExtensionTable[]; +extern const FileExtensionEntry OOFileExtensionTable[]; -extern size_t OOFileExtensionTableSize; +extern const size_t OOFileExtensionTableSize; /** Return the extension of a file diff --git a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx index 8f3f11e5a4b7..c72c298f2edf 100644 --- a/shell/source/win32/shlxthandler/columninfo/columninfo.cxx +++ b/shell/source/win32/shlxthandler/columninfo/columninfo.cxx @@ -29,7 +29,7 @@ namespace /* private */ { - SHCOLUMNINFO ColumnInfoTable[] = + const SHCOLUMNINFO ColumnInfoTable[] = { {{PSGUID_SUMMARYINFORMATION, PIDSI_TITLE}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Title", L"Title"}, {{PSGUID_SUMMARYINFORMATION, PIDSI_AUTHOR}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Author", L"Author"}, @@ -39,7 +39,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); } @@ -114,7 +114,7 @@ HRESULT STDMETHODCALLTYPE CColumnInfo::GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO psci->scid.pid = ColumnInfoTable[dwIndex].scid.pid; ZeroMemory(psci->wszTitle, sizeof(psci->wszTitle)); wcsncpy(psci->wszTitle, ColumnInfoTable[dwIndex].wszTitle, - (sizeof(psci->wszTitle) / sizeof(psci->wszTitle[0]) - 1)); + SAL_N_ELEMENTS(psci->wszTitle) - 1); return S_OK; } diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx index b842234bfba1..1f8e7aacf4ea 100644 --- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -47,7 +47,7 @@ struct PROPERTYMAP PCWSTR pszValueNodeName; }; -PROPERTYMAP g_rgPROPERTYMAP[] = +const PROPERTYMAP g_rgPROPERTYMAP[] = { { PKEY_Title, L"LibreOffice", L"Title" }, { PKEY_Author, L"LibreOffice", L"Author" }, @@ -56,7 +56,7 @@ PROPERTYMAP g_rgPROPERTYMAP[] = { PKEY_Comment, L"LibreOffice", L"Comments" }, }; -size_t gPropertyMapTableSize = sizeof(g_rgPROPERTYMAP)/sizeof(g_rgPROPERTYMAP[0]); +size_t gPropertyMapTableSize = SAL_N_ELEMENTS(g_rgPROPERTYMAP); CPropertyHdl::CPropertyHdl( long nRefCnt ) : diff --git a/shell/source/win32/shlxthandler/util/fileextensions.cxx b/shell/source/win32/shlxthandler/util/fileextensions.cxx index b827e5c896c8..8d0028d42fdf 100644 --- a/shell/source/win32/shlxthandler/util/fileextensions.cxx +++ b/shell/source/win32/shlxthandler/util/fileextensions.cxx @@ -30,7 +30,7 @@ const std::string MATH_FILE_EXTENSIONS = "sxmodf"; const std::string WEB_FILE_EXTENSIONS = "oth"; const std::string DATABASE_FILE_EXTENSIONS = "odb"; -FileExtensionEntry OOFileExtensionTable[] = { +const FileExtensionEntry OOFileExtensionTable[] = { { ".sxw", L".sxw", "soffice.StarWriterDocument.6" }, { ".sxc", L".sxc", "soffice.StarCalcDocument.6" }, { ".sxi", L".sxi", "soffice.StarImpressDocument.6" }, @@ -56,7 +56,7 @@ FileExtensionEntry OOFileExtensionTable[] = { }; -size_t OOFileExtensionTableSize = sizeof(OOFileExtensionTable)/sizeof(OOFileExtensionTable[0]); +const 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 a17df2161114..6c0b14e7117d 100644 --- a/shell/source/win32/simplemail/senddoc.cxx +++ b/shell/source/win32/simplemail/senddoc.cxx @@ -183,7 +183,7 @@ const 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/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 912bed33d0a1..299c7331f4ad 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1593,7 +1593,7 @@ void FmXGridPeer::addColumnListeners(const Reference< XPropertySet >& xCol) Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo(); Property aPropDesc; const OUString* pProps = aPropsListenedTo; - const OUString* pPropsEnd = pProps + sizeof( aPropsListenedTo ) / sizeof( aPropsListenedTo[ 0 ] ); + const OUString* pPropsEnd = pProps + SAL_N_ELEMENTS( aPropsListenedTo ); for (; pProps != pPropsEnd; ++pProps) { if ( xInfo->hasPropertyByName( *pProps ) ) @@ -2650,7 +2650,7 @@ Sequence<sal_uInt16>& FmXGridPeer::getSupportedGridSlots() static Sequence<sal_uInt16> aSupported; if (aSupported.getLength() == 0) { - sal_uInt16 nSupported[] = { + const sal_uInt16 nSupported[] = { DbGridControl::NavigationBar::RECORD_FIRST, DbGridControl::NavigationBar::RECORD_PREV, DbGridControl::NavigationBar::RECORD_NEXT, @@ -2658,7 +2658,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_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) *pSupported = nSupported[i]; @@ -2680,7 +2680,7 @@ Sequence< css::util::URL>& FmXGridPeer::getSupportedURLs() FMURL_RECORD_MOVETONEW, FMURL_RECORD_UNDO }; - aSupported.realloc(sizeof(sSupported)/sizeof(sSupported[0])); + aSupported.realloc(SAL_N_ELEMENTS(sSupported)); css::util::URL* pSupported = aSupported.getArray(); sal_uInt16 i; diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index 37502f11eee9..590b374f3dbd 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -132,7 +132,7 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const OS InternationalKeyCode::Collect, InternationalKeyCode::Fusion, InternationalKeyCode::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++) { OString aKey = getIntlKeywordAscii(Intl_TokenID[i]); diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index f0e3abc90ab9..3f017c207b20 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -548,7 +548,7 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) ::cppu::ContextEntry_Init( OUString( "ControlShapeAccess" ), makeAny( xControlMap ) ) }; m_xInspectorContext.set( - ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), + ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), m_xORB ) ); bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx index ec6aabfee384..a11a99eaaa1d 100644 --- a/svx/source/form/fmdmod.cxx +++ b/svx/source/form/fmdmod.cxx @@ -85,7 +85,7 @@ SAL_WNOUNREACHABLE_CODE_POP OUString(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< OUString > aSeq( nSvxComponentServiceNameListCount ); OUString* pStrings = aSeq.getArray(); diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index e07570a14778..e49af1dc8abe 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -548,8 +548,8 @@ void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt) OUString(FM_PROP_TEXT), OUString(FM_PROP_STATE), OUString(FM_PROP_DATE), OUString(FM_PROP_TIME), OUString(FM_PROP_VALUE), OUString(FM_PROP_SELECT_SEQ), OUString(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 14bc9c9be11e..6845ad6e8b0a 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -417,7 +417,7 @@ namespace svx // but on the medium term, we are to support everything listed // here ::std::vector< sal_Int32 > aSupportedFeatures; - sal_Int32 pSupportedFeatures[] = + const sal_Int32 pSupportedFeatures[] = { SID_FM_RECORD_FIRST, SID_FM_RECORD_NEXT, @@ -442,7 +442,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/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 0093fcdfa77b..feca7d3cdee8 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -364,8 +364,7 @@ static char const*const g_ServicesBookmark[] = "com.sun.star.text.Bookmark", "com.sun.star.document.LinkTarget", }; -static const size_t g_nServicesBookmark( - sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0])); +static const size_t g_nServicesBookmark(SAL_N_ELEMENTS(g_ServicesBookmark)); sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 24f9980ae3cb..ca5a12bd86f7 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -475,7 +475,7 @@ OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType) { SolarMutexGuard aGuard; OUString sRet; - const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); + const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId); if(nObjectType < nEntries) sRet = OUString::createFromAscii(aProvNamesId[nObjectType].pName); return sRet; @@ -483,7 +483,7 @@ OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType) uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames() { - const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); + const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId); uno::Sequence<OUString> aRet(nEntries); OUString* pArray = aRet.getArray(); sal_uInt16 n = 0; @@ -503,7 +503,7 @@ uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames() sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName) { - const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); + const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId); for(sal_uInt16 i = 0; i < nEntries; i++ ) { if (rServiceName.equalsAscii(aProvNamesId[i].pName)) diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 101732863770..790a1379a225 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -194,7 +194,7 @@ static char const*const g_ServicesFootnote[] = "com.sun.star.text.Endnote", // NB: only supported for endnotes! }; -static const size_t g_nServicesEndnote( sizeof (g_ServicesFootnote) / sizeof (g_ServicesFootnote[0]) ); +static const size_t g_nServicesEndnote( SAL_N_ELEMENTS(g_ServicesFootnote) ); static const size_t g_nServicesFootnote( g_nServicesEndnote - 1 ); // NB: omit! diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 56de02bc78d7..f97508891e88 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -850,8 +850,7 @@ static char const*const g_ServicesTextCursor[] = "com.sun.star.text.TextSortable", }; -static const size_t g_nServicesTextCursor( - sizeof(g_ServicesTextCursor)/sizeof(g_ServicesTextCursor[0])); +static const size_t g_nServicesTextCursor(SAL_N_ELEMENTS(g_ServicesTextCursor)); sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 9ef2c2eaa1c3..7c95bb340d9a 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -868,8 +868,7 @@ static char const*const g_ServicesTextRange[] = "com.sun.star.style.ParagraphPropertiesComplex", }; -static const size_t g_nServicesTextRange( - sizeof(g_ServicesTextRange)/sizeof(g_ServicesTextRange[0])); +static const size_t g_nServicesTextRange(SAL_N_ELEMENTS(g_ServicesTextRange)); sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 93cfc6cb49dc..39417de5c410 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -313,8 +313,7 @@ static char const*const g_ServicesParagraph[] = "com.sun.star.style.ParagraphPropertiesComplex", }; -static const size_t g_nServicesParagraph( - sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0])); +static const size_t g_nServicesParagraph(SAL_N_ELEMENTS(g_ServicesParagraph)); sal_Bool SAL_CALL SwXParagraph::supportsService(const OUString& rServiceName) diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index f90c4afb493a..2baff9752f66 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -168,8 +168,7 @@ static char const*const g_ServicesReferenceMark[] = "com.sun.star.text.ReferenceMark", }; -static const size_t g_nServicesReferenceMark( - sizeof(g_ServicesReferenceMark)/sizeof(g_ServicesReferenceMark[0])); +static const size_t g_nServicesReferenceMark(SAL_N_ELEMENTS(g_ServicesReferenceMark)); sal_Bool SAL_CALL SwXReferenceMark::supportsService(const OUString& rServiceName) @@ -906,8 +905,7 @@ static char const*const g_ServicesMeta[] = "com.sun.star.text.InContentMetadata", }; -static const size_t g_nServicesMeta( - sizeof(g_ServicesMeta)/sizeof(g_ServicesMeta[0])); +static const size_t g_nServicesMeta(SAL_N_ELEMENTS(g_ServicesMeta)); sal_Bool SAL_CALL SwXMeta::supportsService(const OUString& rServiceName) @@ -1331,8 +1329,7 @@ static char const*const g_ServicesMetaField[] = "com.sun.star.text.textfield.MetadataField", }; -static const size_t g_nServicesMetaField( - sizeof(g_ServicesMetaField)/sizeof(g_ServicesMetaField[0])); +static const size_t g_nServicesMetaField(SAL_N_ELEMENTS(g_ServicesMetaField)); sal_Bool SAL_CALL SwXMetaField::supportsService(const OUString& rServiceName) diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 6c8443df8c74..caf84cc8332d 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2385,8 +2385,7 @@ static char const*const g_ServicesBodyText[] = "com.sun.star.text.Text", }; -static const size_t g_nServicesBodyText( - sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0])); +static const size_t g_nServicesBodyText(SAL_N_ELEMENTS(g_ServicesBodyText)); sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) diff --git a/sw/source/filter/ww8/fields.cxx b/sw/source/filter/ww8/fields.cxx index d95ccf12de4b..68a58d856f33 100644 --- a/sw/source/filter/ww8/fields.cxx +++ b/sw/source/filter/ww8/fields.cxx @@ -130,7 +130,7 @@ namespace ww }; size_t nIndex = static_cast<size_t>(eIndex); - if (nIndex >= sizeof(aFieldNames) / sizeof(aFieldNames[0])) + if (nIndex >= SAL_N_ELEMENTS(aFieldNames)) eIndex = eNONE; OSL_ENSURE(eIndex != eNONE, "Unknown WinWord Field"); return aFieldNames[eIndex]; diff --git a/sw/source/filter/ww8/styles.cxx b/sw/source/filter/ww8/styles.cxx index 47c2f87ff620..43c10223b815 100644 --- a/sw/source/filter/ww8/styles.cxx +++ b/sw/source/filter/ww8/styles.cxx @@ -123,7 +123,7 @@ namespace "Plain Text" }; - OSL_ENSURE( (sizeof (stiName) / sizeof (stiName[0])) == ww::stiMax, "WrongSizeOfArray" ); + OSL_ENSURE( SAL_N_ELEMENTS(stiName) == ww::stiMax, "WrongSizeOfArray" ); return stiName; } diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 7c480d4ea5c3..666b6c1501ac 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -246,7 +246,7 @@ static void SetFill( SfxItemSet& rSet, WW8_DP_FILL& rFill ) else { rSet.Put(XFillStyleItem(drawing::FillStyle_SOLID)); // necessary for textbox - if (nPat <= 1 || ((sizeof(nPatA)/sizeof(nPatA[0])) <= nPat)) + if (nPat <= 1 || (SAL_N_ELEMENTS(nPatA) <= nPat)) { // Solid background or unknown rSet.Put(XFillColorItem(OUString(), WW8TransCol(rFill.dlpcBg))); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index a50f946ff5b1..555b07ab814c 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -870,7 +870,7 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes) sal_uInt16 nI = n / 32; // # des sal_uInt32 sal_uInt32 nMask = 1 << ( n % 32 ); // Maske fuer Bits - if ((sizeof(m_nFieldTagAlways)/sizeof(m_nFieldTagAlways[0])) <= nI) + if (SAL_N_ELEMENTS(m_nFieldTagAlways) <= nI) { // if indexes larger than 95 are needed, then a new configuration // item has to be added, and nFieldTagAlways/nFieldTagBad expanded! return aF.nLen; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 92176e2eb418..e6438b48122e 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -4633,7 +4633,7 @@ void SwWW8Shade::SetShade(ColorData nFore, ColorData nBack, sal_uInt16 nIndex) if (nUseBack == COL_AUTO) nUseBack = COL_WHITE; - if( nIndex >= sizeof( eMSGrayScale ) / sizeof ( eMSGrayScale[ 0 ] ) ) + if( nIndex >= SAL_N_ELEMENTS( eMSGrayScale ) ) nIndex = 0; sal_uLong nWW8BrushStyle = eMSGrayScale[nIndex]; @@ -5246,7 +5246,7 @@ const wwSprmDispatcher *GetWW2SprmDispatcher() {99, nullptr} //"sprmPicBrcRight", }; - static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmDispatcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; } @@ -5608,7 +5608,7 @@ const wwSprmDispatcher *GetWW6SprmDispatcher() {207, nullptr}, //dunno }; - static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmDispatcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; } @@ -6200,7 +6200,7 @@ const wwSprmDispatcher *GetWW8SprmDispatcher() {0x246D, &SwWW8ImplReader::Read_ParaContextualSpacing} //"sprmPFContextualSpacing" }; - static wwSprmDispatcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmDispatcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index fef78966ffe7..3cd227c5a093 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -246,7 +246,7 @@ const wwSprmSearcher *wwSprmParser::GetWW2SprmSearcher() {164, { 4, L_FIX} }, // "sprmTSetShd", tap.rgshd complex 4 bytes }; - static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; }; @@ -429,7 +429,7 @@ const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher() {207, { 0, L_VAR} } // rtl property ? }; - static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; }; @@ -769,7 +769,7 @@ const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher() {0x246D, { 1, L_FIX} } }; - static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0])); + static wwSprmSearcher aSprmSrch(aSprms, SAL_N_ELEMENTS(aSprms)); return &aSprmSrch; }; diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index d33e9f504f65..c8524558f875 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1239,7 +1239,7 @@ static const char* s_EventNames[] = "OnFieldMergeFinished", "OnLayoutFinished" }; -static sal_Int32 const s_nEvents(sizeof(s_EventNames)/sizeof(s_EventNames[0])); +static sal_Int32 const s_nEvents(SAL_N_ELEMENTS(s_EventNames)); Sequence< OUString > SwDocShell::GetEventNames() { diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index da865f453a5d..4a7d0049ac5e 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -649,8 +649,8 @@ void SwDocShell::SubInitNew() 0, 0, 0 }; if(!bWeb) { - nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 3 ] = RES_PARATR_TABSTOP; - nRange[ (sizeof(nRange)/sizeof(nRange[0])) - 2 ] = RES_PARATR_HYPHENZONE; + nRange[ SAL_N_ELEMENTS(nRange) - 3 ] = RES_PARATR_TABSTOP; + nRange[ SAL_N_ELEMENTS(nRange) - 2 ] = RES_PARATR_HYPHENZONE; } SfxItemSet aDfltSet( m_pDoc->GetAttrPool(), nRange ); diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 70c07fd63655..f37e52536266 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1907,7 +1907,7 @@ Color SwPostItMgr::GetColorDark(sal_uInt16 aAuthorIndex) COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL, COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL }; - return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]); + return Color( aArrayNormal[ aAuthorIndex % SAL_N_ELEMENTS( aArrayNormal )]); } else return Color(COL_WHITE); @@ -1922,7 +1922,7 @@ Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex) COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT, COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT }; - return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]); + return Color( aArrayLight[ aAuthorIndex % SAL_N_ELEMENTS( aArrayLight )]); } else return Color(COL_WHITE); @@ -1937,7 +1937,7 @@ Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex) COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; - return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]); + return Color( aArrayAnchor[ aAuthorIndex % SAL_N_ELEMENTS( aArrayAnchor )]); } else return Color(COL_WHITE); diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 184c49980817..e0e3c097075a 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -470,8 +470,7 @@ void SwOneExampleFrame::CreatePopup(const Point& rPt) sal_Int16 nZoom = 0; aZoom >>= nZoom; - for (sal_uInt16 i = 0; - i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i) + for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(nZoomValues); ++i) { OUString sTemp = unicode::formatPercent(nZoomValues[i], Application::GetSettings().GetUILanguageTag()); @@ -490,7 +489,7 @@ IMPL_LINK_TYPED(SwOneExampleFrame, PopupHdl, Menu*, pMenu, bool ) { sal_uInt16 nId = pMenu->GetCurItemId(); if ((nId > ITEM_ZOOM) && - (nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0]))))) + (nId <= (ITEM_ZOOM + SAL_N_ELEMENTS(nZoomValues)))) { sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1]; uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 72c58379e14e..c9f853e0ef8c 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -614,7 +614,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 5305486ab933..d1f45e91e52d 100644 --- a/ucb/source/ucp/gio/gio_content.cxx +++ b/ucb/source/ucp/gio/gio_content.cxx @@ -1266,7 +1266,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 ); } @@ -1308,7 +1308,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< uc -1, cppu::UnoType<ucb::ContentInfo>::get() ) }; - 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 b30465ed1076..c8094aef3d35 100644 --- a/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx +++ b/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx @@ -66,10 +66,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 ) ) // IMPORTANT: If any property data ( name / type / ... ) are changed, then diff --git a/ucb/source/ucp/package/pkgcontentcaps.cxx b/ucb/source/ucp/package/pkgcontentcaps.cxx index 1234293b96cf..9e6988e60018 100644 --- a/ucb/source/ucp/package/pkgcontentcaps.cxx +++ b/ucb/source/ucp/package/pkgcontentcaps.cxx @@ -67,10 +67,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 ) ) // IMPORTANT: If any property data ( name / type / ... ) are changed, then diff --git a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx index ed469afbc858..254cb27a7cd9 100644 --- a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx +++ b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx @@ -77,10 +77,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_ELEMENTS(a) ) #define MAKECMDSEQUENCE( a ) \ - uno::Sequence< ucb::CommandInfo >( a, (sizeof (a) / sizeof (a[0])) ) + uno::Sequence< ucb::CommandInfo >( a, SAL_N_ELEMENTS(a) ) // IMPORTANT: If any property data ( name / type / ... ) are changed, then diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index b468f8c0e16c..5e0c3ed6a55c 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -324,7 +324,7 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const OUString& MacroName, const uno: // 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 fd19e4a3cb58..d0a617598d39 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -56,7 +56,7 @@ const uno::Reference< uno::XComponentContext >& xContext, const OUString& sDocCt // some strange behavior mxContext = ::cppu::createComponentContext( aHandlerContextInfo, - ( sizeof ( aHandlerContextInfo ) / sizeof ( aHandlerContextInfo[0] ) ), nullptr ); + SAL_N_ELEMENTS( aHandlerContextInfo ), nullptr ); if ( aSrvMgr.is() ) { try diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 0b24033477da..d6ecb786a74d 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -584,9 +584,9 @@ 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 - static const sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]); - static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); - static const sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); + static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags); OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount), "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (2)!"); #endif @@ -625,9 +625,9 @@ namespace xmloff exportedProperty(PROPERTY_MAXTEXTLENGTH); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nIdCount = sizeof(nIntegerPropertyAttributeIds) / sizeof(nIntegerPropertyAttributeIds[0]); - static const sal_Int32 nNameCount = sizeof(pIntegerPropertyNames) / sizeof(pIntegerPropertyNames[0]); - static const sal_Int32 nDefaultCount = sizeof(nIntegerPropertyAttrDefaults) / sizeof(nIntegerPropertyAttrDefaults[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nIntegerPropertyAttributeIds); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pIntegerPropertyNames); + static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nIntegerPropertyAttrDefaults); OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nDefaultCount), "OControlExport::exportCommonControlAttributes: somebody tampered with the maps (3)!"); #endif @@ -977,9 +977,9 @@ namespace xmloff PROPERTY_DEFAULTBUTTON, PROPERTY_TRISTATE, PROPERTY_TOGGLE, PROPERTY_FOCUS_ON_CLICK }; - static const sal_Int32 nIdCount = sizeof(nBooleanPropertyAttributeIds) / sizeof(nBooleanPropertyAttributeIds[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(nBooleanPropertyAttributeIds); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); OSL_ENSURE((nIdCount == nNameCount), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!"); #endif @@ -1017,12 +1017,12 @@ namespace xmloff 10 }; - static const sal_Int32 nIdCount = sizeof( nIntegerPropertyAttributeIds ) / sizeof( nIntegerPropertyAttributeIds[0] ); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nIntegerPropertyAttributeIds ); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof( pIntegerPropertyNames ) / sizeof( pIntegerPropertyNames[0] ); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pIntegerPropertyNames ); OSL_ENSURE( ( nIdCount == nNameCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" ); - static const sal_Int32 nDefaultCount = sizeof( nIntegerPropertyAttrDefaults ) / sizeof( nIntegerPropertyAttrDefaults[0] ); + static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS( nIntegerPropertyAttrDefaults ); OSL_ENSURE( ( nIdCount == nDefaultCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (3)!" ); #endif @@ -1164,9 +1164,9 @@ namespace xmloff OUString(PROPERTY_GROUP_NAME) }; - static const sal_Int32 nIdCount = sizeof( nStringPropertyAttributeIds ) / sizeof( nStringPropertyAttributeIds[0] ); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS( nStringPropertyAttributeIds ); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof( pStringPropertyNames ) / sizeof( pStringPropertyNames[0] ); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS( pStringPropertyNames ); OSL_ENSURE( ( nIdCount == nNameCount ), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (2)!" ); #endif @@ -2093,9 +2093,9 @@ namespace xmloff { PROPERTY_NAME, /*PROPERTY_TARGETURL,*/ PROPERTY_COMMAND, PROPERTY_FILTER, PROPERTY_ORDER }; - static const sal_Int32 nIdCount = sizeof(eStringPropertyIds) / sizeof(eStringPropertyIds[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eStringPropertyIds); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof(aStringPropertyNames) / sizeof(aStringPropertyNames[0]); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(aStringPropertyNames); OSL_ENSURE((nIdCount == nNameCount), "OFormExport::exportAttributes: somebody tampered with the maps (1)!"); #endif @@ -2146,10 +2146,10 @@ namespace xmloff { BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE, BOOLATTR_DEFAULT_TRUE, BOOLATTR_DEFAULT_FALSE }; - static const sal_Int32 nIdCount = sizeof(eBooleanPropertyIds) / sizeof(eBooleanPropertyIds[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eBooleanPropertyIds); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof(pBooleanPropertyNames) / sizeof(pBooleanPropertyNames[0]); - static const sal_Int32 nFlagsCount = sizeof(nBooleanPropertyAttrFlags) / sizeof(nBooleanPropertyAttrFlags[0]); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pBooleanPropertyNames); + static const sal_Int32 nFlagsCount = SAL_N_ELEMENTS(nBooleanPropertyAttrFlags); OSL_ENSURE((nIdCount == nNameCount) && (nNameCount == nFlagsCount), "OFormExport::exportAttributes: somebody tampered with the maps (2)!"); #endif @@ -2184,12 +2184,12 @@ namespace xmloff { sal_False, sal_False, sal_False, sal_False, sal_True }; - static const sal_Int32 nIdCount = sizeof(eEnumPropertyIds) / sizeof(eEnumPropertyIds[0]); + static const sal_Int32 nIdCount = SAL_N_ELEMENTS(eEnumPropertyIds); #if OSL_DEBUG_LEVEL > 0 - static const sal_Int32 nNameCount = sizeof(pEnumPropertyNames) / sizeof(pEnumPropertyNames[0]); - static const sal_Int32 nDefaultCount = sizeof(nEnumPropertyAttrDefaults) / sizeof(nEnumPropertyAttrDefaults[0]); - static const sal_Int32 nDefaultFlagCount = sizeof(nEnumPropertyAttrDefaultFlags) / sizeof(nEnumPropertyAttrDefaultFlags[0]); - static const sal_Int32 nMapCount = sizeof(eEnumPropertyMaps) / sizeof(eEnumPropertyMaps[0]); + static const sal_Int32 nNameCount = SAL_N_ELEMENTS(pEnumPropertyNames); + static const sal_Int32 nDefaultCount = SAL_N_ELEMENTS(nEnumPropertyAttrDefaults); + static const sal_Int32 nDefaultFlagCount = SAL_N_ELEMENTS(nEnumPropertyAttrDefaultFlags); + static const 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 |