diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-12-10 11:41:38 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-12-10 13:57:53 +0100 |
commit | 6c42e3961ed29d3b6aa505c46b7d65024055a08e (patch) | |
tree | 254711ed403793ad340c7ff3e62d7aadc2812230 /sdext | |
parent | 0201942d31f6cf1baee010de8423b8bdc5f8d343 (diff) |
Modernize code in sdext
Change-Id: I2257014cf77b14aba263718b4730744960cc1dc2
Reviewed-on: https://gerrit.libreoffice.org/46178
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/tree/genericelements.cxx | 19 | ||||
-rw-r--r-- | sdext/source/pdfimport/tree/pdfiprocessor.cxx | 10 |
2 files changed, 12 insertions, 17 deletions
diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx index 6c84d8bd5dd4..ccb2fd53c932 100644 --- a/sdext/source/pdfimport/tree/genericelements.cxx +++ b/sdext/source/pdfimport/tree/genericelements.cxx @@ -34,17 +34,14 @@ namespace pdfi Element::~Element() { - while( !Children.empty() ) - { - Element* pCurr( Children.front() ); - delete pCurr; - Children.pop_front(); - } + for (auto const& child : Children) + delete child; + Children.clear(); } void Element::applyToChildren( ElementTreeVisitor& rVisitor ) { - for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it ) + for( auto it = Children.begin(); it != Children.end(); ++it ) (*it)->visitedBy( rVisitor, it ); } @@ -92,8 +89,8 @@ void Element::emitStructure( int nLevel) { SAL_INFO( "sdext", std::string(nLevel, ' ') << "<" << typeid( *this ).name() << " " << this << "> (" << std::setprecision(1) << x << "," << y << ")+(" << w << "x" << h << ")" ); - for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it ) - (*it)->emitStructure(nLevel+1 ); + for (auto const& child : Children) + child->emitStructure(nLevel+1); SAL_INFO( "sdext", std::string(nLevel, ' ') << "</" << typeid( *this ).name() << ">" ); } #endif @@ -179,8 +176,8 @@ void PolyPolyElement::emitStructure( int nLevel) } SAL_WARN( "sdext", " " << buff.makeStringAndClear() ); } - for( std::list< Element* >::iterator it = Children.begin(); it != Children.end(); ++it ) - (*it)->emitStructure( nLevel+1 ); + for (auto const& child : Children) + child->emitStructure( nLevel+1 ); SAL_WARN( "sdext", std::string(nLevel, ' ') << "</" << typeid( *this ).name() << ">"); } #endif diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index 79982ded1c4a..fac0e6873638 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -696,10 +696,9 @@ void PDFIProcessor::sortElements( Element* pEle, bool bDeep ) if( bDeep ) { - for( std::list< Element* >::iterator it = pEle->Children.begin(); - it != pEle->Children.end(); ++it ) + for (auto const& child : pEle->Children) { - sortElements( *it, bDeep ); + sortElements( child, bDeep ); } } // HACK: the stable sort member on std::list that takes a @@ -716,9 +715,8 @@ void PDFIProcessor::sortElements( Element* pEle, bool bDeep ) pEle->Children.pop_front(); } std::stable_sort( aChildren.begin(), aChildren.end(), lr_tb_sort ); - int nChildren = aChildren.size(); - for( int i = 0; i < nChildren; i++ ) - pEle->Children.push_back( aChildren[i] ); + for (auto const& child : aChildren) + pEle->Children.push_back(child); } // helper method: get a mirrored string |