[Libreoffice-commits] core.git: reportdesign/source sal/rtl sax/source sax/test
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Feb 12 06:37:35 UTC 2019
reportdesign/source/core/api/FormattedField.cxx | 8
reportdesign/source/core/api/ReportDefinition.cxx | 24 -
reportdesign/source/core/misc/conditionupdater.cxx | 9
reportdesign/source/core/sdr/PropertyForward.cxx | 16
reportdesign/source/core/sdr/RptPage.cxx | 6
reportdesign/source/core/sdr/formatnormalizer.cxx | 8
reportdesign/source/filter/xml/xmlAutoStyle.cxx | 12
reportdesign/source/filter/xml/xmlExport.cxx | 21 -
reportdesign/source/filter/xml/xmlReport.cxx | 6
reportdesign/source/filter/xml/xmlTable.cxx | 102 ++---
reportdesign/source/ui/dlg/CondFormat.cxx | 25 -
reportdesign/source/ui/dlg/Condition.cxx | 9
reportdesign/source/ui/dlg/GroupsSorting.cxx | 13
reportdesign/source/ui/inspection/GeometryHandler.cxx | 87 ++--
reportdesign/source/ui/misc/RptUndo.cxx | 10
reportdesign/source/ui/misc/UITools.cxx | 26 -
reportdesign/source/ui/report/DesignView.cxx | 7
reportdesign/source/ui/report/ReportController.cxx | 59 +--
reportdesign/source/ui/report/ReportControllerObserver.cxx | 5
reportdesign/source/ui/report/ReportSection.cxx | 67 +--
reportdesign/source/ui/report/ViewsWindow.cxx | 247 ++++---------
sal/rtl/bootstrap.cxx | 11
sax/source/fastparser/fastparser.cxx | 20 -
sax/source/tools/fastattribs.cxx | 4
sax/source/tools/fastserializer.cxx | 10
sax/test/sax/testwriter.cxx | 26 -
sax/test/saxdemo.cxx | 22 -
27 files changed, 348 insertions(+), 512 deletions(-)
New commits:
commit 3f08be2e511dc2300021486a1cc2f1e8ba530373
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Tue Feb 12 00:00:22 2019 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Feb 12 07:37:08 2019 +0100
Simplify containers iterations in reportdesign, sal, sax
Use range-based loop or replace with STL functions
Change-Id: If6b734dab12a7298fce16003d3d175305fbe798d
Reviewed-on: https://gerrit.libreoffice.org/67701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/reportdesign/source/core/api/FormattedField.cxx b/reportdesign/source/core/api/FormattedField.cxx
index a50e79ab19fb..2727c9ed0022 100644
--- a/reportdesign/source/core/api/FormattedField.cxx
+++ b/reportdesign/source/core/api/FormattedField.cxx
@@ -216,13 +216,13 @@ uno::Reference< util::XCloneable > SAL_CALL OFormattedField::createClone( )
uno::Reference< report::XReportComponent> xSource = this;
uno::Reference< report::XFormattedField> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FORMATTEDFIELD),uno::UNO_QUERY_THROW);
- ::std::vector< uno::Reference< report::XFormatCondition> >::const_iterator aIter = m_aProps.m_aFormatConditions.begin();
- ::std::vector< uno::Reference< report::XFormatCondition> >::const_iterator aEnd = m_aProps.m_aFormatConditions.end();
- for (sal_Int32 i = 0; aIter != aEnd; ++aIter,++i)
+ sal_Int32 i = 0;
+ for (const auto& rxFormatCondition : m_aProps.m_aFormatConditions)
{
uno::Reference< report::XFormatCondition > xCond = xSet->createFormatCondition();
- ::comphelper::copyProperties(aIter->get(),xCond.get());
+ ::comphelper::copyProperties(rxFormatCondition.get(), xCond.get());
xSet->insertByIndex(i,uno::makeAny(xCond));
+ ++i;
}
return xSet.get();
}
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index c1d1699d8835..695334214042 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1079,15 +1079,13 @@ void SAL_CALL OReportDefinition::close(sal_Bool bDeliverOwnership)
::std::vector< uno::Reference< frame::XController> > aCopy = m_pImpl->m_aControllers;
- ::std::vector< uno::Reference< frame::XController> >::iterator aIter = aCopy.begin();
- ::std::vector< uno::Reference< frame::XController> >::const_iterator aEnd = aCopy.end();
- for (;aIter != aEnd ; ++aIter)
+ for (auto& rxController : aCopy)
{
- if ( aIter->is() )
+ if ( rxController.is() )
{
try
{
- uno::Reference< util::XCloseable> xFrame( (*aIter)->getFrame(), uno::UNO_QUERY );
+ uno::Reference< util::XCloseable> xFrame( rxController->getFrame(), uno::UNO_QUERY );
if ( xFrame.is() )
xFrame->close( bDeliverOwnership );
}
@@ -1844,15 +1842,13 @@ uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewDat
{
m_pImpl->m_xViewData.set( document::IndexedPropertyValues::create(m_aProps->m_xContext), uno::UNO_QUERY);
uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY);
- ::std::vector< uno::Reference< frame::XController> >::const_iterator aIter = m_pImpl->m_aControllers.begin();
- ::std::vector< uno::Reference< frame::XController> >::const_iterator aEnd = m_pImpl->m_aControllers.end();
- for (;aIter != aEnd ; ++aIter)
+ for (const auto& rxController : m_pImpl->m_aControllers)
{
- if ( aIter->is() )
+ if ( rxController.is() )
{
try
{
- xContainer->insertByIndex(xContainer->getCount(),(*aIter)->getViewData());
+ xContainer->insertByIndex(xContainer->getCount(), rxController->getViewData());
}
catch (const uno::Exception&)
{
@@ -2314,9 +2310,11 @@ uno::Sequence< OUString > SAL_CALL OStylesHelper::getElementNames( )
uno::Sequence< OUString > aNameList(m_aElementsPos.size());
OUString* pStringArray = aNameList.getArray();
- ::std::vector<TStyleElements::iterator>::const_iterator aEnd = m_aElementsPos.end();
- for(::std::vector<TStyleElements::iterator>::const_iterator aIter = m_aElementsPos.begin(); aIter != aEnd;++aIter,++pStringArray)
- *pStringArray = (*aIter)->first;
+ for(const auto& rIter : m_aElementsPos)
+ {
+ *pStringArray = rIter->first;
+ ++pStringArray;
+ }
return aNameList;
}
diff --git a/reportdesign/source/core/misc/conditionupdater.cxx b/reportdesign/source/core/misc/conditionupdater.cxx
index 59714ac22556..428c3b3e7776 100644
--- a/reportdesign/source/core/misc/conditionupdater.cxx
+++ b/reportdesign/source/core/misc/conditionupdater.cxx
@@ -92,16 +92,13 @@ namespace rptui
xFormatCondition.set( _rxRptControlModel->getByIndex( i ), UNO_QUERY_THROW );
sFormulaExpression = ReportFormula(xFormatCondition->getFormula()).getExpression();
- for ( ConditionalExpressions::const_iterator loop = m_aConditionalExpressions.begin();
- loop != m_aConditionalExpressions.end();
- ++loop
- )
+ for (const auto& rEntry : m_aConditionalExpressions)
{
- if ( !loop->second->matchExpression( sFormulaExpression, sOldUnprefixed, sLHS, sRHS ) )
+ if ( !rEntry.second->matchExpression( sFormulaExpression, sOldUnprefixed, sLHS, sRHS ) )
continue;
// the expression matches -> translate it to the new data source of the report control model
- sFormulaExpression = loop->second->assembleExpression( sNewUnprefixed, sLHS, sRHS );
+ sFormulaExpression = rEntry.second->assembleExpression( sNewUnprefixed, sLHS, sRHS );
ReportFormula aFormula(ReportFormula(ReportFormula::Expression, sFormulaExpression));
xFormatCondition->setFormula(aFormula.getCompleteFormula());
break;
diff --git a/reportdesign/source/core/sdr/PropertyForward.cxx b/reportdesign/source/core/sdr/PropertyForward.cxx
index cca1f9825216..e0837cfe3794 100644
--- a/reportdesign/source/core/sdr/PropertyForward.cxx
+++ b/reportdesign/source/core/sdr/PropertyForward.cxx
@@ -53,26 +53,22 @@ OPropertyMediator::OPropertyMediator(const Reference< XPropertySet>& _xSource
if ( _bReverse )
{
::comphelper::copyProperties(m_xDest,m_xSource);
- TPropertyNamePair::const_iterator aIter = m_aNameMap.begin();
- TPropertyNamePair::const_iterator aEnd = m_aNameMap.end();
- for (; aIter != aEnd; ++aIter)
+ for (const auto& [rName, rPropConv] : m_aNameMap)
{
- Property aProp = m_xSourceInfo->getPropertyByName(aIter->first);
+ Property aProp = m_xSourceInfo->getPropertyByName(rName);
if (0 == (aProp.Attributes & PropertyAttribute::READONLY))
{
- Any aValue = _xDest->getPropertyValue(aIter->second.first);
+ Any aValue = _xDest->getPropertyValue(rPropConv.first);
if ( 0 != (aProp.Attributes & PropertyAttribute::MAYBEVOID) || aValue.hasValue() )
- _xSource->setPropertyValue(aIter->first,aIter->second.second->operator()(aIter->second.first,aValue));
+ _xSource->setPropertyValue(rName, rPropConv.second->operator()(rPropConv.first, aValue));
}
}
}
else
{
::comphelper::copyProperties(m_xSource,m_xDest);
- TPropertyNamePair::const_iterator aIter = m_aNameMap.begin();
- TPropertyNamePair::const_iterator aEnd = m_aNameMap.end();
- for (; aIter != aEnd; ++aIter)
- _xDest->setPropertyValue(aIter->second.first,aIter->second.second->operator()(aIter->second.first,_xSource->getPropertyValue(aIter->first)));
+ for (const auto& [rName, rPropConv] : m_aNameMap)
+ _xDest->setPropertyValue(rPropConv.first, rPropConv.second->operator()(rPropConv.first, _xSource->getPropertyValue(rName)));
}
startListening();
}
diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx
index e19c1f725a31..d344397bd6db 100644
--- a/reportdesign/source/core/sdr/RptPage.cxx
+++ b/reportdesign/source/core/sdr/RptPage.cxx
@@ -146,12 +146,10 @@ void OReportPage::removeTempObject(SdrObject const *_pToRemoveObj)
void OReportPage::resetSpecialMode()
{
const bool bChanged = rModel.IsChanged();
- ::std::vector<SdrObject*>::const_iterator aIter = m_aTemporaryObjectList.begin();
- ::std::vector<SdrObject*>::const_iterator aEnd = m_aTemporaryObjectList.end();
- for (; aIter != aEnd; ++aIter)
+ for (const auto& pTemporaryObject : m_aTemporaryObjectList)
{
- removeTempObject(*aIter);
+ removeTempObject(pTemporaryObject);
}
m_aTemporaryObjectList.clear();
rModel.SetChanged(bChanged);
diff --git a/reportdesign/source/core/sdr/formatnormalizer.cxx b/reportdesign/source/core/sdr/formatnormalizer.cxx
index 59e4f3619088..8494732191de 100644
--- a/reportdesign/source/core/sdr/formatnormalizer.cxx
+++ b/reportdesign/source/core/sdr/formatnormalizer.cxx
@@ -231,12 +231,8 @@ namespace rptui
}
sDataField = sDataField.copy( sFieldPrefix.getLength(), sDataField.getLength() - sFieldPrefix.getLength() - 1 );
- FieldList::const_iterator field = m_aFields.begin();
- for ( ; field != m_aFields.end(); ++field )
- {
- if ( field->sName == sDataField )
- break;
- }
+ FieldList::const_iterator field = std::find_if(m_aFields.begin(), m_aFields.end(),
+ [&sDataField](const Field& rField) { return rField.sName == sDataField; });
if ( field == m_aFields.end() )
// unknown field
return;
diff --git a/reportdesign/source/filter/xml/xmlAutoStyle.cxx b/reportdesign/source/filter/xml/xmlAutoStyle.cxx
index 4e0873d976fb..f3855b704df8 100644
--- a/reportdesign/source/filter/xml/xmlAutoStyle.cxx
+++ b/reportdesign/source/filter/xml/xmlAutoStyle.cxx
@@ -39,23 +39,21 @@ void OXMLAutoStylePoolP::exportStyleAttributes(
if ( nFamily == XML_STYLE_FAMILY_TABLE_CELL )
{
rtl::Reference< XMLPropertySetMapper > aPropMapper = rORptExport.GetCellStylePropertyMapper();
- ::std::vector< XMLPropertyState >::const_iterator i = rProperties.begin();
- ::std::vector< XMLPropertyState >::const_iterator aEnd = rProperties.end();
- for (; i != aEnd ; ++i)
+ for (const auto& rProp : rProperties)
{
- sal_Int16 nContextID = aPropMapper->GetEntryContextId(i->mnIndex);
+ sal_Int16 nContextID = aPropMapper->GetEntryContextId(rProp.mnIndex);
switch (nContextID)
{
case CTF_RPT_NUMBERFORMAT :
{
OUString sAttrValue;
- if ( i->maValue >>= sAttrValue )
+ if ( rProp.maValue >>= sAttrValue )
{
if ( !sAttrValue.isEmpty() )
{
rORptExport.AddAttribute(
- aPropMapper->GetEntryNameSpace(i->mnIndex),
- aPropMapper->GetEntryXMLName(i->mnIndex),
+ aPropMapper->GetEntryNameSpace(rProp.mnIndex),
+ aPropMapper->GetEntryXMLName(rProp.mnIndex),
sAttrValue );
}
}
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index 0a7acc361788..a907b3c237c1 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -177,29 +177,26 @@ namespace rptxml
static void lcl_adjustColumnSpanOverRows(ORptExport::TSectionsGrid& _rGrid)
{
- ORptExport::TSectionsGrid::iterator aSectionIter = _rGrid.begin();
- ORptExport::TSectionsGrid::const_iterator aSectionEnd = _rGrid.end();
- for (;aSectionIter != aSectionEnd ; ++aSectionIter)
+ for (auto& rEntry : _rGrid)
{
- ORptExport::TGrid::iterator aRowIter = aSectionIter->second.begin();
- ORptExport::TGrid::const_iterator aRowEnd = aSectionIter->second.end();
+ ORptExport::TGrid::iterator aRowIter = rEntry.second.begin();
+ ORptExport::TGrid::const_iterator aRowEnd = rEntry.second.end();
for (; aRowIter != aRowEnd; ++aRowIter)
{
if ( aRowIter->first )
{
- ::std::vector< ORptExport::TCell >::const_iterator aColIter = aRowIter->second.begin();
- ::std::vector< ORptExport::TCell >::const_iterator aColEnd = aRowIter->second.end();
- for (; aColIter != aColEnd; ++aColIter)
+ sal_Int32 nColIndex = 0;
+ for (const auto& rCell : aRowIter->second)
{
- if ( aColIter->nRowSpan > 1 )
+ if ( rCell.nRowSpan > 1 )
{
- sal_Int32 nColSpan = aColIter->nColSpan;
- sal_Int32 nColIndex = aColIter - aRowIter->second.begin();
- for (sal_Int32 i = 1; i < aColIter->nRowSpan; ++i)
+ sal_Int32 nColSpan = rCell.nColSpan;
+ for (sal_Int32 i = 1; i < rCell.nRowSpan; ++i)
{
(aRowIter+i)->second[nColIndex].nColSpan = nColSpan;
}
}
+ ++nColIndex;
}
}
}
diff --git a/reportdesign/source/filter/xml/xmlReport.cxx b/reportdesign/source/filter/xml/xmlReport.cxx
index d33424691292..52079a32baae 100644
--- a/reportdesign/source/filter/xml/xmlReport.cxx
+++ b/reportdesign/source/filter/xml/xmlReport.cxx
@@ -202,10 +202,8 @@ void OXMLReport::EndElement()
{
Reference< XFunctions > xFunctions = m_xReportDefinition->getFunctions();
const ORptFilter::TGroupFunctionMap& aFunctions = m_rImport.getFunctions();
- ORptFilter::TGroupFunctionMap::const_iterator aIter = aFunctions.begin();
- const ORptFilter::TGroupFunctionMap::const_iterator aEnd = aFunctions.end();
- for (; aIter != aEnd; ++aIter)
- xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(aIter->second));
+ for (const auto& rEntry : aFunctions)
+ xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(rEntry.second));
if ( !m_aMasterFields.empty() )
m_xReportDefinition->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
diff --git a/reportdesign/source/filter/xml/xmlTable.cxx b/reportdesign/source/filter/xml/xmlTable.cxx
index a9bd5d1b1d9a..60030675a095 100644
--- a/reportdesign/source/filter/xml/xmlTable.cxx
+++ b/reportdesign/source/filter/xml/xmlTable.cxx
@@ -35,6 +35,8 @@
#include <com/sun/star/report/XShape.hpp>
#include <com/sun/star/report/XFixedLine.hpp>
+#include <numeric>
+
#define MIN_WIDTH 80
#define MIN_HEIGHT 20
@@ -178,11 +180,8 @@ void OXMLTable::EndElement()
}
}
// set height
- ::std::vector<sal_Int32>::const_iterator aIter = m_aHeight.begin();
- ::std::vector<sal_Int32>::const_iterator aEnd = m_aHeight.end();
- sal_Int32 nHeight = 0;
- for (; aIter != aEnd; ++aIter)
- nHeight += *aIter;
+ sal_Int32 nHeight = std::accumulate(m_aHeight.begin(), m_aHeight.end(), sal_Int32(0),
+ [](const sal_Int32& rSum, const sal_Int32& rHeight) { return rSum + rHeight; });
m_xSection->setHeight( nHeight );
// set positions, widths, and heights
sal_Int32 nLeftMargin = rptui::getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN);
@@ -197,64 +196,59 @@ void OXMLTable::EndElement()
for (sal_Int32 j = 0; aColIter != aColEnd; ++aColIter,++j)
{
TCell& rCell = *aColIter;
- if ( !rCell.xElements.empty())
+ for (const auto& rxElement : rCell.xElements)
{
- ::std::vector< uno::Reference< report::XReportComponent> >::const_iterator aCellIter = rCell.xElements.begin();
- const ::std::vector< uno::Reference< report::XReportComponent> >::const_iterator aCellEnd = rCell.xElements.end();
- for (;aCellIter != aCellEnd ; ++aCellIter)
+ uno::Reference<report::XShape> xShape(rxElement,uno::UNO_QUERY);
+ if ( xShape.is() )
{
- uno::Reference<report::XShape> xShape(*aCellIter,uno::UNO_QUERY);
- if ( xShape.is() )
- {
- xShape->setPositionX(xShape->getPositionX() + nLeftMargin);
- }
- else
+ xShape->setPositionX(xShape->getPositionX() + nLeftMargin);
+ }
+ else
+ {
+ sal_Int32 nWidth = rCell.nWidth;
+ sal_Int32 nColSpan = rCell.nColSpan;
+ if ( nColSpan > 1 )
{
- sal_Int32 nWidth = rCell.nWidth;
- sal_Int32 nColSpan = rCell.nColSpan;
- if ( nColSpan > 1 )
- {
- ::std::vector<TCell>::const_iterator aWidthIter = aColIter + 1;
- while ( nColSpan > 1 )
- {
- nWidth += (aWidthIter++)->nWidth;
- --nColSpan;
- }
- }
- nHeight = rCell.nHeight;
- sal_Int32 nRowSpan = rCell.nRowSpan;
- if ( nRowSpan > 1 )
- {
- ::std::vector< ::std::vector<TCell> >::const_iterator aHeightIter = aRowIter + 1;
- while( nRowSpan > 1)
- {
- nHeight += (*aHeightIter)[j].nHeight;
- ++aHeightIter;
- --nRowSpan;
- }
- }
- Reference<XFixedLine> xFixedLine(*aCellIter,uno::UNO_QUERY);
- if ( xFixedLine.is() )
+ ::std::vector<TCell>::const_iterator aWidthIter = aColIter + 1;
+ while ( nColSpan > 1 )
{
- if ( xFixedLine->getOrientation() == 1 ) // vertical
- {
- OSL_ENSURE(static_cast<sal_uInt32>(j+1) < m_aWidth.size(),"Illegal pos of col iter. There should be an empty cell for the next line part.");
- nWidth += m_aWidth[j+1];
- if ( nWidth < MIN_WIDTH )
- nWidth = MIN_WIDTH;
- }
- else if ( nHeight < MIN_HEIGHT )
- nHeight = MIN_HEIGHT;
+ nWidth += (aWidthIter++)->nWidth;
+ --nColSpan;
}
- try
+ }
+ nHeight = rCell.nHeight;
+ sal_Int32 nRowSpan = rCell.nRowSpan;
+ if ( nRowSpan > 1 )
+ {
+ ::std::vector< ::std::vector<TCell> >::const_iterator aHeightIter = aRowIter + 1;
+ while( nRowSpan > 1)
{
- (*aCellIter)->setSize(awt::Size(nWidth,nHeight));
- (*aCellIter)->setPosition(awt::Point(nPosX,nPosY));
+ nHeight += (*aHeightIter)[j].nHeight;
+ ++aHeightIter;
+ --nRowSpan;
}
- catch(const beans::PropertyVetoException &)
+ }
+ Reference<XFixedLine> xFixedLine(rxElement,uno::UNO_QUERY);
+ if ( xFixedLine.is() )
+ {
+ if ( xFixedLine->getOrientation() == 1 ) // vertical
{
- OSL_FAIL("Could not set the correct position or size!");
+ OSL_ENSURE(static_cast<sal_uInt32>(j+1) < m_aWidth.size(),"Illegal pos of col iter. There should be an empty cell for the next line part.");
+ nWidth += m_aWidth[j+1];
+ if ( nWidth < MIN_WIDTH )
+ nWidth = MIN_WIDTH;
}
+ else if ( nHeight < MIN_HEIGHT )
+ nHeight = MIN_HEIGHT;
+ }
+ try
+ {
+ rxElement->setSize(awt::Size(nWidth,nHeight));
+ rxElement->setPosition(awt::Point(nPosX,nPosY));
+ }
+ catch(const beans::PropertyVetoException &)
+ {
+ OSL_FAIL("Could not set the correct position or size!");
}
}
}
diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx
index 9a67ebdd747b..0fa1180884ba 100644
--- a/reportdesign/source/ui/dlg/CondFormat.cxx
+++ b/reportdesign/source/ui/dlg/CondFormat.cxx
@@ -133,9 +133,9 @@ namespace rptui
void ConditionalFormattingDialog::dispose()
{
- for (auto i = m_aConditions.begin(); i != m_aConditions.end(); ++i)
+ for (auto& rxCondition : m_aConditions)
{
- i->disposeAndClear();
+ rxCondition.disposeAndClear();
}
m_aConditions.clear();
@@ -148,12 +148,10 @@ namespace rptui
void ConditionalFormattingDialog::impl_updateConditionIndicies()
{
sal_Int32 nIndex = 0;
- for ( Conditions::const_iterator cond = m_aConditions.begin();
- cond != m_aConditions.end();
- ++cond, ++nIndex
- )
+ for (const auto& rxCondition : m_aConditions)
{
- (*cond)->setConditionIndex( nIndex, impl_getConditionCount() );
+ rxCondition->setConditionIndex( nIndex, impl_getConditionCount() );
+ ++nIndex;
}
}
@@ -549,15 +547,10 @@ namespace rptui
size_t ConditionalFormattingDialog::impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const
{
- size_t nIndex( 0 );
- for ( Conditions::const_iterator cond = m_aConditions.begin();
- cond != m_aConditions.end();
- ++cond, ++nIndex
- )
- {
- if ( (*cond)->HasChildPathFocus() )
- return nIndex;
- }
+ auto cond = std::find_if(m_aConditions.begin(), m_aConditions.end(),
+ [](const VclPtr<Condition>& rxCondition) { return rxCondition->HasChildPathFocus(); });
+ if (cond != m_aConditions.end())
+ return static_cast<size_t>(std::distance(m_aConditions.begin(), cond));
return _nFallBackIfNone;
}
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 48f2a5c3c26c..796f891d21f9 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -338,15 +338,12 @@ void Condition::impl_setCondition( const OUString& _rConditionFormula )
const OUString sUnprefixedFieldContent( aFieldContentFormula.getBracketedFieldOrExpression() );
// check whether one of the Field Value Expression Factories recognizes the expression
- for ( ConditionalExpressions::const_iterator exp = m_aConditionalExpressions.begin();
- exp != m_aConditionalExpressions.end();
- ++exp
- )
+ for (const auto& [rOperation, rxConditionalExpression] : m_aConditionalExpressions)
{
- if ( exp->second->matchExpression( sExpression, sUnprefixedFieldContent, sLHS, sRHS ) )
+ if ( rxConditionalExpression->matchExpression( sExpression, sUnprefixedFieldContent, sLHS, sRHS ) )
{
eType = eFieldValueComparison;
- eOperation = exp->first;
+ eOperation = rOperation;
break;
}
}
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index e933b6218752..a12479660ad5 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -503,15 +503,10 @@ OUString OFieldExpressionControl::GetCellText( long nRow, sal_uInt16 /*nColId*/
uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
OUString sExpression = xGroup->getExpression();
- for(::std::vector<ColumnInfo>::const_iterator aIter = m_aColumnInfo.begin(); aIter != m_aColumnInfo.end();++aIter)
- {
- if ( aIter->sColumnName == sExpression )
- {
- if ( !aIter->sLabel.isEmpty() )
- sExpression = aIter->sLabel;
- break;
- }
- }
+ auto aIter = std::find_if(m_aColumnInfo.begin(), m_aColumnInfo.end(),
+ [&sExpression](const ColumnInfo& rColumnInfo) { return rColumnInfo.sColumnName == sExpression; });
+ if (aIter != m_aColumnInfo.end() && !aIter->sLabel.isEmpty())
+ sExpression = aIter->sLabel;
sText = sExpression;
}
catch (const uno::Exception&)
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index a5178650f7a8..746c9de1a3f8 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1885,27 +1885,26 @@ bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference< repo
i18nutil::SearchOptions2 aSearchOptions;
aSearchOptions.AlgorithmType2 = util::SearchAlgorithms2::REGEXP;
aSearchOptions.searchFlag = 0x00000100;
- ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
- ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
- for (; aIter != aDeEnd; ++aIter)
+ auto aIter = std::find_if(m_aDefaultFunctions.begin(), m_aDefaultFunctions.end(),
+ [&aSearchOptions, &sFormula](const DefaultFunction& rDefaultFunction) {
+ aSearchOptions.searchString = rDefaultFunction.m_sSearchString;
+ utl::TextSearch aTextSearch( aSearchOptions);
+ sal_Int32 start = 0;
+ sal_Int32 end = sFormula.getLength();
+ return aTextSearch.SearchForward(sFormula, &start, &end) && start == 0 && end == sFormula.getLength();
+ });
+ if (aIter != m_aDefaultFunctions.end()) // default function found
{
- aSearchOptions.searchString = aIter->m_sSearchString;
- utl::TextSearch aTextSearch( aSearchOptions);
sal_Int32 start = 0;
sal_Int32 end = sFormula.getLength();
- if (aTextSearch.SearchForward(sFormula, &start, &end) && start == 0 && end == sFormula.getLength()) // default function found
- {
- aSearchOptions.searchString = "\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
- utl::TextSearch aDataSearch( aSearchOptions);
- (void)aDataSearch.SearchForward(sFormula, &start, &end);
- ++start;
- _rDataField = sFormula.copy(start,end-start-1);
- _rsDefaultFunctionName = aIter->m_sName;
- break;
- }
+ aSearchOptions.searchString = "\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
+ utl::TextSearch aDataSearch( aSearchOptions);
+ (void)aDataSearch.SearchForward(sFormula, &start, &end);
+ ++start;
+ _rDataField = sFormula.copy(start,end-start-1);
+ _rsDefaultFunctionName = aIter->m_sName;
+ bDefaultFunction = true;
}
-
- bDefaultFunction = aIter != aDeEnd;
}
catch(uno::Exception&)
{
@@ -1959,41 +1958,37 @@ void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard& _aGuard
OUString sNamePostfix;
const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostfix);
- ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
- ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
- for (; aIter != aDeEnd; ++aIter)
+ auto aIter = std::find_if(m_aDefaultFunctions.begin(), m_aDefaultFunctions.end(),
+ [&_sFunction](const DefaultFunction& rDefaultFunction) { return rDefaultFunction.m_sName == _sFunction; });
+ if (aIter != m_aDefaultFunctions.end())
{
- if ( aIter->m_sName == _sFunction )
- {
- const OUString sFunctionName( _sFunction + _sDataField + sNamePostfix);
- const OUString sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName));
+ const OUString sFunctionName( _sFunction + _sDataField + sNamePostfix);
+ const OUString sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName));
- beans::PropertyChangeEvent aEvent;
- aEvent.PropertyName = PROPERTY_SCOPE;
- aEvent.OldValue <<= m_sScope;
+ beans::PropertyChangeEvent aEvent;
+ aEvent.PropertyName = PROPERTY_SCOPE;
+ aEvent.OldValue <<= m_sScope;
- ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
- while ( aFind.first != aFind.second )
+ ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
+ while ( aFind.first != aFind.second )
+ {
+ if ( xFunctionsSupplier == aFind.first->second.second )
{
- if ( xFunctionsSupplier == aFind.first->second.second )
- {
- m_xFunction = aFind.first->second.first;
- OUString sTemp;
- isDefaultFunction(sQuotedFunctionName,sTemp,uno::Reference< report::XFunctionsSupplier>(),true); // implicitly sets the m_sScope
- break;
- }
- ++(aFind.first);
+ m_xFunction = aFind.first->second.first;
+ OUString sTemp;
+ isDefaultFunction(sQuotedFunctionName,sTemp,uno::Reference< report::XFunctionsSupplier>(),true); // implicitly sets the m_sScope
+ break;
}
- if ( aFind.first == aFind.second )
- impl_createFunction(sFunctionName,_sDataField,*aIter);
-
- OBlocker aBlocker(m_bIn);
- m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName) )));
- aEvent.NewValue <<= m_sScope;
- _aGuard.clear();
- m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
- break;
+ ++(aFind.first);
}
+ if ( aFind.first == aFind.second )
+ impl_createFunction(sFunctionName,_sDataField,*aIter);
+
+ OBlocker aBlocker(m_bIn);
+ m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName) )));
+ aEvent.NewValue <<= m_sScope;
+ _aGuard.clear();
+ m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
}
}
catch(uno::Exception&)
diff --git a/reportdesign/source/ui/misc/RptUndo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx
index dc8b823d0f24..3bfd9d22ca80 100644
--- a/reportdesign/source/ui/misc/RptUndo.cxx
+++ b/reportdesign/source/ui/misc/RptUndo.cxx
@@ -94,13 +94,11 @@ namespace
{
if ( _xSection.is() )
{
- ::std::vector< ::std::pair< OUString ,uno::Any> >::const_iterator aIter = _aValues.begin();
- ::std::vector< ::std::pair< OUString ,uno::Any> >::const_iterator aEnd = _aValues.end();
- for (; aIter != aEnd; ++aIter)
+ for (const auto& [rPropName, rValue] : _aValues)
{
try
{
- _xSection->setPropertyValue(aIter->first,aIter->second);
+ _xSection->setPropertyValue(rPropName, rValue);
}
catch(const uno::Exception&)
{
@@ -128,10 +126,8 @@ OSectionUndo::~OSectionUndo()
if ( !m_bInserted )
{
OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv();
- ::std::vector< uno::Reference< drawing::XShape> >::const_iterator aEnd = m_aControls.end();
- for (::std::vector< uno::Reference< drawing::XShape> >::const_iterator aIter = m_aControls.begin(); aIter != aEnd; ++aIter)
+ for (uno::Reference<drawing::XShape>& xShape : m_aControls)
{
- uno::Reference< drawing::XShape> xShape = *aIter;
rEnv.RemoveElement(xShape);
#if OSL_DEBUG_LEVEL > 0
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index 63e1a2469604..51e847c74135 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -265,21 +265,19 @@ namespace
SvxUnoPropertyMapProvider aMap;
const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
PropertyEntryVector_t aPropVector = rPropertyMap.getPropertyEntries();
- PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
- while( aIt != aPropVector.end() )
+ for (const auto& rProp : aPropVector)
{
- if ( xInfo->hasPropertyByName(aIt->sName) )
+ if ( xInfo->hasPropertyByName(rProp.sName) )
{
- const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
+ const SfxPoolItem* pItem = _rItemSet.GetItem(rProp.nWID);
if ( pItem )
{
::std::unique_ptr<SfxPoolItem> pClone(pItem->Clone());
- pClone->PutValue(_xShape->getPropertyValue(aIt->sName), aIt->nMemberId);
- pClone->SetWhich(aIt->nWID);
+ pClone->PutValue(_xShape->getPropertyValue(rProp.sName), rProp.nMemberId);
+ pClone->SetWhich(rProp.nWID);
_rItemSet.Put(*pClone);
}
}
- ++aIt;
}
}
@@ -289,21 +287,20 @@ namespace
SvxUnoPropertyMapProvider aMap;
const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
PropertyEntryVector_t aPropVector = rPropertyMap.getPropertyEntries();
- PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
- while( aIt != aPropVector.end() )
+ for (const auto& rProp : aPropVector)
{
- if ( SfxItemState::SET == _rItemSet.GetItemState(aIt->nWID) && xInfo->hasPropertyByName(aIt->sName) )
+ if ( SfxItemState::SET == _rItemSet.GetItemState(rProp.nWID) && xInfo->hasPropertyByName(rProp.sName) )
{
- if ( ( aIt->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
+ if ( ( rProp.nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
{
- const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
+ const SfxPoolItem* pItem = _rItemSet.GetItem(rProp.nWID);
if ( pItem )
{
uno::Any aValue;
- pItem->QueryValue(aValue,aIt->nMemberId);
+ pItem->QueryValue(aValue,rProp.nMemberId);
try
{
- _xShape->setPropertyValue(aIt->sName, aValue);
+ _xShape->setPropertyValue(rProp.sName, aValue);
}
catch(uno::Exception&)
{ // shapes have a bug so we ignore this one.
@@ -311,7 +308,6 @@ namespace
}
}
}
- ++aIt;
}
}
diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx
index b46a44d10cf9..de49c0361817 100644
--- a/reportdesign/source/ui/report/DesignView.cxx
+++ b/reportdesign/source/ui/report/DesignView.cxx
@@ -627,11 +627,12 @@ uno::Any ODesignView::getCurrentlyShownProperty() const
pSectionWindow->getReportSection().fillControlModelSelection(aSelection);
if ( !aSelection.empty() )
{
- ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin();
uno::Sequence< uno::Reference< report::XReportComponent > > aSeq(aSelection.size());
- for(sal_Int32 i = 0; i < aSeq.getLength(); ++i,++aIter)
+ sal_Int32 i = 0;
+ for(const auto& rxInterface : aSelection)
{
- aSeq[i].set(*aIter,uno::UNO_QUERY);
+ aSeq[i].set(rxInterface,uno::UNO_QUERY);
+ ++i;
}
aRet <<= aSeq;
}
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 5cbef2d2be07..283daad8d253 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -888,13 +888,11 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const
{
::std::vector< uno::Reference< uno::XInterface > > aSelection;
getDesignView()->fillControlModelSelection(aSelection);
- ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin();
- for(; aIter != aSelection.end()
- && !uno::Reference< report::XFixedLine >(*aIter,uno::UNO_QUERY).is()
- && !uno::Reference< report::XImageControl >(*aIter,uno::UNO_QUERY).is()
- && uno::Reference< report::XReportControlFormat >(*aIter,uno::UNO_QUERY).is() ;++aIter)
- ;
- aReturn.bEnabled = !aSelection.empty() && aIter == aSelection.end();
+ aReturn.bEnabled = !aSelection.empty()
+ && std::all_of(aSelection.begin(), aSelection.end(), [](const uno::Reference<uno::XInterface>& rxInterface) {
+ return !uno::Reference<report::XFixedLine>(rxInterface, uno::UNO_QUERY).is()
+ && !uno::Reference<report::XImageControl>(rxInterface, uno::UNO_QUERY).is()
+ && uno::Reference<report::XReportControlFormat>(rxInterface, uno::UNO_QUERY).is(); });
}
break;
case SID_CONDITIONALFORMATTING:
@@ -1437,10 +1435,9 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >
const OUString sUndoAction(RptResId(RID_STR_UNDO_CHANGEFONT));
UndoContext aUndoContext( getUndoManager(), sUndoAction );
- ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aControlsFormats.begin();
- for(; aIter != aControlsFormats.end();++aIter)
+ for (const auto& rxControlFormat : aControlsFormats)
{
- uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY);
+ uno::Reference< report::XReportControlFormat> xReportControlFormat(rxControlFormat,uno::UNO_QUERY);
lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
}
}
@@ -1514,10 +1511,9 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >
const OUString sUndoAction( RptResId( RID_STR_UNDO_CHANGEFONT ) );
UndoContext aUndoContext( getUndoManager(), sUndoAction );
- ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aControlsFormats.begin();
- for(; aIter != aControlsFormats.end();++aIter)
+ for (const auto& rxControlFormat : aControlsFormats)
{
- uno::Reference< report::XReportControlFormat > xFormat( *aIter, uno::UNO_QUERY );
+ uno::Reference< report::XReportControlFormat > xFormat( rxControlFormat, uno::UNO_QUERY );
if ( !xFormat.is() )
continue;
@@ -2722,12 +2718,13 @@ uno::Any SAL_CALL OReportController::getViewData()
{
uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
- ::std::vector<sal_uInt16>::const_iterator aIter = aCollapsedPositions.begin();
- ::std::vector<sal_uInt16>::const_iterator aEnd = aCollapsedPositions.end();
- for (sal_Int32 i = 1; aIter != aEnd ; ++aIter,++pCollapsedIter,++i)
+ sal_Int32 i = 1;
+ for (const auto& rPos : aCollapsedPositions)
{
pCollapsedIter->Name = PROPERTY_SECTION + OUString::number(i);
- pCollapsedIter->Value <<= static_cast<sal_Int32>(*aIter);
+ pCollapsedIter->Value <<= static_cast<sal_Int32>(rPos);
+ ++pCollapsedIter;
+ ++i;
}
aViewData.put( "CollapsedSections", aCollapsedSections );
@@ -2763,19 +2760,16 @@ void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data)
::comphelper::NamedValueCollection aCommandProperties( aViewData.get( "CommandProperties" ) );
const ::std::vector< OUString > aCommandNames( aCommandProperties.getNames() );
- for ( ::std::vector< OUString >::const_iterator commandName = aCommandNames.begin();
- commandName != aCommandNames.end();
- ++commandName
- )
+ for ( const auto& rCommandName : aCommandNames )
{
- const Any& rCommandValue = aCommandProperties.get( *commandName );
+ const Any& rCommandValue = aCommandProperties.get( rCommandName );
if ( !rCommandValue.hasValue() )
continue;
if ( getView() )
{
util::URL aCommand;
- aCommand.Complete = ".uno:" + *commandName;
+ aCommand.Complete = ".uno:" + rCommandName;
Sequence< PropertyValue > aCommandArgs(1);
aCommandArgs[0].Name = "Value";
@@ -2785,19 +2779,19 @@ void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data)
}
else
{
- if ( *commandName == "ShowRuler" )
+ if ( rCommandName == "ShowRuler" )
OSL_VERIFY( rCommandValue >>= m_bShowRuler );
- else if ( *commandName == "HelplinesMove" )
+ else if ( rCommandName == "HelplinesMove" )
OSL_VERIFY( rCommandValue >>= m_bHelplinesMove );
- else if ( *commandName == "GridVisible" )
+ else if ( rCommandName == "GridVisible" )
OSL_VERIFY( rCommandValue >>= m_bGridVisible );
- else if ( *commandName == "GridUse" )
+ else if ( rCommandName == "GridUse" )
OSL_VERIFY( rCommandValue >>= m_bGridUse );
- else if ( *commandName == "ControlProperties" )
+ else if ( rCommandName == "ControlProperties" )
OSL_VERIFY( rCommandValue >>= m_bShowProperties );
- else if ( *commandName == "LastPropertyBrowserPage" )
+ else if ( rCommandName == "LastPropertyBrowserPage" )
OSL_VERIFY( rCommandValue >>= m_sLastActivePage );
- else if ( *commandName == "SplitPosition" )
+ else if ( rCommandName == "SplitPosition" )
OSL_VERIFY( rCommandValue >>= m_nSplitPos );
}
}
@@ -4154,14 +4148,13 @@ bool OReportController::impl_setPropertyAtControls_throw(const char* pUndoResId,
::std::vector< uno::Reference< uno::XInterface > > aSelection;
uno::Reference< awt::XWindow> xWindow;
lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection );
- ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin();
const OUString sUndoAction = RptResId( pUndoResId );
UndoContext aUndoContext( getUndoManager(), sUndoAction );
- for(; aIter != aSelection.end();++aIter)
+ for (const auto& rxInterface : aSelection)
{
- const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY);
+ const uno::Reference< beans::XPropertySet > xControlModel(rxInterface,uno::UNO_QUERY);
if ( xControlModel.is() )
// tdf#117795: some elements may have not some property
// eg class "OFixedLine" doesn't have property "CharFontName"
diff --git a/reportdesign/source/ui/report/ReportControllerObserver.cxx b/reportdesign/source/ui/report/ReportControllerObserver.cxx
index d56d55b0a427..abcf21bb9771 100644
--- a/reportdesign/source/ui/report/ReportControllerObserver.cxx
+++ b/reportdesign/source/ui/report/ReportControllerObserver.cxx
@@ -94,11 +94,8 @@ public:
// send all Section Objects a 'tingle'
// maybe they need a change in format, color, etc
- ::std::vector< uno::Reference< container::XChild > >::const_iterator aIter = m_pImpl->m_aSections.begin();
- ::std::vector< uno::Reference< container::XChild > >::const_iterator aEnd = m_pImpl->m_aSections.end();
- for (;aIter != aEnd; ++aIter)
+ for (const uno::Reference<container::XChild>& xChild : m_pImpl->m_aSections)
{
- const uno::Reference<container::XChild> xChild (*aIter);
if (xChild.is())
{
uno::Reference<report::XSection> xSection(xChild, uno::UNO_QUERY);
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 2362d97e5232..9e49938e5484 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -588,47 +588,44 @@ void OReportSection::createDefault(const OUString& _sType,SdrObject* _pObj)
std::vector< OUString > aObjList;
if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
{
- std::vector< OUString >::const_iterator aIter = aObjList.begin();
- std::vector< OUString >::const_iterator aEnd = aObjList.end();
- for (sal_uInt32 i=0 ; aIter != aEnd; ++aIter,++i)
+ auto aIter = std::find_if(aObjList.begin(), aObjList.end(),
+ [&_sType](const OUString& rObj) { return rObj.equalsIgnoreAsciiCase(_sType); });
+ if (aIter != aObjList.end())
{
- if ( aIter->equalsIgnoreAsciiCase( _sType ) )
+ auto i = static_cast<sal_uInt32>(std::distance(aObjList.begin(), aIter));
+ OReportModel aReportModel(nullptr);
+ SfxItemPool& rPool = aReportModel.GetItemPool();
+ rPool.FreezeIdRanges();
+ if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aReportModel ) )
{
- OReportModel aReportModel(nullptr);
- SfxItemPool& rPool = aReportModel.GetItemPool();
- rPool.FreezeIdRanges();
- if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aReportModel ) )
+ const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 );
+ if( pSourceObj )
{
- const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 );
- if( pSourceObj )
- {
- const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
- SfxItemSet aDest(
- _pObj->getSdrModelFromSdrObject().GetItemPool(),
- svl::Items<
- // Ranges from SdrAttrObj:
- SDRATTR_START, SDRATTR_SHADOW_LAST,
- SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
+ SfxItemSet aDest(
+ _pObj->getSdrModelFromSdrObject().GetItemPool(),
+ svl::Items<
+ // Ranges from SdrAttrObj:
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION,
SDRATTR_TEXTDIRECTION,
- SDRATTR_TEXTDIRECTION,
- // Graphic attributes, 3D properties,
- // CustomShape properties:
- SDRATTR_GRAF_FIRST,
- SDRATTR_CUSTOMSHAPE_LAST,
- // Range from SdrTextObj:
- EE_ITEMS_START, EE_ITEMS_END>{});
- aDest.Set( rSource );
- _pObj->SetMergedItemSet( aDest );
- sal_Int32 nAngle = pSourceObj->GetRotateAngle();
- if ( nAngle )
- {
- double a = nAngle * F_PI18000;
- _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
- }
- bAttributesAppliedFromGallery = true;
+ // Graphic attributes, 3D properties,
+ // CustomShape properties:
+ SDRATTR_GRAF_FIRST,
+ SDRATTR_CUSTOMSHAPE_LAST,
+ // Range from SdrTextObj:
+ EE_ITEMS_START, EE_ITEMS_END>{});
+ aDest.Set( rSource );
+ _pObj->SetMergedItemSet( aDest );
+ sal_Int32 nAngle = pSourceObj->GetRotateAngle();
+ if ( nAngle )
+ {
+ double a = nAngle * F_PI18000;
+ _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
}
+ bAttributesAppliedFromGallery = true;
}
- break;
}
}
}
diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx
index 77fed84faa28..19bc83444787 100644
--- a/reportdesign/source/ui/report/ViewsWindow.cxx
+++ b/reportdesign/source/ui/report/ViewsWindow.cxx
@@ -185,8 +185,8 @@ OViewsWindow::~OViewsWindow()
void OViewsWindow::dispose()
{
m_aColorConfig.RemoveListener(this);
- for (auto i = m_aSections.begin(); i != m_aSections.end(); ++i)
- i->disposeAndClear();
+ for (auto& rxSection : m_aSections)
+ rxSection.disposeAndClear();
m_aSections.clear();
m_pParent.clear();
vcl::Window::dispose();
@@ -323,14 +323,8 @@ void OViewsWindow::toggleGrid(bool _bVisible)
sal_Int32 OViewsWindow::getTotalHeight() const
{
- sal_Int32 nHeight = 0;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
- {
- nHeight += (*aIter)->GetSizePixel().Height();
- }
- return nHeight;
+ return std::accumulate(m_aSections.begin(), m_aSections.end(), sal_Int32(0),
+ [](const sal_Int32 nHeight, const VclPtr<OSectionWindow>& rxSection) { return nHeight + rxSection->GetSizePixel().Height(); });
}
sal_uInt16 OViewsWindow::getSectionCount() const
@@ -340,10 +334,8 @@ sal_uInt16 OViewsWindow::getSectionCount() const
void OViewsWindow::SetInsertObj( sal_uInt16 eObj,const OUString& _sShapeType )
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
- (*aIter)->getReportSection().getSectionView().SetCurrentObj( eObj, SdrInventor::ReportDesign );
+ for (const auto& rxSection : m_aSections)
+ rxSection->getReportSection().getSectionView().SetCurrentObj( eObj, SdrInventor::ReportDesign );
m_sShapeType = _sShapeType;
}
@@ -359,11 +351,8 @@ void OViewsWindow::SetMode( DlgEdMode eNewMode )
bool OViewsWindow::HasSelection() const
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd && !(*aIter)->getReportSection().getSectionView().AreObjectsMarked(); ++aIter)
- ;
- return aIter != aEnd;
+ return std::any_of(m_aSections.begin(), m_aSections.end(),
+ [](const VclPtr<OSectionWindow>& rxSection) { return rxSection->getReportSection().getSectionView().AreObjectsMarked(); });
}
void OViewsWindow::Delete()
@@ -507,14 +496,12 @@ void OViewsWindow::unmarkAllObjects(OSectionView const * _pSectionView)
if ( !m_bInUnmark )
{
m_bInUnmark = true;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- if ( &(*aIter)->getReportSection().getSectionView() != _pSectionView )
+ if ( &rxSection->getReportSection().getSectionView() != _pSectionView )
{
- (*aIter)->getReportSection().deactivateOle();
- (*aIter)->getReportSection().getSectionView().UnmarkAllObj();
+ rxSection->getReportSection().deactivateOle();
+ rxSection->getReportSection().getSectionView().UnmarkAllObj();
}
}
m_bInUnmark = false;
@@ -554,21 +541,17 @@ void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( rMEvt.IsLeft() )
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
+ auto aIter = std::find_if(m_aSections.begin(), m_aSections.end(),
+ [](const VclPtr<OSectionWindow>& rxSection) { return rxSection->getReportSection().getSectionView().AreObjectsMarked(); });
+ if (aIter != m_aSections.end())
{
- if ( (*aIter)->getReportSection().getSectionView().AreObjectsMarked() )
- {
- (*aIter)->getReportSection().MouseButtonUp(rMEvt);
- break;
- }
+ (*aIter)->getReportSection().MouseButtonUp(rMEvt);
}
// remove special insert mode
- for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- (*aIter)->getReportSection().getPage()->resetSpecialMode();
+ rxSection->getReportSection().getPage()->resetSpecialMode();
}
}
}
@@ -576,13 +559,11 @@ void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt )
bool OViewsWindow::handleKeyEvent(const KeyEvent& _rEvent)
{
bool bRet = false;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- if ( (*aIter)->getStartMarker().isMarked() )
+ if ( rxSection->getStartMarker().isMarked() )
{
- bRet = (*aIter)->getReportSection().handleKeyEvent(_rEvent);
+ bRet = rxSection->getReportSection().handleKeyEvent(_rEvent);
}
}
return bRet;
@@ -605,17 +586,15 @@ void OViewsWindow::setMarked(OSectionView const * _pSectionView, bool _bMark)
void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection, bool _bMark)
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- if ( (*aIter)->getReportSection().getSection() != _xSection )
+ if ( rxSection->getReportSection().getSection() != _xSection )
{
- (*aIter)->setMarked(false);
+ rxSection->setMarked(false);
}
- else if ( (*aIter)->getStartMarker().isMarked() != _bMark )
+ else if ( rxSection->getStartMarker().isMarked() != _bMark )
{
- (*aIter)->setMarked(_bMark);
+ rxSection->setMarked(_bMark);
}
}
}
@@ -650,11 +629,9 @@ void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XRepor
void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles)
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OSectionView& rView = (*aIter)->getReportSection().getSectionView();
+ OSectionView& rView = rxSection->getReportSection().getSectionView();
if ( rView.AreObjectsMarked() )
{
rView.SortMarkedObjects();
@@ -673,11 +650,8 @@ void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles)
void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles, ControlModification _nControlModification,bool _bAlignAtSection, tools::Rectangle& _rBound, tools::Rectangle& _rResize)
{
bool bOnlyOnce = false;
- TRectangleMap::const_iterator aRectIter = _rSortRectangles.begin();
- TRectangleMap::const_iterator aRectEnd = _rSortRectangles.end();
- for (;aRectIter != aRectEnd ; ++aRectIter)
+ for (const auto& [aObjRect, rObjViewPair] : _rSortRectangles)
{
- tools::Rectangle aObjRect = aRectIter->first;
if ( _rResize.IsEmpty() )
_rResize = aObjRect;
switch(_nControlModification)
@@ -702,7 +676,7 @@ void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,
}
SdrObjTransformInfoRec aInfo;
- const SdrObject* pObj = aRectIter->second.first;
+ const SdrObject* pObj = rObjViewPair.first;
pObj->TakeObjInfo(aInfo);
bool bHasFixed = !aInfo.bMoveAllowed || pObj->IsMoveProtect();
if ( bHasFixed )
@@ -714,7 +688,7 @@ void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,
if ( ! bOnlyOnce )
{
bOnlyOnce = true;
- OReportSection* pReportSection = aRectIter->second.second->getReportSection();
+ OReportSection* pReportSection = rObjViewPair.second->getReportSection();
const uno::Reference< report::XSection>& xSection = pReportSection->getSection();
try
{
@@ -728,7 +702,7 @@ void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,
}
else
{
- _rBound.Union(aRectIter->second.second->GetMarkedObjRect());
+ _rBound.Union(rObjViewPair.second->GetMarkedObjRect());
}
}
}
@@ -901,37 +875,24 @@ void OViewsWindow::createDefault()
void OViewsWindow::setGridSnap(bool bOn)
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- (*aIter)->getReportSection().getSectionView().SetGridSnap(bOn);
- (*aIter)->getReportSection().Invalidate();
+ rxSection->getReportSection().getSectionView().SetGridSnap(bOn);
+ rxSection->getReportSection().Invalidate();
}
}
void OViewsWindow::setDragStripes(bool bOn)
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd ; ++aIter)
- (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn);
+ for (const auto& rxSection : m_aSections)
+ rxSection->getReportSection().getSectionView().SetDragStripes(bOn);
}
sal_uInt16 OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- sal_uInt16 nPosition = 0;
- for (; aIter != aEnd ; ++aIter)
- {
- if ( _pSectionWindow == (*aIter).get() )
- {
- break;
- }
- ++nPosition;
- }
- return nPosition;
+ auto aIter = std::find_if(m_aSections.begin(), m_aSections.end(),
+ [&_pSectionWindow](const VclPtr<OSectionWindow>& rxSection) { return _pSectionWindow == rxSection.get(); });
+ return static_cast<sal_uInt16>(std::distance(m_aSections.begin(), aIter));
}
OSectionWindow* OViewsWindow::getSectionWindow(const sal_uInt16 _nPos) const
@@ -1003,13 +964,11 @@ void OViewsWindow::BrkAction()
void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const tools::Rectangle& _aRect, const OSectionView& _rSection)
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
Point aNewPos(0,0);
- for (; aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
rReportSection.getPage()->setSpecialMode();
OSectionView& rView = rReportSection.getSectionView();
@@ -1042,11 +1001,9 @@ void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionVi
// Calculate the absolute clickpoint in the views
Point aAbsolutePnt = _aPnt;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
OSectionView* pView = &rReportSection.getSectionView();
if (pView == _pSection)
break;
@@ -1066,9 +1023,9 @@ void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionVi
int nViewCount = 0;
Point aNewObjPos(0,0);
Point aLeftTop = Point(SAL_MAX_INT32, SAL_MAX_INT32);
- for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
OSectionView& rView = rReportSection.getSectionView();
@@ -1114,9 +1071,9 @@ void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionVi
const short nDrgLog = static_cast<short>(PixelToLogic(Size(3,0)).Width());
nViewCount = 0;
- for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
SdrHdl* pHdl = _pHdl;
if ( pHdl )
@@ -1149,12 +1106,10 @@ void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection)
bool bAdd = true;
Point aNewPos = _aPnt;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
long nLastSectionHeight = 0;
- for (; aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
if ( &rReportSection.getSectionView() == _pSection )
{
bAdd = false;
@@ -1177,15 +1132,11 @@ void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection)
OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt)
{
OSectionView* pSection = nullptr;
- sal_Int32 nCount = 0;
TSectionsMap::const_iterator aIter = m_aSections.begin();
const TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd ; ++aIter,++nCount)
- {
- OReportSection& rReportSection = (*aIter)->getReportSection();
- if ( &rReportSection.getSectionView() == _pSection)
- break;
- }
+ aIter = std::find_if(aIter, aEnd, [&_pSection](const VclPtr<OSectionWindow>& rxSection) {
+ return &rxSection->getReportSection().getSectionView() == _pSection; });
+ sal_Int32 nCount = static_cast<sal_Int32>(std::distance(m_aSections.cbegin(), aIter));
OSL_ENSURE(aIter != aEnd,"This can never happen!");
if ( _rPnt.Y() < 0 )
{
@@ -1225,12 +1176,9 @@ OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pS
void OViewsWindow::EndDragObj_removeInvisibleObjects()
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
-
- for (; aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
rReportSection.getPage()->resetSpecialMode();
}
}
@@ -1252,11 +1200,9 @@ void OViewsWindow::EndDragObj(bool _bControlKeyPressed, const OSectionView* _pSe
aNewPos -= m_aDragDelta;
uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- const TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
if ( pInSection != &rReportSection.getSectionView() )
{
rReportSection.getSectionView().BrkAction();
@@ -1358,26 +1304,23 @@ void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection, b
aHdlPos = pHdl->GetPos();
}
- TSectionsMap::const_iterator aIter;
- TSectionsMap::const_iterator aEnd = m_aSections.end();
-
- for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
if ( &rReportSection.getSectionView() == _pSection )
break;
- const long nSectionHeight = (*aIter)->PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
+ const long nSectionHeight = rxSection->PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
aCurrentSectionPos.AdjustY(nSectionHeight );
}
aRealMousePos += aCurrentSectionPos;
// If control key is pressed the work area is limited to the section with the current selection.
Point aPosForWorkArea(0,0);
- for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
OSectionView& rView = rReportSection.getSectionView();
- const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
+ const long nSectionHeight = rxSection->PixelToLogic(rxSection->GetOutputSizePixel()).Height();
if (_bControlKeySet)
{
@@ -1396,46 +1339,35 @@ void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection, b
}
- for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
SdrHdl* pCurrentHdl = rReportSection.getSectionView().GetDragHdl();
if ( pCurrentHdl && aRealMousePos.Y() > 0 )
aRealMousePos = _aPnt + pCurrentHdl->GetPos() - aHdlPos;
rReportSection.getSectionView().MovAction ( aRealMousePos );
- const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
+ const long nSectionHeight = rxSection->PixelToLogic(rxSection->GetOutputSizePixel()).Height();
aRealMousePos.AdjustY( -nSectionHeight );
}
}
bool OViewsWindow::IsAction() const
{
- bool bAction = false;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; !bAction && aIter != aEnd; ++aIter)
- bAction = (*aIter)->getReportSection().getSectionView().IsAction();
- return bAction;
+ return std::any_of(m_aSections.begin(), m_aSections.end(),
+ [](const VclPtr<OSectionWindow>& rxSection) { return rxSection->getReportSection().getSectionView().IsAction(); });
}
bool OViewsWindow::IsDragObj() const
{
- bool bAction = false;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; !bAction && aIter != aEnd; ++aIter)
- bAction = (*aIter)->getReportSection().getSectionView().IsAction();
- return bAction;
+ return std::any_of(m_aSections.begin(), m_aSections.end(),
+ [](const VclPtr<OSectionWindow>& rxSection) { return rxSection->getReportSection().getSectionView().IsAction(); });
}
sal_uInt32 OViewsWindow::getMarkedObjectCount() const
{
- sal_uInt32 nCount = 0;
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd; ++aIter)
- nCount += static_cast<sal_uInt32>((*aIter)->getReportSection().getSectionView().GetMarkedObjectCount());
- return nCount;
+ return std::accumulate(m_aSections.begin(), m_aSections.end(), sal_uInt32(0),
+ [](const sal_uInt32 nCount, const VclPtr<OSectionWindow>& rxSection) {
+ return nCount + static_cast<sal_uInt32>(rxSection->getReportSection().getSectionView().GetMarkedObjectCount()); });
}
void OViewsWindow::handleKey(const vcl::KeyCode& _rCode)
@@ -1450,11 +1382,10 @@ void OViewsWindow::handleKey(const vcl::KeyCode& _rCode)
rScrollBar.DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? ScrollType::LineUp : ScrollType::LineDown );
return;
}
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (; aIter != aEnd; ++aIter)
+
+ for (const auto& rxSection : m_aSections)
{
- OReportSection& rReportSection = (*aIter)->getReportSection();
+ OReportSection& rReportSection = rxSection->getReportSection();
long nX = 0;
long nY = 0;
@@ -1665,12 +1596,12 @@ void OViewsWindow::stopScrollTimer()
void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (sal_uInt16 i = 0;aIter != aEnd ; ++aIter,++i)
+ sal_uInt16 i = 0;
+ for (const auto& rxSection : m_aSections)
{
- if ( (*aIter)->getStartMarker().isCollapsed() )
+ if ( rxSection->getStartMarker().isCollapsed() )
_rCollapsedPositions.push_back(i);
+ ++i;
}
}
@@ -1700,11 +1631,9 @@ void OViewsWindow::zoom(const Fraction& _aZoom)
setZoomFactor(_aZoom,*this);
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- (*aIter)->zoom(_aZoom);
+ rxSection->zoom(_aZoom);
}
Resize();
@@ -1732,21 +1661,17 @@ void OViewsWindow::scrollChildren(const Point& _aThumbPos)
Scroll(0, -( aOld.Y() + aPosY.Y()),ScrollFlags::Children);
}
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for (;aIter != aEnd ; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- (*aIter)->scrollChildren(aPos.X());
+ rxSection->scrollChildren(aPos.X());
}
}
void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
{
- TSectionsMap::const_iterator aIter = m_aSections.begin();
- TSectionsMap::const_iterator aEnd = m_aSections.end();
- for(;aIter != aEnd; ++aIter)
+ for (const auto& rxSection : m_aSections)
{
- (*aIter)->getReportSection().fillControlModelSelection(_rSelection);
+ rxSection->getReportSection().fillControlModelSelection(_rSelection);
}
}
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 3482017958c0..4a913f5fef3a 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -133,13 +133,12 @@ static bool find(
OUString * value)
{
OSL_ASSERT(value);
- for (NameValueVector::const_iterator i(vector.begin()); i != vector.end(); ++i)
+ auto i = std::find_if(vector.begin(), vector.end(),
+ [&key](const rtl_bootstrap_NameValue& rNameValue) { return rNameValue.sName == key; });
+ if (i != vector.end())
{
- if (i->sName == key)
- {
- *value = i->sValue;
- return true;
- }
+ *value = i->sValue;
+ return true;
}
return false;
}
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index ff2d0080794b..a8c0c8fc357c 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -839,14 +839,13 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
if ( rEntity.maPendingEvents.size() <= Entity::mnEventLowWater )
{
aGuard.clear();
- for (auto aEventIt = xEventList->maEvents.begin();
- aEventIt != xEventList->maEvents.end(); ++aEventIt)
+ for (auto& rEvent : xEventList->maEvents)
{
- if (aEventIt->mxAttributes.is())
+ if (rEvent.mxAttributes.is())
{
- aEventIt->mxAttributes->clear();
+ rEvent.mxAttributes->clear();
if( rEntity.mxNamespaceHandler.is() )
- aEventIt->mxDeclAttributes->clear();
+ rEvent.mxDeclAttributes->clear();
}
xEventList->mbIsAttributesEmpty = true;
}
@@ -980,23 +979,22 @@ bool FastSaxParserImpl::consume(EventList& rEventList)
{
Entity& rEntity = getEntity();
rEventList.mbIsAttributesEmpty = false;
- for (auto aEventIt = rEventList.maEvents.begin();
- aEventIt != rEventList.maEvents.end(); ++aEventIt)
+ for (auto& rEvent : rEventList.maEvents)
{
- switch ((*aEventIt).maType)
+ switch (rEvent.maType)
{
case CallbackType::START_ELEMENT:
- rEntity.startElement( &(*aEventIt) );
+ rEntity.startElement( &rEvent );
break;
case CallbackType::END_ELEMENT:
rEntity.endElement();
break;
case CallbackType::CHARACTERS:
- rEntity.characters( (*aEventIt).msChars );
+ rEntity.characters( rEvent.msChars );
break;
case CallbackType::PROCESSING_INSTRUCTION:
rEntity.processingInstruction(
- (*aEventIt).msNamespace, (*aEventIt).msElementName ); // ( target, data )
+ rEvent.msNamespace, rEvent.msElementName ); // ( target, data )
break;
case CallbackType::DONE:
return false;
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 21d36d30b81c..bc80a5b31f4c 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -236,8 +236,8 @@ Sequence< Attribute > FastAttributeList::getUnknownAttributes( )
{
Sequence< Attribute > aSeq( maUnknownAttributes.size() );
Attribute* pAttr = aSeq.getArray();
- for( UnknownAttributeList::iterator attrIter = maUnknownAttributes.begin(); attrIter != maUnknownAttributes.end(); ++attrIter )
- (*attrIter).FillAttribute( pAttr++ );
+ for( auto& rAttr : maUnknownAttributes )
+ rAttr.FillAttribute( pAttr++ );
return aSeq;
}
Sequence< FastAttribute > FastAttributeList::getFastAttributes( )
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index d299ca73ce08..a4c080663cc8 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -751,14 +751,12 @@ namespace sax_fastparser {
#if OSL_DEBUG_LEVEL > 0
void FastSaxSerializer::ForSort::print( )
{
- std::map< sal_Int32, Int8Sequence >::iterator iter = maData.begin();
- while ( iter != maData.end( ) )
+ for ( const auto& [rElement, rData] : maData )
{
- std::cerr << "pair: " << iter->first;
- for ( sal_Int32 i=0, len=iter->second.getLength(); i < len; ++i )
- std::cerr << iter->second[i];
+ std::cerr << "pair: " << rElement;
+ for ( sal_Int32 i=0, len=rData.getLength(); i < len; ++i )
+ std::cerr << rData[i];
std::cerr << "\n";
- ++iter;
}
sort( );
diff --git a/sax/test/sax/testwriter.cxx b/sax/test/sax/testwriter.cxx
index ee323ef5cf77..505e3d8a410f 100644
--- a/sax/test/sax/testwriter.cxx
+++ b/sax/test/sax/testwriter.cxx
@@ -236,29 +236,19 @@ OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeExceptio
OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for (; ii != m_pImpl->vecAttribute.end(); ++ii)
- {
- if( (*ii).sName == sName )
- {
- return (*ii).sType;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sType;
return OUString();
}
OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for(; ii != m_pImpl->vecAttribute.end(); ++ii)
- {
- if( (*ii).sName == sName )
- {
- return (*ii).sValue;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sValue;
return OUString();
}
diff --git a/sax/test/saxdemo.cxx b/sax/test/saxdemo.cxx
index f00d598b722f..a501294529e1 100644
--- a/sax/test/saxdemo.cxx
+++ b/sax/test/saxdemo.cxx
@@ -343,25 +343,19 @@ OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeExceptio
OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
- if( (*ii).sName == sName ) {
- return (*ii).sType;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sType;
return OUString();
}
OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException)
{
- vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
-
- for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
- if( (*ii).sName == sName ) {
- return (*ii).sValue;
- }
- }
+ auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+ [&sName](const struct TagAttribute& rAttr) { return rAttr.sName == sName; });
+ if (ii != m_pImpl->vecAttribute.end())
+ return (*ii).sValue;
return OUString();
}
More information about the Libreoffice-commits
mailing list