[poppler] 4 commits - fofi/FoFiTrueType.cc glib/poppler-document.cc poppler/DateInfo.cc poppler/DateInfo.h qt4/src qt/poppler-document.cc utils/Makefile.am utils/pdfinfo.cc utils/pdftohtml.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Sep 9 14:27:17 PDT 2008


 fofi/FoFiTrueType.cc        |    2 +-
 glib/poppler-document.cc    |    6 ++++--
 poppler/DateInfo.cc         |   20 ++++++++++++++------
 poppler/DateInfo.h          |    2 +-
 qt/poppler-document.cc      |    6 ++++--
 qt4/src/poppler-document.cc |   24 ++++++++++++++++++++----
 utils/Makefile.am           |    2 ++
 utils/pdfinfo.cc            |    6 ++++--
 utils/pdftohtml.cc          |    6 ++++--
 9 files changed, 54 insertions(+), 20 deletions(-)

New commits:
commit 646ccc2bb8563d411dc25bdbab53725ae08572ba
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Sep 9 23:22:17 2008 +0200

    m_doc->doc->getOptContentConfig() can be null, so check for it

diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index c54d85b..cf94062 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -493,7 +493,7 @@ namespace Poppler {
 
     bool Document::hasOptionalContent() const
     {
-        return ( m_doc->doc->getOptContentConfig()->hasOCGs() );
+        return ( m_doc->doc->getOptContentConfig() && m_doc->doc->getOptContentConfig()->hasOCGs() );
     }
 
     OptContentModel *Document::optionalContentModel()
commit d7f0bce67101f37f8d3e69d7d701388bcdc7200f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Sep 9 23:18:49 2008 +0200

    Qt4 frontend had timezone parsing that got lost when moving to the common function, i suck

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 1d7e04f..622aff8 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -1508,7 +1508,8 @@ gboolean
 _poppler_convert_pdf_date_to_gtime (GooString *date,
 				    GTime     *gdate) 
 {
-  int year, mon, day, hour, min, sec;
+  int year, mon, day, hour, min, sec, tz_hour, tz_minute;
+  char tz;
   struct tm time;
   gchar *date_string, *ds;
   GTime result;
@@ -1523,7 +1524,8 @@ _poppler_convert_pdf_date_to_gtime (GooString *date,
   ds = date_string;
   
   /* See PDF Reference 1.3, Section 3.8.2 for PDF Date representation */
-  if (!parseDateString(ds, &year, &mon, &day, &hour, &min, &sec)) {
+  // TODO do something with the timezone information
+  if (!parseDateString(ds, &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute)) {
     g_free (ds);
     return FALSE;
   }
diff --git a/poppler/DateInfo.cc b/poppler/DateInfo.cc
index b9e1c0a..6fac732 100644
--- a/poppler/DateInfo.cc
+++ b/poppler/DateInfo.cc
@@ -23,19 +23,27 @@
 #include <string.h>
 
 /* See PDF Reference 1.3, Section 3.8.2 for PDF Date representation */
-/* FIXME only year is mandatory */
-/* FIXME parse optional timezone offset <- It seems Adobe Reader does not do it? */
-GBool parseDateString(const char *dateString, int *year, int *month, int *day, int *hour, int *minute, int *second)
+GBool parseDateString(const char *dateString, int *year, int *month, int *day, int *hour, int *minute, int *second, char *tz, int *tzHour, int *tzMinute)
 {
     if ( dateString == NULL ) return gFalse;
     if ( strlen(dateString) < 2 ) return gFalse;
 
     if ( dateString[0] == 'D' && dateString[1] == ':' )
         dateString += 2;
+
+    *month = 1;
+    *day = 1;
+    *hour = 0;
+    *minute = 0;
+    *second = 0;
+    *tz = 0x00;
+    *tzHour = 0;
+    *tzMinute = 0;
+
     if ( sscanf( dateString,
-                 "%4d%2d%2d%2d%2d%2d",
-                 year, month, day, hour, minute, second ) == 6 )
-    {
+                 "%4d%2d%2d%2d%2d%2d%c%2d%*c%2d",
+                 year, month, day, hour, minute, second,
+                 tz, tzHour, tzMinute ) > 0 ) {
         /* Workaround for y2k bug in Distiller 3 stolen from gpdf, hoping that it won't
         * be used after y2.2k */
         if ( *year < 1930 && strlen (dateString) > 14)
diff --git a/poppler/DateInfo.h b/poppler/DateInfo.h
index 6b11923..c3e237e 100644
--- a/poppler/DateInfo.h
+++ b/poppler/DateInfo.h
@@ -22,6 +22,6 @@
 
 #include "goo/gtypes.h"
 
-GBool parseDateString(const char *string, int *year, int *month, int *day, int *hour, int *minute, int *second);
+GBool parseDateString(const char *string, int *year, int *month, int *day, int *hour, int *minute, int *second, char *tz, int *tzHour, int *tzMinute);
 
 #endif
diff --git a/qt/poppler-document.cc b/qt/poppler-document.cc
index c5282fc..8b92397 100644
--- a/qt/poppler-document.cc
+++ b/qt/poppler-document.cc
@@ -221,14 +221,16 @@ QDateTime Document::getDate( const QString & type ) const
   }
 
   Object obj;
-  int year, mon, day, hour, min, sec;
+  int year, mon, day, hour, min, sec, tz_hour, tz_minute;
+  char tz;
   Dict *infoDict = info.getDict();
   QString result;
 
   if ( infoDict->lookup( (char*)type.latin1(), &obj )->isString() )
   {
     QString s = UnicodeParsedString(obj.getString());
-    if ( parseDateString( s.latin1(), &year, &mon, &day, &hour, &min, &sec ) )
+    // TODO do something with the timezone information
+    if ( parseDateString( s.latin1(), &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) )
     {
       QDate d( year, mon, day );  //CHECK: it was mon-1, Jan->0 (??)
       QTime t( hour, min, sec );
diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 623d590..c54d85b 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -521,14 +521,30 @@ namespace Poppler {
 
     QDateTime convertDate( char *dateString )
     {
-        int year, mon, day, hour, min, sec;
+        int year, mon, day, hour, min, sec, tzHours, tzMins;
+        char tz;
 
-        if ( parseDateString( dateString, &year, &mon, &day, &hour, &min, &sec ) )
+        if ( parseDateString( dateString, &year, &mon, &day, &hour, &min, &sec, &tz, &tzHours, &tzMins ) )
         {
             QDate d( year, mon, day );
             QTime t( hour, min, sec );
             if ( d.isValid() && t.isValid() ) {
-                return QDateTime( d, t );
+                QDateTime dt( d, t, Qt::UTC );
+                if ( tz ) {
+                    // then we have some form of timezone
+                    if ( 'Z' == tz  ) {
+                        // We are already at UTC
+                    } else if ( '+' == tz ) {
+                        // local time is ahead of UTC
+                        dt = dt.addSecs(-1*((tzHours*60)+tzMins)*60);
+                    } else if ( '-' == tz ) {
+                        // local time is behind UTC
+                        dt = dt.addSecs(((tzHours*60)+tzMins)*60);
+                    } else {
+                        qWarning("unexpected tz val");
+                    }
+                }
+		return dt;
             }
         }
         return QDateTime();
diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc
index 9b13dd1..9063f87 100644
--- a/utils/pdfinfo.cc
+++ b/utils/pdfinfo.cc
@@ -370,14 +370,16 @@ static void printInfoString(Dict *infoDict, char *key, char *text,
 static void printInfoDate(Dict *infoDict, char *key, char *text) {
   Object obj;
   char *s;
-  int year, mon, day, hour, min, sec;
+  int year, mon, day, hour, min, sec, tz_hour, tz_minute;
+  char tz;
   struct tm tmStruct;
   char buf[256];
 
   if (infoDict->lookup(key, &obj)->isString()) {
     fputs(text, stdout);
     s = obj.getString()->getCString();
-    if ( parseDateString( s, &year, &mon, &day, &hour, &min, &sec ) ) {
+    // TODO do something with the timezone info
+    if ( parseDateString( s, &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) ) {
       tmStruct.tm_year = year - 1900;
       tmStruct.tm_mon = mon - 1;
       tmStruct.tm_mday = day;
diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc
index 1c29fe6..41312de 100644
--- a/utils/pdftohtml.cc
+++ b/utils/pdftohtml.cc
@@ -407,14 +407,16 @@ static GooString* getInfoString(Dict *infoDict, char *key) {
 static GooString* getInfoDate(Dict *infoDict, char *key) {
   Object obj;
   char *s;
-  int year, mon, day, hour, min, sec;
+  int year, mon, day, hour, min, sec, tz_hour, tz_minute;
+  char tz;
   struct tm tmStruct;
   GooString *result = NULL;
   char buf[256];
 
   if (infoDict->lookup(key, &obj)->isString()) {
     s = obj.getString()->getCString();
-    if ( parseDateString( s, &year, &mon, &day, &hour, &min, &sec ) ) {
+    // TODO do something with the timezone info
+    if ( parseDateString( s, &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) ) {
       tmStruct.tm_year = year - 1900;
       tmStruct.tm_mon = mon - 1;
       tmStruct.tm_mday = day;
commit 0af8609e6c932de2d85168cc9147854ee84b3a1b
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Sep 9 20:55:27 2008 +0200

    i want this packaged too

diff --git a/utils/Makefile.am b/utils/Makefile.am
index 690ef18..342fa73 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -67,6 +67,7 @@ pdfimages_SOURCES =				\
 pdfinfo_SOURCES =				\
 	pdfinfo.cc				\
 	printencodings.cc			\
+	printencodings.h			\
 	$(common)
 
 pdftops_SOURCES =				\
@@ -76,6 +77,7 @@ pdftops_SOURCES =				\
 pdftotext_SOURCES =				\
 	pdftotext.cc				\
 	printencodings.cc			\
+	printencodings.h			\
 	$(common)
 
 pdftohtml_SOURCES =				\
commit dd0f4c1510382e17cf33d3fe163e384da1d6d289
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Sep 9 20:48:04 2008 +0200

    Fix includepath

diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index 9a81d3d..1e903c5 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -37,7 +37,7 @@
 #include "goo/GooHash.h"
 #include "FoFiType1C.h"
 #include "FoFiTrueType.h"
-#include "Error.h"
+#include "poppler/Error.h"
 
 //
 // Terminology


More information about the poppler mailing list