diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-03-28 17:12:04 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-03-31 08:00:13 +0000 |
commit | 1aa4df615fa5599d05e9dd5e925b5852676185fa (patch) | |
tree | 1f637fa13140941a5775c91f058d0742f911693f /reportdesign | |
parent | 2bd1e7aafeebdfe0e1656ed1ff01762039be5af1 (diff) |
use SAL_N_ELEMENTS in for loops
for with
git grep -n 'for.*sizeof'
Change-Id: I6211024385e03ac5eeeb38690d2c1c699e015c2f
Reviewed-on: https://gerrit.libreoffice.org/23569
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/filter/xml/xmlExport.cxx | 4 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/GroupsSorting.cxx | 24 | ||||
-rw-r--r-- | reportdesign/source/ui/inspection/DataProviderHandler.cxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/inspection/GeometryHandler.cxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/inspection/metadata.cxx | 4 | ||||
-rw-r--r-- | reportdesign/source/ui/misc/UITools.cxx | 4 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 22 | ||||
-rw-r--r-- | reportdesign/source/ui/report/propbrw.cxx | 2 |
8 files changed, 30 insertions, 34 deletions
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index 47790b1c796d..b6d936e41d3f 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -1566,8 +1566,8 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG sFunctionName = sFunction + "_" + sExpression; if ( !sFunction.isEmpty() ) { - sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'}; - for(sal_uInt32 j= 0; j < sizeof(pReplaceChars)/sizeof(pReplaceChars[0]);++j) + const sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'}; + for(sal_uInt32 j= 0; j < SAL_N_ELEMENTS(pReplaceChars);++j) sFunctionName = sFunctionName.replace(pReplaceChars[j],'_'); xFunction->setName(sFunctionName); diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 37b608b6fcc4..2beba3d1648b 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -393,12 +393,8 @@ void OFieldExpressionControl::lateInit() m_pComboCell->SetSelectHdl(LINK(this,OFieldExpressionControl,CBChangeHdl)); m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION); - Control* pControls[] = {m_pComboCell}; - for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i) - { - pControls[i]->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot)); - pControls[i]->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost)); - } + m_pComboCell->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot)); + m_pComboCell->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost)); // set browse mode @@ -965,14 +961,14 @@ OGroupsSortingDialog::OGroupsSortingDialog(vcl::Window* _pParent, bool _bReadOnl m_pFieldExpression->set_vexpand(true); Control* pControlsLst[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst, m_pGroupIntervalEd}; - for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst); ++i) { pControlsLst[i]->SetGetFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusGot)); pControlsLst[i]->SetLoseFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusLost)); pControlsLst[i]->Show(); } - for (size_t i = 0; i < (sizeof (pControlsLst) / sizeof (pControlsLst[0])) - 1; ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst) - 1; ++i) static_cast<ListBox*>(pControlsLst[i])->SetSelectHdl(LINK(this,OGroupsSortingDialog,LBChangeHdl)); m_pReportListener = new OPropertyChangeMultiplexer(this,m_pController->getReportDefinition().get()); @@ -1076,7 +1072,7 @@ void OGroupsSortingDialog::SaveData( sal_Int32 _nRow) xGroup->setSortAscending( m_pOrderLst->GetSelectEntryPos() == 0 ); ListBox* pControls[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst}; - for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i) pControls[i]->SaveValue(); } @@ -1108,7 +1104,7 @@ IMPL_LINK_TYPED(OGroupsSortingDialog, OnControlFocusGot, Control&, rControl, voi if ( m_pFieldExpression && m_pFieldExpression->getExpressionControl() ) { Control* pControls[] = { m_pFieldExpression->getExpressionControl(), m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pGroupIntervalEd, m_pKeepTogetherLst, m_pOrderLst}; - for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i) { if ( &rControl == pControls[i] ) { @@ -1252,8 +1248,8 @@ void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _x case sdbc::DataType::TIME: case sdbc::DataType::TIMESTAMP: { - sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE }; - for (sal_uInt16 i = 0; i < sizeof (nIds) / sizeof (nIds[0]); ++i) + const sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE }; + for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(nIds); ++i) { m_pGroupOnLst->InsertEntry(OUString(ModuleRes(nIds[i]))); m_pGroupOnLst->SetEntryData(i+1,reinterpret_cast<void*>(i+2)); @@ -1309,12 +1305,12 @@ void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _x m_pOrderLst->SelectEntryPos(_xGroup->getSortAscending() ? 0 : 1); ListBox* pControls[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst}; - for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControls); ++i) pControls[i]->SaveValue(); ListBox* pControlsLst2[] = { m_pHeaderLst, m_pFooterLst, m_pGroupOnLst, m_pKeepTogetherLst, m_pOrderLst}; bool bReadOnly = !m_pController->isEditable(); - for (size_t i = 0; i < sizeof(pControlsLst2)/sizeof(pControlsLst2[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pControlsLst2); ++i) pControlsLst2[i]->SetReadOnly(bReadOnly); m_pGroupIntervalEd->SetReadOnly(bReadOnly); } diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx index 1d56abb990dc..9b00832ab396 100644 --- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx +++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx @@ -374,7 +374,7 @@ uno::Sequence< beans::Property > SAL_CALL DataProviderHandler::getSupportedPrope ,OUString(PROPERTY_PREVIEW_COUNT) }; - for (size_t nPos = 0; nPos < sizeof(s_pProperties)/sizeof(s_pProperties[0]) ;++nPos ) + for (size_t nPos = 0; nPos < SAL_N_ELEMENTS(s_pProperties); ++nPos ) { aValue.Name = s_pProperties[nPos]; aNewProps.push_back(aValue); diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx index 44d457a26f88..fd9830629360 100644 --- a/reportdesign/source/ui/inspection/GeometryHandler.cxx +++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx @@ -1309,7 +1309,7 @@ uno::Sequence< beans::Property > SAL_CALL GeometryHandler::getSupportedPropertie }; const uno::Reference < beans::XPropertySetInfo > xInfo = m_xReportComponent->getPropertySetInfo(); const uno::Sequence< beans::Property> aSeq = xInfo->getProperties(); - for (size_t i = 0; i < sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i ) + for (size_t i = 0; i < SAL_N_ELEMENTS(pIncludeProperties); ++i ) { const beans::Property* pIter = aSeq.getConstArray(); const beans::Property* pEnd = pIter + aSeq.getLength(); diff --git a/reportdesign/source/ui/inspection/metadata.cxx b/reportdesign/source/ui/inspection/metadata.cxx index 6cff81182202..b0c6c4cbf975 100644 --- a/reportdesign/source/ui/inspection/metadata.cxx +++ b/reportdesign/source/ui/inspection/metadata.cxx @@ -294,9 +294,9 @@ namespace rptui for (; pPropsIter != pPropsEnd; ++pPropsIter) { size_t nPos = 0; - for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos ) + for (; nPos < SAL_N_ELEMENTS(pExcludeProperties) && pExcludeProperties[nPos] != pPropsIter->Name; ++nPos ) ; - if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) ) + if ( nPos == SAL_N_ELEMENTS(pExcludeProperties) ) _rExcludeProperties.push_back(*pPropsIter); } } diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index a070c7e9d10c..007892cee423 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -540,7 +540,7 @@ namespace ,{ITEMID_LANGUAGE_ASIAN,OUString(PROPERTY_CHARLOCALEASIAN)} ,{ITEMID_LANGUAGE_COMPLEX,OUString(PROPERTY_CHARLOCALECOMPLEX)} }; - for(size_t k = 0; k < sizeof(pItems)/sizeof(pItems[0]);++k) + for(size_t k = 0; k < SAL_N_ELEMENTS(pItems); ++k) { if ( SfxItemState::SET == _rItemSet.GetItemState( pItems[k].nWhich,true,&pItem) && dynamic_cast< const SvxLanguageItem *>( pItem ) != nullptr) { @@ -730,7 +730,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep } SfxItemPool::Free(pPool); - for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i) delete pDefaults[i]; return bSuccess; diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 661e012195aa..8b42e4017233 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2094,7 +2094,7 @@ void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _ ,OUString("private:resource/toolbar/resizebar") ,OUString("private:resource/toolbar/sectionshrinkbar") }; - for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i) + for (size_t i = 0; i< SAL_N_ELEMENTS(s_sMenu); ++i) { _xLayoutManager->createElement( s_sMenu[i] ); _xLayoutManager->requestElement( s_sMenu[i] ); @@ -2537,7 +2537,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ } SfxItemPool::Free(pPool); - for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i) delete pDefaults[i]; } @@ -2724,7 +2724,7 @@ uno::Any SAL_CALL OReportController::getViewData() throw( uno::RuntimeException, { ::osl::MutexGuard aGuard( getMutex() ); - sal_Int32 nCommandIDs[] = + const sal_Int32 nCommandIDs[] = { SID_GRID_VISIBLE, SID_GRID_USE, @@ -2736,7 +2736,7 @@ uno::Any SAL_CALL OReportController::getViewData() throw( uno::RuntimeException, }; ::comphelper::NamedValueCollection aCommandProperties; - for ( size_t i=0; i < sizeof (nCommandIDs) / sizeof (nCommandIDs[0]); ++i ) + for ( size_t i=0; i < SAL_N_ELEMENTS(nCommandIDs); ++i ) { const FeatureState aFeatureState = GetState( nCommandIDs[i] ); @@ -3209,7 +3209,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co ,OUString(PROPERTY_FORMATSSUPPLIER) ,OUString(PROPERTY_BACKGROUNDCOLOR) }; - for(size_t i = 0; i < sizeof (sProps) / sizeof (sProps[0]); ++i) + for(size_t i = 0; i < SAL_N_ELEMENTS(sProps); ++i) { if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) ) xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i])); @@ -3493,7 +3493,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) OUString sDefaultName; size_t i = 0; OUnoObject* pObjs[2]; - for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) + for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) { pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]); uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW); @@ -3508,7 +3508,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) ,OUString(PROPERTY_BORDER) ,OUString(PROPERTY_BACKGROUNDCOLOR) }; - for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k) + for(size_t k = 0; k < SAL_N_ELEMENTS(sProps); ++k) { if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) ) xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k])); @@ -3570,7 +3570,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW); xShapeProp->setName(xShapeProp->getName() + sDefaultName ); - for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls + for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) // insert controls { correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection()); } @@ -3619,7 +3619,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) } else { - for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) + for(size_t i = 0; i < SAL_N_ELEMENTS(pControl); ++i) delete pControl[i]; } } @@ -3680,7 +3680,7 @@ void OReportController::listen(const bool _bAdd) void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const OUString&, const uno::Reference< XPropertyChangeListener >& ) = _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener; - for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i) (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) ); OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv(); @@ -4260,7 +4260,7 @@ void OReportController::openZoomDialog() } SfxItemPool::Free(pPool); - for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(pDefaults); ++i) delete pDefaults[i]; } } diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index 77a6c077939b..64461637c975 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -194,7 +194,7 @@ void PropBrw::dispose() const OUString pProps[] = { OUString( "ContextDocument" ) , OUString( "DialogParentWindow" ) , OUString( "ActiveConnection" )}; - for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(pProps); ++i) xName->removeByName(pProps[i]); } } |