summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-02-02 07:28:38 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-02-02 19:49:46 +0100
commitaed2107e1d003566d6cdb46c2bebe8b025d5f399 (patch)
tree5aa1606e03554a4a89c2fa9b624cd7f05acb8c49 /sdext
parent269d6d3366eea8541d965181dfdda1fdc5ef2d00 (diff)
Simplify sortElements in pdfiprocessor (sdext)
For explanation, see: http://nabble.documentfoundation.org/About-simplifying-sortElements-in-pdfiprocessor-sdext-tt4231909.html Change-Id: I53fb732d776d7152279e5fc1440eafac1cfd71fe Reviewed-on: https://gerrit.libreoffice.org/49127 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/inc/pdfiprocessor.hxx2
-rw-r--r--sdext/source/pdfimport/tree/pdfiprocessor.cxx28
2 files changed, 5 insertions, 25 deletions
diff --git a/sdext/source/pdfimport/inc/pdfiprocessor.hxx b/sdext/source/pdfimport/inc/pdfiprocessor.hxx
index f0662b8b1ad9..952944e3dc74 100644
--- a/sdext/source/pdfimport/inc/pdfiprocessor.hxx
+++ b/sdext/source/pdfimport/inc/pdfiprocessor.hxx
@@ -90,7 +90,7 @@ namespace pdfi
const FontAttributes& getFont( sal_Int32 nFontId ) const;
sal_Int32 getFontId( const FontAttributes& rAttr ) const;
- void sortElements( Element* pElement, bool bDeep = false );
+ void sortElements( Element* pElement );
static OUString mirrorString( const OUString& i_rInString );
diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
index 4937e332d6f6..6599d7430b4c 100644
--- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx
+++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
@@ -685,34 +685,14 @@ static bool lr_tb_sort( Element* pLeft, Element* pRight )
return false;
}
-void PDFIProcessor::sortElements( Element* pEle, bool bDeep )
+void PDFIProcessor::sortElements(Element* pEle)
{
if( pEle->Children.empty() )
return;
- if( bDeep )
- {
- for (auto const& child : pEle->Children)
- {
- sortElements( child, bDeep );
- }
- }
- // HACK: the stable sort member on std::list that takes a
- // strict weak ordering requires member templates - which we
- // do not have on all compilers. so we need to use std::stable_sort
- // here - which does need random access iterators which the
- // list iterators are not.
- // so we need to copy the Element* to an array, stable sort that and
- // copy them back.
- std::vector<Element*> aChildren;
- while( ! pEle->Children.empty() )
- {
- aChildren.push_back( pEle->Children.front() );
- pEle->Children.pop_front();
- }
- std::stable_sort( aChildren.begin(), aChildren.end(), lr_tb_sort );
- for (auto const& child : aChildren)
- pEle->Children.push_back(child);
+ // sort method from std::list is equivalent to stable_sort
+ // See S Meyers, Effective STL
+ pEle->Children.sort(lr_tb_sort);
}
// helper method: get a mirrored string