summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-09-29 19:35:12 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-29 21:14:35 +0200
commit65b00f316517b0f570b6aff30e70d95d4d543c03 (patch)
tree57793ade4859169f33ee5d8672872d53b51ba1c5 /writerfilter
parent618d474f059a75c2ac04df16c830d71a88690118 (diff)
Simplify containers iterations in w*
Use range-based loop or replace with STL functions. Change-Id: Ie1e169f9d2d44e188180164bd1f93af43740425d Reviewed-on: https://gerrit.libreoffice.org/61141 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx17
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx23
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx76
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.cxx22
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx15
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx67
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx27
9 files changed, 112 insertions, 182 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 527c0b941517..3a0140f2646e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1902,17 +1902,16 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", m_pImpl->m_aSubInteropGrabBag);
else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color)
{
- std::vector<beans::PropertyValue>::iterator aIter = m_pImpl->m_aSubInteropGrabBag.begin();
- for (; aIter != m_pImpl->m_aSubInteropGrabBag.end(); ++aIter)
- {
- if (aIter->Name == "val")
- m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, aIter->Value, true, CHAR_GRAB_BAG);
- else if (aIter->Name == "themeColor")
- m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, aIter->Value, true, CHAR_GRAB_BAG);
- else if (aIter->Name == "themeShade")
- m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, aIter->Value, true, CHAR_GRAB_BAG);
- else if (aIter->Name == "themeTint")
- m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, aIter->Value, true, CHAR_GRAB_BAG);
+ for (const auto& rItem : m_pImpl->m_aSubInteropGrabBag)
+ {
+ if (rItem.Name == "val")
+ m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, rItem.Value, true, CHAR_GRAB_BAG);
+ else if (rItem.Name == "themeColor")
+ m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, rItem.Value, true, CHAR_GRAB_BAG);
+ else if (rItem.Name == "themeShade")
+ m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, rItem.Value, true, CHAR_GRAB_BAG);
+ else if (rItem.Name == "themeTint")
+ m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, rItem.Value, true, CHAR_GRAB_BAG);
}
if (bTempGrabBag)
//disable and clear DomainMapper grab bag if it wasn't enabled before
@@ -2768,15 +2767,13 @@ void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32
{
assert( m_pImpl->GetTopContextType() == CONTEXT_CHARACTER );
PropertyMapPtr rContext = m_pImpl->GetTopContext();
- for( std::map< sal_Int32, uno::Any >::const_iterator it = deferredCharacterProperties.begin();
- it != deferredCharacterProperties.end();
- ++it )
+ for( const auto& rProp : deferredCharacterProperties )
{
- sal_Int32 Id = it->first;
+ sal_Int32 Id = rProp.first;
sal_Int32 nIntValue = 0;
OUString sStringValue;
- it->second >>= nIntValue;
- it->second >>= sStringValue;
+ rProp.second >>= nIntValue;
+ rProp.second >>= sStringValue;
switch( Id )
{
case NS_ooxml::LN_EG_RPrBase_sz:
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index c0a8cbda54db..ced27a0b80fa 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -909,36 +909,33 @@ css::uno::Sequence<css::beans::PropertyValues> DomainMapperTableHandler::endTabl
#endif
css::uno::Sequence<css::beans::PropertyValues> aRowProperties( m_aRowProperties.size() );
- PropertyMapVector1::const_iterator aRowIter = m_aRowProperties.begin();
- PropertyMapVector1::const_iterator aRowIterEnd = m_aRowProperties.end();
sal_Int32 nRow = 0;
- while( aRowIter != aRowIterEnd )
+ for( const auto& rRow : m_aRowProperties )
{
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement("rowProps.row");
#endif
- if( aRowIter->get() )
+ if( rRow.get() )
{
//set default to 'break across pages"
- (*aRowIter)->Insert( PROP_IS_SPLIT_ALLOWED, uno::makeAny(true ), false );
+ rRow->Insert( PROP_IS_SPLIT_ALLOWED, uno::makeAny(true ), false );
// tblHeader is only our property, remove before the property map hits UNO
- (*aRowIter)->Erase(PROP_TBL_HEADER);
+ rRow->Erase(PROP_TBL_HEADER);
if (lcl_hideMarks(m_aCellProperties[nRow]) && lcl_emptyRow(m_aTableRanges, nRow))
{
// We have CellHideMark on all cells, and also all cells are empty:
// Force the row height to be exactly as specified, and not just as the minimum suggestion.
- (*aRowIter)->Insert(PROP_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
+ rRow->Insert(PROP_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
}
- aRowProperties[nRow] = (*aRowIter)->GetPropertyValues();
+ aRowProperties[nRow] = rRow->GetPropertyValues();
#ifdef DEBUG_WRITERFILTER
- (*aRowIter)->dumpXml();
+ rRow->dumpXml();
lcl_DumpPropertyValues(aRowProperties[nRow]);
#endif
}
++nRow;
- ++aRowIter;
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().endElement();
#endif
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index ed7dfebe97c4..f76f28dcac1f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -35,6 +35,7 @@
#include "DomainMapper.hxx"
#include <rtl/math.hxx>
#include <sal/log.hxx>
+#include <numeric>
namespace writerfilter {
namespace dmapper {
@@ -562,21 +563,19 @@ void DomainMapperTableManager::endOfRowAction()
IntVectorPtr pCellWidths = getCurrentCellWidths( );
if(!m_nTableWidth && pTableGrid->size())
{
- ::std::vector<sal_Int32>::const_iterator aCellIter = pTableGrid->begin();
-
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement("tableWidth");
#endif
- while( aCellIter != pTableGrid->end() )
+ for( const auto& rCell : *pTableGrid )
{
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement("col");
- TagLogger::getInstance().attribute("width", *aCellIter);
+ TagLogger::getInstance().attribute("width", rCell);
TagLogger::getInstance().endElement();
#endif
- m_nTableWidth = o3tl::saturating_add(m_nTableWidth, *aCellIter++);
+ m_nTableWidth = o3tl::saturating_add(m_nTableWidth, rCell);
}
if (m_nTableWidth > 0 && !m_bTableSizeTypeInserted)
@@ -601,26 +600,18 @@ void DomainMapperTableManager::endOfRowAction()
#ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement("gridSpans");
{
- ::std::vector<sal_Int32>::const_iterator aGridSpanIter = pCurrentSpans->begin();
- ::std::vector<sal_Int32>::const_iterator aGridSpanIterEnd = pCurrentSpans->end();
-
- while (aGridSpanIter != aGridSpanIterEnd)
+ for (const auto& rGridSpan : *pCurrentSpans)
{
TagLogger::getInstance().startElement("gridSpan");
- TagLogger::getInstance().attribute("span", *aGridSpanIter);
+ TagLogger::getInstance().attribute("span", rGridSpan);
TagLogger::getInstance().endElement();
-
- ++aGridSpanIter;
}
}
TagLogger::getInstance().endElement();
#endif
//calculate number of used grids - it has to match the size of m_aTableGrid
- size_t nGrids = 0;
- ::std::vector<sal_Int32>::const_iterator aGridSpanIter = pCurrentSpans->begin();
- for( ; aGridSpanIter != pCurrentSpans->end(); ++aGridSpanIter)
- nGrids += *aGridSpanIter;
+ size_t nGrids = std::accumulate(pCurrentSpans->begin(), pCurrentSpans->end(), sal::static_int_cast<size_t>(0));
// sj: the grid is having no units... they is containing only relative values.
// a table with a grid of "1:2:1" looks identical as if the table is having
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6359fdf0982a..5c1251f4d1d9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -631,23 +631,17 @@ void DomainMapper_Impl::InitTabStopFromStyle( const uno::Sequence< style::TabSto
void DomainMapper_Impl::IncorporateTabStop( const DeletableTabStop & rTabStop )
{
- ::std::vector<DeletableTabStop>::iterator aIt = m_aCurrentTabStops.begin();
- ::std::vector<DeletableTabStop>::iterator aEndIt = m_aCurrentTabStops.end();
sal_Int32 nConverted = rTabStop.Position;
- bool bFound = false;
- for( ; aIt != aEndIt; ++aIt)
+ auto aIt = std::find_if(m_aCurrentTabStops.begin(), m_aCurrentTabStops.end(),
+ [&nConverted](const DeletableTabStop& rCurrentTabStop) { return rCurrentTabStop.Position == nConverted; });
+ if( aIt != m_aCurrentTabStops.end() )
{
- if( aIt->Position == nConverted )
- {
- bFound = true;
- if( rTabStop.bDeleted )
- m_aCurrentTabStops.erase( aIt );
- else
- *aIt = rTabStop;
- break;
- }
+ if( rTabStop.bDeleted )
+ m_aCurrentTabStops.erase( aIt );
+ else
+ *aIt = rTabStop;
}
- if( !bFound )
+ else
m_aCurrentTabStops.push_back( rTabStop );
}
@@ -2097,20 +2091,17 @@ void DomainMapper_Impl::CheckRedline( uno::Reference< text::XTextRange > const&
if( GetTopContextOfType(CONTEXT_PARAGRAPH) )
{
std::vector<RedlineParamsPtr>& avRedLines = GetTopContextOfType(CONTEXT_PARAGRAPH)->Redlines();
- for( std::vector<RedlineParamsPtr>::const_iterator it = avRedLines.begin();
- it != avRedLines.end(); ++it )
- CreateRedline( xRange, *it );
+ for( const auto& rRedline : avRedLines )
+ CreateRedline( xRange, rRedline );
}
if( GetTopContextOfType(CONTEXT_CHARACTER) )
{
std::vector<RedlineParamsPtr>& avRedLines = GetTopContextOfType(CONTEXT_CHARACTER)->Redlines();
- for( std::vector<RedlineParamsPtr>::const_iterator it = avRedLines.begin();
- it != avRedLines.end(); ++it )
- CreateRedline( xRange, *it );
+ for( const auto& rRedline : avRedLines )
+ CreateRedline( xRange, rRedline );
}
- std::vector<RedlineParamsPtr>::iterator pIt = m_aRedlines.top().begin( );
- for (; pIt != m_aRedlines.top().end( ); ++pIt )
- CreateRedline( xRange, *pIt );
+ for (const auto& rRedline : m_aRedlines.top() )
+ CreateRedline( xRange, rRedline );
}
void DomainMapper_Impl::StartParaMarkerChange( )
@@ -2931,10 +2922,9 @@ void DomainMapper_Impl::ChainTextFrames()
OUString sChainNextName("ChainNextName");
//learn about ALL of the textboxes and their chaining values first - because frames are processed in no specific order.
- std::vector<uno::Reference< drawing::XShape > >::iterator iter;
- for( iter = m_vTextFramesForChaining.begin(); iter != m_vTextFramesForChaining.end(); ++iter )
+ for( const auto& rTextFrame : m_vTextFramesForChaining )
{
- uno::Reference<text::XTextContent> xTextContent(*iter, uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextContent> xTextContent(rTextFrame, uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY);
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo;
if( xPropertySet.is() )
@@ -2976,30 +2966,30 @@ void DomainMapper_Impl::ChainTextFrames()
if( !sLinkChainName.isEmpty() )
{
- aChainStruct.xShape = *iter;
+ aChainStruct.xShape = rTextFrame;
aTextFramesForChainingHelper[sLinkChainName] = aChainStruct;
}
}
//if mso-next-textbox tags are provided, create those vml-style links first. Afterwards we will make dml-style id/seq links.
- for (ChainMap::iterator msoIter= aTextFramesForChainingHelper.begin(); msoIter != aTextFramesForChainingHelper.end(); ++msoIter)
+ for (auto& msoItem : aTextFramesForChainingHelper)
{
//if no mso-next-textbox, we are done.
//if it points to itself, we are done.
- if( !msoIter->second.s_mso_next_textbox.isEmpty()
- && msoIter->second.s_mso_next_textbox != msoIter->first )
+ if( !msoItem.second.s_mso_next_textbox.isEmpty()
+ && msoItem.second.s_mso_next_textbox != msoItem.first )
{
- ChainMap::iterator nextFinder=aTextFramesForChainingHelper.find(msoIter->second.s_mso_next_textbox);
+ ChainMap::iterator nextFinder=aTextFramesForChainingHelper.find(msoItem.second.s_mso_next_textbox);
if( nextFinder != aTextFramesForChainingHelper.end() )
{
//if the frames have no name yet, then set them. LinkDisplayName / ChainName are read-only.
- if( !msoIter->second.bShapeNameSet )
+ if( !msoItem.second.bShapeNameSet )
{
- uno::Reference< container::XNamed > xNamed( msoIter->second.xShape, uno::UNO_QUERY );
+ uno::Reference< container::XNamed > xNamed( msoItem.second.xShape, uno::UNO_QUERY );
if ( xNamed.is() )
{
- xNamed->setName( msoIter->first );
- msoIter->second.bShapeNameSet = true;
+ xNamed->setName( msoItem.first );
+ msoItem.second.bShapeNameSet = true;
}
}
if( !nextFinder->second.bShapeNameSet )
@@ -3012,7 +3002,7 @@ void DomainMapper_Impl::ChainTextFrames()
}
}
- uno::Reference<text::XTextContent> xTextContent(msoIter->second.xShape, uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextContent> xTextContent(msoItem.second.xShape, uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY);
//The reverse chaining happens automatically, so only one direction needs to be set
@@ -3029,21 +3019,21 @@ void DomainMapper_Impl::ChainTextFrames()
const sal_Int32 nDirection = 1;
//Finally - go through and attach the chains based on matching ID and incremented sequence number (dml-style).
- for (ChainMap::iterator outer_iter= aTextFramesForChainingHelper.begin(); outer_iter != aTextFramesForChainingHelper.end(); ++outer_iter)
+ for (const auto& rOuter : aTextFramesForChainingHelper)
{
- if( outer_iter->second.s_mso_next_textbox.isEmpty() ) //non-empty ones already handled earlier - so skipping them now.
+ if( rOuter.second.s_mso_next_textbox.isEmpty() ) //non-empty ones already handled earlier - so skipping them now.
{
- for (ChainMap::iterator inner_iter=aTextFramesForChainingHelper.begin(); inner_iter != aTextFramesForChainingHelper.end(); ++inner_iter)
+ for (const auto& rInner : aTextFramesForChainingHelper)
{
- if ( inner_iter->second.nId == outer_iter->second.nId )
+ if ( rInner.second.nId == rOuter.second.nId )
{
- if ( inner_iter->second.nSeq == ( outer_iter->second.nSeq + nDirection ) )
+ if ( rInner.second.nSeq == ( rOuter.second.nSeq + nDirection ) )
{
- uno::Reference<text::XTextContent> xTextContent(outer_iter->second.xShape, uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextContent> xTextContent(rOuter.second.xShape, uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY);
//The reverse chaining happens automatically, so only one direction needs to be set
- xPropertySet->setPropertyValue(sChainNextName, uno::makeAny(inner_iter->first));
+ xPropertySet->setPropertyValue(sChainNextName, uno::makeAny(rInner.first));
break ; //there cannot be more than one next frame
}
}
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 61522228523d..4a4c73eed580 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -271,20 +271,14 @@ void GraphicZOrderHelper::addItem(uno::Reference<beans::XPropertySet> const& pro
// added in the proper z-order, it is necessary to find the proper index.
sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldStyle )
{
- Items::const_iterator it = items.begin();
- while( it != items.end())
- {
- // std::map is iterated sorted by key
-
- // Old-style ordering differs in what should happen when there is already an item with the same z-order:
- // we belong under it in case of new-style, but we belong above it in case of old-style.
- bool bCond = bOldStyle ? (it->first > relativeHeight) : (it->first >= relativeHeight);
-
- if( bCond )
- break; // this is the first one higher, we belong right before it
- else
- ++it;
- }
+ // std::map is iterated sorted by key
+ auto it = std::find_if(items.cbegin(), items.cend(),
+ [relativeHeight, bOldStyle](const Items::value_type& rItem) {
+ // Old-style ordering differs in what should happen when there is already an item with the same z-order:
+ // we belong under it in case of new-style, but we belong above it in case of old-style.
+ return bOldStyle ? (rItem.first > relativeHeight) : (rItem.first >= relativeHeight);
+ }
+ );
sal_Int32 itemZOrderOffset(0); // before the item
if( it == items.end()) // we're topmost
{
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 1edc514fb342..9664c784a323 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -676,9 +676,9 @@ ListsManager::~ListsManager( )
void ListsManager::DisposeNumPicBullets( )
{
uno::Reference<drawing::XShape> xShape;
- for (std::vector<NumPicBullet::Pointer>::iterator it = m_aNumPicBullets.begin(); it != m_aNumPicBullets.end(); ++it)
+ for (const auto& rNumPicBullet : m_aNumPicBullets)
{
- xShape = (*it)->GetShape();
+ xShape = rNumPicBullet->GetShape();
if (xShape.is())
{
uno::Reference<lang::XComponent> xShapeComponent(xShape, uno::UNO_QUERY);
@@ -871,11 +871,11 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{
uno::Reference<drawing::XShape> xShape;
- for (std::vector<NumPicBullet::Pointer>::iterator it = m_aNumPicBullets.begin(); it != m_aNumPicBullets.end(); ++it)
+ for (const auto& rNumPicBullet : m_aNumPicBullets)
{
- if ((*it)->GetId() == nIntValue)
+ if (rNumPicBullet->GetId() == nIntValue)
{
- xShape = (*it)->GetShape();
+ xShape = rNumPicBullet->GetShape();
break;
}
}
@@ -1177,10 +1177,9 @@ ListDef::Pointer ListsManager::GetList( sal_Int32 nId )
void ListsManager::CreateNumberingRules( )
{
// Loop over the definitions
- std::vector< ListDef::Pointer >::iterator listIt = m_aLists.begin( );
- for ( ; listIt != m_aLists.end( ); ++listIt )
+ for ( const auto& rList : m_aLists )
{
- (*listIt)->CreateNumberingRules( m_rDMapper, m_xFactory );
+ rList->CreateNumberingRules( m_rDMapper, m_xFactory );
}
}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 47b54abfd040..64c47bfac84b 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -319,43 +319,27 @@ StyleSheetTable_Impl::StyleSheetTable_Impl(DomainMapper& rDMapper,
OUString StyleSheetTable_Impl::HasListCharStyle( const PropertyValueVector_t& rPropValues )
{
- ListCharStylePropertyVector_t::const_iterator aListVectorIter = m_aListCharStylePropertyVector.begin();
- while( aListVectorIter != m_aListCharStylePropertyVector.end() )
+ for( const auto& rListVector : m_aListCharStylePropertyVector )
{
+ const auto& rPropertyValues = rListVector.aPropertyValues;
//if size is identical
- if( aListVectorIter->aPropertyValues.size() == rPropValues.size() )
+ if( rPropertyValues.size() == rPropValues.size() )
{
bool bBreak = false;
//then search for all contained properties
- PropertyValueVector_t::const_iterator aList1Iter = rPropValues.begin();
- while( aList1Iter != rPropValues.end() && !bBreak)
+ for( const auto& rPropVal1 : rPropValues)
{
//find the property
- bool bElementFound = false;
- PropertyValueVector_t::const_iterator aList2Iter = aListVectorIter->aPropertyValues.begin();
- while( aList2Iter != aListVectorIter->aPropertyValues.end() && !bBreak )
- {
- if( aList2Iter->Name == aList1Iter->Name )
- {
- bElementFound = true;
- if( aList2Iter->Value != aList1Iter->Value )
- bBreak = true;
- break;
- }
- ++aList2Iter;
- }
+ auto aListIter = std::find_if(rPropertyValues.begin(), rPropertyValues.end(),
+ [&rPropVal1](const css::beans::PropertyValue& rPropVal2) { return rPropVal2.Name == rPropVal1.Name; });
//set break flag if property hasn't been found
- if(!bElementFound )
- {
- bBreak = true;
+ bBreak = (aListIter == rPropertyValues.end()) || (aListIter->Value != rPropVal1.Value);
+ if( bBreak )
break;
- }
- ++aList1Iter;
}
if( !bBreak )
- return aListVectorIter->sCharStyleName;
+ return rListVector.sCharStyleName;
}
- ++aListVectorIter;
}
return OUString();
}
@@ -883,15 +867,12 @@ public:
void PropValVector::Insert(const beans::PropertyValue& rVal)
{
- auto aIt = m_aValues.begin();
- while (aIt != m_aValues.end())
+ auto aIt = std::find_if(m_aValues.begin(), m_aValues.end(),
+ [&rVal](beans::PropertyValue& rPropVal) { return rPropVal.Name > rVal.Name; });
+ if (aIt != m_aValues.end())
{
- if (aIt->Name > rVal.Name)
- {
- m_aValues.insert( aIt, rVal );
- return;
- }
- ++aIt;
+ m_aValues.insert( aIt, rVal );
+ return;
}
m_aValues.push_back(rVal);
}
@@ -929,10 +910,8 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingParent;
std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingFollow;
std::vector<beans::PropertyValue> aTableStylesVec;
- std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin();
- while( aIt != m_pImpl->m_aStyleSheetEntries.end() )
+ for( auto& pEntry : m_pImpl->m_aStyleSheetEntries )
{
- StyleSheetEntryPtr pEntry = *aIt;
if( pEntry->nStyleTypeCode == STYLE_TYPE_CHAR || pEntry->nStyleTypeCode == STYLE_TYPE_PARA || pEntry->nStyleTypeCode == STYLE_TYPE_LIST )
{
bool bParaStyle = pEntry->nStyleTypeCode == STYLE_TYPE_PARA;
@@ -947,7 +926,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
// When pasting, don't update existing styles.
if (!m_pImpl->m_bIsNewDoc)
{
- ++aIt;
continue;
}
xStyles->getByName( sConvertedStyleName ) >>= xStyle;
@@ -1187,7 +1165,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(pEntry.get());
aTableStylesVec.push_back(pTableEntry->GetInteropGrabBag());
}
- ++aIt;
}
// Update the styles that were created before their parents or next-styles
@@ -1423,13 +1400,11 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten
if( bExtendedSearch )
{
//search for the rWWName in the IdentifierD of the existing styles and convert the sStyleName member
- std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin();
//TODO: performance issue - put styles list into a map sorted by its sStyleIdentifierD members
- while( aIt != m_pImpl->m_aStyleSheetEntries.end() )
+ for( const auto& rStyleSheetEntryPtr : m_pImpl->m_aStyleSheetEntries )
{
- if( rWWName == ( *aIt )->sStyleIdentifierD )
- sRet = ( *aIt )->sStyleName;
- ++aIt;
+ if( rWWName == rStyleSheetEntryPtr->sStyleIdentifierD )
+ sRet = rStyleSheetEntryPtr->sStyleName;
}
}
@@ -1575,18 +1550,16 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp
uno::Reference< style::XStyle > xStyle( xDocFactory->createInstance(
getPropertyName( PROP_SERVICE_CHAR_STYLE )), uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xStyleProps(xStyle, uno::UNO_QUERY_THROW );
- PropertyValueVector_t::const_iterator aCharPropIter = rCharProperties.begin();
- while( aCharPropIter != rCharProperties.end())
+ for( const auto& rCharProp : rCharProperties)
{
try
{
- xStyleProps->setPropertyValue( aCharPropIter->Name, aCharPropIter->Value );
+ xStyleProps->setPropertyValue( rCharProp.Name, rCharProp.Value );
}
catch( const uno::Exception& )
{
OSL_FAIL( "Exception in StyleSheetTable::getOrCreateCharStyle - Style::setPropertyValue");
}
- ++aCharPropIter;
}
xCharStyles->insertByName( sListLabel, uno::makeAny( xStyle) );
m_pImpl->m_aListCharStylePropertyVector.emplace_back( sListLabel, rCharProperties );
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
index 14a14e6f6178..bf9f966ecd24 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
@@ -397,13 +397,7 @@ void OOXMLPropertySet::add(const OOXMLPropertySet::Pointer_t& pPropertySet)
{
int x = mProperties.size();
mProperties.resize(mProperties.size() + pSet->mProperties.size());
- auto itSrc = pSet->mProperties.begin();
- auto itDest = mProperties.begin() + x;
- while (itSrc != pSet->mProperties.end())
- {
- *itDest = *itSrc;
- ++itDest; ++itSrc;
- }
+ std::copy(pSet->mProperties.begin(), pSet->mProperties.end(), mProperties.begin() + x);
}
}
@@ -780,19 +774,15 @@ void OOXMLTable::resolve(Table & rTable)
int nPos = 0;
- PropertySets_t::iterator it = mPropertySets.begin();
- PropertySets_t::iterator itEnd = mPropertySets.end();
-
- while (it != itEnd)
+ for (const auto& rPropSet : mPropertySets)
{
writerfilter::Reference<Properties>::Pointer_t pProperties
- ((*it)->getProperties());
+ (rPropSet->getProperties());
if (pProperties.get() != nullptr)
pTable->entry(nPos, pProperties);
++nPos;
- ++it;
}
}
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index dd80af103367..f5f32f186d42 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -113,13 +113,14 @@ void RTFSprms::set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwr
bool RTFSprms::erase(Id nKeyword)
{
ensureCopyBeforeWrite();
- for (auto i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
+
+ auto i = std::find_if(
+ m_pSprms->begin(), m_pSprms->end(),
+ [&nKeyword](RTFSprmsImpl::value_type& rEntry) { return rEntry.first == nKeyword; });
+ if (i != m_pSprms->end())
{
- if (i->first == nKeyword)
- {
- m_pSprms->erase(i);
- return true;
- }
+ m_pSprms->erase(i);
+ return true;
}
return false;
}
@@ -127,14 +128,12 @@ bool RTFSprms::erase(Id nKeyword)
void RTFSprms::eraseLast(Id nKeyword)
{
ensureCopyBeforeWrite();
- for (auto i = m_pSprms->rbegin(); i != m_pSprms->rend(); ++i)
- {
- if (i->first == nKeyword)
- {
- m_pSprms->erase(std::next(i).base());
- return;
- }
- }
+
+ auto i = std::find_if(
+ m_pSprms->rbegin(), m_pSprms->rend(),
+ [&nKeyword](RTFSprmsImpl::value_type& rEntry) { return rEntry.first == nKeyword; });
+ if (i != m_pSprms->rend())
+ m_pSprms->erase(std::next(i).base());
}
static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType)