summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-06-15 16:36:36 +0200
committerNoel Grandin <noel@peralex.com>2015-06-19 09:55:07 +0200
commite0f3e7c007e9eeced888b491ec2698acba4bc588 (patch)
treebb53c606375f22d63df0ca860e726d27e83fb1c3 /sdext
parent0c5d286cbe299be356797447cb2b6747c68a015e (diff)
tdf#42374 some small optimisations for opening this PDF file
makes it about 10% faster Change-Id: I145faed5aa7c312372f08cc651df5afcf10c70ab
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.cxx43
-rw-r--r--sdext/source/pdfimport/tree/writertreevisiting.cxx33
2 files changed, 33 insertions, 43 deletions
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index e722dc3cd680..832d35569630 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -355,8 +355,8 @@ void DrawXmlEmitter::visit( PageElement& elem, const std::list< Element* >::cons
if( m_rEmitContext.xStatusIndicator.is() )
m_rEmitContext.xStatusIndicator->setValue( elem.PageNumber );
- std::list< Element* >::iterator this_it = elem.Children.begin();
- while( this_it !=elem.Children.end() && *this_it != &elem )
+ std::list< Element* >::iterator this_it = elem.Children.begin();
+ while( this_it != elem.Children.end() && *this_it != &elem )
{
(*this_it)->visitedBy( *this, this_it );
++this_it;
@@ -371,8 +371,8 @@ void DrawXmlEmitter::visit( DocumentElement& elem, const std::list< Element* >::
m_rEmitContext.rEmitter.beginTag( m_bWriteDrawDocument ? "office:drawing" : "office:presentation",
PropertyMap() );
- std::list< Element* >::iterator this_it = elem.Children.begin();
- while( this_it !=elem.Children.end() && *this_it != &elem )
+ std::list< Element* >::iterator this_it = elem.Children.begin();
+ while( this_it != elem.Children.end() && *this_it != &elem )
{
(*this_it)->visitedBy( *this, this_it );
++this_it;
@@ -401,29 +401,28 @@ void DrawXmlOptimizer::visit( ImageElement&, const std::list< Element* >::const_
{
}
-void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& )
+void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& elemIt )
{
/* note: optimize two consecutive PolyPolyElements that
* have the same path but one of which is a stroke while
* the other is a fill
*/
- if( elem.Parent )
- {
- // find following PolyPolyElement in parent's children list
- std::list< Element* >::iterator this_it = elem.Parent->Children.begin();
- while( this_it != elem.Parent->Children.end() && *this_it != &elem )
- ++this_it;
+ if( !elem.Parent )
+ return;
- if( this_it != elem.Parent->Children.end() )
- {
- std::list< Element* >::iterator next_it = this_it;
- if( ++next_it != elem.Parent->Children.end() )
- {
- PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ // find following PolyPolyElement in parent's children list
+ if( elemIt == elem.Parent->Children.end() )
+ return;
+ std::list< Element* >::const_iterator next_it = elemIt;
+ ++next_it;
+ if( next_it == elem.Parent->Children.end() )
+ return;
+
+ PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ // TODO(F2): this comparison fails for OOo-generated polygons with beziers.
+ if( !pNext || pNext->PolyPoly != elem.PolyPoly )
+ return;
- // TODO(F2): this comparison fails for OOo-generated polygons with beziers.
- if( pNext && pNext->PolyPoly == elem.PolyPoly )
- {
const GraphicsContext& rNextGC =
m_rProcessor.getGraphicsContext( pNext->GCId );
const GraphicsContext& rThisGC =
@@ -455,10 +454,6 @@ void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >
elem.Parent->Children.erase( next_it );
delete pNext;
}
- }
- }
- }
- }
}
void DrawXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element* >::const_iterator& )
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index d880191700db..0844c6ee58b9 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -358,27 +358,26 @@ void WriterXmlOptimizer::visit( ImageElement&, const std::list< Element* >::cons
{
}
-void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& )
+void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& elemIt )
{
/* note: optimize two consecutive PolyPolyElements that
* have the same path but one of which is a stroke while
* the other is a fill
*/
- if( elem.Parent )
- {
- // find following PolyPolyElement in parent's children list
- std::list< Element* >::iterator this_it = elem.Parent->Children.begin();
- while( this_it != elem.Parent->Children.end() && *this_it != &elem )
- ++this_it;
+ if( !elem.Parent )
+ return;
+ // find following PolyPolyElement in parent's children list
+ if( elemIt == elem.Parent->Children.end() )
+ return;
+ std::list< Element* >::const_iterator next_it = elemIt;
+ ++next_it;
+ if( next_it == elem.Parent->Children.end() )
+ return;
+
+ PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ if( !pNext || pNext->PolyPoly != elem.PolyPoly )
+ return;
- if( this_it != elem.Parent->Children.end() )
- {
- std::list< Element* >::iterator next_it = this_it;
- if( ++next_it != elem.Parent->Children.end() )
- {
- PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
- if( pNext && pNext->PolyPoly == elem.PolyPoly )
- {
const GraphicsContext& rNextGC =
m_rProcessor.getGraphicsContext( pNext->GCId );
const GraphicsContext& rThisGC =
@@ -406,10 +405,6 @@ void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element*
elem.Parent->Children.erase( next_it );
delete pNext;
}
- }
- }
- }
- }
}
void WriterXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element* >::const_iterator& rParentIt)