Fix functionality broken by commit a9bbaa83

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/38/head
Michele Calgaro 1 year ago
parent a9bbaa83cc
commit c2fdb394e6
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -19,6 +19,8 @@
#include <config.h> #include <config.h>
#include <list>
#include <kgenericfactory.h> #include <kgenericfactory.h>
#include <KoStoreDevice.h> #include <KoStoreDevice.h>
#include <KoFilterChain.h> #include <KoFilterChain.h>
@ -26,7 +28,6 @@
#include <kprkword.h> #include <kprkword.h>
#include <tdelocale.h> #include <tdelocale.h>
#include <kdebug.h> #include <kdebug.h>
#include <tqptrlist.h>
#include <tqcolor.h> #include <tqcolor.h>
typedef KGenericFactory<KprKword, KoFilter> KprKwordFactory; typedef KGenericFactory<KprKword, KoFilter> KprKwordFactory;
@ -177,8 +178,7 @@ void KprKword::convert()
if ( objects.isNull() ) if ( objects.isNull() )
return; return;
TQPtrList< KprObject > objList; std::list<KprObject*> objList;
objList.setAutoDelete( true );
TQDomNodeList lst = objects.elementsByTagName( "OBJECT" ); TQDomNodeList lst = objects.elementsByTagName( "OBJECT" );
uint lstcount = lst.count(); uint lstcount = lst.count();
@ -193,21 +193,22 @@ void KprKword::convert()
KprObject * obj = new KprObject; KprObject * obj = new KprObject;
obj->y = orig.attribute( "y" ).toDouble(); obj->y = orig.attribute( "y" ).toDouble();
obj->elem = object; obj->elem = object;
objList.inSort( obj ); objList.push_back(obj);
} }
} }
} }
objList.sort([](KprObject *a, KprObject *b) { return *a < *b; });
int curPage = -1; int curPage = -1;
//kdDebug() << "found " << objList.count() << " objects" << endl; //kdDebug() << "found " << objList.size() << " objects" << endl;
for ( TQPtrListIterator<KprObject> it(objList); it.current(); ++it ) for (KprObject *obj : objList)
{ {
TQDomElement elem = it.current()->elem; TQDomElement elem = obj->elem;
// Detect the first object of each page // Detect the first object of each page
int page = int( it.current()->y / ptPageHeight ); int page = int( obj->y / ptPageHeight );
bool isTitle = ( page > curPage ); bool isTitle = ( page > curPage );
//kdDebug() << "KprKword::convert y=" << it.current()->y << " ptPageHeight=" << ptPageHeight //kdDebug() << "KprKword::convert y=" << obj->y << " ptPageHeight=" << ptPageHeight
// << " isTitle=" << isTitle << endl; // << " isTitle=" << isTitle << endl;
curPage = page; curPage = page;
@ -461,6 +462,11 @@ void KprKword::convert()
isTitle = false; isTitle = false;
} }
} }
for (KprObject *obj : objList)
{
delete obj;
}
} }
#include <kprkword.moc> #include <kprkword.moc>

Loading…
Cancel
Save