[poppler] poppler/qt: poppler-document.cc, 1.14, 1.15 poppler-page-transition.cc, 1.4, 1.5 poppler-page.cc, 1.19, 1.20 poppler-private.h, 1.9, 1.10

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Apr 25 12:59:12 PDT 2007


Update of /cvs/poppler/poppler/qt
In directory kemper:/tmp/cvs-serv1447/qt

Modified Files:
	poppler-document.cc poppler-page-transition.cc poppler-page.cc 
	poppler-private.h 
Log Message:
Merge xpdf302branch in HEAD as noone vetoed it.
Testing more than welcome


Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-document.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- poppler-document.cc	24 Feb 2007 23:43:35 -0000	1.14
+++ poppler-document.cc	25 Apr 2007 19:59:10 -0000	1.15
@@ -18,7 +18,6 @@
 
 #include <poppler-qt.h>
 #include <qfile.h>
-#include <qimage.h>
 #include <GlobalParams.h>
 #include <Outline.h>
 #include <PDFDoc.h>
@@ -26,7 +25,6 @@
 #include <Catalog.h>
 #include <ErrorCodes.h>
 #include <SplashOutputDev.h>
-#include <UGooString.h>
 #include <splash/SplashBitmap.h>
 #include "poppler-private.h"
 
@@ -215,12 +213,12 @@
 
   if ( infoDict->lookup( (char*)type.latin1(), &obj )->isString() )
   {
-    s = UGooString(*obj.getString()).getCString();
-    const char *aux = s;
+    QString s = UnicodeParsedString(obj.getString());
     if ( s[0] == 'D' && s[1] == ':' )
-      s += 2;
+      s = s.mid(2);
+
     /* FIXME process time zone on systems that support it */  
-    if ( sscanf( s, "%4d%2d%2d%2d%2d%2d", &year, &mon, &day, &hour, &min, &sec ) == 6 )
+    if ( sscanf( s.latin1(), "%4d%2d%2d%2d%2d%2d", &year, &mon, &day, &hour, &min, &sec ) == 6 )
     {
       /* Workaround for y2k bug in Distiller 3 stolen from gpdf, hoping that it won't
        *   * be used after y2.2k */
@@ -233,7 +231,6 @@
 	else {
 	  obj.free();
 	  info.free();
-	  delete[] aux;
 	  return QDateTime();
 	}
       }
@@ -243,11 +240,9 @@
       if ( d.isValid() && t.isValid() ) {
 	obj.free();
 	info.free();
-	delete[] aux;
 	return QDateTime( d, t );
       }
     }
-    delete[] aux;
   }
   obj.free();
   info.free();
@@ -308,7 +303,7 @@
 
 LinkDestination *Document::linkDestination( const QString &name )
 {
-  UGooString * namedDest = QStringToUGooString( name );
+  GooString * namedDest = QStringToGooString( name );
   LinkDestinationData ldd(NULL, namedDest, data);
   LinkDestination *ld = new LinkDestination(ldd);
   delete namedDest;

Index: poppler-page-transition.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page-transition.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- poppler-page-transition.cc	4 Jan 2007 18:56:13 -0000	1.4
+++ poppler-page-transition.cc	25 Apr 2007 19:59:10 -0000	1.5
@@ -18,7 +18,6 @@
 
 #include "Object.h"
 #include "Error.h"
-#include "UGooString.h"
 #include "poppler-page-transition.h"
 #include "poppler-page-transition-private.h"
 

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-page.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- poppler-page.cc	7 Mar 2007 19:15:32 -0000	1.19
+++ poppler-page.cc	25 Apr 2007 19:59:10 -0000	1.20
@@ -76,7 +76,7 @@
   output_dev = data->doc->data->getOutputDev();
 
   data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, xres, yres,
-      0, false, false, doLinks, -1, -1, -1, -1);
+      0, false, true, false, -1, -1, -1, -1);
   bitmap = output_dev->getBitmap ();
   color_ptr = bitmap->getDataPtr ();
   int bw = output_dev->getBitmap()->getWidth();
@@ -235,7 +235,7 @@
   QValueList<Link*> popplerLinks;
 
 #if defined(HAVE_SPLASH)
-  Links *xpdfLinks = data->doc->data->doc.takeLinks();
+  Links *xpdfLinks = data->doc->data->doc.getLinks(data->index + 1);
   for (int i = 0; i < xpdfLinks->getNumLinks(); ++i)
   {
     ::Link *xpdfLink = xpdfLinks->getLink(i);

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-private.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- poppler-private.h	7 Mar 2007 19:15:32 -0000	1.9
+++ poppler-private.h	25 Apr 2007 19:59:10 -0000	1.10
@@ -24,7 +24,6 @@
 #include <Link.h>
 #include <PDFDoc.h>
 #include <FontInfo.h>
-#include <UGooString.h>
 #if defined(HAVE_SPLASH)
 #include <SplashOutputDev.h>
 #else
@@ -35,30 +34,62 @@
     
 /* borrowed from kpdf */
 static QString unicodeToQString(Unicode* u, int len) {
-  QString ret;
-  ret.setLength(len);
-  QChar* qch = (QChar*) ret.unicode();
-  for (;len;--len)
-    *qch++ = (QChar) *u++;
-  return ret;
+    QString ret;
+    ret.setLength(len);
+    QChar* qch = (QChar*) ret.unicode();
+    for (;len;--len)
+      *qch++ = (QChar) *u++;
+    return ret;
 }
 
-static UGooString *QStringToUGooString(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 UGooString(u, len);
+static GooString *QStringToGooString(const QString &s) {
+    int len = s.length();
+    char *cstring = (char *)gmallocn(s.length(), sizeof(char));
+    for (int i = 0; i < len; ++i)
+      cstring[i] = s.at(i).unicode();
+    return new GooString(cstring, len);
 }
-    
+
+static QString UnicodeParsedString(GooString *s1) {
+    GBool isUnicode;
+    int i;
+    Unicode u;
+    QString result;
+    if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff )
+    {
+        isUnicode = gTrue;
+        i = 2;
+    }
+    else
+    {
+        isUnicode = gFalse;
+        i = 0;
+    }
+    while ( i < s1->getLength() )
+    {
+        if ( isUnicode )
+        {
+            u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff );
+            i += 2;
+        }
+        else
+        {
+            u = s1->getChar(i) & 0xff;
+            ++i;
+        }
+        result += unicodeToQString( &u, 1 );
+    }
+    return result;
+}
+
 class LinkDestinationData {
   public:
-     LinkDestinationData( LinkDest *l, UGooString *nd, Poppler::DocumentData *pdfdoc ) : ld(l), namedDest(nd), doc(pdfdoc)
+     LinkDestinationData( LinkDest *l, GooString *nd, Poppler::DocumentData *pdfdoc ) : ld(l), namedDest(nd), doc(pdfdoc)
      {
      }
 	
      LinkDest *ld;
-     UGooString *namedDest;
+     GooString *namedDest;
      Poppler::DocumentData *doc;
 };
 
@@ -83,7 +114,7 @@
             white[0] = 255;
             white[1] = 255;
             white[2] = 255;
-            m_outputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, white);
+            m_outputDev = new SplashOutputDev(splashModeRGBX8, 4, gFalse, white);
             m_outputDev->startDoc(doc.getXRef());
         }
 #endif
@@ -121,9 +152,12 @@
                     // no 'destination' but an internal 'named reference'. we could
                     // get the destination for the page now, but it's VERY time consuming,
                     // so better storing the reference and provide the viewport on demand
-                    UGooString *s = g->getNamedDest();
-                    QString aux = unicodeToQString( s->unicode(), s->getLength() );
+                    GooString *s = g->getNamedDest();
+                    QChar *charArray = new QChar[s->getLength()];
+                    for (int i = 0; i < s->getLength(); ++i) charArray[i] = QChar(s->getCString()[i]);
+                    QString aux(charArray, s->getLength());
                     item.setAttribute( "DestinationName", aux );
+                    delete[] charArray;
                 }
                 else if ( destination && destination->isOk() )
                 {



More information about the poppler mailing list