[poppler] 5 commits - configure.ac glib/poppler-annot.cc glib/poppler-annot.h poppler/Annot.cc poppler/Annot.h poppler/DateInfo.cc poppler/DateInfo.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Fri Apr 24 01:15:14 PDT 2009


 configure.ac          |    1 +
 glib/poppler-annot.cc |    1 +
 glib/poppler-annot.h  |    1 +
 poppler/Annot.cc      |   28 +++++++++++++++++-----------
 poppler/Annot.h       |   11 +++++++----
 poppler/DateInfo.cc   |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 poppler/DateInfo.h    |    8 ++++++++
 7 files changed, 83 insertions(+), 15 deletions(-)

New commits:
commit fb6e7141e3008ae230ae5819e2c7a0425296d8d2
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Fri Apr 24 10:13:53 2009 +0200

    Update copyright headers

diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 58a2478..e97f705 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -1,6 +1,7 @@
 /* poppler-annot.cc: glib interface to poppler
  *
  * Copyright (C) 2007 Inigo Martinez <inigomartinez at gmail.com>
+ * Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index 714e87b..76983cb 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -1,6 +1,7 @@
 /* poppler-annot.h: glib interface to poppler
  *
  * Copyright (C) 2007 Inigo Martinez <inigomartinez at gmail.com>
+ * Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 63d370e..8f3296e 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -16,7 +16,7 @@
 // Copyright (C) 2006 Scott Turner <scotty1024 at mac.com>
 // Copyright (C) 2007, 2008 Julien Rebetez <julienr at svn.gnome.org>
 // Copyright (C) 2007-2009 Albert Astals Cid <aacid at kde.org>
-// Copyright (C) 2007, 2008 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2007-2009 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez at gmail.com>
 // Copyright (C) 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2008 Pino Toscano <pino at kde.org>
diff --git a/poppler/Annot.h b/poppler/Annot.h
index c669104..5d9aad1 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006 Scott Turner <scotty1024 at mac.com>
 // Copyright (C) 2007, 2008 Julien Rebetez <julienr at svn.gnome.org>
-// Copyright (C) 2007, 2008 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2007-2009 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez at gmail.com>
 // Copyright (C) 2008 Michael Vrable <mvrable at cs.ucsd.edu>
 // Copyright (C) 2008 Hugo Mercier <hmercier31 at gmail.com>
diff --git a/poppler/DateInfo.cc b/poppler/DateInfo.cc
index f2be57d..563204a 100644
--- a/poppler/DateInfo.cc
+++ b/poppler/DateInfo.cc
@@ -3,6 +3,7 @@
 // DateInfo.cc
 //
 // Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/poppler/DateInfo.h b/poppler/DateInfo.h
index a0c3942..116350f 100644
--- a/poppler/DateInfo.h
+++ b/poppler/DateInfo.h
@@ -3,6 +3,7 @@
 // DateInfo.h
 //
 // Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
commit fc7e52fef0317f9c85ead2c4f8a0e9b688decca3
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Fri Apr 24 09:53:41 2009 +0200

    Fix typos in Annot::setContents() documentation

diff --git a/poppler/Annot.h b/poppler/Annot.h
index 49c6ef0..c669104 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -497,7 +497,7 @@ public:
 
   double getFontSize() { return fontSize; }
 
-  // Sets the annotn contents to new_conten
+  // Sets the annot contents to new_content
   // new_content should never be NULL
   void setContents(GooString *new_content);
   
commit df0032cf5f6e5dc44bad056c659180e4065d32e2
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Thu Apr 23 13:19:25 2009 +0200

    Document Annot::setContents() method

diff --git a/poppler/Annot.h b/poppler/Annot.h
index a2c09e3..49c6ef0 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -497,6 +497,8 @@ public:
 
   double getFontSize() { return fontSize; }
 
+  // Sets the annotn contents to new_conten
+  // new_content should never be NULL
   void setContents(GooString *new_content);
   
   // getters
commit 86a37a8f3f93e3378b446f8d81d80571267c7660
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Thu Apr 23 13:16:04 2009 +0200

    Update the annotation last modified time when it's modified

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index b6bb7d9..63d370e 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -56,6 +56,7 @@
 #include "OptionalContent.h"
 #include "Sound.h"
 #include "FileSpec.h"
+#include "DateInfo.h"
 #include <string.h>
 
 #define annotFlagHidden    0x0002
@@ -985,6 +986,20 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
   }
 }
 
+void Annot::update(const char *key, Object *value) {
+  /* Set M to current time */
+  delete modified;
+  modified = timeToDateString(NULL);
+
+  Object obj1;
+  obj1.initString (modified->copy());
+  annotObj.dictSet("M", &obj1);
+
+  annotObj.dictSet(const_cast<char*>(key), value);
+  
+  xref->setModifiedObject(&annotObj, ref);
+}
+
 void Annot::setContents(GooString *new_content) {
   delete contents;
 
@@ -1001,9 +1016,7 @@ void Annot::setContents(GooString *new_content) {
   
   Object obj1;
   obj1.initString(contents->copy());
-
-  annotObj.dictSet("Contents", &obj1);
-  xref->setModifiedObject(&annotObj, ref);
+  update ("Contents", &obj1);
 }
 	
 double Annot::getXMin() {
@@ -1347,13 +1360,6 @@ AnnotText::~AnnotText() {
   delete icon;
 }
 
-void AnnotText::setModified(GooString *date) {
-  if (date) {
-    delete modified;
-    modified = new GooString(date);
-  }
-}
-
 void AnnotText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
   Object obj1;
 
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 45e4ebe..a2c09e3 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -528,6 +528,10 @@ protected:
   void drawCircleTopLeft(double cx, double cy, double r);
   void drawCircleBottomRight(double cx, double cy, double r);
 
+  // Updates the field key of the annotation dictionary
+  // and sets M to the current time
+  void update(const char *key, Object *value);
+
   Object annotObj;
   
   // required data
@@ -649,9 +653,6 @@ public:
   GooString *getIcon() const { return icon; }
   AnnotTextState getState() const { return state; }
 
-  // setters
-  void setModified(GooString *date);
-
 private:
 
   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
commit 9662bfa2b4b2282d0fc29d2a327b62d8bde56ff2
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Thu Apr 23 13:13:07 2009 +0200

    Add timeToDateString() to DateInfo
    
    This function converts a time_t into a string in PDF date format.

diff --git a/configure.ac b/configure.ac
index e0d531e..37e08b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,7 @@ AC_PROG_CXX
 AC_PROG_INSTALL
 AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))
 AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system]))
+AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system]))
 
 dnl ##### Check for pkgconfig
 PKG_PROG_PKG_CONFIG
diff --git a/poppler/DateInfo.cc b/poppler/DateInfo.cc
index 6fac732..f2be57d 100644
--- a/poppler/DateInfo.cc
+++ b/poppler/DateInfo.cc
@@ -17,6 +17,8 @@
 //
 //========================================================================
 
+#include <config.h>
+
 #include "DateInfo.h"
 
 #include <stdio.h>
@@ -68,3 +70,48 @@ GBool parseDateString(const char *dateString, int *year, int *month, int *day, i
 
    return gFalse;
 }
+
+
+GooString *timeToDateString(time_t *timet) {
+  GooString *dateString;
+  char s[5];
+  struct tm *gt;
+  size_t len;
+  time_t timep = timet ? *timet : time(NULL);
+  
+#ifdef HAVE_GMTIME_R
+  struct tm t;
+  gt = gmtime_r (&timep, &t);
+#else
+  gt = gmtime (&timep);
+#endif
+
+  dateString = new GooString ("D:");
+
+  /* Year YYYY */
+  len = strftime (s, sizeof(s), "%Y", gt);
+  dateString->append (s, len);
+
+  /* Month MM */
+  len = strftime (s, sizeof(s), "%m", gt);
+  dateString->append (s, len);
+
+  /* Day DD */
+  len = strftime (s, sizeof(s), "%d", gt);
+  dateString->append (s, len);
+
+  /* Hour HH */
+  len = strftime (s, sizeof(s), "%H", gt);
+  dateString->append (s, len);
+
+  /* Minute mm */
+  len = strftime (s, sizeof(s), "%M", gt);
+  dateString->append (s, len);
+
+  /* Second SS */
+  len = strftime (s, sizeof(s), "%S", gt);
+  dateString->append (s, len);
+
+  return dateString;
+}
+
diff --git a/poppler/DateInfo.h b/poppler/DateInfo.h
index c3e237e..a0c3942 100644
--- a/poppler/DateInfo.h
+++ b/poppler/DateInfo.h
@@ -21,7 +21,14 @@
 #define DATE_INFO_H
 
 #include "goo/gtypes.h"
+#include "goo/GooString.h"
+#include <time.h>
 
 GBool parseDateString(const char *string, int *year, int *month, int *day, int *hour, int *minute, int *second, char *tz, int *tzHour, int *tzMinute);
 
+/* Converts the time_t into a PDF Date format string.
+ * If timet is NULL, current time is used.
+ */
+GooString *timeToDateString(time_t *timet);
+
 #endif


More information about the poppler mailing list