[poppler] 4 commits - poppler/Annot.cc poppler/Annot.h

Pino Toscano pino at kemper.freedesktop.org
Fri Apr 4 18:23:24 PDT 2008


 poppler/Annot.cc |   75 ++++++++++++++++++++++++++++++++++++++++++++++---------
 poppler/Annot.h  |   22 +++++++++++++++-
 2 files changed, 84 insertions(+), 13 deletions(-)

New commits:
commit 95d9d2362534c0524ad0448818b2d69b0909d482
Author: Pino Toscano <pino at kde.org>
Date:   Sat Apr 5 03:23:00 2008 +0200

    finally, load the QuadPoints correctly
    
    when checking the validity of the coordinate, do the comparison just with the proper one (either X or Y);
    free the "point" object after each iteration

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 420c652..19c5f75 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -190,12 +190,17 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
         Object obj;
         if (array->get(i * 8 + j, &obj)->isNum()) {
           quadArray[j] = obj.getNum();
-          if (quadArray[j] < rect->x1 || quadArray[j] > rect->x2 ||
-              quadArray[j] < rect->y1 || quadArray[j] < rect->y2)
-            correct = gFalse;
+          if (j % 2 == 1) {
+              if (quadArray[j] < rect->y1 || quadArray[j] > rect->y2)
+                  correct = gFalse;
+          } else {
+              if (quadArray[j] < rect->x1 || quadArray[j] > rect->x2)
+                  correct = gFalse;
+          }
         } else {
             correct = gFalse;
         }
+        obj.free();
       }
 
       if (correct)
commit af1ffcbcec1730332d11f8da4a7ddac833b22408
Author: Pino Toscano <pino at kde.org>
Date:   Sat Apr 5 02:54:00 2008 +0200

    More robust reading of QuadPoints (reset the allocated memory, use the heap)

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 8d7ecc4..420c652 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -30,6 +30,7 @@
 #include "Page.h"
 #include "XRef.h"
 #include "Movie.h"
+#include <string.h>
 
 #define annotFlagHidden    0x0002
 #define annotFlagPrint     0x0004
@@ -170,7 +171,7 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
   GBool correct = gTrue;
   int quadsLength = 0;
   AnnotQuadrilateral **quads;
-  double *quadArray;
+  double quadArray[8];
 
   // default values
   quadrilaterals = NULL;
@@ -182,7 +183,7 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
     quadsLength = arrayLength / 8;
     quads = (AnnotQuadrilateral **) gmallocn
         ((quadsLength), sizeof(AnnotQuadrilateral *));
-    quadArray = (double *) gmallocn (8, sizeof(double));
+    memset(quads, 0, quadsLength * sizeof(AnnotQuadrilateral *));
 
     while (i < (quadsLength) && correct) {
       for (int j = 0; j < 8 && correct; j++) {
@@ -205,8 +206,6 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
       i++;
     }
 
-    gfree (quadArray);
-
     if (correct) {
       quadrilateralsLength = quadsLength;
       quadrilaterals = quads;
commit 68fd98d69bac20282665cf6b824da30c3b310f0b
Author: Pino Toscano <pino at kde.org>
Date:   Sat Apr 5 02:51:41 2008 +0200

    Really implement AnnotTextMarkup.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index b0ca4a3..8d7ecc4 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1671,9 +1671,30 @@ void AnnotLine::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
 // AnnotTextMarkup
 //------------------------------------------------------------------------
 
+AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
+  AnnotMarkup(xrefA, dict, catalog, obj) {
+  // the real type will be read in initialize()
+  type = typeHighlight;
+  initialize(xrefA, catalog, dict);
+}
+
 void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
   Object obj1;
 
+  if (dict->lookup("Subtype", &obj1)->isName()) {
+    GooString typeName(obj1.getName());
+    if (!typeName.cmp("Highlight")) {
+      type = typeHighlight;
+    } else if (!typeName.cmp("Underline")) {
+      type = typeUnderline;
+    } else if (!typeName.cmp("Squiggly")) {
+      type = typeSquiggly;
+    } else if (!typeName.cmp("StrikeOut")) {
+      type = typeStrikeOut;
+    }
+  }
+  obj1.free();
+
   if(dict->lookup("QuadPoints", &obj1)->isArray()) {
     quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect);
   } else {
@@ -3373,13 +3394,13 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj
     } else if (!typeName->cmp("PolyLine")) {
       annot = new Annot(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Highlight")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Underline")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Squiggly")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
     } else if (!typeName->cmp("StrikeOut")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Stamp")) {
       annot = new AnnotStamp(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Caret")) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 3198049..d08b176 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -895,7 +895,7 @@ protected:
 class AnnotTextMarkup: public AnnotMarkup {
 public:
 
-  AnnotTextMarkup(XRef *xrefA, Catalog *catalog, Dict *dict);
+  AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
   virtual ~AnnotTextMarkup();
 
   AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
commit 69a2ecfaf8f8cffd3027db5c3cc88c41413e42f1
Author: Pino Toscano <pino at kde.org>
Date:   Sat Apr 5 01:38:28 2008 +0200

    Add the Stamp annotation type.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index a92ebd6..b0ca4a3 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -3285,6 +3285,32 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
 }
 
 //------------------------------------------------------------------------
+// AnnotStamp
+//------------------------------------------------------------------------
+ 
+AnnotStamp::AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
+  AnnotMarkup(xrefA, dict, catalog, obj) {
+  type = typeStamp;
+  initialize(xrefA, catalog, dict);
+}
+
+AnnotStamp::~AnnotStamp() {
+  delete icon;
+}
+
+void AnnotStamp::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
+  Object obj1;
+
+  if (dict->lookup("Name", &obj1)->isName()) {
+    icon = new GooString(obj1.getName());
+  } else {
+    icon = new GooString("Draft");
+  }
+  obj1.free();
+
+}
+
+//------------------------------------------------------------------------
 // Annots
 //------------------------------------------------------------------------
 
@@ -3355,7 +3381,7 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj
     } else if (!typeName->cmp("StrikeOut")) {
       annot = new Annot(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Stamp")) {
-      annot = new Annot(xref, dict, catalog, obj);
+      annot = new AnnotStamp(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Caret")) {
       annot = new Annot(xref, dict, catalog, obj);
     } else if (!typeName->cmp("Ink")) {
diff --git a/poppler/Annot.h b/poppler/Annot.h
index dbe1d52..3198049 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -908,6 +908,26 @@ protected:
 };
 
 //------------------------------------------------------------------------
+// AnnotStamp
+//------------------------------------------------------------------------
+
+class AnnotStamp: public AnnotMarkup {
+public:
+
+  AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
+  ~AnnotStamp();
+
+  // getters
+  GooString *getIcon() const { return icon; }
+
+private:
+
+  void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
+
+  GooString *icon;                  // Name       (Default Draft)
+};
+
+//------------------------------------------------------------------------
 // AnnotWidget
 //------------------------------------------------------------------------
 


More information about the poppler mailing list