--- ../orig/kdegraphics-3.5.6/kpdf/core/generator_pdf/generator_pdf.cpp	2007-01-15 11:21:55.000000000 +0000
+++ kpdf/core/generator_pdf/generator_pdf.cpp	2007-01-17 14:30:16.000000000 +0000
@@ -25,18 +25,23 @@
 #include <kmessagebox.h>
 #include <kdebug.h>
 
-// xpdf includes
-#include "xpdf/Object.h"
-#include "xpdf/Dict.h"
-#include "xpdf/Annot.h"
-#include "xpdf/PSOutputDev.h"
-#include "xpdf/TextOutputDev.h"
-#include "xpdf/Link.h"
-#include "xpdf/ErrorCodes.h"
-#include "xpdf/UnicodeMap.h"
-#include "xpdf/Outline.h"
-#include "xpdf/UGString.h"
-#include "goo/GList.h"
+#include <stdlib.h>
+
+// poppler includes
+#include "poppler/poppler-page-transition.h"
+#include "poppler/Object.h"
+#include "poppler/Dict.h"
+#include "poppler/Annot.h"
+#include "poppler/PSOutputDev.h"
+#include "poppler/TextOutputDev.h"
+#include "poppler/Link.h"
+#include "poppler/ErrorCodes.h"
+#include "poppler/UnicodeMap.h"
+#include "poppler/Outline.h"
+#include "poppler/UGooString.h"
+#include "poppler/goo/GooString.h"
+#include "poppler/goo/GooList.h"
+//#include "poppler/poppler-qt.h"
 
 // local includes
 #include "generator_pdf.h"
@@ -48,6 +53,8 @@
 
 #include <config.h>
 
+using namespace Poppler;
+
 // id for DATA_READY PDFPixmapGeneratorThread Event
 #define TGE_DATAREADY_ID 6969
 
@@ -103,7 +110,7 @@
     }
 #endif
     // create PDFDoc for the given file
-    pdfdoc = new PDFDoc( new GString( QFile::encodeName( filePath ) ), 0, 0 );
+    pdfdoc = new PDFDoc( new GooString( QFile::encodeName( filePath ) ), 0, 0 );
 
     // if the file didn't open correctly it might be encrypted, so ask for a pass
     bool firstInput = true;
@@ -150,9 +157,9 @@
         }
 
         // 2. reopen the document using the password
-        GString * pwd2 = new GString( password.data() );
+        GooString * pwd2 = new GooString( password.data() );
             delete pdfdoc;
-        pdfdoc = new PDFDoc( new GString( QFile::encodeName( filePath ) ), pwd2, pwd2 );
+        pdfdoc = new PDFDoc( new GooString( QFile::encodeName( filePath ) ), pwd2, pwd2 );
             delete pwd2;
 
         // 3. if the password is correct and the user chose to remember it, store it to the wallet
@@ -241,7 +248,7 @@
     if ( !outline )
         return NULL;
 
-    GList * items = outline->getItems();
+    GooList * items = outline->getItems();
     if ( !items || items->getLength() < 1 )
         return NULL;
 
@@ -446,12 +453,10 @@
         pstitle = m_document->currentDocument().fileName( false );
     }
     const char* pstitlechar = !pstitle.isEmpty() ? pstitle.local8Bit() : 0;
-    PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), pstitlechar, pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS, marginRight, marginBottom, paperWidth - marginLeft, paperHeight - marginTop);
+    PSOutputDev *psOut = new PSOutputDev((char*) tf.name().latin1(), pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS);
 
     if (psOut->isOk())
     {
-        std::list<int> pages;
-
         double xScale = ((double)paperWidth - (double)marginLeft - (double)marginRight) / (double)paperWidth;
         double yScale = ((double)paperHeight - (double)marginBottom - (double)marginTop) / (double)paperHeight;
 
@@ -470,17 +475,19 @@
             QValueList<int> pageList = printer.pageList();
             QValueList<int>::const_iterator it;
 
-            for(it = pageList.begin(); it != pageList.end(); ++it) pages.push_back(*it);
+	    docLock.lock();
+            for(it = pageList.begin(); it != pageList.end(); ++it)
+		pdfdoc->displayPages(psOut, *it, *it, 72, 72, 0, false, globalParams->getPSCrop(), gFalse);
+	    docLock.unlock();
         }
         else
         {
-            for(int i = 1; i <= pdfdoc->getNumPages(); i++) pages.push_back(i);
+	    docLock.lock();
+            for(int i = 1; i <= pdfdoc->getNumPages(); i++)
+		pdfdoc->displayPages(psOut, i, i, 72, 72, 0, false, globalParams->getPSCrop(), gFalse);
+	    docLock.unlock();
         }
 
-        docLock.lock();
-        pdfdoc->displayPages(psOut, pages, 72, 72, 0, false, globalParams->getPSCrop(), gFalse);
-        docLock.unlock();
-
         // needs to be here so that the file is flushed, do not merge with the one
         // in the else
         delete psOut;
@@ -494,12 +501,14 @@
     }
 }
 
-static UGString *QStringToUGString(const QString &s) {
+static UGooString *QStringToUGString(const QString &s) {
+    /*
     int len = s.length();
     Unicode *u = (Unicode *)gmallocn(s.length(), sizeof(Unicode));
     for (int i = 0; i < len; ++i)
       u[i] = s.at(i).unicode();
-    return new UGString(u, len);
+    */
+    return new UGooString(strdup(s.utf8()));
 }
 
 QString PDFGenerator::getMetaData( const QString & key, const QString & option )
@@ -507,7 +516,7 @@
     if ( key == "StartFullScreen" )
     {
         // asking for the 'start in fullscreen mode' (pdf property)
-        if ( pdfdoc->getCatalog()->getPageMode() == Catalog::FullScreen )
+        if ( pdfdoc->getCatalog()->getPageMode() == Catalog::pageModeFullScreen )
             return "yes";
     }
     else if ( key == "NamedViewport" && !option.isEmpty() )
@@ -515,7 +524,7 @@
         // asking for the page related to a 'named link destination'. the
         // option is the link name. @see addSynopsisChildren.
         DocumentViewport viewport;
-        UGString * namedDest = QStringToUGString( option );
+        UGooString * namedDest = QStringToUGString( option );
         docLock.lock();
         LinkDest * destination = pdfdoc->findDest( namedDest );
         if ( destination )
@@ -626,7 +635,7 @@
 {
     Ref fontRef, embRef;
     Object fontObj, toUnicodeObj;
-    GString *name;
+    GooString *name;
     GBool emb;
     int i;
 
@@ -665,7 +674,7 @@
         sName = name->getCString();
         if (!emb)
         {
-            DisplayFontParam *dfp = globalParams->getDisplayFont(name);
+            DisplayFontParam *dfp = globalParams->getDisplayFont(font);
             if (dfp)
             {
                 if (dfp -> kind == displayFontT1) sPath = dfp->t1.fileName->getCString();
@@ -706,13 +715,13 @@
 
     QString result;
     Object obj;
-    GString *s1;
+    GooString *s1;
     GBool isUnicode;
     Unicode u;
     int i;
     Dict *infoDict = info.getDict();
 
-    if ( infoDict->lookup( data.latin1(), &obj )->isString() )
+    if ( infoDict->lookup( (char*) data.latin1(), &obj )->isString() )
     {
         s1 = obj.getString();
         if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff )
@@ -770,9 +779,9 @@
     if ( !uMap )
         return i18n( "Unknown Date" );
 
-    if ( infoDict->lookup( data.latin1(), &obj )->isString() )
+    if ( infoDict->lookup( (char*) data.latin1(), &obj )->isString() )
     {
-        s = UGString(*obj.getString()).getCString();
+        s = UGooString(*obj.getString()).getCString();
         origS = s;
         if ( s[0] == 'D' && s[1] == ':' )
             s += 2;
@@ -797,7 +806,7 @@
     return result;
 }
 
-void PDFGenerator::addSynopsisChildren( QDomNode * parent, GList * items )
+void PDFGenerator::addSynopsisChildren( QDomNode * parent, GooList * items )
 {
     int numItems = items->getLength();
     for ( int i = 0; i < numItems; ++i )
@@ -828,8 +837,8 @@
                 // get the destination for the page now, but it's VERY time consuming,
                 // so better storing the reference and provide the viewport as metadata
                 // on demand
-                UGString *s = g->getNamedDest();
-                QString aux = unicodeToQString( s->unicode(), s->getLength() );
+                UGooString *s = g->getNamedDest();
+                QString aux = QString(s->getCString());
                 item.setAttribute( "ViewportName", aux );
             }
             else if ( destination && destination->isOk() )
@@ -847,7 +856,7 @@
 
         // 3. recursively descend over children
         outlineItem->open();
-        GList * children = outlineItem->getKids();
+        GooList * children = outlineItem->getKids();
         if ( children )
             addSynopsisChildren( &item, children );
     }
@@ -905,12 +914,13 @@
     if ( !pdfPage )
         return;
 
-    PageTransition *pdfTransition = pdfPage->getTransition();
-    if ( !pdfTransition || pdfTransition->getType() == PageTransition::Replace )
+    PageTransition *pdfTransition = NULL;
+    //PageTransition *pdfTransition = pdfPage->getTransition();
+    if ( !pdfTransition || pdfTransition->type() == PageTransition::Replace )
         return;
 
     KPDFPageTransition *transition = new KPDFPageTransition();
-    switch ( pdfTransition->getType() ) {
+    switch ( pdfTransition->type() ) {
         case PageTransition::Replace:
             // won't get here, added to avoid warning
             break;
@@ -949,9 +959,9 @@
             break;
     }
 
-    transition->setDuration( pdfTransition->getDuration() );
+    transition->setDuration( pdfTransition->duration() );
 
-    switch ( pdfTransition->getAlignment() ) {
+    switch ( pdfTransition->alignment() ) {
         case PageTransition::Horizontal:
             transition->setAlignment( KPDFPageTransition::Horizontal );
             break;
@@ -960,7 +970,7 @@
             break;
     }
 
-    switch ( pdfTransition->getDirection() ) {
+    switch ( pdfTransition->direction() ) {
         case PageTransition::Inward:
             transition->setDirection( KPDFPageTransition::Inward );
             break;
@@ -969,8 +979,8 @@
             break;
     }
 
-    transition->setAngle( pdfTransition->getAngle() );
-    transition->setScale( pdfTransition->getScale() );
+    transition->setAngle( pdfTransition->angle() );
+    transition->setScale( pdfTransition->scale() );
     transition->setIsRectangular( pdfTransition->isRectangular() == gTrue );
 
     page->setTransition( transition );
